当前位置: 首页>>代码示例>>PHP>>正文


PHP eZCLI::output方法代码示例

本文整理汇总了PHP中eZCLI::output方法的典型用法代码示例。如果您正苦于以下问题:PHP eZCLI::output方法的具体用法?PHP eZCLI::output怎么用?PHP eZCLI::output使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZCLI的用法示例。


在下文中一共展示了eZCLI::output方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: writeMessage

 /**
  * Displays a message on the appropriate output (cli or eZDebug)
  *
  * @param string $msg
  * @param string $logType
  */
 public static function writeMessage($msg, $logType = self::NOTICELOG)
 {
     self::$cli = eZCLI::instance();
     $isWebOutput = self::$cli->isWebOutput();
     switch ($logType) {
         case self::ERRORLOG:
             if (!$isWebOutput) {
                 self::$cli->output(self::$cli->stylize('error', $msg));
             } else {
                 eZDebug::writeError($msg, 'SQLIImport');
             }
             break;
         case self::WARNINGLOG:
             if (!$isWebOutput) {
                 self::$cli->output(self::$cli->stylize('warning', $msg));
             } else {
                 eZDebug::writeWarning($msg, 'SQLIImport');
             }
             break;
         case self::NOTICELOG:
         default:
             if (!$isWebOutput) {
                 self::$cli->output(self::$cli->stylize('notice', $msg));
             } else {
                 eZDebug::writeNotice($msg, 'SQLIImport');
             }
             break;
     }
 }
开发者ID:lolautruche,项目名称:sqliimport,代码行数:35,代码来源:sqliimportlogger.php

示例2: reportProgress

 public function reportProgress($filename, $count)
 {
     static $progress = array('|', '/', '-', '\\');
     if ($count == 0) {
         $this->cli->output($this->cli->storePosition() . " " . $this->cli->restorePosition(), false);
     } else {
         $text = array_shift($progress);
         $this->cli->output($this->cli->storePosition() . $text . $this->cli->restorePosition(), false);
         $progress[] = $text;
     }
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:11,代码来源:ezcachehelper.php

示例3: showReplies

    /**
     * @param array $possibleReplies
     * @param array $alreadyChosen
     */
    function showReplies ( $possibleReplies, $alreadyChosen = array() )
    {
        if ( count($possibleReplies) > 0 )
        {
            $this->cli->output( "Expected Reply between [ ]" );

            foreach ( $possibleReplies as $label => $description )
            {
                if ( in_array($label, $alreadyChosen) )
                {
                    $this->cli->warning( " * [$label] : $description" );
                }
                else
                {
                    $this->cli->output( "   [$label] : $description" );
                }
            }
        }
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:23,代码来源:questionInteractiveCli.php

示例4: run

 /**
  * Executes the purge operation
  *
  * @param int|null $iterationLimit Number of trashed objects to treat per iteration, use null to use a default value.
  * @param int|null $sleep Number of seconds to sleep between two iterations, use null to use a default value.
  *
  * @return bool True if the operation succeeded.
  */
 public function run($iterationLimit = 100, $sleep = 1)
 {
     if ($iterationLimit === null) {
         $iterationLimit = 100;
     }
     if ($sleep === null) {
         $sleep = 1;
     }
     if ($this->memoryMonitoring) {
         eZLog::rotateLog($this->logFile);
         $this->cli->output("Logging memory usage to {$this->logFile}");
     }
     $this->cli->output("Purging trash items:");
     $this->monitor("start");
     $db = eZDB::instance();
     // Get user's ID who can remove subtrees. (Admin by default with userID = 14)
     $userCreatorID = eZINI::instance()->variable("UserSettings", "UserCreatorID");
     $user = eZUser::fetch($userCreatorID);
     if (!$user) {
         $this->cli->error("Cannot get user object with userID = '{$userCreatorID}'.\n(See site.ini[UserSettings].UserCreatorID)");
         return false;
     }
     eZUser::setCurrentlyLoggedInUser($user, $userCreatorID);
     $trashCount = eZContentObjectTrashNode::trashListCount(false);
     if (!$this->quiet) {
         $this->cli->output("Found {$trashCount} object(s) in trash.");
     }
     if ($trashCount == 0) {
         return true;
     }
     if ($this->script !== null) {
         $this->script->resetIteration($trashCount);
     }
     while ($trashCount > 0) {
         $this->monitor("iteration start");
         $trashList = eZContentObjectTrashNode::trashList(array('Limit' => $iterationLimit), false);
         $db->begin();
         foreach ($trashList as $trashNode) {
             $object = $trashNode->attribute('object');
             $this->monitor("purge");
             $object->purge();
             if ($this->script !== null) {
                 $this->script->iterate($this->cli, true);
             }
         }
         if (!$db->commit()) {
             $this->cli->output();
             $this->cli->error('Trash has not been emptied, impossible to commit the whole transaction');
             return false;
         }
         $trashCount = eZContentObjectTrashNode::trashListCount(false);
         if ($trashCount > 0) {
             eZContentObject::clearCache();
             if ($sleep > 0) {
                 sleep($sleep);
             }
         }
         $this->monitor("iteration end");
     }
     if (!$this->quiet) {
         $this->cli->output('Trash successfully emptied');
     }
     $this->monitor("end");
     return true;
 }
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:73,代码来源:ezscripttrashpurge.php

示例5: generateCache

    /**
     * Generates the static cache from the configured INI settings.
     *
     * @param bool $force If true then it will create all static caches even if it is not outdated.
     * @param bool $quiet If true then the function will not output anything.
     * @param eZCLI|false $cli The eZCLI object or false if no output can be done.
     * @param bool $delay
     */
    public function generateCache( $force = false, $quiet = false, $cli = false, $delay = true )
    {
        $staticURLArray = $this->cachedURLArray();
        $db = eZDB::instance();
        $configSettingCount = count( $staticURLArray );
        $currentSetting = 0;

        // This contains parent elements which must checked to find new urls and put them in $generateList
        // Each entry contains:
        // - url - Url of parent
        // - glob - A glob string to filter direct children based on name
        // - org_url - The original url which was requested
        // - parent_id - The element ID of the parent (optional)
        // The parent_id will be used to quickly fetch the children, if not it will use the url
        $parentList = array();
        // A list of urls which must generated, each entry is a string with the url
        $generateList = array();
        foreach ( $staticURLArray as $url )
        {
            $currentSetting++;
            if ( strpos( $url, '*') === false )
            {
                $generateList[] = $url;
            }
            else
            {
                $queryURL = ltrim( str_replace( '*', '', $url ), '/' );
                $dir = dirname( $queryURL );
                if ( $dir == '.' )
                    $dir = '';
                $glob = basename( $queryURL );
                $parentList[] = array( 'url' => $dir,
                                       'glob' => $glob,
                                       'org_url' => $url );
            }
        }

        // As long as we have urls to generate or parents to check we loop
        while ( count( $generateList ) > 0 || count( $parentList ) > 0 )
        {
            // First generate single urls
            foreach ( $generateList as $generateURL )
            {
                if ( !$quiet and $cli )
                    $cli->output( "caching: $generateURL ", false );
                $this->cacheURL( $generateURL, false, !$force, $delay );
                if ( !$quiet and $cli )
                    $cli->output( "done" );
            }
            $generateList = array();

            // Then check for more data
            $newParentList = array();
            foreach ( $parentList as $parentURL )
            {
                if ( isset( $parentURL['parent_id'] ) )
                {
                    $elements = eZURLAliasML::fetchByParentID( $parentURL['parent_id'], true, true, false );
                    foreach ( $elements as $element )
                    {
                        $path = '/' . $element->getPath();
                        $generateList[] = $path;
                        $newParentList[] = array( 'parent_id' => $element->attribute( 'id' ) );
                    }
                }
                else
                {
                    if ( !$quiet and $cli and $parentURL['glob'] )
                        $cli->output( "wildcard cache: " . $parentURL['url'] . '/' . $parentURL['glob'] . "*" );
                    $elements = eZURLAliasML::fetchByPath( $parentURL['url'], $parentURL['glob'] );
                    foreach ( $elements as $element )
                    {
                        $path = '/' . $element->getPath();
                        $generateList[] = $path;
                        $newParentList[] = array( 'parent_id' => $element->attribute( 'id' ) );
                    }
                }
            }
            $parentList = $newParentList;
        }
    }
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:89,代码来源:ezstaticcache.php

示例6: hideFromApplicationLocalized

/**
 * Sets application localized url to NULL and sets its visibility as private
 * @param int $appId Id of application to be hidden
 * @param string $clusterIdentifier Identifier of cluster
 * @param eZDBInterface $db db to be used
 * @param eZCLI $cli command line to be used
 * @param boolean $dryRun Decides whether queries should be outputed to CLI or be used to update the DB
 */
function hideFromApplicationLocalized( $appId, $clusterIdentifier, eZDBInterface $db, eZCLI $cli, $dryRun = false )
{
    global $appId, $clusterIdentifier, $db, $eZDB, $cli, $dryRun;
    
    $update = sprintf( "UPDATE mm_application_localized
                            SET url = NULL, restriction_level = 'private'
                            WHERE application_id='%s' AND cluster_identifier='%s'", 
                        $db->escapeString($appId),
                        $db->escapeString($clusterIdentifier) );
    if ( !$dryRun )
    {
        $db->query( $update );
    }
    else
    {
        $cli->output( $update );
    }
}
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:26,代码来源:remove_application.php

示例7: fetchTopNode

/**
 * Fetches and returns a eZContentObjectTreeNode
 *
 * If the node id does not exists an error message is outputted and the script
 * is halted.
 *
 * @param int $topNodeId
 * @param eZCLI $cli
 * @param eZScript $script
 * @return eZContentObjectTreeNode
 **/
function fetchTopNode( $topNodeId, $cli, $script )
{
    $topNode = eZContentObjectTreeNode::fetch( $topNodeId );
    if ( !$topNode )
    {
        $cli->error( "The specified top-node-id ({$topNodeId}) was not valid\n" );
        $script->shutdown( 1 );
    }
    else
    {
        $cli->output( "Will export from node `{$topNode->Name}` ({$topNodeId})\n" );
    }

    return $topNode;
}
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:26,代码来源:import_static_pages_from_ez.php

示例8: computeOffsetByFork

/**
 * @param eZCLI $cli
 * @param eZDBInterface $db
 * @param string $cronPart
 * @param int $maxRetries
 * @return int offset to use or -1 if an error occures
 */
function computeOffsetByFork ( $cli, $db, $cronPart, $maxRetries )
{
    // Normal case
    if (!preg_match('#^[a-zA-Z_]+(\d)#', $cronPart, $match))
    {
        return 0;
    }

    $ezfindIni   = eZINI::instance('ezfind.ini');
    $maxForks    = $ezfindIni->variable('IndexOptions', 'MaxPendingForkCount');
    $matchOffset = $match[1] - 1;

    if ( $matchOffset > $maxForks )
    {
        $cli->output( "Ini setting states you can't run more than $maxForks forks, you try to run fork #" . ($matchOffset + 1) );
        return -1;
    }


    $countQuery  = "SELECT count(id) as nb_pending FROM ezpending_actions WHERE action = 'index_object' AND ( param_int IS NULL OR param_int <= $maxRetries )";

    $result = $db->arrayQuery($countQuery);
    if ( !$result || !isset($result[0]['nb_pending']))
    {
        $cli->error("Mysql unexpected error. Script will be stopped.");
        return -1;
    }

    $forkInterval = $ezfindIni->variable('IndexOptions', 'MinPendingForkInterval');
    $pendingCount = $result[0]['nb_pending'];
    $forkMinCount = $matchOffset * $forkInterval;

    if ($pendingCount < $forkMinCount)
    {
        $cli->warning( "Trying to run pending fork #$matchOffset but we have less than $forkMinCount pending objects. Script will be stopped.");

        return -1;
    }

    $offset = max($forkMinCount, round($pendingCount/$maxForks) * $matchOffset);

    $cli->output( "Fork #" . ($matchOffset + 1) . " starting at offset #$offset");

    return $offset;
}
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:52,代码来源:ezfindexcontent.php

示例9: printFields

function printFields($id, array $fields, eZCLI $cli)
{
    $cli->notice("Fields for object with id {$id}");
    foreach ($fields as $field)
    {
        $cli->output($field);
    }
    $cli->output();
}
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:9,代码来源:export_content_object_datamap_fields.php


注:本文中的eZCLI::output方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。