forked from mugoweb/eep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·826 lines (722 loc) · 29.7 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
<?php
/*
EEP is a command line tool to support developers using ezpublish
Copyright © 2012 Mugo Web
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
*/
/**
* eep/modules/contentnode/index.php
*/
class contentnode_commands
{
const contentnode_clearsubtreecache = "clearsubtreecache";
const contentnode_contentobject = "contentobject";
const contentnode_dump = "dump";
const contentnode_info = "info";
const contentnode_location = "location";
const contentnode_find = "find";
const contentnode_deletesubtree = "deletesubtree";
const contentnode_move = "move";
const contentnode_setsortorder = "setsortorder";
const contentnode_hidesubtree = "hidesubtree";
const contentnode_unhidesubtree = "unhidesubtree";
//--------------------------------------------------------------------------
var $availableCommands = array
(
"help"
, self::contentnode_clearsubtreecache
, self::contentnode_contentobject
, self::contentnode_deletesubtree
, self::contentnode_dump
, self::contentnode_find
, self::contentnode_info
, self::contentnode_location
, self::contentnode_move
, self::contentnode_setsortorder
, self::contentnode_hidesubtree
, self::contentnode_unhidesubtree
);
var $help = ""; // used to dump the help string
//--------------------------------------------------------------------------
public function __construct()
{
$parts = explode( "/", __FILE__ );
array_pop( $parts );
$command = array_pop( $parts );
$this->help = <<<EOT
Note: You need to do "eep use ezroot <path>" before starting work with a new local instance of eZ Publish.
clearsubtreecache
eep contentnode clearsubtreecache <subtree node id>
contentobject
- convert a content node id to a content object id
eep contentnode contentobject <content node id>
or
eep use contentnode <content node id>
eep contentnode contentobject
deletesubtree
- is hardcoded to use user 14 to do the deletions
- supports --limit=N to override the sanity check limit (0 means no-limit)
eep contentnode deletesubtree <subtree node id>
... or
eep use contentnode <subtree node id>
eep contentnode deletesubtree
dump
- dump all the data associated with a content node into an XML structure; suitable for dumping an eZ Publish instance for import into some other system, or etc.
eep contentnode dump <node id>
find
- supports --limit=N and/or --offset=M
eep cn find <content class> <parent node id> <search string>P
hidesubtree
- hide node and make subtree invisible
eep contentnode hidesubtree <subtree node id>
unhidesubtree
- unhide node and children
eep contentnode unhidesubtree <subtree node id>
info
eep use contentnode <node id>
eep contentnode info
... or
eep contentnode info <node id>
location
- put content object at an additional location
eep use contentobject <object id>
eep contentnode location <new parent node id>
move
- move provided node to be child at new location
eep use contentnode <node id>
eep contentnode move <new parent node id>
or
eep contentnode move <node id> <new parent node id>
setsortorder
- set the sort order for children of this node
- (you may have to republish the object to make the change visible)
- the available orderings are:
PATH
PUBLISHED
MODIFIED
SECTION
DEPTH
CLASS_IDENTIFIER
CLASS_NAME
PRIORITY
NAME
MODIFIED_SUBNODE
NODE_ID
CONTENTOBJECT_ID
- the available directions are:
DESC
ASC
eep contentnode setsortorder <node id> <sort ordering> <sort direction>
EOT;
}
//--------------------------------------------------------------------------
private function deleteSubtree( $subtreeNodeId, $additional )
{
$effectiveLimit = eepSetting::DeleteNodesSanityCheck;
if( isset($additional["limit"]) )
{
$effectiveLimit = $additional["limit"];
}
if( !eepValidate::validateContentNodeId( $subtreeNodeId ) )
throw new Exception( "This is not a node id: [" .$subtreeNodeId. "]" );
// need to operate in a privileged account
$adminUserObject = eZUser::fetch( eepSetting::PrivilegedAccountId );
$adminUserObject->loginCurrent();
// get the name, just for display purposes
$subtreeNode = eZContentObjectTreeNode::fetch( $subtreeNodeId );
$subtreeName = $subtreeNode->getName();
$subtreeCount = eZContentObjectTreeNode::subTreeCountByNodeID( array(), $subtreeNodeId );
if( ($subtreeCount > $effectiveLimit ) && (0 != $effectiveLimit) )
{
echo "The number of subitems [" .$subtreeCount. "] exceeds the sanity check: [" .$effectiveLimit. "]\n";
return false;
}
/*
// test that we can delete the subtree
$info = eZContentObjectTreeNode::subtreeRemovalInformation( array($subtreeNodeId) );
if( !$info[ "can_remove_all" ] )
{
//var_dump($info);
echo "Permission is denied for the '" . $subtreeName . "' subtree [nodeid=". $subtreeNodeId . "]\n";
return false; // not that anyone is checking the return value ...
}
//*/
// do the removal
$removeResult = eZContentObjectTreeNode::removeSubtrees( array($subtreeNodeId), false, false );
if( true === $removeResult )
{
echo "Subtree '" .$subtreeName. "' removed ok\n";
}
else
{
echo "Failed to remove subtree\n";
}
$adminUserObject->logoutCurrent();
}
//--------------------------------------------------------------------------
private function fetchNodeInfoFromId( $nodeId )
{
if( !eepValidate::validateContentNodeId( $nodeId ) )
throw new Exception( "This is not a node id: [" .$nodeId. "]" );
$keepers = array
(
"Name"
, "ContentObjectID"
, "MainNodeID"
, "ClassIdentifier"
, "PathIdentificationString"
, "PathString"
, "ParentNodeID"
, "CurrentLanguage"
, "ContentObjectVersion"
, "RemoteID"
, "IsHidden"
, "IsInvisible"
, "ContentObjectIsPublished"
);
// get the node
$node = eZContentObjectTreeNode::fetch( $nodeId );
//var_dump($node);
// extract the members we want
$results[] = array( "key", "value" );
foreach( $keepers as $key )
{
$results[] = array( $key, $node->$key );
}
// additional info
$results[] = array( "Reverse related count", eZContentObjectTreeNode::reverseRelatedCount( array($nodeId) ) );
$params = array
(
'Depth' => 1
, 'DepthOperator' => 'eq'
, 'Limitation' => array()
);
$results[] = array( "Children count", eZContentObjectTreeNode::subTreeCountByNodeID( $params, $nodeId ) );
$results[] = array( "URL Alias", $node->urlAlias() );
// do output
eep::printTable( $results, "contentnode info [" .$nodeId. "]" );
}
//--------------------------------------------------------------------------
// CURRENTLY UNUSED
private function searchForNodes_byAttribute( $parentNodeId, $classIdentifier, $attributeIdentifier, $op, $searchString )
{
$contentClass = eZContentClass::fetchByIdentifier( $classIdentifier );
if( !$contentClass )
throw new Exception( "This content class does not exist: [" . $classIdentifier . "]" );
if( !eepValidate::validateContentNodeId( $parentNodeId ) )
throw new Exception( "This is an invalid parent node id: [" .$parentNodeId. "]" );
$classDataMap = $contentClass->attribute( "data_map" );
if( !isset( $classDataMap[ $attributeIdentifier ] ) )
throw new Exception( "Content class '" . $classIdentifier . "' does not contain this attribute: [" . $attributeIdentifier . "]" );
$qualifiedAttributeName = $classIdentifier ."/". $attributeIdentifier;
$limit = 100;
if( isset($additional["limit"]) )
{
$limit = $additional["limit"];
}
$offset = 0;
if( isset($additional["offset"]) )
{
$offset = $additional["offset"];
}
$params[ "ClassFilterType" ] = "include";
$params[ "ClassFilterArray" ] = array( $classIdentifier );
//$params[ "Depth" ] = 1;
$params[ "MainNodeOnly" ] = true;
$params[ "IgnoreVisibility" ] = true;
$params[ 'Limitation' ] = array();
$params[ 'Offset' ] = $offset;
$params[ 'Limit' ] = $limit;
switch( $op )
{
default:
throw new Exception( "in contentobject_commands:searchForObjects_byAttribute(), comparison operator [" .$op. "] is not recognized" );
break;
case "=":
$params[ "AttributeFilter" ] = array
(
array( $qualifiedAttributeName, "=", $searchString )
);
break;
case "like":
$params[ "AttributeFilter" ] = array
(
"and"
, array( $qualifiedAttributeName, "like", "*".$searchString."*" )
);
break;
case "!=":
$params[ "AttributeFilter" ] = array
(
array( $qualifiedAttributeName, "!=", $searchString )
);
break;
}
$matches = eZContentObjectTreeNode::subTreeByNodeID( $params, $parentNodeId );
$title = "Search on '" .$qualifiedAttributeName. "' for '" .$op." ".$searchString. "' from parent ".$parentNodeId;
eep::displayNodeList( $matches, $title );
}
//--------------------------------------------------------------------------
private function searchForNodes( $parentNodeId, $classIdentifier, $searchString )
{
$contentClass = eZContentClass::fetchByIdentifier( $classIdentifier );
if( !$contentClass )
throw new Exception( "This content class does not exist: [" . $classIdentifier . "]" );
if( !eepValidate::validateContentNodeId( $parentNodeId ) )
throw new Exception( "This is not a node id: [" .$parentNodeId. "]" );
$classId = eZContentClass::classIDByIdentifier( $classIdentifier );
$attributeList = eZContentClassAttribute::fetchListByClassID( $classId );
$limit = 100;
if( isset($additional["limit"]) )
{
$limit = $additional["limit"];
}
$offset = 0;
if( isset($additional["offset"]) )
{
$offset = $additional["offset"];
}
$params[ "ClassFilterType" ] = "include";
$params[ "ClassFilterArray" ] = array( $classIdentifier );
$params[ "MainNodeOnly" ] = true;
$params[ "IgnoreVisibility" ] = true;
$params[ 'Limitation' ] = array();
$params[ 'Offset' ] = $offset;
$params[ 'Limit' ] = $limit;
$searchStringIsNumeric = is_numeric( $searchString );
$numericTypes = array
(
"ezinteger"
, "ezfloat"
, "ezdatetime"
, "ezboolean"
);
$params[ "AttributeFilter" ] = array( "or" );
foreach( $attributeList as $attribute )
{
$qualifiedAttributeName = $classIdentifier ."/". $attribute->Identifier; // eg folder/name
// if the string is not numeric and the attribute is numeric, don't
// search on it -- this is still rough functionality
if( in_array( $attribute->DataTypeString, $numericTypes )
&& !$searchStringIsNumeric )
{
continue;
}
// search on everything else -- maybe a bad idea which generates too
// many hits ...
$params[ "AttributeFilter" ][] = array( $qualifiedAttributeName, "like", "*".$searchString."*" );
}
$matches = eZContentObjectTreeNode::subTreeByNodeID( $params, $parentNodeId );
$title = "Search on all attributes in '" .$classIdentifier. "' for '".$searchString. "' from parent ".$parentNodeId;
eep::displayNodeList( $matches, $title );
}
//--------------------------------------------------------------------------
private function location( $objectId, $parentNodeId )
{
if( !eepValidate::validateContentObjectId( $objectId ) )
throw new Exception( "This is not an object id: [" .$objectId. "]" );
if( !eepValidate::validateContentNodeId( $parentNodeId ) )
throw new Exception( "This is not a node id: [" .$parentNodeId. "]" );
$object = eZContentObject::fetch( $objectId );
$object->addLocation( $parentNodeId );
// this is a guess; but otherwise, the new node doesn't become available
eep::republishObject( $objectId );
}
//--------------------------------------------------------------------------
private function convertToContentObjectId( $nodeId )
{
$object = eZContentObject::fetchByNodeID( $nodeId, false );
return $object[ "id" ];
}
//--------------------------------------------------------------------------
private function move( $nodeId, $parentNodeId )
{
if( !eepValidate::validateContentNodeId( $nodeId ) )
throw new Exception( "This is not a node id: [" .$nodeId. "]" );
if( !eepValidate::validateContentNodeId( $parentNodeId ) )
throw new Exception( "This is not a node id: [" .$parentNodeId. "]" );
eZContentObjectTreeNodeOperations::move( $nodeId, $parentNodeId );
}
//--------------------------------------------------------------------------
private function clearSubtreeCache( $nodeId )
{
$node = eZContentObjectTreeNode::fetch( $nodeId );
$limit = 50;
$offset = 0;
$params = array( 'AsObject' => false,
'Depth' => false,
'Limitation' => array() ); // Empty array means no permission checking
$subtreeCount = $node->subTreeCount( $params );
while ( $offset < $subtreeCount )
{
$params['Offset'] = $offset;
$params['Limit'] = $limit;
$subtree = $node->subTree( $params );
$offset += count( $subtree );
if ( count( $subtree ) == 0 )
{
break;
}
$objectIDList = array();
foreach ( $subtree as $subtreeNode )
{
$objectIDList[] = $subtreeNode['contentobject_id'];
}
$objectIDList = array_unique( $objectIDList );
unset( $subtree );
foreach ( $objectIDList as $objectID )
eZContentCacheManager::clearContentCacheIfNeeded( $objectID );
}
}
//--------------------------------------------------------------------------
private function setSortOrder( $nodeId, $sortField, $sortOrder )
{
$availableSortFields = array
(
"PATH" => eZContentObjectTreeNode::SORT_FIELD_PATH
, "PUBLISHED" => eZContentObjectTreeNode::SORT_FIELD_PUBLISHED
, "MODIFIED" => eZContentObjectTreeNode::SORT_FIELD_MODIFIED
, "SECTION" => eZContentObjectTreeNode::SORT_FIELD_SECTION
, "DEPTH" => eZContentObjectTreeNode::SORT_FIELD_DEPTH
, "CLASS_IDENTIFIER" => eZContentObjectTreeNode::SORT_FIELD_CLASS_IDENTIFIER
, "CLASS_NAME" => eZContentObjectTreeNode::SORT_FIELD_CLASS_NAME
, "PRIORITY" => eZContentObjectTreeNode::SORT_FIELD_PRIORITY
, "NAME" => eZContentObjectTreeNode::SORT_FIELD_NAME
, "MODIFIED_SUBNODE" => eZContentObjectTreeNode::SORT_FIELD_MODIFIED_SUBNODE
, "NODE_ID" => eZContentObjectTreeNode::SORT_FIELD_NODE_ID
, "CONTENTOBJECT_ID" => eZContentObjectTreeNode::SORT_FIELD_CONTENTOBJECT_ID
);
$availableSortDirections = array
(
"DESC" => eZContentObjectTreeNode::SORT_ORDER_DESC
, "ASC" => eZContentObjectTreeNode::SORT_ORDER_ASC
);
if( !eepValidate::validateContentNodeId( $nodeId ) )
throw new Exception( "This is not a node id: [" .$nodeId. "]" );
if( !isset( $availableSortFields[ $sortField ] ) )
throw new Exception( "This sort field is not recognized: [" . $sortField . "]" );
if( !isset( $availableSortDirections[ $sortOrder ] ) )
throw new Exception( "This sort field is not recognized: [" . $sortOrder . "]" );
$node = eZContentObjectTreeNode::fetch( $nodeId );
$node->setAttribute( 'sort_field', $availableSortFields[ $sortField ] );
$node->setAttribute( 'sort_order', $availableSortDirections[ $sortOrder ] );
$node->store();
echo "set sort order on node id: " . $nodeId . " on attribute: " . $sortField . " to " . $sortOrder . "\n";
}
//--------------------------------------------------------------------------
private function hidesubtree( $nodeId )
{
if( !eepValidate::validateContentNodeId( $nodeId ) )
throw new Exception( "This is not a node id: [" .$nodeId. "]" );
$node = eZContentObjectTreeNode::fetch( $nodeId );
eZContentObjectTreeNode::hideSubTree( $node );
}
//--------------------------------------------------------------------------
private function unhidesubtree( $nodeId )
{
if( !eepValidate::validateContentNodeId( $nodeId ) )
throw new Exception( "This is not a node id: [" .$nodeId. "]" );
$node = eZContentObjectTreeNode::fetch( $nodeId );
eZContentObjectTreeNode::unhideSubTree( $node );
}
//--------------------------------------------------------------------------
const dump_interestingNodeMembers = array
(
"Name"
, "MainNodeID"
, "NodeID"
, "ClassIdentifier"
, "ParentNodeID"
, "ContentObjectID"
, "ContentObjectVersion"
, "ContentObjectIsPublished"
, "Depth"
, "SortField"
, "SortOrder"
, "Priority"
, "ModifiedSubNode"
, "PathString"
, "PathIdentificationString"
, "RemoteID"
, "IsHidden"
, "IsInvisible"
);
const dump_interestingContentObjectMembers = array
(
"ID"
, "SectionID"
, "OwnerID"
, "Published"
, "Modified"
, "CurrentVersion"
, "Status"
);
const dump_userAttributes = array
(
"Login"
, "Email"
, "PasswordHash"
, "PasswordHashType"
//, "PersistentDataDirty"
, "Groups"
, "OriginalPassword"
, "OriginalPasswordConfirm"
, "ContentObjectID"
);
const dump_interestingAttributeMembers = array
(
"ID"
//, "PersistentDataDirty"
, "HTTPValue"
, "Content"
, "DisplayInfo"
, "IsValid"
, "ContentClassAttributeID"
//, "ValidationError"
//, "ValidationLog"
, "ContentClassAttributeIdentifier"
, "ContentClassAttributeCanTranslate"
, "ContentClassAttributeName"
, "ContentClassAttributeIsInformationCollector"
, "ContentClassAttributeIsRequired"
//, "InputParameters"
//, "HasValidationError"
, "DataTypeCustom"
, "ContentObjectID"
, "Version"
, "LanguageCode"
, "AttributeOriginalID"
, "SortKeyInt"
, "SortKeyString"
, "DataTypeString"
, "DataText"
, "DataInt"
, "DataFloat"
);
//--------------------------------------------------------------------------
// kind of a massive function using a bunch of furniture; look at the furniture
// for how to tweak the export to suit your purposes
private function dumpNodeToXML( $nodeId )
{
// need to operate in a privileged account
$adminUserObject = eZUser::fetch( eepSetting::PrivilegedAccountId );
$adminUserObject->loginCurrent();
$needToDumpeZUserData = false;
if( !eepValidate::validateContentNodeId( $nodeId ) )
throw new Exception( "This is not a node id: [" .$nodeId. "]" );
$eepLogger = new eepLog( eepSetting::LogFolder, eepSetting::LogFile );
$node = eZFunctionHandler::execute( "content", "node", array( "node_id" => $nodeId ) );
//print_r( $node );
$contentClassIdentifier = $node->ClassIdentifier;
eep::writeXMLTag( 0, "item", null );
eep::writeXMLTag( 4, "node", null );
// dump the interesting data for the node
foreach( contentnode_commands::dump_interestingNodeMembers as $member )
{
if( isset( $node->$member ) )
{
eep::writeXMLTag( 8, $member, $node->$member );
}
else
{
$eepLogger->Report( "Node-member not available: ".$member, "error" );
}
}
eep::writeXMLTag( 4, "/node", null );
// dump the interesting data for the content object
$object = $node->attribute( 'object' );
eep::writeXMLTag( 4, "content-object", null );
foreach( contentnode_commands::dump_interestingContentObjectMembers as $member )
{
if( isset( $object->$member ) )
{
eep::writeXMLTag( 8, $member, $object->$member );
}
else
{
$eepLogger->Report( "Content-object-member not available: ".$member, "error" );
}
}
eep::writeXMLTag( 4, "/content-object", null );
// get list of active languages
$activeLanguageStructs = eZContentLanguage::fetchList( true );
$activeLanguages = array();
foreach( $activeLanguageStructs as $als )
{
$activeLanguages[] = $als->Locale;
}
//print_r( $activeLanguages );
// dump all the attributes, associated by translation
eep::writeXMLTag( 4, "attributes", null );
foreach( $activeLanguages as $languageCode )
{
// get the datamap associated with a specific language
$datamap = eZFunctionHandler::execute
(
"content"
, "contentobject_attributes"
, array
(
"version" => $object->attribute( "current" )
, "language_code" => $languageCode
)
);
//print_r( $datamap );
eep::writeXMLTag( 8, "language language-code='" . $languageCode . "'", null );
foreach( $datamap as $attributeIdentifier => $attribute )
{
if( "ezuuser" == $attribute->DataTypeString ) // special case, handled below
{
$contentClassIdentifier = true;
}
else
{
$contentClassIdentifier = false;
}
//echo "\n\n" . $attribute->DataTypeString . "\n\n";
eep::writeXMLTag( 12, "attribute", null );
foreach( contentnode_commands::dump_interestingAttributeMembers as $member )
{
if( "DataText"==$member && "ezxmltext"==$attribute->DataTypeString )
{
$ezText = new eZXMLText( $attribute->DataText, $attribute );
$oh = $ezText->attribute( "output" );
eep::writeXMLTag( 16, "DataText", "" . $oh->attribute( "output_text" ) );
}
elseif( "Content"==$member && "ezbinaryfile"==$attribute->DataTypeString )
{
eep::writeXMLTag( 16, "Content", serialize( $attribute->content() ) ); // for, eg, ezbinaryfile->Content ... is an object
}
else
{
eep::writeXMLTag( 16, $member, "" . $attribute->$member );
}
}
eep::writeXMLTag( 12, "/attribute", null );
}
eep::writeXMLTag( 8, "/language", null );
}
eep::writeXMLTag( 4, "/attributes", null );
// special case, content class uses the magical ezuser datatype to designate a system user
if( $needToDumpeZUserData )
{
if( "user" == $contentClassIdentifier )
{
eep::writeXMLTag( 4, "user", null );
$user = eZUser::fetch( $object->ID );
foreach( contentnode_commands::dump_userAttributes as $member )
{
eep::writeXMLTag( 8, $member, $user->$member );
}
eep::writeXMLTag( 4, "/user", null );
}
}
eep::writeXMLTag( 0, "/item", null );
$adminUserObject->logoutCurrent();
}
//--------------------------------------------------------------------------
public function run( $argv, $additional )
{
$command = @$argv[2];
$param1 = @$argv[3];
$param2 = @$argv[4];
$param3 = @$argv[5];
if( !in_array( $command, $this->availableCommands ) )
{
throw new Exception( "Command '" . $command . "' not recognized." );
}
$eepCache = eepCache::getInstance();
switch( $command )
{
case "help":
echo "\nAvailable commands:: " . implode( ", ", $this->availableCommands ) . "\n";
echo "\n".$this->help."\n";
break;
case self::contentnode_info:
$nodeId = $eepCache->readFromCache( eepCache::use_key_contentnode );
if( $param1 )
{
$nodeId = $param1;
}
$this->fetchNodeInfoFromId( $nodeId );
break;
case self::contentnode_location:
$contentObjectId = $eepCache->readFromCache( eepCache::use_key_object );
$parentNodeId = $param1;
$this->location( $contentObjectId, $parentNodeId );
break;
case self::contentnode_find:
$classIdentifier = $param1;
$parentNodeId = $param2;
$searchString = $param3;
$this->searchForNodes( $parentNodeId, $classIdentifier, $searchString );
break;
case self::contentnode_deletesubtree:
$subtreeNodeId = $eepCache->readFromCache( eepCache::use_key_contentnode );
if( $param1 )
{
$subtreeNodeId = $param1;
}
$this->deleteSubtree( $subtreeNodeId, $additional );
break;
case self::contentnode_dump:
$nodeId = $param1;
echo $this->dumpNodeToXML( $nodeId );
break;
case self::contentnode_contentobject:
$nodeId = $eepCache->readFromCache( eepCache::use_key_contentnode );
if( $param1 )
{
$nodeId = $param1;
}
echo $this->convertToContentObjectId( $nodeId );
break;
case self::contentnode_move:
if( $param2 )
{
// both the node and the parent are being provided
$nodeId = $param1;
$parentNodeId = $param2;
}
else
{
$nodeId = $eepCache->readFromCache( eepCache::use_key_contentnode );
$parentNodeId = $param1;
}
$this->move( $nodeId, $parentNodeId );
break;
case self::contentnode_clearsubtreecache:
$nodeId = $eepCache->readFromCache( eepCache::use_key_contentnode );
if( $param1 )
{
$nodeId = $param1;
}
echo $this->clearSubtreeCache( $nodeId );
break;
case self::contentnode_setsortorder:
$nodeId = (integer )$param1;
$sortField = $param2;
$sortOrder = $param3;
$this->setSortOrder( $nodeId, $sortField, $sortOrder );
break;
case self::contentnode_hidesubtree:
$nodeId = (integer )$param1;
$this->hidesubtree( $nodeId );
break;
case self::contentnode_unhidesubtree:
$nodeId = (integer )$param1;
$this->unhidesubtree( $nodeId );
break;
}
}
}
//------------------------------------------------------------------------------
$operation = new contentnode_commands();
if( !isset($argv[2]) )
{
$argv[2] = "help";
}
$additional = eep::extractAdditionalParams( $argv );
$operation->run( $argv, $additional );
?>