Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezpackagetype.php
Go to the documentation of this file.
1 <?php
19 class eZPackageType extends eZDataType
20 {
21 const DATA_TYPE_STRING = 'ezpackage';
22 const TYPE_FIELD = 'data_text1';
23 const TYPE_VARIABLE = '_ezpackage_type_';
24 const VIEW_MODE_FIELD = 'data_int1';
25 const VIEW_MODE_VARIABLE = '_ezpackage_view_mode_';
26
27 public function __construct()
28 {
29 parent::__construct( self::DATA_TYPE_STRING, ezpI18n::tr( 'kernel/classes/datatypes', 'Package', 'Datatype name' ),
30 array( 'serialize_supported' => true ) );
31 }
32
36 function initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute )
37 {
38 }
39
40 function validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
41 {
42 return eZInputValidator::STATE_ACCEPTED;
43 }
44
48 function fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute )
49 {
50 if ( $http->hasPostVariable( $base . '_ezpackage_data_text_' . $contentObjectAttribute->attribute( 'id' ) ) )
51 {
52 $data = $http->postVariable( $base . '_ezpackage_data_text_' . $contentObjectAttribute->attribute( 'id' ) );
53
54 // Save in ini files if the package type is sitestyle.
55 $classAttribute = $contentObjectAttribute->attribute( 'contentclass_attribute' );
56 if ( $classAttribute->attribute( self::TYPE_FIELD ) == 'sitestyle' )
57 {
58 $package = eZPackage::fetch( $data );
59 if ( $package )
60 {
61 $fileList = $package->fileList( 'default' );
62 foreach ( array_keys( $fileList ) as $key )
63 {
64 $file =& $fileList[$key];
65 $fileIdentifier = $file["variable-name"];
66 if ( $fileIdentifier == 'sitecssfile' )
67 {
68 $siteCSS = $package->fileItemPath( $file, 'default' );
69 }
70 else if ( $fileIdentifier == 'classescssfile' )
71 {
72 $classesCSS = $package->fileItemPath( $file, 'default' );
73 }
74 }
75 $currentSiteAccess = $http->hasPostVariable( 'CurrentSiteAccess' )
76 ? $http->postVariable( 'CurrentSiteAccess' )
77 : false;
78 $iniPath = 'settings/override';
79 if ( $currentSiteAccess != 'Global' and $currentSiteAccess !== false )
80 {
81 $data .= ':' . $currentSiteAccess;
82 $iniPath = 'settings/siteaccess/' . $currentSiteAccess;
83 }
84
85 $designINI = eZINI::instance( 'design.ini.append.php', $iniPath, null, false, null, true );
86 $designINI->setVariable( 'StylesheetSettings', 'SiteCSS', $siteCSS );
87 $designINI->setVariable( 'StylesheetSettings', 'ClassesCSS', $classesCSS );
88 $designINI->save();
89 }
90 }
91 $contentObjectAttribute->setAttribute( 'data_text', $data );
92 }
93 return true;
94 }
95
100 function storeObjectAttribute( $attribute )
101 {
102 $ini = eZINI::instance();
103 // Delete compiled template
104 $siteINI = eZINI::instance();
105 if ( $siteINI->hasVariable( 'FileSettings', 'CacheDir' ) )
106 {
107 $cacheDir = $siteINI->variable( 'FileSettings', 'CacheDir' );
108 if ( $cacheDir[0] == "/" )
109 {
110 $cacheDir = eZDir::path( array( $cacheDir ) );
111 }
112 else
113 {
114 if ( $siteINI->hasVariable( 'FileSettings', 'VarDir' ) )
115 {
116 $varDir = $siteINI->variable( 'FileSettings', 'VarDir' );
117 $cacheDir = eZDir::path( array( $varDir, $cacheDir ) );
118 }
119 }
120 }
121 else if ( $siteINI->hasVariable( 'FileSettings', 'VarDir' ) )
122 {
123 $varDir = $siteINI->variable( 'FileSettings', 'VarDir' );
124 $cacheDir = $ini->variable( 'FileSettings', 'CacheDir' );
125 $cacheDir = eZDir::path( array( $varDir, $cacheDir ) );
126 }
127 else
128 {
129 $cacheDir = eZSys::cacheDirectory();
130 }
131 $compiledTemplateDir = $cacheDir ."/template/compiled";
132 eZDir::unlinkWildcard( $compiledTemplateDir . "/", "*pagelayout*.*" );
133
134 // Expire template block cache
135 eZContentCacheManager::clearTemplateBlockCacheIfNeeded( false );
136 }
137
138 function fetchClassAttributeHTTPInput( $http, $base, $classAttribute )
139 {
140 $packageTypeName = $base . self::TYPE_VARIABLE . $classAttribute->attribute( 'id' );
141 if ( $http->hasPostVariable( $packageTypeName ) )
142 {
143 $packageTypeValue = $http->postVariable( $packageTypeName );
144 $classAttribute->setAttribute( self::TYPE_FIELD, $packageTypeValue );
145 }
146 $packageViewModeName = $base . self::VIEW_MODE_VARIABLE . $classAttribute->attribute( 'id' );
147 if ( $http->hasPostVariable( $packageViewModeName ) )
148 {
149 $packageViewModeValue = $http->postVariable( $packageViewModeName );
150 $classAttribute->setAttribute( self::VIEW_MODE_FIELD, $packageViewModeValue );
151 }
152 return true;
153 }
154
158 function objectAttributeContent( $contentObjectAttribute )
159 {
160 $packageName = $contentObjectAttribute->attribute( "data_text" );
161 $package = eZPackage::fetch( $packageName );
162 return $package;
163 }
164
168 function metaData( $contentObjectAttribute )
169 {
170 return $contentObjectAttribute->attribute( 'data_text' );
171 }
172
176 function title( $contentObjectAttribute, $name = null )
177 {
178 return $contentObjectAttribute->attribute( 'data_text' );
179 }
180
181 function hasObjectAttributeContent( $contentObjectAttribute )
182 {
183 return trim( $contentObjectAttribute->attribute( 'data_text' ) ) != '';
184 }
185
186 function isIndexable()
187 {
188 return false;
189 }
190
191 function sortKey( $contentObjectAttribute )
192 {
193 return strtolower( $contentObjectAttribute->attribute( 'data_text' ) );
194 }
195
196 function sortKeyType()
197 {
198 return 'string';
199 }
200
201 function serializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )
202 {
203 $type = $classAttribute->attribute( self::TYPE_FIELD );
204 $dom = $attributeParametersNode->ownerDocument;
205 $typeNode = $dom->createElement( 'type' );
206 $typeNode->appendChild( $dom->createTextNode( $type ) );
207 $attributeParametersNode->appendChild( $typeNode );
208 }
209
210 function unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode )
211 {
212 $typeNode = $attributeParametersNode->getElementsByTagName( 'type' )->item( 0 );
213 $type = $typeNode ? $typeNode->textContent : '';
214 $classAttribute->setAttribute( self::TYPE_FIELD, $type );
215 }
216
217 function diff( $old, $new, $options = false )
218 {
219 return null;
220 }
221 }
222
223 eZDataType::register( eZPackageType::DATA_TYPE_STRING, 'eZPackageType' );
224
225 ?>
eZContentCacheManager\clearTemplateBlockCacheIfNeeded
static clearTemplateBlockCacheIfNeeded( $objectID)
Definition: ezcontentcachemanager.php:823
eZDataType
Base class for content datatypes.
Definition: ezdatatype.php:46
eZDataType\register
static register( $dataTypeString, $className)
Definition: ezdatatype.php:203
eZDir\unlinkWildcard
static unlinkWildcard( $dir, $pattern)
Definition: ezdir.php:395
eZDir\path
static path( $names, $includeEndSeparator=false, $type=self::SEPARATOR_UNIX)
Definition: ezdir.php:237
eZInputValidator\STATE_ACCEPTED
const STATE_ACCEPTED
Definition: ezinputvalidator.php:79
eZPackageType
The class eZPackageType does.
Definition: ezpackagetype.php:20
eZPackageType\VIEW_MODE_VARIABLE
const VIEW_MODE_VARIABLE
Definition: ezpackagetype.php:25
eZPackageType\fetchClassAttributeHTTPInput
fetchClassAttributeHTTPInput( $http, $base, $classAttribute)
Definition: ezpackagetype.php:138
eZPackageType\diff
diff( $old, $new, $options=false)
Definition: ezpackagetype.php:217
eZPackageType\TYPE_VARIABLE
const TYPE_VARIABLE
Definition: ezpackagetype.php:23
eZPackageType\title
title( $contentObjectAttribute, $name=null)
Definition: ezpackagetype.php:176
eZPackageType\metaData
metaData( $contentObjectAttribute)
Definition: ezpackagetype.php:168
eZPackageType\validateObjectAttributeHTTPInput
validateObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: ezpackagetype.php:40
eZPackageType\serializeContentClassAttribute
serializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode)
Definition: ezpackagetype.php:201
eZPackageType\sortKey
sortKey( $contentObjectAttribute)
Definition: ezpackagetype.php:191
eZPackageType\isIndexable
isIndexable()
Definition: ezpackagetype.php:186
eZPackageType\hasObjectAttributeContent
hasObjectAttributeContent( $contentObjectAttribute)
Definition: ezpackagetype.php:181
eZPackageType\TYPE_FIELD
const TYPE_FIELD
Definition: ezpackagetype.php:22
eZPackageType\sortKeyType
sortKeyType()
Definition: ezpackagetype.php:196
eZPackageType\storeObjectAttribute
storeObjectAttribute( $attribute)
Definition: ezpackagetype.php:100
eZPackageType\objectAttributeContent
objectAttributeContent( $contentObjectAttribute)
Definition: ezpackagetype.php:158
eZPackageType\initializeObjectAttribute
initializeObjectAttribute( $contentObjectAttribute, $currentVersion, $originalContentObjectAttribute)
Definition: ezpackagetype.php:36
eZPackageType\VIEW_MODE_FIELD
const VIEW_MODE_FIELD
Definition: ezpackagetype.php:24
eZPackageType\unserializeContentClassAttribute
unserializeContentClassAttribute( $classAttribute, $attributeNode, $attributeParametersNode)
Definition: ezpackagetype.php:210
eZPackageType\DATA_TYPE_STRING
const DATA_TYPE_STRING
Definition: ezpackagetype.php:21
eZPackageType\fetchObjectAttributeHTTPInput
fetchObjectAttributeHTTPInput( $http, $base, $contentObjectAttribute)
Definition: ezpackagetype.php:48
eZPackageType\__construct
__construct()
Definition: ezpackagetype.php:27
eZPackage\fetch
static fetch( $packageName, $packagePath=false, $repositoryID=false, $dbAvailable=true)
Definition: ezpackage.php:1358
eZSys\cacheDirectory
static cacheDirectory()
Definition: ezsys.php:527
ezpI18n\tr
static tr( $context, $source, $comment=null, $arguments=null)
Definition: ezpi18n.php:86
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.