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


PHP GridField::getName方法代码示例

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


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

示例1: handleAction

 public function handleAction(\GridField $gridField, $actionName, $arguments, $data)
 {
     $state = $gridField->State->Milkyway_SS_GridFieldUtils_RangeSlider;
     if ($actionName === 'filterbyrange') {
         if (isset($data['filterByRange'][$gridField->getName()][$this->filterField]['slider'])) {
             foreach ($data['filterByRange'][$gridField->getName()][$this->filterField]['slider'] as $key => $value) {
                 $state->{$key} = $value;
             }
         }
     }
 }
开发者ID:helpfulrobot,项目名称:milkyway-multimedia-ss-gridfield-utils,代码行数:11,代码来源:RangeSlider.php

示例2: handleAction

 public function handleAction(GridField $gridField, $actionName, $arguments, $data)
 {
     if (!$this->checkDataType($gridField->getList())) {
         return;
     }
     $state = $gridField->State->GridFieldFilterHeader;
     if ($actionName === 'filter') {
         if (isset($data['filter'][$gridField->getName()])) {
             foreach ($data['filter'][$gridField->getName()] as $key => $filter) {
                 $state->Columns->{$key} = $filter;
             }
         }
     } elseif ($actionName === 'reset') {
         $state->Columns = null;
     }
 }
开发者ID:ivoba,项目名称:silverstripe-framework,代码行数:16,代码来源:GridFieldFilterHeader.php

示例3: sortToPage

 /**
  * Handles sorting across pages
  * @param GridField $gridField Grid Field Reference
  * @param Array $data Data submitted in the request
  */
 protected function sortToPage(GridField $gridField, $data)
 {
     if (!($paginator = $gridField->getConfig()->getComponentsByType('GridFieldPaginator')->First())) {
         user_error('Paginator not detected', E_USER_ERROR);
     }
     if (empty($data['ItemID'])) {
         user_error('No item to sort', E_USER_ERROR);
     }
     if (empty($data['Target'])) {
         user_error('No target page', E_USER_ERROR);
     }
     $className = $gridField->getModelClass();
     $owner = $gridField->Form->getRecord();
     $items = clone $gridField->getList();
     $many_many = $items instanceof ManyManyList;
     $sortColumn = $this->sortColumn;
     $targetItem = $items->byID(intval($data['ItemID']));
     if (!$targetItem) {
         user_error('Target item not found', E_USER_ERROR);
     }
     $currentPage = 1;
     $pageState = $gridField->State->GridFieldPaginator;
     if ($pageState->currentPage && $pageState->currentPage > 1) {
         $currentPage = $pageState->currentPage;
     }
     if ($many_many) {
         list($parentClass, $componentClass, $parentField, $componentField, $table) = $owner->many_many($gridField->getName());
     }
     if ($data['Target'] == 'previouspage') {
         $items = $items->limit($paginator->getItemsPerPage() + 1, $paginator->getItemsPerPage() * ($currentPage - 1) - 1);
     } else {
         if ($data['Target'] == 'nextpage') {
             $items = $items->limit($paginator->getItemsPerPage() + 1, $paginator->getItemsPerPage() * ($currentPage - 1));
         } else {
             user_error('Not implemented: ' . $data['Target'], E_USER_ERROR);
         }
     }
     $sortPositions = $items->column($sortColumn);
     //Event to notify the Controller or owner DataObject before list sort
     if ($owner && $owner instanceof DataObject && method_exists($owner, 'onBeforeGridFieldPageSort')) {
         $owner->onBeforeGridFieldPageSort(clone $items);
     } else {
         if (Controller::has_curr() && Controller::curr() instanceof ModelAdmin && method_exists(Controller::curr(), 'onBeforeGridFieldPageSort')) {
             Controller::curr()->onBeforeGridFieldPageSort(clone $items);
         }
     }
     //Start transaction if supported
     if (DB::getConn()->supportsTransactions()) {
         DB::getConn()->transactionStart();
     }
     if ($data['Target'] == 'previouspage') {
         if ($many_many) {
             DB::query('UPDATE "' . $table . '" SET "' . $sortColumn . '" = ' . $sortPositions[0] . ' WHERE "' . $componentField . '" = ' . $targetItem->ID . ' AND "' . $parentField . '" = ' . $owner->ID);
         } else {
             $targetItem->{$sortColumn} = $sortPositions[0];
             $targetItem->write();
         }
         $i = 1;
         foreach ($items as $obj) {
             if ($obj->ID == $targetItem->ID) {
                 continue;
             }
             if ($many_many) {
                 DB::query('UPDATE "' . $table . '" SET "' . $sortColumn . '" = ' . $sortPositions[$i] . ' WHERE "' . $componentField . '" = ' . $obj->ID . ' AND "' . $parentField . '" = ' . $owner->ID);
             } else {
                 $obj->{$sortColumn} = $sortPositions[$i];
                 $obj->write();
             }
             $i++;
         }
     } else {
         if ($many_many) {
             DB::query('UPDATE "' . $table . '" SET "' . $sortColumn . '" = ' . $sortPositions[count($sortPositions) - 1] . ' WHERE "' . $componentField . '" = ' . $targetItem->ID . ' AND "' . $parentField . '" = ' . $owner->ID);
         } else {
             $targetItem->{$sortColumn} = $sortPositions[count($sortPositions) - 1];
             $targetItem->write();
         }
         $i = 0;
         foreach ($items as $obj) {
             if ($obj->ID == $targetItem->ID) {
                 continue;
             }
             if ($many_many) {
                 DB::query('UPDATE "' . $table . '" SET "' . $sortColumn . '" = ' . $sortPositions[$i] . ' WHERE "' . $componentField . '" = ' . $obj->ID . ' AND "' . $parentField . '" = ' . $owner->ID);
             } else {
                 $obj->{$sortColumn} = $sortPositions[$i];
                 $obj->write();
             }
             $i++;
         }
     }
     //End transaction if supported
     if (DB::getConn()->supportsTransactions()) {
         DB::getConn()->transactionEnd();
     }
//.........这里部分代码省略.........
开发者ID:helpfulrobot,项目名称:maldicore-sortablegridfield,代码行数:101,代码来源:GridFieldSortableRows.php

示例4: getFieldName

 protected function getFieldName($name, GridField $grid, DataObjectInterface $record)
 {
     return sprintf('%s[%s][%s][%s]', $grid->getName(), __CLASS__, $record->ID, $name);
 }
开发者ID:ajshort,项目名称:silverstripe-gridfieldextensions,代码行数:4,代码来源:GridFieldEditableColumns.php

示例5: getColumnContent

 /**
  * HTML for the column, content of the <td> element.
  *
  * @param  \GridField $gridField
  * @param  \DataObject $record - Record displayed in this row
  * @param  string $columnName
  *
  * @return string - HTML for the column. Return NULL to skip.
  */
 public function getColumnContent($gridField, $record, $columnName)
 {
     $value = $gridField && $gridField->Form && $gridField->Form->Record ? $gridField->Form->Record->{$this->relation . 'ID'} : '';
     return $record->ID ? _t('GridField_HasOneSelector.SELECTOR', '<input type="radio" name="{name}" value="{value}"{selected}/>', ['name' => sprintf('%s[%s]', $gridField->getName(), str_replace('\\', '_', __CLASS__)), 'value' => $record->ID, 'selected' => $value == $record->ID ? ' checked="checked"' : '']) : '';
 }
开发者ID:helpfulrobot,项目名称:milkyway-multimedia-ss-gridfield-utils,代码行数:14,代码来源:HasOneSelector.php

示例6: handleReorder

 /**
  * Handles requests to reorder a set of IDs in a specific order.
  *
  * @param GridField $grid
  * @param SS_HTTPRequest $request
  * @return SS_HTTPResponse
  */
 public function handleReorder($grid, $request)
 {
     if (!$this->immediateUpdate) {
         $this->httpError(400);
     }
     $list = $grid->getList();
     $modelClass = $grid->getModelClass();
     if ($list instanceof ManyManyList && !singleton($modelClass)->canView()) {
         $this->httpError(403);
     } else {
         if (!$list instanceof ManyManyList && !singleton($modelClass)->canEdit()) {
             $this->httpError(403);
         }
     }
     // Save any un-committed changes to the gridfield
     if (($form = $grid->getForm()) && ($record = $form->getRecord())) {
         $form->loadDataFrom($request->requestVars(), true);
         $grid->saveInto($record);
     }
     // Get records from the `GridFieldEditableColumns` column
     $data = $request->postVar($grid->getName());
     $sortedIDs = $this->getSortedIDs($data);
     if (!$this->executeReorder($grid, $sortedIDs)) {
         $this->httpError(400);
     }
     Controller::curr()->getResponse()->addHeader('X-Status', rawurlencode('Records reordered.'));
     return $grid->FieldHolder();
 }
开发者ID:ajshort,项目名称:silverstripe-gridfieldextensions,代码行数:35,代码来源:GridFieldOrderableRows.php

示例7: getNameFromParent

 /**
  * Calculate the name of the gridfield relative to the Form
  *
  * @param GridField $base Base GridField
  * 
  * @return string
  */
 protected function getNameFromParent($base)
 {
     $name = array();
     do {
         array_unshift($name, $base->getName());
         $base = $base->getForm();
     } while ($base && !$base instanceof Form);
     return implode('.', $name);
 }
开发者ID:silvercart,项目名称:silvercart,代码行数:16,代码来源:SilvercartGridFieldSubObjectHandler.php


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