本文整理汇总了PHP中SS_List::toArray方法的典型用法代码示例。如果您正苦于以下问题:PHP SS_List::toArray方法的具体用法?PHP SS_List::toArray怎么用?PHP SS_List::toArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SS_List
的用法示例。
在下文中一共展示了SS_List::toArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: to_autocomplete_array
/**
* @param SS_List $scope the scope to iterate over - handy if you don't want
* to add this extension for a one-off use
* @return array
*/
public static function to_autocomplete_array($scope)
{
$items = $scope->toArray();
foreach ($items as &$item) {
if ($item->hasMethod('toAutocompleteMap')) {
$item = $item->toAutocompleteMap();
} else {
$item = $item->toMap();
}
}
return $items;
}
示例2: run
public function run(SS_List $pages)
{
// Sort pages by depth
$pageArray = $pages->toArray();
// because of https://bugs.php.net/bug.php?id=50688
foreach ($pageArray as $page) {
$page->getPageLevel();
}
usort($pageArray, function ($a, $b) {
return $a->getPageLevel() - $b->getPageLevel();
});
$pages = new ArrayList($pageArray);
// Restore
return $this->batchaction($pages, 'doRestoreToStage', _t('CMSBatchActions.RESTORED_PAGES', 'Restored %d pages'));
}
示例3: get_map
/**
* Creates a new {@link GoogleMapsAPI} object loaded with the default settings
* and places all of the items in a {@link SS_List}
* e.g. {@link DataList} or {@link ArrayList} on the map
*
* @param SS_List $set
* @return MapAPI
*/
public static function get_map(SS_List $list)
{
$gmap = self::instance();
if ($list) {
$arr = $list->toArray();
foreach ($arr as $mappable) {
if ($mappable->MapPinEdited) {
$gmap->addMarkerAsObject($mappable);
}
}
}
return $gmap;
}
示例4: toArray
public function toArray($index = null)
{
return $this->list->toArray($index);
}
示例5: prepareForRender
/**
* Prepares everything just before rendering the field
*/
protected function prepareForRender()
{
if (!$this->preparedForRender) {
$this->preparedForRender = true;
if (!$this->isReadonly() && $this->depth == 1) {
// NOTE(Jake): jQuery.ondemand is required to allow FormField classes to add their own
// Requirements::javascript on-the-fly.
//Requirements::javascript(FRAMEWORK_DIR . "/thirdparty/jquery/jquery.js");
Requirements::css(MULTIRECORDEDITOR_DIR . '/css/MultiRecordField.css');
if (is_subclass_of(Controller::curr(), 'LeftAndMain')) {
// NOTE(Jake): Only include in CMS to fix margin issues. Not in the main CSS file
// so that the frontend CSS is less in the way.
Requirements::css(MULTIRECORDEDITOR_DIR . '/css/MultiRecordFieldCMS.css');
}
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/smoothness/jquery-ui.css');
Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery-ui/jquery-ui.js');
Requirements::javascript(FRAMEWORK_DIR . '/javascript/jquery-ondemand/jquery.ondemand.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-entwine/dist/jquery.entwine-dist.js');
Requirements::javascript(MULTIRECORDEDITOR_DIR . '/javascript/MultiRecordField.js');
// If config is set to 'default' but 'default' isn't configured, fallback to 'cms'.
// NOTE(Jake): In SS 3.2, 'default' is the default active config but its not configured.
$availableConfigs = HtmlEditorConfig::get_available_configs_map();
$activeIdentifier = HtmlEditorConfig::get_active_identifier();
if ($activeIdentifier === 'default' && !isset($availableConfigs[$activeIdentifier])) {
HtmlEditorConfig::set_active('cms');
}
}
//
// Setup actions
//
$actions = $this->Actions();
if ($actions && $actions->count()) {
$modelClasses = $this->getModelClassesOrThrowExceptionIfEmpty();
$modelFirstClass = key($modelClasses);
$inlineAddButton = $actions->dataFieldByName('action_AddInlineRecord');
if ($inlineAddButton) {
// Setup default inline field data attributes
//$inlineAddButton->setAttribute('data-name', $this->getName());
$inlineAddButton->setAttribute('data-action', $this->getName());
$inlineAddButton->setAttribute('data-class', $modelFirstClass);
$inlineAddButton->setAttribute('data-depth', $this->depth);
// Automatically apply all data attributes on this element, to the inline button.
foreach ($this->getAttributes() as $name => $value) {
if (substr($name, 0, 5) === 'data-') {
$inlineAddButton->setAttribute($name, $value);
}
}
if (count($modelClasses) == 1) {
$name = singleton($modelFirstClass)->i18n_singular_name();
$inlineAddButton->setTitle('Add ' . $name);
}
}
$classField = $actions->dataFieldByName('ClassName');
if ($classField) {
if (count($modelClasses) > 1) {
if ($inlineAddButton) {
$inlineAddButton->setDisabled(true);
}
$classField->setSource($modelClasses);
} else {
$actions->removeByName('ClassName');
}
}
// Allow outside sources to influences the disable state class-wise
if ($inlineAddButton && $inlineAddButton->isDisabled()) {
$inlineAddButton->addExtraClass('is-disabled');
}
//
foreach ($actions as $actionField) {
// Expand out names
$actionField->setName($this->getName() . '_' . $actionField->getName());
}
}
// Get existing records to add fields for
$recordArray = array();
if ($this->list && !$this->list instanceof UnsavedRelationList) {
foreach ($this->list->toArray() as $record) {
$recordArray[$record->ID] = $record;
}
}
//
// If the user validation failed, Value() will be populated with some records
// that have 'new_' IDs, so handle them.
//
$value = $this->Value();
if ($value && is_array($value)) {
foreach ($value as $class => $recordDatas) {
foreach ($recordDatas as $new_id => $fieldData) {
if (substr($new_id, 0, 4) === 'new_') {
$record = $class::create();
$record->MultiRecordField_NewID = $new_id;
$recordArray[$new_id] = $record;
} else {
if ($new_id == (string) (int) $new_id) {
// NOTE(Jake): "o-multirecordediting-1-id" == 0 // evaluates true in PHP 5.5.12,
// So we need to make it a string again to avoid that dumb case.
$new_id = (int) $new_id;
//.........这里部分代码省略.........