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


PHP Console::writeMultiline方法代码示例

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


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

示例1: parseData

 /**
  * Parses argument data
  *
  * @param array $data
  */
 private function parseData($data = array())
 {
     // show help if requested and exit!
     if (isset($data['help'])) {
         require_once MANGA_ROOT_DIR . 'includes/templates/help/index.php';
         exit;
     }
     $data = is_array($data) ? $data : array();
     // image delay
     $this->setImageDelay(Input::array_value($data, 'image-delay', '', 'trim'));
     // chapter delay
     $this->setChapterDelay(Input::array_value($data, 'chapter-delay', '', 'trim'));
     // url
     if (isset($data['url'])) {
         $url = trim($data['url']);
         if ($url == '') {
             consoleLineError("Url parameter cannot be empty!");
             exit;
         }
         $parsedData = UrlParser::parseUrl($url);
         if (!$parsedData) {
             consoleLineError("Provided url is not is not valid!");
             exit;
         } else {
             $data['source'] = $parsedData['source'];
             $data['slug'] = $parsedData['slug'];
             $chapter = trim($parsedData['chapter']);
             if ($chapter != '') {
                 $data['chapter-ids'] = $chapter;
                 $data['action'] = self::ACTION_SPECIFIC_CHAPTERS;
             }
         }
     }
     // check for valid params
     $dataKeys = array_keys($data);
     $diff = array_diff($dataKeys, $this->_allowed_param_names);
     if (count($diff) > 0) {
         consoleLineError("Invalid params: " . join(',', $diff), 2);
         exit;
     }
     $this->_argumentsList = $data;
     // action
     $action = Input::array_value($data, 'action', '', 'trim');
     if ($action == '') {
         $action = self::ACTION_NEW_CHAPTERS;
     }
     if (!$this->isValidAction($action)) {
         $this->displayInvalidActionMessage(TRUE);
     } else {
         $this->_action = $action;
         if ($this->_action == self::ACTION_SPECIFIC_CHAPTERS) {
             $chapterIds = Input::array_value($data, 'chapter-ids', '', 'trim');
             if ($chapterIds == '') {
                 consoleLineError('One or more chapter ids are required when action is "' . self::ACTION_SPECIFIC_CHAPTERS . '"');
                 Console::emptyLines();
                 exit;
             }
         }
     }
     // source
     $source = Input::array_value($data, 'source', MangaSourceList::SOUCE_MANGAPANDA, 'trim');
     if (MangaSourceList::getInstance()->isValidSource($source)) {
         $this->_source = $source;
     } else {
         MangaSourceList::getInstance()->displayInvalidMangaSourceMessage(TRUE);
     }
     // slug
     $slug = Input::array_value($data, 'slug', '', 'trim');
     if ($slug == '') {
         consoleLineError('Manga slug is required!', 2);
         consoleLinePurple('Example: --slug=nisekoi', 2);
         Console::writeMultiline('Slug usualy means the SEO friendly name of the manga. But it can be different for different manga sources.The slug is part of the manga chapters list url.');
         consoleLineInfo('');
         exit;
     }
     $this->_mangaSlug = $slug;
     // name
     $name = Input::array_value($data, 'name', '', 'trim');
     if ($name == '') {
         $name = $this->_mangaSlug;
     }
     $this->_mangaName = $name;
     // Output dir
     $output_dir = Input::array_value($data, 'output-dir', '', 'trim');
     if ($output_dir == '') {
         $output_dir = './manga/' . $this->_source . '/' . $this->_mangaSlug . '/';
     }
     if (!is_dir($output_dir)) {
         if (!mkdir($output_dir, 0777, TRUE)) {
             consoleLineError("Unable to create output dir: " . $output_dir, 2);
             consoleLineInfo('');
             exit;
         }
     } else {
         $tmpFile = tempnam($output_dir, 'mst-');
//.........这里部分代码省略.........
开发者ID:anjan011,项目名称:manga-scrapper,代码行数:101,代码来源:class.ArgumentsList.php

示例2: foreach

$temp = [];
foreach (MangaSourceList::getInstance()->getAllowedSourceList() as $src_key => $src_data) {
    $temp[] = Console::text($src_key, 0, ConsoleColors::COLOR_CYAN, true);
}
$blockText .= join(', ', $temp);
Console::writeMultiline($blockText, MANGA_SCRAPPER_TAB_STR . $emptyPaddedStr, '', true);
# ====================================================================
# By: anjan @ Nov 06, 2015 12:15 PM
# ====================================================================
# --url
# ====================================================================
Console::text(__pad_space_right("--url", $paramPadLength), 1);
$blockText = 'Accepts an url to manga chapters list or a specific chapter. If a valid manga chapter list url is specified, then the source, and slug param is ignored. Also, if the url is for a chapter, in addition to source and slug, action and chapter-ids params are ignored as well.';
Console::writeMultiline($blockText, MANGA_SCRAPPER_TAB_STR . $emptyPaddedStr, '', true);
/*********************************************************************
 * By: Anjan @ Nov 06, 2015 5:13 PM
 *********************************************************************
 * Available actions
 *********************************************************************/
Console::emptyLines(1);
consoleLinePurple('List of supported actions -', 2);
$actionKeyLengths = array();
foreach (ArgumentsList::getActionList() as $key => $data) {
    $actionKeyLengths[] = strlen($key);
}
$maxkeyLen = max($actionKeyLengths) + 2 * strlen(MANGA_SCRAPPER_TAB_STR);
foreach (ArgumentsList::getActionList() as $key => $data) {
    Console::text(__pad_space_right(MANGA_SCRAPPER_TAB_STR . $key . MANGA_SCRAPPER_TAB_STR, $maxkeyLen), 0, ConsoleColors::COLOR_CYAN);
    Console::writeMultiline($data['desc'] . ($data['default'] ? Console::text(' [default]', 0, ConsoleColors::COLOR_RED, true) : ''), __pad_space_right('', $maxkeyLen), '', true);
}
Console::emptyLines(1);
开发者ID:anjan011,项目名称:manga-scrapper,代码行数:31,代码来源:index.php


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