@@ -1,11 +1,11 @@ discard block |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | class LHTranslation extends Base_Site_Model { |
4 | 4 | public $titleFormat = '/^[a-zA-Z0-9_\-.]+$/'; |
5 | 5 | public $chapterFormat = '/^[0-9\.]+$/'; |
6 | 6 | |
7 | 7 | public function getFullTitleURL(string $title_url) : string { |
8 | - $title_url = str_replace('.','', $title_url); |
|
8 | + $title_url = str_replace('.', '', $title_url); |
|
9 | 9 | return "http://lhtranslation.com/{$title_url}"; |
10 | 10 | } |
11 | 11 | |
@@ -17,17 +17,17 @@ discard block |
||
17 | 17 | ]; |
18 | 18 | } |
19 | 19 | |
20 | - public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array { |
|
20 | + public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array { |
|
21 | 21 | $titleData = []; |
22 | 22 | |
23 | - $title_url = str_replace('.','', $title_url); |
|
23 | + $title_url = str_replace('.', '', $title_url); |
|
24 | 24 | $title_url = $this->_fixTitle($title_url); |
25 | 25 | $fullURL = "http://lhtranslation.com/{$title_url}/feed/"; |
26 | 26 | $content = $this->get_content($fullURL); |
27 | 27 | |
28 | 28 | $data = $content['body']; |
29 | 29 | $xml = simplexml_load_string($data) or die("Error: Cannot create object"); |
30 | - if(((string) $xml->{'channel'}->title) !== 'Comments on: '){ |
|
30 | + if(((string) $xml->{'channel'}->title) !== 'Comments on: ') { |
|
31 | 31 | if(isset($xml->{'channel'}->item[0])) { |
32 | 32 | if($title = (string) $xml->{'channel'}->item[0]->category) { |
33 | 33 | $titleData['title'] = trim($title); |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | protected $footer_data = array(); |
7 | 7 | public $global_data = array(); |
8 | 8 | |
9 | - public function __construct(){ |
|
9 | + public function __construct() { |
|
10 | 10 | parent::__construct(); |
11 | 11 | |
12 | 12 | //FIXME: This is pretty much a phpUnit hack. Without it phpUnit fails here. We need a proper way to fake user/admin testing. |
@@ -18,10 +18,10 @@ discard block |
||
18 | 18 | |
19 | 19 | $this->global_data['theme'] = $this->User_Options->get('theme'); |
20 | 20 | $css_path = "css/main.{$this->User_Options->get('theme')}"; |
21 | - $this->global_data['complied_css_path'] = asset_url()."{$css_path}.".filemtime(APPPATH . "../public/assets/{$css_path}.css").".css"; |
|
21 | + $this->global_data['complied_css_path'] = asset_url()."{$css_path}.".filemtime(APPPATH."../public/assets/{$css_path}.css").".css"; |
|
22 | 22 | |
23 | 23 | $js_path = 'js/compiled.min'; |
24 | - $this->global_data['complied_js_path'] = asset_url()."{$js_path}.".filemtime(APPPATH . "../public/assets/{$js_path}.js").".js"; |
|
24 | + $this->global_data['complied_js_path'] = asset_url()."{$js_path}.".filemtime(APPPATH."../public/assets/{$js_path}.js").".js"; |
|
25 | 25 | } |
26 | 26 | |
27 | 27 | public function _render_page(/*(array) $paths*/) : void { |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | $json = is_array($json_input) ? json_encode($json_input) : $json_input; |
46 | 46 | |
47 | 47 | $this->output->set_content_type('application/json', 'utf-8'); |
48 | - $this->_render_content($json,'json', $download, $filenamePrefix); |
|
48 | + $this->_render_content($json, 'json', $download, $filenamePrefix); |
|
49 | 49 | } |
50 | 50 | public function _render_content(string $content, string $filenameExt, bool $download = FALSE, string $filenamePrefix = 'tracker') : void { |
51 | 51 | if($download) { |
@@ -1,4 +1,4 @@ discard block |
||
1 | -<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
1 | +<?php declare(strict_types = 1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2 | 2 | |
3 | 3 | /** |
4 | 4 | * Class Tracker_Sites_Model |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * @param bool $firstGet |
103 | 103 | * @return array|null [title,latest_chapter,last_updated,followed?] |
104 | 104 | */ |
105 | - abstract public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array; |
|
105 | + abstract public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array; |
|
106 | 106 | |
107 | 107 | /** |
108 | 108 | * Validates given $title_url against titleFormat. |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | |
154 | 154 | $ch = curl_init(); |
155 | 155 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); |
156 | - curl_setopt($ch, CURLOPT_ENCODING , "gzip"); |
|
156 | + curl_setopt($ch, CURLOPT_ENCODING, "gzip"); |
|
157 | 157 | //curl_setopt($ch, CURLOPT_VERBOSE, 1); |
158 | 158 | curl_setopt($ch, CURLOPT_HEADER, 1); |
159 | 159 | |
@@ -175,8 +175,8 @@ discard block |
||
175 | 175 | curl_setopt($ch, CURLOPT_URL, $url); |
176 | 176 | |
177 | 177 | if($isPost) { |
178 | - curl_setopt($ch,CURLOPT_POST, count($postFields)); |
|
179 | - curl_setopt($ch,CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
178 | + curl_setopt($ch, CURLOPT_POST, count($postFields)); |
|
179 | + curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($postFields)); |
|
180 | 180 | } |
181 | 181 | |
182 | 182 | $response = curl_exec($ch); |
@@ -220,7 +220,7 @@ discard block |
||
220 | 220 | $result = shell_exec('python '.APPPATH.'../_scripts/get_cloudflare_cookie.py '.escapeshellarg(json_encode($urlData))); |
221 | 221 | $cookieData = json_decode($result, TRUE); |
222 | 222 | |
223 | - $this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */); |
|
223 | + $this->cache->save("cloudflare_{$this->site}", $cookieData['cookies'], 31536000 /* 1 year, or until we renew it */); |
|
224 | 224 | log_message('debug', "Saving CloudFlare Cookies for {$this->site}"); |
225 | 225 | |
226 | 226 | $refresh = TRUE; |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | |
272 | 272 | $dom = new DOMDocument(); |
273 | 273 | libxml_use_internal_errors(TRUE); |
274 | - $dom->loadHTML('<?xml encoding="utf-8" ?>' . $data); |
|
274 | + $dom->loadHTML('<?xml encoding="utf-8" ?>'.$data); |
|
275 | 275 | libxml_use_internal_errors(FALSE); |
276 | 276 | |
277 | 277 | $xpath = new DOMXPath($dom); |
@@ -279,7 +279,7 @@ discard block |
||
279 | 279 | $nodes_row = $xpath->query($node_row_string); |
280 | 280 | if($nodes_title->length === 1 && $nodes_row->length === 1) { |
281 | 281 | $firstRow = $nodes_row->item(0); |
282 | - $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
282 | + $nodes_latest = $xpath->query($node_latest_string, $firstRow); |
|
283 | 283 | |
284 | 284 | if($node_chapter_string !== '') { |
285 | 285 | $nodes_chapter = $xpath->query($node_chapter_string, $firstRow); |
@@ -467,14 +467,14 @@ discard block |
||
467 | 467 | $chapter_parts = explode('/', $chapter); //returns #LANG#/#VOLUME#/#CHAPTER#/#CHAPTER_EXTRA#(/#PAGE#/) |
468 | 468 | return [ |
469 | 469 | 'url' => $this->getChapterURL($title_url, $chapter), |
470 | - 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '') . "c{$chapter_parts[2]}" . (isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
470 | + 'number' => ($chapter_parts[1] !== '0' ? "v{$chapter_parts[1]}/" : '')."c{$chapter_parts[2]}".(isset($chapter_parts[3]) ? ".{$chapter_parts[3]}" : '')/*)*/ |
|
471 | 471 | ]; |
472 | 472 | } |
473 | 473 | public function getChapterURL(string $title_url, string $chapter) : string { |
474 | 474 | return "{$this->baseURL}/read/{$title_url}/{$chapter}/"; |
475 | 475 | } |
476 | 476 | |
477 | - public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array { |
|
477 | + public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array { |
|
478 | 478 | $titleData = []; |
479 | 479 | |
480 | 480 | $jsonURL = $this->getJSONTitleURL($title_url); |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | return $this->getFullTitleURL($title_url).'/'.$chapter; |
595 | 595 | } |
596 | 596 | |
597 | - public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array { |
|
597 | + public function getTitleData(string $title_url, bool $firstGet = FALSE) : ? array { |
|
598 | 598 | $titleData = []; |
599 | 599 | |
600 | 600 | $fullURL = $this->getFullTitleURL($title_url); |