Thursday 18 August 2011 9:22:58 am
By : Steven E. Bailey
For a customer i had to find the objects (out of hundreds) that had an attribute filled out, I figured an attribute filter would be the easiest:
<?php require 'autoload.php'; $cli = eZCLI::instance(); $script = eZScript::instance( array( 'description' => ( "Returns the path and value of objects of <class> that have a non-null value for <attribute>" ), 'use-session' => false, 'use-modules' => true, 'use-extensions' => true ) ); $script->startup(); $options = $script->getOptions( "[class:][attribute:][C:][a:]", "", array( 'class' => "class", 'attribute' => "attribute" ) ); $script->initialize(); $identifier = $options['class'] ? $options['class'] : $options['C']; $attidentifier = $options['attribute'] ? $options['attribute'] : $options['a']; if (!$identifier OR !$attidentifier) { $cli->error( "You must have one --class=<class> identifier and one --attribute=<attribute> identifier"); $script->shutdown(); exit; } if ( is_numeric( $identifier ) ) { $ContentObjectClass = eZContentClass::fetch( $identifier ); $identifier = $ContentObjectClass->attribute('identifier'); } if ($attidentifier) { if ( is_numeric( $attidentifier ) ) { $attidentifier = eZContentClassAttribute::classAttributeIdentifierByID( $attidentifier ); } $attributefilterstring = $identifier."/".$attidentifier; $attributefilter = array( array( $attributefilterstring ,'!=', null ) ); } $params = array(); $params['Limitation'] = array(); // access override $params['MainNodeOnly'] = true; // dont fecth dupes $params['IgnoreVisibility'] = true; // ignore hidden if ($identifier) { $params['ClassFilterType'] = "include"; // "include" or "exclude" $params['ClassFilterArray'] = array($identifier); // array of class_identifiers } $params['AttributeFilter'] = ($attributefilter) ? $attributefilter : false; $topNodeID = 1; $objects = eZContentObjectTreeNode::subTreeByNodeID( $params, $topNodeID ); if ( count($objects) == 0 ) $cli->output( "NO MATCHES" ); else { $cli->output( count($objects) ); foreach($objects as $object) { $cli->output( $object->attribute( 'path_identification_string') ); $datamap = $object->DataMap(); $cli->output( $datamap[$attidentifier]->content() ); } } $cli->output(); $script->shutdown(); ?>
Timing: | Jan 17 2025 23:55:39 |
Script start | |
Timing: | Jan 17 2025 23:55:39 |
Module start 'layout' | |
Timing: | Jan 17 2025 23:55:39 |
Module start 'content' | |
Timing: | Jan 17 2025 23:55:39 |
Module end 'content' | |
Timing: | Jan 17 2025 23:55:39 |
Script end |
Total runtime | 0.0693 sec |
Peak memory usage | 6,144.0000 KB |
Database Queries | 42 |
Checkpoint | Start (sec) | Duration (sec) | Memory at start (KB) | Memory used (KB) |
---|---|---|---|---|
Script start | 0.0000 | 0.0061 | 588.1641 | 152.6563 |
Module start 'layout' | 0.0062 | 0.0026 | 740.8203 | 39.5156 |
Module start 'content' | 0.0088 | 0.0591 | 780.3359 | 361.1875 |
Module end 'content' | 0.0678 | 0.0014 | 1,141.5234 | 15.7031 |
Script end | 0.0693 | 1,157.2266 |
Accumulator | Duration (sec) | Duration (%) | Count | Average (sec) |
---|---|---|---|---|
Ini load | ||||
Load cache | 0.0029 | 4.1209 | 15 | 0.0002 |
Check MTime | 0.0012 | 1.7892 | 15 | 0.0001 |
Mysql Total | ||||
Database connection | 0.0010 | 1.3825 | 1 | 0.0010 |
Mysqli_queries | 0.0304 | 43.8219 | 42 | 0.0007 |
Looping result | 0.0002 | 0.3358 | 40 | 0.0000 |
Template Total | 0.0430 | 62.0 | 2 | 0.0215 |
Template load | 0.0021 | 3.0161 | 2 | 0.0010 |
Template processing | 0.0409 | 58.9977 | 2 | 0.0204 |
Template load and register function | 0.0001 | 0.1270 | 1 | 0.0001 |
states | ||||
state_id_array | 0.0003 | 0.4373 | 1 | 0.0003 |
state_identifier_array | 0.0014 | 1.9928 | 2 | 0.0007 |
Override | ||||
Cache load | 0.0017 | 2.3844 | 8 | 0.0002 |
Sytem overhead | ||||
Fetch class attribute name | 0.0019 | 2.7161 | 3 | 0.0006 |
class_abstraction | ||||
Instantiating content class attribute | 0.0000 | 0.0083 | 3 | 0.0000 |
General | ||||
dbfile | 0.0006 | 0.8289 | 10 | 0.0001 |
String conversion | 0.0000 | 0.0127 | 4 | 0.0000 |
Note: percentages do not add up to 100% because some accumulators overlap |
Usage | Requested template | Template | Template loaded | Edit | Override |
---|---|---|---|---|---|
1 | node/view/full.tpl | blog_entry/full.tpl | extension/community_design/design/suncana/override/templates/blog_entry/full.tpl | ||
2 | content/datatype/view/ezxmltext.tpl | <No override> | extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tpl | ||
2 | content/datatype/view/ezxmltags/paragraph.tpl | <No override> | extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tpl | ||
1 | content/datatype/view/ezxmltags/literal.tpl | <No override> | extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tpl | ||
1 | content/datatype/view/ezkeyword.tpl | <No override> | extension/community_design/design/suncana/templates/content/datatype/view/ezkeyword.tpl | ||
1 | print_pagelayout.tpl | <No override> | extension/community/design/community/templates/print_pagelayout.tpl | ||
Number of times templates used: 8 Number of unique templates used: 6 |
Time used to render debug report: 0.0001 secs