當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Survey::getValidFields方法代碼示例

本文整理匯總了PHP中Survey::getValidFields方法的典型用法代碼示例。如果您正苦於以下問題:PHP Survey::getValidFields方法的具體用法?PHP Survey::getValidFields怎麽用?PHP Survey::getValidFields使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Survey的用法示例。


在下文中一共展示了Survey::getValidFields方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: execute

	public function execute() {
		global $wgUser;
		
		if ( !$wgUser->isAllowed( 'surveyadmin' ) || $wgUser->isBlocked() ) {
			$this->dieUsageMsg( array( 'badaccess-groups' ) );
		}
		
		$params = $this->extractRequestParams();
		
		foreach ( $params['questions'] as &$question ) {
			$question = SurveyQuestion::newFromUrlData( $question );
		}
		
		$survey = new Survey( Survey::getValidFields( $params, $params['id'] ) );
		
		$this->getResult()->addValue(
			null,
			'success',
			$survey->writeToDB()
		);
		
		$this->getResult()->addValue(
			'survey',
			'id',
			$survey->getId()
		);
		
		$this->getResult()->addValue(
			'survey',
			'name',
			$survey->getField( 'name' )
		);
	}
開發者ID:realsoc,項目名稱:mediawiki-extensions,代碼行數:33,代碼來源:ApiEditSurvey.php

示例2: execute

	public function execute() {
		global $wgUser;
		
		if ( !$wgUser->isAllowed( 'surveyadmin' ) || $wgUser->isBlocked() ) {
			$this->dieUsageMsg( array( 'badaccess-groups' ) );
		}
		
		$params = $this->extractRequestParams();
		
		foreach ( $params['questions'] as &$question ) {
			$question = SurveyQuestion::newFromUrlData( $question );
		}
		
		try {
			$survey = new Survey( Survey::getValidFields( $params ) );
			$success = $survey->writeToDB();
		}
		catch ( DBQueryError $ex ) {
			if ( $ex->errno == 1062 ) {
				$this->dieUsage( wfMsgExt( 'survey-err-duplicate-name', 'parsemag', $params['name'] ), 'duplicate-survey-name' );
			} else {
				throw $ex;
			}
		}
		
		$this->getResult()->addValue(
			null,
			'success',
			$success
		);
		
		$this->getResult()->addValue(
			'survey',
			'id',
			$survey->getId()
		);
		
		$this->getResult()->addValue(
			'survey',
			'name',
			$survey->getField( 'name' )
		);
	}
開發者ID:realsoc,項目名稱:mediawiki-extensions,代碼行數:43,代碼來源:ApiAddSurvey.php


注:本文中的Survey::getValidFields方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。