@@ -19,78 +19,78 @@ |
||
19 | 19 | class LoginAttemptNotifications extends Extension |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * |
|
24 | - * @return mixed null |
|
25 | - */ |
|
26 | - public function init() |
|
27 | - { |
|
22 | + /** |
|
23 | + * |
|
24 | + * @return mixed null |
|
25 | + */ |
|
26 | + public function init() |
|
27 | + { |
|
28 | 28 | |
29 | - // Exclude default admin. |
|
30 | - $member = Security::getCurrentUser(); |
|
31 | - if (!$member || !$member->ID) { |
|
32 | - return; |
|
33 | - } |
|
29 | + // Exclude default admin. |
|
30 | + $member = Security::getCurrentUser(); |
|
31 | + if (!$member || !$member->ID) { |
|
32 | + return; |
|
33 | + } |
|
34 | 34 | |
35 | - $message = null; |
|
36 | - $session = $this->owner->getRequest()->getSession(); |
|
35 | + $message = null; |
|
36 | + $session = $this->owner->getRequest()->getSession(); |
|
37 | 37 | |
38 | - Requirements::javascript('cwp/cwp-core:javascript/LoginAttemptNotifications.js'); |
|
39 | - $sessionLastVisited = $session->get('LoginAttemptNotifications.SessionLastVisited'); |
|
40 | - if ($sessionLastVisited) { |
|
41 | - // Session already in progress. Show all attempts since the session was last visited. |
|
38 | + Requirements::javascript('cwp/cwp-core:javascript/LoginAttemptNotifications.js'); |
|
39 | + $sessionLastVisited = $session->get('LoginAttemptNotifications.SessionLastVisited'); |
|
40 | + if ($sessionLastVisited) { |
|
41 | + // Session already in progress. Show all attempts since the session was last visited. |
|
42 | 42 | |
43 | - $meantimeLoginAttempts = LoginAttempt::get()->filter([ |
|
44 | - 'MemberID' => $member->ID, |
|
45 | - 'Created:GreaterThan' => $sessionLastVisited |
|
46 | - ]); |
|
43 | + $meantimeLoginAttempts = LoginAttempt::get()->filter([ |
|
44 | + 'MemberID' => $member->ID, |
|
45 | + 'Created:GreaterThan' => $sessionLastVisited |
|
46 | + ]); |
|
47 | 47 | |
48 | - $attempts = $meantimeLoginAttempts->count(); |
|
49 | - if ($attempts) { |
|
50 | - $lastVisitedObj = DBDatetime::create(); |
|
51 | - $lastVisitedObj->setValue($sessionLastVisited); |
|
52 | - $elapsed = $lastVisitedObj->TimeDiff(); |
|
53 | - $failures = $meantimeLoginAttempts->filter(['Status' => 'Failure'])->count(); |
|
54 | - $IPs = array_unique($meantimeLoginAttempts->column('IP')); |
|
48 | + $attempts = $meantimeLoginAttempts->count(); |
|
49 | + if ($attempts) { |
|
50 | + $lastVisitedObj = DBDatetime::create(); |
|
51 | + $lastVisitedObj->setValue($sessionLastVisited); |
|
52 | + $elapsed = $lastVisitedObj->TimeDiff(); |
|
53 | + $failures = $meantimeLoginAttempts->filter(['Status' => 'Failure'])->count(); |
|
54 | + $IPs = array_unique($meantimeLoginAttempts->column('IP')); |
|
55 | 55 | |
56 | - if ($attempts == 1) { |
|
57 | - $statusString = $failures ? "a failed" : "a successful"; |
|
58 | - $message = "In the last $elapsed $statusString login attempt to your account was " |
|
59 | - . "registered. The attempt was made from ${IPs[0]}. "; |
|
60 | - } else { |
|
61 | - if ($failures == $attempts) { |
|
62 | - $statusString = $failures ? "failed" : "successful"; |
|
63 | - $message = "In the last $elapsed $attempts $statusString login " |
|
64 | - . "attempts to your account were registered. "; |
|
65 | - } else { |
|
66 | - $message = "In the last $elapsed $attempts login attempts to your " |
|
67 | - . "account were registered, of which $failures failed. "; |
|
68 | - } |
|
56 | + if ($attempts == 1) { |
|
57 | + $statusString = $failures ? "a failed" : "a successful"; |
|
58 | + $message = "In the last $elapsed $statusString login attempt to your account was " |
|
59 | + . "registered. The attempt was made from ${IPs[0]}. "; |
|
60 | + } else { |
|
61 | + if ($failures == $attempts) { |
|
62 | + $statusString = $failures ? "failed" : "successful"; |
|
63 | + $message = "In the last $elapsed $attempts $statusString login " |
|
64 | + . "attempts to your account were registered. "; |
|
65 | + } else { |
|
66 | + $message = "In the last $elapsed $attempts login attempts to your " |
|
67 | + . "account were registered, of which $failures failed. "; |
|
68 | + } |
|
69 | 69 | |
70 | - $message .= "The attempts were from " . implode(', ', $IPs) . '. '; |
|
70 | + $message .= "The attempts were from " . implode(', ', $IPs) . '. '; |
|
71 | 71 | |
72 | - // TODO: add this call to action in a way that doesn't break out of the availabel space. Fix CSS? |
|
73 | - // $message .= "If you suspect somebody else might be trying to access |
|
74 | - // . "your account, please contact support."; |
|
75 | - } |
|
76 | - } |
|
77 | - } else { |
|
78 | - // New session - show last login attempt. |
|
79 | - // TODO: this currently does NOT surface to the frontend in any way. |
|
80 | - $lastLoginAttempt = LoginAttempt::get()->filter([ |
|
81 | - 'MemberID' => $member->ID |
|
82 | - ])->sort('Created DESC')->First(); |
|
72 | + // TODO: add this call to action in a way that doesn't break out of the availabel space. Fix CSS? |
|
73 | + // $message .= "If you suspect somebody else might be trying to access |
|
74 | + // . "your account, please contact support."; |
|
75 | + } |
|
76 | + } |
|
77 | + } else { |
|
78 | + // New session - show last login attempt. |
|
79 | + // TODO: this currently does NOT surface to the frontend in any way. |
|
80 | + $lastLoginAttempt = LoginAttempt::get()->filter([ |
|
81 | + 'MemberID' => $member->ID |
|
82 | + ])->sort('Created DESC')->First(); |
|
83 | 83 | |
84 | - if ($lastLoginAttempt) { |
|
85 | - $date = $lastLoginAttempt->Created; |
|
86 | - $message = "Last login attempt to your account was on $lastLoginAttempt->Created " |
|
87 | - . "from $lastLoginAttempt->IP"; |
|
88 | - $message .= $lastLoginAttempt->Status == 'Failure' ? " and was successful." : "and has failed."; |
|
89 | - } |
|
90 | - } |
|
84 | + if ($lastLoginAttempt) { |
|
85 | + $date = $lastLoginAttempt->Created; |
|
86 | + $message = "Last login attempt to your account was on $lastLoginAttempt->Created " |
|
87 | + . "from $lastLoginAttempt->IP"; |
|
88 | + $message .= $lastLoginAttempt->Status == 'Failure' ? " and was successful." : "and has failed."; |
|
89 | + } |
|
90 | + } |
|
91 | 91 | |
92 | - $session->set('LoginAttemptNotifications.SessionLastVisited', DBDatetime::now()->Format('Y-m-d H:i:s')); |
|
92 | + $session->set('LoginAttemptNotifications.SessionLastVisited', DBDatetime::now()->Format('Y-m-d H:i:s')); |
|
93 | 93 | |
94 | - $this->owner->getResponse()->addHeader('X-LoginAttemptNotifications', $message); |
|
95 | - } |
|
94 | + $this->owner->getResponse()->addHeader('X-LoginAttemptNotifications', $message); |
|
95 | + } |
|
96 | 96 | } |
@@ -53,12 +53,12 @@ discard block |
||
53 | 53 | $failures = $meantimeLoginAttempts->filter(['Status' => 'Failure'])->count(); |
54 | 54 | $IPs = array_unique($meantimeLoginAttempts->column('IP')); |
55 | 55 | |
56 | - if ($attempts == 1) { |
|
56 | + if ($attempts==1) { |
|
57 | 57 | $statusString = $failures ? "a failed" : "a successful"; |
58 | 58 | $message = "In the last $elapsed $statusString login attempt to your account was " |
59 | 59 | . "registered. The attempt was made from ${IPs[0]}. "; |
60 | 60 | } else { |
61 | - if ($failures == $attempts) { |
|
61 | + if ($failures==$attempts) { |
|
62 | 62 | $statusString = $failures ? "failed" : "successful"; |
63 | 63 | $message = "In the last $elapsed $attempts $statusString login " |
64 | 64 | . "attempts to your account were registered. "; |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | $date = $lastLoginAttempt->Created; |
86 | 86 | $message = "Last login attempt to your account was on $lastLoginAttempt->Created " |
87 | 87 | . "from $lastLoginAttempt->IP"; |
88 | - $message .= $lastLoginAttempt->Status == 'Failure' ? " and was successful." : "and has failed."; |
|
88 | + $message .= $lastLoginAttempt->Status=='Failure' ? " and was successful." : "and has failed."; |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 |
@@ -16,48 +16,48 @@ |
||
16 | 16 | class RichLinksExtension extends Extension |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var array |
|
21 | - */ |
|
22 | - private static $casting = [ |
|
23 | - 'RichLinks' => 'HTMLText' |
|
24 | - ]; |
|
25 | - |
|
26 | - /** |
|
27 | - * @return string |
|
28 | - */ |
|
29 | - public function RichLinks() |
|
30 | - { |
|
31 | - // Note: |
|
32 | - // Assume we can use Regexes because the link will always be formatted |
|
33 | - // in the same way coming from the CMS. |
|
34 | - |
|
35 | - $content = $this->owner->value; |
|
36 | - |
|
37 | - // Find all file links for processing. |
|
38 | - preg_match_all('/<a.*href="\[file_link,id=([0-9]+)\].*".*>.*<\/a>/U', $content, $matches); |
|
39 | - |
|
40 | - // Attach the file type and size to each of the links. |
|
41 | - for ($i = 0; $i < count($matches[0]); $i++) { |
|
42 | - $file = DataObject::get_by_id('File', $matches[1][$i]); |
|
43 | - if ($file) { |
|
44 | - $size = $file->getSize(); |
|
45 | - $ext = strtoupper($file->getExtension()); |
|
46 | - // Replace the closing </a> tag with the size span (and reattach the closing tag). |
|
47 | - $newLink = substr($matches[0][$i], 0, strlen($matches[0][$i]) - 4) |
|
48 | - . "<span class='fileExt'> [$ext, $size]</span></a>"; |
|
49 | - $content = str_replace($matches[0][$i], $newLink, $content); |
|
50 | - } |
|
51 | - } |
|
52 | - |
|
53 | - // Inject extra attributes into the external links. |
|
54 | - $pattern = '/(<a.*)(href=\"https?:\/\/[^\"]*\"[^>]*>.*)(<\/a>)/iU'; |
|
55 | - $replacement = sprintf( |
|
56 | - '$1class="external" rel="external" title="%s" $2<span class="nonvisual-indicator">(external link)</span>$3', |
|
57 | - _t('RichLinks.OpenLinkTitle', 'Open external link') |
|
58 | - ); |
|
59 | - $content = preg_replace($pattern, $replacement, $content, -1); |
|
60 | - |
|
61 | - return $content; |
|
62 | - } |
|
19 | + /** |
|
20 | + * @var array |
|
21 | + */ |
|
22 | + private static $casting = [ |
|
23 | + 'RichLinks' => 'HTMLText' |
|
24 | + ]; |
|
25 | + |
|
26 | + /** |
|
27 | + * @return string |
|
28 | + */ |
|
29 | + public function RichLinks() |
|
30 | + { |
|
31 | + // Note: |
|
32 | + // Assume we can use Regexes because the link will always be formatted |
|
33 | + // in the same way coming from the CMS. |
|
34 | + |
|
35 | + $content = $this->owner->value; |
|
36 | + |
|
37 | + // Find all file links for processing. |
|
38 | + preg_match_all('/<a.*href="\[file_link,id=([0-9]+)\].*".*>.*<\/a>/U', $content, $matches); |
|
39 | + |
|
40 | + // Attach the file type and size to each of the links. |
|
41 | + for ($i = 0; $i < count($matches[0]); $i++) { |
|
42 | + $file = DataObject::get_by_id('File', $matches[1][$i]); |
|
43 | + if ($file) { |
|
44 | + $size = $file->getSize(); |
|
45 | + $ext = strtoupper($file->getExtension()); |
|
46 | + // Replace the closing </a> tag with the size span (and reattach the closing tag). |
|
47 | + $newLink = substr($matches[0][$i], 0, strlen($matches[0][$i]) - 4) |
|
48 | + . "<span class='fileExt'> [$ext, $size]</span></a>"; |
|
49 | + $content = str_replace($matches[0][$i], $newLink, $content); |
|
50 | + } |
|
51 | + } |
|
52 | + |
|
53 | + // Inject extra attributes into the external links. |
|
54 | + $pattern = '/(<a.*)(href=\"https?:\/\/[^\"]*\"[^>]*>.*)(<\/a>)/iU'; |
|
55 | + $replacement = sprintf( |
|
56 | + '$1class="external" rel="external" title="%s" $2<span class="nonvisual-indicator">(external link)</span>$3', |
|
57 | + _t('RichLinks.OpenLinkTitle', 'Open external link') |
|
58 | + ); |
|
59 | + $content = preg_replace($pattern, $replacement, $content, -1); |
|
60 | + |
|
61 | + return $content; |
|
62 | + } |
|
63 | 63 | } |
@@ -13,13 +13,13 @@ |
||
13 | 13 | class CustomHtmlEditorFieldToolbar extends Extension |
14 | 14 | { |
15 | 15 | |
16 | - /** |
|
17 | - * @param Form $form |
|
18 | - * @return void |
|
19 | - */ |
|
20 | - public function updateMediaForm(Form $form) |
|
21 | - { |
|
22 | - Requirements::add_i18n_javascript('cwp/cwp-core:javascript/lang'); |
|
23 | - Requirements::javascript('cwp/cwp-core:javascript/CustomHtmlEditorFieldToolbar.js'); |
|
24 | - } |
|
16 | + /** |
|
17 | + * @param Form $form |
|
18 | + * @return void |
|
19 | + */ |
|
20 | + public function updateMediaForm(Form $form) |
|
21 | + { |
|
22 | + Requirements::add_i18n_javascript('cwp/cwp-core:javascript/lang'); |
|
23 | + Requirements::javascript('cwp/cwp-core:javascript/CustomHtmlEditorFieldToolbar.js'); |
|
24 | + } |
|
25 | 25 | } |
@@ -18,86 +18,86 @@ |
||
18 | 18 | abstract class CwpSearchIndex extends SolrIndex |
19 | 19 | { |
20 | 20 | |
21 | - /** |
|
22 | - * Copy all fields into both search and spellcheck data source |
|
23 | - * |
|
24 | - * @var array |
|
25 | - * @config |
|
26 | - */ |
|
27 | - private static $copy_fields = array( |
|
28 | - '_text', |
|
29 | - '_spellcheckText' |
|
30 | - ); |
|
21 | + /** |
|
22 | + * Copy all fields into both search and spellcheck data source |
|
23 | + * |
|
24 | + * @var array |
|
25 | + * @config |
|
26 | + */ |
|
27 | + private static $copy_fields = array( |
|
28 | + '_text', |
|
29 | + '_spellcheckText' |
|
30 | + ); |
|
31 | 31 | |
32 | - /** |
|
33 | - * Default dictionary to use. This will overwrite the 'spellcheck.dictionary' option for searches given, |
|
34 | - * unless set to empty. |
|
35 | - * |
|
36 | - * '_spellcheck' is a predefined by the cwp infrastructure, which is configured |
|
37 | - * to be built from the '_spellcheckText' field. You can't rename this within CWP. |
|
38 | - * |
|
39 | - * @var string |
|
40 | - * @config |
|
41 | - */ |
|
42 | - private static $dictionary = '_spellcheck'; |
|
32 | + /** |
|
33 | + * Default dictionary to use. This will overwrite the 'spellcheck.dictionary' option for searches given, |
|
34 | + * unless set to empty. |
|
35 | + * |
|
36 | + * '_spellcheck' is a predefined by the cwp infrastructure, which is configured |
|
37 | + * to be built from the '_spellcheckText' field. You can't rename this within CWP. |
|
38 | + * |
|
39 | + * @var string |
|
40 | + * @config |
|
41 | + */ |
|
42 | + private static $dictionary = '_spellcheck'; |
|
43 | 43 | |
44 | - public function init() |
|
45 | - { |
|
46 | - // Add optional boost |
|
47 | - if (SiteTree::has_extension(CwpSearchBoostExtension::class)) { |
|
48 | - $this->setFieldBoosting(SiteTree::class . '_SearchBoost', SiteTree::config()->get('search_boost')); |
|
49 | - } |
|
50 | - } |
|
44 | + public function init() |
|
45 | + { |
|
46 | + // Add optional boost |
|
47 | + if (SiteTree::has_extension(CwpSearchBoostExtension::class)) { |
|
48 | + $this->setFieldBoosting(SiteTree::class . '_SearchBoost', SiteTree::config()->get('search_boost')); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Upload config for this index to the given store |
|
54 | - * |
|
55 | - * @param SolrConfigStore $store |
|
56 | - */ |
|
57 | - public function uploadConfig($store) |
|
58 | - { |
|
59 | - parent::uploadConfig($store); |
|
52 | + /** |
|
53 | + * Upload config for this index to the given store |
|
54 | + * |
|
55 | + * @param SolrConfigStore $store |
|
56 | + */ |
|
57 | + public function uploadConfig($store) |
|
58 | + { |
|
59 | + parent::uploadConfig($store); |
|
60 | 60 | |
61 | - // Upload configured synonyms {@see SynonymsSiteConfig} |
|
62 | - $siteConfig = SiteConfig::current_site_config(); |
|
63 | - if ($siteConfig->SearchSynonyms) { |
|
64 | - $store->uploadString( |
|
65 | - $this->getIndexName(), |
|
66 | - 'synonyms.txt', |
|
67 | - $siteConfig->SearchSynonyms |
|
68 | - ); |
|
69 | - } |
|
70 | - } |
|
61 | + // Upload configured synonyms {@see SynonymsSiteConfig} |
|
62 | + $siteConfig = SiteConfig::current_site_config(); |
|
63 | + if ($siteConfig->SearchSynonyms) { |
|
64 | + $store->uploadString( |
|
65 | + $this->getIndexName(), |
|
66 | + 'synonyms.txt', |
|
67 | + $siteConfig->SearchSynonyms |
|
68 | + ); |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * |
|
74 | - * @return string |
|
75 | - */ |
|
76 | - public function getFieldDefinitions() |
|
77 | - { |
|
78 | - $xml = parent::getFieldDefinitions(); |
|
79 | - $xml .= "\n\n\t\t<!-- Additional custom fields for spell checking -->"; |
|
80 | - $xml .= "\n\t\t<field name='_spellcheckText' type='textSpellHtml' indexed='true' " |
|
81 | - . "stored='false' multiValued='true' />"; |
|
72 | + /** |
|
73 | + * |
|
74 | + * @return string |
|
75 | + */ |
|
76 | + public function getFieldDefinitions() |
|
77 | + { |
|
78 | + $xml = parent::getFieldDefinitions(); |
|
79 | + $xml .= "\n\n\t\t<!-- Additional custom fields for spell checking -->"; |
|
80 | + $xml .= "\n\t\t<field name='_spellcheckText' type='textSpellHtml' indexed='true' " |
|
81 | + . "stored='false' multiValued='true' />"; |
|
82 | 82 | |
83 | - return $xml; |
|
84 | - } |
|
83 | + return $xml; |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * |
|
88 | - * @param SearchQuery $query |
|
89 | - * @param int $offset |
|
90 | - * @param int $limit |
|
91 | - * @param array $params |
|
92 | - * @return ArrayData |
|
93 | - */ |
|
94 | - public function search(SearchQuery $query, $offset = -1, $limit = -1, $params = []) |
|
95 | - { |
|
96 | - // Override dictionary if given |
|
97 | - if ($dictionary = $this->config()->dictionary) { |
|
98 | - $params["spellcheck.dictionary"] = $dictionary; |
|
99 | - } |
|
86 | + /** |
|
87 | + * |
|
88 | + * @param SearchQuery $query |
|
89 | + * @param int $offset |
|
90 | + * @param int $limit |
|
91 | + * @param array $params |
|
92 | + * @return ArrayData |
|
93 | + */ |
|
94 | + public function search(SearchQuery $query, $offset = -1, $limit = -1, $params = []) |
|
95 | + { |
|
96 | + // Override dictionary if given |
|
97 | + if ($dictionary = $this->config()->dictionary) { |
|
98 | + $params["spellcheck.dictionary"] = $dictionary; |
|
99 | + } |
|
100 | 100 | |
101 | - return parent::search($query, $offset, $limit, $params); |
|
102 | - } |
|
101 | + return parent::search($query, $offset, $limit, $params); |
|
102 | + } |
|
103 | 103 | } |
@@ -18,57 +18,57 @@ |
||
18 | 18 | |
19 | 19 | class CwpAtomFeed extends RSSFeed |
20 | 20 | { |
21 | - public function __construct( |
|
22 | - SS_List $entries, |
|
23 | - $link, |
|
24 | - $title, |
|
25 | - $description = null, |
|
26 | - $titleField = "Title", |
|
27 | - $descriptionField = "Content", |
|
28 | - $authorField = null, |
|
29 | - $lastModified = null, |
|
30 | - $etag = null |
|
31 | - ) { |
|
32 | - parent::__construct( |
|
33 | - $entries, |
|
34 | - $link, |
|
35 | - $title, |
|
36 | - $description, |
|
37 | - $titleField, |
|
38 | - $descriptionField, |
|
39 | - $authorField, |
|
40 | - $lastModified |
|
41 | - ); |
|
21 | + public function __construct( |
|
22 | + SS_List $entries, |
|
23 | + $link, |
|
24 | + $title, |
|
25 | + $description = null, |
|
26 | + $titleField = "Title", |
|
27 | + $descriptionField = "Content", |
|
28 | + $authorField = null, |
|
29 | + $lastModified = null, |
|
30 | + $etag = null |
|
31 | + ) { |
|
32 | + parent::__construct( |
|
33 | + $entries, |
|
34 | + $link, |
|
35 | + $title, |
|
36 | + $description, |
|
37 | + $titleField, |
|
38 | + $descriptionField, |
|
39 | + $authorField, |
|
40 | + $lastModified |
|
41 | + ); |
|
42 | 42 | |
43 | - $this->setTemplate(__CLASS__); |
|
44 | - } |
|
43 | + $this->setTemplate(__CLASS__); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Include an link to the feed |
|
48 | - * |
|
49 | - * @param string $url URL of the feed |
|
50 | - * @param string $title Title to show |
|
51 | - */ |
|
52 | - public static function linkToFeed($url, $title = null) |
|
53 | - { |
|
54 | - $title = Convert::raw2xml($title); |
|
55 | - Requirements::insertHeadTags( |
|
56 | - '<link rel="alternate" type="application/atom+xml" title="' . $title . |
|
57 | - '" href="' . $url . '" />' |
|
58 | - ); |
|
59 | - } |
|
46 | + /** |
|
47 | + * Include an link to the feed |
|
48 | + * |
|
49 | + * @param string $url URL of the feed |
|
50 | + * @param string $title Title to show |
|
51 | + */ |
|
52 | + public static function linkToFeed($url, $title = null) |
|
53 | + { |
|
54 | + $title = Convert::raw2xml($title); |
|
55 | + Requirements::insertHeadTags( |
|
56 | + '<link rel="alternate" type="application/atom+xml" title="' . $title . |
|
57 | + '" href="' . $url . '" />' |
|
58 | + ); |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Output the feed to the browser |
|
63 | - * |
|
64 | - * @return DBHTMLText |
|
65 | - */ |
|
66 | - public function outputToBrowser() |
|
67 | - { |
|
68 | - $output = parent::outputToBrowser(); |
|
69 | - $response = Controller::curr()->getResponse(); |
|
70 | - $response->addHeader("Content-Type", "application/atom+xml"); |
|
61 | + /** |
|
62 | + * Output the feed to the browser |
|
63 | + * |
|
64 | + * @return DBHTMLText |
|
65 | + */ |
|
66 | + public function outputToBrowser() |
|
67 | + { |
|
68 | + $output = parent::outputToBrowser(); |
|
69 | + $response = Controller::curr()->getResponse(); |
|
70 | + $response->addHeader("Content-Type", "application/atom+xml"); |
|
71 | 71 | |
72 | - return $output; |
|
73 | - } |
|
72 | + return $output; |
|
73 | + } |
|
74 | 74 | } |
@@ -12,68 +12,68 @@ |
||
12 | 12 | */ |
13 | 13 | class CwpSolrConfigStore implements SolrConfigStore |
14 | 14 | { |
15 | - /** |
|
16 | - * @var string |
|
17 | - */ |
|
18 | - protected $remote = ''; |
|
15 | + /** |
|
16 | + * @var string |
|
17 | + */ |
|
18 | + protected $remote = ''; |
|
19 | 19 | |
20 | - /** |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $url = ''; |
|
20 | + /** |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $url = ''; |
|
24 | 24 | |
25 | - /** |
|
26 | - * @param array $config |
|
27 | - */ |
|
28 | - public function __construct($config) |
|
29 | - { |
|
30 | - $options = Solr::solr_options(); |
|
25 | + /** |
|
26 | + * @param array $config |
|
27 | + */ |
|
28 | + public function __construct($config) |
|
29 | + { |
|
30 | + $options = Solr::solr_options(); |
|
31 | 31 | |
32 | - $this->url = implode('', [ |
|
33 | - 'http://', |
|
34 | - isset($config['auth']) ? $config['auth'] . '@' : '', |
|
35 | - $options['host'] . ':' . $options['port'], |
|
36 | - $config['path'] |
|
37 | - ]); |
|
38 | - $this->remote = $config['remotepath']; |
|
39 | - } |
|
32 | + $this->url = implode('', [ |
|
33 | + 'http://', |
|
34 | + isset($config['auth']) ? $config['auth'] . '@' : '', |
|
35 | + $options['host'] . ':' . $options['port'], |
|
36 | + $config['path'] |
|
37 | + ]); |
|
38 | + $this->remote = $config['remotepath']; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param string $index |
|
43 | - * @param string $file |
|
44 | - * @return void |
|
45 | - */ |
|
46 | - public function uploadFile($index, $file) |
|
47 | - { |
|
48 | - $this->uploadString($index, basename($file), file_get_contents($file)); |
|
49 | - } |
|
41 | + /** |
|
42 | + * @param string $index |
|
43 | + * @param string $file |
|
44 | + * @return void |
|
45 | + */ |
|
46 | + public function uploadFile($index, $file) |
|
47 | + { |
|
48 | + $this->uploadString($index, basename($file), file_get_contents($file)); |
|
49 | + } |
|
50 | 50 | |
51 | - /** |
|
52 | - * |
|
53 | - * @param string $index |
|
54 | - * @param string $filename |
|
55 | - * @param string $string |
|
56 | - * @return void |
|
57 | - */ |
|
58 | - public function uploadString($index, $filename, $string) |
|
59 | - { |
|
60 | - $targetDir = "{$this->url}/config/$index"; |
|
51 | + /** |
|
52 | + * |
|
53 | + * @param string $index |
|
54 | + * @param string $filename |
|
55 | + * @param string $string |
|
56 | + * @return void |
|
57 | + */ |
|
58 | + public function uploadString($index, $filename, $string) |
|
59 | + { |
|
60 | + $targetDir = "{$this->url}/config/$index"; |
|
61 | 61 | |
62 | - file_get_contents($targetDir . '/' . $filename, false, stream_context_create([ |
|
63 | - 'http' => [ |
|
64 | - 'method' => 'POST', |
|
65 | - 'header' => 'Content-type: application/octet-stream', |
|
66 | - 'content' => (string) $string |
|
67 | - ] |
|
68 | - ])); |
|
69 | - } |
|
62 | + file_get_contents($targetDir . '/' . $filename, false, stream_context_create([ |
|
63 | + 'http' => [ |
|
64 | + 'method' => 'POST', |
|
65 | + 'header' => 'Content-type: application/octet-stream', |
|
66 | + 'content' => (string) $string |
|
67 | + ] |
|
68 | + ])); |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * @param string $index |
|
73 | - * @return string |
|
74 | - */ |
|
75 | - public function instanceDir($index) |
|
76 | - { |
|
77 | - return $this->remote ? "{$this->remote}/$index" : $index; |
|
78 | - } |
|
71 | + /** |
|
72 | + * @param string $index |
|
73 | + * @return string |
|
74 | + */ |
|
75 | + public function instanceDir($index) |
|
76 | + { |
|
77 | + return $this->remote ? "{$this->remote}/$index" : $index; |
|
78 | + } |
|
79 | 79 | } |
@@ -63,7 +63,7 @@ |
||
63 | 63 | 'http' => [ |
64 | 64 | 'method' => 'POST', |
65 | 65 | 'header' => 'Content-type: application/octet-stream', |
66 | - 'content' => (string) $string |
|
66 | + 'content' => (string)$string |
|
67 | 67 | ] |
68 | 68 | ])); |
69 | 69 | } |
@@ -14,119 +14,119 @@ |
||
14 | 14 | */ |
15 | 15 | class CwpSolr |
16 | 16 | { |
17 | - use Configurable; |
|
17 | + use Configurable; |
|
18 | 18 | |
19 | - /** |
|
20 | - * |
|
21 | - * @var array |
|
22 | - */ |
|
23 | - private static $options; |
|
19 | + /** |
|
20 | + * |
|
21 | + * @var array |
|
22 | + */ |
|
23 | + private static $options; |
|
24 | 24 | |
25 | - /** |
|
26 | - * Configure Solr. |
|
27 | - * |
|
28 | - * $options - An array consisting of: |
|
29 | - * |
|
30 | - * 'extraspath' - (String) Where to find Solr core configuartion files. |
|
31 | - * Defaults to '<BASE_PATH>/mysite/conf/extras'. |
|
32 | - * 'version' - select the Solr configuration to use when in CWP. One of: |
|
33 | - * * 'cwp-4': preferred version, uses secured 4.x service available on CWP |
|
34 | - * * 'local-4': this can be use for development using silverstripe-localsolr package, 4.x branch |
|
35 | - */ |
|
36 | - public static function configure() |
|
37 | - { |
|
38 | - if (!class_exists(Solr::class)) { |
|
39 | - return; |
|
40 | - } |
|
25 | + /** |
|
26 | + * Configure Solr. |
|
27 | + * |
|
28 | + * $options - An array consisting of: |
|
29 | + * |
|
30 | + * 'extraspath' - (String) Where to find Solr core configuartion files. |
|
31 | + * Defaults to '<BASE_PATH>/mysite/conf/extras'. |
|
32 | + * 'version' - select the Solr configuration to use when in CWP. One of: |
|
33 | + * * 'cwp-4': preferred version, uses secured 4.x service available on CWP |
|
34 | + * * 'local-4': this can be use for development using silverstripe-localsolr package, 4.x branch |
|
35 | + */ |
|
36 | + public static function configure() |
|
37 | + { |
|
38 | + if (!class_exists(Solr::class)) { |
|
39 | + return; |
|
40 | + } |
|
41 | 41 | |
42 | - // get options from configuration |
|
43 | - $options = static::config()->get('options'); |
|
42 | + // get options from configuration |
|
43 | + $options = static::config()->get('options'); |
|
44 | 44 | |
45 | - // get version specific options |
|
46 | - switch ($options['version']) { |
|
47 | - case 'cwp-4': |
|
48 | - $solrOptions = self::options_for_cwp($options); |
|
49 | - break; |
|
50 | - case 'local-4': |
|
51 | - $solrOptions = self::options_for_local($options); |
|
52 | - break; |
|
53 | - default: |
|
54 | - throw new InvalidArgumentException(sprintf( |
|
55 | - 'Solr version "%s" is not supported on CWP. Please use "local-4" on local ' . |
|
56 | - 'and "cwp-4" on production. For preferred configuration see ' . |
|
57 | - 'https://www.cwp.govt.nz/developer-docs/.', |
|
58 | - $options['version'] |
|
59 | - )); |
|
60 | - break; |
|
61 | - } |
|
45 | + // get version specific options |
|
46 | + switch ($options['version']) { |
|
47 | + case 'cwp-4': |
|
48 | + $solrOptions = self::options_for_cwp($options); |
|
49 | + break; |
|
50 | + case 'local-4': |
|
51 | + $solrOptions = self::options_for_local($options); |
|
52 | + break; |
|
53 | + default: |
|
54 | + throw new InvalidArgumentException(sprintf( |
|
55 | + 'Solr version "%s" is not supported on CWP. Please use "local-4" on local ' . |
|
56 | + 'and "cwp-4" on production. For preferred configuration see ' . |
|
57 | + 'https://www.cwp.govt.nz/developer-docs/.', |
|
58 | + $options['version'] |
|
59 | + )); |
|
60 | + break; |
|
61 | + } |
|
62 | 62 | |
63 | - // Allow users to override extras path. |
|
64 | - // CAUTION: CWP does not permit usage of customised solrconfig.xml. |
|
65 | - if (isset($options['extraspath']) && file_exists($options['extraspath'])) { |
|
66 | - $solrOptions['extraspath'] = $options['extraspath']; |
|
67 | - } elseif (file_exists(BASE_PATH . '/mysite/conf/extras')) { |
|
68 | - $solrOptions['extraspath'] = BASE_PATH . '/mysite/conf/extras'; |
|
69 | - } |
|
63 | + // Allow users to override extras path. |
|
64 | + // CAUTION: CWP does not permit usage of customised solrconfig.xml. |
|
65 | + if (isset($options['extraspath']) && file_exists($options['extraspath'])) { |
|
66 | + $solrOptions['extraspath'] = $options['extraspath']; |
|
67 | + } elseif (file_exists(BASE_PATH . '/mysite/conf/extras')) { |
|
68 | + $solrOptions['extraspath'] = BASE_PATH . '/mysite/conf/extras'; |
|
69 | + } |
|
70 | 70 | |
71 | - Solr::configure_server($solrOptions); |
|
72 | - } |
|
71 | + Solr::configure_server($solrOptions); |
|
72 | + } |
|
73 | 73 | |
74 | - /** |
|
75 | - * @throws Exception |
|
76 | - */ |
|
77 | - public static function options_from_environment() |
|
78 | - { |
|
79 | - throw new Exception( |
|
80 | - 'CwpSolr::options_from_environment has been deprecated, in favour of implicit Solr ' . |
|
81 | - 'configuration provided by the CwpSolr class in the cwp-core module. For preferred configuration see ' . |
|
82 | - 'https://www.cwp.govt.nz/developer-docs/.' |
|
83 | - ); |
|
84 | - } |
|
74 | + /** |
|
75 | + * @throws Exception |
|
76 | + */ |
|
77 | + public static function options_from_environment() |
|
78 | + { |
|
79 | + throw new Exception( |
|
80 | + 'CwpSolr::options_from_environment has been deprecated, in favour of implicit Solr ' . |
|
81 | + 'configuration provided by the CwpSolr class in the cwp-core module. For preferred configuration see ' . |
|
82 | + 'https://www.cwp.govt.nz/developer-docs/.' |
|
83 | + ); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * @param array $options |
|
88 | - * @return array |
|
89 | - */ |
|
90 | - public static function options_for_cwp($options) |
|
91 | - { |
|
92 | - $version = $options['version']; |
|
86 | + /** |
|
87 | + * @param array $options |
|
88 | + * @return array |
|
89 | + */ |
|
90 | + public static function options_for_cwp($options) |
|
91 | + { |
|
92 | + $version = $options['version']; |
|
93 | 93 | |
94 | - return [ |
|
95 | - 'host' => Environment::getEnv('SOLR_SERVER'), |
|
96 | - 'port' => Environment::getEnv('SOLR_PORT'), |
|
97 | - 'path' => '/v4/', |
|
98 | - 'version' => 4, |
|
99 | - 'indexstore' => [ |
|
100 | - 'mode' => CwpSolrConfigStore::class, |
|
101 | - 'path' => '/v4', |
|
102 | - ], |
|
103 | - ]; |
|
104 | - } |
|
94 | + return [ |
|
95 | + 'host' => Environment::getEnv('SOLR_SERVER'), |
|
96 | + 'port' => Environment::getEnv('SOLR_PORT'), |
|
97 | + 'path' => '/v4/', |
|
98 | + 'version' => 4, |
|
99 | + 'indexstore' => [ |
|
100 | + 'mode' => CwpSolrConfigStore::class, |
|
101 | + 'path' => '/v4', |
|
102 | + ], |
|
103 | + ]; |
|
104 | + } |
|
105 | 105 | |
106 | - /** |
|
107 | - * |
|
108 | - * @param array $options |
|
109 | - * @return array |
|
110 | - */ |
|
111 | - public static function options_for_local($options) |
|
112 | - { |
|
113 | - return [ |
|
114 | - 'host' => Environment::getEnv('SOLR_SERVER') ? Environment::getEnv('SOLR_SERVER') : 'localhost', |
|
115 | - 'port' => Environment::getEnv('SOLR_PORT') ? Environment::getEnv('SOLR_PORT') : 8983, |
|
116 | - 'path' => Environment::getEnv('SOLR_PATH') ? Environment::getEnv('SOLR_PATH') : '/solr/', |
|
117 | - 'version' => 4, |
|
118 | - 'indexstore' => [ |
|
119 | - 'mode' => Environment::getEnv('SOLR_MODE') ? Environment::getEnv('SOLR_MODE') : 'file', |
|
120 | - 'auth' => Environment::getEnv('SOLR_AUTH') ? Environment::getEnv('SOLR_AUTH') : null, |
|
121 | - // Allow storing the solr index and config data in an arbitrary location, |
|
122 | - // e.g. outside of the webroot |
|
123 | - 'path' => Environment::getEnv('SOLR_INDEXSTORE_PATH') |
|
124 | - ? Environment::getEnv('SOLR_INDEXSTORE_PATH') |
|
125 | - : BASE_PATH . '/.solr', |
|
126 | - 'remotepath' => Environment::getEnv('SOLR_REMOTE_PATH') |
|
127 | - ? Environment::getEnv('SOLR_REMOTE_PATH') |
|
128 | - : null |
|
129 | - ] |
|
130 | - ]; |
|
131 | - } |
|
106 | + /** |
|
107 | + * |
|
108 | + * @param array $options |
|
109 | + * @return array |
|
110 | + */ |
|
111 | + public static function options_for_local($options) |
|
112 | + { |
|
113 | + return [ |
|
114 | + 'host' => Environment::getEnv('SOLR_SERVER') ? Environment::getEnv('SOLR_SERVER') : 'localhost', |
|
115 | + 'port' => Environment::getEnv('SOLR_PORT') ? Environment::getEnv('SOLR_PORT') : 8983, |
|
116 | + 'path' => Environment::getEnv('SOLR_PATH') ? Environment::getEnv('SOLR_PATH') : '/solr/', |
|
117 | + 'version' => 4, |
|
118 | + 'indexstore' => [ |
|
119 | + 'mode' => Environment::getEnv('SOLR_MODE') ? Environment::getEnv('SOLR_MODE') : 'file', |
|
120 | + 'auth' => Environment::getEnv('SOLR_AUTH') ? Environment::getEnv('SOLR_AUTH') : null, |
|
121 | + // Allow storing the solr index and config data in an arbitrary location, |
|
122 | + // e.g. outside of the webroot |
|
123 | + 'path' => Environment::getEnv('SOLR_INDEXSTORE_PATH') |
|
124 | + ? Environment::getEnv('SOLR_INDEXSTORE_PATH') |
|
125 | + : BASE_PATH . '/.solr', |
|
126 | + 'remotepath' => Environment::getEnv('SOLR_REMOTE_PATH') |
|
127 | + ? Environment::getEnv('SOLR_REMOTE_PATH') |
|
128 | + : null |
|
129 | + ] |
|
130 | + ]; |
|
131 | + } |
|
132 | 132 | } |
@@ -20,108 +20,108 @@ |
||
20 | 20 | */ |
21 | 21 | class CwpStatsReport extends Report |
22 | 22 | { |
23 | - public function title() |
|
24 | - { |
|
25 | - return _t(__CLASS__ . '.Title', 'Summary statistics'); |
|
26 | - } |
|
27 | - |
|
28 | - public function description() |
|
29 | - { |
|
30 | - return _t( |
|
31 | - __CLASS__ . '.Description', |
|
32 | - 'This report provides various statistics for this site. The "total live page count" is the number that ' . |
|
33 | - 'can be compared against the instance size specifications.' |
|
34 | - ); |
|
35 | - } |
|
36 | - |
|
37 | - public function columns() |
|
38 | - { |
|
39 | - return [ |
|
40 | - 'Name' => _t(__CLASS__ . '.Name', 'Name'), |
|
41 | - 'Count' => _t(__CLASS__ . '.Count', 'Count'), |
|
42 | - ]; |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * Manually create source records for the report. Agreggates cannot be provided as a column of a DataQuery result. |
|
47 | - * |
|
48 | - * {@inheritDoc} |
|
49 | - */ |
|
50 | - public function sourceRecords($params = [], $sort = null, $limit = null) |
|
51 | - { |
|
52 | - $records = []; |
|
53 | - |
|
54 | - // Get the query to apply across all variants: looks at all subsites, translations, live stage only. |
|
55 | - $crossVariant = (function ($dataQuery) { |
|
56 | - $params = [ |
|
57 | - 'Subsite.filter' => false, |
|
58 | - 'Versioned.mode' => 'stage', |
|
59 | - 'Versioned.stage' => Versioned::LIVE, |
|
60 | - ]; |
|
61 | - |
|
62 | - return $dataQuery->setDataQueryParam($params); |
|
63 | - }); |
|
64 | - |
|
65 | - // Total. |
|
66 | - $records[] = [ |
|
67 | - 'Name' => _t( |
|
68 | - __CLASS__ . '.TotalPageCount', |
|
69 | - 'Total live page count, across all translations and subsites' |
|
70 | - ), |
|
71 | - 'Count' => $crossVariant(SiteTree::get())->count(), |
|
72 | - ]; |
|
73 | - |
|
74 | - if (class_exists(Subsite::class)) { |
|
75 | - // Main site. |
|
76 | - $records[] = [ |
|
77 | - 'Name' => _t(__CLASS__ . '.PagesForMainSite', '- in the main site'), |
|
78 | - 'Count' => $crossVariant(SiteTree::get()) |
|
79 | - ->filter(['SubsiteID' => 0]) |
|
80 | - ->count(), |
|
81 | - ]; |
|
82 | - |
|
83 | - // Per subsite. |
|
84 | - $subsites = Subsite::get(); |
|
85 | - foreach ($subsites as $subsite) { |
|
86 | - $records[] = [ |
|
87 | - 'Name' => _t( |
|
88 | - __CLASS__ . '.PagesForSubsite', |
|
89 | - "- in the subsite '{SubsiteTitle}'", |
|
90 | - ['SubsiteTitle' => $subsite->Title] |
|
91 | - ), |
|
92 | - 'Count' => $crossVariant(SiteTree::get()) |
|
93 | - ->filter(['SubsiteID' => $subsite->ID]) |
|
94 | - ->count(), |
|
95 | - ]; |
|
96 | - } |
|
97 | - } |
|
98 | - |
|
99 | - // Files. |
|
100 | - $records[] = [ |
|
101 | - 'Name' => _t('CwpStatsReport.FileCount', 'File count'), |
|
102 | - 'Count' => File::get() |
|
103 | - ->setDataQueryParam('Subsite.filter', false) |
|
104 | - ->filter(['ClassName:not' => Folder::class]) |
|
105 | - ->count(), |
|
106 | - ]; |
|
107 | - |
|
108 | - return ArrayList::create($records); |
|
109 | - } |
|
110 | - |
|
111 | - /** |
|
112 | - * @return GridField |
|
113 | - */ |
|
114 | - public function getReportField() |
|
115 | - { |
|
116 | - /** @var GridField $gridField */ |
|
117 | - $gridField = parent::getReportField(); |
|
118 | - |
|
119 | - /** @var GridFieldConfig $gridConfig */ |
|
120 | - $gridConfig = $gridField->getConfig(); |
|
121 | - $gridConfig->removeComponentsByType(GridFieldPrintButton::class); |
|
122 | - $gridConfig->removeComponentsByType(GridFieldExportButton::class); |
|
123 | - $gridConfig->removeComponentsByType(GridFieldSortableHeader::class); |
|
124 | - |
|
125 | - return $gridField; |
|
126 | - } |
|
23 | + public function title() |
|
24 | + { |
|
25 | + return _t(__CLASS__ . '.Title', 'Summary statistics'); |
|
26 | + } |
|
27 | + |
|
28 | + public function description() |
|
29 | + { |
|
30 | + return _t( |
|
31 | + __CLASS__ . '.Description', |
|
32 | + 'This report provides various statistics for this site. The "total live page count" is the number that ' . |
|
33 | + 'can be compared against the instance size specifications.' |
|
34 | + ); |
|
35 | + } |
|
36 | + |
|
37 | + public function columns() |
|
38 | + { |
|
39 | + return [ |
|
40 | + 'Name' => _t(__CLASS__ . '.Name', 'Name'), |
|
41 | + 'Count' => _t(__CLASS__ . '.Count', 'Count'), |
|
42 | + ]; |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * Manually create source records for the report. Agreggates cannot be provided as a column of a DataQuery result. |
|
47 | + * |
|
48 | + * {@inheritDoc} |
|
49 | + */ |
|
50 | + public function sourceRecords($params = [], $sort = null, $limit = null) |
|
51 | + { |
|
52 | + $records = []; |
|
53 | + |
|
54 | + // Get the query to apply across all variants: looks at all subsites, translations, live stage only. |
|
55 | + $crossVariant = (function ($dataQuery) { |
|
56 | + $params = [ |
|
57 | + 'Subsite.filter' => false, |
|
58 | + 'Versioned.mode' => 'stage', |
|
59 | + 'Versioned.stage' => Versioned::LIVE, |
|
60 | + ]; |
|
61 | + |
|
62 | + return $dataQuery->setDataQueryParam($params); |
|
63 | + }); |
|
64 | + |
|
65 | + // Total. |
|
66 | + $records[] = [ |
|
67 | + 'Name' => _t( |
|
68 | + __CLASS__ . '.TotalPageCount', |
|
69 | + 'Total live page count, across all translations and subsites' |
|
70 | + ), |
|
71 | + 'Count' => $crossVariant(SiteTree::get())->count(), |
|
72 | + ]; |
|
73 | + |
|
74 | + if (class_exists(Subsite::class)) { |
|
75 | + // Main site. |
|
76 | + $records[] = [ |
|
77 | + 'Name' => _t(__CLASS__ . '.PagesForMainSite', '- in the main site'), |
|
78 | + 'Count' => $crossVariant(SiteTree::get()) |
|
79 | + ->filter(['SubsiteID' => 0]) |
|
80 | + ->count(), |
|
81 | + ]; |
|
82 | + |
|
83 | + // Per subsite. |
|
84 | + $subsites = Subsite::get(); |
|
85 | + foreach ($subsites as $subsite) { |
|
86 | + $records[] = [ |
|
87 | + 'Name' => _t( |
|
88 | + __CLASS__ . '.PagesForSubsite', |
|
89 | + "- in the subsite '{SubsiteTitle}'", |
|
90 | + ['SubsiteTitle' => $subsite->Title] |
|
91 | + ), |
|
92 | + 'Count' => $crossVariant(SiteTree::get()) |
|
93 | + ->filter(['SubsiteID' => $subsite->ID]) |
|
94 | + ->count(), |
|
95 | + ]; |
|
96 | + } |
|
97 | + } |
|
98 | + |
|
99 | + // Files. |
|
100 | + $records[] = [ |
|
101 | + 'Name' => _t('CwpStatsReport.FileCount', 'File count'), |
|
102 | + 'Count' => File::get() |
|
103 | + ->setDataQueryParam('Subsite.filter', false) |
|
104 | + ->filter(['ClassName:not' => Folder::class]) |
|
105 | + ->count(), |
|
106 | + ]; |
|
107 | + |
|
108 | + return ArrayList::create($records); |
|
109 | + } |
|
110 | + |
|
111 | + /** |
|
112 | + * @return GridField |
|
113 | + */ |
|
114 | + public function getReportField() |
|
115 | + { |
|
116 | + /** @var GridField $gridField */ |
|
117 | + $gridField = parent::getReportField(); |
|
118 | + |
|
119 | + /** @var GridFieldConfig $gridConfig */ |
|
120 | + $gridConfig = $gridField->getConfig(); |
|
121 | + $gridConfig->removeComponentsByType(GridFieldPrintButton::class); |
|
122 | + $gridConfig->removeComponentsByType(GridFieldExportButton::class); |
|
123 | + $gridConfig->removeComponentsByType(GridFieldSortableHeader::class); |
|
124 | + |
|
125 | + return $gridField; |
|
126 | + } |
|
127 | 127 | } |
@@ -52,7 +52,7 @@ |
||
52 | 52 | $records = []; |
53 | 53 | |
54 | 54 | // Get the query to apply across all variants: looks at all subsites, translations, live stage only. |
55 | - $crossVariant = (function ($dataQuery) { |
|
55 | + $crossVariant = (function($dataQuery) { |
|
56 | 56 | $params = [ |
57 | 57 | 'Subsite.filter' => false, |
58 | 58 | 'Versioned.mode' => 'stage', |
@@ -14,71 +14,71 @@ |
||
14 | 14 | class CwpInitialisationFilter implements RequestFilter |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @var boolean |
|
19 | - * |
|
20 | - * Enable egress proxy. This works on the principle of setting http(s)_proxy environment variables, |
|
21 | - * which will be automatically picked up by curl. This means RestfulService and raw curl |
|
22 | - * requests should work out of the box. Stream-based requests need extra manual configuration. |
|
23 | - * Refer to https://www.cwp.govt.nz/guides/core-technical-documentation/common-web-platform-core/en/how-tos/external_http_requests_with_proxy |
|
24 | - * |
|
25 | - * @config |
|
26 | - * @var bool |
|
27 | - */ |
|
28 | - private static $egress_proxy_default_enabled = true; |
|
17 | + /** |
|
18 | + * @var boolean |
|
19 | + * |
|
20 | + * Enable egress proxy. This works on the principle of setting http(s)_proxy environment variables, |
|
21 | + * which will be automatically picked up by curl. This means RestfulService and raw curl |
|
22 | + * requests should work out of the box. Stream-based requests need extra manual configuration. |
|
23 | + * Refer to https://www.cwp.govt.nz/guides/core-technical-documentation/common-web-platform-core/en/how-tos/external_http_requests_with_proxy |
|
24 | + * |
|
25 | + * @config |
|
26 | + * @var bool |
|
27 | + */ |
|
28 | + private static $egress_proxy_default_enabled = true; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var array |
|
32 | - * |
|
33 | - * Configure the list of domains to bypass proxy by setting the NO_PROXY environment variable. |
|
34 | - * 'services.cwp.govt.nz' needs to be present for Solr and Docvert internal CWP integration. |
|
35 | - * 'localhost' is necessary for accessing services on the same instance such as tika-server for text extraction. |
|
36 | - * |
|
37 | - * @config |
|
38 | - * @var string[] |
|
39 | - */ |
|
40 | - private static $egress_proxy_exclude_domains = [ |
|
41 | - 'services.cwp.govt.nz', |
|
42 | - 'localhost', |
|
43 | - ]; |
|
30 | + /** |
|
31 | + * @var array |
|
32 | + * |
|
33 | + * Configure the list of domains to bypass proxy by setting the NO_PROXY environment variable. |
|
34 | + * 'services.cwp.govt.nz' needs to be present for Solr and Docvert internal CWP integration. |
|
35 | + * 'localhost' is necessary for accessing services on the same instance such as tika-server for text extraction. |
|
36 | + * |
|
37 | + * @config |
|
38 | + * @var string[] |
|
39 | + */ |
|
40 | + private static $egress_proxy_exclude_domains = [ |
|
41 | + 'services.cwp.govt.nz', |
|
42 | + 'localhost', |
|
43 | + ]; |
|
44 | 44 | |
45 | - /** |
|
46 | - * |
|
47 | - * @param HTTPRequest $request |
|
48 | - * @return boolean |
|
49 | - */ |
|
50 | - public function preRequest(HTTPRequest $request) |
|
51 | - { |
|
52 | - if (Config::inst()->get(__CLASS__, 'egress_proxy_default_enabled')) { |
|
53 | - if (Environment::getEnv('SS_OUTBOUND_PROXY') && Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) { |
|
54 | - $proxy = Environment::getEnv('SS_OUTBOUND_PROXY'); |
|
55 | - $proxyPort = Environment::getEnv('SS_OUTBOUND_PROXY_PORT'); |
|
45 | + /** |
|
46 | + * |
|
47 | + * @param HTTPRequest $request |
|
48 | + * @return boolean |
|
49 | + */ |
|
50 | + public function preRequest(HTTPRequest $request) |
|
51 | + { |
|
52 | + if (Config::inst()->get(__CLASS__, 'egress_proxy_default_enabled')) { |
|
53 | + if (Environment::getEnv('SS_OUTBOUND_PROXY') && Environment::getEnv('SS_OUTBOUND_PROXY_PORT')) { |
|
54 | + $proxy = Environment::getEnv('SS_OUTBOUND_PROXY'); |
|
55 | + $proxyPort = Environment::getEnv('SS_OUTBOUND_PROXY_PORT'); |
|
56 | 56 | |
57 | - Environment::setEnv('http_proxy', $proxy . ':' . $proxyPort); |
|
58 | - Environment::setEnv('https_proxy', $proxy. ':' . $proxyPort); |
|
59 | - } |
|
60 | - } |
|
57 | + Environment::setEnv('http_proxy', $proxy . ':' . $proxyPort); |
|
58 | + Environment::setEnv('https_proxy', $proxy. ':' . $proxyPort); |
|
59 | + } |
|
60 | + } |
|
61 | 61 | |
62 | - $noProxy = Config::inst()->get(__CLASS__, 'egress_proxy_exclude_domains'); |
|
62 | + $noProxy = Config::inst()->get(__CLASS__, 'egress_proxy_exclude_domains'); |
|
63 | 63 | |
64 | - if (!empty($noProxy)) { |
|
65 | - if (!is_array($noProxy)) { |
|
66 | - $noProxy = [$noProxy]; |
|
67 | - } |
|
64 | + if (!empty($noProxy)) { |
|
65 | + if (!is_array($noProxy)) { |
|
66 | + $noProxy = [$noProxy]; |
|
67 | + } |
|
68 | 68 | |
69 | - // Merge with exsiting if needed. |
|
70 | - if (Environment::getEnv('NO_PROXY')) { |
|
71 | - $noProxy = array_merge(explode(',', Environment::getEnv('NO_PROXY')), $noProxy); |
|
72 | - } |
|
69 | + // Merge with exsiting if needed. |
|
70 | + if (Environment::getEnv('NO_PROXY')) { |
|
71 | + $noProxy = array_merge(explode(',', Environment::getEnv('NO_PROXY')), $noProxy); |
|
72 | + } |
|
73 | 73 | |
74 | - Environment::setEnv('NO_PROXY', implode(',', array_unique($noProxy))); |
|
75 | - } |
|
74 | + Environment::setEnv('NO_PROXY', implode(',', array_unique($noProxy))); |
|
75 | + } |
|
76 | 76 | |
77 | - return true; |
|
78 | - } |
|
77 | + return true; |
|
78 | + } |
|
79 | 79 | |
80 | - public function postRequest(HTTPRequest $request, HTTPResponse $response) |
|
81 | - { |
|
82 | - return true; |
|
83 | - } |
|
80 | + public function postRequest(HTTPRequest $request, HTTPResponse $response) |
|
81 | + { |
|
82 | + return true; |
|
83 | + } |
|
84 | 84 | } |
@@ -55,7 +55,7 @@ |
||
55 | 55 | $proxyPort = Environment::getEnv('SS_OUTBOUND_PROXY_PORT'); |
56 | 56 | |
57 | 57 | Environment::setEnv('http_proxy', $proxy . ':' . $proxyPort); |
58 | - Environment::setEnv('https_proxy', $proxy. ':' . $proxyPort); |
|
58 | + Environment::setEnv('https_proxy', $proxy . ':' . $proxyPort); |
|
59 | 59 | } |
60 | 60 | } |
61 | 61 |