diff --git a/src/Components/FeatureComponent.php b/src/Components/FeatureComponent.php index 2a3a732..6468e96 100644 --- a/src/Components/FeatureComponent.php +++ b/src/Components/FeatureComponent.php @@ -99,6 +99,7 @@ class FeatureComponent extends BaseComponent 'ButtonLabel' => 'Varchar(128)', 'LinkHeading' => 'Boolean', 'LinkFeature' => 'Boolean', + 'LinkImage' => 'Boolean', 'ShowIcon' => 'Boolean', 'ShowImage' => 'Boolean', 'ShowHeader' => 'Boolean', @@ -135,6 +136,7 @@ class FeatureComponent extends BaseComponent private static $defaults = [ 'LinkFeature' => 0, 'LinkHeading' => 1, + 'LinkImage' => 0, 'ShowIcon' => 1, 'ShowImage' => 1, 'ShowHeader' => 1, @@ -149,7 +151,8 @@ class FeatureComponent extends BaseComponent * @config */ private static $casting = [ - 'SummaryText' => 'HTMLFragment' + 'SummaryText' => 'HTMLFragment', + 'ImageLinkAttributesHTML' => 'HTMLFragment' ]; /** @@ -315,6 +318,10 @@ public function getCMSFields() 'LinkFeature', $this->fieldLabel('LinkFeature') ), + CheckboxField::create( + 'LinkImage', + $this->fieldLabel('LinkImage') + ), TextField::create( 'ButtonLabel', $this->fieldLabel('ButtonLabel') @@ -352,6 +359,7 @@ public function fieldLabels($includerelations = true) $labels['ShowFooter'] = _t(__CLASS__ . '.SHOWFOOTER', 'Show footer'); $labels['LinkHeading'] = _t(__CLASS__ . '.LINKHEADING', 'Link heading'); $labels['LinkFeature'] = _t(__CLASS__ . '.LINKFEATURE', 'Link feature'); + $labels['LinkImage'] = _t(__CLASS__ . '.LINKIMAGE', 'Link image'); $labels['ButtonLabel'] = _t(__CLASS__ . '.BUTTONLABEL', 'Button label'); $labels['Heading'] = _t(__CLASS__ . '.HEADING', 'Heading'); $labels['SubHeading'] = _t(__CLASS__ . '.SUBHEADING', 'Sub-heading'); @@ -489,6 +497,33 @@ public function getLinkClassNames() return $classes; } + /** + * Answers an array of attributes for the image link element. + * + * @return array + */ + public function getImageLinkAttributes() + { + $attributes = [ + 'href' => $this->getLink(), + 'class' => 'image' + ]; + + $this->extend('updateImageLinkAttributes', $attributes); + + return $attributes; + } + + /** + * Answers a string of attributes for the image link element. + * + * @return string + */ + public function getImageLinkAttributesHTML() + { + return $this->getAttributesHTML($this->getImageLinkAttributes()); + } + /** * Answers the heading tag for the receiver. * @@ -623,6 +658,16 @@ public function getHeadingLinked() return ($this->LinkHeading && $this->hasLink() && !$this->LinkFeature); } + /** + * Answers true if the image is to be linked. + * + * @return boolean + */ + public function getImageLinked() + { + return ($this->LinkImage && $this->hasLink() && !$this->LinkFeature); + } + /** * Answers true if the summary is to be shown in the template. * @@ -651,7 +696,7 @@ public function getFooterShown() public function getSummaryText() { if ($this->Summary) { - return $this->Summary; + return $this->dbObject('Summary'); } if ($this->hasLinkPage()) { diff --git a/templates/SilverWare/Components/FeatureComponent/Includes/Image.ss b/templates/SilverWare/Components/FeatureComponent/Includes/Image.ss index e31d4f9..a8fb7c5 100644 --- a/templates/SilverWare/Components/FeatureComponent/Includes/Image.ss +++ b/templates/SilverWare/Components/FeatureComponent/Includes/Image.ss @@ -1,5 +1,7 @@ <% if $ImageShown %>