eZ Publish  [4.0]
ezurltranslator.php
Go to the documentation of this file.
00001 <?php
00002 //
00003 // Definition of eZURLTranslator class
00004 //
00005 // Created on: <25-Nov-2002 09:49:11 amos>
00006 //
00007 // ## BEGIN COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00008 // SOFTWARE NAME: eZ Publish
00009 // SOFTWARE RELEASE: 4.0.x
00010 // COPYRIGHT NOTICE: Copyright (C) 1999-2008 eZ Systems AS
00011 // SOFTWARE LICENSE: GNU General Public License v2.0
00012 // NOTICE: >
00013 //   This program is free software; you can redistribute it and/or
00014 //   modify it under the terms of version 2.0  of the GNU General
00015 //   Public License as published by the Free Software Foundation.
00016 //
00017 //   This program is distributed in the hope that it will be useful,
00018 //   but WITHOUT ANY WARRANTY; without even the implied warranty of
00019 //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00020 //   GNU General Public License for more details.
00021 //
00022 //   You should have received a copy of version 2.0 of the GNU General
00023 //   Public License along with this program; if not, write to the Free
00024 //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00025 //   MA 02110-1301, USA.
00026 //
00027 //
00028 // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ##
00029 //
00030 
00031 /*! \file ezurltranslator.php
00032 */
00033 
00034 /*!
00035   \class eZURLTranslator ezurltranslator.php
00036   \brief Translation requested URLs into new URLs internally.
00037 
00038   Performs translation on supplied urls, currently only does tree node translation.
00039 
00040   \note This class is deprecated and not in use.
00041   \deprecated This class is deprecated and not in use.
00042 */
00043 
00044 //include_once( 'lib/ezutils/classes/ezini.php' );
00045 //include_once( 'kernel/classes/ezurlaliasml.php' );
00046 
00047 class eZURLTranslator
00048 {
00049     /*!
00050      Constructor
00051     */
00052     function eZURLTranslator()
00053     {
00054     }
00055 
00056     /*!
00057      Adds a new URL alias.
00058     */
00059     function addURLAlias( $source, $destination, $isInternal = true )
00060     {
00061         die( __CLASS__ . "::" . __FUNCTION__ . " in file " . __FILE__ . ":" . __LINE__ . " is deprecated" );
00062     }
00063 
00064     /*!
00065      Translates the url found in the object \a $uri and returns the corrected url object.
00066      \return false if no url translation was done.
00067     */
00068     function translate( &$uri )
00069     {
00070         die( __CLASS__ . "::" . __FUNCTION__ . " in file " . __FILE__ . ":" . __LINE__ . " is deprecated" );
00071         $newURI = false;
00072         $functionList = array();
00073         $ini = eZINI::instance();
00074         if ( $ini->variable( 'URLTranslator', 'NodeTranslation' ) == 'enabled' )
00075             $functionList[] = 'translateNodeTree';
00076         foreach ( $functionList as $functionName )
00077         {
00078             $uriResult =& $this->$functionName( $uri );
00079             if ( is_string( $uriResult ) )
00080             {
00081                 $newURI =& eZURI::instance( $uriResult );
00082                 return $newURI;
00083             }
00084         }
00085         return $newURI;
00086     }
00087 
00088     /*!
00089      Tries to find a node path which matches the uri \a $uri and returns a new uri string which views that node.
00090      \note This code should get a separate class/package.
00091     */
00092     function translateNodeTree( &$uri )
00093     {
00094         die( __CLASS__ . "::" . __FUNCTION__ . " in file " . __FILE__ . ":" . __LINE__ . " is deprecated" );
00095         $nodePathString = $uri->elements();
00096         $nodePathString = preg_replace( "/\.\w*$/", "", $nodePathString );
00097         $nodePathString = preg_replace( "#\/$#", "", $nodePathString );
00098         print( "try to translate: $nodePathString<br>" );
00099 
00100         //include_once( 'kernel/classes/ezcontentobjecttreenode.php' );
00101 
00102         $node = eZContentObjectTreeNode::fetchByCRC( $nodePathString );
00103 
00104         $uriResult = false;
00105         if ( $node instanceof eZContentObjectTreeNode )
00106         {
00107             $uriResult= 'content/view/full/' . $node->attribute( 'node_id' ) . '/';
00108         }
00109         return $uriResult;
00110     }
00111 
00112     /*!
00113      \return The only instance of the translator.
00114     */
00115     static function instance()
00116     {
00117         die( __CLASS__ . "::" . __FUNCTION__ . " in file " . __FILE__ . ":" . __LINE__ . " is deprecated" );
00118         $instance =& $GLOBALS['eZURLTranslatorInstance'];
00119         if ( !( $instance instanceof eZURLTranslator ) )
00120         {
00121             $instance = new eZURLTranslator();
00122         }
00123         return $instance;
00124     }
00125 }
00126 
00127 ?>