eZ Publish  [trunk]
ezurlaliasfilterappendnodeid.php
Go to the documentation of this file.
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  * This class is an URL alias filter to be run with the eZURLAliasFilter system
00013  *
00014  * It appends the value of the nodeID in the URL so the contents can be for
00015  * example indexed by Google for its Google News
00016  */
00017 class eZURLAliasFilterAppendNodeID extends eZURLAliasFilter
00018 {
00019     /**
00020      * Empty constructor
00021      */
00022     public function __construct() {}
00023 
00024     /**
00025      * Append the node ID of the object being published
00026      * So its URL alias will look like :
00027      * someurlalias-<nodeID>
00028      *
00029      * @param string The text of the URL alias
00030      * @param object The eZContentObject object being published
00031      * @params object The eZContentObjectTreeNode in which the eZContentObject is published
00032      * @return string The transformed URL alias with the nodeID
00033      */
00034     public function process( $text, &$languageObject, &$caller )
00035     {
00036         if( !$caller instanceof eZContentObjectTreeNode )
00037         {
00038             eZDebug::writeError( 'The caller variable was not an eZContentObjectTreeNode', __METHOD__ );
00039             return $text;
00040         }
00041 
00042         $ini = eZINI::instance( 'site.ini' );
00043         $applyOnClassList = $ini->variable( 'AppendNodeIDFilterSettings', 'ApplyOnClass' );
00044 
00045         $classIdentifier = $caller->attribute( 'class_identifier' );
00046 
00047         if( in_array( $classIdentifier, $applyOnClassList ) )
00048         {
00049             $separator  = eZCharTransform::wordSeparator();
00050             $text .= $separator . $caller->attribute( 'node_id' );
00051         }
00052 
00053         return $text;
00054     }
00055 }
00056 ?>