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


PHP HTMLFormField类代码示例

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


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

示例1: getInputHTML

 function getInputHTML($value)
 {
     $valInSelect = false;
     if ($value !== false) {
         $value = strval($value);
         $valInSelect = in_array($value, HTMLFormField::flattenOptions($this->getOptions()), true);
     }
     $selected = $valInSelect ? $value : 'other';
     $select = new XmlSelect($this->mName, $this->mID, $selected);
     $select->addOptions($this->getOptions());
     $select->setAttribute('class', 'mw-htmlform-select-or-other');
     $tbAttribs = array('id' => $this->mID . '-other', 'size' => $this->getSize());
     if (!empty($this->mParams['disabled'])) {
         $select->setAttribute('disabled', 'disabled');
         $tbAttribs['disabled'] = 'disabled';
     }
     if (isset($this->mParams['tabindex'])) {
         $select->setAttribute('tabindex', $this->mParams['tabindex']);
         $tbAttribs['tabindex'] = $this->mParams['tabindex'];
     }
     $select = $select->getHTML();
     if (isset($this->mParams['maxlength'])) {
         $tbAttribs['maxlength'] = $this->mParams['maxlength'];
     }
     if ($this->mClass !== '') {
         $tbAttribs['class'] = $this->mClass;
     }
     $textbox = Html::input($this->mName . '-other', $valInSelect ? '' : $value, 'text', $tbAttribs);
     return "{$select}<br />\n{$textbox}";
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:30,代码来源:HTMLSelectOrOtherField.php

示例2: filterDataForSubmit

 function filterDataForSubmit($data)
 {
     $options = HTMLFormField::flattenOptions($this->getOptions());
     $res = array();
     foreach ($options as $opt) {
         $res["{$opt}"] = in_array($opt, $data);
     }
     return $res;
 }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:9,代码来源:HTMLMultiSelectField.php

示例3: validate

 function validate($value, $alldata)
 {
     $p = parent::validate($value, $alldata);
     if ($p !== true) {
         return $p;
     }
     $validOptions = HTMLFormField::flattenOptions($this->getOptions());
     if (in_array(strval($value), $validOptions, true)) {
         return true;
     } else {
         return $this->msg('htmlform-select-badoption')->parse();
     }
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:13,代码来源:HTMLSelectField.php

示例4: datetimePreferences

	/**
	 * @param $user User
	 * @param $context IContextSource
	 * @param $defaultPreferences
	 * @return void
	 */
	static function datetimePreferences( $user, IContextSource $context, &$defaultPreferences ) {
		## Date and time #####################################
		$dateOptions = self::getDateOptions( $context );
		if ( $dateOptions ) {
			$defaultPreferences['date'] = array(
				'type' => 'radio',
				'options' => $dateOptions,
				'label' => '&#160;',
				'section' => 'datetime/dateformat',
			);
		}

		// Info
		$now = wfTimestampNow();
		$lang = $context->getLanguage();
		$nowlocal = Xml::element( 'span', array( 'id' => 'wpLocalTime' ),
			$lang->time( $now, true ) );
		$nowserver = $lang->time( $now, false ) .
			Html::hidden( 'wpServerTime', (int)substr( $now, 8, 2 ) * 60 + (int)substr( $now, 10, 2 ) );

		$defaultPreferences['nowserver'] = array(
			'type' => 'info',
			'raw' => 1,
			'label-message' => 'servertime',
			'default' => $nowserver,
			'section' => 'datetime/timeoffset',
		);

		$defaultPreferences['nowlocal'] = array(
			'type' => 'info',
			'raw' => 1,
			'label-message' => 'localtime',
			'default' => $nowlocal,
			'section' => 'datetime/timeoffset',
		);

		// Grab existing pref.
		$tzOffset = $user->getOption( 'timecorrection' );
		$tz = explode( '|', $tzOffset, 3 );

		$tzOptions = self::getTimezoneOptions( $context );

		$tzSetting = $tzOffset;
		if ( count( $tz ) > 1 && $tz[0] == 'Offset' ) {
			$minDiff = $tz[1];
			$tzSetting = sprintf( '%+03d:%02d', floor( $minDiff / 60 ), abs( $minDiff ) % 60 );
		} elseif ( count( $tz ) > 1 && $tz[0] == 'ZoneInfo' &&
			!in_array( $tzOffset, HTMLFormField::flattenOptions( $tzOptions ) ) )
		{
			# Timezone offset can vary with DST
			$userTZ = timezone_open( $tz[2] );
			if ( $userTZ !== false ) {
				$minDiff = floor( timezone_offset_get( $userTZ, date_create( 'now' ) ) / 60 );
				$tzSetting = "ZoneInfo|$minDiff|{$tz[2]}";
			}
		}

		$defaultPreferences['timecorrection'] = array(
			'class' => 'HTMLSelectOrOtherField',
			'label-message' => 'timezonelegend',
			'options' => $tzOptions,
			'default' => $tzSetting,
			'size' => 20,
			'section' => 'datetime/timeoffset',
		);
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:72,代码来源:Preferences.php

示例5: getOptionKinds

	/**
	 * Return an associative array mapping preferences keys to the kind of a preference they're
	 * used for. Different kinds are handled differently when setting or reading preferences.
	 *
	 * See User::listOptionKinds for the list of valid option types that can be provided.
	 *
	 * @see User::listOptionKinds
	 * @param $context IContextSource
	 * @param array $options assoc. array with options keys to check as keys. Defaults to $this->mOptions.
	 * @return array the key => kind mapping data
	 */
	public function getOptionKinds( IContextSource $context, $options = null ) {
		$this->loadOptions();
		if ( $options === null ) {
			$options = $this->mOptions;
		}

		$prefs = Preferences::getPreferences( $this, $context );
		$mapping = array();

		// Multiselect and checkmatrix options are stored in the database with
		// one key per option, each having a boolean value. Extract those keys.
		$multiselectOptions = array();
		foreach ( $prefs as $name => $info ) {
			if ( ( isset( $info['type'] ) && $info['type'] == 'multiselect' ) ||
					( isset( $info['class'] ) && $info['class'] == 'HTMLMultiSelectField' ) ) {
				$opts = HTMLFormField::flattenOptions( $info['options'] );
				$prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;

				foreach ( $opts as $value ) {
					$multiselectOptions["$prefix$value"] = true;
				}

				unset( $prefs[$name] );
			}
		}
		$checkmatrixOptions = array();
		foreach ( $prefs as $name => $info ) {
			if ( ( isset( $info['type'] ) && $info['type'] == 'checkmatrix' ) ||
					( isset( $info['class'] ) && $info['class'] == 'HTMLCheckMatrix' ) ) {
				$columns = HTMLFormField::flattenOptions( $info['columns'] );
				$rows = HTMLFormField::flattenOptions( $info['rows'] );
				$prefix = isset( $info['prefix'] ) ? $info['prefix'] : $name;

				foreach ( $columns as $column ) {
					foreach ( $rows as $row ) {
						$checkmatrixOptions["$prefix-$column-$row"] = true;
					}
				}

				unset( $prefs[$name] );
			}
		}

		// $value is ignored
		foreach ( $options as $key => $value ) {
			if ( isset( $prefs[$key] ) ) {
				$mapping[$key] = 'registered';
			} elseif ( isset( $multiselectOptions[$key] ) ) {
				$mapping[$key] = 'registered-multiselect';
			} elseif ( isset( $checkmatrixOptions[$key] ) ) {
				$mapping[$key] = 'registered-checkmatrix';
			} elseif ( substr( $key, 0, 7 ) === 'userjs-' ) {
				$mapping[$key] = 'userjs';
			} else {
				$mapping[$key] = 'unused';
			}
		}

		return $mapping;
	}
开发者ID:nahoj,项目名称:mediawiki_ynh,代码行数:71,代码来源:User.php

示例6: validate

 protected function validate(HTMLFormField $field, $submitted)
 {
     return $field->validate($submitted, [self::$defaultOptions['fieldname'] => $submitted]);
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:4,代码来源:HTMLCheckMatrixTest.php

示例7: validate

 /**
  * HTMLMultiSelectField throws validation errors if we get input data
  * that doesn't match the data set in the form setup. This causes
  * problems if something gets removed from the watchlist while the
  * form is open (bug 32126), but we know that invalid items will
  * be harmless so we can override it here.
  *
  * @param $value String the value the field was submitted with
  * @param $alldata Array the data collected from the form
  * @return Mixed Bool true on success, or String error to display.
  */
 function validate($value, $alldata)
 {
     // Need to call into grandparent to be a good citizen. :)
     return HTMLFormField::validate($value, $alldata);
 }
开发者ID:schwarer2006,项目名称:wikia,代码行数:16,代码来源:SpecialEditWatchlist.php

示例8: getRaw

 /**
  * @param string $value
  * @return string
  * @since 1.20
  */
 public function getRaw($value)
 {
     if (!empty($this->mParams['rawrow'])) {
         return $value;
     }
     return parent::getRaw($value);
 }
开发者ID:paladox,项目名称:mediawiki,代码行数:12,代码来源:HTMLInfoField.php

示例9: __construct

 /**
  * @param array $params
  */
 public function __construct($params)
 {
     parent::__construct($params);
     $this->msg = empty($params['licenses']) ? wfMessage('licenses')->inContentLanguage()->plain() : $params['licenses'];
     $this->selected = null;
     $this->makeLicenses();
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:10,代码来源:Licenses.php

示例10: __construct

 public function __construct($info)
 {
     $info['nodata'] = true;
     if (isset($info['flags'])) {
         $this->mFlags = $info['flags'];
     }
     # Generate the label from a message, if possible
     if (isset($info['buttonlabel-message'])) {
         $msgInfo = $info['buttonlabel-message'];
         if (is_array($msgInfo)) {
             $msg = array_shift($msgInfo);
         } else {
             $msg = $msgInfo;
             $msgInfo = array();
         }
         $this->buttonLabel = $this->msg($msg, $msgInfo)->parse();
     } elseif (isset($info['buttonlabel'])) {
         if ($info['buttonlabel'] === '&#160;') {
             // Apparently some things set &nbsp directly and in an odd format
             $this->buttonLabel = '&#160;';
         } else {
             $this->buttonLabel = htmlspecialchars($info['buttonlabel']);
         }
     } elseif (isset($info['buttonlabel-raw'])) {
         $this->buttonLabel = $info['buttonlabel-raw'];
     }
     parent::__construct($info);
 }
开发者ID:Kaph-Noir,项目名称:mediawiki,代码行数:28,代码来源:HTMLButtonField.php

示例11: __construct

 public function __construct($params)
 {
     parent::__construct($params);
     # Per HTML5 spec, hidden fields cannot be 'required'
     # http://www.w3.org/TR/html5/forms.html#hidden-state-%28type=hidden%29
     unset($this->mParams['required']);
 }
开发者ID:whysasse,项目名称:kmwiki,代码行数:7,代码来源:HTMLHiddenField.php

示例12: __construct

 public function __construct($params)
 {
     parent::__construct($params);
     # Per HTML5 spec, hidden fields cannot be 'required'
     # http://dev.w3.org/html5/spec/states-of-the-type-attribute.html#hidden-state
     unset($this->mParams['required']);
 }
开发者ID:Tarendai,项目名称:spring-website,代码行数:7,代码来源:HTMLHiddenField.php

示例13: __construct

 /**
  * Constructor
  *
  * @param $params array
  */
 public function __construct($params)
 {
     parent::__construct($params);
     $this->msg = empty($params['licenses']) ? wfMsg('licenses') : $params['licenses'];
     $this->selected = null;
     $this->makeLicenses();
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:12,代码来源:Licenses.php

示例14: __construct

 public function __construct($params)
 {
     parent::__construct($params);
     // For differentiating the type of form, mainly
     if (isset($params['prefix'])) {
         $this->prefix = $params['prefix'];
     }
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:8,代码来源:HTMLCaptchaField.php

示例15: getDiv

 function getDiv($value)
 {
     $this->tagFilter = ChangeTags::buildTagFilterSelector($value);
     if ($this->tagFilter) {
         return parent::getDiv($value);
     }
     return '';
 }
开发者ID:MediaWiki-stable,项目名称:1.26.1,代码行数:8,代码来源:HTMLTagFilter.php


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