| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZTemplateCacheFunction class 4 // 5 // Created on: <28-Feb-2003 15:06:33 bf> 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 /*! 30 \class eZTemplateCacheFunction eztemplatecachefunction.php 31 \ingroup eZTemplateFunctions 32 \brief Advanced cache handling 33 34 */ 35 36 define( 'eZTemplateCacheFunction_FileGenerateTimeout', 5 ); 37 38 class eZTemplateCacheFunction 39 { 40 /*! 41 Initializes the object with names. 42 */ 43 function eZTemplateCacheFunction( $blockName = 'cache-block' ) 44 { 45 $this->BlockName = $blockName; 46 } 47 48 /*! 49 Returns an array containing the name of the block function, default is "block". 50 The name is specified in the constructor. 51 */ 52 function functionList() 53 { 54 return array( $this->BlockName ); 55 } 56 57 function functionTemplateHints() 58 { 59 return array( $this->BlockName => array( 'parameters' => true, 60 'static' => false, 61 'transform-children' => true, 62 'tree-transformation' => true, 63 'transform-parameters' => true ) ); 64 } 65 66 function templateNodeTransformation( $functionName, &$node, 67 &$tpl, $parameters, $privateData ) 68 { 69 $ini =& eZINI::instance(); 70 $children = eZTemplateNodeTool::extractFunctionNodeChildren( $node ); 71 if ( $ini->variable( 'TemplateSettings', 'TemplateCache' ) != 'enabled' ) 72 { 73 return $children; 74 } 75 76 $functionPlacement = eZTemplateNodeTool::extractFunctionNodePlacement( $node ); 77 $placementKeyString = $functionPlacement[0][0] . "_"; 78 $placementKeyString .= $functionPlacement[0][1] . "_"; 79 $placementKeyString .= $functionPlacement[1][0] . "_"; 80 $placementKeyString .= $functionPlacement[1][1] . "_"; 81 $placementKeyString .= $functionPlacement[2] . "_"; 82 83 $newNodes = array(); 84 $ignoreExpiry = false; 85 $ignoreContentExpiry = false; 86 87 $expiry = 60*60*2; 88 if ( isset( $parameters['expiry'] ) ) 89 { 90 if ( eZTemplateNodeTool::isStaticElement( $parameters['expiry'] ) ) 91 { 92 $expiryValue = eZTemplateNodeTool::elementStaticValue( $parameters['expiry'] ); 93 94 if ( $expiryValue ) 95 { 96 $expiryText = eZPHPCreator::variableText( $expiryValue , 0, 0, false ); 97 } 98 else 99 { 100 $ignoreExpiry = true; 101 } 102 } 103 else 104 { 105 $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $parameters['expiry'], false, array(), 'localExpiry' ); 106 $expiryText = "\$localExpiry"; 107 } 108 } 109 else 110 { 111 $expiryText = eZPHPCreator::variableText( $expiry , 0, 0, false ); 112 } 113 114 if ( isset( $parameters['ignore_content_expiry'] ) ) 115 { 116 $ignoreContentExpiry = eZTemplateNodeTool::elementStaticValue( $parameters['ignore_content_expiry'] ); 117 } 118 119 $keysData = false; 120 $keyValue = false; 121 $keyValueText = false; 122 $useDynamicKeys = false; 123 $subtreeExpiryData = false; 124 if ( isset( $parameters['keys'] ) ) 125 { 126 $keysData = $parameters['keys']; 127 if ( !eZTemplateNodeTool::isStaticElement( $keysData ) ) 128 { 129 $useDynamicKeys = true; 130 } 131 else 132 { 133 $keyValue = eZTemplateNodeTool::elementStaticValue( $keysData ); 134 $keyValueText = $keyValue . '_'; 135 } 136 } 137 if ( isset( $parameters['subtree_expiry'] ) ) 138 { 139 $subtreeExpiryData = $parameters['subtree_expiry']; 140 if ( !eZTemplateNodeTool::isStaticElement( $subtreeExpiryData ) ) 141 $useDynamicKeys = true; 142 else 143 $subtreeValue = eZTemplateNodeTool::elementStaticValue( $subtreeExpiryData ); 144 145 $ignoreContentExpiry = true; 146 } 147 if ( $useDynamicKeys ) 148 { 149 $accessName = false; 150 if ( isset( $GLOBALS['eZCurrentAccess']['name'] ) ) 151 $accessName = $GLOBALS['eZCurrentAccess']['name']; 152 $extraKeyString = $placementKeyString . $accessName; 153 $extraKeyText = eZPHPCreator::variableText( $extraKeyString, 0, 0, false ); 154 $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $keysData, false, array(), 'cacheKeys' ); 155 $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $subtreeExpiryData, false, array(), 'subtreeExpiry' ); 156 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "if ( is_array( \$cacheKeys ) )\n \$cacheKeys = implode( '_', \$cacheKeys ) . '_';\nelse\n \$cacheKeys .= '_';" ); 157 $cacheDir = eZTemplateCacheFunction::templateBlockCacheDir(); 158 $cachePathText = eZPHPCreator::variableText( "$cacheDir", 0, 0, false ); 159 $code = ( "include_once ( 'lib/ezutils/classes/ezsys.php' );\n" . 160 "\$keyString = eZSys::ezcrc32( \$cacheKeys . $extraKeyText );\n" . 161 "\$cacheFilename = \$keyString . '.cache';\n" . 162 "if ( isset( \$subtreeExpiry ) && \$subtreeExpiry !== false )\n" . 163 "{\n" . 164 " include_once ( 'lib/eztemplate/classes/eztemplatecachefunction.php' );\n" . 165 " \$cacheDir = $cachePathText . eZTemplateCacheFunction::subtreeCacheSubDir( \$subtreeExpiry, \$cacheFilename );\n" . 166 "}\n" . 167 "else\n" . 168 "{\n" . 169 " \$cacheDir = $cachePathText . \$keyString[0] . '/' . \$keyString[1] . '/' . \$keyString[2];\n" . 170 "}\n" . 171 "\$cachePath = \$cacheDir . '/' . \$cacheFilename;" ); 172 } 173 else 174 { 175 $accessName = false; 176 if ( isset( $GLOBALS['eZCurrentAccess']['name'] ) ) 177 $accessName = $GLOBALS['eZCurrentAccess']['name']; 178 179 include_once ( 'lib/ezutils/classes/ezsys.php' ); 180 $keyString = eZSys::ezcrc32( $keyValueText . $placementKeyString . $accessName ); 181 $cacheFilename = $keyString . '.cache'; 182 $cacheDir = eZTemplateCacheFunction::templateBlockCacheDir(); 183 if ( isset( $subtreeValue ) ) 184 $cacheDir = "$cacheDir" . eZTemplateCacheFunction::subtreeCacheSubDir( $subtreeValue, $cacheFilename ); 185 else 186 $cacheDir = "$cacheDir" . $keyString[0] . '/' . $keyString[1] . '/' . $keyString[2]; 187 188 $cachePath = "$cacheDir" . '/' . $cacheFilename; 189 $code = ( "\$keyString = '$keyString';\n" . 190 "\$cacheDir = '$cacheDir';\n" . 191 "\$cachePath = '$cachePath';" ); 192 } 193 194 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( $code ); 195 $filedirText = "\$cacheDir"; 196 $filepathText = "\$cachePath"; 197 198 $code = ''; 199 200 if ( !$ignoreContentExpiry ) 201 { 202 $code .= <<<ENDADDCODE 203 include_once ( 'lib/ezutils/classes/ezexpiryhandler.php' ); 204 \$handler =& eZExpiryHandler::instance(); 205 \$globalExpiryTime = -1; 206 if ( \$handler->hasTimestamp( 'template-block-cache' ) ) 207 { 208 \$globalExpiryTime = \$handler->timestamp( 'template-block-cache' ); 209 } 210 211 ENDADDCODE; 212 } 213 214 // VS-DBFILE 215 216 $code .= 217 "require_once ( 'kernel/classes/ezclusterfilehandler.php' );\n" . 218 "\$cacheFile = eZClusterFileHandler::instance( $filepathText );\n" . 219 "if ( \$cacheFile->exists()"; 220 221 if ( !$ignoreExpiry ) { 222 $code .= "\n and \$cacheFile->mtime() >= ( time() - $expiryText )"; 223 } 224 if ( !$ignoreContentExpiry ) { 225 $code .= "\n and ( ( \$cacheFile->mtime() > \$globalExpiryTime ) or ( \$globalExpiryTime == -1 ) )"; 226 } 227 $code .= " )\n" . 228 "{\n" . 229 " \$contentData = \$cacheFile->size() ? \$cacheFile->fetchContents() : '';\n"; 230 231 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( $code, array( 'spacing' => 0 ) ); 232 $newNodes[] = eZTemplateNodeTool::createWriteToOutputVariableNode( 'contentData', array( 'spacing' => 4 ) ); 233 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( " unset( \$contentData );\n" . 234 "}\n" . 235 "else\n" . 236 "{" ); 237 238 // Check if cache gen file exists, and wait 239 // for eZTemplateFunction_FileGenerateTimeout seconds if it does. 240 $code = 241 "\$phpPathGen = $filepathText . '.gen';\n" . 242 "\$cacheGenFile = eZClusterFileHandler::instance( \$phpPathGen );\n" . 243 "while( \$cacheGenFile->exists() &&\n" . 244 "\$cacheGenFile->mtime() + " . eZTemplateCacheFunction_FileGenerateTimeout . " < mktime() )\n" . 245 "{\n" . 246 "sleep( 1 );\n" . 247 "\$cacheGenFile->loadMetaData();\n" . 248 "}\n"; 249 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( $code, array( 'spacing' => 0 ) ); 250 251 252 // Cache file might have been generated by now. 253 $code = "\$cacheFile->loadMetaData();\n". 254 "if ( \$cacheFile->exists()"; 255 if ( !$ignoreExpiry ) { 256 $code .= "\n and \$cacheFile->mtime() >= ( time() - $expiryText )"; 257 } 258 if ( !$ignoreContentExpiry ) { 259 $code .= "\n and ( ( \$cacheFile->mtime() > \$globalExpiryTime ) or ( \$globalExpiryTime == -1 ) )"; 260 } 261 $code .= " )\n" . 262 "{\n" . 263 " \$contentData = \$cacheFile->size() ? \$cacheFile->fetchContents() : '';\n"; 264 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( $code ); 265 $newNodes[] = eZTemplateNodeTool::createWriteToOutputVariableNode( 'contentData', array( 'spacing' => 4 ) ); 266 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( " unset( \$contentData );\n" . 267 "}\n" . 268 "else\n" . 269 "{" ); 270 271 // Create tmp cache file 272 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "\$cacheGenFile->storeContents( '1' );" ); 273 274 275 $newNodes[] = eZTemplateNodeTool::createOutputVariableIncreaseNode( array( 'spacing' => 4 ) ); 276 $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode( 4 ); 277 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "if ( !isset( \$cacheStack ) )\n" . 278 " \$cacheStack = array();\n" . 279 "\$cacheEntry = array( \$cacheDir, \$cachePath, \$keyString, false );\n" . 280 "if ( isset( \$subtreeExpiry ) )\n" . 281 " \$cacheEntry[3] = \$subtreeExpiry;\n" . 282 "\$cacheStack[] = \$cacheEntry;" ); 283 $newNodes = array_merge( $newNodes, $children ); 284 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "list( \$cacheDir, \$cachePath, \$keyString, \$subtreeExpiry ) = array_pop( \$cacheStack );" ); 285 $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode( 4 ); 286 $newNodes[] = eZTemplateNodeTool::createAssignFromOutputVariableNode( 'cachedText', array( 'spacing' => 4 ) ); 287 $ini =& eZINI::instance(); 288 $perm = octdec( $ini->variable( 'FileSettings', 'StorageDirPermissions' ) ); 289 $code = ( "include_once ( 'lib/ezfile/classes/ezdir.php' );\n" . 290 "\$uniqid = md5( uniqid( 'ezpcache'. getmypid(), true ) );\n" . 291 "eZDir::mkdir( $filedirText, $perm, true );\n" . 292 "\$fd = fopen( $filedirText. '/'. \$uniqid, 'w' );\n" . 293 "fwrite( \$fd, \$cachedText );\n" . 294 "fclose( \$fd );\n" ); 295 /* On windows we need to unlink the destination file first */ 296 if ( strtolower( substr( PHP_OS, 0, 3 ) ) == 'win' ) 297 { 298 $code .= "@unlink( $filepathText );\n"; 299 } 300 $code .= "rename( $filedirText. '/'. \$uniqid, $filepathText );\n" . 301 "\$cacheGenFile->delete();\n" . 302 "unset( \$cacheGenFile );"; 303 304 // VS-DBFILE 305 306 $code .= 307 "require_once ( 'kernel/classes/ezclusterfilehandler.php' );\n" . 308 "\$fileHandler = eZClusterFileHandler::instance();\n" . 309 "\$fileHandler->fileStore( $filepathText, 'template-block', true );\n"; 310 311 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( $code, array( 'spacing' => 4 ) ); 312 $newNodes[] = eZTemplateNodeTool::createOutputVariableDecreaseNode( array( 'spacing' => 4 ) ); 313 $newNodes[] = eZTemplateNodeTool::createWriteToOutputVariableNode( 'cachedText', array( 'spacing' => 4 ) ); 314 $newNodes[] = eZTemplateNodeTool::createCodePieceNode( " unset( \$cachedText );\n}}" ); 315 return $newNodes; 316 } 317 318 /*! 319 Processes the function with all it's children. 320 */ 321 function process( &$tpl, &$textElements, $functionName, $functionChildren, $functionParameters, $functionPlacement, $rootNamespace, $currentNamespace ) 322 { 323 switch ( $functionName ) 324 { 325 case $this->BlockName: 326 { 327 // Check for disabled cache. 328 $ini =& eZINI::instance(); 329 if ( $ini->variable( 'TemplateSettings', 'TemplateCache' ) != 'enabled' ) 330 { 331 $children = $functionChildren; 332 333 $childTextElements = array(); 334 foreach ( array_keys( $children ) as $childKey ) 335 { 336 $child =& $children[$childKey]; 337 $tpl->processNode( $child, $childTextElements, $rootNamespace, $currentNamespace ); 338 } 339 $text = implode( '', $childTextElements ); 340 $textElements[] = $text; 341 } 342 else 343 { 344 $keyString = ""; 345 // Get cache keys 346 if ( isset( $functionParameters["keys"] ) ) 347 { 348 $keys = $tpl->elementValue( $functionParameters["keys"], $rootNamespace, $currentNamespace, $functionPlacement ); 349 350 if ( is_array( $keys ) ) 351 { 352 foreach ( $keys as $key ) 353 { 354 $keyString .= $key . "_"; 355 } 356 } 357 else 358 { 359 $keyString .= $keys . "_"; 360 } 361 } 362 363 // Append keys from position in template 364 $keyString .= $functionPlacement[0][0] . "_"; 365 $keyString .= $functionPlacement[0][1] . "_"; 366 $keyString .= $functionPlacement[1][0] . "_"; 367 $keyString .= $functionPlacement[1][1] . "_"; 368 $keyString .= $functionPlacement[2] . "_"; 369 370 // Fetch the current siteaccess 371 $accessName = false; 372 if ( isset( $GLOBALS['eZCurrentAccess']['name'] ) ) 373 $accessName = $GLOBALS['eZCurrentAccess']['name']; 374 $keyString .= $accessName; 375 376 include_once ( 'lib/ezutils/classes/ezsys.php' ); 377 $hashedKey = eZSys::ezcrc32( $keyString ); 378 379 $cacheFilename = $hashedKey . ".cache"; 380 381 $phpDir = eZTemplateCacheFunction::templateBlockCacheDir(); 382 if ( isset( $functionParameters['subtree_expiry'] ) ) 383 $phpDir .= eZTemplateCacheFunction::subtreeCacheSubDir( $tpl->elementValue( $functionParameters["subtree_expiry"], $rootNamespace, $currentNamespace, $functionPlacement ), $cacheFilename ); 384 else 385 $phpDir .= $hashedKey[0] . '/' . $hashedKey[1] . '/' . $hashedKey[2]; 386 387 $phpPath = $phpDir . '/' . $cacheFilename; 388 389 // Check if a custom expiry time is defined 390 if ( isset( $functionParameters["expiry"] ) ) 391 { 392 $expiry = $tpl->elementValue( $functionParameters["expiry"], $rootNamespace, $currentNamespace, $functionPlacement ); 393 } 394 else 395 { 396 // Default expiry time is set to two hours 397 $expiry = 60*60*2; 398 } 399 400 $localExpiryTime = 0; 401 if ( $expiry > 0 ) 402 $localExpiryTime = time() - $expiry; 403 404 $ignoreContentExpiry = false; 405 if ( isset( $functionParameters["ignore_content_expiry"] ) ) 406 { 407 $ignoreContentExpiry = $tpl->elementValue( $functionParameters["ignore_content_expiry"], $rootNamespace, $currentNamespace, $functionPlacement ) === true; 408 } 409 if ( isset( $functionParameters['subtree_expiry'] ) ) 410 { 411 $ignoreContentExpiry = true; 412 } 413 414 $expiryTime = $localExpiryTime; 415 if ( $ignoreContentExpiry == false ) 416 { 417 include_once ( 'lib/ezutils/classes/ezexpiryhandler.php' ); 418 $handler =& eZExpiryHandler::instance(); 419 if ( $handler->hasTimestamp( 'template-block-cache' ) ) 420 { 421 $globalExpiryTime = $handler->timestamp( 'template-block-cache' ); 422 $expiryTime = max( $localExpiryTime, $globalExpiryTime ); 423 } 424 } 425 426 // Check if we can restore 427 require_once ( 'kernel/classes/ezclusterfilehandler.php' ); 428 $cacheFile = eZClusterFileHandler::instance( $phpPath ); 429 if ( $cacheFile->exists() && $cacheFile->mtime() >= $expiryTime ) 430 { 431 $textElements[] = $cacheFile->fetchContents(); 432 return; 433 } 434 435 // Check if cache gen file exists, and wait 436 // for eZTemplateFunction_FileGenerateTimeout seconds if it does. 437 $phpPathGen = $phpPath . '.gen'; 438 $cacheGenFile = eZClusterFileHandler::instance( $phpPathGen ); 439 while( $cacheGenFile->exists() && 440 $cacheGenFile->mtime() + eZTemplateCacheFunction_FileGenerateTimeout < mktime() ) 441 { 442 sleep( 1 ); 443 $cacheGenFile->loadMetaData(); 444 } 445 446 // Cache file might have been generated by now. 447 $cacheFile->loadMetaData(); 448 if ( $cacheFile->exists() && $cacheFile->mtime() >= $expiryTime ) 449 { 450 $textElements[] = $cacheFile->fetchContents(); 451 return; 452 } 453 454 $cacheGenFile->storeContents( '1' ); 455 456 // If no cache or expired cache, load data 457 $children = $functionChildren; 458 459 $childTextElements = array(); 460 if ( is_array( $children ) ) 461 { 462 foreach ( array_keys( $children ) as $childKey ) 463 { 464 $child =& $children[$childKey]; 465 $tpl->processNode( $child, $childTextElements, $rootNamespace, $currentNamespace ); 466 } 467 } 468 $text = implode( '', $childTextElements ); 469 $textElements[] = $text; 470 471 include_once ( 'lib/ezfile/classes/ezfile.php' ); 472 $ini =& eZINI::instance(); 473 $perm = octdec( $ini->variable( 'FileSettings', 'StorageDirPermissions' ) ); 474 $uniqid = md5( uniqid( 'ezpcache'. getmypid(), true ) ); 475 eZDir::mkdir( $phpDir, $perm, true ); 476 $fd = fopen( "$phpDir/$uniqid", 'w' ); 477 fwrite( $fd, $text ); 478 fclose( $fd ); 479 eZFile::rename( "$phpDir/$uniqid", $phpPath ); 480 481 // VS-DBFILE 482 require_once ( 'kernel/classes/ezclusterfilehandler.php' ); 483 $fileHandler = eZClusterFileHandler::instance(); 484 $fileHandler->fileStore( $phpPath, 'template-block', true ); 485 486 // Clean up "lock" file. 487 $cacheGenFile->delete(); 488 } 489 } break; 490 } 491 } 492 493 /*! 494 Returns true. 495 */ 496 function hasChildren() 497 { 498 return true; 499 } 500 501 /*! 502 \static 503 Returns base directory where 'subtree_expiry' caches are stored. 504 */ 505 function subtreeCacheBaseSubDir() 506 { 507 return 'subtree'; 508 } 509 510 /*! 511 \static 512 Returns base directory where expired 'subtree_expiry' caches are stored. 513 */ 514 function expiryTemplateBlockCacheDir() 515 { 516 $expiryCacheDir = eZSys::cacheDirectory() . '/' . 'template-block-expiry'; 517 return $expiryCacheDir; 518 } 519 520 /*! 521 \static 522 Returns base directory where template block caches are stored. 523 */ 524 function templateBlockCacheDir() 525 { 526 $cacheDir = eZSys::cacheDirectory() . '/template-block/' ; 527 return $cacheDir; 528 } 529 530 /*! 531 \static 532 Returns path of the directory where 'subtree_expiry' caches are stored. 533 */ 534 function subtreeCacheSubDir( $subtreeExpiryParameter, $cacheFilename ) 535 { 536 $nodePathString = ''; 537 538 include_once ( 'lib/ezdb/classes/ezdb.php' ); 539 $db =& eZDB::instance(); 540 541 // clean up $subtreeExpiryParameter 542 $subtreeExpiryParameter = trim( $subtreeExpiryParameter, '/' ); 543 544 // get 'path_stirng' attribute for node. 545 $nodeID = false; 546 $subtree = $db->escapeString( $subtreeExpiryParameter ); 547 548 if ( $subtree == '' ) 549 { 550 // 'subtree_expiry' is empty => use root node. 551 $nodeID = 2; 552 } 553 else 554 { 555 $nonAliasPath = 'content/view/full/'; 556 557 if ( strpos( $subtree, $nonAliasPath ) === 0 ) 558 { 559 // 'subtree_expiry' is like 'content/view/full/2' 560 $nodeID = substr( $subtree, strlen( $nonAliasPath ) ); 561 } 562 else 563 { 564 // 'subtree_expiry' is url_alias 565 $nodePathStringSQL = "SELECT node_id FROM ezcontentobject_tree WHERE path_identification_string='$subtree'"; 566 $nodes = $db->arrayQuery( $nodePathStringSQL ); 567 if ( count( $nodes ) != 1 ) 568 { 569 eZDebug::writeError( 'Could not find path_string for \'subtree_expiry\' node.', 'eZTemplateCacheFunction::subtreeExpiryCacheDir()' ); 570 } 571 else 572 { 573 $nodeID = $nodes[0]['node_id']; 574 } 575 } 576 } 577 578 $cacheDir = eZTemplateCacheFunction::subtreeCacheSubDirForNode( $nodeID ); 579 $cacheDir .= '/' . $cacheFilename[0] . '/' . $cacheFilename[1] . '/' . $cacheFilename[2]; 580 581 return $cacheDir; 582 } 583 584 /*! 585 \static 586 Builds and returns path from $nodeID, e.g. if $nodeID = 23 then path = subtree/2/3 587 */ 588 function subtreeCacheSubDirForNode( $nodeID ) 589 { 590 $cacheDir = eZTemplateCacheFunction::subtreeCacheBaseSubDir(); 591 592 if ( is_numeric( $nodeID ) ) 593 { 594 $nodeID = (string)$nodeID; 595 $length = strlen( $nodeID ); 596 $pos = 0; 597 while ( $pos < $length ) 598 { 599 $cacheDir .= '/' . $nodeID[$pos]; 600 ++$pos; 601 } 602 } 603 else 604 { 605 eZDebug::writeWarning( "Unable to determine cacheDir for nodeID = $nodeID", 'eZtemplateCacheFunction::subtreeCacheSubDirForNode' ); 606 } 607 608 $cacheDir .= '/cache'; 609 return $cacheDir; 610 } 611 612 /// \privatesection 613 /// Name of the function 614 var $BlockName; 615 } 616 617 ?>
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 |