@@ -22,7 +22,7 @@ |
||
22 | 22 | // if this class is already loaded before instantiating it. Loading it now |
23 | 23 | // makes sure our version is used when a controller enables query caching |
24 | 24 | if(!class_exists('CI_DB_Cache')) { |
25 | - @include(APPPATH . 'libraries/MY_DB_cache.php'); |
|
25 | + @include(APPPATH.'libraries/MY_DB_cache.php'); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | // call the parent method to retain the CI functionality |
@@ -137,7 +137,9 @@ discard block |
||
137 | 137 | } |
138 | 138 | |
139 | 139 | $success = $this->set_db($idData, $valueData); |
140 | - if($success) $this->session->unset_tempdata("option_{$option}"); |
|
140 | + if($success) { |
|
141 | + $this->session->unset_tempdata("option_{$option}"); |
|
142 | + } |
|
141 | 143 | } else { |
142 | 144 | $success = FALSE; |
143 | 145 | } |
@@ -164,7 +166,9 @@ discard block |
||
164 | 166 | } |
165 | 167 | |
166 | 168 | //Overall fallback method. |
167 | - if(!isset($value)) $value = $this->options[$option]['default']; |
|
169 | + if(!isset($value)) { |
|
170 | + $value = $this->options[$option]['default']; |
|
171 | + } |
|
168 | 172 | } else { |
169 | 173 | $value = FALSE; |
170 | 174 | } |
@@ -215,7 +219,10 @@ discard block |
||
215 | 219 | //This should never happen. |
216 | 220 | break; |
217 | 221 | } |
218 | - if(!isset($value)) $value = FALSE; //FIXME: This won't play nice with BOOL type false? |
|
222 | + if(!isset($value)) { |
|
223 | + $value = FALSE; |
|
224 | + } |
|
225 | + //FIXME: This won't play nice with BOOL type false? |
|
219 | 226 | |
220 | 227 | return $value; |
221 | 228 | } |
@@ -114,7 +114,7 @@ |
||
114 | 114 | * @param string $option |
115 | 115 | * @param int|null $userID |
116 | 116 | * |
117 | - * @return mixed Returns option value as STRING, or FALSE if option does not exist. |
|
117 | + * @return string Returns option value as STRING, or FALSE if option does not exist. |
|
118 | 118 | */ |
119 | 119 | public function get(string $option, ?int $userID = NULL) { |
120 | 120 | $userID = (is_null($userID) ? (int) $this->User->id : $userID); |
@@ -188,18 +188,18 @@ |
||
188 | 188 | //FIXME: Query duplication. |
189 | 189 | if($this->User->id !== $userID) { |
190 | 190 | $query = $this->db->select('value_str, value_int') |
191 | - ->from('user_options') |
|
192 | - ->where('user_id', $userID) |
|
193 | - ->where('name', $option) |
|
194 | - ->limit(1); |
|
191 | + ->from('user_options') |
|
192 | + ->where('user_id', $userID) |
|
193 | + ->where('name', $option) |
|
194 | + ->limit(1); |
|
195 | 195 | $data = $query->get()->row_array(); |
196 | 196 | } else { |
197 | 197 | if(!($data = $this->session->tempdata("option_{$option}"))) { |
198 | 198 | $query = $this->db->select('value_str, value_int') |
199 | - ->from('user_options') |
|
200 | - ->where('user_id', $userID) |
|
201 | - ->where('name', $option) |
|
202 | - ->limit(1); |
|
199 | + ->from('user_options') |
|
200 | + ->where('user_id', $userID) |
|
201 | + ->where('name', $option) |
|
202 | + ->limit(1); |
|
203 | 203 | $data = $query->get()->row_array(); |
204 | 204 | $this->session->set_tempdata("option_{$option}", $data, 3600); |
205 | 205 | } |
@@ -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 | class User_Options_Model extends CI_Model { |
4 | 4 | public $options = array( |
@@ -200,7 +200,7 @@ discard block |
||
200 | 200 | $query = $this->db->select('value_str, value_int') |
201 | 201 | ->from('user_options') |
202 | 202 | ->where('user_id', $userID) |
203 | - ->where('name', $option) |
|
203 | + ->where('name', $option) |
|
204 | 204 | ->limit(1); |
205 | 205 | $data = $query->get()->row_array(); |
206 | 206 | } else { |
@@ -208,7 +208,7 @@ discard block |
||
208 | 208 | $query = $this->db->select('value_str, value_int') |
209 | 209 | ->from('user_options') |
210 | 210 | ->where('user_id', $userID) |
211 | - ->where('name', $option) |
|
211 | + ->where('name', $option) |
|
212 | 212 | ->limit(1); |
213 | 213 | $data = $query->get()->row_array(); |
214 | 214 | $this->session->set_tempdata("option_{$option}", $data, 3600); |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | ); |
262 | 262 | //FIXME: Get a better solution than str_replace for removing special characters |
263 | 263 | $elements = array(); |
264 | - foreach (array_values($this->options[$option]['valid_options']) as $valid_option) { |
|
264 | + foreach(array_values($this->options[$option]['valid_options']) as $valid_option) { |
|
265 | 265 | $elements[$option.'_'.str_replace(',', '_', $valid_option)] = array_merge($base_attributes, array( |
266 | 266 | 'value' => $valid_option |
267 | 267 | )); |
@@ -1,7 +1,7 @@ |
||
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 | include_once APPPATH.'models/Tracker/Tracker_Base_Model.php'; |
4 | -foreach (glob(APPPATH.'models/Tracker/*.php') as $filename) { |
|
4 | +foreach(glob(APPPATH.'models/Tracker/*.php') as $filename) { |
|
5 | 5 | /** @noinspection PhpIncludeInspection */ |
6 | 6 | include_once $filename; |
7 | 7 | } |
@@ -1,4 +1,4 @@ |
||
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 | include_once APPPATH.'models/Tracker/Tracker_Base_Model.php'; |
4 | 4 | foreach (glob(APPPATH.'models/Tracker/*.php') as $filename) { |
@@ -9,9 +9,9 @@ |
||
9 | 9 | $success = FALSE; |
10 | 10 | if(preg_match("/^[a-z0-9\\-_,:]{0,255}$/", $tag_string)) { |
11 | 11 | $success = (bool) $this->db->set(['tags' => $tag_string, 'active' => 'Y', 'last_updated' => NULL]) |
12 | - ->where('user_id', $userID) |
|
13 | - ->where('id', $chapterID) |
|
14 | - ->update('tracker_chapters'); |
|
12 | + ->where('user_id', $userID) |
|
13 | + ->where('id', $chapterID) |
|
14 | + ->update('tracker_chapters'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | if($success) { |
@@ -1,4 +1,4 @@ |
||
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 Tracker_Tag_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -1,4 +1,4 @@ |
||
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 Tracker_Tag_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -35,9 +35,13 @@ |
||
35 | 35 | $titleID = $id; |
36 | 36 | } else { |
37 | 37 | //TODO: Check if title is valid URL! |
38 | - if($create) $titleID = $this->addTitle($titleURL, $siteID); |
|
38 | + if($create) { |
|
39 | + $titleID = $this->addTitle($titleURL, $siteID); |
|
40 | + } |
|
41 | + } |
|
42 | + if(!isset($titleID) || !$titleID) { |
|
43 | + $titleID = 0; |
|
39 | 44 | } |
40 | - if(!isset($titleID) || !$titleID) $titleID = 0; |
|
41 | 45 | |
42 | 46 | return ($returnData && $titleID !== 0 ? $query->row_array() : $titleID); |
43 | 47 | } |
@@ -1,4 +1,4 @@ |
||
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 Tracker_Title_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -1,4 +1,4 @@ |
||
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 Tracker_Title_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -122,7 +122,7 @@ |
||
122 | 122 | /** |
123 | 123 | * @param string $site_url |
124 | 124 | * |
125 | - * @return stdClass|object|null |
|
125 | + * @return string |
|
126 | 126 | */ |
127 | 127 | public function getSiteDataFromURL(string $site_url) { |
128 | 128 | $query = $this->db->select('*') |
@@ -15,11 +15,11 @@ discard block |
||
15 | 15 | */ |
16 | 16 | public function getID(string $titleURL, int $siteID, bool $create = TRUE, bool $returnData = FALSE) { |
17 | 17 | $query = $this->db->select('tracker_titles.id, tracker_titles.title, tracker_titles.title_url, tracker_titles.latest_chapter, tracker_titles.status, tracker_sites.site_class, (tracker_titles.last_checked > DATE_SUB(NOW(), INTERVAL 3 DAY)) AS active', FALSE) |
18 | - ->from('tracker_titles') |
|
19 | - ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
20 | - ->where('tracker_titles.title_url', $titleURL) |
|
21 | - ->where('tracker_titles.site_id', $siteID) |
|
22 | - ->get(); |
|
18 | + ->from('tracker_titles') |
|
19 | + ->join('tracker_sites', 'tracker_sites.id = tracker_titles.site_id', 'left') |
|
20 | + ->where('tracker_titles.title_url', $titleURL) |
|
21 | + ->where('tracker_titles.site_id', $siteID) |
|
22 | + ->get(); |
|
23 | 23 | |
24 | 24 | if($query->num_rows() > 0) { |
25 | 25 | $id = (int) $query->row('id'); |
@@ -32,8 +32,8 @@ discard block |
||
32 | 32 | //Make sure last_checked is always updated on successful run. |
33 | 33 | //CHECK: Is there a reason we aren't just doing this in updateTitleById? |
34 | 34 | $this->db->set('last_checked', 'CURRENT_TIMESTAMP', FALSE) |
35 | - ->where('id', $id) |
|
36 | - ->update('tracker_titles'); |
|
35 | + ->where('id', $id) |
|
36 | + ->update('tracker_titles'); |
|
37 | 37 | } |
38 | 38 | } else { |
39 | 39 | log_message('error', "{$query->row('title')} failed to update successfully"); |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | */ |
74 | 74 | private function addTitle(string $titleURL, int $siteID) : int { |
75 | 75 | $query = $this->db->select('site, site_class') |
76 | - ->from('tracker_sites') |
|
77 | - ->where('id', $siteID) |
|
78 | - ->get(); |
|
76 | + ->from('tracker_sites') |
|
77 | + ->where('id', $siteID) |
|
78 | + ->get(); |
|
79 | 79 | |
80 | 80 | $titleData = $this->sites->{$query->row()->site_class}->getTitleData($titleURL, TRUE); |
81 | 81 | |
@@ -101,20 +101,20 @@ discard block |
||
101 | 101 | public function updateByID(int $titleID, string $latestChapter) : bool { |
102 | 102 | //FIXME: Really not too happy with how we're doing history stuff here, it just feels messy. |
103 | 103 | $query = $this->db->select('latest_chapter AS current_chapter') |
104 | - ->from('tracker_titles') |
|
105 | - ->where('id', $titleID) |
|
106 | - ->get(); |
|
104 | + ->from('tracker_titles') |
|
105 | + ->where('id', $titleID) |
|
106 | + ->get(); |
|
107 | 107 | $row = $query->row(); |
108 | 108 | |
109 | 109 | $success = $this->db->set(['latest_chapter' => $latestChapter, 'failed_checks' => 0]) //last_updated gets updated via a trigger if something changes |
110 | - ->where('id', $titleID) |
|
111 | - ->update('tracker_titles'); |
|
110 | + ->where('id', $titleID) |
|
111 | + ->update('tracker_titles'); |
|
112 | 112 | |
113 | 113 | if($this->db->affected_rows() > 0) { |
114 | 114 | //Clear hidden latest chapter |
115 | 115 | $this->db->set(['ignore_chapter' => 'NULL', 'last_updated' => 'last_updated'], NULL, FALSE) |
116 | - ->where('title_id', $titleID) |
|
117 | - ->update('tracker_chapters'); |
|
116 | + ->where('title_id', $titleID) |
|
117 | + ->update('tracker_chapters'); |
|
118 | 118 | } |
119 | 119 | |
120 | 120 | //Update History |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | |
128 | 128 | public function updateFailedChecksByID(int $titleID) : bool { |
129 | 129 | $success = $this->db->set('failed_checks', 'failed_checks + 1', FALSE) |
130 | - ->where('id', $titleID) |
|
131 | - ->update('tracker_titles'); |
|
130 | + ->where('id', $titleID) |
|
131 | + ->update('tracker_titles'); |
|
132 | 132 | |
133 | 133 | return $success; |
134 | 134 | } |
@@ -140,9 +140,9 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function getSiteDataFromURL(string $site_url) { |
142 | 142 | $query = $this->db->select('*') |
143 | - ->from('tracker_sites') |
|
144 | - ->where('site', $site_url) |
|
145 | - ->get(); |
|
143 | + ->from('tracker_sites') |
|
144 | + ->where('site', $site_url) |
|
145 | + ->get(); |
|
146 | 146 | |
147 | 147 | return $query->row(); |
148 | 148 | } |
@@ -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 | //http://english.stackexchange.com/a/141735 |
4 | 4 | class Tracker_Portation_Model extends Tracker_Base_Model { |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | |
56 | 56 | $arr = []; |
57 | 57 | if($query->num_rows() > 0) { |
58 | - foreach ($query->result() as $row) { |
|
58 | + foreach($query->result() as $row) { |
|
59 | 59 | $arr[$row->category][] = [ |
60 | 60 | 'site' => $row->site, |
61 | 61 | 'title_url' => $row->title_url, |
@@ -1,4 +1,4 @@ |
||
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 | //http://english.stackexchange.com/a/141735 |
4 | 4 | class Tracker_Portation_Model extends Tracker_Base_Model { |
@@ -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 | class Tracker_Favourites_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -14,8 +14,8 @@ discard block |
||
14 | 14 | tf.chapter, tf.updated_at', FALSE) |
15 | 15 | ->from('tracker_favourites AS tf') |
16 | 16 | ->join('tracker_chapters AS tc', 'tf.chapter_id = tc.id', 'left') |
17 | - ->join('tracker_titles AS tt', 'tc.title_id = tt.id', 'left') |
|
18 | - ->join('tracker_sites AS ts', 'tt.site_id = ts.id', 'left') |
|
17 | + ->join('tracker_titles AS tt', 'tc.title_id = tt.id', 'left') |
|
18 | + ->join('tracker_sites AS ts', 'tt.site_id = ts.id', 'left') |
|
19 | 19 | ->where('tc.user_id', $this->User->id) //CHECK: Is this inefficient? Would it be better to have a user_id column in tracker_favourites? |
20 | 20 | ->order_by('tf.id DESC') |
21 | 21 | ->limit($rowsPerPage, ($rowsPerPage * ($page - 1))) |
@@ -1,4 +1,4 @@ |
||
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 Tracker_Favourites_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -71,32 +71,32 @@ |
||
71 | 71 | |
72 | 72 | ////We need the series to be tracked |
73 | 73 | $idCQuery = $this->db->select('id') |
74 | - ->where('user_id', $userID) |
|
75 | - ->where('title_id', $titleID) |
|
76 | - ->get('tracker_chapters'); |
|
74 | + ->where('user_id', $userID) |
|
75 | + ->where('title_id', $titleID) |
|
76 | + ->get('tracker_chapters'); |
|
77 | 77 | if(!($idCQuery->num_rows() > 0)) { |
78 | 78 | //NOTE: This pretty much repeats a lot of what we already did above. Is there a better way to do this? |
79 | 79 | $this->Tracker->list->update($userID, $site, $title, $chapter, FALSE); |
80 | 80 | |
81 | 81 | $idCQuery = $this->db->select('id') |
82 | - ->where('user_id', $userID) |
|
83 | - ->where('title_id', $titleID) |
|
84 | - ->get('tracker_chapters'); |
|
82 | + ->where('user_id', $userID) |
|
83 | + ->where('title_id', $titleID) |
|
84 | + ->get('tracker_chapters'); |
|
85 | 85 | } |
86 | 86 | if($idCQuery->num_rows() > 0) { |
87 | 87 | $idCQueryRow = $idCQuery->row(); |
88 | 88 | |
89 | 89 | //Check if it is already favourited |
90 | 90 | $idFQuery = $this->db->select('id') |
91 | - ->where('chapter_id', $idCQueryRow->id) |
|
92 | - ->where('chapter', $chapter) |
|
93 | - ->get('tracker_favourites'); |
|
91 | + ->where('chapter_id', $idCQueryRow->id) |
|
92 | + ->where('chapter', $chapter) |
|
93 | + ->get('tracker_favourites'); |
|
94 | 94 | if($idFQuery->num_rows() > 0) { |
95 | 95 | //Chapter is already favourited, so remove it from DB |
96 | 96 | $idFQueryRow = $idFQuery->row(); |
97 | 97 | |
98 | 98 | $isSuccess = (bool) $this->db->where('id', $idFQueryRow->id) |
99 | - ->delete('tracker_favourites'); |
|
99 | + ->delete('tracker_favourites'); |
|
100 | 100 | |
101 | 101 | if($isSuccess) { |
102 | 102 | $success = array( |
@@ -7,9 +7,9 @@ discard block |
||
7 | 7 | |
8 | 8 | public function setByID(int $userID, int $chapterID, string $category) : bool { |
9 | 9 | $success = $this->db->set(['category' => $category, 'active' => 'Y', 'last_updated' => NULL]) |
10 | - ->where('user_id', $userID) |
|
11 | - ->where('id', $chapterID) |
|
12 | - ->update('tracker_chapters'); |
|
10 | + ->where('user_id', $userID) |
|
11 | + ->where('id', $chapterID) |
|
12 | + ->update('tracker_chapters'); |
|
13 | 13 | |
14 | 14 | return (bool) $success; |
15 | 15 | } |
@@ -40,11 +40,11 @@ discard block |
||
40 | 40 | |
41 | 41 | public function getUsed(int $userID) : array { |
42 | 42 | $query = $this->db->distinct() |
43 | - ->select('category') |
|
44 | - ->from('tracker_chapters') |
|
45 | - ->where('tracker_chapters.active', 'Y') |
|
46 | - ->where('user_id', $userID) |
|
47 | - ->get(); |
|
43 | + ->select('category') |
|
44 | + ->from('tracker_chapters') |
|
45 | + ->where('tracker_chapters.active', 'Y') |
|
46 | + ->where('user_id', $userID) |
|
47 | + ->get(); |
|
48 | 48 | |
49 | 49 | return array_column($query->result_array(), 'category'); |
50 | 50 | } |
@@ -1,4 +1,4 @@ |
||
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 Tracker_Category_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -1,4 +1,4 @@ |
||
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 Tracker_Category_Model extends Tracker_Base_Model { |
4 | 4 | public function __construct() { |
@@ -1,5 +1,5 @@ |
||
1 | 1 | <?php |
2 | -defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2 | +defined('BASEPATH') or exit('No direct script access allowed'); |
|
3 | 3 | |
4 | 4 | echo "\nERROR: ", |
5 | 5 | $heading, |