|
eZ Publish
[trunk]
|
00001 <?php 00002 /** 00003 * File containing the eZURLAliasFilter class. 00004 * 00005 * @copyright Copyright (C) 1999-2012 eZ Systems AS. All rights reserved. 00006 * @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 00007 * @version //autogentag// 00008 * @package kernel 00009 */ 00010 00011 /** 00012 * The eZURLAliasFilter class the interface for all url alias filters, 00013 * the filter implementation must implement the process method. 00014 * 00015 * For execution of the configured filters use the static method processFilters. 00016 * Help with configuration is found in settings/site.ini under the group URLTranslator. 00017 * 00018 * @abstract 00019 */ 00020 00021 abstract class eZURLAliasFilter 00022 { 00023 /** 00024 * Initialize the filter object. 00025 */ 00026 public function eZURLAliasFilter() 00027 { 00028 } 00029 00030 /* 00031 * 00032 * Process the url alias element $text and return the new element as a string. 00033 * This method must be overriden in custom URL alias filters. 00034 * 00035 * This function has not been declared as "abstract" because of backward compatibility 00036 * but you should see it as an abstract method. 00037 * 00038 * @abstract 00039 * @param string $text The URL alias 00040 * @param string $languageObject The current language object used for the string $text. 00041 * @param object $caller The object which called the filtering process, can be null. 00042 * @return string the processed URL alias 00043 */ 00044 public function process( $text, &$languageObject, &$caller ) 00045 { 00046 return $text; 00047 } 00048 00049 /** 00050 * 00051 * Process all configured filters and return the resulting text. 00052 * 00053 * Filters are found in the INI group URLTranslator and the setting Filters. 00054 * This is done in combination with the setting Extensions which controls 00055 * which extensions have filter classes. 00056 * 00057 * The parameters $text, $languageObject and $caller are sent to the method 00058 * process on the filter object. 00059 * 00060 * Note: The filter list will be cached in memory to improve performance of subsequent calls. 00061 * 00062 * @static 00063 * @param string $text The URL alias 00064 * @param string $languageObject The current language object used for the string $text. 00065 * @param object $caller The object which called the filtering process, can be null. 00066 * @return string the URL alias processed by the process() method 00067 */ 00068 public static function processFilters( $text, $languageObject, $caller ) 00069 { 00070 $ini = eZINI::instance( 'site.ini' ); 00071 $filterClassList = $ini->variable( 'URLTranslator', 'FilterClasses' ); 00072 00073 foreach ( $filterClassList as $filterClass ) 00074 { 00075 if( !class_exists( $filterClass ) ) 00076 { 00077 eZDebug::writeError( $filterClass . ' does not exist, please run bin/php/ezpgenerateautoload.php', __METHOD__ ); 00078 continue; 00079 } 00080 00081 $filter = new $filterClass(); 00082 $text = $filter->process( $text, $languageObject, $caller ); 00083 } 00084 00085 return $text; 00086 } 00087 } 00088 00089 ?>