[ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZHTTPHeader class 4 // 5 // Created on: <24-Nov-2005 12:34:48 hovik> 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 ezhttpheader.php 30 */ 31 32 /*! 33 \class eZHTTPHeader ezhttpheader.php 34 \brief The class eZHTTPHeader does 35 36 */ 37 38 class eZHTTPHeader 39 { 40 /*! 41 * \static 42 * Returns true if the custom HTTP headers are enabled, false otherwise. 43 * The result is cached in memory to save time on multiple invocations. 44 */ 45 function enabled() 46 { 47 if ( isset( $GLOBALS['eZHTTPHeaderCustom'] ) ) 48 { 49 return $GLOBALS['eZHTTPHeaderCustom']; 50 } 51 52 $ini =& eZINI::instance(); 53 if ( !$ini->hasVariable( 'HTTPHeaderSettings', 'CustomHeader' ) ) 54 { 55 $GLOBALS['eZHTTPHeaderCustom'] = false; 56 } 57 else 58 { 59 $GLOBALS['eZHTTPHeaderCustom'] = $ini->variable( 'HTTPHeaderSettings', 'CustomHeader' ) == 'enabled'; 60 } 61 62 return $GLOBALS['eZHTTPHeaderCustom']; 63 } 64 65 /*! 66 \static 67 Get Header override array by requested URI 68 */ 69 function headerOverrideArray( $uri ) 70 { 71 $headerArray = array(); 72 73 if ( !eZHTTPHeader::enabled() ) 74 { 75 return $headerArray; 76 } 77 78 $contentView = false; 79 80 include_once ( 'kernel/classes/ezurlalias.php' ); 81 $uriString = eZURLAlias::cleanURL( $uri->uriString() ); 82 83 // If content/view used, get path_identification_string. 84 if ( strpos( $uriString, 'content/view/' ) === 0 ) 85 { 86 $urlParts = explode( '/', $uriString ); 87 $nodeID = $urlParts[3]; 88 if ( !$nodeID ) 89 { 90 return $headerArray; 91 } 92 93 include_once ( 'kernel/classes/ezcontentobjecttreenode.php' ); 94 $resultSet = eZPersistentObject::fetchObject( eZContentObjectTreeNode::definition(), 95 array( 'path_identification_string' ), 96 array( 'node_id' => $nodeID ), 97 false ); 98 if ( !$resultSet ) 99 { 100 return $headerArray; 101 } 102 103 $uriString = $resultSet['path_identification_string']; 104 $contentView = true; 105 } 106 else 107 { 108 $uriCopy = $uri; 109 eZURLAlias::translate( $uriCopy ); 110 if ( strpos( $uriCopy->uriString(), 'content/view' ) === 0 ) 111 { 112 $contentView = true; 113 } 114 } 115 116 $uriString = '/' . eZURLAlias::cleanURL( $uriString ); 117 $ini = eZINI::instance(); 118 119 foreach( $ini->variable( 'HTTPHeaderSettings', 'HeaderList' ) as $header ) 120 { 121 foreach( $ini->variable( 'HTTPHeaderSettings', $header ) as $path => $value ) 122 { 123 $path = '/' . eZURLAlias::cleanURL( $path ); 124 if ( strlen( $path ) == 1 && 125 !$contentView && 126 $uriString != '/' ) 127 { 128 continue; 129 } 130 131 if ( strpos( $uriString, $path ) === 0 ) 132 { 133 @list( $headerValue, $depth, $level ) = explode( ';', $value ); 134 135 if ( $header == 'Expires' ) 136 { 137 $headerValue = gmdate( 'D, d M Y H:i:s', gmmktime() + $headerValue ) . ' GMT'; 138 } 139 140 if ( $depth === null ) 141 { 142 $headerArray[$header] = $headerValue; 143 } 144 else 145 { 146 $pathLevel = count( explode( '/', $path ) ); 147 $uriLevel = count( explode( '/', $uriString ) ); 148 if ( $level === null ) 149 { 150 if ( $uriLevel <= $pathLevel + $depth ) 151 { 152 $headerArray[$header] = $headerValue; 153 } 154 } 155 else 156 { 157 if ( $uriLevel <= $pathLevel + $depth && 158 $uriLevel >= $pathLevel + $level ) 159 { 160 $headerArray[$header] = $headerValue; 161 } 162 } 163 } 164 } 165 } 166 } 167 168 return $headerArray; 169 } 170 } 171 172 ?>
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 |