1<?php 2// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 3// 4// All Rights Reserved. See copyright.txt for details and a complete list of authors. 5// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 6// $Id$ 7 8/** 9 * Class TikiFilter_Lang 10 * 11 * Filters for valid language values 12 */ 13class TikiFilter_Lang implements Zend\Filter\FilterInterface 14{ 15 /** 16 * Based on is_valid_language() method in lib/language/Language.php. The Language class isn't used here because 17 * necessary classes/definitions are not available at the point the filter is used in the installer 18 * 19 * @param mixed $input 20 * @return mixed|string 21 */ 22 function filter($input) 23 { 24 $filtered = preg_filter('/^[a-zA-Z-_]*$/', '$0', $input); 25 return $filtered && file_exists('lang/' . $filtered . '/language.php') ? $filtered : ''; 26 } 27} 28