• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP FormatJson类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getFormatOutput

 /**
  * @see SMWResultPrinter::getFormatOutput
  *
  * @since 1.8
  *
  * @param array $data label => value
  * @return string
  */
 protected function getFormatOutput(array $data)
 {
     // Object count
     static $statNr = 0;
     $d3chartID = 'd3-chart-' . ++$statNr;
     $this->isHTML = true;
     // Reorganize the raw data
     foreach ($data as $name => $value) {
         if ($value >= $this->params['min']) {
             $dataObject[] = array('label' => $name, 'value' => $value);
         }
     }
     // Ensure right conversion
     $width = strstr($this->params['width'], "%") ? $this->params['width'] : $this->params['width'] . 'px';
     // Prepare transfer objects
     $d3data = array('data' => $dataObject, 'parameters' => array('colorscheme' => $this->params['colorscheme'] ? $this->params['colorscheme'] : null, 'charttitle' => $this->params['charttitle'], 'charttext' => $this->params['charttext'], 'datalabels' => $this->params['datalabels']));
     // Encoding
     $requireHeadItem = array($d3chartID => FormatJson::encode($d3data));
     SMWOutputs::requireHeadItem($d3chartID, Skin::makeVariablesScript($requireHeadItem));
     // RL module
     $resource = 'ext.srf.d3.chart.' . $this->params['charttype'];
     SMWOutputs::requireResource($resource);
     // Chart/graph placeholder
     $chart = Html::rawElement('div', array('id' => $d3chartID, 'class' => 'container', 'style' => 'display:none;'), null);
     // Processing placeholder
     $processing = SRFUtils::htmlProcessingElement($this->isHTML);
     // Beautify class selector
     $class = $this->params['charttype'] ? '-' . $this->params['charttype'] : '';
     $class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class . ' d3-chart-common';
     // D3 wrappper
     return Html::rawElement('div', array('class' => 'srf-d3-chart' . $class, 'style' => "width:{$width}; height:{$this->params['height']}px;"), $processing . $chart);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:40,代码来源:SRF_D3Chart.php


示例2: getFormatOutput

 /**
  * Prepare data output
  *
  * @since 1.8
  *
  * @param array $data label => value
  */
 protected function getFormatOutput(array $data)
 {
     //Init
     $dataObject = array();
     static $statNr = 0;
     $chartID = 'sparkline-' . $this->params['charttype'] . '-' . ++$statNr;
     $this->isHTML = true;
     // Prepare data array
     foreach ($data as $key => $value) {
         if ($value >= $this->params['min']) {
             $dataObject['label'][] = $key;
             $dataObject['value'][] = $value;
         }
     }
     $dataObject['charttype'] = $this->params['charttype'];
     // Encode data objects
     $requireHeadItem = array($chartID => FormatJson::encode($dataObject));
     SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
     // RL module
     SMWOutputs::requireResource('ext.srf.sparkline');
     // Processing placeholder
     $processing = SRFUtils::htmlProcessingElement(false);
     // Chart/graph placeholder
     $chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none;"), null);
     // Beautify class selector
     $class = $this->params['class'] ? ' ' . $this->params['class'] : '';
     // Chart/graph wrappper
     return Html::rawElement('span', array('class' => 'srf-sparkline' . $class), $processing . $chart);
 }
开发者ID:yusufchang,项目名称:app,代码行数:36,代码来源:SRF_Sparkline.php


示例3: execute

 public function execute()
 {
     $variantLangs = array();
     $variants = array();
     foreach (LanguageConverter::$languagesWithVariants as $langCode) {
         $lang = Language::factory($langCode);
         if (count($lang->getVariants()) > 1) {
             $variants += array_flip($lang->getVariants());
             $variantLangs[$langCode] = $lang->getVariants();
         }
     }
     $variants = array_keys($variants);
     sort($variants);
     $result = $this->hasOption('flat') ? $variants : $variantLangs;
     // Not using $this->output() because muting makes no sense here
     if ($this->hasOption('json')) {
         echo FormatJson::encode($result, true) . "\n";
     } else {
         foreach ($result as $key => $value) {
             if (is_array($value)) {
                 echo "{$key}\n";
                 foreach ($value as $variant) {
                     echo "   {$variant}\n";
                 }
             } else {
                 echo "{$value}\n";
             }
         }
     }
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:30,代码来源:listVariants.php


示例4: fetchScriptList

 protected function fetchScriptList()
 {
     $data = ['action' => 'query', 'format' => 'json', 'list' => 'allpages', 'apnamespace' => '8', 'aplimit' => '500', 'continue' => ''];
     $baseUrl = $this->getArg(0);
     $pages = [];
     while (true) {
         $url = wfAppendQuery($baseUrl, $data);
         $strResult = Http::get($url, [], __METHOD__);
         $result = FormatJson::decode($strResult, true);
         $page = null;
         foreach ($result['query']['allpages'] as $page) {
             if (substr($page['title'], -3) === '.js') {
                 strtok($page['title'], ':');
                 $pages[] = strtok('');
             }
         }
         if ($page !== null) {
             $this->output("Fetched list up to {$page['title']}\n");
         }
         if (isset($result['continue'])) {
             // >= 1.21
             $data = array_replace($data, $result['continue']);
         } elseif (isset($result['query-continue']['allpages'])) {
             // <= 1.20
             $data = array_replace($data, $result['query-continue']['allpages']);
         } else {
             break;
         }
     }
     return $pages;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:31,代码来源:importSiteScripts.php


示例5: execute

 /**
  * @return string
  */
 public function execute()
 {
     $r = $this->parent->request;
     if ($r->wasPosted()) {
         if ($this->submit()) {
             return 'continue';
         }
     }
     $this->startForm();
     // Encourage people to not name their site 'MediaWiki' by blanking the
     // field. I think that was the intent with the original $GLOBALS['wgSitename']
     // but these two always were the same so had the effect of making the
     // installer forget $wgSitename when navigating back to this page.
     if ($this->getVar('wgSitename') == 'MediaWiki') {
         $this->setVar('wgSitename', '');
     }
     // Set wgMetaNamespace to something valid before we show the form.
     // $wgMetaNamespace defaults to $wgSiteName which is 'MediaWiki'
     $metaNS = $this->getVar('wgMetaNamespace');
     $this->setVar('wgMetaNamespace', wfMessage('config-ns-other-default')->inContentLanguage()->text());
     $pingbackInfo = (new Pingback())->getSystemInfo();
     // Database isn't available in config yet, so take it
     // from the installer
     $pingbackInfo['database'] = $this->getVar('wgDBtype');
     $this->addHTML($this->parent->getTextBox(['var' => 'wgSitename', 'label' => 'config-site-name', 'help' => $this->parent->getHelpBox('config-site-name-help')]) . $this->parent->getRadioSet(['var' => '_NamespaceType', 'label' => 'config-project-namespace', 'itemLabelPrefix' => 'config-ns-', 'values' => ['site-name', 'generic', 'other'], 'commonAttribs' => ['class' => 'enableForOther', 'rel' => 'config_wgMetaNamespace'], 'help' => $this->parent->getHelpBox('config-project-namespace-help')]) . $this->parent->getTextBox(['var' => 'wgMetaNamespace', 'label' => '', 'attribs' => ['readonly' => 'readonly', 'class' => 'enabledByOther']]) . $this->getFieldsetStart('config-admin-box') . $this->parent->getTextBox(['var' => '_AdminName', 'label' => 'config-admin-name', 'help' => $this->parent->getHelpBox('config-admin-help')]) . $this->parent->getPasswordBox(['var' => '_AdminPassword', 'label' => 'config-admin-password']) . $this->parent->getPasswordBox(['var' => '_AdminPasswordConfirm', 'label' => 'config-admin-password-confirm']) . $this->parent->getTextBox(['var' => '_AdminEmail', 'attribs' => ['dir' => 'ltr'], 'label' => 'config-admin-email', 'help' => $this->parent->getHelpBox('config-admin-email-help')]) . $this->parent->getCheckBox(['var' => '_Subscribe', 'label' => 'config-subscribe', 'help' => $this->parent->getHelpBox('config-subscribe-help')]) . $this->parent->getCheckBox(['var' => 'wgPingback', 'label' => 'config-pingback', 'help' => $this->parent->getHelpBox('config-pingback-help', FormatJson::encode($pingbackInfo, true)), 'value' => true]) . $this->getFieldsetEnd() . $this->parent->getInfoBox(wfMessage('config-almost-done')->text()) . $this->parent->getRadioSet(['var' => '_SkipOptional', 'itemLabelPrefix' => 'config-optional-', 'values' => ['continue', 'skip']]));
     // Restore the default value
     $this->setVar('wgMetaNamespace', $metaNS);
     $this->endForm();
     return 'output';
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:33,代码来源:WebInstallerName.php


示例6: getFormatOutput

 /**
  * Prepare data output
  *
  * @since 1.8
  *
  * @param array $data label => value
  */
 protected function getFormatOutput(array $data)
 {
     static $statNr = 0;
     $chartID = 'jqplot-' . $this->params['charttype'] . '-' . ++$statNr;
     $this->isHTML = true;
     // Prepare data objects
     if (in_array($this->params['charttype'], array('bar', 'line'))) {
         // Parse bar relevant data
         $dataObject = $this->prepareBarData($data);
     } elseif (in_array($this->params['charttype'], array('pie', 'donut'))) {
         //Parse pie/donut relevant data
         $dataObject = $this->preparePieData($data);
     } else {
         // Return with an error
         return Html::rawElement('span', array('class' => "error"), wfMessage('srf-error-missing-layout')->inContentLanguage()->text());
     }
     // Encode data objects
     $requireHeadItem = array($chartID => FormatJson::encode($dataObject));
     SMWOutputs::requireHeadItem($chartID, Skin::makeVariablesScript($requireHeadItem));
     // Processing placeholder
     $processing = SRFUtils::htmlProcessingElement($this->isHTML);
     // Ensure right conversion
     $width = strstr($this->params['width'], "%") ? $this->params['width'] : $this->params['width'] . 'px';
     // Chart/graph placeholder
     $chart = Html::rawElement('div', array('id' => $chartID, 'class' => 'container', 'style' => "display:none; width: {$width}; height: {$this->params['height']}px;"), null);
     // Beautify class selector
     $class = $this->params['charttype'] ? '-' . $this->params['charttype'] : '';
     $class = $this->params['class'] ? $class . ' ' . $this->params['class'] : $class . ' jqplot-common';
     // Chart/graph wrappper
     return Html::rawElement('div', array('class' => 'srf-jqplot' . $class), $processing . $chart);
 }
开发者ID:cicalese,项目名称:SemanticResultFormats,代码行数:38,代码来源:SRF_jqPlotChart.php


示例7: execute

 public function execute()
 {
     $params = $this->extractRequestParams();
     $this->requireOnlyOneParameter($params, 'vars', 'rcid', 'logid');
     // "Anti-DoS"
     if (!$this->getUser()->isAllowed('abusefilter-modify')) {
         $this->dieUsageMsg('permissiondenied');
     }
     if ($params['vars']) {
         $vars = FormatJson::decode($params['vars'], true);
     } elseif ($params['rcid']) {
         $dbr = wfGetDB(DB_SLAVE);
         $row = $dbr->selectRow('recentchanges', '*', array('rc_id' => $params['rcid']), __METHOD__);
         if (!$row) {
             $this->dieUsageMsg(array('nosuchrcid', $params['rcid']));
         }
         $vars = AbuseFilter::getVarsFromRCRow($row);
     } elseif ($params['logid']) {
         $dbr = wfGetDB(DB_SLAVE);
         $row = $dbr->selectRow('abuse_filter_log', '*', array('afl_id' => $params['logid']), __METHOD__);
         if (!$row) {
             $this->dieUsage("There is no abuselog entry with the id ``{$params['logid']}''", 'nosuchlogid');
         }
         $vars = AbuseFilter::loadVarDump($row->afl_var_dump);
     }
     if (AbuseFilter::checkSyntax($params['filter']) !== true) {
         $this->dieUsage('The filter has invalid syntax', 'badsyntax');
     }
     $result = AbuseFilter::checkConditions($params['filter'], $vars);
     $this->getResult()->addValue(null, $this->getModuleName(), array('result' => $result));
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:31,代码来源:ApiAbuseFilterCheckMatch.php


示例8: execute

 public function execute()
 {
     global $wgUser;
     if (!$wgUser->isAllowed('surveysubmit') || $wgUser->isBlocked()) {
         $this->dieUsageMsg(array('badaccess-groups'));
     }
     $params = $this->extractRequestParams();
     if (!(isset($params['id']) xor isset($params['name']))) {
         $this->dieUsage(wfMsg('survey-err-id-xor-name'), 'id-xor-name');
     }
     if (isset($params['name'])) {
         $survey = Survey::newFromName($params['name'], null, false);
         if ($survey === false) {
             $this->dieUsage(wfMsgExt('survey-err-survey-name-unknown', 'parsemag', $params['name']), 'survey-name-unknown');
         }
     } else {
         $survey = Survey::newFromId($params['id'], null, false);
         if ($survey === false) {
             $this->dieUsage(wfMsgExt('survey-err-survey-id-unknown', 'parsemag', $params['id']), 'survey-id-unknown');
         }
     }
     $submission = new SurveySubmission(array('survey_id' => $survey->getId(), 'page_id' => 0, 'user_name' => $GLOBALS['wgUser']->getName(), 'time' => wfTimestampNow()));
     foreach (FormatJson::decode($params['answers']) as $answer) {
         $submission->addAnswer(SurveyAnswer::newFromArray((array) $answer));
     }
     $submission->writeToDB();
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:27,代码来源:ApiSubmitSurvey.php


示例9: execute

 public function execute()
 {
     if (wfReadOnly()) {
         $this->error("Unable to run jobs; the wiki is in read-only mode.", 1);
         // die
     }
     if ($this->hasOption('procs')) {
         $procs = intval($this->getOption('procs'));
         if ($procs < 1 || $procs > 1000) {
             $this->error("Invalid argument to --procs", true);
         } elseif ($procs != 1) {
             $fc = new ForkController($procs);
             if ($fc->start() != 'child') {
                 exit(0);
             }
         }
     }
     $json = $this->getOption('result') === 'json';
     $runner = new JobRunner();
     if (!$json) {
         $runner->setDebugHandler(array($this, 'debugInternal'));
     }
     $response = $runner->run(array('type' => $this->getOption('type', false), 'maxJobs' => $this->getOption('maxjobs', false), 'maxTime' => $this->getOption('maxtime', false), 'throttle' => $this->hasOption('nothrottle') ? false : true));
     if ($json) {
         $this->output(FormatJson::encode($response, true));
     }
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:27,代码来源:runJobs.php


示例10: execute

 public function execute()
 {
     $res = array();
     foreach (explode(' ', $this->getOption('settings')) as $name) {
         if (!preg_match('/^wg[A-Z]/', $name)) {
             throw new MWException("Variable '{$name}' does start with 'wg'.");
         } elseif (!isset($GLOBALS[$name])) {
             throw new MWException("Variable '{$name}' is not set.");
         } elseif (!$this->isAllowedVariable($GLOBALS[$name])) {
             throw new MWException("Variable '{$name}' includes non-array, non-scalar, items.");
         }
         $res[$name] = $GLOBALS[$name];
     }
     $out = null;
     switch ($this->getOption('format')) {
         case 'PHP':
             $out = serialize($res);
             break;
         case 'JSON':
             $out = FormatJson::encode($res);
             break;
         default:
             throw new MWException("Invalid serialization format given.");
     }
     if (!is_string($out)) {
         throw new MWException("Failed to serialize the requested settings.");
     }
     $this->output($out . "\n");
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:29,代码来源:getConfiguration.php


示例11: makeMemberList

 /**
  * @param $username string
  * @return CollaborationListContent
  */
 public static function makeMemberList($username, $initialDescription)
 {
     $linkToUserpage = Title::makeTitleSafe(NS_USER, $username)->getPrefixedText();
     $newMemberList = ["displaymode" => "members", "columns" => [["items" => [["title" => $linkToUserpage]]]], "options" => ["mode" => "normal"], "description" => "{$initialDescription}"];
     $newMemberListJson = FormatJson::encode($newMemberList, "\t", FormatJson::ALL_OK);
     return new CollaborationListContent($newMemberListJson);
 }
开发者ID:wikimedia,项目名称:mediawiki-extensions-CollaborationKit,代码行数:11,代码来源:CollaborationListContentHandler.php


示例12: getUntranslatedPages

 protected function getUntranslatedPages($apiUrl, $category, $targetDomain)
 {
     $this->output("Fetching pages from {$category} not present in {$targetDomain} ...");
     $pages = array();
     $params = array('action' => 'query', 'format' => 'json', 'generator' => 'categorymembers', 'gcmtitle' => "Category:{$category}", 'gcmnamespace' => 0, 'gcmlimit' => 500, 'gcmsort' => 'timestamp', 'prop' => 'langlinks', 'lllang' => $targetDomain, 'lllimit' => 500, 'continue' => '');
     while (true) {
         $url = $apiUrl . http_build_query($params);
         $json = Http::get($url);
         $data = FormatJson::decode($json, true);
         if (!isset($data['query'])) {
             $this->output("\t[FAIL]\n");
             return array();
         }
         $pagesInCategory = $data['query']['pages'];
         foreach ($pagesInCategory as $pageId => $page) {
             if (!isset($page['langlinks'])) {
                 $pages[] = $page['title'];
             }
         }
         if (!isset($data['continue']) || count($pages) > 5000) {
             break;
         } else {
             unset($params['llcontinue']);
             unset($params['gcmcontinue']);
             $params += $data['continue'];
         }
     }
     $this->output("\t[OK]\n");
     return $pages;
 }
开发者ID:Wikia,项目名称:mediawiki-extensions-ContentTranslation,代码行数:30,代码来源:manage-lists.php


示例13: execute

 public function execute()
 {
     global $wgUser;
     $result = $this->getResult();
     $params = $this->extractRequestParams();
     $token = array();
     if ($wgUser->isAnon()) {
         if (!isset($params['anontoken'])) {
             $this->dieUsageMsg(array('missingparam', 'anontoken'));
         } elseif (strlen($params['anontoken']) != 32) {
             $this->dieUsage('The anontoken is not 32 characters', 'invalidtoken');
         }
         $token = $params['anontoken'];
     } else {
         $token = '';
     }
     $dbr = wfGetDB(DB_SLAVE);
     $dbw = wfGetDB(DB_MASTER);
     // Check if the incoming survey is valid
     $surveyCount = $dbr->selectRow('research_tools_surveys', 'rts_id', array('rts_id' => $params['survey']), __METHOD__);
     if ($surveyCount === false) {
         $this->dieUsage('The survey is unknown', 'invalidsurvey');
     }
     // Find an existing response from this user for this survey
     $response = $dbr->selectRow('research_tools_survey_responses', 'rtsr_id', array('rtsr_user_text' => $wgUser->getName(), 'rtsr_user_anon_token' => $token, 'rtsr_survey' => $params['survey']), __METHOD__);
     if ($response !== false) {
         // Delete any of the previous answers (they questions may have changed)
         $dbw->delete('research_tools_survey_answers', array('rtsa_response' => $response->rtsr_id), __METHOD__);
     }
     // Decode JSON answer data
     $answers = FormatJson::decode($params['answers'], true);
     if (!is_array($answers)) {
         $this->dieUsage('Invalid answer data', 'invalidanswers');
     }
     // Verify questions exist
     foreach ($answers as $question => $answer) {
         $question = $dbr->selectRow('research_tools_survey_questions', 'rtsq_id', array('rtsq_survey' => $params['survey'], 'rtsq_id' => $question), __METHOD__);
         if ($question === false) {
             $this->dieUsage('A question is unknown', 'invalidquestion');
         }
     }
     if ($response === false) {
         // Insert a new response row
         $dbw->insert('research_tools_survey_responses', array('rtsr_time' => wfTimestamp(TS_MW), 'rtsr_user_text' => $wgUser->getName(), 'rtsr_user_anon_token' => $token, 'rtsr_survey' => $params['survey']), __METHOD__);
         $response = $dbw->insertId();
     } else {
         $response = $response->rtsr_id;
         // Update the timestamp of the existing response row
         $dbw->update('research_tools_survey_responses', array('rtsr_time' => wfTimestamp(TS_MW)), array('rtsr_id' => $response), __METHOD__);
     }
     // Insert answers for the response
     $answerRows = array();
     foreach ($answers as $question => $answer) {
         // Build row data
         $answerRows[] = array('rtsa_response' => $response, 'rtsa_question' => $question, 'rtsa_value_integer' => is_numeric($answer) ? intval($answer) : null, 'rtsa_value_text' => is_numeric($answer) ? '' : $answer);
     }
     $dbw->insert('research_tools_survey_answers', $answerRows, __METHOD__);
     // Add success to result
     $result->addValue(null, $this->getModuleName(), array('result' => 'Success'));
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:60,代码来源:ApiResearchToolsSurveyResponse.php


示例14: passCaptcha

 /**
  * Check, if the user solved the captcha.
  *
  * Based on reference implementation:
  * https://github.com/google/recaptcha#php
  *
  * @return boolean
  */
 function passCaptcha()
 {
     global $wgRequest, $wgReCaptchaSecretKey, $wgReCaptchaSendRemoteIP;
     $url = 'https://www.google.com/recaptcha/api/siteverify';
     // Build data to append to request
     $data = array('secret' => $wgReCaptchaSecretKey, 'response' => $wgRequest->getVal('g-recaptcha-response'));
     if ($wgReCaptchaSendRemoteIP) {
         $data['remoteip'] = $wgRequest->getIP();
     }
     $url = wfAppendQuery($url, $data);
     $request = MWHttpRequest::factory($url, array('method' => 'GET'));
     $status = $request->execute();
     if (!$status->isOK()) {
         $this->error = 'http';
         $this->logStatusError($status);
         return false;
     }
     $response = FormatJson::decode($request->getContent(), true);
     if (!$response) {
         $this->error = 'json';
         $this->logStatusError($this->error);
         return false;
     }
     if (isset($response['error-codes'])) {
         $this->error = 'recaptcha-api';
         $this->logCheckError($response['error-codes']);
         return false;
     }
     return $response['success'];
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:38,代码来源:ReCaptchaNoCaptcha.class.php


示例15: execute

 public function execute()
 {
     global $wgCommandLineMode;
     if ($this->hasOption('procs')) {
         $procs = intval($this->getOption('procs'));
         if ($procs < 1 || $procs > 1000) {
             $this->error("Invalid argument to --procs", true);
         } elseif ($procs != 1) {
             $fc = new ForkController($procs);
             if ($fc->start() != 'child') {
                 exit(0);
             }
         }
     }
     $outputJSON = $this->getOption('result') === 'json';
     // Enable DBO_TRX for atomicity; JobRunner manages transactions
     // and works well in web server mode already (@TODO: this is a hack)
     $wgCommandLineMode = false;
     $runner = new JobRunner(LoggerFactory::getInstance('runJobs'));
     if (!$outputJSON) {
         $runner->setDebugHandler(array($this, 'debugInternal'));
     }
     $response = $runner->run(array('type' => $this->getOption('type', false), 'maxJobs' => $this->getOption('maxjobs', false), 'maxTime' => $this->getOption('maxtime', false), 'throttle' => $this->hasOption('nothrottle') ? false : true));
     if ($outputJSON) {
         $this->output(FormatJson::encode($response, true));
     }
     $wgCommandLineMode = true;
 }
开发者ID:admonkey,项目名称:mediawiki,代码行数:28,代码来源:runJobs.php


示例16: testPreSaveTransform

 /**
  * Tests JSON pretty-printing.
  * @covers JsonSchemaContent::preSaveTransform
  */
 function testPreSaveTransform()
 {
     $transformed = new JsonSchemaContent(self::VALID_JSON_SCHEMA);
     $prettyJson = $transformed->preSaveTransform(new Title(), new User(), new ParserOptions())->getNativeData();
     $this->assertContains("\n", $prettyJson, 'Transformed JSON is beautified.');
     $this->assertEquals(FormatJson::decode($prettyJson), FormatJson::decode(self::VALID_JSON_SCHEMA), 'Beautification does not alter JSON value.');
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:11,代码来源:JsonSchemaTest.php


示例17: execute

 public function execute()
 {
     $filename = $this->getArg(0);
     if (!is_readable($filename)) {
         $this->error("Error: Unable to read {$filename}", 1);
     }
     $json = FormatJson::decode(file_get_contents($filename), true);
     if ($json === null) {
         $this->error("Error: Invalid JSON", 1);
     }
     if (!isset($json['manifest_version'])) {
         $json['manifest_version'] = 1;
     }
     if ($json['manifest_version'] == ExtensionRegistry::MANIFEST_VERSION) {
         $this->output("Already at the latest version: {$json['manifest_version']}\n");
         return;
     }
     while ($json['manifest_version'] !== ExtensionRegistry::MANIFEST_VERSION) {
         $json['manifest_version'] += 1;
         $func = "updateTo{$json['manifest_version']}";
         $this->{$func}($json);
     }
     file_put_contents($filename, FormatJson::encode($json, "\t", FormatJson::ALL_OK) . "\n");
     $this->output("Updated to {$json['manifest_version']}...\n");
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:25,代码来源:updateExtensionJsonSchema.php


示例18: testFillParserOutput

 /**
  * @dataProvider provideDataAndParserText
  */
 public function testFillParserOutput($data, $expected)
 {
     $obj = new JsonContent(FormatJson::encode($data));
     $parserOutput = $obj->getParserOutput($this->getMockTitle(), null, null, true);
     $this->assertInstanceOf('ParserOutput', $parserOutput);
     $this->assertEquals($expected, $parserOutput->getText());
 }
开发者ID:rploaiza,项目名称:dbpedia-latinoamerica,代码行数:10,代码来源:JsonContentTest.php


示例19: testGetTourNames

 public function testGetTourNames()
 {
     $this->assertSame(array(), GuidedTourHooks::getTourNames(null), 'Returns empty array for null parameter');
     $this->assertSame(array('test'), GuidedTourHooks::getTourNames(FormatJson::encode(array('version' => 1, 'tours' => array('test' => array('step' => 3))))), 'Valid JSON cookie with a single tour is parsed correctly');
     $this->assertSame(array('firsttour', 'secondtour', 'thirdtour'), GuidedTourHooks::getTourNames(FormatJson::encode(array('version' => 1, 'tours' => array('firsttour' => array('step' => 4), 'secondtour' => array('step' => 2), 'thirdtour' => array('step' => 3, 'firstArticleId' => 38333))))), 'Valid JSON cookie with multiple tours is parsed correctly');
     $this->assertSame(array(), GuidedTourHooks::getTourNames('{"bad": "cookie"}'), 'Valid JSON with missing tours field returns empty array');
     $this->assertSame(array(), GuidedTourHooks::getTourNames('<invalid: JSON>'), 'Invalid JSON returns empty array');
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:8,代码来源:GuidedTourTest.php


示例20: testParseGeocoderCircle

 public function testParseGeocoderCircle()
 {
     global $egMultiMaps_AllowGeocoderTests;
     if (!$egMultiMaps_AllowGeocoderTests) {
         return;
     }
     $this->assertRegExp('{"circles":\\[{"radius":\\[[0-9\\.]+\\],"pos":\\[{"lat":[0-9\\.]+,"lon":[0-9\\.]+}\\]}\\],"bounds":{"ne":{"lat":[0-9\\.]+,"lon":[0-9\\.]+},"sw":{"lat":[0-9\\.]+,"lon":[0-9\\.]+}}}', \FormatJson::encode($this->object->getMapData(array('circle=Moscow', 'service=google'))));
 }
开发者ID:MapsMD,项目名称:mediawikiMaps,代码行数:8,代码来源:GoogleTest.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Formatter类代码示例发布时间:2022-05-23
下一篇:
PHP Format类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap