) );

$script->initialize();

$publisher         = $options['publisher'];
$clusterIdentifier = $options['clusterIdentifier'];
$checkModified	   = isset($options['checkModified']);
$checkLocations	   = isset($options['checkLocations']);
$checkLanguages	   = isset($options['checkLanguages']);
$checkHidden       = isset($options['checkHidden']);
$interactive       = isset($options['interactive']);
$sleepTime         = $options['sleepTime'];
$forceLast         = $options['forceLast'];
$timingDelay	   = $options['timingDelay'];
$eZSolr            = eZSearch::getEngine();
$questionHandler   = new QuestionInteractiveCli();

if ( isset($options['allChecks']) )
	$checkModified = $checkLocations = $checkLanguages = $checkHidden = true;

if ( $publisher == null && $clusterIdentifier == null && !$interactive )
	$script->shutdown( 1, 'Either publisher or clusterIdentifier has to be given or interactive should be used' );
else if ( $publisher != null && $clusterIdentifier != null )
	$script->shutdown( 1, 'Only one of the options publisher/clusterIdentifier can be set' );

if ( !empty($publisher) )
	$source = SOURCE_PUBLISHER;
elseif( !empty($clusterIdentifier) )
	$source = SOURCE_CLUSTER;

if ( empty($timingDelay) || !is_numeric($timingDelay) )
        continue;
    }

    $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() );
}
if (!array_key_exists($countryCode, $clusterMapping))
{
    $cli->error('No cluster mapping is defined in merck.ini for country-code ' . $countryCode);
    $script->shutdown(1);
}
$clusterIdentifier = $clusterMapping[$countryCode];

$application = ApplicationObject::fetchObject(ApplicationObject::definition(), null, array('id' => $appId));
if ($application == null || $application instanceof ApplicationObject == false)
{
    $cli->error("Application with id {$appId} doesn't exist.");
    $script->shutdown(1);
}
$applicationIdentifier = $application->identifier;

$questionCli = new QuestionInteractiveCli();
$replies = array(
    'N' => 'N',
    'Y' => 'Y'
);
$response = $questionCli->askQuestion( "Are you sure you want to remove application {$application->identifier} for country {$countryCode}", $replies);
if ($response == 'N')
{
    $cli->error('Operation aborted by user');
    $script->shutdown(0);
}

removeApplicationFromUserAppBar();
removeApplicationFromCountryAppBar();
removeApplicationFromCountryApplicationLibrary();
removeIcons();
/**
 * Asks user about new country code for given country - if it's different, updates it. 
 * @param eZContentObject $country
 * @param QuestionInteractiveCli $cli
 * @return eZContentObject
 */
function interactiveUpdateCountry( $country, $cli )
{
    $countryCode = $country->Name;
    $question = "Specify the new name of the country {$countryCode} (leave empty if the name should not change)";
    $countryCode = $cli->askQuestion( $question, array(
        '/(^$)|(^[a-zA-Z]{2,3}$)/'
    ), 'validateReplyRegex', false );
    if ( $countryCode == '' || $countryCode == $country->Name )
    {
        $countryCode = $country->Name;
    }
    else
    {
        $country = updateCountry( $country, $countryCode );
    }
    return $country;
}
    'debug-output'   => false,
) );

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

if ( ContextTool::instance()->environment() != ContextTool::ENVIRONMENT_PROD )
    $script->shutdown( 1, "This script can only be run on production" );

$options = $script->getOptions( "[cluster:][nlt:][frq:]", array(
    'cluster'   => 'Cluster identifier',
    'nlt'       => 'Newsletter type [news|education]',
    'frq'       => 'Frequency [daily|ẁeekly|monthly]'
) );

$cli = new QuestionInteractiveCli();

$clusterIdentifier  = isset ( $options['cluster'] ) ? $options['cluster'] : false;
$nlType             = isset( $options['nlt'] ) ? $options['nlt'] : null;
$nlFrequency        = isset( $options['frq'] ) ? $options['frq'] : null;

$clusterDomains = eZINI::instance( 'merck.ini' )->variable( 'DomainMappingSettings', 'ClusterDomains' );
if ( !$clusterIdentifier )
{
    $clusters = array_keys( $clusterDomains );
    sort( $clusters );
    $clusterAnswer = $cli->askQuestion( "On which cluster?", $clusters );
    $clusterIdentifier = $clusters[$clusterAnswer];

}
$domain = $clusterDomains[$clusterIdentifier];
$script->startup();
$options = $script->getOptions( "[publisherFolders:]", "", array(
        'publisherFolders' => "Comma separated list of publisher folder path",
    ) );
$script->initialize();

$query = "select f.id, f.path as path
        from mm_application_has_publisher_folder as h
        left join mm_publisher_folder as f on h.publisher_folder_id = f.id
        order by f.id";

$db                  = MMDB::instance();
$allResults          = $db->arrayQuery( $query );
$folders             = array();
$interactiveQuestion = new QuestionInteractiveCli();
$cli                 = eZCLI::instance();

foreach ( $allResults as $row )
{
    $exists = (  is_array(eZContentObject::fetchByRemoteID( 'publisher_folder-' . $row['path'], false )) );

    if ( $exists )
        $folders[$row['id']] = $row['path'];
}
if ( isset($options['publisherFolders']) )
{
    $folderList = explode(',', $options['publisherFolders'] );
    $replies = array();

    foreach ($folderList as $folder)
<?php

/**
 * Documentation can be found at http://confluence.kaliop.net/display/MSD/How+to+generate+sprites+for+cluster+using+script
 */
require 'autoload.php';

$cli = new QuestionInteractiveCli();

$script = eZScript::instance( array(
    'description' => 'Generate ico_sprite for given cluster. Documentation can be found at http://confluence.kaliop.net/display/MSD/How+to+generate+sprites+for+cluster+using+script',
    'use-modules' => true,
    'use-extensions' => true,
    'debug-output' => true
) );

$options = $script->getOptions( "[clusterIdentifier:][interactive:][sanitize:][backup:][timestamp:][env:]", "", array(
    'clusterIdentifier' => 'List of cluster identifiers to generate the sprite for (if empty will use all available clusters)',
    'interactive' => 'Decides whether script should provide list of clusters to select the ones to generate the sprite for (default: false)',
    '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'];
<?php

if ( !isset($cli) )
    die('This is a eZexec script, please use php bin/php/ezexec.php -s site_admin ' . preg_replace('#^.*/extension/#', 'extension/', __FILE__) . "\n" );

$cli = new QuestionInteractiveCli();
$r = $cli->askQuestion( "This script deletes some class attributes. It must be run AFTER the content has been aligned.\nAre you REALLY sure to proceed? [y/N]", array('#y|n#i'), 'validateReplyRegex', true );
if( strtolower($r) != 'y' )
    $script->shutdown(0, "Bye bye");

$class = eZContentClass::fetchByIdentifier( 'article' );
$classAttributes = $class->fetchAttributes();

$attributesToDelete = array();
foreach( $classAttributes as $classAttribute )
{
    if( $classAttribute->attribute( 'data_type_string') == 'eztags' )
        $attributesToDelete[] = $classAttribute;
}

foreach( $attributesToDelete as $attribute )
{
    $cli->cli->output( $attribute->attribute('identifier').'-'.$attribute->attribute('name') );
}
$r = $cli->askQuestion( "proceed? [y/N]", array('#y|n#i'), 'validateReplyRegex', true );
if( strtolower($r) != 'y')
    $script->shutdown(0, "Bye bye");

$class->removeAttributes( $attributesToDelete );
$cli->cli->output( "Done. You can now run extension/ezscriptmonitor/bin/php/syncobjectattributes.php -s site_admin --classid=".$class->attribute('id'));
<?php

const SOURCE_PUBLISHER                    = 'publisher';
const SOURCE_CLUSTER                      = 'cluster';
const ATTRIBUTE_TARGET_CONTENT_SERVICE    = 'target_cs';
const CLASS_IDENTIFIER_APPLICATION_FOLDER = 'application_folder';
const CLASS_IDENTIFIER_PUBLISHER_FOLDER   = 'publisher_folder';
const IS_ALIGNING_CLI                     = true;
require 'autoload.php';

// Use admin
$user   = eZUser::fetchByName( "admin" );
$userID = $user->attribute( 'contentobject_id' );
eZUser::setCurrentlyLoggedInUser( $user, $userID );

$cli    = new QuestionInteractiveCli();
$script = eZScript::instance( array(
    'description'    => ( "Align article location according to their publishers folders" ),
    'use-modules'    => true,
    'use-extensions' => true,
    'debug-output'   => false,
) );

$script->startup();

$options = $script->getOptions( "[publisher:][clusterIdentifier:][interactive][offset:]", "", array(
    'publisher'         => 'Publisher folder objectID / identifier',
    'clusterIdentifier' => 'Cluster identifier',
    'interactive'       => 'Should script be interactive',
    'offset'            => 'Offset, one publisher only',
) );
$script = eZScript::instance( array(
    'description' => ( 'Publisher folder synchronization' ),
    'use-modules' => true,
    'use-extensions' => true,
    'debug-output' => false,
) );

$script->startup();
$options = $script->getOptions( '[clusterIdentifier:][auto]', "", array(
    'clusterIdentifier' => "(optional) Cluster Identifier to filter Interactive List",
    'auto' => "(optional) Cluster Identifier to filter Interactive List",
    )
);
$script->initialize();

$cli             = new QuestionInteractiveCli();
MMSynchLog::$cli = eZCli::instance();

SQLIContentPublisher::getInstance()->setOptions(new SQLIContentPublishOptions(array(
    'modification_check' => false,
    'update_null_field' => true
) ) );

// Use admin
$user   = eZUser::fetchByName( 'admin' );
$userID = $user->attribute( 'contentobject_id' );
eZUser::setCurrentlyLoggedInUser( $user, $userID );

$whereClause = "";

$query = "select f.id, f.path as path
function completeUncertainDatas( &$datas )
{
    $cli             = eZCLI::instance();
    $questionHandler = new QuestionInteractiveCli();
    $collisionable   = array ( 'ux_type', 'facet_type', 'hide_empty_values', 'can_be_hidden' );

    foreach ($datas as $key => $facet)
    {
        $f         = $facet['facet'];
        $beggining = "Select the default translation for following facet (Leave empty to specify a custom name):\n";
        $question  = "  > Attribute identifier : {$f['attribute_identifier']}\n";
        $question .= "  > UX type : {$f['ux_type']}\n";
        $question .= "  > Facet type : {$f['facet_type']}\n";
        $question .= "  > Hide empty values : {$f['hide_empty_values']}\n";
        $question .= "  > Can be hidden : {$f['can_be_hidden']}";

        if ($facet['collision'])
        {
            $question.= "\n/!\ There is a collision with another facet using the same attribute identifier:";

            $fb = array();

            if ( isset($datas[$key-1]))
            {
                if ( $datas[$key-1]['facet']['attribute_identifier'] == $f['attribute_identifier'] )
                {
                    $fb[] = $datas[$key-1]['facet'];
                }
            }

            if ( isset($datas[$key+1]))
            {
                if ( $datas[$key+1]['facet']['attribute_identifier'] == $f['attribute_identifier'] )
                {
                    $fb[] = $datas[$key+1]['facet'];
                }
            }

            foreach ( $fb as $fbb )
            {
                foreach ( $collisionable as $col )
                {
                    if ( $f[$col] != $fbb[$col] )
                    {
                        $question .= "\n  > Difference on $col";
                    }
                }
            }

            $question .= "\n>>> Ensure the default translation will be unique";
        }

        $facet['tr'][] = "Other ...";

        $reply = $questionHandler->askQuestion($beggining.$question, $facet['tr'], 'validateReply' );

        if ( $reply == count($facet['tr']) - 1 )
        {
            $beggining = "Enter the default translation for following facet:\n";
            $response  = $questionHandler->askQuestion ($beggining.$question, array(), "validateOpenReply" );
        }
        else
        {
            $response = $facet['tr'][$reply];
        }

        $datas[$key]['reply'] = $response;

        if ($facet['collision'])
        {
            $identifier = $questionHandler->askQuestion ('Enter an identifier for this facet (as it is in collision)', array(), "validateOpenReply" );
        }
        else
        {
            $identifier = $f['attribute_identifier'];
            $cli->notice("No collision, the new identifier will be the attribute identifier : $identifier");
        }

        $datas[$key]['identifier'] = $identifier;

        unset($datas[$key]['tr']);
    }
}
        continue;
    }

    $newId = $mappingKeyWithNewID[$key];
    $sql = sprintf('UPDATE content_has_taxonomy SET new_taxonomy_id = %s WHERE taxonomy_id = %s;', $newId, $id);
    if ( $apply )
    {
        XMLImportDB::query($sql);
    }
}



if ( $apply && $tmpColumnExist )
{
    $qCli = new QuestionInteractiveCli();
    $switchTable = $qCli->askQuestion('Switch actual column by the temporary column', array(
        'Y' => 'New values replace the old and old value are maintained in a new column',
        'N' => 'Do nothing : old values are maintained and the new value remain in the temporary column'
    ));

    if ( $switchTable == 'Y' )
    {
        $cli->notice('Swith columns...');
        $sql = '
            ALTER TABLE content_has_taxonomy
            DROP PRIMARY KEY,
            DROP FOREIGN KEY fk_article_has_taxonomy_taxonomy1,
            CHANGE taxonomy_id old_taxonomy_id INT(11) NOT NULL,
            CHANGE new_taxonomy_id taxonomy_id INT(11) NOT NULL,
            ADD PRIMARY KEY(content_id, taxonomy_id);';
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;
}