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


PHP HTMLFormField::flattenOptions方法代码示例

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


在下文中一共展示了HTMLFormField::flattenOptions方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: validate

 function validate($value, $alldata)
 {
     $p = parent::validate($value, $alldata);
     if ($p !== true) {
         return $p;
     }
     if (!is_string($value) && !is_int($value)) {
         return false;
     }
     $validOptions = HTMLFormField::flattenOptions($this->mParams['options']);
     if (in_array($value, $validOptions)) {
         return true;
     } else {
         return $this->msg('htmlform-select-badoption')->parse();
     }
 }
开发者ID:h4ck3rm1k3,项目名称:mediawiki,代码行数:16,代码来源:HTMLForm.php

示例6: 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 IContextSource $context
  * @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();
     // Pull out the "special" options, so they don't get converted as
     // multiselect or checkmatrix.
     $specialOptions = array_fill_keys(Preferences::getSaveBlacklist(), true);
     foreach ($specialOptions as $name => $value) {
         unset($prefs[$name]);
     }
     // 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 (isset($specialOptions[$key])) {
             $mapping[$key] = 'special';
         } elseif (substr($key, 0, 7) === 'userjs-') {
             $mapping[$key] = 'userjs';
         } else {
             $mapping[$key] = 'unused';
         }
     }
     return $mapping;
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:71,代码来源:User.php

示例7: getInputHTML

 function getInputHTML($value)
 {
     $oldClass = $this->mClass;
     $this->mClass = (array) $this->mClass;
     $valInSelect = false;
     $ret = '';
     if ($this->getOptions()) {
         if ($value !== false) {
             $value = strval($value);
             $valInSelect = in_array($value, HTMLFormField::flattenOptions($this->getOptions()), true);
         }
         $selected = $valInSelect ? $value : 'other';
         $select = new XmlSelect($this->mName . '-select', $this->mID . '-select', $selected);
         $select->addOptions($this->getOptions());
         $select->setAttribute('class', 'mw-htmlform-select-or-other');
         if (!empty($this->mParams['disabled'])) {
             $select->setAttribute('disabled', 'disabled');
         }
         if (isset($this->mParams['tabindex'])) {
             $select->setAttribute('tabindex', $this->mParams['tabindex']);
         }
         $ret = $select->getHTML() . "<br />\n";
         $this->mClass[] = 'mw-htmlform-hide-if';
     }
     if ($valInSelect) {
         $value = '';
     } else {
         $key = array_search(strval($value), $this->autocomplete, true);
         if ($key !== false) {
             $value = $key;
         }
     }
     $this->mClass[] = 'mw-htmlform-autocomplete';
     $ret .= parent::getInputHTML($valInSelect ? '' : $value);
     $this->mClass = $oldClass;
     return $ret;
 }
开发者ID:jpena88,项目名称:mediawiki-dokku-deploy,代码行数:37,代码来源:HTMLAutoCompleteSelectField.php

示例8: filterDataForSubmit

 /**
  * @param $data array
  * @return array
  */
 function filterDataForSubmit($data)
 {
     // Support for separating MultiSelect preferences into multiple preferences
     // Due to lack of array support.
     foreach ($this->mFlatFields as $fieldname => $field) {
         $info = $field->mParams;
         if ($field instanceof HTMLMultiSelectField) {
             $options = HTMLFormField::flattenOptions($info['options']);
             $prefix = isset($info['prefix']) ? $info['prefix'] : $fieldname;
             foreach ($options as $opt) {
                 $data["{$prefix}{$opt}"] = in_array($opt, $data[$fieldname]);
             }
             unset($data[$fieldname]);
         }
     }
     return $data;
 }
开发者ID:eFFemeer,项目名称:seizamcore,代码行数:21,代码来源:Preferences.php

示例9: filterDataForSubmit

 function filterDataForSubmit($data)
 {
     $columns = HTMLFormField::flattenOptions($this->mParams['columns']);
     $rows = HTMLFormField::flattenOptions($this->mParams['rows']);
     $res = [];
     foreach ($columns as $column) {
         foreach ($rows as $row) {
             // Make sure option hasn't been forced
             $thisTag = "{$column}-{$row}";
             if ($this->isTagForcedOff($thisTag)) {
                 $res[$thisTag] = false;
             } elseif ($this->isTagForcedOn($thisTag)) {
                 $res[$thisTag] = true;
             } else {
                 $res[$thisTag] = in_array($thisTag, $data);
             }
         }
     }
     return $res;
 }
开发者ID:claudinec,项目名称:galan-wiki,代码行数:20,代码来源:HTMLCheckMatrix.php

示例10: filterDataForSubmit

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

示例11: 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

示例12: filterDataForSubmit

 /**
  * @param $data array
  * @return array
  */
 function filterDataForSubmit($data)
 {
     // Support for separating multi-option preferences into multiple preferences
     // Due to lack of array support.
     foreach ($this->mFlatFields as $fieldname => $field) {
         $info = $field->mParams;
         if ($field instanceof HTMLMultiSelectField) {
             $options = HTMLFormField::flattenOptions($info['options']);
             $prefix = isset($info['prefix']) ? $info['prefix'] : $fieldname;
             foreach ($options as $opt) {
                 $data["{$prefix}{$opt}"] = in_array($opt, $data[$fieldname]);
             }
             unset($data[$fieldname]);
         } elseif ($field instanceof HTMLCheckMatrix) {
             $columns = HTMLFormField::flattenOptions($info['columns']);
             $rows = HTMLFormField::flattenOptions($info['rows']);
             $prefix = isset($info['prefix']) ? $info['prefix'] : $fieldname;
             foreach ($columns as $column) {
                 foreach ($rows as $row) {
                     // Make sure option hasn't been removed
                     if (!isset($info['remove-options']) || !in_array("{$column}-{$row}", $info['remove-options'])) {
                         $data["{$prefix}-{$column}-{$row}"] = in_array("{$column}-{$row}", $data[$fieldname]);
                     }
                 }
             }
             unset($data[$fieldname]);
         }
     }
     return $data;
 }
开发者ID:Grprashanthkumar,项目名称:ColfusionWeb,代码行数:34,代码来源:Preferences.php


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