|
eZ Publish
[4.0]
|
00001 <?php 00002 // 00003 // Definition of eZModule class 00004 // 00005 // Created on: <17-Apr-2002 11:11:39 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 /*! 00032 \class eZModule ezmodule.php 00033 \ingroup eZUtils 00034 \brief Allows execution of modules and functions 00035 00036 */ 00037 00038 require_once( "lib/ezutils/classes/ezdebug.php" ); 00039 00040 class eZModule 00041 { 00042 const STATUS_IDLE = 0; 00043 const STATUS_OK = 1; 00044 const STATUS_FAILED = 2; 00045 const STATUS_REDIRECT = 3; 00046 const STATUS_RERUN = 4; 00047 00048 const HOOK_STATUS_OK = 0; 00049 const HOOK_STATUS_CANCEL_RUN = 1; 00050 const HOOK_STATUS_FAILED = 2; 00051 00052 function eZModule( $path, $file, $moduleName ) 00053 { 00054 $this->initialize( $path, $file, $moduleName ); 00055 } 00056 00057 /*! 00058 \private 00059 Initializes the module object with the path and file and name. 00060 It will look for a file called \a $file and include the contents 00061 of that file, it will then assume that some variables were set 00062 which defines the module and it's view/functions. 00063 */ 00064 function initialize( $path, $file, $moduleName ) 00065 { 00066 if ( file_exists( $file ) ) 00067 { 00068 unset( $FunctionList ); 00069 unset( $Module ); 00070 unset( $ViewList ); 00071 include( $file ); 00072 $this->Functions = $ViewList; 00073 if ( isset( $FunctionList ) and 00074 is_array( $FunctionList ) and 00075 count( $FunctionList ) > 0 ) 00076 { 00077 ksort( $FunctionList, SORT_STRING ); 00078 $this->FunctionList = $FunctionList; 00079 } 00080 else 00081 { 00082 $this->FunctionList = array(); 00083 } 00084 if ( empty( $Module ) ) 00085 { 00086 $Module = array( "name" => "null", 00087 "variable_params" => false, 00088 "function" => array() ); 00089 } 00090 $this->Module = $Module; 00091 $this->Name = $moduleName; 00092 $this->Path = $path; 00093 $this->Title = ""; 00094 $this->UIContext = 'navigation'; 00095 $this->UIComponent = $moduleName; 00096 00097 $uiComponentMatch = 'module'; 00098 if ( isset( $this->Module['ui_component_match'] ) ) 00099 { 00100 $uiComponentMatch = $this->Module['ui_component_match']; 00101 } 00102 $this->UIComponentMatch = $uiComponentMatch; 00103 00104 foreach( $this->Functions as $key => $dummy) 00105 { 00106 $this->Functions[$key]["uri"] = "/$moduleName/$key"; 00107 } 00108 } 00109 else 00110 { 00111 $this->Functions = array(); 00112 $this->Module = array( "name" => "null", 00113 "variable_params" => false, 00114 "function" => array() ); 00115 $this->Name = $moduleName; 00116 $this->Path = $path; 00117 $this->Title = ""; 00118 $this->UIContext = 'navigation'; 00119 $this->UIComponent = $moduleName; 00120 $this->UIComponentMatch = 'module'; 00121 } 00122 $this->HookList = array(); 00123 $this->ExitStatus = eZModule::STATUS_IDLE; 00124 $this->ErrorCode = 0; 00125 $this->ViewActions = array(); 00126 $this->OriginalParameters = null; 00127 $this->UserParameters = array(); 00128 00129 // Load in navigation part overrides 00130 $ini = eZINI::instance( 'module.ini' ); 00131 $this->NavigationParts = $ini->variable( 'ModuleOverrides', 'NavigationPart' ); 00132 } 00133 00134 /*! 00135 \return the URI of the module. 00136 \sa functionURI 00137 */ 00138 function uri() 00139 { 00140 return "/" . $this->Name; 00141 } 00142 00143 /*! 00144 \return the URI to the view \a $function. If the view is empty or the module is a singleView type 00145 it will return the result of uri(). If the view does not exist the \c null is returned. 00146 \sa uri 00147 */ 00148 function functionURI( $function ) 00149 { 00150 if ( $this->singleFunction() or 00151 $function == '' ) 00152 return $this->uri(); 00153 if ( isset( $this->Functions[$function] ) ) 00154 return $this->Functions[$function]["uri"]; 00155 else 00156 return null; 00157 } 00158 00159 /*! 00160 \return the title of the current view run, it's normally set by the view 00161 and display as the title of view pages. 00162 */ 00163 function title() 00164 { 00165 return $this->Title; 00166 } 00167 00168 /*! 00169 Sets the current view for the module to \a $title. 00170 */ 00171 function setTitle( $title ) 00172 { 00173 $this->Title = $title; 00174 } 00175 00176 /*! 00177 Sets the name of the currently running module to \a $name. 00178 */ 00179 function setCurrentName( $name ) 00180 { 00181 $this->Name = $name; 00182 foreach( $this->Functions as $key => $dummy ) 00183 { 00184 $this->Functions[$key]["uri"] = "/$name/$key"; 00185 } 00186 } 00187 00188 /*! 00189 Sets the name of the currently running view to \a $name. 00190 */ 00191 function setCurrentView( $name ) 00192 { 00193 $GLOBALS['eZModuleCurrentView'] = $name; 00194 } 00195 00196 /*! 00197 \return true if the module acts a single view. 00198 */ 00199 function singleFunction() 00200 { 00201 return count( $this->Functions ) == 0; 00202 } 00203 00204 /*! 00205 \return A string describing the current UI context, the default is \c 'navigation' 00206 00207 Change the context with setUIContextName(). 00208 */ 00209 function uiContextName() 00210 { 00211 return $this->UIContext; 00212 } 00213 00214 /*! 00215 \return A string describing the current UI component. 00216 00217 The default value is the name of the currently running module, can be changed with setUIComponentName(). 00218 */ 00219 function uiComponentName() 00220 { 00221 return $this->UIComponent; 00222 } 00223 00224 /*! 00225 Sets the current context string to \a $context. 00226 */ 00227 function setUIContextName( $context ) 00228 { 00229 $this->UIContext = $context; 00230 } 00231 00232 /*! 00233 Sets the current component string to \a $component. 00234 */ 00235 function setUIComponentName( $component ) 00236 { 00237 $this->UIComponent = $component; 00238 } 00239 00240 /*! 00241 \return the current status from the module. 00242 */ 00243 function exitStatus() 00244 { 00245 return $this->ExitStatus; 00246 } 00247 00248 /*! 00249 Sets the current status for the module to \a $stat, the status can trigger 00250 a redirect or tell the client that the view failed. 00251 */ 00252 function setExitStatus( $stat ) 00253 { 00254 $this->ExitStatus = $stat; 00255 } 00256 00257 /*! 00258 \return the error code if the function failed to run or \c 0 if no error code. 00259 \sa setErrorCode 00260 */ 00261 function errorCode() 00262 { 00263 return $this->ErrorCode; 00264 } 00265 00266 /*! 00267 Sets the current error code. 00268 \note You need to set the exit status to eZModule::STATUS_FAILED for the error code to be used. 00269 \sa setExitStatus, errorCode 00270 */ 00271 function setErrorCode( $errorCode ) 00272 { 00273 $this->ErrorCode = $errorCode; 00274 } 00275 00276 /*! 00277 \return the name of the module which will be run on errors. 00278 The default name is 'error'. 00279 \sa handleError 00280 */ 00281 function errorModule() 00282 { 00283 if ( !isset( $GLOBALS['eZModuleGlobalErrorModule'] ) ) 00284 $GLOBALS['eZModuleGlobalErrorModule'] = array( 'module' => 'error', 00285 'view' => 'view' ); 00286 return $GLOBALS['eZModuleGlobalErrorModule']; 00287 } 00288 00289 /*! 00290 Sets the name of the module which will be run on errors. 00291 \sa handleError 00292 */ 00293 function setErrorModule( $moduleName, $viewName ) 00294 { 00295 $GLOBALS['eZModuleGlobalErrorModule'] = array( 'module' => $moduleName, 00296 'view' => $viewName ); 00297 } 00298 00299 /*! 00300 Tries to run the error module with the error code \a $errorCode. 00301 Sets the state of the module object to \c failed and sets the error code. 00302 */ 00303 function handleError( $errorCode, $errorType = false, $parameters = array(), $userParameters = false ) 00304 { 00305 if ( !$errorType ) 00306 { 00307 eZDebug::writeWarning( "No error type specified for error code $errorCode, assuming kernel.\nA specific error type should be supplied, please check your code.", 00308 'eZModule::handleError' ); 00309 $errorType = 'kernel'; 00310 } 00311 $errorModule = eZModule::errorModule(); 00312 $module = eZModule::findModule( $errorModule['module'], $this ); 00313 00314 if ( $module === null ) 00315 { 00316 return false; 00317 } 00318 00319 $result = $module->run( $errorModule['view'], array( $errorType, $errorCode, $parameters, $userParameters ) ); 00320 // The error module may want to redirect to another URL, see error.ini 00321 if ( $this->exitStatus() != eZModule::STATUS_REDIRECT and 00322 $this->exitStatus() != eZModule::STATUS_RERUN ) 00323 { 00324 $this->setExitStatus( eZModule::STATUS_FAILED ); 00325 $this->setErrorCode( $errorCode ); 00326 } 00327 return $result; 00328 } 00329 00330 /*! 00331 Redirects the page to the module \a $moduleName and view \a $viewName with parameters \a $parameters 00332 and unorderedParameters \a $unorderedParameters. If you already have the module object use redirectModule 00333 instead or if you need to redirect to a view in the current module use redirectToView. 00334 \return false if the view could not redirected to. 00335 \sa redirectionURI 00336 */ 00337 function redirect( $moduleName, $viewName, $parameters = array(), 00338 $unorderedParameters = null, $userParameters = false, 00339 $anchor = false ) 00340 { 00341 $module = eZModule::exists( $moduleName ); 00342 if ( $module ) 00343 { 00344 return $this->redirectModule( $module, $viewName, $parameters, 00345 $unorderedParameters, $userParameters, $anchor ); 00346 } 00347 else 00348 { 00349 eZDebug::writeError( 'Undefined module: ' . $moduleName, 'eZModule::redirect' ); 00350 } 00351 return false; 00352 } 00353 00354 /*! 00355 Same as redirect() only redirects in the current module. 00356 */ 00357 function redirectToView( $viewName = '', $parameters = array(), 00358 $unorderedParameters = null, $userParameters = false, 00359 $anchor = false ) 00360 { 00361 return $this->redirectModule( $this, $viewName, $parameters, 00362 $unorderedParameters, $userParameters, $anchor ); 00363 } 00364 00365 /*! 00366 Same as redirect() but takes a module object instead of the name. 00367 */ 00368 function redirectModule( $module, $viewName, $parameters = array(), 00369 $unorderedParameters = null, $userParameters = false, 00370 $anchor = false ) 00371 { 00372 $uri = $this->redirectionURIForModule( $module, $viewName, $parameters, 00373 $unorderedParameters, $userParameters, $anchor ); 00374 $this->redirectTo( $uri ); 00375 return true; 00376 } 00377 00378 /*! 00379 \return the URI for the module \a $moduleName and view \a $viewName using parameters \a $parameters 00380 and unordered parameters \a $unorderedParameters. 00381 \sa redirect 00382 */ 00383 function redirectionURI( $moduleName, $viewName, $parameters = array(), 00384 $unorderedParameters = null, $userParameters = false, 00385 $anchor = false ) 00386 { 00387 $module = eZModule::exists( $moduleName ); 00388 if ( $module ) 00389 { 00390 return $this->redirectionURIForModule( $module, $viewName, $parameters, 00391 $unorderedParameters, $userParameters, $anchor ); 00392 } 00393 else 00394 eZDebug::writeError( 'Undefined module: ' . $moduleName, 'eZModule::redirectionURI' ); 00395 return false; 00396 } 00397 00398 /*! 00399 \return The URI of the currently run view in the current module with the current parameters. 00400 */ 00401 function currentRedirectionURI() 00402 { 00403 $module = $this; 00404 $viewName = eZModule::currentView(); 00405 $parameters = $this->OriginalViewParameters; 00406 $unorderedParameters = $this->OriginalUnorderedParameters; 00407 $userParameters = $this->UserParameters; 00408 return $this->redirectionURIForModule( $module, $viewName, $parameters, 00409 $unorderedParameters, $userParameters ); 00410 } 00411 00412 /*! 00413 Redirects to the current module and view, it will use currentRedirectionURI() to 00414 figure out the URL. 00415 \note By changing using setCurrentName() and setCurrentView() first it is possible to 00416 redirect to another module or view with the same parameters. 00417 */ 00418 function redirectCurrent() 00419 { 00420 $this->redirectTo( $this->currentRedirectionURI() ); 00421 } 00422 00423 /*! 00424 Sames as redirectionURI but takes a module object instead of the name. 00425 */ 00426 function redirectionURIForModule( $module, $viewName, $parameters = array(), 00427 $unorderedParameters = null, $userParameters = false, 00428 $anchor = false ) 00429 { 00430 if ( $viewName == '' ) 00431 $viewName = eZModule::currentView(); 00432 $uri = $module->functionURI( $viewName ); 00433 $uri .= '/'; 00434 $viewParameters = $module->parameters( $viewName ); 00435 $parameterIndex = 0; 00436 $unorderedURI = ''; 00437 $hasUnorderedParameter = false; 00438 if ( $unorderedParameters !== null ) 00439 { 00440 $unorderedViewParameters = $module->unorderedParameters( $viewName ); 00441 if ( is_array( $unorderedViewParameters ) ) 00442 { 00443 foreach ( $unorderedViewParameters as $unorderedViewParameterName => $unorderedViewParameterVariable ) 00444 { 00445 if ( isset( $unorderedParameters[$unorderedViewParameterVariable] ) ) 00446 { 00447 $unorderedURI .= $unorderedViewParameterName . '/' . $unorderedParameters[$unorderedViewParameterVariable] . '/'; 00448 $hasUnorderedParameter = true; 00449 } 00450 } 00451 } 00452 } 00453 00454 if( !isset( $viewParameters ) ) 00455 $viewParameters = array(); // prevent PHP warning below 00456 00457 foreach ( $viewParameters as $viewParameter ) 00458 { 00459 if ( !isset( $parameters[$parameterIndex] ) ) 00460 { 00461 // We don't show a warning anymore since some parameters can be optional 00462 // In future versions we will need required and optional parameters 00463 // for modules and give warnings for required ones. 00464 // eZDebug::writeWarning( "Missing parameter(s) " . implode( ', ', array_slice( $viewParameters, $parameterIndex ) ) . 00465 // " in view '$viewName'", 'eZModule::redirect' ); 00466 } 00467 else 00468 $uri .= $parameters[$parameterIndex] . '/'; 00469 ++$parameterIndex; 00470 } 00471 if ( $hasUnorderedParameter ) 00472 { 00473 $uri .= $unorderedURI; 00474 } 00475 00476 if ( is_array( $userParameters ) ) 00477 { 00478 foreach ( $userParameters as $name => $value ) 00479 { 00480 $uri .= '/(' . $name . ')/' . $value; 00481 } 00482 } 00483 00484 $uri = preg_replace( "#(^.*)(//+)$#", "\$1", $uri ); 00485 if ( $anchor !== false ) 00486 $uri .= '#' . urlencode( $anchor ); 00487 return $uri; 00488 } 00489 00490 /*! 00491 \return the parameter definition for the view \a $viewName. If \a $viewName 00492 is empty the current view is used. 00493 \sa unorderedParameters, viewData, currentView, currentModule 00494 */ 00495 function parameters( $viewName = '' ) 00496 { 00497 if ( $viewName == '' ) 00498 $viewName = eZModule::currentView(); 00499 $viewData = $this->viewData( $viewName ); 00500 if ( isset( $viewData['params'] ) ) 00501 { 00502 return $viewData['params']; 00503 } 00504 return null; 00505 return $retValue; 00506 } 00507 00508 /*! 00509 \return the unordered parameter definition for the view \a $viewName. If \a $viewName 00510 is empty the current view is used. 00511 \sa parameters, viewData, currentView, currentModule 00512 */ 00513 function unorderedParameters( $viewName = '' ) 00514 { 00515 if ( $viewName == '' ) 00516 $viewName = eZModule::currentView(); 00517 $viewData = $this->viewData( $viewName ); 00518 if ( isset( $viewData['unordered_params'] ) ) 00519 { 00520 return $viewData['unordered_params']; 00521 } 00522 return null; 00523 } 00524 00525 /*! 00526 \return the view data for the view \a $viewName. If \a $viewName 00527 is empty the current view is used. 00528 \sa parameters, unorderedParameters, currentView, currentModule 00529 */ 00530 function viewData( $viewName = '' ) 00531 { 00532 if ( $viewName == '' ) 00533 $viewName = eZModule::currentView(); 00534 if ( $this->singleFunction() ) 00535 $viewData = $this->Module["function"]; 00536 else 00537 $viewData = $this->Functions[$viewName]; 00538 return $viewData; 00539 } 00540 00541 /*! 00542 Makes sure that the module is redirected to the URI \a $uri when the function exits. 00543 \sa setRedirectURI, setExitStatus 00544 */ 00545 function redirectTo( $uri ) 00546 { 00547 $originalURI = $uri; 00548 $uri = preg_replace( "#(^.*)(/+)$#", "\$1", $uri ); 00549 if ( strlen( $originalURI ) != 0 and 00550 strlen( $uri ) == 0 ) 00551 $uri = '/'; 00552 $this->RedirectURI = $uri; 00553 $this->setExitStatus( eZModule::STATUS_REDIRECT ); 00554 } 00555 00556 /*! 00557 \return the URI which will be redirected to when the function exits. 00558 */ 00559 function redirectURI() 00560 { 00561 return $this->RedirectURI; 00562 } 00563 00564 /*! 00565 Sets the URI which will be redirected to when the function exits. 00566 */ 00567 function setRedirectURI( $uri ) 00568 { 00569 $this->RedirectURI = $uri; 00570 } 00571 00572 /*! 00573 \return the status which will be set when redirecting. 00574 */ 00575 function redirectStatus() 00576 { 00577 return $this->RedirectStatus; 00578 } 00579 00580 /*! 00581 Sets the status which will be set when redirecting. 00582 \note The status must be a valid HTTP status with number and text. 00583 */ 00584 function setRedirectStatus( $status ) 00585 { 00586 $this->RedirectStatus = $status; 00587 } 00588 00589 /*! 00590 \return an array with the available attributes. 00591 */ 00592 function attributes() 00593 { 00594 return array( "uri", 00595 "functions", 00596 'views', 00597 "name", 00598 "path", 00599 "info", 00600 "aviable_functions", 00601 "available_functions" ); 00602 } 00603 00604 /*! 00605 \return true if the attribute \a $attr is available. 00606 */ 00607 function hasAttribute( $attr ) 00608 { 00609 return in_array( $attr, $this->attributes() ); 00610 } 00611 00612 /*! 00613 \return the attribute value for attribute \a $attr if it is available, otherwise \c null. 00614 */ 00615 function attribute( $attr ) 00616 { 00617 switch( $attr ) 00618 { 00619 case "uri": 00620 return $this->uri(); 00621 break; 00622 case "functions": 00623 return $this->Functions; 00624 case "views": 00625 return $this->Functions; 00626 case "name": 00627 return $this->Name; 00628 case "path": 00629 return $this->Path; 00630 case "info": 00631 return $this->Module; 00632 case 'aviable_functions': 00633 case 'available_functions': 00634 return $this->FunctionList; 00635 default: 00636 { 00637 eZDebug::writeError( "Attribute '$attr' does not exist", 'eZModule::attribute' ); 00638 return null; 00639 } 00640 break; 00641 } 00642 } 00643 00644 /*! 00645 Sets the current action in view \a $view to \a $actionName. 00646 \sa currentAction, isCurrentAction 00647 */ 00648 function setCurrentAction( $actionName, $view = '' ) 00649 { 00650 if ( $view == '' ) 00651 $view = eZModule::currentView(); 00652 if ( $view == '' or $actionName == '' ) 00653 return false; 00654 $this->ViewActions[$view] = $actionName; 00655 } 00656 00657 /*! 00658 \return the current action for the view \a $view. 00659 00660 If the current action is not yet determined it will use the definitions in 00661 \c module.php for finding out the current action. It first looks trough 00662 the \c single_post_actions array in the selected view mode, the key to 00663 each element is the name of the post-variable to match, if it matches the 00664 element value is set as the action. 00665 \code 00666 'single_post_actions' => array( 'PreviewButton' => 'Preview', 00667 'PublishButton' => 'Publish' ) 00668 \endcode 00669 If none of these matches it will use the elements from the \c post_actions 00670 array to find a match. It uses the element value for each element to match 00671 agains a post-variable, if it is found the contents of the post-variable 00672 is set as the action. 00673 \code 00674 'post_actions' => array( 'BrowseActionName' ) 00675 \endcode 00676 \sa setCurrentAction 00677 */ 00678 function currentAction( $view = '' ) 00679 { 00680 if ( $view == '' ) 00681 $view = eZModule::currentView(); 00682 if ( isset( $this->ViewActions[$view] ) ) 00683 return $this->ViewActions[$view]; 00684 //include_once( "lib/ezutils/classes/ezhttptool.php" ); 00685 $http = eZHTTPTool::instance(); 00686 if ( isset( $this->Functions[$view]['default_action'] ) ) 00687 { 00688 $defaultAction = $this->Functions[$view]['default_action']; 00689 foreach ( $defaultAction as $defaultActionStructure ) 00690 { 00691 $actionName = $defaultActionStructure['name']; 00692 $type = $defaultActionStructure['type']; 00693 if ( $type == 'post' ) 00694 { 00695 $parameters = array(); 00696 if ( isset( $defaultActionStructure['parameters'] ) ) 00697 $parameters = $defaultActionStructure['parameters']; 00698 $hasParameters = true; 00699 foreach ( $parameters as $parameterName ) 00700 { 00701 if ( !$http->hasPostVariable( $parameterName ) ) 00702 { 00703 $hasParameters = false; 00704 break; 00705 } 00706 } 00707 if ( $hasParameters ) 00708 { 00709 $this->ViewActions[$view] = $actionName; 00710 return $this->ViewActions[$view]; 00711 } 00712 } 00713 else 00714 { 00715 eZDebug::writeWarning( 'Unknown default action type: ' . $type, 'eZModule::currentAction' ); 00716 } 00717 } 00718 } 00719 if ( isset( $this->Functions[$view]['single_post_actions'] ) ) 00720 { 00721 $singlePostActions = $this->Functions[$view]['single_post_actions']; 00722 foreach( $singlePostActions as $postActionName => $realActionName ) 00723 { 00724 if ( $http->hasPostVariable( $postActionName ) ) 00725 { 00726 $this->ViewActions[$view] = $realActionName; 00727 return $this->ViewActions[$view]; 00728 } 00729 } 00730 } 00731 if ( isset( $this->Functions[$view]['post_actions'] ) ) 00732 { 00733 $postActions = $this->Functions[$view]['post_actions']; 00734 foreach( $postActions as $postActionName ) 00735 { 00736 if ( $http->hasPostVariable( $postActionName ) ) 00737 { 00738 $this->ViewActions[$view] = $http->postVariable( $postActionName ); 00739 return $this->ViewActions[$view]; 00740 } 00741 } 00742 } 00743 00744 $this->ViewActions[$view] = false; 00745 return false; 00746 } 00747 00748 function setActionParameter( $parameterName, $parameterValue, $view = '' ) 00749 { 00750 if ( $view == '' ) 00751 $view = eZModule::currentView(); 00752 $this->ViewActionParameters[$view][$parameterName] = $parameterValue; 00753 } 00754 00755 function actionParameter( $parameterName, $view = '' ) 00756 { 00757 if ( $view == '' ) 00758 $view = eZModule::currentView(); 00759 if ( isset( $this->ViewActionParameters[$view][$parameterName] ) ) 00760 return $this->ViewActionParameters[$view][$parameterName]; 00761 $currentAction = $this->currentAction( $view ); 00762 //include_once( "lib/ezutils/classes/ezhttptool.php" ); 00763 $http = eZHTTPTool::instance(); 00764 if ( isset( $this->Functions[$view]['post_action_parameters'][$currentAction] ) ) 00765 { 00766 $postParameters = $this->Functions[$view]['post_action_parameters'][$currentAction]; 00767 if ( isset( $postParameters[$parameterName] ) && 00768 $http->hasPostVariable( $postParameters[$parameterName] ) ) 00769 { 00770 return $http->postVariable( $postParameters[$parameterName] ); 00771 } 00772 eZDebug::writeError( "No such action parameter: $parameterName", 'eZModule::actionParameter' ); 00773 } 00774 if ( isset( $this->Functions[$view]['post_value_action_parameters'][$currentAction] ) ) 00775 { 00776 $postParameters = $this->Functions[$view]['post_value_action_parameters'][$currentAction]; 00777 if ( isset( $postParameters[$parameterName] ) ) 00778 { 00779 $postVariables = $http->attribute( 'post' ); 00780 $postVariableNameMatch = $postParameters[$parameterName]; 00781 $regMatch = "/^" . $postVariableNameMatch . "_(.+)$/"; 00782 foreach ( $postVariables as $postVariableName => $postVariableValue ) 00783 { 00784 if ( preg_match( $regMatch, $postVariableName, $matches ) ) 00785 { 00786 $parameterValue = $matches[1]; 00787 $this->ViewActionParameters[$view][$parameterName] = $parameterValue; 00788 return $parameterValue; 00789 } 00790 } 00791 eZDebug::writeError( "No such action parameter: $parameterName", 'eZModule::actionParameter' ); 00792 } 00793 } 00794 return null; 00795 } 00796 00797 function hasActionParameter( $parameterName, $view = '' ) 00798 { 00799 if ( $view == '' ) 00800 $view = eZModule::currentView(); 00801 if ( isset( $this->ViewActionParameters[$view][$parameterName] ) ) 00802 return true; 00803 $currentAction = $this->currentAction( $view ); 00804 //include_once( "lib/ezutils/classes/ezhttptool.php" ); 00805 $http = eZHTTPTool::instance(); 00806 if ( isset( $this->Functions[$view]['post_action_parameters'][$currentAction] ) ) 00807 { 00808 $postParameters = $this->Functions[$view]['post_action_parameters'][$currentAction]; 00809 if ( isset( $postParameters[$parameterName] ) and 00810 $http->hasPostVariable( $postParameters[$parameterName] ) ) 00811 { 00812 return true; 00813 } 00814 } 00815 if ( isset( $this->Functions[$view]['post_value_action_parameters'][$currentAction] ) ) 00816 { 00817 $postParameters = $this->Functions[$view]['post_value_action_parameters'][$currentAction]; 00818 if ( isset( $postParameters[$parameterName] ) ) 00819 { 00820 $postVariables = $http->attribute( 'post' ); 00821 $postVariableNameMatch = $postParameters[$parameterName]; 00822 $regMatch = "/^" . $postVariableNameMatch . "_(.+)$/"; 00823 foreach ( $postVariables as $postVariableName => $postVariableValue ) 00824 { 00825 if ( preg_match( $regMatch, $postVariableName, $matches ) ) 00826 { 00827 $parameterValue = $matches[1]; 00828 $this->ViewActionParameters[$view][$parameterName] = $parameterValue; 00829 return true; 00830 } 00831 } 00832 } 00833 } 00834 return false; 00835 } 00836 00837 /*! 00838 \return true if the current action matches the action name \a $actionName in view \a $view. 00839 Always returns false if either \a $view or \a $actionName is empty. 00840 \sa currentAction, setCurrentAction 00841 */ 00842 function isCurrentAction( $actionName, $view = '' ) 00843 { 00844 if ( $view == '' ) 00845 $view = eZModule::currentView(); 00846 if ( $view == '' or $actionName == '' ) 00847 return false; 00848 return $this->currentAction( $view ) == $actionName; 00849 } 00850 00851 /*! 00852 Adds an entry to the hook named \a $hookName. The entry is placed 00853 before all other existing entries unless \a $append is set to \c true 00854 in which case the entry is placed at the end. 00855 \param $function Either the name of the function to be run or an 00856 array where the first entry is the object and the second 00857 is the method name. 00858 */ 00859 function addHook( $hookName, $function, $priority = 1, $expandParameters = true, $append = false ) 00860 { 00861 $hookEntries = isset( $this->HookList[$hookName] ) ? $this->HookList[$hookName] : false; 00862 if ( !is_array( $hookEntries ) ) 00863 { 00864 $hookEntries = array(); 00865 } 00866 $entry = array( 'function' => $function, 00867 'expand_parameters' => $expandParameters ); 00868 00869 $position = $priority; 00870 if ( $append ) 00871 { 00872 while ( isset( $hookEntries[$position] ) ) 00873 ++$position; 00874 } 00875 else 00876 { 00877 while ( isset( $hookEntries[$position] ) ) 00878 --$position; 00879 } 00880 $this->HookList[$hookName][$position] = $entry; 00881 } 00882 00883 /*! 00884 Runs all hooks found in the hook list named \a $hookName. 00885 The parameter array \a $parameters will be passed to each hook function. 00886 */ 00887 function runHooks( $hookName, $parameters = null ) 00888 { 00889 $status = null; 00890 $hookEntries = isset( $this->HookList[$hookName] ) ? $this->HookList[$hookName] : false; 00891 if ( isset( $hookEntries ) and 00892 is_array( $hookEntries ) ) 00893 { 00894 ksort( $hookEntries ); 00895 foreach ( $hookEntries as $hookEntry ) 00896 { 00897 $function = $hookEntry['function']; 00898 $expandParameters = $hookEntry['expand_parameters']; 00899 if ( is_string( $function ) ) 00900 { 00901 $functionName = $function; 00902 if ( function_exists( $functionName ) ) 00903 { 00904 if ( $parameters === null || 00905 $expandParameters === null ) 00906 { 00907 $retVal = $functionName( $this ); 00908 } 00909 else if ( $expandParameters ) 00910 { 00911 $retVal = call_user_func_array( $functionName, array_merge( array( $this ), $parameters ) ); 00912 } 00913 else 00914 { 00915 $retVal = $functionName( $this, $parameters ); 00916 } 00917 } 00918 else 00919 { 00920 eZDebug::writeError( "Unknown hook function '$functionName' in hook: $hookName", 'eZModule::runHooks' ); 00921 } 00922 } 00923 else if ( is_array( $function ) ) 00924 { 00925 if ( isset( $function[0] ) && 00926 isset( $function[1] ) ) 00927 { 00928 $object = $function[0]; 00929 $functionName = $function[1]; 00930 if ( method_exists( $object, $functionName ) ) 00931 { 00932 if ( $parameters === null ) 00933 { 00934 $retVal = $object->$function( $this ); 00935 } 00936 else if ( $expandParameters ) 00937 { 00938 $retVal = call_user_func_array( array( $object, $functionName ), array_merge( array( $this ), $parameters ) ); 00939 } 00940 else 00941 { 00942 $retVal = $object->$functionName( $this, $parameters ); 00943 } 00944 } 00945 else 00946 { 00947 eZDebug::writeError( "Unknown hook method '$functionName' in class '" . strtolower( get_class( $object ) ) . "' in hook: $hookName", 'eZModule::runHooks' ); 00948 } 00949 } 00950 else 00951 { 00952 eZDebug::writeError( "Missing data for method handling in hook: $hookName", 'eZModule::runHooks' ); 00953 } 00954 } 00955 else 00956 { 00957 eZDebug::writeError( 'Unknown entry type ' . gettype( $function ) . 'in hook: ' . $hookName, 'eZModule::runHooks' ); 00958 } 00959 00960 switch( $retVal ) 00961 { 00962 case eZModule::HOOK_STATUS_OK: 00963 { 00964 } break; 00965 00966 case eZModule::HOOK_STATUS_FAILED: 00967 { 00968 eZDebug::writeWarning( 'Hook execution failed in hook: ' . $hookName, 'eZModule::runHooks' ); 00969 } break; 00970 00971 case eZModule::HOOK_STATUS_CANCEL_RUN: 00972 { 00973 return $retVal; 00974 } break; 00975 } 00976 } 00977 } 00978 return $status; 00979 } 00980 00981 function setViewResult( $result, $view = '' ) 00982 { 00983 if ( $view == '' ) 00984 $view = $this->currentView(); 00985 $this->ViewResult[$view] = $result; 00986 } 00987 00988 function hasViewResult( $view = '' ) 00989 { 00990 if ( $view == '' ) 00991 $view = $this->currentView(); 00992 return isset( $this->ViewResult[$view] ); 00993 } 00994 00995 function viewResult( $view = '' ) 00996 { 00997 if ( $view == '' ) 00998 $view = $this->currentView(); 00999 if ( isset( $this->ViewResult[$view] ) ) 01000 { 01001 return $this->ViewResult[$view]; 01002 } 01003 return null; 01004 } 01005 01006 function forward( $module, $functionName, $parameters = false ) 01007 { 01008 $Return = null; 01009 if ( $module && $functionName ) 01010 { 01011 $viewName = eZModule::currentView(); 01012 01013 if ( $parameters === false) 01014 { 01015 $parameters = array(); 01016 } 01017 01018 $parameters = array_merge( $parameters, $this->OriginalViewParameters ); 01019 $unorderedParameters = $this->OriginalUnorderedParameters; 01020 $userParameters = $this->UserParameters; 01021 01022 $Return = $module->run( $functionName, $parameters, $unorderedParameters, $userParameters ); 01023 01024 // override default navigation part 01025 if ( $Return['is_default_navigation_part'] === true ) 01026 { 01027 if ( $this->singleFunction() ) 01028 $function = $this->Module["function"]; 01029 else 01030 $function = $this->Functions[$functionName]; 01031 01032 if ( isset( $function['default_navigation_part'] ) ) 01033 { 01034 $Return['navigation_part'] = $function['default_navigation_part']; 01035 } 01036 } 01037 01038 $this->RedirectURI = $module->redirectURI(); 01039 $this->setExitStatus( $module->exitStatus() ); 01040 } 01041 return $Return; 01042 } 01043 01044 /*! 01045 Tries to run the function \a $functionName in the current module. 01046 \param parameters An indexed list of parameters, these will be mapped 01047 onto real parameter names using the defined parameter 01048 names in the module/function definition. 01049 If this variable is shorter than the required parameters 01050 they will be set to \c null. 01051 \param overrideParameters An associative array of parameters which 01052 will override any parameters found using the 01053 defined parameters. 01054 \return null if function could not be run or no return value was found. 01055 */ 01056 function run( $functionName, $parameters = array(), $overrideParameters = false, $userParameters = false ) 01057 { 01058 if ( count( $this->Functions ) > 0 and 01059 !isset( $this->Functions[$functionName] ) ) 01060 { 01061 eZDebug::writeError( "Undefined view: " . $this->Module["name"] . "::$functionName ", 01062 "eZModule" ); 01063 $this->setExitStatus( eZModule::STATUS_FAILED ); 01064 $Return = null; 01065 return $Return; 01066 } 01067 if ( $this->singleFunction() ) 01068 $function = $this->Module["function"]; 01069 else 01070 $function = $this->Functions[$functionName]; 01071 01072 $params = array(); 01073 $i = 0; 01074 $parameterValues = array(); 01075 if ( isset( $function["params"] ) ) 01076 { 01077 $functionParameterDefinitions = $function["params"]; 01078 foreach ( $functionParameterDefinitions as $param ) 01079 { 01080 if ( isset( $parameters[$i] ) ) 01081 { 01082 $params[$param] = $parameters[$i]; 01083 $parameterValues[] = $parameters[$i]; 01084 } 01085 else 01086 { 01087 $params[$param] = null; 01088 $parameterValues[] = null; 01089 } 01090 ++$i; 01091 } 01092 } 01093 01094 $this->ViewParameters = $parameters; 01095 $this->OriginalParameters = $parameters; 01096 $this->OriginalViewParameters = $parameterValues; 01097 $this->NamedParameters = $params; 01098 01099 $GLOBALS['eZRequestedModuleParams'] = array( 'module_name' => $this->Name, 01100 'function_name' => $functionName, 01101 'parameters' => $params ); 01102 01103 $this->UserParameters = $userParameters; 01104 01105 if ( isset( $function['ui_context'] ) ) 01106 { 01107 $this->UIContext = $function['ui_context']; 01108 } 01109 if ( isset( $function['ui_component'] ) ) 01110 { 01111 $this->UIComponent = $function['ui_component']; 01112 } 01113 else if ( $this->UIComponentMatch == 'view' ) 01114 { 01115 $this->UIComponent = $functionName; 01116 } 01117 01118 if ( array_key_exists( 'Limitation', $parameters ) ) 01119 { 01120 $params['Limitation'] =& $parameters[ 'Limitation' ]; 01121 } 01122 01123 // check for unordered parameters and initialize variables if they exist 01124 $unorderedParametersList = array(); 01125 $unorderedParameters = array(); 01126 if ( isset( $function["unordered_params"] ) ) 01127 { 01128 $unorderedParams = $function["unordered_params"]; 01129 01130 foreach ( $unorderedParams as $urlParamName => $variableParamName ) 01131 { 01132 if ( in_array( $urlParamName, $parameters ) ) 01133 { 01134 $pos = array_search( $urlParamName, $parameters ); 01135 01136 $params[$variableParamName] = $parameters[$pos + 1]; 01137 $unorderedParameters[$variableParamName] = $parameters[$pos + 1]; 01138 $unorderedParametersList[$variableParamName] = $parameters[$pos + 1]; 01139 } 01140 else 01141 { 01142 $params[$variableParamName] = false; 01143 $unorderedParameters[$variableParamName] = false; 01144 } 01145 } 01146 } 01147 01148 // Loop through user defines parameters 01149 if ( $userParameters !== false ) 01150 { 01151 if ( !isset( $params['UserParameters'] ) or 01152 !is_array( $params['UserParameters'] ) ) 01153 { 01154 $params['UserParameters'] = array(); 01155 } 01156 01157 if ( is_array( $userParameters ) && count( $userParameters ) > 0 ) 01158 { 01159 foreach ( array_keys( $userParameters ) as $paramKey ) 01160 { 01161 if( isset( $function['unordered_params'] ) && 01162 $unorderedParams != null ) 01163 { 01164 if ( array_key_exists( $paramKey, $unorderedParams ) ) 01165 { 01166 $params[$unorderedParams[$paramKey]] = $userParameters[$paramKey]; 01167 $unorderedParametersList[$unorderedParams[$paramKey]] = $userParameters[$paramKey]; 01168 } 01169 } 01170 01171 $params['UserParameters'][$paramKey] = $userParameters[$paramKey]; 01172 } 01173 } 01174 } 01175 01176 $this->OriginalUnorderedParameters = $unorderedParametersList; 01177 01178 if ( is_array( $overrideParameters ) ) 01179 { 01180 foreach ( $overrideParameters as $param => $value ) 01181 { 01182 $params[$param] = $value; 01183 } 01184 } 01185 $params["Module"] = $this; 01186 $params["ModuleName"] = $this->Name; 01187 $params["FunctionName"] = $functionName; 01188 $params["Parameters"] = $parameters; 01189 $params_as_var = isset( $this->Module["variable_params"] ) ? $this->Module["variable_params"] : false; 01190 //include_once( "lib/ezutils/classes/ezprocess.php" ); 01191 $this->ExitStatus = eZModule::STATUS_OK; 01192 // eZDebug::writeNotice( $params, 'module parameters1' ); 01193 01194 01195 $currentView =& $GLOBALS['eZModuleCurrentView']; 01196 $viewStack =& $GLOBALS['eZModuleViewStack']; 01197 if ( !isset( $currentView ) ) 01198 $currentView = false; 01199 if ( !isset( $viewStack ) ) 01200 $viewStack = array(); 01201 if ( is_array( $currentView ) ) 01202 $viewStack[] = $currentView; 01203 $currentView = array( 'view' => $functionName, 01204 'module' => $this->Name ); 01205 $Return = eZProcess::run( $this->Path . "/" . $this->Name . "/" . $function["script"], 01206 $params, 01207 $params_as_var ); 01208 01209 if ( $this->hasViewResult( $functionName ) ) 01210 { 01211 $Return = $this->viewResult( $functionName ); 01212 } 01213 01214 if ( count( $viewStack ) > 0 ) 01215 $currentView = array_pop( $viewStack ); 01216 else 01217 $currentView = false; 01218 01219 // Check if the module has set the navigation part, if not default to module setting 01220 if ( !isset( $Return['navigation_part'] ) ) 01221 { 01222 $Return['is_default_navigation_part'] = true; 01223 if ( isset( $function['default_navigation_part'] ) ) 01224 $Return['navigation_part'] = $function['default_navigation_part']; 01225 01226 } 01227 else 01228 { 01229 $Return['is_default_navigation_part'] = false; 01230 } 01231 01232 // Check if we have overrides for navigation part 01233 $viewName = $this->Name . '/' . $functionName; 01234 if ( isset( $this->NavigationParts[$viewName] ) ) 01235 { 01236 $Return['is_default_navigation_part'] = false; 01237 $Return['navigation_part'] = $this->NavigationParts[$viewName]; 01238 } 01239 else if ( isset( $this->NavigationParts[$this->Name] ) ) 01240 { 01241 $Return['is_default_navigation_part'] = false; 01242 $Return['navigation_part'] = $this->NavigationParts[$this->Name]; 01243 } 01244 01245 return $Return; 01246 } 01247 01248 /*! 01249 \static 01250 \return the current view which is run or \c false if no view is active. 01251 \sa currentModule 01252 */ 01253 function currentView() 01254 { 01255 $currentView = $GLOBALS['eZModuleCurrentView']; 01256 if ( $currentView !== false ) 01257 return $currentView['view']; 01258 return false; 01259 } 01260 01261 /*! 01262 \static 01263 \return the current module which is run or \c false if no module is active. 01264 \sa currentModule 01265 */ 01266 function currentModule() 01267 { 01268 $currentView = $GLOBALS['eZModuleCurrentView']; 01269 if ( $currentView !== false ) 01270 return $currentView['module']; 01271 return false; 01272 } 01273 01274 /*! 01275 \static 01276 \return the global path list which is used for finding modules. Returns \c null if no 01277 list is available. 01278 \sa setGlobalPathList, addGlobalPathList 01279 */ 01280 static function globalPathList() 01281 { 01282 if ( !isset( $GLOBALS['eZModuleGlobalPathList'] ) ) 01283 return null; 01284 return $GLOBALS['eZModuleGlobalPathList']; 01285 } 01286 01287 /*! 01288 \static 01289 \return a path list of currently active modules 01290 */ 01291 static function activeModuleRepositories( $useExtensions = true ) 01292 { 01293 //include_once( 'lib/ezutils/classes/ezini.php' ); 01294 //include_once( 'lib/ezutils/classes/ezextension.php' ); 01295 $moduleINI = eZINI::instance( 'module.ini' ); 01296 $moduleRepositories = $moduleINI->variable( 'ModuleSettings', 'ModuleRepositories' ); 01297 01298 if ( $useExtensions ) 01299 { 01300 $extensionRepositories = $moduleINI->variable( 'ModuleSettings', 'ExtensionRepositories' ); 01301 $extensionDirectory = eZExtension::baseDirectory(); 01302 $activeExtensions = eZExtension::activeExtensions(); 01303 $globalExtensionRepositories = array(); 01304 01305 foreach ( $extensionRepositories as $extensionRepository ) 01306 { 01307 $extPath = $extensionDirectory . '/' . $extensionRepository; 01308 $modulePath = $extPath . '/modules'; 01309 if ( file_exists( $modulePath ) ) 01310 { 01311 $globalExtensionRepositories[] = $modulePath; 01312 } 01313 else if ( !file_exists( $extPath ) ) 01314 { 01315 eZDebug::writeWarning( "Extension '$extensionRepository' was reported to have modules but the extension itself does not exist.\n" . 01316 "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions.\n" . 01317 "You should probably remove this extension from the list." ); 01318 } 01319 else if ( !in_array( $extensionRepository, $activeExtensions ) ) 01320 { 01321 eZDebug::writeWarning( "Extension '$extensionRepository' was reported to have modules but has not yet been activated.\n" . 01322 "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions\n" . 01323 "or make sure it is activated in the setting ExtensionSettings/ActiveExtensions in site.ini." ); 01324 } 01325 else 01326 { 01327 eZDebug::writeWarning( "Extension '$extensionRepository' does not have the subdirectory 'modules' allthough it reported it had modules.\n" . 01328 "Looked for directory '" . $modulePath . "'\n" . 01329 "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extension." ); 01330 } 01331 } 01332 01333 $moduleRepositories = array_merge( $moduleRepositories, $globalExtensionRepositories ); 01334 } 01335 01336 return $moduleRepositories; 01337 } 01338 01339 /*! 01340 \static 01341 Sets the global path list which is used for finding modules. 01342 \param $pathList Is either an array with path strings or a single path string 01343 \sa addGlobalPathList 01344 */ 01345 static function setGlobalPathList( $pathList ) 01346 { 01347 if ( !is_array( $pathList ) ) 01348 $pathList = array( $pathList ); 01349 $GLOBALS['eZModuleGlobalPathList'] = $pathList; 01350 } 01351 01352 /*! 01353 \static 01354 Adds the pathlist entries \a $pathList to the global path list which is used for finding modules. 01355 \param $pathList Is either an array with path strings or a single path string 01356 \sa setGlobalPathList 01357 */ 01358 static function addGlobalPathList( $pathList ) 01359 { 01360 if ( !is_array( $GLOBALS['eZModuleGlobalPathList'] ) ) 01361 { 01362 $GLOBALS['eZModuleGlobalPathList'] = array(); 01363 } 01364 if ( !is_array( $pathList ) ) 01365 { 01366 $pathList = array( $pathList ); 01367 } 01368 $GLOBALS['eZModuleGlobalPathList'] = array_merge( $GLOBALS['eZModuleGlobalPathList'], $pathList ); 01369 } 01370 01371 /*! 01372 \static 01373 Tries to locate the module named \a $moduleName and returns an eZModule object 01374 for it. Returns \c null if no module can be found. 01375 01376 It uses the globalPathList() to search for modules, use \a $pathList to add 01377 additional path. 01378 \param $moduleName The name of the module to find 01379 \param $pathList Is either an array with path strings or a single path string 01380 \param $showError If true an error will be shown if the module it not found. 01381 */ 01382 static function exists( $moduleName, $pathList = null, $showError = false ) 01383 { 01384 $module = null; 01385 return eZModule::findModule( $moduleName, $module, $pathList, $showError ); 01386 } 01387 01388 /*! 01389 \static 01390 Tries to locate the module named \a $moduleName, sets the \a $module parameter with the eZModule object 01391 and returns the eZModule object. If \a $module is already a module object its contents are overwritten. 01392 Returns \c null if no module can be found. 01393 01394 It uses the globalPathList() to search for modules, use \a $pathList to add 01395 additional path. 01396 \param $moduleName The name of the module to find 01397 \param $module 01398 \param $pathList Is either an array with path strings or a single path string 01399 \param $showError If true an error will be shown if the module it not found. 01400 */ 01401 static function findModule( $moduleName, $module = null, $pathList = null, $showError = false ) 01402 { 01403 if ( $pathList === null ) 01404 $pathList = array(); 01405 else if ( !is_array( $pathList ) ) 01406 $pathList = array( $pathList ); 01407 $searchPathList = eZModule::globalPathList(); 01408 if ( $searchPathList === null ) 01409 $searchPathList = array(); 01410 $searchPathList = array_merge( $searchPathList, $pathList ); 01411 $triedList = array(); 01412 $triedDirList = array(); 01413 $foundADir = false; 01414 foreach ( $searchPathList as $path ) 01415 { 01416 $dir = "$path/$moduleName"; 01417 $file = "$dir/module.php"; 01418 if ( file_exists( $file ) ) 01419 { 01420 if ( $module === null ) 01421 $module = new eZModule( $path, $file, $moduleName ); 01422 else 01423 $module->initialize( $path, $file, $moduleName ); 01424 return $module; 01425 } 01426 else if ( !file_exists( $dir ) ) 01427 { 01428 $triedDirList[] = $dir; 01429 } 01430 else 01431 { 01432 $foundADir = true; 01433 $triedList[] = $dir; 01434 } 01435 } 01436 01437 $msg = "Could not find module named '$moduleName'"; 01438 if ( $foundADir ) 01439 { 01440 $msg = "\nThese directories had a directory named '$moduleName' but did not contain the module.php file:\n" . 01441 implode( ", ", $triedList ) . "\n" . 01442 "This usually means it is missing or has a wrong name."; 01443 if ( count( $triedDirList ) > 0 ) 01444 $msg .= "\n\nThese directories were tried too but none of them exists:\n" . implode( ', ', $triedDirList ); 01445 } 01446 else 01447 { 01448 if ( count( $triedDirList ) > 0 ) 01449 $msg.= "\nThese directories were tried but none of them exists:\n" . implode( ", ", $triedDirList ); 01450 } 01451 if ( $showError ) 01452 eZDebug::writeWarning( $msg ); 01453 01454 return null; 01455 } 01456 01457 function getNamedParameters() 01458 { 01459 return $this->NamedParameters; 01460 } 01461 01462 /// \privatesection 01463 public $Functions; 01464 public $Module; 01465 public $Name; 01466 public $Path; 01467 public $ExitStatus; 01468 public $ErrorCode; 01469 public $RedirectURI; 01470 public $RedirectStatus; 01471 public $Title; 01472 public $HookList; 01473 public $ViewActions; 01474 public $ViewResult; 01475 public $ViewParameters; 01476 public $OriginalParameters; 01477 public $OriginalViewParameters; 01478 public $NamedParameters; 01479 public $OriginalUnorderedParameters; 01480 public $UserParameters; 01481 01482 /// The current UI context, by default 'navigation' but can be changed depending on module or PHP code 01483 public $UIContext; 01484 /// The current UI context, by default the current module but can be changed depending on module or PHP code 01485 public $UIComponent; 01486 /// Controls at which level UI component matching is done, either 'module' which uses module name or 'view' which uses view name 01487 public $UIComponentMatch; 01488 } 01489 01490 ?>