[ Index ]
 

Code source de eZ Publish 3.9.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/kernel/classes/ -> ezredirectmanager.php (source)

   1  <?php
   2  //
   3  // Definition of eZRedirectManager class
   4  //
   5  // Created on: <24-Nov-2004 15:03:51 jb>
   6  //
   7  // SOFTWARE NAME: eZ publish
   8  // SOFTWARE RELEASE: 3.9.0
   9  // BUILD VERSION: 17785
  10  // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS
  11  // SOFTWARE LICENSE: GNU General Public License v2.0
  12  // NOTICE: >
  13  //   This program is free software; you can redistribute it and/or
  14  //   modify it under the terms of version 2.0  of the GNU General
  15  //   Public License as published by the Free Software Foundation.
  16  //
  17  //   This program is distributed in the hope that it will be useful,
  18  //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  19  //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20  //   GNU General Public License for more details.
  21  //
  22  //   You should have received a copy of version 2.0 of the GNU General
  23  //   Public License along with this program; if not, write to the Free
  24  //   Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  25  //   MA 02110-1301, USA.
  26  //
  27  //
  28  
  29  /*! \file ezredirectmanager.php
  30  */
  31  
  32  /*!
  33    \class eZRedirectManager ezredirectmanager.php
  34    \brief Handles generation of redirection URIs and redirection
  35  
  36  */
  37  
  38  class eZRedirectManager
  39  {
  40  
  41      /*!
  42       Generates a URI which can be used to redirect with, the uri is based on:
  43       - The last accessed view/non-view page if any (see \a $view parameter)
  44       - The uri is not the currently running module, if so use default
  45       - The default uri \a $default
  46  
  47       \return The new URI string or \c false if no uri could be made.
  48  
  49       \param $module The current module object
  50       \param $default The default URI to redirect to if all else fails.
  51                       If set to \c false then it will return false.
  52       \param $view If true it will try to redirect to last accessed view URI.
  53       \param $disallowed An array with urls not allowed to redirect to or \c false to allow all
  54       \param $preferredURI An URI that is preferred for the caller. If that URI is valid, it's returned.
  55  
  56       \note All URLs must start with a slash \c /
  57  
  58       \sa redirectTo()
  59      */
  60      function redirectURI( &$module, $default, $view = true, $disallowed = false, $preferredURI = false )
  61      {
  62          $uri = false;
  63          $http =& eZHTTPTool::instance();
  64  
  65          if ( $preferredURI ) // check if $preferredURI is a valid URI
  66              return $preferredURI;
  67  
  68          if ( $view )
  69          {
  70              if ( $http->hasSessionVariable( "LastAccessesURI" ) )
  71              {
  72                  $uri = $http->sessionVariable( "LastAccessesURI" );
  73              }
  74          }
  75          else
  76          {
  77              if ( $http->hasSessionVariable( "LastAccessedModifyingURI" ) )
  78              {
  79                  $uri = $http->sessionVariable( "LastAccessedModifyingURI" );
  80              }
  81          }
  82  
  83          if ( $uri !== false )
  84          {
  85              $moduleURI = $module->functionURI( $module->currentView() );
  86              // Check for correct module/view
  87              if ( substr( $uri, 0, strlen( $moduleURI ) ) == $moduleURI )
  88              {
  89                  // Check parameters
  90                  $moduleURI = $module->currentRedirectionURI();
  91                  if ( $moduleURI == $uri )
  92                      $uri = false;
  93              }
  94          }
  95  
  96          // Check for disallowed urls
  97          if ( $uri !== false and
  98               is_array( $disallowed ) )
  99          {
 100              if ( in_array( $uri, $disallowed ) )
 101                  $uri = false;
 102          }
 103  
 104          if ( $uri === false )
 105          {
 106              // If no default is set we should return false.
 107              if ( $default === false )
 108                  return false;
 109              $uri = $default;
 110          }
 111  
 112          return $uri;
 113      }
 114  
 115      /*!
 116       Generates a URI which can be used to redirect with, the uri is based on:
 117       - The last accessed view/non-view page if any (see \a $view parameter)
 118       - The uri is not the currently running module, if so use default
 119       - The default uri \a $default
 120  
 121       \param $module The current module object
 122       \param $default The default URI to redirect to if all else fails.
 123                       If set to \c false then it will not redirect if there is no url found
 124                       but instead it will return false.
 125       \param $view If true it will try to redirect to last accessed view URI.
 126       \param $disallowed An array with urls not allowed to redirect to or \c false to allow all
 127       \param $preferredURI An URI that is preferred for the caller.
 128              We redirect to that URI if it's specified and is valid.
 129  
 130       \return \c true if the module was redirected or \c false if not.
 131  
 132       \note All URLs must start with a slash \c /
 133       \sa redirectURI()
 134      */
 135      function redirectTo( &$module, $default, $view = true, $disallowed = false, $preferredURI = false )
 136      {
 137          $uri = eZRedirectManager::redirectURI( $module, $default, $view, $disallowed, $preferredURI );
 138          if ( $uri === false )
 139              return false;
 140          $module->redirectTo( $uri );
 141          return true;
 142      }
 143  }
 144  
 145  ?>


Généré le : Sat Feb 24 10:30:04 2007 par Balluche grâce à PHPXref 0.7