@@ -11,120 +11,120 @@ |
||
| 11 | 11 | |
| 12 | 12 | class Quicklink extends DataObject |
| 13 | 13 | { |
| 14 | - private static $db = [ |
|
| 15 | - 'Name' => 'Varchar(255)', |
|
| 16 | - 'ExternalLink' => 'Varchar(255)', |
|
| 17 | - 'SortOrder' => 'Int', |
|
| 18 | - ]; |
|
| 19 | - |
|
| 20 | - private static $has_one = [ |
|
| 21 | - 'Parent' => BaseHomePage::class, |
|
| 22 | - 'InternalLink' => SiteTree::class, |
|
| 23 | - ]; |
|
| 24 | - |
|
| 25 | - private static $summary_fields = [ |
|
| 26 | - 'Name' => 'Name', |
|
| 27 | - 'InternalLink.Title' => 'Internal Link', |
|
| 28 | - 'ExternalLink' => 'External Link', |
|
| 29 | - ]; |
|
| 30 | - |
|
| 31 | - private static $table_name = 'Quicklink'; |
|
| 32 | - |
|
| 33 | - public function fieldLabels($includerelations = true) |
|
| 34 | - { |
|
| 35 | - $labels = parent::fieldLabels($includerelations); |
|
| 36 | - $labels['Name'] = _t(__CLASS__ . '.NameLabel', 'Name'); |
|
| 37 | - $labels['ExternalLink'] = _t(__CLASS__ . '.ExternalLinkLabel', 'External Link'); |
|
| 38 | - $labels['SortOrder'] = _t(__CLASS__ . '.SortOrderLabel', 'Sort Order'); |
|
| 39 | - $labels['ParentID'] = _t(__CLASS__ . '.ParentRelationLabel', 'Parent'); |
|
| 40 | - $labels['InternalLinkID'] = _t(__CLASS__ . '.InternalLinkLabel', 'Internal Link'); |
|
| 41 | - |
|
| 42 | - return $labels; |
|
| 43 | - } |
|
| 44 | - |
|
| 45 | - public function getLink() |
|
| 46 | - { |
|
| 47 | - if ($this->ExternalLink) { |
|
| 48 | - $url = parse_url($this->ExternalLink); |
|
| 49 | - |
|
| 50 | - // if no scheme set in the link, default to http |
|
| 51 | - if (!isset($url['scheme'])) { |
|
| 52 | - return 'http://' . $this->ExternalLink; |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - return $this->ExternalLink; |
|
| 56 | - } elseif ($this->InternalLinkID) { |
|
| 57 | - return $this->InternalLink()->Link(); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - public function canCreate($member = null, $context = []) |
|
| 62 | - { |
|
| 63 | - return $this->Parent()->canCreate($member, $context); |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - public function canEdit($member = null) |
|
| 67 | - { |
|
| 68 | - return $this->Parent()->canEdit($member); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - public function canDelete($member = null) |
|
| 72 | - { |
|
| 73 | - return $this->Parent()->canDelete($member); |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - public function canView($member = null) |
|
| 77 | - { |
|
| 78 | - return $this->Parent()->canView($member); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - public function getCMSFields() |
|
| 82 | - { |
|
| 83 | - $fields = parent::getCMSFields(); |
|
| 84 | - |
|
| 85 | - $fields->removeByName('ParentID'); |
|
| 86 | - |
|
| 87 | - $externalLinkField = $fields->fieldByName('Root.Main.ExternalLink'); |
|
| 88 | - |
|
| 89 | - $fields->removeByName('ExternalLink'); |
|
| 90 | - $fields->removeByName('InternalLinkID'); |
|
| 91 | - $fields->removeByName('SortOrder'); |
|
| 92 | - $externalLinkField->addExtraClass('noBorder'); |
|
| 93 | - |
|
| 94 | - $fields->addFieldToTab('Root.Main', CompositeField::create( |
|
| 95 | - array( |
|
| 96 | - TreeDropdownField::create( |
|
| 97 | - 'InternalLinkID', |
|
| 98 | - $this->fieldLabel('InternalLinkID'), |
|
| 99 | - SiteTree::class |
|
| 100 | - ), |
|
| 101 | - $externalLinkField, |
|
| 102 | - $wrap = CompositeField::create( |
|
| 103 | - $extraLabel = LiteralField::create( |
|
| 104 | - 'NoteOverride', |
|
| 105 | - _t( |
|
| 106 | - __CLASS__ . '.Note', |
|
| 107 | - // @todo remove the HTML from this translation |
|
| 108 | - '<div class="message good notice">Note: If you specify an External Link, ' |
|
| 109 | - . 'the Internal Link will be ignored.</div>' |
|
| 110 | - ) |
|
| 111 | - ) |
|
| 112 | - ) |
|
| 113 | - ) |
|
| 114 | - )); |
|
| 115 | - $fields->insertBefore( |
|
| 116 | - 'Name', |
|
| 117 | - LiteralField::create( |
|
| 118 | - 'Note', |
|
| 119 | - _t( |
|
| 120 | - __CLASS__ . '.Note2', |
|
| 121 | - // @todo remove the HTML from this translation |
|
| 122 | - '<p>Use this to specify a link to a page either on this site ' |
|
| 123 | - . '(Internal Link) or another site (External Link).</p>' |
|
| 124 | - ) |
|
| 125 | - ) |
|
| 126 | - ); |
|
| 127 | - |
|
| 128 | - return $fields; |
|
| 129 | - } |
|
| 14 | + private static $db = [ |
|
| 15 | + 'Name' => 'Varchar(255)', |
|
| 16 | + 'ExternalLink' => 'Varchar(255)', |
|
| 17 | + 'SortOrder' => 'Int', |
|
| 18 | + ]; |
|
| 19 | + |
|
| 20 | + private static $has_one = [ |
|
| 21 | + 'Parent' => BaseHomePage::class, |
|
| 22 | + 'InternalLink' => SiteTree::class, |
|
| 23 | + ]; |
|
| 24 | + |
|
| 25 | + private static $summary_fields = [ |
|
| 26 | + 'Name' => 'Name', |
|
| 27 | + 'InternalLink.Title' => 'Internal Link', |
|
| 28 | + 'ExternalLink' => 'External Link', |
|
| 29 | + ]; |
|
| 30 | + |
|
| 31 | + private static $table_name = 'Quicklink'; |
|
| 32 | + |
|
| 33 | + public function fieldLabels($includerelations = true) |
|
| 34 | + { |
|
| 35 | + $labels = parent::fieldLabels($includerelations); |
|
| 36 | + $labels['Name'] = _t(__CLASS__ . '.NameLabel', 'Name'); |
|
| 37 | + $labels['ExternalLink'] = _t(__CLASS__ . '.ExternalLinkLabel', 'External Link'); |
|
| 38 | + $labels['SortOrder'] = _t(__CLASS__ . '.SortOrderLabel', 'Sort Order'); |
|
| 39 | + $labels['ParentID'] = _t(__CLASS__ . '.ParentRelationLabel', 'Parent'); |
|
| 40 | + $labels['InternalLinkID'] = _t(__CLASS__ . '.InternalLinkLabel', 'Internal Link'); |
|
| 41 | + |
|
| 42 | + return $labels; |
|
| 43 | + } |
|
| 44 | + |
|
| 45 | + public function getLink() |
|
| 46 | + { |
|
| 47 | + if ($this->ExternalLink) { |
|
| 48 | + $url = parse_url($this->ExternalLink); |
|
| 49 | + |
|
| 50 | + // if no scheme set in the link, default to http |
|
| 51 | + if (!isset($url['scheme'])) { |
|
| 52 | + return 'http://' . $this->ExternalLink; |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + return $this->ExternalLink; |
|
| 56 | + } elseif ($this->InternalLinkID) { |
|
| 57 | + return $this->InternalLink()->Link(); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + public function canCreate($member = null, $context = []) |
|
| 62 | + { |
|
| 63 | + return $this->Parent()->canCreate($member, $context); |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + public function canEdit($member = null) |
|
| 67 | + { |
|
| 68 | + return $this->Parent()->canEdit($member); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + public function canDelete($member = null) |
|
| 72 | + { |
|
| 73 | + return $this->Parent()->canDelete($member); |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + public function canView($member = null) |
|
| 77 | + { |
|
| 78 | + return $this->Parent()->canView($member); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + public function getCMSFields() |
|
| 82 | + { |
|
| 83 | + $fields = parent::getCMSFields(); |
|
| 84 | + |
|
| 85 | + $fields->removeByName('ParentID'); |
|
| 86 | + |
|
| 87 | + $externalLinkField = $fields->fieldByName('Root.Main.ExternalLink'); |
|
| 88 | + |
|
| 89 | + $fields->removeByName('ExternalLink'); |
|
| 90 | + $fields->removeByName('InternalLinkID'); |
|
| 91 | + $fields->removeByName('SortOrder'); |
|
| 92 | + $externalLinkField->addExtraClass('noBorder'); |
|
| 93 | + |
|
| 94 | + $fields->addFieldToTab('Root.Main', CompositeField::create( |
|
| 95 | + array( |
|
| 96 | + TreeDropdownField::create( |
|
| 97 | + 'InternalLinkID', |
|
| 98 | + $this->fieldLabel('InternalLinkID'), |
|
| 99 | + SiteTree::class |
|
| 100 | + ), |
|
| 101 | + $externalLinkField, |
|
| 102 | + $wrap = CompositeField::create( |
|
| 103 | + $extraLabel = LiteralField::create( |
|
| 104 | + 'NoteOverride', |
|
| 105 | + _t( |
|
| 106 | + __CLASS__ . '.Note', |
|
| 107 | + // @todo remove the HTML from this translation |
|
| 108 | + '<div class="message good notice">Note: If you specify an External Link, ' |
|
| 109 | + . 'the Internal Link will be ignored.</div>' |
|
| 110 | + ) |
|
| 111 | + ) |
|
| 112 | + ) |
|
| 113 | + ) |
|
| 114 | + )); |
|
| 115 | + $fields->insertBefore( |
|
| 116 | + 'Name', |
|
| 117 | + LiteralField::create( |
|
| 118 | + 'Note', |
|
| 119 | + _t( |
|
| 120 | + __CLASS__ . '.Note2', |
|
| 121 | + // @todo remove the HTML from this translation |
|
| 122 | + '<p>Use this to specify a link to a page either on this site ' |
|
| 123 | + . '(Internal Link) or another site (External Link).</p>' |
|
| 124 | + ) |
|
| 125 | + ) |
|
| 126 | + ); |
|
| 127 | + |
|
| 128 | + return $fields; |
|
| 129 | + } |
|
| 130 | 130 | } |
@@ -11,55 +11,55 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class CustomSiteConfig extends DataExtension |
| 13 | 13 | { |
| 14 | - private static $db = array( |
|
| 15 | - 'GACode' => 'Varchar(16)', |
|
| 16 | - 'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open. |
|
| 17 | - 'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15 |
|
| 18 | - ); |
|
| 14 | + private static $db = array( |
|
| 15 | + 'GACode' => 'Varchar(16)', |
|
| 16 | + 'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open. |
|
| 17 | + 'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15 |
|
| 18 | + ); |
|
| 19 | 19 | |
| 20 | - public function updateCMSFields(FieldList $fields) |
|
| 21 | - { |
|
| 22 | - $fields->addFieldToTab( |
|
| 23 | - 'Root.Main', |
|
| 24 | - $gaCode = TextField::create( |
|
| 25 | - 'GACode', |
|
| 26 | - _t(__CLASS__ . '.GaField', 'Google Analytics account') |
|
| 27 | - ) |
|
| 28 | - ); |
|
| 20 | + public function updateCMSFields(FieldList $fields) |
|
| 21 | + { |
|
| 22 | + $fields->addFieldToTab( |
|
| 23 | + 'Root.Main', |
|
| 24 | + $gaCode = TextField::create( |
|
| 25 | + 'GACode', |
|
| 26 | + _t(__CLASS__ . '.GaField', 'Google Analytics account') |
|
| 27 | + ) |
|
| 28 | + ); |
|
| 29 | 29 | |
| 30 | - $gaCode->setRightTitle( |
|
| 31 | - _t( |
|
| 32 | - __CLASS__ . '.GaFieldDesc', |
|
| 33 | - 'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)' |
|
| 34 | - ) |
|
| 35 | - ); |
|
| 30 | + $gaCode->setRightTitle( |
|
| 31 | + _t( |
|
| 32 | + __CLASS__ . '.GaFieldDesc', |
|
| 33 | + 'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)' |
|
| 34 | + ) |
|
| 35 | + ); |
|
| 36 | 36 | |
| 37 | - $fields->findOrMakeTab('Root.SocialMedia', _t(__CLASS__ . '.SocialMediaTab', 'Social Media')); |
|
| 37 | + $fields->findOrMakeTab('Root.SocialMedia', _t(__CLASS__ . '.SocialMediaTab', 'Social Media')); |
|
| 38 | 38 | |
| 39 | - $fields->addFieldToTab( |
|
| 40 | - 'Root.SocialMedia', |
|
| 41 | - $facebookURL = TextField::create( |
|
| 42 | - 'FacebookURL', |
|
| 43 | - _t(__CLASS__ . '.FbField', 'Facebook UID or username') |
|
| 44 | - ) |
|
| 45 | - ); |
|
| 46 | - $facebookURL->setRightTitle( |
|
| 47 | - _t( |
|
| 48 | - __CLASS__ . '.FbFieldDesc', |
|
| 49 | - 'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/' |
|
| 50 | - . '<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)' |
|
| 51 | - ) |
|
| 52 | - ); |
|
| 39 | + $fields->addFieldToTab( |
|
| 40 | + 'Root.SocialMedia', |
|
| 41 | + $facebookURL = TextField::create( |
|
| 42 | + 'FacebookURL', |
|
| 43 | + _t(__CLASS__ . '.FbField', 'Facebook UID or username') |
|
| 44 | + ) |
|
| 45 | + ); |
|
| 46 | + $facebookURL->setRightTitle( |
|
| 47 | + _t( |
|
| 48 | + __CLASS__ . '.FbFieldDesc', |
|
| 49 | + 'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/' |
|
| 50 | + . '<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)' |
|
| 51 | + ) |
|
| 52 | + ); |
|
| 53 | 53 | |
| 54 | - $fields->addFieldToTab( |
|
| 55 | - 'Root.SocialMedia', |
|
| 56 | - $twitterUsername = TextField::create( |
|
| 57 | - 'TwitterUsername', |
|
| 58 | - _t(__CLASS__ . '.TwitterField', 'Twitter username') |
|
| 59 | - ) |
|
| 60 | - ); |
|
| 61 | - $twitterUsername->setRightTitle( |
|
| 62 | - _t(__CLASS__ . '.TwitterFieldDesc', 'Twitter username (eg, http://twitter.com/<strong>username</strong>)') |
|
| 63 | - ); |
|
| 64 | - } |
|
| 54 | + $fields->addFieldToTab( |
|
| 55 | + 'Root.SocialMedia', |
|
| 56 | + $twitterUsername = TextField::create( |
|
| 57 | + 'TwitterUsername', |
|
| 58 | + _t(__CLASS__ . '.TwitterField', 'Twitter username') |
|
| 59 | + ) |
|
| 60 | + ); |
|
| 61 | + $twitterUsername->setRightTitle( |
|
| 62 | + _t(__CLASS__ . '.TwitterFieldDesc', 'Twitter username (eg, http://twitter.com/<strong>username</strong>)') |
|
| 63 | + ); |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -13,20 +13,20 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class CwpCommentingExtension extends Extension |
| 15 | 15 | { |
| 16 | - public function alterCommentForm(Form $form) |
|
| 17 | - { |
|
| 18 | - $fields = $form->Fields(); |
|
| 16 | + public function alterCommentForm(Form $form) |
|
| 17 | + { |
|
| 18 | + $fields = $form->Fields(); |
|
| 19 | 19 | |
| 20 | - if ($emailField = $fields->dataFieldByName(Email::class)) { |
|
| 21 | - $emailField |
|
| 22 | - ->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', Email::class)) |
|
| 23 | - ->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.')); |
|
| 24 | - } |
|
| 20 | + if ($emailField = $fields->dataFieldByName(Email::class)) { |
|
| 21 | + $emailField |
|
| 22 | + ->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', Email::class)) |
|
| 23 | + ->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.')); |
|
| 24 | + } |
|
| 25 | 25 | |
| 26 | - if ($urlField = $fields->dataFieldByName('URL')) { |
|
| 27 | - $urlField |
|
| 28 | - ->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)')) |
|
| 29 | - ->setAttribute('placeholder', 'http://'); |
|
| 30 | - } |
|
| 31 | - } |
|
| 26 | + if ($urlField = $fields->dataFieldByName('URL')) { |
|
| 27 | + $urlField |
|
| 28 | + ->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)')) |
|
| 29 | + ->setAttribute('placeholder', 'http://'); |
|
| 30 | + } |
|
| 31 | + } |
|
| 32 | 32 | } |
@@ -12,45 +12,45 @@ |
||
| 12 | 12 | class CwpSearchBoostExtension extends DataExtension |
| 13 | 13 | { |
| 14 | 14 | |
| 15 | - /** |
|
| 16 | - * Quality to boost the 'SearchBoost' field by. |
|
| 17 | - * Default boost is 2x |
|
| 18 | - * |
|
| 19 | - * @config |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - private static $search_boost = '2'; |
|
| 23 | - |
|
| 24 | - private static $db = array( |
|
| 25 | - 'SearchBoost' => 'Text' |
|
| 26 | - ); |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Adds boost fields to this page |
|
| 30 | - * |
|
| 31 | - * @param FieldList $fields |
|
| 32 | - */ |
|
| 33 | - public function updateCMSFields(FieldList $fields) |
|
| 34 | - { |
|
| 35 | - parent::updateCMSFields($fields); |
|
| 36 | - |
|
| 37 | - // Rename metafield |
|
| 38 | - $meta = $fields->fieldByName('Root.Main.Metadata'); |
|
| 39 | - $meta->setTitle(_t(__CLASS__ . '.PAGEINFO', 'Page info and SEO')); |
|
| 40 | - |
|
| 41 | - $boostTitle = _t(__CLASS__ . '.SearchBoost', 'Boost Keywords'); |
|
| 42 | - $boostNote = _t( |
|
| 43 | - __CLASS__ . '.SearchBoostNote', |
|
| 44 | - '(Only applies to the search results on this site e.g. not on Google search)' |
|
| 45 | - ); |
|
| 46 | - $boostDescription = _t( |
|
| 47 | - __CLASS__ . '.SearchBoostDescription', |
|
| 48 | - 'Enter keywords separated by comma ( , ) for which to boost the ranking of this page ' |
|
| 49 | - . 'within the search results on this site.' |
|
| 50 | - ); |
|
| 51 | - $boostField = TextareaField::create('SearchBoost', $boostTitle) |
|
| 52 | - ->setRightTitle($boostNote) |
|
| 53 | - ->setDescription($boostDescription); |
|
| 54 | - $fields->insertBefore('MetaDescription', $boostField); |
|
| 55 | - } |
|
| 15 | + /** |
|
| 16 | + * Quality to boost the 'SearchBoost' field by. |
|
| 17 | + * Default boost is 2x |
|
| 18 | + * |
|
| 19 | + * @config |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + private static $search_boost = '2'; |
|
| 23 | + |
|
| 24 | + private static $db = array( |
|
| 25 | + 'SearchBoost' => 'Text' |
|
| 26 | + ); |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Adds boost fields to this page |
|
| 30 | + * |
|
| 31 | + * @param FieldList $fields |
|
| 32 | + */ |
|
| 33 | + public function updateCMSFields(FieldList $fields) |
|
| 34 | + { |
|
| 35 | + parent::updateCMSFields($fields); |
|
| 36 | + |
|
| 37 | + // Rename metafield |
|
| 38 | + $meta = $fields->fieldByName('Root.Main.Metadata'); |
|
| 39 | + $meta->setTitle(_t(__CLASS__ . '.PAGEINFO', 'Page info and SEO')); |
|
| 40 | + |
|
| 41 | + $boostTitle = _t(__CLASS__ . '.SearchBoost', 'Boost Keywords'); |
|
| 42 | + $boostNote = _t( |
|
| 43 | + __CLASS__ . '.SearchBoostNote', |
|
| 44 | + '(Only applies to the search results on this site e.g. not on Google search)' |
|
| 45 | + ); |
|
| 46 | + $boostDescription = _t( |
|
| 47 | + __CLASS__ . '.SearchBoostDescription', |
|
| 48 | + 'Enter keywords separated by comma ( , ) for which to boost the ranking of this page ' |
|
| 49 | + . 'within the search results on this site.' |
|
| 50 | + ); |
|
| 51 | + $boostField = TextareaField::create('SearchBoost', $boostTitle) |
|
| 52 | + ->setRightTitle($boostNote) |
|
| 53 | + ->setDescription($boostDescription); |
|
| 54 | + $fields->insertBefore('MetaDescription', $boostField); |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -6,154 +6,154 @@ |
||
| 6 | 6 | |
| 7 | 7 | class SynonymValidator extends Validator |
| 8 | 8 | { |
| 9 | - /** |
|
| 10 | - * @var array |
|
| 11 | - */ |
|
| 12 | - protected $fieldNames; |
|
| 13 | - |
|
| 14 | - /** |
|
| 15 | - * @inheritdoc |
|
| 16 | - * |
|
| 17 | - * @param array $fieldNames |
|
| 18 | - */ |
|
| 19 | - public function __construct(array $fieldNames) |
|
| 20 | - { |
|
| 21 | - $this->fieldNames = $fieldNames; |
|
| 22 | - |
|
| 23 | - parent::__construct(); |
|
| 24 | - } |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @inheritdoc |
|
| 28 | - * |
|
| 29 | - * @param array $data |
|
| 30 | - * |
|
| 31 | - * @return mixed |
|
| 32 | - */ |
|
| 33 | - public function php($data) |
|
| 34 | - { |
|
| 35 | - foreach ($this->fieldNames as $fieldName) { |
|
| 36 | - if (empty($data[$fieldName])) { |
|
| 37 | - return; |
|
| 38 | - } |
|
| 39 | - |
|
| 40 | - $this->validateField($fieldName, $data[$fieldName]); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * Validate field values, raising errors if the values are invalid. |
|
| 46 | - * |
|
| 47 | - * @param string $fieldName |
|
| 48 | - * @param mixed $value |
|
| 49 | - */ |
|
| 50 | - protected function validateField($fieldName, $value) |
|
| 51 | - { |
|
| 52 | - if (!$this->validateValue($value)) { |
|
| 53 | - $this->validationError( |
|
| 54 | - $fieldName, |
|
| 55 | - _t( |
|
| 56 | - __CLASS__ . '.InvalidValue', |
|
| 57 | - 'Synonyms cannot contain words separated by spaces' |
|
| 58 | - ) |
|
| 59 | - ); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * Check field values to see that they doesn't contain spaces between words. |
|
| 65 | - * |
|
| 66 | - * @param mixed $value |
|
| 67 | - * |
|
| 68 | - * @return bool |
|
| 69 | - */ |
|
| 70 | - protected function validateValue($value) |
|
| 71 | - { |
|
| 72 | - // strip empty lines |
|
| 73 | - $lines = array_filter( |
|
| 74 | - explode("\n", $value) |
|
| 75 | - ); |
|
| 76 | - |
|
| 77 | - // strip comments (lines beginning with "#") |
|
| 78 | - $lines = array_filter($lines, function ($line) { |
|
| 79 | - $line = trim($line); |
|
| 80 | - |
|
| 81 | - return !empty($line) && $line[0] !== '#'; |
|
| 82 | - }); |
|
| 83 | - |
|
| 84 | - // validate each line |
|
| 85 | - foreach ($lines as $line) { |
|
| 86 | - if (!$this->validateLine($line)) { |
|
| 87 | - return false; |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - return true; |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - /** |
|
| 95 | - * Check each line to see that it doesn't contain spaces between words. |
|
| 96 | - * |
|
| 97 | - * @param string $line |
|
| 98 | - * |
|
| 99 | - * @return bool |
|
| 100 | - */ |
|
| 101 | - protected function validateLine($line) |
|
| 102 | - { |
|
| 103 | - $line = trim($line); |
|
| 104 | - |
|
| 105 | - $parts = explode(',', $line); |
|
| 106 | - $parts = array_filter($parts); |
|
| 107 | - |
|
| 108 | - foreach ($parts as $part) { |
|
| 109 | - if (!$this->validatePart($part)) { |
|
| 110 | - return false; |
|
| 111 | - } |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - return true; |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * Check each part of the line doesn't contain spaces between words. |
|
| 119 | - * |
|
| 120 | - * @param string $part |
|
| 121 | - * |
|
| 122 | - * @return bool |
|
| 123 | - */ |
|
| 124 | - protected function validatePart($part) |
|
| 125 | - { |
|
| 126 | - if (strpos($part, '=>') !== false) { |
|
| 127 | - $subs = explode('=>', $part); |
|
| 128 | - $subs = array_filter($subs); |
|
| 129 | - |
|
| 130 | - foreach ($subs as $sub) { |
|
| 131 | - if (!$this->validateNoSpaces($sub)) { |
|
| 132 | - return false; |
|
| 133 | - } |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - return true; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - return $this->validateNoSpaces($part); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @param string $value |
|
| 144 | - * |
|
| 145 | - * @return bool |
|
| 146 | - */ |
|
| 147 | - protected function validateNoSpaces($value) |
|
| 148 | - { |
|
| 149 | - // allow spaces at the beginning and end of the value |
|
| 150 | - $value = trim($value); |
|
| 151 | - |
|
| 152 | - // does the value contain 1 or more whitespace characters? |
|
| 153 | - if (preg_match('/\s+/', $value)) { |
|
| 154 | - return false; |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - return true; |
|
| 158 | - } |
|
| 9 | + /** |
|
| 10 | + * @var array |
|
| 11 | + */ |
|
| 12 | + protected $fieldNames; |
|
| 13 | + |
|
| 14 | + /** |
|
| 15 | + * @inheritdoc |
|
| 16 | + * |
|
| 17 | + * @param array $fieldNames |
|
| 18 | + */ |
|
| 19 | + public function __construct(array $fieldNames) |
|
| 20 | + { |
|
| 21 | + $this->fieldNames = $fieldNames; |
|
| 22 | + |
|
| 23 | + parent::__construct(); |
|
| 24 | + } |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @inheritdoc |
|
| 28 | + * |
|
| 29 | + * @param array $data |
|
| 30 | + * |
|
| 31 | + * @return mixed |
|
| 32 | + */ |
|
| 33 | + public function php($data) |
|
| 34 | + { |
|
| 35 | + foreach ($this->fieldNames as $fieldName) { |
|
| 36 | + if (empty($data[$fieldName])) { |
|
| 37 | + return; |
|
| 38 | + } |
|
| 39 | + |
|
| 40 | + $this->validateField($fieldName, $data[$fieldName]); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * Validate field values, raising errors if the values are invalid. |
|
| 46 | + * |
|
| 47 | + * @param string $fieldName |
|
| 48 | + * @param mixed $value |
|
| 49 | + */ |
|
| 50 | + protected function validateField($fieldName, $value) |
|
| 51 | + { |
|
| 52 | + if (!$this->validateValue($value)) { |
|
| 53 | + $this->validationError( |
|
| 54 | + $fieldName, |
|
| 55 | + _t( |
|
| 56 | + __CLASS__ . '.InvalidValue', |
|
| 57 | + 'Synonyms cannot contain words separated by spaces' |
|
| 58 | + ) |
|
| 59 | + ); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * Check field values to see that they doesn't contain spaces between words. |
|
| 65 | + * |
|
| 66 | + * @param mixed $value |
|
| 67 | + * |
|
| 68 | + * @return bool |
|
| 69 | + */ |
|
| 70 | + protected function validateValue($value) |
|
| 71 | + { |
|
| 72 | + // strip empty lines |
|
| 73 | + $lines = array_filter( |
|
| 74 | + explode("\n", $value) |
|
| 75 | + ); |
|
| 76 | + |
|
| 77 | + // strip comments (lines beginning with "#") |
|
| 78 | + $lines = array_filter($lines, function ($line) { |
|
| 79 | + $line = trim($line); |
|
| 80 | + |
|
| 81 | + return !empty($line) && $line[0] !== '#'; |
|
| 82 | + }); |
|
| 83 | + |
|
| 84 | + // validate each line |
|
| 85 | + foreach ($lines as $line) { |
|
| 86 | + if (!$this->validateLine($line)) { |
|
| 87 | + return false; |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + return true; |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + /** |
|
| 95 | + * Check each line to see that it doesn't contain spaces between words. |
|
| 96 | + * |
|
| 97 | + * @param string $line |
|
| 98 | + * |
|
| 99 | + * @return bool |
|
| 100 | + */ |
|
| 101 | + protected function validateLine($line) |
|
| 102 | + { |
|
| 103 | + $line = trim($line); |
|
| 104 | + |
|
| 105 | + $parts = explode(',', $line); |
|
| 106 | + $parts = array_filter($parts); |
|
| 107 | + |
|
| 108 | + foreach ($parts as $part) { |
|
| 109 | + if (!$this->validatePart($part)) { |
|
| 110 | + return false; |
|
| 111 | + } |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + return true; |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * Check each part of the line doesn't contain spaces between words. |
|
| 119 | + * |
|
| 120 | + * @param string $part |
|
| 121 | + * |
|
| 122 | + * @return bool |
|
| 123 | + */ |
|
| 124 | + protected function validatePart($part) |
|
| 125 | + { |
|
| 126 | + if (strpos($part, '=>') !== false) { |
|
| 127 | + $subs = explode('=>', $part); |
|
| 128 | + $subs = array_filter($subs); |
|
| 129 | + |
|
| 130 | + foreach ($subs as $sub) { |
|
| 131 | + if (!$this->validateNoSpaces($sub)) { |
|
| 132 | + return false; |
|
| 133 | + } |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + return true; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + return $this->validateNoSpaces($part); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @param string $value |
|
| 144 | + * |
|
| 145 | + * @return bool |
|
| 146 | + */ |
|
| 147 | + protected function validateNoSpaces($value) |
|
| 148 | + { |
|
| 149 | + // allow spaces at the beginning and end of the value |
|
| 150 | + $value = trim($value); |
|
| 151 | + |
|
| 152 | + // does the value contain 1 or more whitespace characters? |
|
| 153 | + if (preg_match('/\s+/', $value)) { |
|
| 154 | + return false; |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + return true; |
|
| 158 | + } |
|
| 159 | 159 | } |
@@ -11,53 +11,53 @@ |
||
| 11 | 11 | class CwpSiteTreeFileExtension extends DataExtension |
| 12 | 12 | { |
| 13 | 13 | |
| 14 | - public function updateCMSFields(FieldList $fields) |
|
| 15 | - { |
|
| 16 | - Requirements::css('cwp/cwp:css/fieldDescriptionToggle.css'); |
|
| 17 | - Requirements::javascript('cwp/cwp:javascript/fieldDescriptionToggle.js'); |
|
| 18 | - |
|
| 19 | - $fields->insertAfter( |
|
| 20 | - 'LastEdited', |
|
| 21 | - ReadonlyField::create( |
|
| 22 | - 'BackLinkCount', |
|
| 23 | - _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.BACKLINKCOUNT', 'Used on:'), |
|
| 24 | - $this->owner->BackLinkTracking()->Count() . ' ' |
|
| 25 | - . _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.PAGES', 'page(s)') |
|
| 26 | - ) |
|
| 27 | - ->addExtraClass('cms-description-toggle') |
|
| 28 | - ->setDescription($this->BackLinkHTMLList()) |
|
| 29 | - ); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * Generate an HTML list which provides links to where a file is used. |
|
| 34 | - * |
|
| 35 | - * @return string |
|
| 36 | - */ |
|
| 37 | - public function BackLinkHTMLList() |
|
| 38 | - { |
|
| 39 | - $html = '<em>' . _t( |
|
| 40 | - __CLASS__ . '.BACKLINK_LIST_DESCRIPTION', |
|
| 41 | - 'This list shows all pages where the file has been added through a WYSIWYG editor.' |
|
| 42 | - ) . '</em>'; |
|
| 43 | - $html .= '<ul>'; |
|
| 44 | - |
|
| 45 | - foreach ($this->owner->BackLinkTracking() as $backLink) { |
|
| 46 | - $listItem = '<li>'; |
|
| 47 | - |
|
| 48 | - // Add the page link |
|
| 49 | - $listItem .= '<a href="' . $backLink->Link() . '" target="_blank">' |
|
| 50 | - . Convert::raw2xml($backLink->MenuTitle) . '</a> – '; |
|
| 51 | - |
|
| 52 | - // Add the CMS link |
|
| 53 | - $listItem .= '<a href="' . $backLink->CMSEditLink() . '">' |
|
| 54 | - . _t(__CLASS__ . '.EDIT', 'Edit') . '</a>'; |
|
| 55 | - |
|
| 56 | - $html .= $listItem . '</li>'; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - $html .= '</ul>'; |
|
| 60 | - |
|
| 61 | - return $html; |
|
| 62 | - } |
|
| 14 | + public function updateCMSFields(FieldList $fields) |
|
| 15 | + { |
|
| 16 | + Requirements::css('cwp/cwp:css/fieldDescriptionToggle.css'); |
|
| 17 | + Requirements::javascript('cwp/cwp:javascript/fieldDescriptionToggle.js'); |
|
| 18 | + |
|
| 19 | + $fields->insertAfter( |
|
| 20 | + 'LastEdited', |
|
| 21 | + ReadonlyField::create( |
|
| 22 | + 'BackLinkCount', |
|
| 23 | + _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.BACKLINKCOUNT', 'Used on:'), |
|
| 24 | + $this->owner->BackLinkTracking()->Count() . ' ' |
|
| 25 | + . _t('SilverStripe\\CMS\\Model\\SiteTreeFileExtension.PAGES', 'page(s)') |
|
| 26 | + ) |
|
| 27 | + ->addExtraClass('cms-description-toggle') |
|
| 28 | + ->setDescription($this->BackLinkHTMLList()) |
|
| 29 | + ); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * Generate an HTML list which provides links to where a file is used. |
|
| 34 | + * |
|
| 35 | + * @return string |
|
| 36 | + */ |
|
| 37 | + public function BackLinkHTMLList() |
|
| 38 | + { |
|
| 39 | + $html = '<em>' . _t( |
|
| 40 | + __CLASS__ . '.BACKLINK_LIST_DESCRIPTION', |
|
| 41 | + 'This list shows all pages where the file has been added through a WYSIWYG editor.' |
|
| 42 | + ) . '</em>'; |
|
| 43 | + $html .= '<ul>'; |
|
| 44 | + |
|
| 45 | + foreach ($this->owner->BackLinkTracking() as $backLink) { |
|
| 46 | + $listItem = '<li>'; |
|
| 47 | + |
|
| 48 | + // Add the page link |
|
| 49 | + $listItem .= '<a href="' . $backLink->Link() . '" target="_blank">' |
|
| 50 | + . Convert::raw2xml($backLink->MenuTitle) . '</a> – '; |
|
| 51 | + |
|
| 52 | + // Add the CMS link |
|
| 53 | + $listItem .= '<a href="' . $backLink->CMSEditLink() . '">' |
|
| 54 | + . _t(__CLASS__ . '.EDIT', 'Edit') . '</a>'; |
|
| 55 | + |
|
| 56 | + $html .= $listItem . '</li>'; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + $html .= '</ul>'; |
|
| 60 | + |
|
| 61 | + return $html; |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -9,39 +9,39 @@ |
||
| 9 | 9 | |
| 10 | 10 | class CwpSiteTreeExtension extends DataExtension |
| 11 | 11 | { |
| 12 | - private static $db = array( |
|
| 13 | - 'ShowPageUtilities' => 'Boolean(1)' |
|
| 14 | - ); |
|
| 12 | + private static $db = array( |
|
| 13 | + 'ShowPageUtilities' => 'Boolean(1)' |
|
| 14 | + ); |
|
| 15 | 15 | |
| 16 | - private static $defaults = array( |
|
| 17 | - 'ShowPageUtilities' => true |
|
| 18 | - ); |
|
| 16 | + private static $defaults = array( |
|
| 17 | + 'ShowPageUtilities' => true |
|
| 18 | + ); |
|
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * Modify the settings for a SiteTree |
|
| 22 | - * |
|
| 23 | - * {@inheritDoc} |
|
| 24 | - * |
|
| 25 | - * @param FieldList $fields |
|
| 26 | - */ |
|
| 27 | - public function updateSettingsFields(FieldList $fields) |
|
| 28 | - { |
|
| 29 | - $helpText = _t( |
|
| 30 | - __CLASS__ . '.SHOW_PAGE_UTILITIES_HELP', |
|
| 31 | - 'You can disable page utilities (print, share, etc) for this page' |
|
| 32 | - ); |
|
| 20 | + /** |
|
| 21 | + * Modify the settings for a SiteTree |
|
| 22 | + * |
|
| 23 | + * {@inheritDoc} |
|
| 24 | + * |
|
| 25 | + * @param FieldList $fields |
|
| 26 | + */ |
|
| 27 | + public function updateSettingsFields(FieldList $fields) |
|
| 28 | + { |
|
| 29 | + $helpText = _t( |
|
| 30 | + __CLASS__ . '.SHOW_PAGE_UTILITIES_HELP', |
|
| 31 | + 'You can disable page utilities (print, share, etc) for this page' |
|
| 32 | + ); |
|
| 33 | 33 | |
| 34 | - $fields->addFieldsToTab( |
|
| 35 | - 'Root.Settings', |
|
| 36 | - array( |
|
| 37 | - LiteralField::create('PageUtilitiesHelp', $helpText), |
|
| 38 | - CheckboxField::create('ShowPageUtilities', $this->owner->fieldLabel('ShowPageUtilities')) |
|
| 39 | - ) |
|
| 40 | - ); |
|
| 41 | - } |
|
| 34 | + $fields->addFieldsToTab( |
|
| 35 | + 'Root.Settings', |
|
| 36 | + array( |
|
| 37 | + LiteralField::create('PageUtilitiesHelp', $helpText), |
|
| 38 | + CheckboxField::create('ShowPageUtilities', $this->owner->fieldLabel('ShowPageUtilities')) |
|
| 39 | + ) |
|
| 40 | + ); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - public function updateFieldLabels(&$labels) |
|
| 44 | - { |
|
| 45 | - $labels['ShowPageUtilities'] = _t(__CLASS__ . '.SHOW_PAGE_UTILITIES', 'Show page utilities?'); |
|
| 46 | - } |
|
| 43 | + public function updateFieldLabels(&$labels) |
|
| 44 | + { |
|
| 45 | + $labels['ShowPageUtilities'] = _t(__CLASS__ . '.SHOW_PAGE_UTILITIES', 'Show page utilities?'); |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -16,52 +16,52 @@ |
||
| 16 | 16 | class SynonymsSiteConfig extends DataExtension |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - private static $db = array( |
|
| 20 | - 'SearchSynonyms' => 'Text', // fulltextsearch synonyms.txt content |
|
| 21 | - ); |
|
| 19 | + private static $db = array( |
|
| 20 | + 'SearchSynonyms' => 'Text', // fulltextsearch synonyms.txt content |
|
| 21 | + ); |
|
| 22 | 22 | |
| 23 | - public function updateCMSFields(FieldList $fields) |
|
| 24 | - { |
|
| 25 | - // Don't show this field if you're not an admin |
|
| 26 | - if (!Permission::check('ADMIN')) { |
|
| 27 | - return; |
|
| 28 | - } |
|
| 23 | + public function updateCMSFields(FieldList $fields) |
|
| 24 | + { |
|
| 25 | + // Don't show this field if you're not an admin |
|
| 26 | + if (!Permission::check('ADMIN')) { |
|
| 27 | + return; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - // Search synonyms |
|
| 31 | - $fields->addFieldToTab( |
|
| 32 | - 'Root.FulltextSearch', |
|
| 33 | - TextareaField::create('SearchSynonyms', _t(__CLASS__ . '.SearchSynonyms', 'Search Synonyms')) |
|
| 34 | - ->setDescription(_t( |
|
| 35 | - __CLASS__ . '.SearchSynonyms_Description', |
|
| 36 | - 'Enter as many comma separated synonyms as you wish, where '. |
|
| 37 | - 'each line represents a group of synonyms.<br /> ' . |
|
| 38 | - 'You will need to run <a rel="external" target="_blank" href="dev/tasks/Solr_Configure">' |
|
| 39 | - . 'Solr_Configure</a> if you make any changes' |
|
| 40 | - )) |
|
| 41 | - ); |
|
| 42 | - } |
|
| 30 | + // Search synonyms |
|
| 31 | + $fields->addFieldToTab( |
|
| 32 | + 'Root.FulltextSearch', |
|
| 33 | + TextareaField::create('SearchSynonyms', _t(__CLASS__ . '.SearchSynonyms', 'Search Synonyms')) |
|
| 34 | + ->setDescription(_t( |
|
| 35 | + __CLASS__ . '.SearchSynonyms_Description', |
|
| 36 | + 'Enter as many comma separated synonyms as you wish, where '. |
|
| 37 | + 'each line represents a group of synonyms.<br /> ' . |
|
| 38 | + 'You will need to run <a rel="external" target="_blank" href="dev/tasks/Solr_Configure">' |
|
| 39 | + . 'Solr_Configure</a> if you make any changes' |
|
| 40 | + )) |
|
| 41 | + ); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * @inheritdoc |
|
| 46 | - * |
|
| 47 | - * @param ValidationResult $validationResult |
|
| 48 | - */ |
|
| 49 | - public function validate(ValidationResult $validationResult) |
|
| 50 | - { |
|
| 51 | - $validator = new SynonymValidator(array( |
|
| 52 | - 'SearchSynonyms', |
|
| 53 | - )); |
|
| 44 | + /** |
|
| 45 | + * @inheritdoc |
|
| 46 | + * |
|
| 47 | + * @param ValidationResult $validationResult |
|
| 48 | + */ |
|
| 49 | + public function validate(ValidationResult $validationResult) |
|
| 50 | + { |
|
| 51 | + $validator = new SynonymValidator(array( |
|
| 52 | + 'SearchSynonyms', |
|
| 53 | + )); |
|
| 54 | 54 | |
| 55 | - $validator->php(array( |
|
| 56 | - 'SearchSynonyms' => $this->owner->SearchSynonyms |
|
| 57 | - )); |
|
| 55 | + $validator->php(array( |
|
| 56 | + 'SearchSynonyms' => $this->owner->SearchSynonyms |
|
| 57 | + )); |
|
| 58 | 58 | |
| 59 | - $errors = $validator->getErrors(); |
|
| 59 | + $errors = $validator->getErrors(); |
|
| 60 | 60 | |
| 61 | - if (is_array($errors) || $errors instanceof Traversable) { |
|
| 62 | - foreach ($errors as $error) { |
|
| 63 | - $validationResult->addError($error['message']); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - } |
|
| 61 | + if (is_array($errors) || $errors instanceof Traversable) { |
|
| 62 | + foreach ($errors as $error) { |
|
| 63 | + $validationResult->addError($error['message']); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | 67 | } |
@@ -11,25 +11,25 @@ |
||
| 11 | 11 | */ |
| 12 | 12 | class CwpSearchPageController extends PageController |
| 13 | 13 | { |
| 14 | - /** |
|
| 15 | - * Create the dummy search record for this page |
|
| 16 | - * |
|
| 17 | - * @return CwpSearchPage |
|
| 18 | - */ |
|
| 19 | - protected function generateSearchRecord() |
|
| 20 | - { |
|
| 21 | - $searchPage = CwpSearchPage::create(); |
|
| 22 | - $searchPage->URLSegment = 'search'; |
|
| 23 | - $searchPage->Title = _t('SilverStripe\\CMS\\Search\\SearchForm.SearchResults', 'Search Results'); |
|
| 24 | - $searchPage->ID = -1; |
|
| 25 | - return $searchPage; |
|
| 26 | - } |
|
| 14 | + /** |
|
| 15 | + * Create the dummy search record for this page |
|
| 16 | + * |
|
| 17 | + * @return CwpSearchPage |
|
| 18 | + */ |
|
| 19 | + protected function generateSearchRecord() |
|
| 20 | + { |
|
| 21 | + $searchPage = CwpSearchPage::create(); |
|
| 22 | + $searchPage->URLSegment = 'search'; |
|
| 23 | + $searchPage->Title = _t('SilverStripe\\CMS\\Search\\SearchForm.SearchResults', 'Search Results'); |
|
| 24 | + $searchPage->ID = -1; |
|
| 25 | + return $searchPage; |
|
| 26 | + } |
|
| 27 | 27 | |
| 28 | - public function __construct($dataRecord = null) |
|
| 29 | - { |
|
| 30 | - if (!$dataRecord) { |
|
| 31 | - $dataRecord = $this->generateSearchRecord(); |
|
| 32 | - } |
|
| 33 | - parent::__construct($dataRecord); |
|
| 34 | - } |
|
| 28 | + public function __construct($dataRecord = null) |
|
| 29 | + { |
|
| 30 | + if (!$dataRecord) { |
|
| 31 | + $dataRecord = $this->generateSearchRecord(); |
|
| 32 | + } |
|
| 33 | + parent::__construct($dataRecord); |
|
| 34 | + } |
|
| 35 | 35 | } |