• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP ArrayLib类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: Field

 /**
  * Returns a readonly span containing the correct value.
  *
  * @param array $properties
  *
  * @return string
  */
 public function Field($properties = array())
 {
     $source = ArrayLib::flatten($this->getSource());
     $values = $this->getValueArray();
     // Get selected values
     $mapped = array();
     foreach ($values as $value) {
         if (isset($source[$value])) {
             $mapped[] = $source[$value];
         }
     }
     // Don't check if string arguments are matching against the source,
     // as they might be generated HTML diff views instead of the actual values
     if ($this->value && is_string($this->value) && empty($mapped)) {
         $mapped = array(trim($this->value));
         $values = array();
     }
     if ($mapped) {
         $attrValue = implode(', ', array_values($mapped));
         if (!$this->dontEscape) {
             $attrValue = Convert::raw2xml($attrValue);
         }
         $inputValue = implode(', ', array_values($values));
     } else {
         $attrValue = '<i>(' . _t('FormField.NONE', 'none') . ')</i>';
         $inputValue = '';
     }
     $properties = array_merge($properties, array('AttrValue' => $attrValue, 'InputValue' => $inputValue));
     return parent::Field($properties);
 }
开发者ID:assertchris,项目名称:silverstripe-framework,代码行数:37,代码来源:LookupField.php


示例2: getSearchContext

 public function getSearchContext()
 {
     $context = parent::getSearchContext();
     $categories = EmailTemplate::get()->column('Category');
     $context->getFields()->replaceField('q[Category]', new DropdownField('q[Category]', 'Category', ArrayLib::valuekey($categories)));
     return $context;
 }
开发者ID:philbenoit,项目名称:silverstripe-mandrill,代码行数:7,代码来源:EmailTemplatesAdmin.php


示例3: __construct

	/**
	 * Create a new DataObjectSet. If you pass one or more arguments, it will try to convert them into {@link ArrayData} objects. 
	 * @todo Does NOT automatically convert objects with complex datatypes (e.g. converting arrays within an objects to its own DataObjectSet)							
	 * 
	 * @param ViewableData|array|mixed $items Parameters to use in this set, either as an associative array, object with simple properties, or as multiple parameters.
	 */
	public function __construct($items = null) {
		if($items) {
			// if the first parameter is not an array, or we have more than one parameter, collate all parameters to an array
			// otherwise use the passed array
			$itemsArr = (!is_array($items) || count(func_get_args()) > 1) ? func_get_args() : $items;
			
			// We now have support for using the key of a data object set
			foreach($itemsArr as $i => $item) {
				if(is_subclass_of($item, 'ViewableData')) {
					$this->items[$i] = $item;
				} elseif(is_object($item) || ArrayLib::is_associative($item)) {
					$this->items[$i] = new ArrayData($item);
				} else {
					user_error(
						"DataObjectSet::__construct: Passed item #{$i} is not an object or associative array, 
						can't be properly iterated on in templates", 
						E_USER_WARNING
					);						
					$this->items[$i] = $item;
				}
			}

			
		}
		parent::__construct();
	}
开发者ID:neopba,项目名称:silverstripe-book,代码行数:32,代码来源:DataObjectSet.php


示例4: getField

 /**
  * Get a value from a given field
  *
  * @param string $f field key
  * @return mixed
  */
 public function getField($f)
 {
     if (is_object($this->array[$f]) && !$this->array[$f] instanceof ViewableData || is_array($this->array[$f]) && ArrayLib::is_associative($this->array[$f])) {
         return new ArrayData($this->array[$f]);
     }
     return $this->array[$f];
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:13,代码来源:ArrayData.php


示例5: __construct

	/**
	 * @deprecated 3.0
	 */
	public function __construct($items = array()) {
		Deprecation::notice('3.0', 'Use DataList or ArrayList instead');

		if ($items) {
			if (!is_array($items) || func_num_args() > 1) {
				$items = func_get_args();
			}

			foreach ($items as $i => $item) {
				if ($item instanceof ViewableData) {
					continue;
				}

				if (is_object($item) || ArrayLib::is_associative($item)) {
					$items[$i] = new ArrayData($item);
				} else {
					user_error(
						"DataObjectSet::__construct: Passed item #{$i} is not an"
						. ' and object or associative array, can\'t be properly'
						. ' iterated on in templates', E_USER_WARNING
					);
				}
			}
		}

		parent::__construct($items);
	}
开发者ID:redema,项目名称:sapphire,代码行数:30,代码来源:DataObjectSet.php


示例6: add

 /**
  * Add a mapping of nice short permalinks to a full long path
  *
  * <code>
  * DocumentationPermalinks::add(array(
  * 	'debugging' => 'current/en/sapphire/topics/debugging'
  * ));
  * </code>
  *
  * Do not need to include the language or the version current as it 
  * will add it based off the language or version in the session
  *
  * @param array
  */
 public static function add($map = array())
 {
     if (ArrayLib::is_associative($map)) {
         self::$mapping = array_merge(self::$mapping, $map);
     } else {
         user_error("DocumentationPermalinks::add() requires an associative array", E_USER_ERROR);
     }
 }
开发者ID:Jellygnite,项目名称:silverstripe-docsviewer,代码行数:22,代码来源:DocumentationPermalinks.php


示例7: testAncestry

 /**
  * @covers ClassInfo::ancestry()
  */
 public function testAncestry()
 {
     $ancestry = ClassInfo::ancestry('ClassInfoTest_ChildClass');
     $expect = ArrayLib::valuekey(array('Object', 'ViewableData', 'DataObject', 'ClassInfoTest_BaseClass', 'ClassInfoTest_ChildClass'));
     $this->assertEquals($expect, $ancestry);
     $ancestry = ClassInfo::ancestry('ClassInfoTest_ChildClass', true);
     $this->assertEquals(array('ClassInfoTest_BaseClass' => 'ClassInfoTest_BaseClass'), $ancestry, '$tablesOnly option excludes memory-only inheritance classes');
 }
开发者ID:fanggu,项目名称:loveyourwater_ss_v3.1.6,代码行数:11,代码来源:ClassInfoTest.php


示例8: getCMSFields

 public function getCMSFields()
 {
     $fields = FieldList::create(TabSet::create('Root'));
     $fields->addFieldsToTab('Root.Main', array(TextField::create('Title'), TextareaField::create('Description'), CurrencyField::create('PricePerNight', 'Price (per night)'), DropdownField::create('Bedrooms')->setSource(ArrayLib::valuekey(range(1, 10))), DropdownField::create('Bathrooms')->setSource(ArrayLib::valuekey(range(1, 10))), DropdownField::create('RegionID', 'Region')->setSource(Region::get()->map('ID', 'Title'))->setEmptyString('-- Select a region --'), CheckboxField::create('FeaturedOnHomepage', 'Feature on homepage')));
     $fields->addFieldToTab('Root.Photos', $upload = UploadField::create('PrimaryPhoto', 'Primary photo'));
     $upload->getValidator()->setAllowedExtensions(array('png', 'jpeg', 'jpg', 'gif'));
     $upload->setFolderName('property-photos');
     return $fields;
 }
开发者ID:sachithranuwan,项目名称:one-ring-rentals,代码行数:9,代码来源:Property.php


示例9: testFlatten

 public function testFlatten()
 {
     $options = array('1' => 'one', '2' => 'two');
     $expected = $options;
     $this->assertEquals($expected, ArrayLib::flatten($options));
     $options = array('1' => array('2' => 'two', '3' => 'three'), '4' => 'four');
     $expected = array('2' => 'two', '3' => 'three', '4' => 'four');
     $this->assertEquals($expected, ArrayLib::flatten($options));
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:9,代码来源:ArrayLibTest.php


示例10: generateColorPalette

 protected function generateColorPalette($fieldName, $paletteSetting)
 {
     $palette = $this->owner->config()->get($paletteSetting) ? $this->owner->config()->get($paletteSetting) : Config::inst()->get($this->class, $paletteSetting);
     $field = ColorPaletteField::create($fieldName, $this->owner->fieldLabel($fieldName), ArrayLib::valuekey($palette));
     if (Config::inst()->get($this->class, 'colors_can_be_empty')) {
         $field = $field->setEmptyString('none');
     }
     return $field;
 }
开发者ID:wernerkrauss,项目名称:silverstripe-onepage,代码行数:9,代码来源:OnePageSlide.php


示例11: direct

 /**
  * Process the given URL, creating the appropriate controller and executing it.
  * 
  * Request processing is handled as follows:
  *  - Director::direct() creates a new SS_HTTPResponse object and passes this to Director::handleRequest().
  *  - Director::handleRequest($request) checks each of the Director rules and identifies a controller to handle this 
  *    request.
  *  - Controller::handleRequest($request) is then called.  This will find a rule to handle the URL, and call the rule
  *    handling method.
  *  - RequestHandler::handleRequest($request) is recursively called whenever a rule handling method returns a
  *    RequestHandler object.
  *
  * In addition to request processing, Director will manage the session, and perform the output of the actual response
  * to the browser.
  * 
  * @param $url String, the URL the user is visiting, without the querystring.
  * @uses handleRequest() rule-lookup logic is handled by this.
  * @uses Controller::run() Controller::run() handles the page logic for a Director::direct() call.
  */
 static function direct($url)
 {
     // Validate $_FILES array before merging it with $_POST
     foreach ($_FILES as $k => $v) {
         if (is_array($v['tmp_name'])) {
             $v = ArrayLib::array_values_recursive($v['tmp_name']);
             foreach ($v as $tmpFile) {
                 if ($tmpFile && !is_uploaded_file($tmpFile)) {
                     user_error("File upload '{$k}' doesn't appear to be a valid upload", E_USER_ERROR);
                 }
             }
         } else {
             if ($v['tmp_name'] && !is_uploaded_file($v['tmp_name'])) {
                 user_error("File upload '{$k}' doesn't appear to be a valid upload", E_USER_ERROR);
             }
         }
     }
     $req = new SS_HTTPRequest(isset($_SERVER['X-HTTP-Method-Override']) ? $_SERVER['X-HTTP-Method-Override'] : $_SERVER['REQUEST_METHOD'], $url, $_GET, array_merge((array) $_POST, (array) $_FILES), @file_get_contents('php://input'));
     // @todo find better way to extract HTTP headers
     if (isset($_SERVER['HTTP_ACCEPT'])) {
         $req->addHeader("Accept", $_SERVER['HTTP_ACCEPT']);
     }
     if (isset($_SERVER['CONTENT_TYPE'])) {
         $req->addHeader("Content-Type", $_SERVER['CONTENT_TYPE']);
     }
     if (isset($_SERVER['HTTP_REFERER'])) {
         $req->addHeader("Referer", $_SERVER['HTTP_REFERER']);
     }
     // Load the session into the controller
     $session = new Session(isset($_SESSION) ? $_SESSION : null);
     $result = Director::handleRequest($req, $session);
     $session->inst_save();
     // Return code for a redirection request
     if (is_string($result) && substr($result, 0, 9) == 'redirect:') {
         $response = new SS_HTTPResponse();
         $response->redirect(substr($result, 9));
         $response->output();
         // Handle a controller
     } else {
         if ($result) {
             if ($result instanceof SS_HTTPResponse) {
                 $response = $result;
             } else {
                 $response = new SS_HTTPResponse();
                 $response->setBody($result);
             }
             // ?debug_memory=1 will output the number of bytes of memory used for this request
             if (isset($_REQUEST['debug_memory']) && $_REQUEST['debug_memory']) {
                 Debug::message(sprintf("Peak memory usage in bytes: %s", number_format(memory_get_peak_usage(), 0)));
             } else {
                 $response->output();
             }
             //$controllerObj->getSession()->inst_save();
         }
     }
 }
开发者ID:hamishcampbell,项目名称:silverstripe-sapphire,代码行数:75,代码来源:Director.php


示例12: direct

 /**
  * Process the given URL, creating the appropriate controller and executing it.
  * 
  * Request processing is handled as follows:
  *  - Director::direct() creates a new SS_HTTPResponse object and passes this to Director::handleRequest().
  *  - Director::handleRequest($request) checks each of the Director rules and identifies a controller to handle this 
  *    request.
  *  - Controller::handleRequest($request) is then called.  This will find a rule to handle the URL, and call the rule
  *    handling method.
  *  - RequestHandler::handleRequest($request) is recursively called whenever a rule handling method returns a
  *    RequestHandler object.
  *
  * In addition to request processing, Director will manage the session, and perform the output of the actual response
  * to the browser.
  * 
  * @param $url String, the URL the user is visiting, without the querystring.
  * @uses handleRequest() rule-lookup logic is handled by this.
  * @uses Controller::run() Controller::run() handles the page logic for a Director::direct() call.
  */
 static function direct($url, DataModel $model)
 {
     // Validate $_FILES array before merging it with $_POST
     foreach ($_FILES as $k => $v) {
         if (is_array($v['tmp_name'])) {
             $v = ArrayLib::array_values_recursive($v['tmp_name']);
             foreach ($v as $tmpFile) {
                 if ($tmpFile && !is_uploaded_file($tmpFile)) {
                     user_error("File upload '{$k}' doesn't appear to be a valid upload", E_USER_ERROR);
                 }
             }
         } else {
             if ($v['tmp_name'] && !is_uploaded_file($v['tmp_name'])) {
                 user_error("File upload '{$k}' doesn't appear to be a valid upload", E_USER_ERROR);
             }
         }
     }
     $req = new SS_HTTPRequest(isset($_SERVER['X-HTTP-Method-Override']) ? $_SERVER['X-HTTP-Method-Override'] : $_SERVER['REQUEST_METHOD'], $url, $_GET, array_merge((array) $_POST, (array) $_FILES), @file_get_contents('php://input'));
     // Load the request headers. If we're not running on Apache, then we
     // need to manually extract the headers from the $_SERVER array.
     if (function_exists('apache_request_headers')) {
         $headers = apache_request_headers();
     } else {
         $headers = self::extract_request_headers($_SERVER);
     }
     foreach ($headers as $header => $value) {
         $req->addHeader($header, $value);
     }
     // Load the session into the controller
     $session = new Session(isset($_SESSION) ? $_SESSION : null);
     $result = Director::handleRequest($req, $session, $model);
     $session->inst_save();
     // Return code for a redirection request
     if (is_string($result) && substr($result, 0, 9) == 'redirect:') {
         $response = new SS_HTTPResponse();
         $response->redirect(substr($result, 9));
         $response->output();
         // Handle a controller
     } else {
         if ($result) {
             if ($result instanceof SS_HTTPResponse) {
                 $response = $result;
             } else {
                 $response = new SS_HTTPResponse();
                 $response->setBody($result);
             }
             // ?debug_memory=1 will output the number of bytes of memory used for this request
             if (isset($_REQUEST['debug_memory']) && $_REQUEST['debug_memory']) {
                 Debug::message(sprintf("Peak memory usage in bytes: %s", number_format(memory_get_peak_usage(), 0)));
             } else {
                 $response->output();
             }
             //$controllerObj->getSession()->inst_save();
         }
     }
 }
开发者ID:rixrix,项目名称:sapphire,代码行数:75,代码来源:Director.php


示例13: FieldCurrency

 /**
  * @param string $name - Name of field
  * @return FormField
  */
 protected function FieldCurrency($name)
 {
     $allowedCurrencies = $this->getAllowedCurrencies();
     if ($allowedCurrencies) {
         $field = new DropdownField("{$name}[Currency]", _t('MoneyField.FIELDLABELCURRENCY', 'Currency'), ArrayLib::is_associative($allowedCurrencies) ? $allowedCurrencies : array_combine($allowedCurrencies, $allowedCurrencies));
     } else {
         $field = new TextField("{$name}[Currency]", _t('MoneyField.FIELDLABELCURRENCY', 'Currency'));
     }
     return $field;
 }
开发者ID:miamollie,项目名称:echoAerial,代码行数:14,代码来源:MoneyField.php


示例14: SearchForm

 /**
  * Update the SearchForm to use dropdown fields for MessageType/Status filters
  * @return Form
  **/
 public function SearchForm()
 {
     $form = parent::SearchForm();
     $fields = $form->Fields();
     $q = $this->getRequest()->requestVar('q');
     $fields->removeByName('q[MessageType]');
     $fields->push(DropdownField::create('q[MessageType]', 'Message Type', ArrayLib::valuekey(Config::inst()->get('TimedNotice', 'message_types')), isset($q['MessageType']) ? $q['MessageType'] : null)->setEmptyString(' '));
     $fields->push(DropdownField::create('q[Status]', 'Status', ArrayLib::valuekey(Config::inst()->get('TimedNotice', 'status_options')), isset($q['Status']) ? $q['Status'] : null)->setEmptyString(' '));
     return $form;
 }
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-timednotices,代码行数:14,代码来源:TimedNoticeAdmin.php


示例15: __construct

 /**
  * @param object|array $array Either an object with simple properties or an associative array.
  * Converts object-properties to indices of an associative array.
  */
 public function __construct($array)
 {
     if (is_object($array)) {
         $this->array = self::object_to_array($array);
     } elseif (is_array($array) && ArrayLib::is_associative($array)) {
         $this->array = $array;
     } else {
         $this->array = $array;
         user_error("ArrayData::__construct: Parameter needs to be an object or associative array", E_USER_WARNING);
     }
 }
开发者ID:ramziammar,项目名称:websites,代码行数:15,代码来源:ArrayData.php


示例16: getField

 /**
  * Gets a field from this object.
  *
  * @param string $field
  *
  * If the value is an object but not an instance of
  * ViewableData, it will be converted recursively to an
  * ArrayData.
  *
  * If the value is an associative array, it will likewise be
  * converted recursively to an ArrayData.
  */
 public function getField($f)
 {
     $value = $this->array[$f];
     if (is_object($value) && !$value instanceof ViewableData) {
         return new ArrayData($value);
     } elseif (ArrayLib::is_associative($value)) {
         return new ArrayData($value);
     } else {
         return $value;
     }
 }
开发者ID:prostart,项目名称:cobblestonepath,代码行数:23,代码来源:ArrayData.php


示例17: updateCMSFields

 public function updateCMSFields(FieldList $fields)
 {
     // if there are Models set in the Product Category then use a dropdown to select
     if ($this->owner->Parent && $this->owner->Parent->ProductModels()->count()) {
         $fields->replaceField('Model', DropdownField::create('Model', _t("Product.MODELREQUIRED", "Model (required)"), ArrayLib::valuekey($this->owner->Parent->ProductModels()->column('Title')))->setEmptyString(_t("Product.MODELSELECT", "Select..."))->setAttribute('Required', true));
     } else {
         // Update Model for extended length
         // see config.yml for updated db settings
         $model = $fields->dataFieldByName('Model');
         $model->setMaxLength(100);
     }
 }
开发者ID:antonythorpe,项目名称:silvershop-productmodel,代码行数:12,代码来源:ProductModelExtension.php


示例18: getCMSFields

 public function getCMSFields()
 {
     $fields = parent::getCMSFields();
     $fields->addFieldToTab('Root.Main', TreeDropdownField::create('SourceFolderID', 'Source folder', 'Folder'), 'Content');
     $fields->addFieldToTab('Root.Main', NumericField::create('ItemsPerPage', 'Items per page'), 'Content');
     $fileFields = singleton('File')->inheritedDatabaseFields();
     $fileFields = array_merge($fileFields, array('Created' => null, 'LastEdited' => null));
     $fileFields = ArrayLib::valuekey(array_keys($fileFields));
     $fields->addFieldToTab('Root.Main', DropdownField::create('FileSortBy', 'Sort files by', $fileFields), 'Content');
     $fields->addFieldToTab('Root.Main', DropdownField::create('FileSortDir', 'Sort direction', self::$sort_dirs_map), 'Content');
     return $fields;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-australia-intranet-sis,代码行数:12,代码来源:FileListingPage.php


示例19: buildCurrencyField

 /**
  * Builds a new currency field based on the allowed currencies configured
  *
  * @return FormField
  */
 protected function buildCurrencyField()
 {
     $name = $this->getName();
     $allowedCurrencies = $this->getAllowedCurrencies();
     if ($allowedCurrencies) {
         $field = new DropdownField("{$name}[Currency]", _t('MoneyField.FIELDLABELCURRENCY', 'Currency'), ArrayLib::is_associative($allowedCurrencies) ? $allowedCurrencies : array_combine($allowedCurrencies, $allowedCurrencies));
     } else {
         $field = new TextField("{$name}[Currency]", _t('MoneyField.FIELDLABELCURRENCY', 'Currency'));
     }
     $field->setReadonly($this->isReadonly());
     $field->setDisabled($this->isDisabled());
     return $field;
 }
开发者ID:jacobbuck,项目名称:silverstripe-framework,代码行数:18,代码来源:MoneyField.php


示例20: pageTypeOptions

 /**
  * Returns a sorted array suitable for a dropdown with pagetypes and their translated name.
  *
  * @return array
  */
 protected function pageTypeOptions()
 {
     $pageTypes = array();
     $classes = ArrayLib::valueKey(SiteTree::page_type_classes());
     unset($classes['VirtualPage']);
     unset($classes['ErrorPage']);
     unset($classes['RedirectorPage']);
     foreach ($classes as $pageTypeClass) {
         $pageTypes[$pageTypeClass] = singleton($pageTypeClass)->i18n_singular_name();
     }
     asort($pageTypes);
     return $pageTypes;
 }
开发者ID:anselmdk,项目名称:silverstripe-blocks,代码行数:18,代码来源:BlockSet.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ArrayList类代码示例发布时间:2022-05-23
下一篇:
PHP ArrayIterator类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap