Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezcontentbrowse.php
Go to the documentation of this file.
1 <?php
32 class eZContentBrowse
33 {
40 function __construct( $params = array() )
41 {
42 $http = eZHTTPTool::instance();
43 if ( !$params && $http->hasSessionVariable( 'BrowseParameters' ) )
44 {
45 $this->Parameters =& $http->sessionVariable( 'BrowseParameters' );
46 }
47 else
48 {
49 $this->Parameters = $params;
50 }
51 }
52
56 function attributes()
57 {
58 return array_keys( $this->Parameters );
59 }
60
64 function hasAttribute( $attributeName )
65 {
66 return isset( $this->Parameters[$attributeName] );
67 }
68
72 function attribute( $attributeName )
73 {
74 if ( isset( $this->Parameters[$attributeName] ) )
75 {
76 return $this->Parameters[$attributeName];
77 }
78
79 eZDebug::writeError( "Attribute '$attributeName' does not exist", __METHOD__ );
80 return null;
81 }
82
89 static function browse( $parameters = array(), &$module )
90 {
91 $ini = eZINI::instance( 'browse.ini' );
92
93 if ( !isset( $parameters['action_name'] ) )
94 $parameters['action_name'] = $ini->variable( 'BrowseSettings', 'DefaultActionName' );
95
96 if ( !isset( $parameters['type'] ) )
97 $parameters['type'] = $parameters['action_name']; //$ini->variable( $parameters['action_name'], 'BrowseType' );
98
99 if ( !isset( $parameters['selection'] ) )
100 {
101 if ( $ini->hasVariable( $parameters['type'], 'SelectionType' ) )
102 $parameters['selection'] = $ini->variable( $parameters['type'], 'SelectionType' );
103 else
104 $parameters['selection'] = $ini->variable( 'BrowseSettings', 'DefaultSelectionType' );
105 }
106
107 if ( !isset( $parameters['return_type'] ) )
108 {
109 if ( $ini->hasVariable( $parameters['type'], 'ReturnType' ) )
110 $parameters['return_type'] = $ini->variable( $parameters['type'], 'ReturnType' );
111 else
112 $parameters['return_type'] = $ini->variable( 'BrowseSettings', 'DefaultReturnType' );
113 }
114
115 if ( !isset( $parameters['browse_custom_action'] ) )
116 $parameters['browse_custom_action'] = false;
117
118 if ( !isset( $parameters['custom_action_data'] ) )
119 $parameters['custom_action_data'] = false;
120
121 if ( !isset( $parameters['description_template'] ) )
122 $parameters['description_template'] = false;
123
124 if ( !isset( $parameters['start_node'] ) )
125 $parameters['start_node'] = $ini->variable( $parameters['type'], 'StartNode' );
126
127 if ( !isset( $parameters['ignore_nodes_select'] ) )
128 $parameters['ignore_nodes_select'] = array();
129
130 if ( !isset( $parameters['ignore_nodes_select_subtree'] ) )
131 $parameters['ignore_nodes_select_subtree'] = array();
132
133 if ( !isset( $parameters['ignore_nodes_click'] ) )
134 $parameters['ignore_nodes_click'] = array();
135
136 if ( !isset( $parameters['class_array'] ) )
137 {
138 if ( $ini->hasVariable( $parameters['type'], 'Class' ) )
139 {
140 $parameters['class_array'] = $ini->variable( $parameters['type'], 'Class' );
141 }
142 else
143 {
144 $parameters['class_array'] = false;
145 }
146 }
147
148 if ( isset( $parameters['keys'] ) )
149 {
150 $overrideStartNode = false;
151 foreach ( $parameters['keys'] as $key => $keyValue )
152 {
153 $variableName = 'StartNode_' . $key;
154 if ( !$ini->hasVariable( $parameters['type'], $variableName ) )
155 continue;
156 $keyData = $ini->variable( $parameters['type'], $variableName );
157 if ( is_array( $keyValue ) )
158 {
159 foreach ( $keyValue as $keySubValue )
160 {
161 if ( isset( $keyData[$keySubValue] ) )
162 $overrideStartNode = $keyData[$keySubValue];
163 }
164 }
165 else if ( isset( $keyData[$keyValue] ) )
166 {
167 $overrideStartNode = $keyData[$keyValue];
168 }
169 if ( $overrideStartNode )
170 break;
171 }
172 if ( $overrideStartNode )
173 $parameters['start_node'] = $overrideStartNode;
174 }
175
176 if ( !isset( $parameters['persistent_data'] ) )
177 $parameters['persistent_data'] = false;
178
179 if ( !isset( $parameters['permission'] ) )
180 $parameters['permission'] = false;
181
182 if ( !isset( $parameters['top_level_nodes'] ) )
183 {
184 $parameters['top_level_nodes'] = $ini->variable( 'BrowseSettings', 'DefaultTopLevelNodes' );
185 if ( $ini->hasVariable( $parameters['type'], 'TopLevelNodes' ) )
186 $parameters['top_level_nodes'] = $ini->variable( $parameters['type'], 'TopLevelNodes' );
187 }
188
189 if ( !is_numeric( $parameters['start_node'] ) )
190 $parameters['start_node'] = eZContentBrowse::nodeAliasID( $parameters['start_node'] );
191
192 for ( $i =0; $i < count( $parameters['top_level_nodes'] ); $i++ )
193 {
194 if ( !is_numeric( $parameters['top_level_nodes'][$i] ) )
195 $parameters['top_level_nodes'][$i] = eZContentBrowse::nodeAliasID( $parameters['top_level_nodes'][$i] );
196 }
197
198 if ( !isset( $parameters['cancel_page'] ) )
199 $parameters['cancel_page'] = false;
200
201 if ( !isset( $parameters['from_page'] ) )
202 {
203 eZDebug::writeError( $parameters, 'eZContentBrowse::browse() $parameters[\'from_page\'] is not set' );
204 }
205
206 $http = eZHTTPTool::instance();
207 $http->setSessionVariable( 'BrowseParameters', $parameters );
208
209 if ( $module === null )
210 {
211 return "/content/browse/";
212 }
213 else
214 {
215 $module->redirectTo( "/content/browse/" );
216 return "/content/browse/";
217 }
218 }
219
224 static function nodeAliasID( $nodeName )
225 {
226 if ( is_numeric( $nodeName ) )
227 return $nodeName;
228 $browseINI = eZINI::instance( 'browse.ini' );
229 $aliasList = $browseINI->variable( 'BrowseSettings', 'AliasList' );
230 if ( isset( $aliasList[$nodeName] ) )
231 return $aliasList[$nodeName];
232 $contentINI = eZINI::instance( 'content.ini' );
233 if ( $nodeName == 'content' )
234 return $contentINI->variable( 'NodeSettings', 'RootNode' );
235 else if ( $nodeName == 'users' )
236 return $contentINI->variable( 'NodeSettings', 'UserRootNode' );
237 else if ( $nodeName == 'media' )
238 return $contentINI->variable( 'NodeSettings', 'MediaRootNode' );
239 else if ( $nodeName == 'setup' )
240 return $contentINI->variable( 'NodeSettings', 'SetupRootNode' );
241 else
242 return false;
243 }
244
248 function setStartNode( $nodeID )
249 {
250 $this->Parameters['start_node'] = $nodeID;
251 }
252
258 static function result( $actionName, $asObject = false )
259 {
260 $ini = eZINI::instance( 'browse.ini' );
261 $isNodeSelection = $ini->variable( $actionName, 'ReturnType' ) == 'NodeID';
262 if ( $isNodeSelection )
263 $postName = 'SelectedNodeIDArray';
264 else
265 $postName = 'SelectedObjectIDArray';
266 $http = eZHTTPTool::instance();
267 if ( $http->hasPostVariable( $postName ) && !$http->hasPostVariable( 'BrowseCancelButton' ) )
268 {
269 $postList = $http->postVariable( $postName );
270 $list = array();
271 foreach ( $postList as $value )
272 {
273 if ( !is_numeric( $value ) )
274 {
275 eZDebug::writeError( "Non-numeric value ($value) found for POST variable $postName for browse action '$actionName', the value will be excluded",
276 'eZContentBrowse::result' );
277 continue;
278 }
279 // Append the value as a real integer, avoids XSS problems.
280 $intValue = (int)$value;
281 if ( $value != $intValue )
282 {
283 eZDebug::writeError( "Non-integer value ($value) found for POST variable $postName for browse action '$actionName', the value will be excluded",
284 'eZContentBrowse::result' );
285 continue;
286 }
287 $list[] = $intValue;
288 }
289 return array_unique( $list );
290 }
291 return false;
292 }
293
296 public $Parameters = false;
297 }
298
299 ?>
eZContentBrowse
Handles browsing of content in the node tree.
Definition: ezcontentbrowse.php:33
eZContentBrowse\attribute
attribute( $attributeName)
Definition: ezcontentbrowse.php:72
eZContentBrowse\result
static result( $actionName, $asObject=false)
Definition: ezcontentbrowse.php:258
eZContentBrowse\__construct
__construct( $params=array())
Definition: ezcontentbrowse.php:40
eZContentBrowse\hasAttribute
hasAttribute( $attributeName)
Definition: ezcontentbrowse.php:64
eZContentBrowse\nodeAliasID
static nodeAliasID( $nodeName)
Definition: ezcontentbrowse.php:224
eZContentBrowse\$Parameters
$Parameters
Definition: ezcontentbrowse.php:296
eZContentBrowse\setStartNode
setStartNode( $nodeID)
Definition: ezcontentbrowse.php:248
eZContentBrowse\browse
static browse( $parameters=array(), &$module)
Definition: ezcontentbrowse.php:89
eZContentBrowse\attributes
attributes()
Definition: ezcontentbrowse.php:56
eZDebug\writeError
static writeError( $string, $label="", $backgroundClass="")
Definition: ezdebug.php:545
eZHTTPTool\instance
static instance()
Definition: ezhttptool.php:189
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.