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


PHP GridField::getList方法代码示例

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


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

示例1: testSetAndGetList

 /**
  * @covers GridField::setList
  * @covers GridField::getList
  */
 public function testSetAndGetList()
 {
     $list = Member::get();
     $arrayList = ArrayList::create(array(1, 2, 3));
     $obj = new GridField('testfield', 'testfield', $list);
     $this->assertEquals($list, $obj->getList());
     $obj->setList($arrayList);
     $this->assertEquals($arrayList, $obj->getList());
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:13,代码来源:GridFieldTest.php

示例2: handleAction

 /**
  * Only delete record is supported.
  * Somehow this will not refresh the list, so we remove the item from the list as well
  */
 public function handleAction(GridField $gridField, $actionName, $arguments, $data)
 {
     if ($actionName == 'deleterecord') {
         $item = $gridField->getList()->byID($arguments['RecordID']);
         if (!$item) {
             return;
         }
         if (!$item->canDelete()) {
             throw new ValidationException(_t('GridFieldAction_Delete.DeletePermissionsFailure', "No delete permissions"), 0);
         }
         $item->delete();
         $gridField->getList()->remove($item);
     }
 }
开发者ID:helpfulrobot,项目名称:axyr-silverstripe-externaldata,代码行数:18,代码来源:ExternalDataGridFieldDeleteAction.php

示例3: handleAction

 /**
  * Handles the add action for the given DataObject.
  *
  * @param $gridField GridField
  * @param $actionName string
  * @param $arguments mixed
  * @param $data array
  *
  * @return null|SS_HTTPResponse
  *
  * @throws UnexpectedValueException
  */
 public function handleAction(GridField $gridField, $actionName, $arguments, $data)
 {
     if ($actionName == 'add') {
         $dbField = $this->getDataObjectField();
         $objClass = $gridField->getModelClass();
         /**
          * @var DataObject $obj
          */
         $obj = new $objClass();
         if ($obj->hasField($dbField)) {
             $obj->setCastedField($dbField, $data['gridfieldaddbydbfield'][$obj->ClassName][$dbField]);
             if ($obj->canCreate()) {
                 $id = $gridField->getList()->add($obj);
                 if (!$id) {
                     $gridField->setError(_t('GridFieldAddByDBField.AddFail', 'Unable to save {class} to the database.', 'Unable to add the DataObject.', array('class' => get_class($obj))), 'error');
                 }
             } else {
                 return Security::permissionFailure(Controller::curr(), _t('GridFieldAddByDBField.PermissionFail', 'You don\'t have permission to create a {class}.', 'Unable to add the DataObject.', array('class' => get_class($obj))));
             }
         } else {
             throw new UnexpectedValueException(sprintf('Invalid field (%s) on %s.', $dbField, $obj->ClassName));
         }
     }
     return null;
 }
开发者ID:sunnysideup,项目名称:silverstripe-blog,代码行数:37,代码来源:GridFieldAddByDBField.php

示例4: handleAction

 public function handleAction(\GridField $gridField, $actionName, $arguments, $data)
 {
     if ($actionName != $this->urlSegment) {
         return;
     }
     $record = $gridField->Form && $gridField->Form->Record ? $gridField->Form->Record : null;
     if (!$record || !$record->SiteTreeID) {
         throw new \ValidationException(_t('Link.NO_CURRENT_PAGE', 'No current page to draw from'), 0);
     }
     $root = \SiteTree::get()->filter('ParentID', $record->SiteTreeID);
     if (!$root->exists()) {
         throw new \ValidationException(_t('Link.NO_PAGES', 'No pages available'), 0);
     }
     $item = singleton($gridField->getModelClass());
     if (!$item->canCreate()) {
         throw new \ValidationException(_t('Link.CANNOT_CREATE', 'You cannot create a Link'), 0);
     }
     foreach ($root as $page) {
         $link = $item->create();
         $link->Type = 'SiteTree';
         $link->SiteTreeID = $page->ID;
         $link->write();
         $gridField->getList()->add($link);
     }
 }
开发者ID:milkyway-multimedia,项目名称:ss-linkable-menus,代码行数:25,代码来源:CopyChildrenFromCurrentPage.php

示例5: handleAction

 public function handleAction(GridField $gridField, $actionName, $arguments, $data)
 {
     if ($actionName == 'publishsummitevent') {
         $summit_event = $gridField->getList()->byID($arguments['RecordID']);
         $former_state = $summit_event->isPublished();
         $msg = 'Summit Event Published!';
         $code = 200;
         try {
             if ($former_state) {
                 $summit_event->unPublish();
             } else {
                 $summit_event->publish();
             }
             $summit_event->write();
             if ($former_state) {
                 $msg = 'Summit Event Unpublished!';
             }
         } catch (Exception $ex) {
             //SS_Log::log($ex->getMessage(). SS_Log::ERR);
             //throw new ValidationException($ex->getMessage(),0);
             //return sprintf('<div>%s</div>', $ex->getMessage());
             //Controller::curr()->getResponse()->setStatusCode($code,  $ex->getMessage());
             //Controller::curr()->getResponse()->setBody(sprintf('<div>%s</div>', $ex->getMessage()));
             throw new ValidationException($ex->getMessage(), 0);
         }
         Controller::curr()->getResponse()->setStatusCode($code, $msg);
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:28,代码来源:GridFieldPublishSummitEventAction.php

示例6: handleSave

 public function handleSave(GridField $grid, DataObjectInterface $record)
 {
     $list = $grid->getList();
     $value = $grid->Value();
     if (!isset($value[__CLASS__]) || !is_array($value[__CLASS__])) {
         // throw error ?
         return;
     }
     $updatedList = ArrayList::create();
     foreach ($value[__CLASS__] as $id => $v) {
         if (!is_numeric($id)) {
             continue;
         }
         $updatedList->push($id);
     }
     $list->exclude(['ID' => $updatedList->toArray()])->removeAll();
     foreach ($updatedList->toArray() as $i => $id) {
         // if list already contains item, leave it there
         if ($list->byID($id)) {
             continue;
         }
         $gridfieldItem = DataObject::get_by_id($list->dataClass, $id);
         if (!$gridfieldItem || !$gridfieldItem->canEdit()) {
             continue;
         }
         $list->add($gridfieldItem);
     }
 }
开发者ID:helpfulrobot,项目名称:danbroooks-gridfield-selectexisting,代码行数:28,代码来源:GridFieldSelectExisting.php

示例7: handleAction

 public function handleAction(GridField $gridField, $actionName, $arguments, $data)
 {
     if (!$this->checkDataType($gridField->getList())) {
         return;
     }
     if ($actionName === 'filter') {
         $gridField->State->UserFormsGridField = array('filter' => isset($data['FieldNameFilter']) ? $data['FieldNameFilter'] : null, 'value' => isset($data['FieldValue']) ? $data['FieldValue'] : null, 'start' => isset($data['StartFilter']) ? $data['StartFilter'] : null, 'end' => isset($data['EndFilter']) ? $data['EndFilter'] : null);
     }
 }
开发者ID:prostart,项目名称:erics-homes,代码行数:9,代码来源:UserFormsGridFieldFilterHeader.php

示例8: scaffoldLoader

 /**
  * Scaffold a bulk loader, if none is provided
  *
  * @param GridField $gridField
  * @return mixed
  */
 public function scaffoldLoader(GridField $gridField)
 {
     $gridlist = $gridField->getList();
     $class = $gridlist instanceof HasManyList ? "ListBulkLoader" : "BetterBulkLoader";
     //set the correct constructor argument
     $arg = $class === "ListBulkLoader" || is_subclass_of($class, "ListBulkLoader") ? $gridlist : $gridField->getModelClass();
     $loader = new $class($arg);
     $loader->setSource(new CsvBulkLoaderSource());
     return $loader;
 }
开发者ID:muskie9,项目名称:silverstripe-importexport,代码行数:16,代码来源:GridFieldImporter.php

示例9: handleAction

 public function handleAction(GridField $gridField, $actionName, $arguments, $data)
 {
     $item = $gridField->getList()->byID($arguments['RecordID']);
     if (!$item) {
         return;
     }
     if ($actionName == 'message') {
         $admin = new PostmarkAdmin();
         return $admin->MessageForm(null, $item->ID)->forTemplate();
     } elseif ($actionName == 'postmessage') {
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripers-silverstripe-postmarked,代码行数:12,代码来源:GridFieldPostmarkMessageButton.php

示例10: generateExportFileData

 /**
  * Generate export fields for CSV.
  *
  * @param GridField $gridField
  * @return array
  */
 public function generateExportFileData($gridField)
 {
     $separator = $this->csvSeparator;
     $singl = singleton($gridField->getModelClass());
     if ($singl->hasMethod('exportedFields')) {
         $fallbackColumns = $singl->exportedFields();
     } else {
         $fallbackColumns = $singl->summaryFields();
     }
     $csvColumns = $this->exportColumns ? $this->exportColumns : $fallbackColumns;
     $fileData = '';
     $columnData = array();
     $fieldItems = new ArrayList();
     if ($this->csvHasHeader) {
         $headers = array();
         // determine the CSV headers. If a field is callable (e.g. anonymous function) then use the
         // source name as the header instead
         foreach ($csvColumns as $columnSource => $columnHeader) {
             $headers[] = !is_string($columnHeader) && is_callable($columnHeader) ? utf8_decode($columnSource) : utf8_decode($columnHeader);
         }
         $fileData .= "\"" . implode("\"{$separator}\"", array_values($headers)) . "\"";
         $fileData .= "\n";
     }
     $items = $gridField->getList();
     foreach ($items as $item) {
         if (!$item->hasMethod('canView') || $item->canView()) {
             $columnData = array();
             foreach ($csvColumns as $columnSource => $columnHeader) {
                 if (!is_string($columnHeader) && is_callable($columnHeader)) {
                     if ($item->hasMethod($columnSource)) {
                         $relObj = $item->{$columnSource}();
                     } else {
                         $relObj = $item->relObject($columnSource);
                     }
                     $value = $columnHeader($relObj);
                 } else {
                     $value = $gridField->getDataFieldValue($item, $columnSource);
                     if (!$value) {
                         $value = $gridField->getDataFieldValue($item, $columnHeader);
                     }
                 }
                 $value = str_replace(array("\r", "\n"), "\n", $value);
                 $columnData[] = '"' . str_replace('"', '""', utf8_decode($value)) . '"';
             }
             $fileData .= implode($separator, $columnData);
             $fileData .= "\n";
         }
         if ($item->hasMethod('destroy')) {
             $item->destroy();
         }
     }
     return $fileData;
 }
开发者ID:helpfulrobot,项目名称:lekoala-silverstripe-form-extras,代码行数:59,代码来源:GridFieldExportAllButton.php

示例11: handleAction

 /**
  * Handle the actions and apply any changes to the GridField
  *
  * @param GridField $gridField
  * @param string $actionName
  * @param mixed $arguments
  * @param array $data - form data
  * @return void
  */
 public function handleAction(GridField $gridField, $actionName, $arguments, $data)
 {
     if ($actionName == 'deleterecord' || $actionName == 'unlinkrelation') {
         $item = $gridField->getList()->byID($arguments['RecordID']);
         if (!$item) {
             return;
         }
         if ($actionName == 'deleterecord' && !$item->canDelete()) {
             throw new ValidationException(_t('GridFieldAction_Delete.DeletePermissionsFailure', "No delete permissions"), 0);
         }
         $delete = false;
         if ($item->Pages()->Count() <= 1) {
             $delete = true;
         }
         $gridField->getList()->remove($item);
         //remove the relation
         if ($delete) {
             $item->delete();
         }
         //delete the DMSDocument
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-dms,代码行数:31,代码来源:DMSGridFieldDeleteAction.php

示例12: handleAction

 public function handleAction(GridField $gridField, $actionName, $arguments, $data)
 {
     if ($actionName == 'becomefoundationmember') {
         $member = $gridField->getList()->byID($arguments['RecordID']);
         $allowed = !$member->isFoundationMember();
         $msg = 'This user is already a Foundation Member!';
         if ($allowed) {
             $member->upgradeToFoundationMember();
             $msg = 'User is now a Foundation Member';
         }
         Controller::curr()->getResponse()->setStatusCode(200, $msg);
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:13,代码来源:SecurityAdminDecorator.php

示例13: handleAction

 public function handleAction(\GridField $gridField, $actionName, $arguments, $data)
 {
     $item = $gridField->getList()->byID($arguments['RecordID']);
     if (!$item) {
         return;
     }
     parent::handleAction($gridField, $actionName, $arguments, $data);
     $item->extend('onUnlinkFromGroup', $gridField);
     $group = $gridField->getForm()->getRecord();
     if ($group) {
         $group->updateGroupCache();
     }
 }
开发者ID:nyeholt,项目名称:silverstripe-restrictedobjects,代码行数:13,代码来源:RestrictedGroupExtension.php

示例14: doSearch

 /**
  * Returns a json array of a search results that can be used by for example Jquery.ui.autosuggestion
  *
  * @param GridField $gridField
  * @param SS_HTTPRequest $request 
  * @return sting in JSON fromat
  */
 public function doSearch($gridField, $request)
 {
     $dataClass = $gridField->getList()->dataClass();
     $allList = $this->searchList ? $this->searchList : DataList::create($dataClass);
     $searchFields = $this->getSearchFields() ? $this->getSearchFields() : $this->scaffoldSearchFields($dataClass);
     if (!$searchFields) {
         throw new LogicException(sprintf('GridFieldAddExistingAutocompleter: No searchable fields could be found for class "%s"', $dataClass));
     }
     // TODO Replace with DataList->filterAny() once it correctly supports OR connectives
     $stmts = array();
     foreach ($searchFields as $searchField) {
         $stmts[] .= sprintf('"%s" LIKE \'%s%%\'', $searchField, Convert::raw2sql($request->getVar('gridfield_relationsearch')));
     }
     $results = $allList->where(implode(' OR ', $stmts))->subtract($gridField->getList());
     $results = $results->sort($searchFields[0], 'ASC');
     $results = $results->limit($this->getResultsLimit());
     if (!empty($this->filters)) {
         $results = $results->addFilter($this->filters);
     }
     if (!empty($this->excludes)) {
         switch (count($this->excludes)) {
             case 1:
                 $key = key($this->excludes);
                 $results->exclude($key, $this->excludes[$key]);
                 break;
             case 2:
                 $results->exclude($this->excludes);
                 break;
             default:
                 throw new InvalidArgumentException('Incorrect number of arguments passed to filter()');
         }
     }
     $json = array();
     foreach ($results as $result) {
         $json[$result->ID] = SSViewer::fromString($this->resultsFormat)->process($result);
     }
     return Convert::array2json($json);
 }
开发者ID:tractorcow,项目名称:silverstripe-newsletter,代码行数:45,代码来源:GridFieldAutocompleterWithFilter.php

示例15: handleAction

	function handleAction(GridField $gridField, $actionName, $arguments, $data) {
		if(!$this->checkDataType($gridField->getList())) return;

		$state = $gridField->State->GridFieldFilterHeader;
		if($actionName === 'filter') {
			if(isset($data['filter'])){
				foreach($data['filter'] as $key => $filter ){
					$state->Columns->$key = $filter;
				}
			}
		} elseif($actionName === 'reset') {
			$state->Columns = null;
		}
	}
开发者ID:redema,项目名称:sapphire,代码行数:14,代码来源:GridFieldFilterHeader.php


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