@@ -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 | |
@@ -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 | } |
@@ -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(); |
@@ -77,7 +77,9 @@ |
||
| 77 | 77 | } |
| 78 | 78 | |
| 79 | 79 | public function ArchivedReadable(){ |
| 80 | - if($this->Archived == 1) return _t('GridField.Archived', 'Archived'); |
|
| 80 | + if($this->Archived == 1) { |
|
| 81 | + return _t('GridField.Archived', 'Archived'); |
|
| 82 | + } |
|
| 81 | 83 | return _t('GridField.Live', 'Live'); |
| 82 | 84 | } |
| 83 | 85 | } |
@@ -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(); |