當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。