{
		$script->shutdown( 1, $e->getMessage() );
	}
}
elseif ( $interactive )
{
	$db = MMDB::instance();
	
	$results = $db->arrayQuery( 'select path from mm_publisher_folder' );
	$question = 'Select publisher folders to align articles for';
	$choices = array();
	
	foreach ( $results as $result )
		$choices[] = $result['path'];
	
	$replies = $questionHandler->askQuestionMultipleChoices( $question, $choices, 'validateReplyMultiple', false );
	
	foreach ( $replies as $choice )
	{
		try
		{
			$publisherObject = fetchPublisher( $choices[$choice] );
			alignArticle( $publisherObject, $checkModified, $checkLocations, $checkLanguages, $checkHidden, $timingDelay, $forceLast, $sleepTime );
		}
		catch ( Exception $e )
		{
			echo "Publisher folder doesn't exist : {$choices[$choice]}";
			echo $e->getMessage(). "\n";
		}
	}
}
    }

    $pathIdentificationString = $node->attribute('path_identification_string');

    if ( $node->IsHidden )
    {
        $cli->warning ( " Already hidden : [" . $nodeId . "] " . $pathIdentificationString . " : " . $node->getName() );
        continue;
    }

    $validCalculatorsNodeId[] = $nodeId;
    $possibleReplies[] = $nodeId . " " . $pathIdentificationString . " : " . $node->getName();
}

$questionHandler = new QuestionInteractiveCli();
$question = "Hide which nodes";

$response = $questionHandler->askQuestionMultipleChoices($question, $possibleReplies, 'validateReplyMultiple', true);

foreach ( $response as $indexToHide )
{
    $nodeId = $validCalculatorsNodeId[$indexToHide];
    $node   = eZContentObjectTreeNode::fetch($nodeId);

    eZContentObjectTreeNode::hideSubTree( $node );
    eZSearch::updateNodeVisibility( $node->NodeID, 'hide' );

    $pathIdentificationString = $node->attribute('path_identification_string');
    $cli->warning ( " Hiding : [" . $nodeId . "] " . $pathIdentificationString . " : " . $node->getName() );
}
        {
            $cli->warning("Folder $folder is not a valid publisher folder path");
        }
    }

    if ( count($replies) == 0 )
    {
        $cli->error( 'No valid folder to treat, script is stoping');
        $script->shutdown(1);
    }
}
else
{
    $replies = $interactiveQuestion->askQuestionMultipleChoices(
        'Choose publisher folders you want to purge',
        $folders,
        'validateReplyMultiple',
        true
    );
}

if ( !empty( $replies ) )
{
    foreach ( $replies as $key )
    {
        try
        {
            $publisherFolderPath = $folders[$key];
            $publisherFolderNode = PublisherFolderTool::getPublisherFolderNodeFromPath ( $publisherFolderPath );
            
            if ( !($publisherFolderNode instanceof eZContentObjectTreeNode) )
            {
    'sanitize' => 'Decides whether unexisting clusters should be removed from the list (default: true)',
    'backup' => 'Decides whether existing file should be backed up as "name.png.bak" before overwriting (defalt: true)',
    'timestamp' => 'Decides whether timestamp should be added to name of file outputted (default: true)',
    'env' => 'Environment used for generating sprite (default: current environment)'
));

$script->startup();
$script->initialize();

$options = parseOptions($options);

$clusterIdentifiers = $options['clusterIdentifiers'];

if ( $options['interactive'] )
{
    $replies = $cli->askQuestionMultipleChoices( 'Select cluster identifiers to generate sprites for', $clusterIdentifiers, 'validateReplyMultiple', true );
    if (empty($replies))
    {
        $script->shutdown(1, 'No clusters were selected');
    }
    $selectedClusters = array();
    foreach ($replies as $reply)
    {
       $selectedClusters[] = $clusterIdentifiers[$reply];
    }
    $clusterIdentifiers = $selectedClusters;
}


$spriteTool = new SpriteTool($options['env']);
    {
        $publisherFolders = fetchPublisherFoldersForCluster( $clusterIdentifier );
    }
    catch ( Exception $e )
    {
        $script->shutdown( 1, $e->getMessage() );
    }

    if ( !is_array( $publisherFolders ) || empty( $publisherFolders ) )
    {
        $script->shutdown( 1, 'No publisher folders are available for given cluster identifier' );
    }

    if ( $interactive )
    {
        $replies = $cli->askQuestionMultipleChoices( 'Select publisher folders to align articles for', $publisherFolders['questions'], 'validateReplyMultiple', true );
        if ( empty( $replies ) )
        {
            $script->shutdown( 1, 'No publisher folders selected' );
        }
        foreach ( $replies as $key )
        {
            $publisherObject = $publisherFolders['objects'][$key];
            alignArticleLocation( $publisherObject );
        }
    }
    else
    {
        foreach ( $publisherFolders['objects'] as $publisherObject )
        {
            alignArticleLocation( $publisherObject );
    $id      = $row['id'];
    $update  = is_array( eZContentObject::fetchByRemoteID( 'publisher_folder-' . $row['path'], false ) );

    if ( !$update )
        $folders[$id] = 'Create' . $row['path'];
}

if (count($folders) > 0)
{
    if ( $autoMode )
        $replies = array_keys($folders);
    else
    {
        $replies = $cli->askQuestionMultipleChoices(
            'Choose publisher folders you want to create',
            $folders,
            'validateReplyMultiple',
            true
        );
    }

    if (!empty($replies))
    {
        foreach ($replies as $key)
        {
            try
            {
                $object = MMSynchPublisherFolder::fetch($key);
                $path   = $object->getContent(true)->fields->path->toString();
            }
            catch (Exception $e)
            {
function selectTaxonomiesToUpdate($taxonomies)
{
    $questionHandler = new QuestionInteractiveCli();
    $possibleReplies = array();

    foreach ($taxonomies as $taxonomy)
    {
        if ( $taxonomy['case'] == 1 )
        {
            // Change Label
            $possibleReplies[] = "[{$taxonomy['category']}] ({$taxonomy['code']}) New translation \"{$taxonomy['oldLabel']}\" to \"{$taxonomy['label']}\"";
        }
        elseif ( $taxonomy['case'] == 2 )
        {
            // Add Taxonomy
            $possibleReplies[] = "[{$taxonomy['category']}] ({$taxonomy['code']}) Add taxonomy \"{$taxonomy['label']}\"";
        }
        elseif ( $taxonomy['case'] == 3 )
        {
            // Add Taxonomy
            $possibleReplies[] = "[{$taxonomy['category']}] ({$taxonomy['code']}) Add translation \"{$taxonomy['label']}\"";
        }
    }

    $question = "Which of these actions should be done";
    $response = $questionHandler->askQuestionMultipleChoices ( $question, $possibleReplies, "validateReplyMultiple", true );

    return $response;
}