From 8f10ed4924ed530b033e7db2859bc2f4ad37e466 Mon Sep 17 00:00:00 2001 From: ajshort Date: Sat, 16 Feb 2013 22:59:29 +1100 Subject: [PATCH] Make the title and fragment configurable. --- code/GridFieldAddExistingSearchButton.php | 31 +++++++++++++++++++ templates/GridFieldAddExistingSearchButton.ss | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/code/GridFieldAddExistingSearchButton.php b/code/GridFieldAddExistingSearchButton.php index b221386..4d3b175 100644 --- a/code/GridFieldAddExistingSearchButton.php +++ b/code/GridFieldAddExistingSearchButton.php @@ -7,6 +7,7 @@ class GridFieldAddExistingSearchButton implements GridField_HTMLProvider, GridField_URLHandler { + protected $title; protected $fragment; /** @@ -14,12 +15,42 @@ class GridFieldAddExistingSearchButton implements */ public function __construct($fragment = 'buttons-before-left') { $this->fragment = $fragment; + $this->title = _t('GridFieldExtensions.ADDEXISTING', 'Add Existing'); + } + + /** + * @return string + */ + public function getTitle() { + return $this->title; + } + + /** + * @param string $title + */ + public function setTitle($title) { + $this->title = $title; + } + + /** + * @return string + */ + public function getFragment() { + return $this->fragment; + } + + /** + * @param string $fragment + */ + public function setFragment($fragment) { + $this->fragment = $fragment; } public function getHTMLFragments($grid) { GridFieldExtensions::include_requirements(); $data = new ArrayData(array( + 'Title' => $this->getTitle(), 'Link' => $grid->Link('add-existing-search') )); diff --git a/templates/GridFieldAddExistingSearchButton.ss b/templates/GridFieldAddExistingSearchButton.ss index c06cb01..1a3a28d 100644 --- a/templates/GridFieldAddExistingSearchButton.ss +++ b/templates/GridFieldAddExistingSearchButton.ss @@ -1,3 +1,3 @@ - <% _t("ADDEXISTING", "Add Existing") %> + $Title