Permalink
Browse files

Merge pull request #407 from normann/trac/7173

trac 7173, Add "level up" list entry to CMS page list view
  • Loading branch information...
2 parents 0a5616a + 7324712 commit 5f5197b4c1e69f016b0b51049f9a5c74e3b39c7d @sminnee sminnee committed May 7, 2012
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1,49 @@
+<?php
+
+class GridFieldLevelup implements GridField_HTMLProvider{
+ /**
+ * @var integer - the record id of the level up to
+ */
+ protected $levelID = null;
+
+ /**
+ *
+ * @param integer $levelID - the record id of the level up to
+ */
+ public function __construct($levelID = null) {
+ if($levelID && is_numeric($levelID)) {
+ $this->levelID = $levelID;
+ }
+ }
+
+ public function getHTMLFragments($gridField) {
+ $modelClass = $gridField->getModelClass();
+ if(isset($_GET['ParentID']) && $_GET['ParentID']){
+
+ $modelObj = DataObject::get_by_id($modelClass, $_GET['ParentID']);
+
+ if(is_callable(array($modelObj, 'getParent'))){
+ $levelup = $modelObj->getParent();
+ if(!$levelup){
+ $parentID = 0;
+ }else{
+ $parentID = $levelup->ID;
+ }
+ }
+ //$controller = $gridField->getForm()->Controller();
+ $forTemplate = new ArrayData(array(
+ 'UpLink' => sprintf(
+ '<a class="cms-panel-link list-parent-link" href="?ParentID=%d&view=list" data-target-panel="#Form_ListViewForm" data-pjax="ListViewForm">%s</a>',
+ $parentID,
+ _t('GridField.LEVELUP', 'Level up' )
+ ),
+ ));
+
+ return array(
+ 'before' => $forTemplate->renderWith('GridFieldLevelup'),
+ //'header' => $forTemplate->renderWith('GridFieldLevelup_Row'),
+ );
+ }
+ }
+}
+?>
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -76,6 +76,14 @@ $gf_grid_x: 16px;
}
.ss-gridfield {
+ .grid-levelup {
+ text-indent: -9999em;
+ a.list-parent-link{
+ background: transparent url(../images/gridfield-level-up.png) no-repeat 0 0;
+ display:block;
+ }
+ margin-bottom: 6px;
+ }
.add-existing-autocompleter {
input.relation-search {
width: 380px;
@@ -0,0 +1,3 @@
+<div class="grid-levelup">
+ $UpLink
+</div>

0 comments on commit 5f5197b

Please sign in to comment.