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


PHP Survey::newFromName方法代码示例

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


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

示例1: 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

示例2: execute

 /**
  * Main method.
  * 
  * @since 0.1
  * 
  * @param string $arg
  */
 public function execute($subPage)
 {
     if (!parent::execute($subPage)) {
         return;
     }
     if (is_null($subPage) || trim($subPage) === '') {
         $this->getOutput()->redirect(SpecialPage::getTitleFor('Surveys')->getLocalURL());
     } else {
         $subPage = trim($subPage);
         if (Survey::has(array('name' => $subPage))) {
             $survey = Survey::newFromName($subPage);
             $this->displayNavigation(array(wfMsgExt('survey-navigation-edit', 'parseinline', $survey->getField('name')), wfMsgExt('survey-navigation-take', 'parseinline', $survey->getField('name')), wfMsgExt('survey-navigation-list', 'parseinline')));
             $this->displayStats($survey);
         } else {
             $this->showError('surveys-surveystats-nosuchsurvey');
         }
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:25,代码来源:SpecialSurveyStats.php

示例3: execute

 /**
  * Main method.
  * 
  * @since 0.1
  * 
  * @param string $arg
  */
 public function execute($subPage)
 {
     if (!parent::execute($subPage)) {
         return;
     }
     if ($this->getRequest()->wasPosted() && $this->getUser()->matchEditToken($this->getRequest()->getVal('wpEditToken'))) {
         $this->handleSubmission();
     } else {
         if (is_null($subPage) || trim($subPage) === '') {
             $this->getOutput()->redirect(SpecialPage::getTitleFor('Surveys')->getLocalURL());
         } else {
             $subPage = trim($subPage);
             $survey = Survey::newFromName($subPage, null, true);
             if ($survey === false) {
                 $survey = new Survey(array('name' => $subPage), true);
             } else {
                 $this->displayNavigation(array(wfMsgExt('survey-navigation-take', 'parseinline', $subPage), wfMsgExt('survey-navigation-stats', 'parseinline', $subPage), wfMsgExt('survey-navigation-list', 'parseinline')));
             }
             $this->showSurvey($survey);
             $this->addModules('ext.survey.special.survey');
         }
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:30,代码来源:SpecialSurvey.php


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