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


PHP FormOptions::add方法代码示例

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


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

示例1: setup

 protected function setup($par)
 {
     global $wgRequest, $wgUser, $wgEnableNewpagesUserFilter;
     // Options
     $opts = new FormOptions();
     $this->opts = $opts;
     // bind
     $opts->add('hideliu', false);
     $opts->add('hidepatrolled', $wgUser->getBoolOption('newpageshidepatrolled'));
     $opts->add('hidebots', false);
     $opts->add('hideredirs', true);
     $opts->add('limit', (int) $wgUser->getOption('rclimit'));
     $opts->add('offset', '');
     $opts->add('namespace', '0');
     $opts->add('username', '');
     $opts->add('feed', '');
     $opts->add('tagfilter', '');
     // Set values
     $opts->fetchValuesFromRequest($wgRequest);
     if ($par) {
         $this->parseParams($par);
     }
     // Validate
     $opts->validateIntBounds('limit', 0, 5000);
     if (!$wgEnableNewpagesUserFilter) {
         $opts->setValue('username', '');
     }
     // Store some objects
     $this->skin = $wgUser->getSkin();
 }
开发者ID:ruizrube,项目名称:spdef,代码行数:30,代码来源:SpecialNewpages.php

示例2: execute

 public function execute($par)
 {
     $this->setHeaders();
     $this->outputHeader();
     $out = $this->getOutput();
     $this->addHelpLink('Help:New images');
     $opts = new FormOptions();
     $opts->add('like', '');
     $opts->add('showbots', false);
     $opts->add('hidepatrolled', false);
     $opts->add('limit', 50);
     $opts->add('offset', '');
     $opts->fetchValuesFromRequest($this->getRequest());
     if ($par !== null) {
         $opts->setValue(is_numeric($par) ? 'limit' : 'like', $par);
     }
     $opts->validateIntBounds('limit', 0, 500);
     $this->opts = $opts;
     if (!$this->including()) {
         $this->setTopText();
         $this->buildForm();
     }
     $pager = new NewFilesPager($this->getContext(), $opts);
     $out->addHTML($pager->getBody());
     if (!$this->including()) {
         $out->addHTML($pager->getNavigationBar());
     }
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:28,代码来源:SpecialNewimages.php

示例3: execute

 public function execute($par)
 {
     global $wgLogRestrictions;
     $this->setHeaders();
     $this->outputHeader();
     $opts = new FormOptions();
     $opts->add('type', '');
     $opts->add('user', '');
     $opts->add('page', '');
     $opts->add('pattern', false);
     //		$opts->add( 'year', null, FormOptions::INTNULL ); don't default to zero
     $opts->add('year', '');
     $opts->add('month', null, FormOptions::INTNULL);
     $opts->add('tagfilter', '');
     $opts->add('offset', '');
     $opts->add('dir', '');
     $opts->add('offender', '');
     // Set values
     $opts->fetchValuesFromRequest($this->getRequest());
     if ($par !== null) {
         $this->parseParams($opts, (string) $par);
     }
     # Don't let the user get stuck with a certain date
     if ($opts->getValue('offset') || $opts->getValue('dir') == 'prev') {
         $opts->setValue('year', '');
         $opts->setValue('month', '');
     }
     // If the user doesn't have the right permission to view the specific
     // log type, throw a PermissionsError
     // If the log type is invalid, just show all public logs
     $type = $opts->getValue('type');
     if (!LogPage::isLogType($type)) {
         $opts->setValue('type', '');
     } elseif (isset($wgLogRestrictions[$type]) && !$this->getUser()->isAllowed($wgLogRestrictions[$type])) {
         throw new PermissionsError($wgLogRestrictions[$type]);
     }
     # Handle type-specific inputs
     $qc = array();
     if ($opts->getValue('type') == 'suppress') {
         $offender = User::newFromName($opts->getValue('offender'), false);
         if ($offender && $offender->getId() > 0) {
             $qc = array('ls_field' => 'target_author_id', 'ls_value' => $offender->getId());
         } elseif ($offender && IP::isIPAddress($offender->getName())) {
             $qc = array('ls_field' => 'target_author_ip', 'ls_value' => $offender->getName());
         }
     }
     # Some log types are only for a 'User:' title but we might have been given
     # only the username instead of the full title 'User:username'. This part try
     # to lookup for a user by that name and eventually fix user input. See bug 1697.
     wfRunHooks('GetLogTypesOnUser', array(&$this->typeOnUser));
     if (in_array($opts->getValue('type'), $this->typeOnUser)) {
         # ok we have a type of log which expect a user title.
         $target = Title::newFromText($opts->getValue('page'));
         if ($target && $target->getNamespace() === NS_MAIN) {
             # User forgot to add 'User:', we are adding it for him
             $opts->setValue('page', Title::makeTitleSafe(NS_USER, $opts->getValue('page')));
         }
     }
     $this->show($opts, $qc);
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:60,代码来源:SpecialLog.php

示例4: execute

 public function execute($par)
 {
     // Shortcut by using $par
     if ($par) {
         $this->getOutput()->redirect($this->getTitle()->getLinkURL(array('user' => $par)));
         return;
     }
     $this->setHeaders();
     $this->outputHeader();
     // Parse options
     $opt = new \FormOptions();
     $opt->add('user', '');
     $opt->add('delete', '');
     $opt->add('reason', '');
     $opt->fetchValuesFromRequest($this->getRequest());
     // Parse user
     $user = $opt->getValue('user');
     $userObj = \User::newFromName($user);
     $userExists = $userObj && $userObj->getId() !== 0;
     // If current task is delete and user is not allowed
     $canDoAdmin = $this->getUser()->isAllowed('avataradmin');
     if ($opt->getValue('delete')) {
         if (!$canDoAdmin) {
             throw new \PermissionsError('avataradmin');
         }
         // Delete avatar if the user exists
         if ($userExists) {
             if (Avatars::deleteAvatar($userObj)) {
                 global $wgAvatarLogInRC;
                 $logEntry = new \ManualLogEntry('avatar', 'delete');
                 $logEntry->setPerformer($this->getUser());
                 $logEntry->setTarget($userObj->getUserPage());
                 $logEntry->setComment($opt->getValue('reason'));
                 $logId = $logEntry->insert();
                 $logEntry->publish($logId, $wgAvatarLogInRC ? 'rcandudp' : 'udp');
             }
         }
     }
     $this->getOutput()->addModules(array('mediawiki.userSuggest'));
     $this->showForm($user);
     if ($userExists) {
         $haveAvatar = Avatars::hasAvatar($userObj);
         if ($haveAvatar) {
             $html = \Xml::tags('img', array('src' => Avatars::getLinkFor($user, 'original') . '&nocache&ver=' . dechex(time()), 'height' => 400), '');
             $html = \Xml::tags('p', array(), $html);
             $this->getOutput()->addHTML($html);
             // Add a delete button
             if ($canDoAdmin) {
                 $this->showDeleteForm($user);
             }
         } else {
             $this->getOutput()->addWikiMsg('viewavatar-noavatar');
         }
     } else {
         if ($user) {
             $this->getOutput()->addWikiMsg('viewavatar-nouser');
         }
     }
 }
开发者ID:nbdd0121,项目名称:MW-Avatar,代码行数:59,代码来源:SpecialView.php

示例5: setUp

 /**
  * Instanciates a FormOptions object to play with.	 
  * FormOptions::add() is tested by the class FormOptionsInitializationTest
  * so we assume the function is well tested already an use it to create
  * the fixture.
  */
 protected function setUp()
 {
     $this->object = new FormOptions();
     $this->object->add('string1', 'string one');
     $this->object->add('string2', 'string two');
     $this->object->add('integer', 0);
     $this->object->add('intnull', 0, FormOptions::INTNULL);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:14,代码来源:FormOptionsTest.php

示例6: execute

 function execute($par)
 {
     $out = $this->getOutput();
     $this->setHeaders();
     $this->outputHeader();
     $opts = new FormOptions();
     $opts->add('target', '');
     $opts->add('namespace', '', FormOptions::INTNULL);
     $opts->add('limit', 50);
     $opts->add('from', 0);
     $opts->add('back', 0);
     $opts->add('hideredirs', false);
     $opts->add('hidetrans', false);
     $opts->add('hidelinks', false);
     $opts->add('hideimages', false);
     $opts->fetchValuesFromRequest($this->getRequest());
     $opts->validateIntBounds('limit', 0, 5000);
     // Give precedence to subpage syntax
     if (isset($par)) {
         $opts->setValue('target', $par);
     }
     // Bind to member variable
     $this->opts = $opts;
     $this->target = Title::newFromURL($opts->getValue('target'));
     if (!$this->target) {
         $out->addHTML($this->whatlinkshereForm());
         return;
     }
     $this->getSkin()->setRelevantTitle($this->target);
     $this->selfTitle = $this->getTitle($this->target->getPrefixedDBkey());
     $out->setPageTitle(wfMsg('whatlinkshere-title', $this->target->getPrefixedText()));
     $out->setSubtitle(wfMsg('whatlinkshere-backlink', Linker::link($this->target, $this->target->getPrefixedText(), array(), array('redirect' => 'no'))));
     $this->showIndirectLinks(0, $this->target, $opts->getValue('limit'), $opts->getValue('from'), $opts->getValue('back'));
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:34,代码来源:SpecialWhatlinkshere.php

示例7: setupOptions

 public function setupOptions()
 {
     $this->opts = new FormOptions();
     $this->opts->add('hidebots', false, FormOptions::BOOL);
     $this->opts->add('hidesysops', false, FormOptions::BOOL);
     $this->opts->fetchValuesFromRequest($this->getRequest());
     if ($this->opts->getValue('hidebots') == 1) {
         $this->hideRights[] = 'bot';
     }
     if ($this->opts->getValue('hidesysops') == 1) {
         $this->hideGroups[] = 'sysop';
     }
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:13,代码来源:SpecialActiveusers.php

示例8: setupOptions

 public function setupOptions()
 {
     $this->opts = new FormOptions();
     $this->opts->add('hidebots', false, FormOptions::BOOL);
     $this->opts->add('hidesysops', false, FormOptions::BOOL);
     $this->opts->fetchValuesFromRequest($this->getRequest());
     $this->groups = array();
     if ($this->opts->getValue('hidebots') == 1) {
         $this->groups['bot'] = true;
     }
     if ($this->opts->getValue('hidesysops') == 1) {
         $this->groups['sysop'] = true;
     }
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:14,代码来源:SpecialActiveusers.php

示例9: fromArrayCallback

 /**
  * Get options from array, applying callback to extract key and value.
  *
  * fromArrayCallback([$a, $b, $c], function($x){
  *   return [$x->key, $x->value];
  * });
  **/
 public static function fromArrayCallback(array $data, callable $callback)
 {
     $ret = new FormOptions();
     foreach ($data as $item) {
         list($value, $text) = $callback($item);
         $ret->add($value, $text);
     }
     return $ret;
 }
开发者ID:nitroxy,项目名称:php-forms,代码行数:16,代码来源:FormOptions.php

示例10: setup

 protected function setup($par)
 {
     global $wgRequest, $wgUser;
     // Options
     $opts = new FormOptions();
     $this->opts = $opts;
     // bind
     $opts->add('page1', '');
     $opts->add('page2', '');
     $opts->add('rev1', '');
     $opts->add('rev2', '');
     $opts->add('action', '');
     // Set values
     $opts->fetchValuesFromRequest($wgRequest);
     $title1 = Title::newFromText($opts->getValue('page1'));
     $title2 = Title::newFromText($opts->getValue('page2'));
     if ($title1 && $title1->exists() && $opts->getValue('rev1') == '') {
         $pda = new Article($title1);
         $pdi = $pda->getID();
         $pdLastRevision = Revision::loadFromPageId(wfGetDB(DB_SLAVE), $pdi);
         $opts->setValue('rev1', $pdLastRevision->getId());
     } elseif ($opts->getValue('rev1') != '') {
         $pdrev = Revision::newFromId($opts->getValue('rev1'));
         if ($pdrev) {
             $opts->setValue('page1', $pdrev->getTitle()->getPrefixedText());
         }
     }
     if ($title2 && $title2->exists() && $opts->getValue('rev2') == '') {
         $pda = new Article($title2);
         $pdi = $pda->getID();
         $pdLastRevision = Revision::loadFromPageId(wfGetDB(DB_SLAVE), $pdi);
         $opts->setValue('rev2', $pdLastRevision->getId());
     } elseif ($opts->getValue('rev2') != '') {
         $pdrev = Revision::newFromId($opts->getValue('rev2'));
         if ($pdrev) {
             $opts->setValue('page2', $pdrev->getTitle()->getPrefixedText());
         }
     }
     // Store some objects
     $this->skin = $wgUser->getSkin();
 }
开发者ID:GodelDesign,项目名称:Godel,代码行数:41,代码来源:SpecialComparePages.php

示例11: execute

 /**
  * Show the special page
  *
  * @param string $par Parameter passed to the page or null
  */
 public function execute($par)
 {
     $out = $this->getOutput();
     $this->setHeaders();
     $this->outputHeader();
     $opts = new FormOptions();
     $opts->add('username', '');
     $opts->add('hidebots', false, FormOptions::BOOL);
     $opts->add('hidesysops', false, FormOptions::BOOL);
     $opts->fetchValuesFromRequest($this->getRequest());
     if ($par !== null) {
         $opts->setValue('username', $par);
     }
     // Mention the level of cache staleness...
     $cacheText = '';
     $dbr = wfGetDB(DB_SLAVE, 'recentchanges');
     $rcMax = $dbr->selectField('recentchanges', 'MAX(rc_timestamp)', '', __METHOD__);
     if ($rcMax) {
         $cTime = $dbr->selectField('querycache_info', 'qci_timestamp', ['qci_type' => 'activeusers'], __METHOD__);
         if ($cTime) {
             $secondsOld = wfTimestamp(TS_UNIX, $rcMax) - wfTimestamp(TS_UNIX, $cTime);
         } else {
             $rcMin = $dbr->selectField('recentchanges', 'MIN(rc_timestamp)');
             $secondsOld = time() - wfTimestamp(TS_UNIX, $rcMin);
         }
         if ($secondsOld > 0) {
             $cacheTxt = '<br>' . $this->msg('cachedspecial-viewing-cached-ttl')->durationParams($secondsOld);
         }
     }
     $pager = new ActiveUsersPager($this->getContext(), $opts);
     $usersBody = $pager->getBody();
     $days = $this->getConfig()->get('ActiveUserDays');
     $formDescriptor = ['username' => ['type' => 'user', 'name' => 'username', 'label-message' => 'activeusers-from'], 'hidebots' => ['type' => 'check', 'name' => 'hidebots', 'label-message' => 'activeusers-hidebots', 'default' => false], 'hidesysops' => ['type' => 'check', 'name' => 'hidesysops', 'label-message' => 'activeusers-hidesysops', 'default' => false]];
     $htmlForm = HTMLForm::factory('ooui', $formDescriptor, $this->getContext())->setIntro($this->msg('activeusers-intro')->numParams($days) . $cacheText)->setWrapperLegendMsg('activeusers')->setSubmitTextMsg('activeusers-submit')->setMethod('get')->prepareForm()->displayForm(false);
     if ($usersBody) {
         $out->addHTML($pager->getNavigationBar() . Html::rawElement('ul', [], $usersBody) . $pager->getNavigationBar());
     } else {
         $out->addWikiMsg('activeusers-noresult');
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:45,代码来源:SpecialActiveusers.php

示例12: execute

 public function execute($par)
 {
     global $wgRequest;
     $this->setHeaders();
     $this->outputHeader();
     $opts = new FormOptions();
     $opts->add('type', '');
     $opts->add('user', '');
     $opts->add('page', '');
     $opts->add('pattern', false);
     $opts->add('year', null, FormOptions::INTNULL);
     $opts->add('month', null, FormOptions::INTNULL);
     $opts->add('tagfilter', '');
     $opts->add('offset', '');
     $opts->add('dir', '');
     $opts->add('offender', '');
     // Set values
     $opts->fetchValuesFromRequest($wgRequest);
     if ($par) {
         $this->parseParams($opts, (string) $par);
     }
     # Don't let the user get stuck with a certain date
     if ($opts->getValue('offset') || $opts->getValue('dir') == 'prev') {
         $opts->setValue('year', '');
         $opts->setValue('month', '');
     }
     # Handle type-specific inputs
     $qc = array();
     if ($opts->getValue('type') == 'suppress') {
         $offender = User::newFromName($opts->getValue('offender'), false);
         if ($offender && $offender->getId() > 0) {
             $qc = array('ls_field' => 'target_author_id', 'ls_value' => $offender->getId());
         } elseif ($offender && IP::isIPAddress($offender->getName())) {
             $qc = array('ls_field' => 'target_author_ip', 'ls_value' => $offender->getName());
         }
     }
     $this->show($opts, $qc);
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:38,代码来源:SpecialLog.php

示例13: execute

 function execute($par)
 {
     $out = $this->getOutput();
     $this->setHeaders();
     $this->outputHeader();
     $this->addHelpLink('Help:What links here');
     $opts = new FormOptions();
     $opts->add('target', '');
     $opts->add('namespace', '', FormOptions::INTNULL);
     $opts->add('limit', $this->getConfig()->get('QueryPageDefaultLimit'));
     $opts->add('from', 0);
     $opts->add('back', 0);
     $opts->add('hideredirs', false);
     $opts->add('hidetrans', false);
     $opts->add('hidelinks', false);
     $opts->add('hideimages', false);
     $opts->add('invert', false);
     $opts->fetchValuesFromRequest($this->getRequest());
     $opts->validateIntBounds('limit', 0, 5000);
     // Give precedence to subpage syntax
     if ($par !== null) {
         $opts->setValue('target', $par);
     }
     // Bind to member variable
     $this->opts = $opts;
     $this->target = Title::newFromText($opts->getValue('target'));
     if (!$this->target) {
         if (!$this->including()) {
             $out->addHTML($this->whatlinkshereForm());
         }
         return;
     }
     $this->getSkin()->setRelevantTitle($this->target);
     $this->selfTitle = $this->getPageTitle($this->target->getPrefixedDBkey());
     $out->setPageTitle($this->msg('whatlinkshere-title', $this->target->getPrefixedText()));
     $out->addBacklinkSubtitle($this->target);
     $this->showIndirectLinks(0, $this->target, $opts->getValue('limit'), $opts->getValue('from'), $opts->getValue('back'));
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:38,代码来源:SpecialWhatlinkshere.php

示例14: execute

 public function execute($par)
 {
     $this->useTransactionalTimeLimit();
     $this->checkPermissions();
     $this->checkReadOnly();
     $this->setHeaders();
     $this->outputHeader();
     $this->addHelpLink('Help:Merge history');
     $opts = new FormOptions();
     $opts->add('target', '');
     $opts->add('dest', '');
     $opts->add('target', '');
     $opts->add('mergepoint', '');
     $opts->add('reason', '');
     $opts->add('merge', false);
     $opts->fetchValuesFromRequest($this->getRequest());
     $target = $opts->getValue('target');
     $dest = $opts->getValue('dest');
     $targetObj = Title::newFromText($target);
     $destObj = Title::newFromText($dest);
     $status = Status::newGood();
     $this->mOpts = $opts;
     $this->mTargetObj = $targetObj;
     $this->mDestObj = $destObj;
     if ($opts->getValue('merge') && $targetObj && $destObj && $opts->getValue('mergepoint') !== '') {
         $this->merge();
         return;
     }
     if ($target === '' && $dest === '') {
         $this->showMergeForm();
         return;
     }
     if (!$targetObj instanceof Title) {
         $status->merge(Status::newFatal('mergehistory-invalid-source'));
     } elseif (!$targetObj->exists()) {
         $status->merge(Status::newFatal('mergehistory-no-source', wfEscapeWikiText($targetObj->getPrefixedText())));
     }
     if (!$destObj instanceof Title) {
         $status->merge(Status::newFatal('mergehistory-invalid-destination'));
     } elseif (!$destObj->exists()) {
         $status->merge(Status::newFatal('mergehistory-no-destination', wfEscapeWikiText($destObj->getPrefixedText())));
     }
     if ($targetObj && $destObj && $targetObj->equals($destObj)) {
         $status->merge(Status::newFatal('mergehistory-same-destination'));
     }
     $this->mStatus = $status;
     $this->showMergeForm();
     if ($status->isOK()) {
         $this->showHistory();
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:51,代码来源:SpecialMergeHistory.php

示例15: getDefaultOptions

	/**
	 * Returns default options.
	 */
	public function getDefaultOptions() {
		global $wgWikilogNumArticles;

		$opts = new FormOptions();
		$opts->add( 'view',     'summary' );
		$opts->add( 'show',     'published' );
		$opts->add( 'wikilog',  '' );
		$opts->add( 'category', '' );
		$opts->add( 'author',   '' );
		$opts->add( 'tag',      '' );
		$opts->add( 'year',     '', FormOptions::INTNULL );
		$opts->add( 'month',    '', FormOptions::INTNULL );
		$opts->add( 'day',      '', FormOptions::INTNULL );
		$opts->add( 'limit',    $wgWikilogNumArticles );
		$opts->add( 'template', '' );
		return $opts;
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:20,代码来源:SpecialWikilog.php


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