| [ Index ] |
|
Code source de eZ Publish 3.9.0 |
1 <?php 2 // 3 // Definition of eZPackageType class 4 // 5 // Created on: <15-Oct-2003 13:17:04 wy> 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 ezpackagetype.php 30 */ 31 32 /*! 33 \class eZPackageType ezpackagetype.php 34 \ingroup eZDatatype 35 \brief The class eZPackageType does 36 37 */ 38 include_once ( 'kernel/classes/ezdatatype.php' ); 39 include_once ( 'kernel/classes/ezpackage.php' ); 40 include_once ( 'kernel/common/i18n.php' ); 41 42 define( 'EZ_DATATYPESTRING_EZ_PACKAGE', 'ezpackage' ); 43 define( 'EZ_DATATYPESTRING_PACKAGE_TYPE_FIELD', 'data_text1' ); 44 define( 'EZ_DATATYPESTRING_PACKAGE_TYPE_VARIABLE', '_ezpackage_type_' ); 45 define( 'EZ_DATATYPESTRING_PACKAGE_VIEW_MODE_FIELD', 'data_int1' ); 46 define( 'EZ_DATATYPESTRING_PACKAGE_VIEW_MODE_VARIABLE', '_ezpackage_view_mode_' ); 47 48 class eZPackageType extends eZDataType 49 { 50 /*! 51 Constructor 52 */ 53 function eZPackageType() 54 { 55 $this->eZDataType( EZ_DATATYPESTRING_EZ_PACKAGE, ezi18n( 'kernel/classes/datatypes', 'Package', 'Datatype name' ), 56 array( 'serialize_supported' => true ) ); 57 } 58 59 /*! 60 Sets the default value. 61 */ 62 function initializeObjectAttribute( &$contentObjectAttribute, $currentVersion, &$originalContentObjectAttribute ) 63 { 64 } 65 66 /*! 67 \reimp 68 */ 69 function validateObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute ) 70 { 71 return EZ_INPUT_VALIDATOR_STATE_ACCEPTED; 72 } 73 74 /*! 75 Fetches the http post var string input and stores it in the data instance. 76 */ 77 function fetchObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute ) 78 { 79 if ( $http->hasPostVariable( $base . '_ezpackage_data_text_' . $contentObjectAttribute->attribute( 'id' ) ) ) 80 { 81 $data = $http->postVariable( $base . '_ezpackage_data_text_' . $contentObjectAttribute->attribute( 'id' ) ); 82 83 // Save in ini files if the package type is sitestyle. 84 $classAttribute =& $contentObjectAttribute->attribute( 'contentclass_attribute' ); 85 if ( $classAttribute->attribute( EZ_DATATYPESTRING_PACKAGE_TYPE_FIELD ) == 'sitestyle' ) 86 { 87 $package = eZPackage::fetch( $data ); 88 if ( $package ) 89 { 90 $fileList = $package->fileList( 'default' ); 91 foreach ( array_keys( $fileList ) as $key ) 92 { 93 $file =& $fileList[$key]; 94 $fileIdentifier = $file["variable-name"]; 95 if ( $fileIdentifier == 'sitecssfile' ) 96 { 97 $siteCSS = $package->fileItemPath( $file, 'default' ); 98 } 99 else if ( $fileIdentifier == 'classescssfile' ) 100 { 101 $classesCSS = $package->fileItemPath( $file, 'default' ); 102 } 103 } 104 $currentSiteAccess = $http->hasPostVariable( 'CurrentSiteAccess' ) 105 ? $http->postVariable( 'CurrentSiteAccess' ) 106 : false; 107 $iniPath = 'settings/override'; 108 if ( $currentSiteAccess != 'Global' and $currentSiteAccess !== false ) 109 { 110 $data .= ':' . $currentSiteAccess; 111 $iniPath = 'settings/siteaccess/' . $currentSiteAccess; 112 } 113 114 $designINI =& eZIni::instance( 'design.ini.append.php', $iniPath, null, false, null, true ); 115 $designINI->setVariable( 'StylesheetSettings', 'SiteCSS', $siteCSS ); 116 $designINI->setVariable( 'StylesheetSettings', 'ClassesCSS', $classesCSS ); 117 $designINI->save(); 118 } 119 } 120 $contentObjectAttribute->setAttribute( 'data_text', $data ); 121 } 122 return true; 123 } 124 125 /*! 126 Does nothing since it uses the data_text field in the content object attribute. 127 See fetchObjectAttributeHTTPInput for the actual storing. 128 */ 129 function storeObjectAttribute( &$attribute ) 130 { 131 $ini =& eZIni::instance(); 132 // Delete compiled template 133 $siteINI = eZINI::instance(); 134 if ( $siteINI->hasVariable( 'FileSettings', 'CacheDir' ) ) 135 { 136 $cacheDir = $siteINI->variable( 'FileSettings', 'CacheDir' ); 137 if ( $cacheDir[0] == "/" ) 138 { 139 $cacheDir = eZDir::path( array( $cacheDir ) ); 140 } 141 else 142 { 143 if ( $siteINI->hasVariable( 'FileSettings', 'VarDir' ) ) 144 { 145 $varDir = $siteINI->variable( 'FileSettings', 'VarDir' ); 146 $cacheDir = eZDir::path( array( $varDir, $cacheDir ) ); 147 } 148 } 149 } 150 else if ( $siteINI->hasVariable( 'FileSettings', 'VarDir' ) ) 151 { 152 $varDir = $siteINI->variable( 'FileSettings', 'VarDir' ); 153 $cacheDir = $ini->variable( 'FileSettings', 'CacheDir' ); 154 $cacheDir = eZDir::path( array( $varDir, $cacheDir ) ); 155 } 156 else 157 { 158 $cacheDir = eZSys::cacheDirectory(); 159 } 160 $compiledTemplateDir = $cacheDir ."/template/compiled"; 161 eZDir::unlinkWildcard( $compiledTemplateDir . "/", "*pagelayout*.*" ); 162 163 // Expire template block cache 164 include_once ( 'kernel/classes/ezcontentcachemanager.php' ); 165 eZContentCacheManager::clearTemplateBlockCacheIfNeeded( false ); 166 } 167 168 /*! 169 \reimp 170 */ 171 function fetchClassAttributeHTTPInput( &$http, $base, &$classAttribute ) 172 { 173 $packageTypeName = $base . EZ_DATATYPESTRING_PACKAGE_TYPE_VARIABLE . $classAttribute->attribute( 'id' ); 174 if ( $http->hasPostVariable( $packageTypeName ) ) 175 { 176 $packageTypeValue = $http->postVariable( $packageTypeName ); 177 $classAttribute->setAttribute( EZ_DATATYPESTRING_PACKAGE_TYPE_FIELD, $packageTypeValue ); 178 } 179 $packageViewModeName = $base . EZ_DATATYPESTRING_PACKAGE_VIEW_MODE_VARIABLE . $classAttribute->attribute( 'id' ); 180 if ( $http->hasPostVariable( $packageViewModeName ) ) 181 { 182 $packageViewModeValue = $http->postVariable( $packageViewModeName ); 183 $classAttribute->setAttribute( EZ_DATATYPESTRING_PACKAGE_VIEW_MODE_FIELD, $packageViewModeValue ); 184 } 185 return true; 186 } 187 188 /*! 189 Returns the content. 190 */ 191 function &objectAttributeContent( &$contentObjectAttribute ) 192 { 193 $packageName = $contentObjectAttribute->attribute( "data_text" ); 194 $package = eZPackage::fetch( $packageName ); 195 return $package; 196 } 197 198 /*! 199 Returns the meta data used for storing search indeces. 200 */ 201 function metaData( &$contentObjectAttribute ) 202 { 203 return $contentObjectAttribute->attribute( 'data_text' ); 204 } 205 206 /*! 207 Returns the content of the string for use as a title 208 */ 209 function title( &$contentObjectAttribute ) 210 { 211 return $contentObjectAttribute->attribute( 'data_text' ); 212 } 213 214 function hasObjectAttributeContent( &$contentObjectAttribute ) 215 { 216 return trim( $contentObjectAttribute->attribute( 'data_text' ) ) != ''; 217 } 218 219 /*! 220 \reimp 221 */ 222 function isIndexable() 223 { 224 return false; 225 } 226 227 /*! 228 \reimp 229 */ 230 function sortKey( &$contentObjectAttribute ) 231 { 232 return strtolower( $contentObjectAttribute->attribute( 'data_text' ) ); 233 } 234 235 /*! 236 \reimp 237 */ 238 function sortKeyType() 239 { 240 return 'string'; 241 } 242 243 /*! 244 \reimp 245 */ 246 function serializeContentClassAttribute( &$classAttribute, &$attributeNode, &$attributeParametersNode ) 247 { 248 $type = $classAttribute->attribute( EZ_DATATYPESTRING_PACKAGE_TYPE_FIELD ); 249 $attributeParametersNode->appendChild( eZDOMDocument::createElementTextNode( 'type', $type ) ); 250 } 251 252 /*! 253 \reimp 254 */ 255 function unserializeContentClassAttribute( &$classAttribute, &$attributeNode, &$attributeParametersNode ) 256 { 257 $type = $attributeParametersNode->elementTextContentByName( 'type' ); 258 $classAttribute->setAttribute( EZ_DATATYPESTRING_PACKAGE_TYPE_FIELD, $type ); 259 } 260 261 /*! 262 \reimp 263 */ 264 function diff( $old, $new, $options = false ) 265 { 266 return null; 267 } 268 } 269 270 eZDataType::register( EZ_DATATYPESTRING_EZ_PACKAGE, 'ezpackagetype' ); 271 272 ?>
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 |