Xavier Dutoit
|
Monday 15 May 2006 1:22:57 am
Hi, No "out of the box" functionnalities for that. It is quite simple to develop one. We are working on an extension to ease the admin of a website (so far focussing on the creation of content), it looks like a nice add on. This being said, that's not my priority so far, unless you persuade me otherwise ;) Plan B: export the class definitions as a package, delete the classes (it's going to delete the content too) and import the package containing the classes. It <b>should</b> work. Let us know... X+
http://www.sydesy.com
|
Kristof Coomans
|
Monday 15 May 2006 2:31:47 am
Hi Ted I once wrote such a command line script. I haven't used it for a long time, but it will probably still work with the latest eZ publish releases.
#!/usr/bin/env php
<?php
// include needed kernel classes
include_once( 'kernel/classes/ezscript.php' );
include_once( 'kernel/classes/ezcontentclass.php' );
include_once( 'kernel/classes/ezcontentobject.php' );
// include needed library classes
include_once( 'lib/ezutils/classes/ezcli.php' );
$cli = &eZCLI::instance( );
$script = &eZScript::instance( array( 'description' => 'this script automates the removal of objects, usefull when removing corrupt items or cleaning up test data on development portals',
'use-session' => false,
'use-modules' => false,
'use-extensions' => true ) );
$script->startup( );
$options =& $script->getOptions( '[classidentifier:][objectid:][exclude:][preview]', '', array( 'classidentifier' => 'class identifier of the objects you want to remove', 'exclude' => 'comma seperated list of object id\'s to exclude from removal', 'preview' => 'don\'t really remove objects, just show what would happen', 'objectid' => 'comma seperated list of the object id\'s you want to remove' ), false, array( 'user' => true ) );
$script->initialize( );
$objects = array( );
if ( $options['classidentifier'] or $options['objectid'] )
{
// get the objects according to specified options
if ( $options['classidentifier'] )
{
$class = &eZContentClass::fetchByIdentifier( $options['classidentifier'] );
if ( $class )
{
$objects = &eZContentObject::fetchSameClassList( $class->attribute( 'id' ) );
}
else
{
$cli->output( 'could not find class' );
}
}
elseif ( $options['objectid'] )
{
$idList = explode( ',', $options['objectid'] );
if ( is_array( $idList ) )
{
$objects = &eZContentObject::fetchIDArray( $idList );
}
else
{
$objects[] = &eZContentObject::fetch( $idList );
}
}
if ( count( $objects ) > 0 )
{
$removedCount = 0;
$excludes = array( );
if ( $options['exclude'] )
{
$excludes = explode( ',', $options['exclude'] );
}
foreach( array_keys( $objects ) as $key )
{
if ( in_array( $objects[$key]->attribute( 'id' ), $excludes ) )
{
$cli->output( 'excluding object ' . $objects[$key]->attribute( 'id' ) . ': ' . $objects[$key]->attribute( 'name' ) );
}
else
{
$cli->output( 'removing object ' . $objects[$key]->attribute( 'id' ) . ': ' . $objects[$key]->attribute( 'name' ) );
if ( $options['preview'] !== true )
{
if ( $objects[$key]->attribute( 'status' ) == EZ_CONTENT_OBJECT_STATUS_PUBLISHED )
{
$assignedNodes = $objects[$key]->attribute( 'assigned_nodes' );
$nodeIdArray = array( );
foreach ( array_keys( $assignedNodes ) as $assignedNodeKey )
{
if ( $assignedNodes[$assignedNodeKey]->attribute( 'can_remove' ) )
{
$nodeIdArray[] = $assignedNodes[$assignedNodeKey]->attribute( 'node_id' );
}
else
{
$nodeIdArray = false;
break;
}
}
if ( $nodeIdArray )
{
eZContentObjectTreeNode::removeSubtrees( $nodeIdArray, false );
}
else
{
$cli->output( 'you have insufficient rights to remove this object' );
}
}
else
{
$objects[$key]->remove( );
$objects[$key]->purge( );
}
}
$removedCount++;
}
}
$cli->output( 'removed items: ' . $removedCount );
}
else
{
$cli->output( 'no objects of this class were found' );
}
}
else
{
$script->showHelp( );
}
$script->shutdown( );
?>
independent eZ Publish developer and service provider | http://blog.coomanskristof.be | http://ezpedia.org
|