@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | // |
34 | 34 | } |
35 | 35 | |
36 | - public function loadMyGroups (int $userID) { |
|
36 | + public function loadMyGroups(int $userID) { |
|
37 | 37 | if (Cache::contains("groups", "own-groups-" . $userID)) { |
38 | 38 | $this->my_groups = Cache::get("groups", "own-groups-" . $userID); |
39 | 39 | } else { |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | } |
52 | 52 | } |
53 | 53 | |
54 | - public function listGroupIDs () : array { |
|
54 | + public function listGroupIDs() : array { |
|
55 | 55 | $array = array(); |
56 | 56 | |
57 | 57 | foreach ($this->my_groups as $group_row) { |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | return $array; |
62 | 62 | } |
63 | 63 | |
64 | - public function listMyGroups () : array { |
|
64 | + public function listMyGroups() : array { |
|
65 | 65 | $array = array(); |
66 | 66 | |
67 | 67 | foreach ($this->my_groups as $row) { |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | return $array; |
75 | 75 | } |
76 | 76 | |
77 | - public static function createGroupIfIdAbsent (int $groupID, string $name, string $description, string $color = "#000000", bool $show = true, bool $system_group = false, bool $auto_assign_regist = false) { |
|
77 | + public static function createGroupIfIdAbsent(int $groupID, string $name, string $description, string $color = "#000000", bool $show = true, bool $system_group = false, bool $auto_assign_regist = false) { |
|
78 | 78 | //check, if color is valide |
79 | 79 | $validator = new Validator_Color(); |
80 | 80 | |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | Cache::clear("groups"); |
101 | 101 | } |
102 | 102 | |
103 | - public static function deleteGroup (int $groupID) { |
|
103 | + public static function deleteGroup(int $groupID) { |
|
104 | 104 | $group = new Group(); |
105 | 105 | |
106 | 106 | try { |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | $group->delete(); |
114 | 114 | } |
115 | 115 | |
116 | - public static function addGroupToUser (int $groupID, int $userID, bool $group_leader = false) { |
|
116 | + public static function addGroupToUser(int $groupID, int $userID, bool $group_leader = false) { |
|
117 | 117 | Database::getInstance()->execute("INSERT INTO `{praefix}group_members` ( |
118 | 118 | `groupID`, `userID`, `group_leader`, `activated` |
119 | 119 | ) VALUES ( |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | Cache::clear("groups", "own-groups-" . $userID); |
135 | 135 | } |
136 | 136 | |
137 | - public static function removeGroupFromUser (int $groupID, int $userID) { |
|
137 | + public static function removeGroupFromUser(int $groupID, int $userID) { |
|
138 | 138 | Database::getInstance()->execute("DELETE FROM `{praefix}group_members` WHERE `groupID` = :groupID AND `userID` = :userID; ", array( |
139 | 139 | 'groupID' => array( |
140 | 140 | 'type' => PDO::PARAM_INT, |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | // |
35 | 35 | } |
36 | 36 | |
37 | - public function loadById (int $groupID) { |
|
37 | + public function loadById(int $groupID) { |
|
38 | 38 | if (Cache::contains("groups", "group-" . $groupID)) { |
39 | 39 | $this->row = Cache::get("groups", "group-" . $groupID); |
40 | 40 | } else { |
@@ -57,12 +57,12 @@ discard block |
||
57 | 57 | } |
58 | 58 | } |
59 | 59 | |
60 | - public function loadByRow (array $row) { |
|
60 | + public function loadByRow(array $row) { |
|
61 | 61 | $this->row = $row; |
62 | 62 | $this->groupID = $row['groupID']; |
63 | 63 | } |
64 | 64 | |
65 | - public function update (string $name, string $description, string $color, bool $auto_assign_regist = false) { |
|
65 | + public function update(string $name, string $description, string $color, bool $auto_assign_regist = false) { |
|
66 | 66 | //throw event |
67 | 67 | Events::throwEvent("before_update_group", array( |
68 | 68 | 'groupID' => $this->groupID, |
@@ -100,12 +100,12 @@ discard block |
||
100 | 100 | Cache::clear("groups", "group-" . $this->groupID); |
101 | 101 | } |
102 | 102 | |
103 | - public function putCache () { |
|
103 | + public function putCache() { |
|
104 | 104 | //cache database row |
105 | 105 | Cache::put("groups", "group-" . $this->groupID, $this->row); |
106 | 106 | } |
107 | 107 | |
108 | - public function removeCache () { |
|
108 | + public function removeCache() { |
|
109 | 109 | //clear cache data for this group |
110 | 110 | Cache::clear("groups", "group-" . $this->groupID); |
111 | 111 | } |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | * |
116 | 116 | * @return id of group |
117 | 117 | */ |
118 | - public function getGroupID () : int { |
|
118 | + public function getGroupID() : int { |
|
119 | 119 | return $this->groupID; |
120 | 120 | } |
121 | 121 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * |
125 | 125 | * @return name of group |
126 | 126 | */ |
127 | - public function getName () : string { |
|
127 | + public function getName() : string { |
|
128 | 128 | return $this->row['name']; |
129 | 129 | } |
130 | 130 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * |
134 | 134 | * @return group description |
135 | 135 | */ |
136 | - public function getDescription () : string { |
|
136 | + public function getDescription() : string { |
|
137 | 137 | return $this->row['description']; |
138 | 138 | } |
139 | 139 | |
@@ -142,7 +142,7 @@ discard block |
||
142 | 142 | * |
143 | 143 | * @return color of group in hex |
144 | 144 | */ |
145 | - public function getColor () : string { |
|
145 | + public function getColor() : string { |
|
146 | 146 | return $this->row['color']; |
147 | 147 | } |
148 | 148 | |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | * |
152 | 152 | * @return true, if group is a system group |
153 | 153 | */ |
154 | - public function isSystemGroup () : bool { |
|
154 | + public function isSystemGroup() : bool { |
|
155 | 155 | return $this->row['system_group'] === 1; |
156 | 156 | } |
157 | 157 | |
@@ -160,39 +160,39 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @return true, if group is a auto assign group on registration |
162 | 162 | */ |
163 | - public function isAutoAssignGroup () : bool { |
|
163 | + public function isAutoAssignGroup() : bool { |
|
164 | 164 | return $this->row['auto_assign_regist'] === 1; |
165 | 165 | } |
166 | 166 | |
167 | - public function getRow () : array { |
|
167 | + public function getRow() : array { |
|
168 | 168 | return $this->row; |
169 | 169 | } |
170 | 170 | |
171 | - public function visible () : bool { |
|
171 | + public function visible() : bool { |
|
172 | 172 | return $this->row['show'] === 1; |
173 | 173 | } |
174 | 174 | |
175 | - public function hasRank () : bool { |
|
175 | + public function hasRank() : bool { |
|
176 | 176 | return $this->row['rank'] !== "none"; |
177 | 177 | } |
178 | 178 | |
179 | - public function getRank () : string { |
|
179 | + public function getRank() : string { |
|
180 | 180 | return $this->row['rank']; |
181 | 181 | } |
182 | 182 | |
183 | - public function hasRankImage () : bool { |
|
183 | + public function hasRankImage() : bool { |
|
184 | 184 | return $this->row['rank_image'] !== "none"; |
185 | 185 | } |
186 | 186 | |
187 | - public function getRankImage () : string { |
|
187 | + public function getRankImage() : string { |
|
188 | 188 | return $this->row['rank_image']; |
189 | 189 | } |
190 | 190 | |
191 | - public function isActivated () : bool { |
|
191 | + public function isActivated() : bool { |
|
192 | 192 | return $this->row['activated'] === 1; |
193 | 193 | } |
194 | 194 | |
195 | - public function delete () { |
|
195 | + public function delete() { |
|
196 | 196 | if ($this->groupID <= 0) { |
197 | 197 | throw new IllegalStateException("groupID cannot be <= 0, maybe group wasnt loaded with loadById() or loadByRow()?"); |
198 | 198 | } |
@@ -27,7 +27,7 @@ |
||
27 | 27 | |
28 | 28 | class LoginHandler { |
29 | 29 | |
30 | - public static function handle () : array { |
|
30 | + public static function handle() : array { |
|
31 | 31 | // |
32 | 32 | } |
33 | 33 |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | $this->page = $page; |
38 | 38 | } |
39 | 39 | |
40 | - public function load () { |
|
40 | + public function load() { |
|
41 | 41 | if (Cache::contains("page_rights", "page_" . $this->pageID)) { |
42 | 42 | $this->group_rows = Cache::get("page_rights", "page_" . $this->pageID); |
43 | 43 | } else { |
@@ -94,7 +94,7 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * check, if user has right for this page |
96 | 96 | */ |
97 | - public function checkRights (int $userID, array $groupIDs, string $token) : bool { |
|
97 | + public function checkRights(int $userID, array $groupIDs, string $token) : bool { |
|
98 | 98 | $value = 0; |
99 | 99 | |
100 | 100 | //per default published pages are visible, if not specified |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | return $value == 1 || $value == -1; |
133 | 133 | } |
134 | 134 | |
135 | - protected function mergeRow (array $permissions, string $token, int $value) : array { |
|
135 | + protected function mergeRow(array $permissions, string $token, int $value) : array { |
|
136 | 136 | if ($value < 0 || $value > 2) { |
137 | 137 | throw new IllegalArgumentException("token ('" . $token . "') value '" . $value . "' is not allowed, value has to be >= 0 and <= 2."); |
138 | 138 | } |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | return $permissions; |
151 | 151 | } |
152 | 152 | |
153 | - public static function setDefaultAllowedGroups (int $pageID, array $groupIDs) { |
|
153 | + public static function setDefaultAllowedGroups(int $pageID, array $groupIDs) { |
|
154 | 154 | if (sizeof($groupIDs) == 0) { |
155 | 155 | throw new IllegalArgumentException("no groupIDs was set."); |
156 | 156 | } |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | Cache::clear("page_rights", "page_" . $pageID); |
177 | 177 | } |
178 | 178 | |
179 | - public static function setDefaultAllowedGroupsForAlias (string $alias, array $groupIDs) { |
|
179 | + public static function setDefaultAllowedGroupsForAlias(string $alias, array $groupIDs) { |
|
180 | 180 | $pageID = Page::getPageIDByAlias($alias); |
181 | 181 | |
182 | 182 | self::setDefaultAllowedGroups($pageID, $groupIDs); |
@@ -27,12 +27,12 @@ |
||
27 | 27 | |
28 | 28 | class PageLoader { |
29 | 29 | |
30 | - public static function loadInstance (string $type_name) : PageType { |
|
30 | + public static function loadInstance(string $type_name) : PageType { |
|
31 | 31 | if ($type_name == null || empty($type_name)) { |
32 | 32 | throw new NullPointerException("page_type cannot be null or empty."); |
33 | 33 | } |
34 | 34 | |
35 | - $class = $type_name;//DataBase::getInstance()->escape($type_name); |
|
35 | + $class = $type_name; //DataBase::getInstance()->escape($type_name); |
|
36 | 36 | |
37 | 37 | return new $class(); |
38 | 38 | } |
@@ -50,12 +50,12 @@ discard block |
||
50 | 50 | |
51 | 51 | protected $db_driver = null; |
52 | 52 | |
53 | - public function __construct (string $table_name, DBDriver &$db_driver) { |
|
53 | + public function __construct(string $table_name, DBDriver &$db_driver) { |
|
54 | 54 | $this->table_name = $this->escape($table_name); |
55 | 55 | $this->db_driver = &$db_driver; |
56 | 56 | } |
57 | 57 | |
58 | - public function setEngine (string $engine_name) { |
|
58 | + public function setEngine(string $engine_name) { |
|
59 | 59 | $found = false; |
60 | 60 | $founded_engine = ""; |
61 | 61 | |
@@ -77,15 +77,15 @@ discard block |
||
77 | 77 | $this->db_engine = $engine_name; |
78 | 78 | } |
79 | 79 | |
80 | - public function setCharset (string $charset) { |
|
80 | + public function setCharset(string $charset) { |
|
81 | 81 | $this->charset = utf8_encode(htmlentities($charset)); |
82 | 82 | } |
83 | 83 | |
84 | - public function setTmpTable (bool $tmp_table) { |
|
84 | + public function setTmpTable(bool $tmp_table) { |
|
85 | 85 | $this->temp_table = $tmp_table; |
86 | 86 | } |
87 | 87 | |
88 | - public function setAutoIncrementStartValue (int $value) { |
|
88 | + public function setAutoIncrementStartValue(int $value) { |
|
89 | 89 | $this->auto_increment = $value; |
90 | 90 | } |
91 | 91 | |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * @param $unsigned unsigned value false / true |
98 | 98 | * @param $zerofill true, if values should be filled with 0, if value length isnt length of column |
99 | 99 | */ |
100 | - public function addInt (string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
100 | + public function addInt(string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
101 | 101 | $this->columns[$name] = array( |
102 | 102 | 'type' => "int", |
103 | 103 | 'name' => $name, |
@@ -113,7 +113,7 @@ discard block |
||
113 | 113 | /** |
114 | 114 | * addInteger() is an alias to addInt() |
115 | 115 | */ |
116 | - public function addInteger (string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
116 | + public function addInteger(string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
117 | 117 | $this->addInt($name, $length, $not_null, $auto_increment, $default_value, $unsigned, $zerofill); |
118 | 118 | } |
119 | 119 | |
@@ -124,7 +124,7 @@ discard block |
||
124 | 124 | * @param $length length of column |
125 | 125 | * @param $zerofill true, if values should be filled with 0, if value length isnt length of column |
126 | 126 | */ |
127 | - public function addUnsignedInteger (string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $zerofill = false) { |
|
127 | + public function addUnsignedInteger(string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $zerofill = false) { |
|
128 | 128 | $this->columns[$name] = array( |
129 | 129 | 'type' => "int", |
130 | 130 | 'name' => $name, |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | ); |
138 | 138 | } |
139 | 139 | |
140 | - public function addVarchar (string $name, int $length = 255, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
140 | + public function addVarchar(string $name, int $length = 255, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
141 | 141 | $this->columns[$name] = array( |
142 | 142 | 'type' => "varchar", |
143 | 143 | 'name' => $name, |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | ); |
150 | 150 | } |
151 | 151 | |
152 | - public function addBit (string $name, int $length = null, bool $not_null = false, string $default_value = null) { |
|
152 | + public function addBit(string $name, int $length = null, bool $not_null = false, string $default_value = null) { |
|
153 | 153 | $this->columns[$name] = array( |
154 | 154 | 'type' => "bit", |
155 | 155 | 'name' => $name, |
@@ -159,7 +159,7 @@ discard block |
||
159 | 159 | ); |
160 | 160 | } |
161 | 161 | |
162 | - public function addBinary (string $name, int $length = null, bool $not_null = false, string $default_value = null) { |
|
162 | + public function addBinary(string $name, int $length = null, bool $not_null = false, string $default_value = null) { |
|
163 | 163 | $this->columns[$name] = array( |
164 | 164 | 'type' => "binary", |
165 | 165 | 'name' => $name, |
@@ -169,7 +169,7 @@ discard block |
||
169 | 169 | ); |
170 | 170 | } |
171 | 171 | |
172 | - public function addText (string $name, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
172 | + public function addText(string $name, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
173 | 173 | $this->columns[$name] = array( |
174 | 174 | 'type' => "text", |
175 | 175 | 'name' => $name, |
@@ -180,7 +180,7 @@ discard block |
||
180 | 180 | ); |
181 | 181 | } |
182 | 182 | |
183 | - public function addChar (string $name, int $length = 255, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
183 | + public function addChar(string $name, int $length = 255, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
184 | 184 | $this->columns[$name] = array( |
185 | 185 | 'type' => "char", |
186 | 186 | 'name' => $name, |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | ); |
193 | 193 | } |
194 | 194 | |
195 | - public function addTinyText (string $name, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
195 | + public function addTinyText(string $name, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
196 | 196 | $this->columns[$name] = array( |
197 | 197 | 'type' => "tinytext", |
198 | 198 | 'name' => $name, |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | ); |
204 | 204 | } |
205 | 205 | |
206 | - public function addMediumText (string $name, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
206 | + public function addMediumText(string $name, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
207 | 207 | $this->columns[$name] = array( |
208 | 208 | 'type' => "mediumtext", |
209 | 209 | 'name' => $name, |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | ); |
215 | 215 | } |
216 | 216 | |
217 | - public function addLongText (string $name, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
217 | + public function addLongText(string $name, bool $not_null = false, string $default_value = null, bool $binary = false, string $charset = null) { |
|
218 | 218 | $this->columns[$name] = array( |
219 | 219 | 'type' => "longtext", |
220 | 220 | 'name' => $name, |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | ); |
226 | 226 | } |
227 | 227 | |
228 | - public function addTinyInt (string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
228 | + public function addTinyInt(string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
229 | 229 | $this->columns[$name] = array( |
230 | 230 | 'type' => "tinyint", |
231 | 231 | 'name' => $name, |
@@ -238,7 +238,7 @@ discard block |
||
238 | 238 | ); |
239 | 239 | } |
240 | 240 | |
241 | - public function addSmallInt (string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
241 | + public function addSmallInt(string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
242 | 242 | $this->columns[$name] = array( |
243 | 243 | 'type' => "smallint", |
244 | 244 | 'name' => $name, |
@@ -251,7 +251,7 @@ discard block |
||
251 | 251 | ); |
252 | 252 | } |
253 | 253 | |
254 | - public function addMediumInt (string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
254 | + public function addMediumInt(string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
255 | 255 | $this->columns[$name] = array( |
256 | 256 | 'type' => "mediumint", |
257 | 257 | 'name' => $name, |
@@ -264,7 +264,7 @@ discard block |
||
264 | 264 | ); |
265 | 265 | } |
266 | 266 | |
267 | - public function addBigInt (string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
267 | + public function addBigInt(string $name, int $length = null, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
268 | 268 | $this->columns[$name] = array( |
269 | 269 | 'type' => "bigint", |
270 | 270 | 'name' => $name, |
@@ -277,7 +277,7 @@ discard block |
||
277 | 277 | ); |
278 | 278 | } |
279 | 279 | |
280 | - public function addDecimal (string $name, int $length = 5, int $decimals = 2, bool $not_null = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
280 | + public function addDecimal(string $name, int $length = 5, int $decimals = 2, bool $not_null = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
281 | 281 | //DECIMAL doesnt support AUTO_INCREMENT |
282 | 282 | |
283 | 283 | $this->columns[$name] = array( |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | ); |
293 | 293 | } |
294 | 294 | |
295 | - public function addNumeric (string $name, int $length = 5, int $decimals = 2, bool $not_null = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
295 | + public function addNumeric(string $name, int $length = 5, int $decimals = 2, bool $not_null = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
296 | 296 | //NUMERIC doesnt support AUTO_INCREMENT |
297 | 297 | |
298 | 298 | $this->columns[$name] = array( |
@@ -307,7 +307,7 @@ discard block |
||
307 | 307 | ); |
308 | 308 | } |
309 | 309 | |
310 | - public function addDouble (string $name, int $length = 5, int $decimals = 2, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
310 | + public function addDouble(string $name, int $length = 5, int $decimals = 2, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
311 | 311 | $this->columns[$name] = array( |
312 | 312 | 'type' => "double", |
313 | 313 | 'name' => $name, |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | ); |
322 | 322 | } |
323 | 323 | |
324 | - public function addFloat (string $name, int $length = 5, int $decimals = 2, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
324 | + public function addFloat(string $name, int $length = 5, int $decimals = 2, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
325 | 325 | $this->columns[$name] = array( |
326 | 326 | 'type' => "float", |
327 | 327 | 'name' => $name, |
@@ -335,7 +335,7 @@ discard block |
||
335 | 335 | ); |
336 | 336 | } |
337 | 337 | |
338 | - public function addReal (string $name, int $length = 5, int $decimals = 2, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
338 | + public function addReal(string $name, int $length = 5, int $decimals = 2, bool $not_null = false, bool $auto_increment = false, int $default_value = null, bool $unsigned = false, bool $zerofill = false) { |
|
339 | 339 | $this->columns[$name] = array( |
340 | 340 | 'type' => "real", |
341 | 341 | 'name' => $name, |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | ); |
350 | 350 | } |
351 | 351 | |
352 | - public function addBlob (string $name, bool $not_null = false, string $default_value = null) { |
|
352 | + public function addBlob(string $name, bool $not_null = false, string $default_value = null) { |
|
353 | 353 | $this->columns[$name] = array( |
354 | 354 | 'type' => "blob", |
355 | 355 | 'name' => $name, |
@@ -358,7 +358,7 @@ discard block |
||
358 | 358 | ); |
359 | 359 | } |
360 | 360 | |
361 | - public function addTinyBlob (string $name, bool $not_null = false, string $default_value = null) { |
|
361 | + public function addTinyBlob(string $name, bool $not_null = false, string $default_value = null) { |
|
362 | 362 | $this->columns[$name] = array( |
363 | 363 | 'type' => "tinyblob", |
364 | 364 | 'name' => $name, |
@@ -367,7 +367,7 @@ discard block |
||
367 | 367 | ); |
368 | 368 | } |
369 | 369 | |
370 | - public function addMediumBlob (string $name, bool $not_null = false, string $default_value = null) { |
|
370 | + public function addMediumBlob(string $name, bool $not_null = false, string $default_value = null) { |
|
371 | 371 | $this->columns[$name] = array( |
372 | 372 | 'type' => "mediumblob", |
373 | 373 | 'name' => $name, |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | ); |
377 | 377 | } |
378 | 378 | |
379 | - public function addLongBlob (string $name, bool $not_null = false, string $default_value = null) { |
|
379 | + public function addLongBlob(string $name, bool $not_null = false, string $default_value = null) { |
|
380 | 380 | $this->columns[$name] = array( |
381 | 381 | 'type' => "longblob", |
382 | 382 | 'name' => $name, |
@@ -385,7 +385,7 @@ discard block |
||
385 | 385 | ); |
386 | 386 | } |
387 | 387 | |
388 | - public function addEnum (string $name, $values = array(), bool $not_null = false, string $default_value = null, string $charset = null) { |
|
388 | + public function addEnum(string $name, $values = array(), bool $not_null = false, string $default_value = null, string $charset = null) { |
|
389 | 389 | $this->columns[$name] = array( |
390 | 390 | 'type' => "enum", |
391 | 391 | 'name' => $name, |
@@ -396,7 +396,7 @@ discard block |
||
396 | 396 | ); |
397 | 397 | } |
398 | 398 | |
399 | - public function addSet (string $name, array $values = array(), bool $not_null = false, string $default_value = null, string $charset = null) { |
|
399 | + public function addSet(string $name, array $values = array(), bool $not_null = false, string $default_value = null, string $charset = null) { |
|
400 | 400 | $this->columns[$name] = array( |
401 | 401 | 'type' => "set", |
402 | 402 | 'name' => $name, |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | ); |
408 | 408 | } |
409 | 409 | |
410 | - public function addDate (string $name, bool $not_null = false, string $default_value = null) { |
|
410 | + public function addDate(string $name, bool $not_null = false, string $default_value = null) { |
|
411 | 411 | $this->columns[$name] = array( |
412 | 412 | 'type' => "date", |
413 | 413 | 'name' => $name, |
@@ -416,7 +416,7 @@ discard block |
||
416 | 416 | ); |
417 | 417 | } |
418 | 418 | |
419 | - public function addTime (string $name, bool $not_null = false, string $default_value = null, int $fsp = null) { |
|
419 | + public function addTime(string $name, bool $not_null = false, string $default_value = null, int $fsp = null) { |
|
420 | 420 | $this->columns[$name] = array( |
421 | 421 | 'type' => "time", |
422 | 422 | 'name' => $name, |
@@ -426,7 +426,7 @@ discard block |
||
426 | 426 | ); |
427 | 427 | } |
428 | 428 | |
429 | - public function addYear (string $name, bool $not_null = false, string $default_value = null) { |
|
429 | + public function addYear(string $name, bool $not_null = false, string $default_value = null) { |
|
430 | 430 | $this->columns[$name] = array( |
431 | 431 | 'type' => "year", |
432 | 432 | 'name' => $name, |
@@ -435,7 +435,7 @@ discard block |
||
435 | 435 | ); |
436 | 436 | } |
437 | 437 | |
438 | - public function addJSON (string $name, bool $not_null = false, string $default_value = null) { |
|
438 | + public function addJSON(string $name, bool $not_null = false, string $default_value = null) { |
|
439 | 439 | $this->columns[$name] = array( |
440 | 440 | 'type' => "json", |
441 | 441 | 'name' => $name, |
@@ -444,7 +444,7 @@ discard block |
||
444 | 444 | ); |
445 | 445 | } |
446 | 446 | |
447 | - public function addTimestamp (string $name, bool $not_null = false, string $default_value = null, bool $on_update_current_timestamp = false, int $fsp = null) { |
|
447 | + public function addTimestamp(string $name, bool $not_null = false, string $default_value = null, bool $on_update_current_timestamp = false, int $fsp = null) { |
|
448 | 448 | $this->columns[$name] = array( |
449 | 449 | 'type' => "timestamp", |
450 | 450 | 'name' => $name, |
@@ -455,7 +455,7 @@ discard block |
||
455 | 455 | ); |
456 | 456 | } |
457 | 457 | |
458 | - public function addDateTime (string $name, bool $not_null = false, string $default_value = null, int $fsp = null) { |
|
458 | + public function addDateTime(string $name, bool $not_null = false, string $default_value = null, int $fsp = null) { |
|
459 | 459 | $this->columns[$name] = array( |
460 | 460 | 'type' => "datetime", |
461 | 461 | 'name' => $name, |
@@ -465,14 +465,14 @@ discard block |
||
465 | 465 | ); |
466 | 466 | } |
467 | 467 | |
468 | - public function addPrimaryKey ($columns) { |
|
468 | + public function addPrimaryKey($columns) { |
|
469 | 469 | $this->indexes['primary'] = array( |
470 | 470 | 'type' => "primary", |
471 | 471 | 'columns' => $columns |
472 | 472 | ); |
473 | 473 | } |
474 | 474 | |
475 | - public function addIndex ($columns, string $index_name = null) { |
|
475 | + public function addIndex($columns, string $index_name = null) { |
|
476 | 476 | if ($index_name == null) { |
477 | 477 | if (!is_array($columns)) { |
478 | 478 | $index_name = "ix_" . $columns; |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | ); |
490 | 490 | } |
491 | 491 | |
492 | - public function addUnique ($columns, string $index_name = null) { |
|
492 | + public function addUnique($columns, string $index_name = null) { |
|
493 | 493 | if ($index_name == null) { |
494 | 494 | if (!is_array($columns)) { |
495 | 495 | $index_name = "uq_" . $columns; |
@@ -506,7 +506,7 @@ discard block |
||
506 | 506 | ); |
507 | 507 | } |
508 | 508 | |
509 | - public function addSpatial ($columns, string $index_name = null) { |
|
509 | + public function addSpatial($columns, string $index_name = null) { |
|
510 | 510 | if ($index_name == null) { |
511 | 511 | if (!is_array($columns)) { |
512 | 512 | $index_name = "sp_" . $columns; |
@@ -523,7 +523,7 @@ discard block |
||
523 | 523 | ); |
524 | 524 | } |
525 | 525 | |
526 | - public function addFulltext ($columns, string $index_name = null) { |
|
526 | + public function addFulltext($columns, string $index_name = null) { |
|
527 | 527 | if ($index_name == null) { |
528 | 528 | if (!is_array($columns)) { |
529 | 529 | $index_name = "ix_" . $columns; |
@@ -540,7 +540,7 @@ discard block |
||
540 | 540 | ); |
541 | 541 | } |
542 | 542 | |
543 | - public function addForeignKey ($columns, string $reference_table_name, $reference_columns, string $index_name = null, string $on_update = null, string $on_delete = null) { |
|
543 | + public function addForeignKey($columns, string $reference_table_name, $reference_columns, string $index_name = null, string $on_update = null, string $on_delete = null) { |
|
544 | 544 | if ($index_name == null) { |
545 | 545 | if (!is_array($columns)) { |
546 | 546 | $index_name = "ix_" . $columns; |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | ); |
562 | 562 | } |
563 | 563 | |
564 | - public function generateCreateQuery () : string { |
|
564 | + public function generateCreateQuery() : string { |
|
565 | 565 | $tmp_str = ""; |
566 | 566 | |
567 | 567 | if ($this->temp_table) { |
@@ -599,7 +599,7 @@ discard block |
||
599 | 599 | return $sql; |
600 | 600 | } |
601 | 601 | |
602 | - protected function generateColoumQuery () : string { |
|
602 | + protected function generateColoumQuery() : string { |
|
603 | 603 | //generate lines of coloum definitions |
604 | 604 | $lines = $this->getColoumLines(); |
605 | 605 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | return implode(",\r\n", $lines) . ""; |
608 | 608 | } |
609 | 609 | |
610 | - protected function generateIndexQuery () : string { |
|
610 | + protected function generateIndexQuery() : string { |
|
611 | 611 | //check, if no index is set |
612 | 612 | if (count($this->indexes) == 0) { |
613 | 613 | return ""; |
@@ -829,7 +829,7 @@ discard block |
||
829 | 829 | return ",\r\n" . implode(",\r\n", $lines); |
830 | 830 | } |
831 | 831 | |
832 | - protected function getColoumLines () : array { |
|
832 | + protected function getColoumLines() : array { |
|
833 | 833 | $lines = array(); |
834 | 834 | |
835 | 835 | foreach ($this->columns as $column) { |
@@ -1285,7 +1285,7 @@ discard block |
||
1285 | 1285 | /** |
1286 | 1286 | * create table structure in database, if table not exists |
1287 | 1287 | */ |
1288 | - public function create () { |
|
1288 | + public function create() { |
|
1289 | 1289 | //create table |
1290 | 1290 | $this->db_driver->execute($this->generateCreateQuery()); |
1291 | 1291 | } |
@@ -1293,7 +1293,7 @@ discard block |
||
1293 | 1293 | /** |
1294 | 1294 | * upgrades table structure in database, or if table not exists, creates table |
1295 | 1295 | */ |
1296 | - public function upgrade () { |
|
1296 | + public function upgrade() { |
|
1297 | 1297 | if (!$this->existsTable()) { |
1298 | 1298 | //create table structure |
1299 | 1299 | $this->create(); |
@@ -1305,7 +1305,7 @@ discard block |
||
1305 | 1305 | } |
1306 | 1306 | } |
1307 | 1307 | |
1308 | - public function listColumnsFromDatabase () : array { |
|
1308 | + public function listColumnsFromDatabase() : array { |
|
1309 | 1309 | $columns = array(); |
1310 | 1310 | |
1311 | 1311 | //get columns from database |
@@ -1406,7 +1406,7 @@ discard block |
||
1406 | 1406 | 'length' => $length, |
1407 | 1407 | 'decimals' => $decimals, |
1408 | 1408 | 'not_null' => $not_null, |
1409 | - 'values' => $values,//only for enum and set |
|
1409 | + 'values' => $values, //only for enum and set |
|
1410 | 1410 | 'auto_increment' => $auto_increment, |
1411 | 1411 | 'on_update_current_timestamp' => $on_update_current_timestamp, |
1412 | 1412 | 'unsigned' => $unsigned, |
@@ -1419,7 +1419,7 @@ discard block |
||
1419 | 1419 | return $columns; |
1420 | 1420 | } |
1421 | 1421 | |
1422 | - protected function detectTableChanges () : array { |
|
1422 | + protected function detectTableChanges() : array { |
|
1423 | 1423 | //columns |
1424 | 1424 | $changed_columns = array(); |
1425 | 1425 | $added_columns = array(); |
@@ -1520,64 +1520,64 @@ discard block |
||
1520 | 1520 | * |
1521 | 1521 | * @param $output_file file where sql query should be written in |
1522 | 1522 | */ |
1523 | - public function backup (string $output_file) : void { |
|
1523 | + public function backup(string $output_file) : void { |
|
1524 | 1524 | //TODO: implement this feature |
1525 | 1525 | } |
1526 | 1526 | |
1527 | - public function truncate () { |
|
1527 | + public function truncate() { |
|
1528 | 1528 | $this->db_driver->query("TRUNCATE `" . $this->table_name . "`; "); |
1529 | 1529 | } |
1530 | 1530 | |
1531 | 1531 | /** |
1532 | 1532 | * alias to truncate() |
1533 | 1533 | */ |
1534 | - public function cleanUp () { |
|
1534 | + public function cleanUp() { |
|
1535 | 1535 | $this->truncate(); |
1536 | 1536 | } |
1537 | 1537 | |
1538 | - public function check () { |
|
1538 | + public function check() { |
|
1539 | 1539 | //check table |
1540 | 1540 | return $this->db_driver->getRow("CHECK TABLE `{DBPRAEFIX}" . $this->table_name . "`; "); |
1541 | 1541 | } |
1542 | 1542 | |
1543 | - public function analyze () { |
|
1543 | + public function analyze() { |
|
1544 | 1544 | //check table |
1545 | 1545 | return $this->db_driver->getRow("ANALYZE TABLE `{DBPRAEFIX}" . $this->table_name . "`; "); |
1546 | 1546 | } |
1547 | 1547 | |
1548 | - public function optimize () { |
|
1548 | + public function optimize() { |
|
1549 | 1549 | //optimize table |
1550 | 1550 | return $this->db_driver->listRows("OPTIMIZE TABLE `{DBPRAEFIX}" . $this->table_name . "`; "); |
1551 | 1551 | } |
1552 | 1552 | |
1553 | - public function flush () { |
|
1553 | + public function flush() { |
|
1554 | 1554 | //flush table |
1555 | 1555 | $this->db_driver->query("FLUSH TABLE `{DBPRAEFIX}" . $this->table_name . "`; "); |
1556 | 1556 | } |
1557 | 1557 | |
1558 | - public function drop () { |
|
1558 | + public function drop() { |
|
1559 | 1559 | //drop table |
1560 | 1560 | $this->db_driver->query("DROP TABLE `{DBPRAEFIX}" . $this->table_name . "`; "); |
1561 | 1561 | } |
1562 | 1562 | |
1563 | - public function existsTable () : bool { |
|
1563 | + public function existsTable() : bool { |
|
1564 | 1564 | return count($this->db_driver->listRows("SHOW TABLES LIKE '{DBPRAEFIX}" . $this->table_name . "'; ")) > 0; |
1565 | 1565 | } |
1566 | 1566 | |
1567 | - public function escape (string $str) { |
|
1567 | + public function escape(string $str) { |
|
1568 | 1568 | return utf8_encode(htmlentities($str)); |
1569 | 1569 | } |
1570 | 1570 | |
1571 | - public static function listTables (DBDriver &$dbDriver) { |
|
1571 | + public static function listTables(DBDriver &$dbDriver) { |
|
1572 | 1572 | return $dbDriver->listRows("SHOW TABLES; "); |
1573 | 1573 | } |
1574 | 1574 | |
1575 | - public static function getTableStructure (string $table_name, DBDriver &$dbDriver) { |
|
1575 | + public static function getTableStructure(string $table_name, DBDriver &$dbDriver) { |
|
1576 | 1576 | //https://dev.mysql.com/doc/refman/5.5/en/creating-tables.html |
1577 | 1577 | return $dbDriver->listRows("DESCRIBE `{DBPRAEFIX}" . $table_name . "`; "); |
1578 | 1578 | } |
1579 | 1579 | |
1580 | - public static function getTableStructureByInformationSchema (string $table_name, DBDriver &$dbDriver) { |
|
1580 | + public static function getTableStructureByInformationSchema(string $table_name, DBDriver &$dbDriver) { |
|
1581 | 1581 | //https://makandracards.com/makandra/2531-show-the-character-set-and-the-collation-of-your-mysql-tables |
1582 | 1582 | |
1583 | 1583 | //http://stackoverflow.com/questions/8662906/getting-mysql-to-display-the-encoding-used-for-a-particular-column |
@@ -1588,7 +1588,7 @@ discard block |
||
1588 | 1588 | return $dbDriver->listRows("SELECT * FROM `information_schema`.`COLUMNS` WHERE `TABLE_SCHEMA` = '" . $dbDriver->getDatabaseName() . "' AND `TABLE_NAME` = `{DBPRAEFIX}" . $table_name . "`; ", array(), true); |
1589 | 1589 | } |
1590 | 1590 | |
1591 | - public static function listIndexes (string $table_name, DBDriver &$dbDriver) { |
|
1591 | + public static function listIndexes(string $table_name, DBDriver &$dbDriver) { |
|
1592 | 1592 | return $dbDriver->listRows("SHOW INDEX FROM `{DBPRAEFIX}" . $table_name . "`; "); |
1593 | 1593 | } |
1594 | 1594 |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | * @access public |
37 | 37 | * @var int |
38 | 38 | */ |
39 | - public $cache_expiry = 0; |
|
39 | + public $cache_expiry = 0; |
|
40 | 40 | |
41 | 41 | /** |
42 | 42 | * Cache file unique identifier |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | * @access public |
46 | 46 | * @var string |
47 | 47 | */ |
48 | - public $cache_unique = 'unique'; |
|
48 | + public $cache_unique = 'unique'; |
|
49 | 49 | |
50 | 50 | /** |
51 | 51 | * Filename extension |
@@ -54,7 +54,7 @@ discard block |
||
54 | 54 | * @access public |
55 | 55 | * @var string |
56 | 56 | */ |
57 | - public $cache_ext = '.xcache'; |
|
57 | + public $cache_ext = '.xcache'; |
|
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Path to cache dir |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @access public |
65 | 65 | * @var string |
66 | 66 | */ |
67 | - public $cache_dir = './xcache'; |
|
67 | + public $cache_dir = './xcache'; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Flag showing whether template is cached |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | * @access private |
73 | 73 | * @var boolean |
74 | 74 | */ |
75 | - private $_template_is_cached = false; |
|
75 | + private $_template_is_cached = false; |
|
76 | 76 | |
77 | 77 | /** |
78 | 78 | * Cache expiry time |
@@ -80,7 +80,7 @@ discard block |
||
80 | 80 | * @access private |
81 | 81 | * @var int |
82 | 82 | */ |
83 | - private $_cache_expiry = 0; |
|
83 | + private $_cache_expiry = 0; |
|
84 | 84 | |
85 | 85 | /** |
86 | 86 | * File modified time |
@@ -88,7 +88,7 @@ discard block |
||
88 | 88 | * @access private |
89 | 89 | * @var int |
90 | 90 | */ |
91 | - private $_cache_filemtime = 0; |
|
91 | + private $_cache_filemtime = 0; |
|
92 | 92 | |
93 | 93 | /** |
94 | 94 | * Override of parent constructor |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @param string $cache_dir Cache folder |
127 | 127 | * @param string $cache_ext Cache file extension |
128 | 128 | */ |
129 | - public function restart ($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true, $tag_start = '{', $tag_end = '}', $cache_expiry = 0, $cache_unique = '', $cache_dir = './xcache', $cache_ext = '.xcache') { |
|
129 | + public function restart($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true, $tag_start = '{', $tag_end = '}', $cache_expiry = 0, $cache_unique = '', $cache_dir = './xcache', $cache_ext = '.xcache') { |
|
130 | 130 | |
131 | 131 | if ($cache_expiry > 0) { |
132 | 132 | $this->cache_expiry = $cache_expiry; |
@@ -170,7 +170,7 @@ discard block |
||
170 | 170 | * @param string / array $val Value to assign to $name |
171 | 171 | * @param boolean $magic_quotes |
172 | 172 | */ |
173 | - public function assign ($name, $val = '', $magic_quotes = false) { |
|
173 | + public function assign($name, $val = '', $magic_quotes = false) { |
|
174 | 174 | |
175 | 175 | if (!$this->_template_is_cached) { |
176 | 176 | parent::assign($name, $val, $magic_quotes); |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | * @param string $name Variable to assign $val to |
185 | 185 | * @param string / array $val Values to assign to $name |
186 | 186 | */ |
187 | - public function assign_file ($name, $val = '') { |
|
187 | + public function assign_file($name, $val = '') { |
|
188 | 188 | |
189 | 189 | if (!$this->_template_is_cached) { |
190 | 190 | parent::assign_file($name, $val); |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | * @param string $bname Block name to parse |
199 | 199 | * @param int $cache_expiry Seconds to cache block for |
200 | 200 | */ |
201 | - public function parse ($bname, $cache_expiry = 0) { |
|
201 | + public function parse($bname, $cache_expiry = 0) { |
|
202 | 202 | |
203 | 203 | if (!$this->_template_is_cached) { |
204 | 204 | |
@@ -218,7 +218,7 @@ discard block |
||
218 | 218 | * @param string $bname Block name to return |
219 | 219 | * @return string |
220 | 220 | */ |
221 | - public function text ($bname = '') { |
|
221 | + public function text($bname = '') { |
|
222 | 222 | |
223 | 223 | $text = parent::text($bname); |
224 | 224 | |
@@ -252,7 +252,7 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @access protected |
254 | 254 | */ |
255 | - protected function read_template_cache () { |
|
255 | + protected function read_template_cache() { |
|
256 | 256 | |
257 | 257 | $filename = $this->_get_filename(); |
258 | 258 | |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @access protected |
284 | 284 | */ |
285 | - protected function write_template_cache () { |
|
285 | + protected function write_template_cache() { |
|
286 | 286 | |
287 | 287 | if ($this->cache_expiry > 0 && is_writable($this->cache_dir)) { |
288 | 288 | |
@@ -304,7 +304,7 @@ discard block |
||
304 | 304 | * @param ing $cache_expiry Seconds to cache block for |
305 | 305 | * @return boolean |
306 | 306 | */ |
307 | - protected function read_block_cache ($bname, $cache_expiry = 0) { |
|
307 | + protected function read_block_cache($bname, $cache_expiry = 0) { |
|
308 | 308 | |
309 | 309 | $retval = false; |
310 | 310 | |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | * @param string $bname Block name to cache |
345 | 345 | * @param int $cache_expiry Seconds to cache block for |
346 | 346 | */ |
347 | - protected function write_block_cache ($bname, $cache_expiry = 0) { |
|
347 | + protected function write_block_cache($bname, $cache_expiry = 0) { |
|
348 | 348 | |
349 | 349 | if ($cache_expiry > 0 && is_writable($this->cache_dir)) { |
350 | 350 | |
@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * @access private |
365 | 365 | * @return string |
366 | 366 | */ |
367 | - private function _get_filename () { |
|
367 | + private function _get_filename() { |
|
368 | 368 | |
369 | 369 | $filename = $this->filename; |
370 | 370 | if (!empty($this->tpldir)) { |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @param boolean $autosetup If true, run setup() as part of constuctor |
332 | 332 | * @return XTemplate |
333 | 333 | */ |
334 | - public function XTemplate ($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true) { |
|
334 | + public function XTemplate($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true) { |
|
335 | 335 | |
336 | 336 | assert('Deprecated - use PHP 5 constructor'); |
337 | 337 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | * @param string $tag_start { |
360 | 360 | * @param string $tag_end } |
361 | 361 | */ |
362 | - public function restart ($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true, $tag_start = '{', $tag_end = '}') { |
|
362 | + public function restart($file, $tpldir = '', $files = null, $mainblock = 'main', $autosetup = true, $tag_start = '{', $tag_end = '}') { |
|
363 | 363 | |
364 | 364 | $this->filename = $file; |
365 | 365 | |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | * @access public |
405 | 405 | * @param boolean $add_outer If true is passed when called, it adds an outer main block to the file |
406 | 406 | */ |
407 | - public function setup ($add_outer = false) { |
|
407 | + public function setup($add_outer = false) { |
|
408 | 408 | |
409 | 409 | $this->tag_start_delim = preg_quote($this->tag_start_delim); |
410 | 410 | $this->tag_end_delim = preg_quote($this->tag_end_delim); |
@@ -461,7 +461,7 @@ discard block |
||
461 | 461 | * @param string / array $val Value to assign to $name |
462 | 462 | * @param boolean $reset_array Reset the variable array if $val is an array |
463 | 463 | */ |
464 | - public function assign ($name, $val = '', $reset_array = true) { |
|
464 | + public function assign($name, $val = '', $reset_array = true) { |
|
465 | 465 | |
466 | 466 | if (is_array($name)) { |
467 | 467 | |
@@ -494,7 +494,7 @@ discard block |
||
494 | 494 | * @param string $name Variable to assign $val to |
495 | 495 | * @param string / array $val Values to assign to $name |
496 | 496 | */ |
497 | - public function assign_file ($name, $val = '') { |
|
497 | + public function assign_file($name, $val = '') { |
|
498 | 498 | |
499 | 499 | if (is_array($name)) { |
500 | 500 | |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | * @access public |
515 | 515 | * @param string $bname Block name to parse |
516 | 516 | */ |
517 | - public function parse ($bname) { |
|
517 | + public function parse($bname) { |
|
518 | 518 | |
519 | 519 | if (isset($this->preparsed_blocks[$bname])) { |
520 | 520 | |
@@ -550,7 +550,7 @@ discard block |
||
550 | 550 | $var_array = array(); |
551 | 551 | |
552 | 552 | /* find & replace variables+blocks */ |
553 | - preg_match_all("|" . $this->tag_start_delim . "([A-Za-z0-9\._]+?" . $this->comment_preg . ")" . $this->tag_end_delim. "|", $copy, $var_array); |
|
553 | + preg_match_all("|" . $this->tag_start_delim . "([A-Za-z0-9\._]+?" . $this->comment_preg . ")" . $this->tag_end_delim . "|", $copy, $var_array); |
|
554 | 554 | |
555 | 555 | $var_array = $var_array[1]; |
556 | 556 | |
@@ -700,7 +700,7 @@ discard block |
||
700 | 700 | * @access public |
701 | 701 | * @param string $bname Block name to parse |
702 | 702 | */ |
703 | - public function rparse ($bname) { |
|
703 | + public function rparse($bname) { |
|
704 | 704 | |
705 | 705 | if (!empty($this->sub_blocks[$bname])) { |
706 | 706 | |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | * @param string $var Variable to assign values to |
726 | 726 | * @param string / array $value Value to assign to $var |
727 | 727 | */ |
728 | - public function insert_loop ($bname, $var, $value = '') { |
|
728 | + public function insert_loop($bname, $var, $value = '') { |
|
729 | 729 | |
730 | 730 | $this->assign($var, $value); |
731 | 731 | $this->parse($bname); |
@@ -739,11 +739,11 @@ discard block |
||
739 | 739 | * @param string $var Variable to assign values to |
740 | 740 | * @param array $values Values to assign to $var |
741 | 741 | */ |
742 | - public function array_loop ($bname, $var, &$values) { |
|
742 | + public function array_loop($bname, $var, &$values) { |
|
743 | 743 | |
744 | 744 | if (is_array($values)) { |
745 | 745 | |
746 | - foreach($values as $v) { |
|
746 | + foreach ($values as $v) { |
|
747 | 747 | |
748 | 748 | $this->insert_loop($bname, $var, $v); |
749 | 749 | } |
@@ -757,7 +757,7 @@ discard block |
||
757 | 757 | * @param string $bname Block name to return |
758 | 758 | * @return string |
759 | 759 | */ |
760 | - public function text ($bname = '') { |
|
760 | + public function text($bname = '') { |
|
761 | 761 | |
762 | 762 | $text = ''; |
763 | 763 | |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | * @access public |
781 | 781 | * @param string $bname Block name to echo out |
782 | 782 | */ |
783 | - public function out ($bname) { |
|
783 | + public function out($bname) { |
|
784 | 784 | |
785 | 785 | $out = $this->text($bname); |
786 | 786 | // $length=strlen($out); |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | * @param string $bname Block name to write out |
797 | 797 | * @param string $fname File name to write to |
798 | 798 | */ |
799 | - public function out_file ($bname, $fname) { |
|
799 | + public function out_file($bname, $fname) { |
|
800 | 800 | |
801 | 801 | if (!empty($bname) && !empty($fname) && is_writeable($fname)) { |
802 | 802 | |
@@ -812,7 +812,7 @@ discard block |
||
812 | 812 | * @access public |
813 | 813 | * @param string $bname Block to reset |
814 | 814 | */ |
815 | - public function reset ($bname) { |
|
815 | + public function reset($bname) { |
|
816 | 816 | |
817 | 817 | $this->parsed_blocks[$bname] = ''; |
818 | 818 | } |
@@ -824,7 +824,7 @@ discard block |
||
824 | 824 | * @param string $bname Block name to test |
825 | 825 | * @return boolean |
826 | 826 | */ |
827 | - public function parsed ($bname) { |
|
827 | + public function parsed($bname) { |
|
828 | 828 | |
829 | 829 | return (!empty($this->parsed_blocks[$bname])); |
830 | 830 | } |
@@ -848,7 +848,7 @@ discard block |
||
848 | 848 | * @param string $varname |
849 | 849 | * @deprecated Change to set_null_string to keep in with rest of naming convention |
850 | 850 | */ |
851 | - public function SetNullString ($str, $varname = '') { |
|
851 | + public function SetNullString($str, $varname = '') { |
|
852 | 852 | $this->set_null_string($str, $varname); |
853 | 853 | } |
854 | 854 | |
@@ -859,7 +859,7 @@ discard block |
||
859 | 859 | * @param string $str Display string for null block |
860 | 860 | * @param string $bname Block name to apply $str to |
861 | 861 | */ |
862 | - public function set_null_block ($str, $bname = '') { |
|
862 | + public function set_null_block($str, $bname = '') { |
|
863 | 863 | |
864 | 864 | $this->_null_block[$bname] = $str; |
865 | 865 | } |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | * @param string $bname |
872 | 872 | * @deprecated Change to set_null_block to keep in with rest of naming convention |
873 | 873 | */ |
874 | - public function SetNullBlock ($str, $bname = '') { |
|
874 | + public function SetNullBlock($str, $bname = '') { |
|
875 | 875 | $this->set_null_block($str, $bname); |
876 | 876 | } |
877 | 877 | |
@@ -882,7 +882,7 @@ discard block |
||
882 | 882 | * |
883 | 883 | * @access public |
884 | 884 | */ |
885 | - public function set_autoreset () { |
|
885 | + public function set_autoreset() { |
|
886 | 886 | |
887 | 887 | $this->_autoreset = true; |
888 | 888 | } |
@@ -894,7 +894,7 @@ discard block |
||
894 | 894 | * |
895 | 895 | * @access public |
896 | 896 | */ |
897 | - public function clear_autoreset () { |
|
897 | + public function clear_autoreset() { |
|
898 | 898 | |
899 | 899 | $this->_autoreset = false; |
900 | 900 | } |
@@ -904,7 +904,7 @@ discard block |
||
904 | 904 | * |
905 | 905 | * @access public |
906 | 906 | */ |
907 | - public function scan_globals () { |
|
907 | + public function scan_globals() { |
|
908 | 908 | |
909 | 909 | reset($GLOBALS); |
910 | 910 | |
@@ -926,7 +926,7 @@ discard block |
||
926 | 926 | * @access public |
927 | 927 | * @return boolean / string |
928 | 928 | */ |
929 | - public function get_error () { |
|
929 | + public function get_error() { |
|
930 | 930 | |
931 | 931 | // JRC: 3/1/2003 Added ouptut wrapper and detection of output type for error message output |
932 | 932 | $retval = false; |
@@ -961,7 +961,7 @@ discard block |
||
961 | 961 | * @param string $con content to be processed |
962 | 962 | * @param string $parentblock name of the parent block in the block hierarchy |
963 | 963 | */ |
964 | - public function _maketree ($con, $parentblock='') { |
|
964 | + public function _maketree($con, $parentblock = '') { |
|
965 | 965 | |
966 | 966 | $blocks = array(); |
967 | 967 | |
@@ -982,7 +982,7 @@ discard block |
||
982 | 982 | //$patt = "($this->block_start_word|$this->block_end_word)\s*(\w+)\s*$this->block_end_delim(.*)"; |
983 | 983 | $patt = "(" . $this->block_start_word . "|" . $this->block_end_word . ")\s*(\w+)" . $this->comment_preg . "\s*" . $this->block_end_delim . "(.*)"; |
984 | 984 | |
985 | - foreach($con2 as $k => $v) { |
|
985 | + foreach ($con2 as $k => $v) { |
|
986 | 986 | |
987 | 987 | $res = array(); |
988 | 988 | |
@@ -1004,7 +1004,7 @@ discard block |
||
1004 | 1004 | $block_names[++$level] = $block_name; |
1005 | 1005 | |
1006 | 1006 | // make block name (main.table.row) |
1007 | - $cur_block_name=implode('.', $block_names); |
|
1007 | + $cur_block_name = implode('.', $block_names); |
|
1008 | 1008 | |
1009 | 1009 | // build block parsing order (reverse) |
1010 | 1010 | $this->block_parse_order[] = $cur_block_name; |
@@ -1055,7 +1055,7 @@ discard block |
||
1055 | 1055 | * @param string $name |
1056 | 1056 | * @param string $val |
1057 | 1057 | */ |
1058 | - private function _assign_file_sub ($name, $val) { |
|
1058 | + private function _assign_file_sub($name, $val) { |
|
1059 | 1059 | |
1060 | 1060 | if (isset($this->filevar_parent[$name])) { |
1061 | 1061 | |
@@ -1063,7 +1063,7 @@ discard block |
||
1063 | 1063 | |
1064 | 1064 | $val = $this->_r_getfile($val); |
1065 | 1065 | |
1066 | - foreach($this->filevar_parent[$name] as $parent) { |
|
1066 | + foreach ($this->filevar_parent[$name] as $parent) { |
|
1067 | 1067 | |
1068 | 1068 | if (isset($this->preparsed_blocks[$parent]) && !isset($this->filevars[$name])) { |
1069 | 1069 | |
@@ -1107,7 +1107,7 @@ discard block |
||
1107 | 1107 | * @param array $blocks |
1108 | 1108 | * @return array |
1109 | 1109 | */ |
1110 | - public function _store_filevar_parents ($blocks){ |
|
1110 | + public function _store_filevar_parents($blocks) { |
|
1111 | 1111 | |
1112 | 1112 | $parents = array(); |
1113 | 1113 | |
@@ -1131,7 +1131,7 @@ discard block |
||
1131 | 1131 | * @access private |
1132 | 1132 | * @param string $str |
1133 | 1133 | */ |
1134 | - private function _set_error ($str) { |
|
1134 | + private function _set_error($str) { |
|
1135 | 1135 | |
1136 | 1136 | // JRC: 3/1/2003 Made to append the error messages |
1137 | 1137 | $this->_error .= '* ' . $str . " *\n"; |
@@ -1146,7 +1146,7 @@ discard block |
||
1146 | 1146 | * @param string $file |
1147 | 1147 | * @return string |
1148 | 1148 | */ |
1149 | - protected function _getfile ($file) { |
|
1149 | + protected function _getfile($file) { |
|
1150 | 1150 | |
1151 | 1151 | if (!isset($file)) { |
1152 | 1152 | // JC 19/12/02 added $file to error message |
@@ -1186,7 +1186,7 @@ discard block |
||
1186 | 1186 | } |
1187 | 1187 | } else { |
1188 | 1188 | |
1189 | - $file = $this->tpldir. DIRECTORY_SEPARATOR . $file; |
|
1189 | + $file = $this->tpldir . DIRECTORY_SEPARATOR . $file; |
|
1190 | 1190 | } |
1191 | 1191 | } |
1192 | 1192 | |
@@ -1212,7 +1212,7 @@ discard block |
||
1212 | 1212 | return ''; |
1213 | 1213 | } |
1214 | 1214 | |
1215 | - $file_text .= fread($fh,filesize($file)); |
|
1215 | + $file_text .= fread($fh, filesize($file)); |
|
1216 | 1216 | fclose($fh); |
1217 | 1217 | |
1218 | 1218 | } |
@@ -1255,16 +1255,16 @@ discard block |
||
1255 | 1255 | * @param string $file |
1256 | 1256 | * @return string |
1257 | 1257 | */ |
1258 | - public function _r_getfile ($file) { |
|
1258 | + public function _r_getfile($file) { |
|
1259 | 1259 | |
1260 | 1260 | $text = $this->_getfile($file); |
1261 | 1261 | |
1262 | 1262 | $res = array(); |
1263 | 1263 | |
1264 | - while (preg_match($this->file_delim,$text,$res)) { |
|
1264 | + while (preg_match($this->file_delim, $text, $res)) { |
|
1265 | 1265 | |
1266 | 1266 | $text2 = $this->_getfile($res[1]); |
1267 | - $text = preg_replace("'".preg_quote($res[0])."'",$text2,$text); |
|
1267 | + $text = preg_replace("'" . preg_quote($res[0]) . "'", $text2, $text); |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | return $text; |
@@ -1276,7 +1276,7 @@ discard block |
||
1276 | 1276 | * |
1277 | 1277 | * @access private |
1278 | 1278 | */ |
1279 | - private function _add_outer_block () { |
|
1279 | + private function _add_outer_block() { |
|
1280 | 1280 | |
1281 | 1281 | $before = $this->block_start_delim . $this->block_start_word . ' ' . $this->mainblock . ' ' . $this->block_end_delim; |
1282 | 1282 | $after = $this->block_start_delim . $this->block_end_word . ' ' . $this->mainblock . ' ' . $this->block_end_delim; |
@@ -1290,7 +1290,7 @@ discard block |
||
1290 | 1290 | * @access private |
1291 | 1291 | * @param multiple var_dumps all the supplied arguments |
1292 | 1292 | */ |
1293 | - private function _pre_var_dump ($args) { |
|
1293 | + private function _pre_var_dump($args) { |
|
1294 | 1294 | |
1295 | 1295 | if ($this->debug) { |
1296 | 1296 | echo '<pre>'; |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | protected $template = null; |
22 | 22 | protected static $registeredTemplate = array(); |
23 | 23 | |
24 | - public function __construct ($file, Registry &$registry = null) { |
|
24 | + public function __construct($file, Registry &$registry = null) { |
|
25 | 25 | if ($registry == null) { |
26 | 26 | $registry = Registry::singleton(); |
27 | 27 | } |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | $this->template->assign("USERNAME", User::current()->getUsername()); |
72 | 72 | |
73 | 73 | $style_name = $registry->getSetting("current_style_name"); |
74 | - $this->template->assign("STYLE_PATH",DomainUtils::getBaseURL() . "/styles/" . $style_name . "/"); |
|
74 | + $this->template->assign("STYLE_PATH", DomainUtils::getBaseURL() . "/styles/" . $style_name . "/"); |
|
75 | 75 | |
76 | 76 | Events::throwEvent("init_template", array( |
77 | 77 | 'file' => &$file, |
@@ -82,36 +82,36 @@ discard block |
||
82 | 82 | |
83 | 83 | } |
84 | 84 | |
85 | - public function assign ($var, $value) { |
|
85 | + public function assign($var, $value) { |
|
86 | 86 | $this->template->assign($var, $value); |
87 | 87 | } |
88 | 88 | |
89 | - public function parse ($name = "main") { |
|
89 | + public function parse($name = "main") { |
|
90 | 90 | $this->template->parse($name); |
91 | 91 | } |
92 | 92 | |
93 | - public function getCode ($name = "main") { |
|
93 | + public function getCode($name = "main") { |
|
94 | 94 | return $this->template->text($name); |
95 | 95 | } |
96 | 96 | |
97 | - public static function registerTemplate ($template, $file) { |
|
97 | + public static function registerTemplate($template, $file) { |
|
98 | 98 | self::$registeredTemplate[$template] = $file; |
99 | 99 | } |
100 | 100 | |
101 | - public static function clearTemplates () { |
|
101 | + public static function clearTemplates() { |
|
102 | 102 | self::$registeredTemplate = array(); |
103 | 103 | } |
104 | 104 | |
105 | - public static function createTemplate ($file) { |
|
105 | + public static function createTemplate($file) { |
|
106 | 106 | $class = (String) __CLASS__; |
107 | 107 | return new $class($file); |
108 | 108 | } |
109 | 109 | |
110 | - public static function getName () { |
|
110 | + public static function getName() { |
|
111 | 111 | return __CLASS__; |
112 | 112 | } |
113 | 113 | |
114 | - public static function findTemplate (string $tpl_name, Registry &$registry) : string { |
|
114 | + public static function findTemplate(string $tpl_name, Registry &$registry) : string { |
|
115 | 115 | if (strpos($tpl_name, ".tpl") !== FALSE) { |
116 | 116 | //remove file extension |
117 | 117 | $tpl_name = str_replace(".tpl", "", $tpl_name); |