@@ -13,48 +13,48 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class MaintenanceProxyExtension extends Extension |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * Configures required environment settings for Composer's use, applies to |
|
| 18 | - * {@link \BringYourOwnIdeas\Maintenance\Util\ComposerLoader} and is applied before ComposerLoaderExtension in |
|
| 19 | - * bringyourownideas/silverstripe-composer-update-checker to ensure the proxy information is set before Composer |
|
| 20 | - * is created |
|
| 21 | - */ |
|
| 22 | - public function onAfterBuild() |
|
| 23 | - { |
|
| 24 | - // Provide access for Composer's StreamContextFactory, since it creates its own stream context |
|
| 25 | - if ($proxy = $this->getCwpProxy()) { |
|
| 26 | - $_SERVER['CGI_HTTP_PROXY'] = $proxy; |
|
| 27 | - } |
|
| 28 | - } |
|
| 16 | + /** |
|
| 17 | + * Configures required environment settings for Composer's use, applies to |
|
| 18 | + * {@link \BringYourOwnIdeas\Maintenance\Util\ComposerLoader} and is applied before ComposerLoaderExtension in |
|
| 19 | + * bringyourownideas/silverstripe-composer-update-checker to ensure the proxy information is set before Composer |
|
| 20 | + * is created |
|
| 21 | + */ |
|
| 22 | + public function onAfterBuild() |
|
| 23 | + { |
|
| 24 | + // Provide access for Composer's StreamContextFactory, since it creates its own stream context |
|
| 25 | + if ($proxy = $this->getCwpProxy()) { |
|
| 26 | + $_SERVER['CGI_HTTP_PROXY'] = $proxy; |
|
| 27 | + } |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Provide proxy options for {@link \BringYourOwnIdeas\Maintenance\Util\ApiLoader} instances to use in |
|
| 32 | - * their Guzzle clients |
|
| 33 | - * |
|
| 34 | - * @param array $options |
|
| 35 | - */ |
|
| 36 | - public function updateClientOptions(&$options) |
|
| 37 | - { |
|
| 38 | - if ($proxy = $this->getCwpProxy()) { |
|
| 39 | - $options['proxy'] = $proxy; |
|
| 40 | - } |
|
| 41 | - } |
|
| 30 | + /** |
|
| 31 | + * Provide proxy options for {@link \BringYourOwnIdeas\Maintenance\Util\ApiLoader} instances to use in |
|
| 32 | + * their Guzzle clients |
|
| 33 | + * |
|
| 34 | + * @param array $options |
|
| 35 | + */ |
|
| 36 | + public function updateClientOptions(&$options) |
|
| 37 | + { |
|
| 38 | + if ($proxy = $this->getCwpProxy()) { |
|
| 39 | + $options['proxy'] = $proxy; |
|
| 40 | + } |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Returns a formatted CWP proxy string, e.g. `tcp://proxy.cwp.govt.nz:1234` |
|
| 45 | - * |
|
| 46 | - * @return string |
|
| 47 | - */ |
|
| 48 | - protected function getCwpProxy() |
|
| 49 | - { |
|
| 50 | - if (!Environment::getEnv('SS_OUTBOUND_PROXY') || !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) { |
|
| 51 | - return ''; |
|
| 52 | - } |
|
| 43 | + /** |
|
| 44 | + * Returns a formatted CWP proxy string, e.g. `tcp://proxy.cwp.govt.nz:1234` |
|
| 45 | + * |
|
| 46 | + * @return string |
|
| 47 | + */ |
|
| 48 | + protected function getCwpProxy() |
|
| 49 | + { |
|
| 50 | + if (!Environment::getEnv('SS_OUTBOUND_PROXY') || !Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) { |
|
| 51 | + return ''; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - return sprintf( |
|
| 55 | - 'tcp://%s:%d', |
|
| 56 | - Environment::getEnv('SS_OUTBOUND_PROXY'), |
|
| 57 | - Environment::getEnv('SS_OUTBOUND_PROXY_PORT') |
|
| 58 | - ); |
|
| 59 | - } |
|
| 54 | + return sprintf( |
|
| 55 | + 'tcp://%s:%d', |
|
| 56 | + Environment::getEnv('SS_OUTBOUND_PROXY'), |
|
| 57 | + Environment::getEnv('SS_OUTBOUND_PROXY_PORT') |
|
| 58 | + ); |
|
| 59 | + } |
|
| 60 | 60 | } |
@@ -14,20 +14,20 @@ |
||
| 14 | 14 | */ |
| 15 | 15 | class CwpCommentingExtension extends Extension |
| 16 | 16 | { |
| 17 | - public function alterCommentForm(Form $form) |
|
| 18 | - { |
|
| 19 | - $fields = $form->Fields(); |
|
| 17 | + public function alterCommentForm(Form $form) |
|
| 18 | + { |
|
| 19 | + $fields = $form->Fields(); |
|
| 20 | 20 | |
| 21 | - if ($emailField = $fields->dataFieldByName('Email')) { |
|
| 22 | - $emailField |
|
| 23 | - ->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', 'Email')) |
|
| 24 | - ->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.')); |
|
| 25 | - } |
|
| 21 | + if ($emailField = $fields->dataFieldByName('Email')) { |
|
| 22 | + $emailField |
|
| 23 | + ->setTitle(_t(__CLASS__ . '.EMAIL_TITLE', 'Email')) |
|
| 24 | + ->setDescription(_t(__CLASS__ . '.WILL_NOT_BE_PUBLISHED', 'Will not be published.')); |
|
| 25 | + } |
|
| 26 | 26 | |
| 27 | - if ($urlField = $fields->dataFieldByName('URL')) { |
|
| 28 | - $urlField |
|
| 29 | - ->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)')) |
|
| 30 | - ->setAttribute('placeholder', 'http://'); |
|
| 31 | - } |
|
| 32 | - } |
|
| 27 | + if ($urlField = $fields->dataFieldByName('URL')) { |
|
| 28 | + $urlField |
|
| 29 | + ->setTitle(_t(__CLASS__ . '.WEBSITE_TITLE', 'Your website (optional)')) |
|
| 30 | + ->setAttribute('placeholder', 'http://'); |
|
| 31 | + } |
|
| 32 | + } |
|
| 33 | 33 | } |
@@ -8,30 +8,30 @@ |
||
| 8 | 8 | |
| 9 | 9 | class RelatedPageLink extends DataObject |
| 10 | 10 | { |
| 11 | - private static $table_name = 'BasePage_RelatedPages'; |
|
| 11 | + private static $table_name = 'BasePage_RelatedPages'; |
|
| 12 | 12 | |
| 13 | - private static $extensions = [ |
|
| 14 | - Versioned::class, |
|
| 15 | - ]; |
|
| 13 | + private static $extensions = [ |
|
| 14 | + Versioned::class, |
|
| 15 | + ]; |
|
| 16 | 16 | |
| 17 | - private static $db = [ |
|
| 18 | - 'SortOrder' => 'Int', |
|
| 19 | - ]; |
|
| 17 | + private static $db = [ |
|
| 18 | + 'SortOrder' => 'Int', |
|
| 19 | + ]; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * For backwards compatibility these must match a traditional 'many_many' definition. |
|
| 23 | - * This was BasePage.RelatedPages => BasePage |
|
| 24 | - * ManyMany relations are normally joined by ${DefiningClass}ID && ${RelatedClass}ID |
|
| 25 | - * excepting in the case where ${DefiningClass} === ${RelatedClass} |
|
| 26 | - * Then the 'related class' column changes from ${RelatedClass}ID to "ChildID". |
|
| 27 | - * |
|
| 28 | - * {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()} |
|
| 29 | - * |
|
| 30 | - * @var array |
|
| 31 | - * @config |
|
| 32 | - */ |
|
| 33 | - private static $has_one = [ |
|
| 34 | - 'BasePage' => BasePage::class, |
|
| 35 | - 'Child' => BasePage::class, |
|
| 36 | - ]; |
|
| 21 | + /** |
|
| 22 | + * For backwards compatibility these must match a traditional 'many_many' definition. |
|
| 23 | + * This was BasePage.RelatedPages => BasePage |
|
| 24 | + * ManyMany relations are normally joined by ${DefiningClass}ID && ${RelatedClass}ID |
|
| 25 | + * excepting in the case where ${DefiningClass} === ${RelatedClass} |
|
| 26 | + * Then the 'related class' column changes from ${RelatedClass}ID to "ChildID". |
|
| 27 | + * |
|
| 28 | + * {@see SilverStripe\ORM\DataObjectSchema->parseManyManyComponent()} |
|
| 29 | + * |
|
| 30 | + * @var array |
|
| 31 | + * @config |
|
| 32 | + */ |
|
| 33 | + private static $has_one = [ |
|
| 34 | + 'BasePage' => BasePage::class, |
|
| 35 | + 'Child' => BasePage::class, |
|
| 36 | + ]; |
|
| 37 | 37 | } |
@@ -12,58 +12,58 @@ |
||
| 12 | 12 | */ |
| 13 | 13 | class CustomSiteConfig extends DataExtension |
| 14 | 14 | { |
| 15 | - private static $db = array( |
|
| 16 | - 'GACode' => 'Varchar(16)', |
|
| 17 | - 'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open. |
|
| 18 | - 'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15 |
|
| 19 | - ); |
|
| 15 | + private static $db = array( |
|
| 16 | + 'GACode' => 'Varchar(16)', |
|
| 17 | + 'FacebookURL' => 'Varchar(256)', // multitude of ways to link to Facebook accounts, best to leave it open. |
|
| 18 | + 'TwitterUsername' => 'Varchar(16)', // max length of Twitter username 15 |
|
| 19 | + ); |
|
| 20 | 20 | |
| 21 | - public function updateCMSFields(FieldList $fields) |
|
| 22 | - { |
|
| 23 | - $fields->addFieldToTab( |
|
| 24 | - 'Root.Main', |
|
| 25 | - $gaCode = TextField::create( |
|
| 26 | - 'GACode', |
|
| 27 | - _t(__CLASS__ . '.GaField', 'Google Analytics account') |
|
| 28 | - ) |
|
| 29 | - ); |
|
| 21 | + public function updateCMSFields(FieldList $fields) |
|
| 22 | + { |
|
| 23 | + $fields->addFieldToTab( |
|
| 24 | + 'Root.Main', |
|
| 25 | + $gaCode = TextField::create( |
|
| 26 | + 'GACode', |
|
| 27 | + _t(__CLASS__ . '.GaField', 'Google Analytics account') |
|
| 28 | + ) |
|
| 29 | + ); |
|
| 30 | 30 | |
| 31 | - $gaCode->setDescription( |
|
| 32 | - DBField::create_field('HTMLFragment', _t( |
|
| 33 | - __CLASS__ . '.GaFieldDesc', |
|
| 34 | - 'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)' |
|
| 35 | - )) |
|
| 36 | - ); |
|
| 31 | + $gaCode->setDescription( |
|
| 32 | + DBField::create_field('HTMLFragment', _t( |
|
| 33 | + __CLASS__ . '.GaFieldDesc', |
|
| 34 | + 'Account number to be used all across the site (in the format <strong>UA-XXXXX-X</strong>)' |
|
| 35 | + )) |
|
| 36 | + ); |
|
| 37 | 37 | |
| 38 | - $fields->findOrMakeTab('Root.SocialMedia', _t(__CLASS__ . '.SocialMediaTab', 'Social Media')); |
|
| 38 | + $fields->findOrMakeTab('Root.SocialMedia', _t(__CLASS__ . '.SocialMediaTab', 'Social Media')); |
|
| 39 | 39 | |
| 40 | - $fields->addFieldToTab( |
|
| 41 | - 'Root.SocialMedia', |
|
| 42 | - $facebookURL = TextField::create( |
|
| 43 | - 'FacebookURL', |
|
| 44 | - _t(__CLASS__ . '.FbField', 'Facebook UID or username') |
|
| 45 | - ) |
|
| 46 | - ); |
|
| 47 | - $facebookURL->setDescription( |
|
| 48 | - DBField::create_field('HTMLFragment', _t( |
|
| 49 | - __CLASS__ . '.FbFieldDesc', |
|
| 50 | - 'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/' |
|
| 51 | - . '<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)' |
|
| 52 | - )) |
|
| 53 | - ); |
|
| 40 | + $fields->addFieldToTab( |
|
| 41 | + 'Root.SocialMedia', |
|
| 42 | + $facebookURL = TextField::create( |
|
| 43 | + 'FacebookURL', |
|
| 44 | + _t(__CLASS__ . '.FbField', 'Facebook UID or username') |
|
| 45 | + ) |
|
| 46 | + ); |
|
| 47 | + $facebookURL->setDescription( |
|
| 48 | + DBField::create_field('HTMLFragment', _t( |
|
| 49 | + __CLASS__ . '.FbFieldDesc', |
|
| 50 | + 'Facebook link (everything after the "http://facebook.com/", eg http://facebook.com/' |
|
| 51 | + . '<strong>username</strong> or http://facebook.com/<strong>pages/108510539573</strong>)' |
|
| 52 | + )) |
|
| 53 | + ); |
|
| 54 | 54 | |
| 55 | - $fields->addFieldToTab( |
|
| 56 | - 'Root.SocialMedia', |
|
| 57 | - $twitterUsername = TextField::create( |
|
| 58 | - 'TwitterUsername', |
|
| 59 | - _t(__CLASS__ . '.TwitterField', 'Twitter username') |
|
| 60 | - ) |
|
| 61 | - ); |
|
| 62 | - $twitterUsername->setDescription( |
|
| 63 | - DBField::create_field('HTMLFragment', _t( |
|
| 64 | - __CLASS__ . '.TwitterFieldDesc', |
|
| 65 | - 'Twitter username (eg, http://twitter.com/<strong>username</strong>)' |
|
| 66 | - )) |
|
| 67 | - ); |
|
| 68 | - } |
|
| 55 | + $fields->addFieldToTab( |
|
| 56 | + 'Root.SocialMedia', |
|
| 57 | + $twitterUsername = TextField::create( |
|
| 58 | + 'TwitterUsername', |
|
| 59 | + _t(__CLASS__ . '.TwitterField', 'Twitter username') |
|
| 60 | + ) |
|
| 61 | + ); |
|
| 62 | + $twitterUsername->setDescription( |
|
| 63 | + DBField::create_field('HTMLFragment', _t( |
|
| 64 | + __CLASS__ . '.TwitterFieldDesc', |
|
| 65 | + 'Twitter username (eg, http://twitter.com/<strong>username</strong>)' |
|
| 66 | + )) |
|
| 67 | + ); |
|
| 68 | + } |
|
| 69 | 69 | } |
@@ -7,50 +7,50 @@ |
||
| 7 | 7 | |
| 8 | 8 | class NewsHolder extends DatedUpdateHolder |
| 9 | 9 | { |
| 10 | - private static $description = 'Container page for News Pages, provides news filtering and pagination'; |
|
| 11 | - |
|
| 12 | - private static $allowed_children = [ |
|
| 13 | - NewsPage::class, |
|
| 14 | - ]; |
|
| 15 | - |
|
| 16 | - private static $default_child = NewsPage::class; |
|
| 17 | - |
|
| 18 | - private static $update_name = 'News'; |
|
| 19 | - |
|
| 20 | - private static $update_class = NewsPage::class; |
|
| 21 | - |
|
| 22 | - private static $icon_class = 'font-icon-news'; |
|
| 23 | - |
|
| 24 | - private static $singular_name = 'News Holder'; |
|
| 25 | - |
|
| 26 | - private static $plural_name = 'News Holders'; |
|
| 27 | - |
|
| 28 | - private static $table_name = 'NewsHolder'; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * Find all site's news items, based on some filters. |
|
| 32 | - * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together. |
|
| 33 | - * |
|
| 34 | - * @param string $className The name of the class to fetch. |
|
| 35 | - * @param int $parentID The ID of the holder to extract the news items from. |
|
| 36 | - * @param int $tagID The ID of the tag to filter the news items by. |
|
| 37 | - * @param string $dateFrom The beginning of a date filter range. |
|
| 38 | - * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for. |
|
| 39 | - * @param int $year Numeric value of the year to show. |
|
| 40 | - * @param int $monthNumber Numeric value of the month to show. |
|
| 41 | - * |
|
| 42 | - * @returns DataList|PaginatedList |
|
| 43 | - */ |
|
| 44 | - public static function AllUpdates( |
|
| 45 | - $className = NewsPage::class, |
|
| 46 | - $parentID = null, |
|
| 47 | - $tagID = null, |
|
| 48 | - $dateFrom = null, |
|
| 49 | - $dateTo = null, |
|
| 50 | - $year = null, |
|
| 51 | - $monthNumber = null |
|
| 52 | - ) { |
|
| 53 | - return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber) |
|
| 54 | - ->Sort('Date', 'DESC'); |
|
| 55 | - } |
|
| 10 | + private static $description = 'Container page for News Pages, provides news filtering and pagination'; |
|
| 11 | + |
|
| 12 | + private static $allowed_children = [ |
|
| 13 | + NewsPage::class, |
|
| 14 | + ]; |
|
| 15 | + |
|
| 16 | + private static $default_child = NewsPage::class; |
|
| 17 | + |
|
| 18 | + private static $update_name = 'News'; |
|
| 19 | + |
|
| 20 | + private static $update_class = NewsPage::class; |
|
| 21 | + |
|
| 22 | + private static $icon_class = 'font-icon-news'; |
|
| 23 | + |
|
| 24 | + private static $singular_name = 'News Holder'; |
|
| 25 | + |
|
| 26 | + private static $plural_name = 'News Holders'; |
|
| 27 | + |
|
| 28 | + private static $table_name = 'NewsHolder'; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * Find all site's news items, based on some filters. |
|
| 32 | + * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together. |
|
| 33 | + * |
|
| 34 | + * @param string $className The name of the class to fetch. |
|
| 35 | + * @param int $parentID The ID of the holder to extract the news items from. |
|
| 36 | + * @param int $tagID The ID of the tag to filter the news items by. |
|
| 37 | + * @param string $dateFrom The beginning of a date filter range. |
|
| 38 | + * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for. |
|
| 39 | + * @param int $year Numeric value of the year to show. |
|
| 40 | + * @param int $monthNumber Numeric value of the month to show. |
|
| 41 | + * |
|
| 42 | + * @returns DataList|PaginatedList |
|
| 43 | + */ |
|
| 44 | + public static function AllUpdates( |
|
| 45 | + $className = NewsPage::class, |
|
| 46 | + $parentID = null, |
|
| 47 | + $tagID = null, |
|
| 48 | + $dateFrom = null, |
|
| 49 | + $dateTo = null, |
|
| 50 | + $year = null, |
|
| 51 | + $monthNumber = null |
|
| 52 | + ) { |
|
| 53 | + return parent::AllUpdates($className, $parentID, $tagID, $dateFrom, $dateTo, $year, $monthNumber) |
|
| 54 | + ->Sort('Date', 'DESC'); |
|
| 55 | + } |
|
| 56 | 56 | } |
@@ -6,13 +6,13 @@ |
||
| 6 | 6 | |
| 7 | 7 | class SitemapPage extends Page |
| 8 | 8 | { |
| 9 | - private static $description = 'Lists all pages on the site'; |
|
| 9 | + private static $description = 'Lists all pages on the site'; |
|
| 10 | 10 | |
| 11 | - private static $singular_name = 'Sitemap Page'; |
|
| 11 | + private static $singular_name = 'Sitemap Page'; |
|
| 12 | 12 | |
| 13 | - private static $plural_name = 'Sitemap Pages'; |
|
| 13 | + private static $plural_name = 'Sitemap Pages'; |
|
| 14 | 14 | |
| 15 | - private static $table_name = 'SitemapPage'; |
|
| 15 | + private static $table_name = 'SitemapPage'; |
|
| 16 | 16 | |
| 17 | - private static $icon_class = 'font-icon-sitemap'; |
|
| 17 | + private static $icon_class = 'font-icon-sitemap'; |
|
| 18 | 18 | } |
@@ -7,57 +7,57 @@ |
||
| 7 | 7 | |
| 8 | 8 | class EventHolder extends DatedUpdateHolder |
| 9 | 9 | { |
| 10 | - private static $description = 'Container page for Event Pages, provides event filtering and pagination'; |
|
| 11 | - |
|
| 12 | - private static $allowed_children = [ |
|
| 13 | - EventPage::class, |
|
| 14 | - ]; |
|
| 15 | - |
|
| 16 | - private static $default_child = EventPage::class; |
|
| 17 | - |
|
| 18 | - private static $update_name = 'Events'; |
|
| 19 | - |
|
| 20 | - private static $update_class = EventPage::class; |
|
| 21 | - |
|
| 22 | - private static $icon_class = 'font-icon-p-event-alt'; |
|
| 23 | - |
|
| 24 | - private static $singular_name = 'Event Holder'; |
|
| 25 | - |
|
| 26 | - private static $plural_name = 'Event Holders'; |
|
| 27 | - |
|
| 28 | - private static $table_name = 'EventHolder'; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * Find all site's news items, based on some filters. |
|
| 32 | - * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together. |
|
| 33 | - * |
|
| 34 | - * @param string $className The name of the class to fetch. |
|
| 35 | - * @param int $parentID The ID of the holder to extract the news items from. |
|
| 36 | - * @param int $tagID The ID of the tag to filter the news items by. |
|
| 37 | - * @param string $dateFrom The beginning of a date filter range. |
|
| 38 | - * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for. |
|
| 39 | - * @param int $year Numeric value of the year to show. |
|
| 40 | - * @param int $monthNumber Numeric value of the month to show. |
|
| 41 | - * |
|
| 42 | - * @returns DataList|PaginatedList |
|
| 43 | - */ |
|
| 44 | - public static function AllUpdates( |
|
| 45 | - $className = 'Events', |
|
| 46 | - $parentID = null, |
|
| 47 | - $tagID = null, |
|
| 48 | - $dateFrom = null, |
|
| 49 | - $dateTo = null, |
|
| 50 | - $year = null, |
|
| 51 | - $monthNumber = null |
|
| 52 | - ) { |
|
| 53 | - return parent::AllUpdates( |
|
| 54 | - $className, |
|
| 55 | - $parentID, |
|
| 56 | - $tagID, |
|
| 57 | - $dateFrom, |
|
| 58 | - $dateTo, |
|
| 59 | - $year, |
|
| 60 | - $monthNumber |
|
| 61 | - )->Sort('Date', 'ASC'); |
|
| 62 | - } |
|
| 10 | + private static $description = 'Container page for Event Pages, provides event filtering and pagination'; |
|
| 11 | + |
|
| 12 | + private static $allowed_children = [ |
|
| 13 | + EventPage::class, |
|
| 14 | + ]; |
|
| 15 | + |
|
| 16 | + private static $default_child = EventPage::class; |
|
| 17 | + |
|
| 18 | + private static $update_name = 'Events'; |
|
| 19 | + |
|
| 20 | + private static $update_class = EventPage::class; |
|
| 21 | + |
|
| 22 | + private static $icon_class = 'font-icon-p-event-alt'; |
|
| 23 | + |
|
| 24 | + private static $singular_name = 'Event Holder'; |
|
| 25 | + |
|
| 26 | + private static $plural_name = 'Event Holders'; |
|
| 27 | + |
|
| 28 | + private static $table_name = 'EventHolder'; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * Find all site's news items, based on some filters. |
|
| 32 | + * Omitting parameters will prevent relevant filters from being applied. The filters are ANDed together. |
|
| 33 | + * |
|
| 34 | + * @param string $className The name of the class to fetch. |
|
| 35 | + * @param int $parentID The ID of the holder to extract the news items from. |
|
| 36 | + * @param int $tagID The ID of the tag to filter the news items by. |
|
| 37 | + * @param string $dateFrom The beginning of a date filter range. |
|
| 38 | + * @param string $dateTo The end of the date filter range. If empty, only one day will be searched for. |
|
| 39 | + * @param int $year Numeric value of the year to show. |
|
| 40 | + * @param int $monthNumber Numeric value of the month to show. |
|
| 41 | + * |
|
| 42 | + * @returns DataList|PaginatedList |
|
| 43 | + */ |
|
| 44 | + public static function AllUpdates( |
|
| 45 | + $className = 'Events', |
|
| 46 | + $parentID = null, |
|
| 47 | + $tagID = null, |
|
| 48 | + $dateFrom = null, |
|
| 49 | + $dateTo = null, |
|
| 50 | + $year = null, |
|
| 51 | + $monthNumber = null |
|
| 52 | + ) { |
|
| 53 | + return parent::AllUpdates( |
|
| 54 | + $className, |
|
| 55 | + $parentID, |
|
| 56 | + $tagID, |
|
| 57 | + $dateFrom, |
|
| 58 | + $dateTo, |
|
| 59 | + $year, |
|
| 60 | + $monthNumber |
|
| 61 | + )->Sort('Date', 'ASC'); |
|
| 62 | + } |
|
| 63 | 63 | } |
@@ -15,121 +15,121 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | class Quicklink extends DataObject |
| 17 | 17 | { |
| 18 | - private static $db = [ |
|
| 19 | - 'Name' => 'Varchar(255)', |
|
| 20 | - 'ExternalLink' => 'Varchar(255)', |
|
| 21 | - 'SortOrder' => 'Int', |
|
| 22 | - ]; |
|
| 23 | - |
|
| 24 | - private static $has_one = [ |
|
| 25 | - 'Parent' => BaseHomePage::class, |
|
| 26 | - 'InternalLink' => SiteTree::class, |
|
| 27 | - ]; |
|
| 28 | - |
|
| 29 | - private static $summary_fields = [ |
|
| 30 | - 'Name' => 'Name', |
|
| 31 | - 'InternalLink.Title' => 'Internal Link', |
|
| 32 | - 'ExternalLink' => 'External Link', |
|
| 33 | - ]; |
|
| 34 | - |
|
| 35 | - private static $table_name = 'Quicklink'; |
|
| 36 | - |
|
| 37 | - public function fieldLabels($includerelations = true) |
|
| 38 | - { |
|
| 39 | - $labels = parent::fieldLabels($includerelations); |
|
| 40 | - $labels['Name'] = _t(__CLASS__ . '.NameLabel', 'Name'); |
|
| 41 | - $labels['ExternalLink'] = _t(__CLASS__ . '.ExternalLinkLabel', 'External Link'); |
|
| 42 | - $labels['SortOrder'] = _t(__CLASS__ . '.SortOrderLabel', 'Sort Order'); |
|
| 43 | - $labels['ParentID'] = _t(__CLASS__ . '.ParentRelationLabel', 'Parent'); |
|
| 44 | - $labels['InternalLinkID'] = _t(__CLASS__ . '.InternalLinkLabel', 'Internal Link'); |
|
| 45 | - |
|
| 46 | - return $labels; |
|
| 47 | - } |
|
| 48 | - |
|
| 49 | - public function getLink() |
|
| 50 | - { |
|
| 51 | - if ($this->ExternalLink) { |
|
| 52 | - $url = parse_url($this->ExternalLink); |
|
| 53 | - |
|
| 54 | - // if no scheme set in the link, default to http |
|
| 55 | - if (!isset($url['scheme'])) { |
|
| 56 | - return 'http://' . $this->ExternalLink; |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - return $this->ExternalLink; |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - if ($this->InternalLinkID) { |
|
| 63 | - return $this->InternalLink()->Link(); |
|
| 64 | - } |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - public function canCreate($member = null, $context = []) |
|
| 68 | - { |
|
| 69 | - // Creating quick links should not be the same permission level as creating parent pages for them, they're |
|
| 70 | - // essentially content in the context of the page, so use the edit permission instead. |
|
| 71 | - return $this->canEdit($member); |
|
| 72 | - } |
|
| 73 | - |
|
| 74 | - public function canEdit($member = null) |
|
| 75 | - { |
|
| 76 | - return $this->Parent()->canEdit($member); |
|
| 77 | - } |
|
| 78 | - |
|
| 79 | - public function canDelete($member = null) |
|
| 80 | - { |
|
| 81 | - return $this->Parent()->canDelete($member); |
|
| 82 | - } |
|
| 83 | - |
|
| 84 | - public function canView($member = null) |
|
| 85 | - { |
|
| 86 | - return $this->Parent()->canView($member); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - public function getCMSFields() |
|
| 90 | - { |
|
| 91 | - $fields = parent::getCMSFields(); |
|
| 92 | - |
|
| 93 | - $fields->removeByName('ParentID'); |
|
| 94 | - |
|
| 95 | - $externalLinkField = $fields->fieldByName('Root.Main.ExternalLink'); |
|
| 96 | - |
|
| 97 | - $fields->removeByName('ExternalLink'); |
|
| 98 | - $fields->removeByName('InternalLinkID'); |
|
| 99 | - $fields->removeByName('SortOrder'); |
|
| 100 | - $externalLinkField->addExtraClass('noBorder'); |
|
| 101 | - |
|
| 102 | - $fields->addFieldToTab('Root.Main', CompositeField::create( |
|
| 103 | - array( |
|
| 104 | - TreeDropdownField::create( |
|
| 105 | - 'InternalLinkID', |
|
| 106 | - $this->fieldLabel('InternalLinkID'), |
|
| 107 | - SiteTree::class |
|
| 108 | - ), |
|
| 109 | - $externalLinkField, |
|
| 110 | - $wrap = CompositeField::create( |
|
| 111 | - $extraLabel = LiteralField::create( |
|
| 112 | - 'NoteOverride', |
|
| 113 | - sprintf('<div class="message good notice">%s</div>', _t( |
|
| 114 | - __CLASS__ . '.Note', |
|
| 115 | - 'Note: If you specify an External Link, the Internal Link will be ignored.' |
|
| 116 | - )) |
|
| 117 | - ) |
|
| 118 | - ) |
|
| 119 | - ) |
|
| 120 | - )); |
|
| 121 | - $fields->insertBefore( |
|
| 122 | - 'Name', |
|
| 123 | - LiteralField::create( |
|
| 124 | - 'Note', |
|
| 125 | - sprintf('<p>%s</p>', _t( |
|
| 126 | - __CLASS__ . '.Note2', |
|
| 127 | - 'Use this to specify a link to a page either on this site ' |
|
| 128 | - . '(Internal Link) or another site (External Link).' |
|
| 129 | - )) |
|
| 130 | - ) |
|
| 131 | - ); |
|
| 132 | - |
|
| 133 | - return $fields; |
|
| 134 | - } |
|
| 18 | + private static $db = [ |
|
| 19 | + 'Name' => 'Varchar(255)', |
|
| 20 | + 'ExternalLink' => 'Varchar(255)', |
|
| 21 | + 'SortOrder' => 'Int', |
|
| 22 | + ]; |
|
| 23 | + |
|
| 24 | + private static $has_one = [ |
|
| 25 | + 'Parent' => BaseHomePage::class, |
|
| 26 | + 'InternalLink' => SiteTree::class, |
|
| 27 | + ]; |
|
| 28 | + |
|
| 29 | + private static $summary_fields = [ |
|
| 30 | + 'Name' => 'Name', |
|
| 31 | + 'InternalLink.Title' => 'Internal Link', |
|
| 32 | + 'ExternalLink' => 'External Link', |
|
| 33 | + ]; |
|
| 34 | + |
|
| 35 | + private static $table_name = 'Quicklink'; |
|
| 36 | + |
|
| 37 | + public function fieldLabels($includerelations = true) |
|
| 38 | + { |
|
| 39 | + $labels = parent::fieldLabels($includerelations); |
|
| 40 | + $labels['Name'] = _t(__CLASS__ . '.NameLabel', 'Name'); |
|
| 41 | + $labels['ExternalLink'] = _t(__CLASS__ . '.ExternalLinkLabel', 'External Link'); |
|
| 42 | + $labels['SortOrder'] = _t(__CLASS__ . '.SortOrderLabel', 'Sort Order'); |
|
| 43 | + $labels['ParentID'] = _t(__CLASS__ . '.ParentRelationLabel', 'Parent'); |
|
| 44 | + $labels['InternalLinkID'] = _t(__CLASS__ . '.InternalLinkLabel', 'Internal Link'); |
|
| 45 | + |
|
| 46 | + return $labels; |
|
| 47 | + } |
|
| 48 | + |
|
| 49 | + public function getLink() |
|
| 50 | + { |
|
| 51 | + if ($this->ExternalLink) { |
|
| 52 | + $url = parse_url($this->ExternalLink); |
|
| 53 | + |
|
| 54 | + // if no scheme set in the link, default to http |
|
| 55 | + if (!isset($url['scheme'])) { |
|
| 56 | + return 'http://' . $this->ExternalLink; |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + return $this->ExternalLink; |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + if ($this->InternalLinkID) { |
|
| 63 | + return $this->InternalLink()->Link(); |
|
| 64 | + } |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + public function canCreate($member = null, $context = []) |
|
| 68 | + { |
|
| 69 | + // Creating quick links should not be the same permission level as creating parent pages for them, they're |
|
| 70 | + // essentially content in the context of the page, so use the edit permission instead. |
|
| 71 | + return $this->canEdit($member); |
|
| 72 | + } |
|
| 73 | + |
|
| 74 | + public function canEdit($member = null) |
|
| 75 | + { |
|
| 76 | + return $this->Parent()->canEdit($member); |
|
| 77 | + } |
|
| 78 | + |
|
| 79 | + public function canDelete($member = null) |
|
| 80 | + { |
|
| 81 | + return $this->Parent()->canDelete($member); |
|
| 82 | + } |
|
| 83 | + |
|
| 84 | + public function canView($member = null) |
|
| 85 | + { |
|
| 86 | + return $this->Parent()->canView($member); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + public function getCMSFields() |
|
| 90 | + { |
|
| 91 | + $fields = parent::getCMSFields(); |
|
| 92 | + |
|
| 93 | + $fields->removeByName('ParentID'); |
|
| 94 | + |
|
| 95 | + $externalLinkField = $fields->fieldByName('Root.Main.ExternalLink'); |
|
| 96 | + |
|
| 97 | + $fields->removeByName('ExternalLink'); |
|
| 98 | + $fields->removeByName('InternalLinkID'); |
|
| 99 | + $fields->removeByName('SortOrder'); |
|
| 100 | + $externalLinkField->addExtraClass('noBorder'); |
|
| 101 | + |
|
| 102 | + $fields->addFieldToTab('Root.Main', CompositeField::create( |
|
| 103 | + array( |
|
| 104 | + TreeDropdownField::create( |
|
| 105 | + 'InternalLinkID', |
|
| 106 | + $this->fieldLabel('InternalLinkID'), |
|
| 107 | + SiteTree::class |
|
| 108 | + ), |
|
| 109 | + $externalLinkField, |
|
| 110 | + $wrap = CompositeField::create( |
|
| 111 | + $extraLabel = LiteralField::create( |
|
| 112 | + 'NoteOverride', |
|
| 113 | + sprintf('<div class="message good notice">%s</div>', _t( |
|
| 114 | + __CLASS__ . '.Note', |
|
| 115 | + 'Note: If you specify an External Link, the Internal Link will be ignored.' |
|
| 116 | + )) |
|
| 117 | + ) |
|
| 118 | + ) |
|
| 119 | + ) |
|
| 120 | + )); |
|
| 121 | + $fields->insertBefore( |
|
| 122 | + 'Name', |
|
| 123 | + LiteralField::create( |
|
| 124 | + 'Note', |
|
| 125 | + sprintf('<p>%s</p>', _t( |
|
| 126 | + __CLASS__ . '.Note2', |
|
| 127 | + 'Use this to specify a link to a page either on this site ' |
|
| 128 | + . '(Internal Link) or another site (External Link).' |
|
| 129 | + )) |
|
| 130 | + ) |
|
| 131 | + ); |
|
| 132 | + |
|
| 133 | + return $fields; |
|
| 134 | + } |
|
| 135 | 135 | } |
@@ -9,21 +9,21 @@ |
||
| 9 | 9 | |
| 10 | 10 | class NewsPageTest extends SapphireTest |
| 11 | 11 | { |
| 12 | - protected $usesDatabase = true; |
|
| 12 | + protected $usesDatabase = true; |
|
| 13 | 13 | |
| 14 | - public function testGetNewsPageAuthor() |
|
| 15 | - { |
|
| 16 | - $holder = new NewsHolder(); |
|
| 17 | - $holder->Title = 'Holder'; |
|
| 18 | - $holder->write(); |
|
| 14 | + public function testGetNewsPageAuthor() |
|
| 15 | + { |
|
| 16 | + $holder = new NewsHolder(); |
|
| 17 | + $holder->Title = 'Holder'; |
|
| 18 | + $holder->write(); |
|
| 19 | 19 | |
| 20 | - $page = new NewsPage(); |
|
| 21 | - $page->Author = 'Leslie Lawless'; |
|
| 22 | - $page->ParentID = $holder->ID; |
|
| 23 | - $page->write(); |
|
| 20 | + $page = new NewsPage(); |
|
| 21 | + $page->Author = 'Leslie Lawless'; |
|
| 22 | + $page->ParentID = $holder->ID; |
|
| 23 | + $page->write(); |
|
| 24 | 24 | |
| 25 | - $field = $page->getNewsPageAuthor(); |
|
| 26 | - $this->assertInstanceOf(DBField::class, $field); |
|
| 27 | - $this->assertSame('Leslie Lawless', $field->getValue()); |
|
| 28 | - } |
|
| 25 | + $field = $page->getNewsPageAuthor(); |
|
| 26 | + $this->assertInstanceOf(DBField::class, $field); |
|
| 27 | + $this->assertSame('Leslie Lawless', $field->getValue()); |
|
| 28 | + } |
|
| 29 | 29 | } |