本文整理汇总了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();
}
示例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');
}
}
}
示例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');
}
}
}