Skip to content

Commit

Permalink
Updated: Added php script parameter code and example ini settings to …
Browse files Browse the repository at this point in the history
…exclude content from parent node ids content tree paths from report
  • Loading branch information
brookinsconsulting committed Mar 6, 2015
1 parent 902befa commit e60f67e
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 11 deletions.
43 changes: 36 additions & 7 deletions bin/php/ezpfolderswithnocontentreport.php
Expand Up @@ -3,10 +3,10 @@
/**
* File containing the ezpfolderswithnocontentreport.php bin script
*
* @copyright Copyright (C) 1999 - 2015 Brookins Consulting. All rights reserved.
* @copyright Copyright (C) 2013 - 2015 Think Creative. All rights reserved.
* @copyright Copyright (C) 1999 - 2016 Brookins Consulting. All rights reserved.
* @copyright Copyright (C) 2013 - 2016 Think Creative. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 (or later)
* @version 0.1.1
* @version 0.1.2
* @package ezpfolderswithnocontentreport
*/

Expand All @@ -21,22 +21,28 @@
$cli = eZCLI::instance();
$script = eZScript::instance( array( 'description' => ( "eZ Publish Folders With No Content CSV Report Script\n" .
"\n" .
"ezpfolderswithnocontentreport.php --storage-dir=var/foldersWithNoContentCsvReport --hostname=www.example.com" ),
"ezpfolderswithnocontentreport.php --storage-dir=var/foldersWithNoContentCsvReport --hostname=www.example.com --exclude-node-ids=43,1999,2001" ),
'use-session' => false,
'use-modules' => true,
'use-extensions' => true,
'user' => true ) );

$script->startup();

$options = $script->getOptions( "[storage-dir:][hostname:]",
$options = $script->getOptions( "[storage-dir:][hostname:][exclude-node-ids:]",
"[node]",
array( 'storage-dir' => 'Directory to place exported report file in',
'hostname' => 'Website hostname to match url searches for' ),
'hostname' => 'Website hostname to match url searches for',
'exclude-node-ids' => 'Comma separted list of nodeID content tree nodeID paths to exclude from report. This parameter overrides defeault ini settings when used.' ),
false,
array( 'user' => true ) );
$script->initialize();


/** Access ini variables **/
$ini = eZINI::instance();
$iniFoldersWithNoContentReport = eZINI::instance( 'ezpfolderswithnocontentreport.ini' );

/** Script default values **/

$openedFPs = array();
Expand All @@ -47,6 +53,8 @@

$siteNodeUrlPrefix = "http://";

$excludeParentNodeIDs = $iniFoldersWithNoContentReport->variable( 'SiteSettings', 'ExcludedParentNodeIDs' );

/** Test for required script arguments **/

if ( $options['storage-dir'] )
Expand All @@ -68,6 +76,10 @@
$script->shutdown( 2 );
}

if ( isset( $options['exclude-node-ids'] ) )
{
$excludeParentNodeIDs = explode( ',', $options['exclude-node-ids'] );
}

/** Alert user of report generation process starting **/

Expand Down Expand Up @@ -149,6 +161,7 @@
{
$objectData = array();
$estimateObjectOrphaned = 0;
$excludeObjectMainNode = false;
$status = true;

/** Fetch object details **/
Expand All @@ -166,13 +179,29 @@
$objectName = $object->name();
$objectMainNode = $object->mainNode();

if( $object->attribute('current_version') != $contentObject['version'] )
if( $object->attribute( 'current_version' ) != $contentObject['version'] )
{
continue;
}

if ( is_object( $objectMainNode ) )
{
/** Test if content object tree node id exists within excluded parent node ids content tree node id path **/
foreach( $excludeParentNodeIDs as $excludeParentNodeID )
{
if( strpos( $objectMainNode->attribute( 'path_string' ), '/' . $excludeParentNodeID . '/' ) !== false )
{
// print_r( $objectMainNode->attribute( 'path_string' ) ); echo "\n\n";
$excludeObjectMainNode = true;
}
}

/** Exclude matches from the report **/
if( $excludeObjectMainNode == true )
{
continue;
}

$objectMainNodeID = $objectMainNode->attribute( 'node_id' );
$objectMainNodePath = $siteNodeUrlPrefix . $siteNodeUrlHostname . '/' . $objectMainNode->attribute( 'url' );

Expand Down
8 changes: 4 additions & 4 deletions ezinfo.php
Expand Up @@ -2,8 +2,8 @@
/**
* File containing the ezpfolderswithnocontentreportInfo class.
*
* @copyright Copyright (C) 1999 - 2015 Brookins Consulting. All rights reserved.
* @copyright Copyright (C) 2013 - 2015 Think Creative. All rights reserved.
* @copyright Copyright (C) 1999 - 2016 Brookins Consulting. All rights reserved.
* @copyright Copyright (C) 2013 - 2016 Think Creative. All rights reserved.
* @license http://www.gnu.org/licenses/gpl-2.0.txt GNU General Public License v2 (or any later version)
* @version //autogentag//
* @package ezpfolderswithnocontentreport
Expand All @@ -14,8 +14,8 @@ function info()
{
return array(
'Name' => "<a href='http://bitbucket.org/brookinsconsulting/ezpfolderswithnocontentreport'>eZp Folders With No Content Report</a>",
'Version' => "0.1.1",
'Copyright' => "Copyright (C) 1999 - 2015 <a href='http://brookinsconsulting.com'>Brookins Consulting</a> and <a href='http://thinkcreative.com'>Think Creative</a>",
'Version' => "0.1.2",
'Copyright' => "Copyright (C) 1999 - 2016 <a href='http://brookinsconsulting.com'>Brookins Consulting</a> and <a href='http://thinkcreative.com'>Think Creative</a>",
'Author' => "Brookins Consulting",
'License' => "GNU General Public License"
);
Expand Down
3 changes: 3 additions & 0 deletions settings/ezpfolderswithnocontentreport.ini.append.php
Expand Up @@ -4,4 +4,7 @@
SiteHostname=admin.example.com
ReportStoragePath=var/foldersWithNoContentCsvReport
ExcludedParentNodeIDs[]
#ExcludedParentNodeIDs[]=43
*/ ?>

0 comments on commit e60f67e

Please sign in to comment.