Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezcontentobjectpackageinstaller.php
Go to the documentation of this file.
1 <?php
17 class eZContentObjectPackageInstaller extends eZPackageInstallationHandler
18 {
19 public $InstallItem;
27 public function __construct( $package, $type, $installItem )
28 {
29 $steps = array();
30 $steps[] = array( 'id' => 'site_access',
31 'name' => ezpI18n::tr( 'kernel/package', 'Site access mapping' ),
32 'methods' => array( 'initialize' => 'initializeSiteAccess',
33 'validate' => 'validateSiteAccess' ),
34 'template' => 'site_access.tpl' );
35 $steps[] = array( 'id' => 'top_nodes',
36 'name' => ezpI18n::tr( 'kernel/package', 'Top node placements' ),
37 'methods' => array( 'initialize' => 'initializeTopNodes',
38 'validate' => 'validateTopNodes' ),
39 'template' => 'top_nodes.tpl' );
40 $steps[] = array( 'id' => 'advanced_options',
41 'name' => ezpI18n::tr( 'kernel/package', 'Advanced options' ),
42 'methods' => array( 'initialize' => 'initializeAdvancedOptions',
43 'validate' => 'validateAdvancedOptions' ),
44 'template' => 'advanced_options.tpl' );
45 parent::__construct(
46 $package, $type, $installItem, ezpI18n::tr( 'kernel/package', 'Content object import' ), $steps
47 );
48 }
49
53 function packageInitialState( $package, &$persistentData )
54 {
55 return 'stable';
56 }
57
61 function packageType( $package, &$persistentData )
62 {
63 return 'contentobject';
64 }
65
66 function initializeSiteAccess( $package, $http, $step, &$persistentData, $tpl, $module )
67 {
68 $ini = eZINI::instance();
69 $availableSiteAccessArray = $ini->variable( 'SiteAccessSettings', 'RelatedSiteAccessList' );
70
71 if ( !isset( $persistentData['site_access_map'] ) )
72 {
73 $persistentData['site_access_map'] = array();
74 $persistentData['site_access_available'] = $availableSiteAccessArray;
75 $rootDOMNode = $this->rootDOMNode();
76 $siteAccessListNode = $rootDOMNode->getElementsByTagName( 'site-access-list' )->item( 0 );
77
78 foreach( $siteAccessListNode->getElementsByTagName( 'site-access' ) as $siteAccessNode )
79 {
80 $originalSiteAccessName = $siteAccessNode->textContent;
81 if ( in_array( $originalSiteAccessName, $availableSiteAccessArray ) )
82 {
83 $persistentData['site_access_map'][$originalSiteAccessName] = $originalSiteAccessName;
84 }
85 else
86 {
87 $persistentData['site_access_map'][$originalSiteAccessName] = '';
88 }
89 }
90 }
91
92 $tpl->setVariable( 'site_access_map', $persistentData['site_access_map'] );
93 $tpl->setVariable( 'available_site_access_array', $availableSiteAccessArray );
94 }
95
96 function validateSiteAccess( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
97 {
98 $validate = true;
99 foreach( $persistentData['site_access_map'] as $originalSiteAccess => $newSiteAccess )
100 {
101 $persistentData['site_access_map'][$originalSiteAccess] = $http->postVariable( 'SiteAccessMap_'.$originalSiteAccess );
102 if ( !in_array( $persistentData['site_access_map'][$originalSiteAccess], $persistentData['site_access_available'] ) )
103 {
104 $validate = false;
105 }
106 }
107
108 return $validate;
109 }
110
111 function initializeTopNodes( $package, $http, $step, &$persistentData, $tpl, $module )
112 {
113 if ( !isset( $persistentData['top_nodes_map'] ) )
114 {
115 $persistentData['top_nodes_map'] = array();
116 $rootDOMNode = $this->rootDOMNode();
117 $topNodeListNode = $rootDOMNode->getElementsByTagName( 'top-node-list' )->item( 0 );
118
119 $ini = eZINI::instance( 'content.ini' );
120 $defaultPlacementNodeID = $ini->variable( 'NodeSettings', 'RootNode' );
121 $defaultPlacementNode = eZContentObjectTreeNode::fetch( $defaultPlacementNodeID );
122 $defaultPlacementName = $defaultPlacementNode->attribute( 'name' );
123 foreach ( $topNodeListNode->getElementsByTagName( 'top-node' ) as $topNodeDOMNode )
124 {
125 $persistentData['top_nodes_map'][(string)$topNodeDOMNode->getAttribute( 'node-id' )] = array( 'old_node_id' => $topNodeDOMNode->getAttribute( 'node-id' ),
126 'name' => $topNodeDOMNode->textContent,
127 'new_node_id' => $defaultPlacementNodeID,
128 'new_parent_name' => $defaultPlacementName );
129 }
130 }
131
132 foreach( array_keys( $persistentData['top_nodes_map'] ) as $topNodeArrayKey )
133 {
134 if ( $http->hasPostVariable( 'BrowseNode_' . $topNodeArrayKey ) )
135 {
136 eZContentBrowse::browse( array( 'action_name' => 'SelectObjectRelationNode',
137 'description_template' => 'design:package/installers/ezcontentobject/browse_topnode.tpl',
138 'from_page' => '/package/install',
139 'persistent_data' => array( 'PackageStep' => $http->postVariable( 'PackageStep' ),
140 'InstallerType' => $http->postVariable( 'InstallerType' ),
141 'InstallStepID' => $http->postVariable( 'InstallStepID' ),
142 'ReturnBrowse_' . $topNodeArrayKey => 1 ) ),
143 $module );
144 }
145 else if ( $http->hasPostVariable( 'ReturnBrowse_' . $topNodeArrayKey ) && !$http->hasPostVariable( 'BrowseCancelButton' ) )
146 {
147 $nodeIDArray = $http->postVariable( 'SelectedNodeIDArray' );
148 if ( $nodeIDArray != null )
149 {
150 $persistentData['top_nodes_map'][$topNodeArrayKey]['new_node_id'] = $nodeIDArray[0];
151 $contentNode = eZContentObjectTreeNode::fetch( $nodeIDArray[0] );
152 $persistentData['top_nodes_map'][$topNodeArrayKey]['new_parent_name'] = $contentNode->attribute( 'name' );
153 }
154 }
155 }
156
157 $tpl->setVariable( 'top_nodes_map', $persistentData['top_nodes_map'] );
158 }
159
160 function validateTopNodes( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList )
161 {
162 $validate = true;
163 foreach( array_keys( $persistentData['top_nodes_map'] ) as $topNodeArrayKey )
164 {
165 if ( $persistentData['top_nodes_map'][$topNodeArrayKey]['new_node_id'] === false )
166 {
167 $errorList[] = array( 'field' => ezpI18n::tr( 'kernel/package', 'Select parent nodes' ),
168 'description' => ezpI18n::tr( 'kernel/package', 'You must assign all nodes to new parent nodes.' ) );
169 $validate = false;
170 break;
171 }
172 }
173
174 return $validate;
175 }
176
177 function initializeAdvancedOptions( $package, $http, $step, &$persistentData, $tpl, $module )
178 {
179 if ( !isset( $persistentData['use_dates_from_package'] ) )
180 {
181 $persistentData['use_dates_from_package'] = 0;
182 }
183
184 $tpl->setVariable( 'use_dates_from_package', (bool)$persistentData['use_dates_from_package'] );
185 }
186
187 function validateAdvancedOptions( $package, $http, $currentStepId, &$stepMap, &$persistentData, &$errorList )
188 {
189 $persistentData['use_dates_from_package'] = $http->postVariable( 'UseDatesFromPackage', 0 );
190 return true;
191 }
192
193 function finalize( $package, $http, &$persistentData )
194 {
195 eZDebug::writeDebug( 'finalize is called', __METHOD__ );
196 $package->installItem( $this->InstallItem, $persistentData );
197 }
198
199 }
200 ?>
eZContentBrowse\browse
static browse( $parameters=array(), &$module)
Definition: ezcontentbrowse.php:89
eZContentObjectPackageInstaller
A package creator for content objects.
Definition: ezcontentobjectpackageinstaller.php:18
eZContentObjectPackageInstaller\validateTopNodes
validateTopNodes( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList)
Definition: ezcontentobjectpackageinstaller.php:160
eZContentObjectPackageInstaller\validateAdvancedOptions
validateAdvancedOptions( $package, $http, $currentStepId, &$stepMap, &$persistentData, &$errorList)
Definition: ezcontentobjectpackageinstaller.php:187
eZContentObjectPackageInstaller\packageInitialState
packageInitialState( $package, &$persistentData)
Definition: ezcontentobjectpackageinstaller.php:53
eZContentObjectPackageInstaller\finalize
finalize( $package, $http, &$persistentData)
Definition: ezcontentobjectpackageinstaller.php:193
eZContentObjectPackageInstaller\packageType
packageType( $package, &$persistentData)
Definition: ezcontentobjectpackageinstaller.php:61
eZContentObjectPackageInstaller\validateSiteAccess
validateSiteAccess( $package, $http, $currentStepID, &$stepMap, &$persistentData, &$errorList)
Definition: ezcontentobjectpackageinstaller.php:96
eZContentObjectPackageInstaller\__construct
__construct( $package, $type, $installItem)
Definition: ezcontentobjectpackageinstaller.php:27
eZContentObjectPackageInstaller\initializeSiteAccess
initializeSiteAccess( $package, $http, $step, &$persistentData, $tpl, $module)
Definition: ezcontentobjectpackageinstaller.php:66
eZContentObjectPackageInstaller\initializeTopNodes
initializeTopNodes( $package, $http, $step, &$persistentData, $tpl, $module)
Definition: ezcontentobjectpackageinstaller.php:111
eZContentObjectPackageInstaller\initializeAdvancedOptions
initializeAdvancedOptions( $package, $http, $step, &$persistentData, $tpl, $module)
Definition: ezcontentobjectpackageinstaller.php:177
eZContentObjectPackageInstaller\$InstallItem
$InstallItem
Definition: ezcontentobjectpackageinstaller.php:19
eZContentObjectTreeNode\fetch
static fetch( $nodeID=false, $lang=false, $asObject=true, $conditions=false)
Definition: ezcontentobjecttreenode.php:3058
eZDebug\writeDebug
static writeDebug( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:588
eZPackageInstallationHandler
The class eZPackageInstallationHandler does.
Definition: ezpackageinstallationhandler.php:19
eZPackageInstallationHandler\rootDOMNode
rootDOMNode()
Definition: ezpackageinstallationhandler.php:338
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+.