@@ -1,6 +1,6 @@ |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | // default to the binary being in the usual path on Linux |
4 | -if(!defined('WKHTMLTOPDF_BINARY')) { |
|
4 | +if (!defined('WKHTMLTOPDF_BINARY')) { |
|
5 | 5 | define('WKHTMLTOPDF_BINARY', '/usr/local/bin/wkhtmltopdf_12'); |
6 | 6 | } |
@@ -8,12 +8,12 @@ |
||
8 | 8 | |
9 | 9 | public function run($request) { |
10 | 10 | $path = sprintf('%s/%s', BASE_PATH, BasePage::config()->generated_pdf_path); |
11 | - if(!file_exists($path)) return false; |
|
11 | + if (!file_exists($path)) return false; |
|
12 | 12 | |
13 | 13 | exec(sprintf('if [ "$(ls -A %s 2> /dev/null)" != "" ]; then rm %s/*; fi', $path, $path), $output, $return_val); |
14 | 14 | |
15 | 15 | // output any errors |
16 | - if($return_val != 0) { |
|
16 | + if ($return_val != 0) { |
|
17 | 17 | user_error(sprintf('%s failed: ', get_class($this)) . implode("\n", $output), E_USER_ERROR); |
18 | 18 | } |
19 | 19 | } |
@@ -8,7 +8,9 @@ |
||
8 | 8 | |
9 | 9 | public function run($request) { |
10 | 10 | $path = sprintf('%s/%s', BASE_PATH, BasePage::config()->generated_pdf_path); |
11 | - if(!file_exists($path)) return false; |
|
11 | + if(!file_exists($path)) { |
|
12 | + return false; |
|
13 | + } |
|
12 | 14 | |
13 | 15 | exec(sprintf('if [ "$(ls -A %s 2> /dev/null)" != "" ]; then rm %s/*; fi', $path, $path), $output, $return_val); |
14 | 16 |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | $url = parse_url($this->ExternalLink); |
35 | 35 | |
36 | 36 | // if no scheme set in the link, default to http |
37 | - if(!isset($url['scheme'])) { |
|
37 | + if (!isset($url['scheme'])) { |
|
38 | 38 | return 'http://' . $this->ExternalLink; |
39 | 39 | } |
40 | 40 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | $fields->removeByName('SortOrder'); |
73 | 73 | $externalLinkField->addExtraClass('noBorder'); |
74 | 74 | |
75 | - $fields->addFieldToTab('Root.Main',CompositeField::create( |
|
75 | + $fields->addFieldToTab('Root.Main', CompositeField::create( |
|
76 | 76 | array( |
77 | 77 | TreeDropdownField::create( |
78 | 78 | 'InternalLinkID', |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | $wrap = CompositeField::create( |
84 | 84 | $extraLabel = LiteralField::create( |
85 | 85 | 'NoteOverride', |
86 | - _t('Quicklink.Note','<div class="message good notice">Note: If you specify an External Link, the Internal Link will be ignored.</div>') |
|
86 | + _t('Quicklink.Note', '<div class="message good notice">Note: If you specify an External Link, the Internal Link will be ignored.</div>') |
|
87 | 87 | ) |
88 | 88 | ) |
89 | 89 | ) |
@@ -19,7 +19,7 @@ discard block |
||
19 | 19 | ); |
20 | 20 | |
21 | 21 | public function Page($link) { |
22 | - if($link instanceof SS_HTTPRequest) { |
|
22 | + if ($link instanceof SS_HTTPRequest) { |
|
23 | 23 | Deprecation::notice('2.0', 'Using page() as a url handler is deprecated. Use showpage() action instead'); |
24 | 24 | return $this->showpage($link); |
25 | 25 | } |
@@ -28,18 +28,18 @@ discard block |
||
28 | 28 | |
29 | 29 | public function showpage($request) { |
30 | 30 | $id = (int) $request->param('ID'); |
31 | - if(!$id) { |
|
31 | + if (!$id) { |
|
32 | 32 | return false; |
33 | 33 | } |
34 | 34 | $page = SiteTree::get()->byId($id); |
35 | 35 | |
36 | 36 | // does the page exist? |
37 | - if(!($page && $page->exists())) { |
|
37 | + if (!($page && $page->exists())) { |
|
38 | 38 | return $this->httpError(404); |
39 | 39 | } |
40 | 40 | |
41 | 41 | // can the page be viewed? |
42 | - if(!$page->canView()) { |
|
42 | + if (!$page->canView()) { |
|
43 | 43 | return $this->httpError(403); |
44 | 44 | } |
45 | 45 | |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | 'Children' => $page->Children() |
50 | 50 | )); |
51 | 51 | |
52 | - if($request->isAjax()) { |
|
52 | + if ($request->isAjax()) { |
|
53 | 53 | return $viewer->renderWith('SitemapNodeChildren'); |
54 | 54 | } else { |
55 | 55 | return $viewer; |
@@ -14,7 +14,7 @@ discard block |
||
14 | 14 | |
15 | 15 | private static $icon = 'cwp/images/icons/sitetree_images/event_holder.png'; |
16 | 16 | |
17 | - public $pageIcon = 'images/icons/sitetree_images/event_holder.png'; |
|
17 | + public $pageIcon = 'images/icons/sitetree_images/event_holder.png'; |
|
18 | 18 | |
19 | 19 | private static $singular_name = 'Event Holder'; |
20 | 20 | |
@@ -58,7 +58,7 @@ discard block |
||
58 | 58 | public function getUpdateName() { |
59 | 59 | $params = $this->parseParams(); |
60 | 60 | if ($params['upcomingOnly']) { |
61 | - return _t('EventHolder.Upcoming','Upcoming events'); |
|
61 | + return _t('EventHolder.Upcoming', 'Upcoming events'); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | return 'Events'; |
@@ -14,7 +14,7 @@ |
||
14 | 14 | |
15 | 15 | private static $icon = 'cwp/images/icons/sitetree_images/news_listing.png'; |
16 | 16 | |
17 | - public $pageIcon = 'images/icons/sitetree_images/news_listing.png'; |
|
17 | + public $pageIcon = 'images/icons/sitetree_images/news_listing.png'; |
|
18 | 18 | |
19 | 19 | private static $singular_name = 'News Holder'; |
20 | 20 |
@@ -313,13 +313,25 @@ discard block |
||
313 | 313 | $year = $this->request->getVar('year'); |
314 | 314 | $month = $this->request->getVar('month'); |
315 | 315 | |
316 | - if ($tag=='') $tag = null; |
|
317 | - if ($from=='') $from = null; |
|
318 | - if ($to=='') $to = null; |
|
319 | - if ($year=='') $year = null; |
|
320 | - if ($month=='') $month = null; |
|
316 | + if ($tag=='') { |
|
317 | + $tag = null; |
|
318 | + } |
|
319 | + if ($from=='') { |
|
320 | + $from = null; |
|
321 | + } |
|
322 | + if ($to=='') { |
|
323 | + $to = null; |
|
324 | + } |
|
325 | + if ($year=='') { |
|
326 | + $year = null; |
|
327 | + } |
|
328 | + if ($month=='') { |
|
329 | + $month = null; |
|
330 | + } |
|
321 | 331 | |
322 | - if (isset($tag)) $tag = (int)$tag; |
|
332 | + if (isset($tag)) { |
|
333 | + $tag = (int)$tag; |
|
334 | + } |
|
323 | 335 | if (isset($from)) { |
324 | 336 | $from = urldecode($from); |
325 | 337 | $parser = new SS_Datetime; |
@@ -332,8 +344,12 @@ discard block |
||
332 | 344 | $parser->setValue($to); |
333 | 345 | $to = $parser->Format('Y-m-d'); |
334 | 346 | } |
335 | - if (isset($year)) $year = (int)$year; |
|
336 | - if (isset($month)) $month = (int)$month; |
|
347 | + if (isset($year)) { |
|
348 | + $year = (int)$year; |
|
349 | + } |
|
350 | + if (isset($month)) { |
|
351 | + $month = (int)$month; |
|
352 | + } |
|
337 | 353 | |
338 | 354 | // If only "To" has been provided filter by single date. Normalise by swapping with "From". |
339 | 355 | if (isset($to) && !isset($from)) { |
@@ -499,7 +515,9 @@ discard block |
||
499 | 515 | // Build the link - keep the tag, but reset month, year and pagination. |
500 | 516 | $link = HTTP::setGetVar('from', $params['from'], $this->AbsoluteLink(), '&'); |
501 | 517 | $link = HTTP::setGetVar('to', $params['to'], $link, '&'); |
502 | - if (isset($params['tag'])) $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
518 | + if (isset($params['tag'])) { |
|
519 | + $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
520 | + } |
|
503 | 521 | |
504 | 522 | $this->redirect($link); |
505 | 523 | } |
@@ -509,7 +527,9 @@ discard block |
||
509 | 527 | |
510 | 528 | // Reset the link - only include the tag. |
511 | 529 | $link = $this->AbsoluteLink(); |
512 | - if (isset($params['tag'])) $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
530 | + if (isset($params['tag'])) { |
|
531 | + $link = HTTP::setGetVar('tag', $params['tag'], $link, '&'); |
|
532 | + } |
|
513 | 533 | |
514 | 534 | $this->redirect($link); |
515 | 535 | } |
@@ -86,8 +86,8 @@ discard block |
||
86 | 86 | |
87 | 87 | // Filter down to single month. |
88 | 88 | if (isset($year) && isset($monthNumber)) { |
89 | - $year = (int)$year; |
|
90 | - $monthNumber = (int)$monthNumber; |
|
89 | + $year = (int) $year; |
|
90 | + $monthNumber = (int) $monthNumber; |
|
91 | 91 | |
92 | 92 | $beginDate = sprintf("%d-%d-01 00:00:00", $year, $monthNumber); |
93 | 93 | $endDate = date('Y-m-d H:i:s', strtotime("{$beginDate} +1 month")); |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | // Check if the currently processed month is the one that is selected via GET params. |
160 | 160 | $active = false; |
161 | 161 | if (isset($year) && isset($monthNumber)) { |
162 | - $active = (((int)$currentYear)==$year && ((int)$currentMonthNumber)==$monthNumber); |
|
162 | + $active = (((int) $currentYear) == $year && ((int) $currentMonthNumber) == $monthNumber); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | // Build the link - keep the tag and date filter, but reset the pagination. |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | public function getMetaTitle() { |
239 | 239 | $title = $this->data()->getTitle(); |
240 | 240 | $filter = $this->FilterDescription(); |
241 | - if($filter) { |
|
241 | + if ($filter) { |
|
242 | 242 | $title = "{$title} - {$filter}"; |
243 | 243 | } |
244 | 244 | |
@@ -309,13 +309,13 @@ discard block |
||
309 | 309 | $year = $this->request->getVar('year'); |
310 | 310 | $month = $this->request->getVar('month'); |
311 | 311 | |
312 | - if ($tag=='') $tag = null; |
|
313 | - if ($from=='') $from = null; |
|
314 | - if ($to=='') $to = null; |
|
315 | - if ($year=='') $year = null; |
|
316 | - if ($month=='') $month = null; |
|
312 | + if ($tag == '') $tag = null; |
|
313 | + if ($from == '') $from = null; |
|
314 | + if ($to == '') $to = null; |
|
315 | + if ($year == '') $year = null; |
|
316 | + if ($month == '') $month = null; |
|
317 | 317 | |
318 | - if (isset($tag)) $tag = (int)$tag; |
|
318 | + if (isset($tag)) $tag = (int) $tag; |
|
319 | 319 | if (isset($from)) { |
320 | 320 | $from = urldecode($from); |
321 | 321 | $parser = new SS_Datetime; |
@@ -328,8 +328,8 @@ discard block |
||
328 | 328 | $parser->setValue($to); |
329 | 329 | $to = $parser->Format('Y-m-d'); |
330 | 330 | } |
331 | - if (isset($year)) $year = (int)$year; |
|
332 | - if (isset($month)) $month = (int)$month; |
|
331 | + if (isset($year)) $year = (int) $year; |
|
332 | + if (isset($month)) $month = (int) $month; |
|
333 | 333 | |
334 | 334 | // If only "To" has been provided filter by single date. Normalise by swapping with "From". |
335 | 335 | if (isset($to) && !isset($from)) { |
@@ -337,13 +337,13 @@ discard block |
||
337 | 337 | } |
338 | 338 | |
339 | 339 | // Flip the dates if the order is wrong. |
340 | - if (isset($to) && isset($from) && strtotime($from)>strtotime($to)) { |
|
340 | + if (isset($to) && isset($from) && strtotime($from) > strtotime($to)) { |
|
341 | 341 | list($to, $from) = array($from, $to); |
342 | 342 | |
343 | 343 | if ($produceErrorMessages) { |
344 | 344 | Session::setFormMessage( |
345 | 345 | 'Form_DateRangeForm', |
346 | - _t('DateUpdateHolder.FilterAppliedMessage','Filter has been applied with the dates reversed.'), |
|
346 | + _t('DateUpdateHolder.FilterAppliedMessage', 'Filter has been applied with the dates reversed.'), |
|
347 | 347 | 'warning' |
348 | 348 | ); |
349 | 349 | } |
@@ -354,7 +354,7 @@ discard block |
||
354 | 354 | if ($produceErrorMessages) { |
355 | 355 | Session::setFormMessage( |
356 | 356 | 'Form_DateRangeForm', |
357 | - _t('DateUpdateHolder.DateRangeFilterMessage','Filtered by a single date.'), |
|
357 | + _t('DateUpdateHolder.DateRangeFilterMessage', 'Filtered by a single date.'), |
|
358 | 358 | 'warning' |
359 | 359 | ); |
360 | 360 | } |
@@ -410,7 +410,7 @@ discard block |
||
410 | 410 | $tagID = $this->request->getVar('tag'); |
411 | 411 | |
412 | 412 | if (isset($tagID)) { |
413 | - return TaxonomyTerm::get_by_id('TaxonomyTerm', (int)$tagID); |
|
413 | + return TaxonomyTerm::get_by_id('TaxonomyTerm', (int) $tagID); |
|
414 | 414 | } |
415 | 415 | } |
416 | 416 |
@@ -14,10 +14,10 @@ |
||
14 | 14 | private static $create_default_workflow = true; |
15 | 15 | |
16 | 16 | public function requireDefaultRecords() { |
17 | - if(Config::inst()->get('CwpWorkflowDefinitionExtension', 'create_default_workflow')) { |
|
17 | + if (Config::inst()->get('CwpWorkflowDefinitionExtension', 'create_default_workflow')) { |
|
18 | 18 | // Only proceed if a definition using this template has not been created yet |
19 | 19 | $definition = WorkflowDefinition::get()->filter("Template", "Review and Approve")->First(); |
20 | - if($definition && $definition->exists()) return; |
|
20 | + if ($definition && $definition->exists()) return; |
|
21 | 21 | |
22 | 22 | //generate from the template, which happens after we write the definition |
23 | 23 | $definition = WorkflowDefinition::create(); |
@@ -17,7 +17,9 @@ |
||
17 | 17 | if(Config::inst()->get('CwpWorkflowDefinitionExtension', 'create_default_workflow')) { |
18 | 18 | // Only proceed if a definition using this template has not been created yet |
19 | 19 | $definition = WorkflowDefinition::get()->filter("Template", "Review and Approve")->First(); |
20 | - if($definition && $definition->exists()) return; |
|
20 | + if($definition && $definition->exists()) { |
|
21 | + return; |
|
22 | + } |
|
21 | 23 | |
22 | 24 | //generate from the template, which happens after we write the definition |
23 | 25 | $definition = WorkflowDefinition::create(); |
@@ -25,8 +25,8 @@ discard block |
||
25 | 25 | * @return mixed |
26 | 26 | */ |
27 | 27 | public function php($data) { |
28 | - foreach($this->fieldNames as $fieldName) { |
|
29 | - if(empty($data[$fieldName])) { |
|
28 | + foreach ($this->fieldNames as $fieldName) { |
|
29 | + if (empty($data[$fieldName])) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | * @param mixed $value |
42 | 42 | */ |
43 | 43 | protected function validateField($fieldName, $value) { |
44 | - if(!$this->validateValue($value)) { |
|
44 | + if (!$this->validateValue($value)) { |
|
45 | 45 | $this->validationError( |
46 | 46 | $fieldName, |
47 | 47 | _t( |
@@ -66,15 +66,15 @@ discard block |
||
66 | 66 | ); |
67 | 67 | |
68 | 68 | // strip comments (lines beginning with "#") |
69 | - $lines = array_filter($lines, function ($line) { |
|
69 | + $lines = array_filter($lines, function($line) { |
|
70 | 70 | $line = trim($line); |
71 | 71 | |
72 | 72 | return !empty($line) && $line[0] !== '#'; |
73 | 73 | }); |
74 | 74 | |
75 | 75 | // validate each line |
76 | - foreach($lines as $line) { |
|
77 | - if(!$this->validateLine($line)) { |
|
76 | + foreach ($lines as $line) { |
|
77 | + if (!$this->validateLine($line)) { |
|
78 | 78 | return false; |
79 | 79 | } |
80 | 80 | } |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | $parts = explode(',', $line); |
96 | 96 | $parts = array_filter($parts); |
97 | 97 | |
98 | - foreach($parts as $part) { |
|
99 | - if(!$this->validatePart($part)) { |
|
98 | + foreach ($parts as $part) { |
|
99 | + if (!$this->validatePart($part)) { |
|
100 | 100 | return false; |
101 | 101 | } |
102 | 102 | } |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | * @return bool |
113 | 113 | */ |
114 | 114 | protected function validatePart($part) { |
115 | - if(strpos($part, '=>') !== false) { |
|
115 | + if (strpos($part, '=>') !== false) { |
|
116 | 116 | $subs = explode('=>', $part); |
117 | 117 | $subs = array_filter($subs); |
118 | 118 | |
119 | - foreach($subs as $sub) { |
|
119 | + foreach ($subs as $sub) { |
|
120 | 120 | if (!$this->validateNoSpaces($sub)) { |
121 | 121 | return false; |
122 | 122 | } |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | $value = trim($value); |
139 | 139 | |
140 | 140 | // does the value contain 1 or more whitespace characters? |
141 | - if(preg_match('/\s+/', $value)) { |
|
141 | + if (preg_match('/\s+/', $value)) { |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 |