@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | $baseName = sprintf('%s-%s', $this->URLSegment, $this->ID); |
67 | 67 | |
68 | 68 | $folderPath = Config::inst()->get('BasePage', 'generated_pdf_path'); |
69 | - if($folderPath[0] != '/') $folderPath = BASE_PATH . '/' . $folderPath; |
|
69 | + if ($folderPath[0] != '/') $folderPath = BASE_PATH . '/' . $folderPath; |
|
70 | 70 | |
71 | 71 | return sprintf('%s/%s.pdf', $folderPath, $baseName); |
72 | 72 | } |
@@ -75,11 +75,11 @@ discard block |
||
75 | 75 | * Build pdf link for template. |
76 | 76 | */ |
77 | 77 | public function PdfLink() { |
78 | - if(!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
78 | + if (!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
79 | 79 | |
80 | 80 | $path = $this->getPdfFilename(); |
81 | 81 | |
82 | - if((Versioned::current_stage() == 'Live') && file_exists($path)) { |
|
82 | + if ((Versioned::current_stage() == 'Live') && file_exists($path)) { |
|
83 | 83 | return Director::baseURL() . preg_replace('#^/#', '', Director::makeRelative($path)); |
84 | 84 | } else { |
85 | 85 | return $this->Link('downloadpdf'); |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | */ |
101 | 101 | public function onAfterPublish(&$original) { |
102 | 102 | $filepath = $this->getPdfFilename(); |
103 | - if(file_exists($filepath)) { |
|
103 | + if (file_exists($filepath)) { |
|
104 | 104 | unlink($filepath); |
105 | 105 | } |
106 | 106 | } |
@@ -112,10 +112,10 @@ discard block |
||
112 | 112 | * @return boolean |
113 | 113 | */ |
114 | 114 | public function doUnpublish() { |
115 | - if(!parent::doUnpublish()) return false; |
|
115 | + if (!parent::doUnpublish()) return false; |
|
116 | 116 | |
117 | 117 | $filepath = $this->getPdfFilename(); |
118 | - if(file_exists($filepath)) { |
|
118 | + if (file_exists($filepath)) { |
|
119 | 119 | unlink($filepath); |
120 | 120 | } |
121 | 121 | |
@@ -152,20 +152,20 @@ discard block |
||
152 | 152 | |
153 | 153 | $fields->findOrMakeTab( |
154 | 154 | 'Root.RelatedPages', |
155 | - _t('BasePage.RelatedPages','Related pages') |
|
155 | + _t('BasePage.RelatedPages', 'Related pages') |
|
156 | 156 | ); |
157 | 157 | $fields->addFieldToTab( |
158 | 158 | 'Root.RelatedPages', |
159 | 159 | GridField::create( |
160 | 160 | 'RelatedPages', |
161 | - _t('BasePage.RelatedPages','Related pages'), |
|
161 | + _t('BasePage.RelatedPages', 'Related pages'), |
|
162 | 162 | $this->RelatedPages(), |
163 | 163 | $components |
164 | 164 | ) |
165 | 165 | ); |
166 | 166 | |
167 | 167 | // Taxonomies - Unless they have their own 'Tags' field (such as in Blog, etc) |
168 | - if(!$this->has_many('Tags') && !$this->many_many('Tags')) { |
|
168 | + if (!$this->has_many('Tags') && !$this->many_many('Tags')) { |
|
169 | 169 | $components = GridFieldConfig_RelationEditor::create(); |
170 | 170 | $components->removeComponentsByType('GridFieldAddNewButton'); |
171 | 171 | $components->removeComponentsByType('GridFieldEditButton'); |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | |
176 | 176 | $dataColumns = $components->getComponentByType('GridFieldDataColumns'); |
177 | 177 | $dataColumns->setDisplayFields(array( |
178 | - 'Name' => _t('BasePage.Term','Term'), |
|
179 | - 'TaxonomyName' => _t('BasePage.Taxonomy','Taxonomy') |
|
178 | + 'Name' => _t('BasePage.Term', 'Term'), |
|
179 | + 'TaxonomyName' => _t('BasePage.Taxonomy', 'Taxonomy') |
|
180 | 180 | )); |
181 | 181 | |
182 | 182 | $fields->findOrMakeTab('Root.Tags', _t('BasePage.TagsTabTitle', 'Tags')); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | 'Root.Tags', |
185 | 185 | TreeMultiselectField::create( |
186 | 186 | 'Terms', |
187 | - _t('BasePage.Terms','Terms'), |
|
187 | + _t('BasePage.Terms', 'Terms'), |
|
188 | 188 | 'TaxonomyTerm' |
189 | 189 | )->setDescription(_t('BasePage.TermsDescription', 'Click to search for additional terms')) |
190 | 190 | ); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | */ |
202 | 202 | function getAvailableTranslations() { |
203 | 203 | |
204 | - if(!class_exists('Translatable')){ |
|
204 | + if (!class_exists('Translatable')) { |
|
205 | 205 | return false; |
206 | 206 | } |
207 | 207 | |
@@ -241,11 +241,11 @@ discard block |
||
241 | 241 | $translations->push(new ArrayData(array( |
242 | 242 | 'LangName' => $nativeLangName, |
243 | 243 | 'Link' => $link, |
244 | - 'Current' => (Translatable::get_current_locale()==$loc) |
|
244 | + 'Current' => (Translatable::get_current_locale() == $loc) |
|
245 | 245 | ))); |
246 | 246 | } |
247 | 247 | |
248 | - if ($translations->count()>1) return $translations; |
|
248 | + if ($translations->count() > 1) return $translations; |
|
249 | 249 | else return null; |
250 | 250 | } |
251 | 251 | |
@@ -291,13 +291,13 @@ discard block |
||
291 | 291 | * Serve the page rendered as PDF. |
292 | 292 | */ |
293 | 293 | public function downloadpdf() { |
294 | - if(!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
294 | + if (!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
295 | 295 | |
296 | 296 | // We only allow producing live pdf. There is no way to secure the draft files. |
297 | 297 | Versioned::reading_stage('Live'); |
298 | 298 | |
299 | 299 | $path = $this->dataRecord->getPdfFilename(); |
300 | - if(!file_exists($path)) { |
|
300 | + if (!file_exists($path)) { |
|
301 | 301 | $this->generatePDF(); |
302 | 302 | } |
303 | 303 | |
@@ -310,11 +310,11 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function getPDFBaseURL() { |
312 | 312 | //if base url YML is defined in YML, use that |
313 | - if(Config::inst()->get('BasePage', 'pdf_base_url')){ |
|
314 | - $pdf_base_url = Config::inst()->get('BasePage', 'pdf_base_url').'/'; |
|
313 | + if (Config::inst()->get('BasePage', 'pdf_base_url')) { |
|
314 | + $pdf_base_url = Config::inst()->get('BasePage', 'pdf_base_url') . '/'; |
|
315 | 315 | //otherwise, if we are CWP use the secure domain |
316 | - } elseif (defined('CWP_SECURE_DOMAIN')){ |
|
317 | - $pdf_base_url = CWP_SECURE_DOMAIN.'/'; |
|
316 | + } elseif (defined('CWP_SECURE_DOMAIN')) { |
|
317 | + $pdf_base_url = CWP_SECURE_DOMAIN . '/'; |
|
318 | 318 | //or if neither, leave blank |
319 | 319 | } else { |
320 | 320 | $pdf_base_url = ''; |
@@ -327,7 +327,7 @@ discard block |
||
327 | 327 | * Or if we aren't on a CWP server |
328 | 328 | */ |
329 | 329 | public function getPDFProxy($pdf_base_url) { |
330 | - if (!defined('CWP_SECURE_DOMAIN') || $pdf_base_url == CWP_SECURE_DOMAIN.'/') { |
|
330 | + if (!defined('CWP_SECURE_DOMAIN') || $pdf_base_url == CWP_SECURE_DOMAIN . '/') { |
|
331 | 331 | $proxy = ''; |
332 | 332 | } else { |
333 | 333 | $proxy = ' --proxy ' . SS_OUTBOUND_PROXY . ':' . SS_OUTBOUND_PROXY_PORT; |
@@ -339,20 +339,20 @@ discard block |
||
339 | 339 | * Render the page as PDF using wkhtmltopdf. |
340 | 340 | */ |
341 | 341 | public function generatePDF() { |
342 | - if(!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
342 | + if (!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
343 | 343 | |
344 | 344 | $binaryPath = Config::inst()->get('BasePage', 'wkhtmltopdf_binary'); |
345 | - if(!$binaryPath || !is_executable($binaryPath)) { |
|
346 | - if(defined('WKHTMLTOPDF_BINARY') && is_executable(WKHTMLTOPDF_BINARY)) { |
|
345 | + if (!$binaryPath || !is_executable($binaryPath)) { |
|
346 | + if (defined('WKHTMLTOPDF_BINARY') && is_executable(WKHTMLTOPDF_BINARY)) { |
|
347 | 347 | $binaryPath = WKHTMLTOPDF_BINARY; |
348 | 348 | } |
349 | 349 | } |
350 | 350 | |
351 | - if(!$binaryPath) { |
|
351 | + if (!$binaryPath) { |
|
352 | 352 | user_error('Neither WKHTMLTOPDF_BINARY nor BasePage.wkhtmltopdf_binary are defined', E_USER_ERROR); |
353 | 353 | } |
354 | 354 | |
355 | - if(Versioned::get_reading_mode() == 'Stage.Stage') { |
|
355 | + if (Versioned::get_reading_mode() == 'Stage.Stage') { |
|
356 | 356 | user_error('Generating PDFs on draft is not supported', E_USER_ERROR); |
357 | 357 | } |
358 | 358 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | $footerFile = str_replace('.pdf', '_pdffooter.html', $pdfFile); |
365 | 365 | |
366 | 366 | // make sure the work directory exists |
367 | - if(!file_exists(dirname($pdfFile))) Filesystem::makeFolder(dirname($pdfFile)); |
|
367 | + if (!file_exists(dirname($pdfFile))) Filesystem::makeFolder(dirname($pdfFile)); |
|
368 | 368 | |
369 | 369 | //decide the domain to use in generation |
370 | 370 | $pdf_base_url = $this->getPDFBaseURL(); |
@@ -374,8 +374,8 @@ discard block |
||
374 | 374 | Config::inst()->nest(); |
375 | 375 | Config::inst()->update('Director', 'alternate_protocol', 'http'); |
376 | 376 | //only set alternate protocol if CWP_SECURE_DOMAIN is defined OR pdf_base_url is |
377 | - if($pdf_base_url){ |
|
378 | - Config::inst()->update('Director', 'alternate_base_url', 'http://'.$pdf_base_url); |
|
377 | + if ($pdf_base_url) { |
|
378 | + Config::inst()->update('Director', 'alternate_base_url', 'http://' . $pdf_base_url); |
|
379 | 379 | } |
380 | 380 | } |
381 | 381 | |
@@ -408,7 +408,7 @@ discard block |
||
408 | 408 | unlink($footerFile); |
409 | 409 | |
410 | 410 | // output any errors |
411 | - if($return_val != 0) { |
|
411 | + if ($return_val != 0) { |
|
412 | 412 | user_error('wkhtmltopdf failed: ' . implode("\n", $output), E_USER_ERROR); |
413 | 413 | } |
414 | 414 | |
@@ -420,9 +420,9 @@ discard block |
||
420 | 420 | * Site search form |
421 | 421 | */ |
422 | 422 | public function SearchForm() { |
423 | - $searchText = _t('SearchForm.SEARCH', 'Search'); |
|
423 | + $searchText = _t('SearchForm.SEARCH', 'Search'); |
|
424 | 424 | |
425 | - if($this->getRequest()->getVar('Search')) { |
|
425 | + if ($this->getRequest()->getVar('Search')) { |
|
426 | 426 | $searchText = $this->getRequest()->getVar('Search'); |
427 | 427 | } |
428 | 428 | |
@@ -472,7 +472,7 @@ discard block |
||
472 | 472 | 'Results' => $results ? $results->getResults() : '', |
473 | 473 | 'Title' => _t('SearchForm.SearchResults', 'Search Results') |
474 | 474 | )); |
475 | - if($results) { |
|
475 | + if ($results) { |
|
476 | 476 | $response = $response->customise($results); |
477 | 477 | } |
478 | 478 | |
@@ -506,8 +506,8 @@ discard block |
||
506 | 506 | $themeDir = SSViewer::get_theme_folder(); |
507 | 507 | |
508 | 508 | return array( |
509 | - THIRDPARTY_DIR .'/jquery/jquery.js', |
|
510 | - THIRDPARTY_DIR .'/jquery-ui/jquery-ui.js', |
|
509 | + THIRDPARTY_DIR . '/jquery/jquery.js', |
|
510 | + THIRDPARTY_DIR . '/jquery-ui/jquery-ui.js', |
|
511 | 511 | "$themeDir/js/lib/modernizr.js", |
512 | 512 | "$themeDir/js/bootstrap-transition.2.3.1.js", |
513 | 513 | 'themes/module_bootstrap/js/bootstrap-collapse.js', |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | |
544 | 544 | // Ensure we only include styles when theme is enabled (except when running certain tests) |
545 | 545 | $theme = Config::inst()->get('SSViewer', 'theme'); |
546 | - if($theme) { |
|
546 | + if ($theme) { |
|
547 | 547 | // Include base scripts that are needed on all pages |
548 | 548 | Requirements::combine_files('scripts.js', $this->getBaseScripts()); |
549 | 549 |
@@ -66,7 +66,9 @@ discard block |
||
66 | 66 | $baseName = sprintf('%s-%s', $this->URLSegment, $this->ID); |
67 | 67 | |
68 | 68 | $folderPath = Config::inst()->get('BasePage', 'generated_pdf_path'); |
69 | - if($folderPath[0] != '/') $folderPath = BASE_PATH . '/' . $folderPath; |
|
69 | + if($folderPath[0] != '/') { |
|
70 | + $folderPath = BASE_PATH . '/' . $folderPath; |
|
71 | + } |
|
70 | 72 | |
71 | 73 | return sprintf('%s/%s.pdf', $folderPath, $baseName); |
72 | 74 | } |
@@ -75,7 +77,9 @@ discard block |
||
75 | 77 | * Build pdf link for template. |
76 | 78 | */ |
77 | 79 | public function PdfLink() { |
78 | - if(!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
80 | + if(!Config::inst()->get('BasePage', 'pdf_export')) { |
|
81 | + return false; |
|
82 | + } |
|
79 | 83 | |
80 | 84 | $path = $this->getPdfFilename(); |
81 | 85 | |
@@ -112,7 +116,9 @@ discard block |
||
112 | 116 | * @return boolean |
113 | 117 | */ |
114 | 118 | public function doUnpublish() { |
115 | - if(!parent::doUnpublish()) return false; |
|
119 | + if(!parent::doUnpublish()) { |
|
120 | + return false; |
|
121 | + } |
|
116 | 122 | |
117 | 123 | $filepath = $this->getPdfFilename(); |
118 | 124 | if(file_exists($filepath)) { |
@@ -245,8 +251,11 @@ discard block |
||
245 | 251 | ))); |
246 | 252 | } |
247 | 253 | |
248 | - if ($translations->count()>1) return $translations; |
|
249 | - else return null; |
|
254 | + if ($translations->count()>1) { |
|
255 | + return $translations; |
|
256 | + } else { |
|
257 | + return null; |
|
258 | + } |
|
250 | 259 | } |
251 | 260 | |
252 | 261 | } |
@@ -291,7 +300,9 @@ discard block |
||
291 | 300 | * Serve the page rendered as PDF. |
292 | 301 | */ |
293 | 302 | public function downloadpdf() { |
294 | - if(!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
303 | + if(!Config::inst()->get('BasePage', 'pdf_export')) { |
|
304 | + return false; |
|
305 | + } |
|
295 | 306 | |
296 | 307 | // We only allow producing live pdf. There is no way to secure the draft files. |
297 | 308 | Versioned::reading_stage('Live'); |
@@ -339,7 +350,9 @@ discard block |
||
339 | 350 | * Render the page as PDF using wkhtmltopdf. |
340 | 351 | */ |
341 | 352 | public function generatePDF() { |
342 | - if(!Config::inst()->get('BasePage', 'pdf_export')) return false; |
|
353 | + if(!Config::inst()->get('BasePage', 'pdf_export')) { |
|
354 | + return false; |
|
355 | + } |
|
343 | 356 | |
344 | 357 | $binaryPath = Config::inst()->get('BasePage', 'wkhtmltopdf_binary'); |
345 | 358 | if(!$binaryPath || !is_executable($binaryPath)) { |
@@ -364,7 +377,9 @@ discard block |
||
364 | 377 | $footerFile = str_replace('.pdf', '_pdffooter.html', $pdfFile); |
365 | 378 | |
366 | 379 | // make sure the work directory exists |
367 | - if(!file_exists(dirname($pdfFile))) Filesystem::makeFolder(dirname($pdfFile)); |
|
380 | + if(!file_exists(dirname($pdfFile))) { |
|
381 | + Filesystem::makeFolder(dirname($pdfFile)); |
|
382 | + } |
|
368 | 383 | |
369 | 384 | //decide the domain to use in generation |
370 | 385 | $pdf_base_url = $this->getPDFBaseURL(); |
@@ -35,7 +35,7 @@ |
||
35 | 35 | public function redirectionLink() { |
36 | 36 | $childPage = $this->Children()->first(); |
37 | 37 | |
38 | - if($childPage) { |
|
38 | + if ($childPage) { |
|
39 | 39 | // If we're linking to another redirectorpage then just return the URLSegment, to prevent a cycle of redirector |
40 | 40 | // pages from causing an infinite loop. Instead, they will cause a 30x redirection loop in the browser, but |
41 | 41 | // this can be handled sufficiently gracefully by the browser. |