| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Created on: <24-Apr-2002 11:18:59 bf> 4 // 5 // SOFTWARE NAME: eZ publish 6 // SOFTWARE RELEASE: 3.9.0 7 // BUILD VERSION: 17785 8 // COPYRIGHT NOTICE: Copyright (C) 1999-2006 eZ systems AS 9 // SOFTWARE LICENSE: GNU General Public License v2.0 10 // NOTICE: > 11 // This program is free software; you can redistribute it and/or 12 // modify it under the terms of version 2.0 of the GNU General 13 // Public License as published by the Free Software Foundation. 14 // 15 // This program is distributed in the hope that it will be useful, 16 // but WITHOUT ANY WARRANTY; without even the implied warranty of 17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 // GNU General Public License for more details. 19 // 20 // You should have received a copy of version 2.0 of the GNU General 21 // Public License along with this program; if not, write to the Free 22 // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 23 // MA 02110-1301, USA. 24 // 25 // 26 27 include_once ( 'kernel/classes/ezcontentobject.php' ); 28 include_once ( 'kernel/classes/ezcontentclass.php' ); 29 include_once ( 'kernel/classes/ezcontentobjecttreenode.php' ); 30 include_once ( 'kernel/classes/eznodeviewfunctions.php' ); 31 32 include_once ( 'lib/ezutils/classes/ezhttptool.php' ); 33 34 include_once ( 'kernel/common/template.php' ); 35 36 $http =& eZHTTPTool::instance(); 37 38 $tpl =& templateInit(); 39 40 $ViewMode = $Params['ViewMode']; 41 $NodeID = $Params['NodeID']; 42 $Module =& $Params['Module']; 43 $LanguageCode = $Params['Language']; 44 $Offset = $Params['Offset']; 45 $Year = $Params['Year']; 46 $Month = $Params['Month']; 47 $Day = $Params['Day']; 48 49 // Check if we should switch access mode (http/https) for this node. 50 include_once ( 'kernel/classes/ezsslzone.php' ); 51 eZSSLZone::checkNodeID( 'content', 'view', $NodeID ); 52 53 if ( isset( $Params['UserParameters'] ) ) 54 { 55 $UserParameters = $Params['UserParameters']; 56 } 57 else 58 { 59 $UserParameters = array(); 60 } 61 62 if ( $Offset ) 63 $Offset = (int) $Offset; 64 if ( $Year ) 65 $Year = (int) $Year; 66 if ( $Month ) 67 $Month = (int) $Month; 68 if ( $Day ) 69 $Day = (int) $Day; 70 71 if ( $NodeID < 2 ) 72 $NodeID = 2; 73 74 if ( !is_numeric( $Offset ) ) 75 $Offset = 0; 76 77 $ini =& eZINI::instance(); 78 $viewCacheEnabled = ( $ini->variable( 'ContentSettings', 'ViewCaching' ) == 'enabled' ); 79 80 if ( isset( $Params['ViewCache'] ) ) 81 { 82 $viewCacheEnabled = $Params['ViewCache']; 83 } 84 elseif ( $viewCacheEnabled && !in_array( $ViewMode, $ini->variableArray( 'ContentSettings', 'CachedViewModes' ) ) ) 85 { 86 $viewCacheEnabled = false; 87 } 88 89 $collectionAttributes = false; 90 if ( isset( $Params['CollectionAttributes'] ) ) 91 $collectionAttributes = $Params['CollectionAttributes']; 92 93 $validation = array( 'processed' => false, 94 'attributes' => array() ); 95 if ( isset( $Params['AttributeValidation'] ) ) 96 $validation = $Params['AttributeValidation']; 97 98 // Check if read operations should be used 99 $workflowINI =& eZINI::instance( 'workflow.ini' ); 100 $operationList = $workflowINI->variableArray( 'OperationSettings', 'AvailableOperations' ); 101 $operationList = array_unique( array_merge( $operationList, $workflowINI->variable( 'OperationSettings', 'AvailableOperationList' ) ) ); 102 if ( in_array( 'content_read', $operationList ) ) 103 { 104 $useTriggers = true; 105 } 106 else 107 { 108 $useTriggers = false; 109 } 110 111 $res =& eZTemplateDesignResource::instance(); 112 $keys =& $res->keys(); 113 if ( isset( $keys['layout'] ) ) 114 $layout = $keys['layout']; 115 else 116 $layout = false; 117 118 $viewParameters = array( 'offset' => $Offset, 119 'year' => $Year, 120 'month' => $Month, 121 'day' => $Day, 122 'namefilter' => false ); 123 $viewParameters = array_merge( $viewParameters, $UserParameters ); 124 125 $user =& eZUser::currentUser(); 126 127 eZDebugSetting::addTimingPoint( 'kernel-content-view', 'Operation start' ); 128 129 130 include_once ( 'lib/ezutils/classes/ezmoduleoperationdefinition.php' ); 131 132 $operationResult = array(); 133 134 if ( $useTriggers == true ) 135 { 136 include_once ( 'lib/ezutils/classes/ezoperationhandler.php' ); 137 include_once ( 'kernel/classes/eztrigger.php' ); 138 139 $operationResult = eZOperationHandler::execute( 'content', 'read', array( 'node_id' => $NodeID, 140 'user_id' => $user->id(), 141 'language_code' => $LanguageCode ), null, $useTriggers ); 142 } 143 144 if ( ( array_key_exists( 'status', $operationResult ) && $operationResult['status'] != EZ_MODULE_OPERATION_CONTINUE ) ) 145 { 146 switch( $operationResult['status'] ) 147 { 148 case EZ_MODULE_OPERATION_HALTED: 149 { 150 if ( isset( $operationResult['redirect_url'] ) ) 151 { 152 $Module->redirectTo( $operationResult['redirect_url'] ); 153 return; 154 } 155 else if ( isset( $operationResult['result'] ) ) 156 { 157 $result =& $operationResult['result']; 158 $resultContent = false; 159 if ( is_array( $result ) ) 160 { 161 if ( isset( $result['content'] ) ) 162 $resultContent = $result['content']; 163 if ( isset( $result['path'] ) ) 164 $Result['path'] = $result['path']; 165 } 166 else 167 $resultContent =& $result; 168 $Result['content'] =& $resultContent; 169 } 170 }break; 171 case EZ_MODULE_OPERATION_CANCELED: 172 { 173 $Result = array(); 174 $Result['content'] = "Content view cancelled<br/>"; 175 } 176 } 177 return $Result; 178 } 179 else 180 { 181 if ( $viewCacheEnabled ) 182 { 183 $cacheExpired = false; 184 $user =& eZUser::currentUser(); 185 186 $cacheFileArray = eZNodeviewfunctions::generateViewCacheFile( $user, $NodeID, $Offset, $layout, $LanguageCode, $ViewMode, $viewParameters ); 187 188 // VS-DBFILE 189 190 $cacheFilePath = $cacheFileArray['cache_path']; 191 require_once ( 'kernel/classes/ezclusterfilehandler.php' ); 192 $cacheFile = eZClusterFileHandler::instance( $cacheFilePath ); 193 $stat = $cacheFile->stat(); 194 195 // Read Cache file 196 if ( isset( $stat['mtime'] ) && !eZContentObject::isCacheExpired( $stat['mtime'] ) ) 197 { 198 $contents = $cacheFile->fetchContents(); 199 $Result = unserialize( $contents ); 200 201 // Check if cache has expired when cache_ttl is set 202 $cacheTTL = isset( $Result['cache_ttl'] ) ? $Result['cache_ttl'] : -1; 203 if ( $cacheTTL > 0 ) 204 { 205 $expiryTime = $stat['mtime'] + $cacheTTL; 206 if ( time() > $expiryTime ) 207 { 208 $cacheExpired = true; 209 } 210 } 211 212 // Check if template source files are newer, but only if the cache is not expired 213 if ( !$cacheExpired ) 214 { 215 $developmentModeEnabled = $ini->variable( 'TemplateSettings', 'DevelopmentMode' ) == 'enabled'; 216 // Only do filemtime checking when development mode is enabled. 217 if ( $developmentModeEnabled && 218 isset( $Result['template_list'] ) ) // And only if there is a list stored in the cache 219 { 220 foreach ( $Result['template_list'] as $templateFile ) 221 { 222 if ( @filemtime( $templateFile ) > $stat['mtime'] ) 223 { 224 $cacheExpired = true; 225 break; 226 } 227 } 228 } 229 } 230 231 if ( !$cacheExpired ) 232 { 233 $keyArray = array( array( 'object', $Result['content_info']['object_id'] ), 234 array( 'node', $Result['content_info']['node_id'] ), 235 array( 'parent_node', $Result['content_info']['parent_node_id'] ), 236 array( 'class', $Result['content_info']['class_id'] ), 237 array( 'view_offset', $Result['content_info']['offset'] ), 238 array( 'navigation_part_identifier', $Result['content_info']['navigation_part_identifier'] ), 239 array( 'viewmode', $Result['content_info']['viewmode'] ), 240 array( 'depth', $Result['content_info']['node_depth'] ), 241 array( 'url_alias', $Result['content_info']['url_alias'] ), 242 array( 'persistent_variable', $Result['content_info']['persistent_variable'] ), 243 array( 'class_group', $Result['content_info']['class_group'] ), 244 array( 'parent_class_id', $Result['content_info']['parent_class_id'] ), 245 array( 'parent_class_identifier', $Result['content_info']['parent_class_identifier'] ) ); 246 247 if ( isset( $Result['content_info']['class_identifier'] ) ) 248 $keyArray[] = array( 'class_identifier', $Result['content_info']['class_identifier'] ); 249 250 $res =& eZTemplateDesignResource::instance(); 251 $res->setKeys( $keyArray ); 252 253 // set section id 254 include_once ( 'kernel/classes/ezsection.php' ); 255 eZSection::setGlobalID( $Result['section_id'] ); 256 257 return $Result; 258 } 259 } 260 } 261 else 262 { 263 $cacheFileArray = array( 'cache_dir' => false, 'cache_path' => false ); 264 } 265 266 $node = eZContentObjectTreeNode::fetch( $NodeID ); 267 268 if ( !is_object( $node ) ) 269 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 270 271 $object =& $node->attribute( 'object' ); 272 273 if ( !is_object( $object ) ) 274 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 275 276 if ( !get_class( $object ) == 'ezcontentobject' ) 277 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 278 279 if ( $node === null ) 280 return $Module->handleError( EZ_ERROR_KERNEL_NOT_AVAILABLE, 'kernel' ); 281 282 if ( $object === null ) 283 return $Module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel' ); 284 285 if ( $node->attribute( 'is_invisible' ) && !eZContentObjectTreeNode::showInvisibleNodes() ) 286 return $Module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel' ); 287 288 // if ( !$object->attribute( 'can_read' ) ) 289 if ( !$object->canRead() ) 290 { 291 return $Module->handleError( EZ_ERROR_KERNEL_ACCESS_DENIED, 'kernel', array( 'AccessList' => $object->accessList( 'read' ) ) ); 292 } 293 294 $Result =& eZNodeviewfunctions::generateNodeView( $tpl, $node, $object, $LanguageCode, $ViewMode, $Offset, 295 $cacheFileArray['cache_dir'], $cacheFileArray['cache_path'], $viewCacheEnabled, $viewParameters, 296 $collectionAttributes, $validation ); 297 298 return $Result; 299 } 300 301 302 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Sat Feb 24 10:30:04 2007 | par Balluche grâce à PHPXref 0.7 |