Source of file PublishableGridFieldConfig.php
Size: 7,347 Bytes - Last Modified: 2021-12-23T10:38:26+00:00
/var/www/docs.ssmods.com/process/src/code/forms/gridfield/PublishableGridFieldConfig.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186 | <?php /** * PublishableGridFieldConfig. * * @author Tom Densham <tom.densham@studiobonito.co.uk> * @copyright (c) 2012, Studio Bonito Ltd. * @version 1.0 */ class PublishableGridFieldConfig extends GridFieldConfig { } /** * PublishableGridFieldConfig_Base. * * @author Tom Densham <tom.densham@studiobonito.co.uk> * @copyright (c) 2012, Studio Bonito Ltd. * @version 1.0 */ class PublishableGridFieldConfig_Base extends PublishableGridFieldConfig { /** * * @param int $itemsPerPage - How many items per page should show up */ public function __construct($itemsPerPage = null, $currentStage = 'Latest') { $this->addComponent(new PublishableGridFieldStage($currentStage)); $this->addComponent(new GridFieldButtonRow('before')); $this->addComponent(new GridFieldToolbarHeader()); $this->addComponent($sort = new GridFieldSortableHeader()); $this->addComponent($filter = new GridFieldFilterHeader()); $this->addComponent($columns = new GridFieldDataColumns()); $this->addComponent(new GridFieldPageCount('toolbar-header-right')); $this->addComponent($pagination = new GridFieldPaginator($itemsPerPage)); $sort->setThrowExceptionOnBadDataType(false); $filter->setThrowExceptionOnBadDataType(false); $pagination->setThrowExceptionOnBadDataType(false); $columns->setFieldFormatting(array( 'Title' => function($value, &$item) { $badge = array(); if ($item->ExistsOnLive && $item->IsModifiedOnStage) { $badge['class'] = 'modified'; $badge['title'] = _t('PublishableGridFieldStatusColumns.ModifiedStage', 'Modified'); } elseif ($item->IsAddedToStage) { $badge['class'] = 'addedtodraft'; $badge['title'] = _t('PublishableGridFieldStatusColumns.Stage', 'Draft'); } $return = $item->Title; if(isset($badge['class']) && isset($badge['title'])) { $return .= sprintf( "<span class=\"badge %s\">%s</span>", 'status-' . Convert::raw2xml($badge['class']), Convert::raw2xml($badge['title']) ); } return $return; } )); } } /** * PublishableGridFieldConfig_RecordViewer. * * @author Tom Densham <tom.densham@studiobonito.co.uk> * @copyright (c) 2012, Studio Bonito Ltd. * @version 1.0 */ class PublishableGridFieldConfig_RecordViewer extends PublishableGridFieldConfig { /** * * @param int $itemsPerPage - How many items per page should show up */ public function __construct($itemsPerPage = null, $currentStage = 'Latest') { $this->addComponent(new PublishableGridFieldStage($currentStage)); $this->addComponent(new GridFieldButtonRow('before')); $this->addComponent(new GridFieldAddNewButton('buttons-before-left')); $this->addComponent(new GridFieldToolbarHeader()); $this->addComponent($sort = new GridFieldSortableHeader()); $this->addComponent($filter = new GridFieldFilterHeader()); $this->addComponent($columns = new GridFieldDataColumns()); $this->addComponent(new PublishableGridFieldViewButton()); $this->addComponent(new GridFieldPageCount('toolbar-header-right')); $this->addComponent($pagination = new GridFieldPaginator($itemsPerPage)); $this->addComponent(new PublishableGridFieldDetailForm()); $sort->setThrowExceptionOnBadDataType(false); $filter->setThrowExceptionOnBadDataType(false); $pagination->setThrowExceptionOnBadDataType(false); $columns->setFieldFormatting(array( 'Title' => function($value, &$item) { $badge = array(); if ($item->ExistsOnLive && $item->IsModifiedOnStage) { $badge['class'] = 'modified'; $badge['title'] = _t('PublishableGridFieldStatusColumns.ModifiedStage', 'Modified'); } elseif ($item->IsAddedToStage) { $badge['class'] = 'addedtodraft'; $badge['title'] = _t('PublishableGridFieldStatusColumns.Stage', 'Draft'); } $return = $item->Title; if(isset($badge['class']) && isset($badge['title'])) { $return .= sprintf( "<span class=\"badge %s\">%s</span>", 'status-' . Convert::raw2xml($badge['class']), Convert::raw2xml($badge['title']) ); } return $return; } )); } } /** * PublishableGridFieldConfig_RecordEditor. * * @author Tom Densham <tom.densham@studiobonito.co.uk> * @copyright (c) 2012, Studio Bonito Ltd. * @version 1.0 */ class PublishableGridFieldConfig_RecordEditor extends PublishableGridFieldConfig { /** * * @param int $itemsPerPage - How many items per page should show up */ public function __construct($itemsPerPage = null, $currentStage = 'Latest') { $this->addComponent(new PublishableGridFieldStage($currentStage)); $this->addComponent(new GridFieldButtonRow('before')); $this->addComponent(new GridFieldAddNewButton('buttons-before-left')); $this->addComponent(new GridFieldToolbarHeader()); $this->addComponent($sort = new GridFieldSortableHeader()); $this->addComponent($filter = new GridFieldFilterHeader()); $this->addComponent($columns = new GridFieldDataColumns()); $this->addComponent(new PublishableGridFieldDeleteAction()); $this->addComponent(new PublishableGridFieldPublishAction()); $this->addComponent(new PublishableGridFieldEditButton()); $this->addComponent(new GridFieldPageCount('toolbar-header-right')); $this->addComponent($pagination = new GridFieldPaginator($itemsPerPage)); $this->addComponent(new PublishableGridFieldDetailForm()); $sort->setThrowExceptionOnBadDataType(false); $filter->setThrowExceptionOnBadDataType(false); $pagination->setThrowExceptionOnBadDataType(false); $columns->setFieldFormatting(array( 'Title' => function($value, &$item) { $badge = array(); if ($item->ExistsOnLive && $item->IsModifiedOnStage) { $badge['class'] = 'modified'; $badge['title'] = _t('PublishableGridFieldStatusColumns.ModifiedStage', 'Modified'); } elseif ($item->IsAddedToStage) { $badge['class'] = 'addedtodraft'; $badge['title'] = _t('PublishableGridFieldStatusColumns.Stage', 'Draft'); } $return = $item->Title; if(isset($badge['class']) && isset($badge['title'])) { $return .= sprintf( "<span class=\"badge %s\">%s</span>", 'status-' . Convert::raw2xml($badge['class']), Convert::raw2xml($badge['title']) ); } return $return; } )); } } |