@@ -32,7 +32,7 @@ discard block |
||
| 32 | 32 | // |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function load ($alias = null) { |
|
| 35 | + public function load($alias = null) { |
|
| 36 | 36 | if ($alias == null) { |
| 37 | 37 | if (isset($_REQUEST['page']) && !empty($_REQUEST['page'])) { |
| 38 | 38 | $alias = Validator_String::get($_REQUEST['page']); |
@@ -88,7 +88,7 @@ discard block |
||
| 88 | 88 | $this->pagetype = $this->row['page_type']; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | - public function loadByID (int $pageID, bool $use_cache = true) { |
|
| 91 | + public function loadByID(int $pageID, bool $use_cache = true) { |
|
| 92 | 92 | if ($use_cache && Cache::contains("pages", "pageID_" . $pageID)) { |
| 93 | 93 | $this->row = Cache::get("pages", "pageID_" . $pageID); |
| 94 | 94 | } else { |
@@ -111,135 +111,135 @@ discard block |
||
| 111 | 111 | $this->pagetype = $this->row['page_type']; |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | - protected function getDomain () : Domain { |
|
| 114 | + protected function getDomain() : Domain { |
|
| 115 | 115 | return Registry::singleton()->getObject("domain"); |
| 116 | 116 | } |
| 117 | 117 | |
| 118 | - public function reloadCache () { |
|
| 118 | + public function reloadCache() { |
|
| 119 | 119 | Cache::clear("pages"); |
| 120 | 120 | } |
| 121 | 121 | |
| 122 | - public function getPageID () : int { |
|
| 122 | + public function getPageID() : int { |
|
| 123 | 123 | return $this->row['id']; |
| 124 | 124 | } |
| 125 | 125 | |
| 126 | - public function getAlias () : string { |
|
| 126 | + public function getAlias() : string { |
|
| 127 | 127 | return $this->alias; |
| 128 | 128 | } |
| 129 | 129 | |
| 130 | - public function getPageType () : string { |
|
| 130 | + public function getPageType() : string { |
|
| 131 | 131 | return $this->pagetype; |
| 132 | 132 | } |
| 133 | 133 | |
| 134 | - public function getTitle () : string { |
|
| 134 | + public function getTitle() : string { |
|
| 135 | 135 | return $this->row['title']; |
| 136 | 136 | } |
| 137 | 137 | |
| 138 | - public function setTitle (string $title) { |
|
| 138 | + public function setTitle(string $title) { |
|
| 139 | 139 | $this->row['title'] = $title; |
| 140 | 140 | $this->changes[] = "title"; |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - public function getContent () : string { |
|
| 143 | + public function getContent() : string { |
|
| 144 | 144 | return $this->row['content']; |
| 145 | 145 | } |
| 146 | 146 | |
| 147 | - public function setContent (string $content) { |
|
| 147 | + public function setContent(string $content) { |
|
| 148 | 148 | $this->row['content'] = $content; |
| 149 | 149 | $this->changes[] = "content"; |
| 150 | 150 | $this->changes[] = "content"; |
| 151 | 151 | } |
| 152 | 152 | |
| 153 | - public function getGlobalMenuID () : int { |
|
| 153 | + public function getGlobalMenuID() : int { |
|
| 154 | 154 | return $this->row['global_menu']; |
| 155 | 155 | } |
| 156 | 156 | |
| 157 | - public function getLocalMenuID () : int { |
|
| 157 | + public function getLocalMenuID() : int { |
|
| 158 | 158 | return $this->row['local_menu']; |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - public function getStyle () : string { |
|
| 161 | + public function getStyle() : string { |
|
| 162 | 162 | return $this->row['design']; |
| 163 | 163 | } |
| 164 | 164 | |
| 165 | - public function getFolder () : string { |
|
| 165 | + public function getFolder() : string { |
|
| 166 | 166 | return $this->row['folder']; |
| 167 | 167 | } |
| 168 | 168 | |
| 169 | - public function getLastEdit () { |
|
| 169 | + public function getLastEdit() { |
|
| 170 | 170 | return $this->row['lastUpdate']; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - public function hasCustomTemplate () : bool { |
|
| 173 | + public function hasCustomTemplate() : bool { |
|
| 174 | 174 | return $this->row['template'] !== "none"; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | - public function getCustomTemplate () : string { |
|
| 177 | + public function getCustomTemplate() : string { |
|
| 178 | 178 | return $this->row['template']; |
| 179 | 179 | } |
| 180 | 180 | |
| 181 | - public function hasCustomPermissions () : bool { |
|
| 181 | + public function hasCustomPermissions() : bool { |
|
| 182 | 182 | return $this->row['can_see_permissions'] !== "none"; |
| 183 | 183 | } |
| 184 | 184 | |
| 185 | - public function listCustomPermissions () : array { |
|
| 185 | + public function listCustomPermissions() : array { |
|
| 186 | 186 | return explode("|", $this->row['can_see_permissions']); |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - public function isPublished () : bool { |
|
| 189 | + public function isPublished() : bool { |
|
| 190 | 190 | return $this->row['published'] == 1; |
| 191 | 191 | } |
| 192 | 192 | |
| 193 | - public function publish () { |
|
| 193 | + public function publish() { |
|
| 194 | 194 | $this->row['published'] = 1; |
| 195 | 195 | $this->changes[] = "published"; |
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - public function getContentType () : string { |
|
| 198 | + public function getContentType() : string { |
|
| 199 | 199 | return $this->row['content_type']; |
| 200 | 200 | } |
| 201 | 201 | |
| 202 | - public function getParentID () : int { |
|
| 202 | + public function getParentID() : int { |
|
| 203 | 203 | return $this->row['parent']; |
| 204 | 204 | } |
| 205 | 205 | |
| 206 | - public function getLeftSidebarID () : int { |
|
| 206 | + public function getLeftSidebarID() : int { |
|
| 207 | 207 | return $this->row['sidebar_left']; |
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - public function getRightSidebarID () : int { |
|
| 210 | + public function getRightSidebarID() : int { |
|
| 211 | 211 | return $this->row['sidebar_right']; |
| 212 | 212 | } |
| 213 | 213 | |
| 214 | - public function getMetaDescription () : string { |
|
| 214 | + public function getMetaDescription() : string { |
|
| 215 | 215 | return $this->row['meta_description']; |
| 216 | 216 | } |
| 217 | 217 | |
| 218 | - public function getMetaKeywords () : string { |
|
| 218 | + public function getMetaKeywords() : string { |
|
| 219 | 219 | return $this->row['meta_keywords']; |
| 220 | 220 | } |
| 221 | 221 | |
| 222 | - public function getMetaRobotsOptions () : string { |
|
| 222 | + public function getMetaRobotsOptions() : string { |
|
| 223 | 223 | return $this->row['meta_robots']; |
| 224 | 224 | } |
| 225 | 225 | |
| 226 | - public function getMetaCanonicals () : string { |
|
| 226 | + public function getMetaCanonicals() : string { |
|
| 227 | 227 | return $this->row['meta_canonicals']; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - public function getOgType () : string { |
|
| 230 | + public function getOgType() : string { |
|
| 231 | 231 | return $this->row['og_type']; |
| 232 | 232 | } |
| 233 | 233 | |
| 234 | - public function getOgTitle () : string { |
|
| 234 | + public function getOgTitle() : string { |
|
| 235 | 235 | return !empty($this->row['og_title']) ? $this->row['og_title'] : $this->getTitle(); |
| 236 | 236 | } |
| 237 | 237 | |
| 238 | - public function getOgDescription () : string { |
|
| 238 | + public function getOgDescription() : string { |
|
| 239 | 239 | return !empty($this->row['og_description']) ? $this->row['og_description'] : $this->getMetaDescription(); |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | - public function getOgImages () : array { |
|
| 242 | + public function getOgImages() : array { |
|
| 243 | 243 | if (empty($this->row['og_image'])) { |
| 244 | 244 | return array(); |
| 245 | 245 | } |
@@ -247,11 +247,11 @@ discard block |
||
| 247 | 247 | return explode(",", $this->row['og_image']); |
| 248 | 248 | } |
| 249 | 249 | |
| 250 | - public function getAuthorID () : int { |
|
| 250 | + public function getAuthorID() : int { |
|
| 251 | 251 | return $this->row['author']; |
| 252 | 252 | } |
| 253 | 253 | |
| 254 | - public function getAuthor () : User { |
|
| 254 | + public function getAuthor() : User { |
|
| 255 | 255 | if ($this->author == null) { |
| 256 | 256 | //load author |
| 257 | 257 | $this->author = new User(); |
@@ -266,31 +266,31 @@ discard block |
||
| 266 | 266 | return $this->author; |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - public function isSitemapEnabled () : bool { |
|
| 269 | + public function isSitemapEnabled() : bool { |
|
| 270 | 270 | return $this->row['sitemap'] == 1; |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - public function activate (bool $bool = true) { |
|
| 273 | + public function activate(bool $bool = true) { |
|
| 274 | 274 | $this->row['activated'] = ($bool ? 1 : 0); |
| 275 | 275 | } |
| 276 | 276 | |
| 277 | - public function isTrash () : bool { |
|
| 277 | + public function isTrash() : bool { |
|
| 278 | 278 | return $this->row['activated'] == 2; |
| 279 | 279 | } |
| 280 | 280 | |
| 281 | - public function isEditable () : bool { |
|
| 281 | + public function isEditable() : bool { |
|
| 282 | 282 | return $this->row['editable'] == 1; |
| 283 | 283 | } |
| 284 | 284 | |
| 285 | - public function isDeletable () : bool { |
|
| 285 | + public function isDeletable() : bool { |
|
| 286 | 286 | return $this->row['deletable'] == 1; |
| 287 | 287 | } |
| 288 | 288 | |
| 289 | - public function isActivated () : bool { |
|
| 289 | + public function isActivated() : bool { |
|
| 290 | 290 | return $this->row['activated'] == 1; |
| 291 | 291 | } |
| 292 | 292 | |
| 293 | - public function moveToTrash () { |
|
| 293 | + public function moveToTrash() { |
|
| 294 | 294 | self::movePageToTrash($this->pageID); |
| 295 | 295 | |
| 296 | 296 | //clear cache |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | /** |
| 301 | 301 | * restore page from trash |
| 302 | 302 | */ |
| 303 | - public function restore () { |
|
| 303 | + public function restore() { |
|
| 304 | 304 | self::restorePage($this->pageID); |
| 305 | 305 | |
| 306 | 306 | //clear cache |
@@ -310,11 +310,11 @@ discard block |
||
| 310 | 310 | /** |
| 311 | 311 | * save changes into database |
| 312 | 312 | */ |
| 313 | - public function save () { |
|
| 313 | + public function save() { |
|
| 314 | 314 | //TODO: add code here |
| 315 | 315 | } |
| 316 | 316 | |
| 317 | - public function clearCache () { |
|
| 317 | + public function clearCache() { |
|
| 318 | 318 | if (!is_int($this->getPageID())) { |
| 319 | 319 | throw new IllegalStateException("pageID isn't set."); |
| 320 | 320 | } |
@@ -324,7 +324,7 @@ discard block |
||
| 324 | 324 | Cache::clear("pages", "page_" . $this->getAlias()); |
| 325 | 325 | } |
| 326 | 326 | |
| 327 | - public static function createIfAbsent (string $alias, string $title, string $page_type, string $content = "", string $folder = "/", int $globalMenu = -1, int $localMenu = -1, int $parentID = -1, bool $sitemap = true, bool $published = true, bool $editable = true, bool $deletable = true, string $author = "system") : int { |
|
| 327 | + public static function createIfAbsent(string $alias, string $title, string $page_type, string $content = "", string $folder = "/", int $globalMenu = -1, int $localMenu = -1, int $parentID = -1, bool $sitemap = true, bool $published = true, bool $editable = true, bool $deletable = true, string $author = "system") : int { |
|
| 328 | 328 | //throw event |
| 329 | 329 | Events::throwEvent("create_page", array( |
| 330 | 330 | 'alias' => &$alias, |
@@ -394,7 +394,7 @@ discard block |
||
| 394 | 394 | return $pageID; |
| 395 | 395 | } |
| 396 | 396 | |
| 397 | - public static function delete (string $alias) { |
|
| 397 | + public static function delete(string $alias) { |
|
| 398 | 398 | $delete = true; |
| 399 | 399 | |
| 400 | 400 | //plugins can avoid deletion or change alias |
@@ -411,7 +411,7 @@ discard block |
||
| 411 | 411 | } |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - public static function deleteByID (int $id) { |
|
| 414 | + public static function deleteByID(int $id) { |
|
| 415 | 415 | $delete = true; |
| 416 | 416 | |
| 417 | 417 | //plugins can avoid deletion or change alias |
@@ -428,14 +428,14 @@ discard block |
||
| 428 | 428 | } |
| 429 | 429 | } |
| 430 | 430 | |
| 431 | - public static function get (string $alias) : Page { |
|
| 431 | + public static function get(string $alias) : Page { |
|
| 432 | 432 | $page = new Page(); |
| 433 | 433 | $page->load($alias); |
| 434 | 434 | |
| 435 | 435 | return $page; |
| 436 | 436 | } |
| 437 | 437 | |
| 438 | - public static function setPageType (string $alias, string $page_type) { |
|
| 438 | + public static function setPageType(string $alias, string $page_type) { |
|
| 439 | 439 | Events::throwEvent("set_pagetype", array( |
| 440 | 440 | 'alias' => &$alias, |
| 441 | 441 | 'page_type' => &$page_type |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | * |
| 461 | 461 | * @return int pageID |
| 462 | 462 | */ |
| 463 | - public static function getPageIDByAlias (string $alias) : int { |
|
| 463 | + public static function getPageIDByAlias(string $alias) : int { |
|
| 464 | 464 | $row = Database::getInstance()->getRow("SELECT * FROM `{praefix}pages` WHERE `alias` = :alias; ", array('alias' => $alias)); |
| 465 | 465 | |
| 466 | 466 | if (!$row) { |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | return $row['id']; |
| 471 | 471 | } |
| 472 | 472 | |
| 473 | - public static function lockPage (int $pageID, int $userID) { |
|
| 473 | + public static function lockPage(int $pageID, int $userID) { |
|
| 474 | 474 | Database::getInstance()->execute("UPDATE `{praefix}pages` SET `locked_by` = :userID, `locked_timestamp` = CURRENT_TIMESTAMP WHERE `id` = :pageID; ", array( |
| 475 | 475 | 'userID' => $userID, |
| 476 | 476 | 'pageID' => $pageID |
@@ -480,7 +480,7 @@ discard block |
||
| 480 | 480 | Cache::clear("pages", "pageID_" . $pageID); |
| 481 | 481 | } |
| 482 | 482 | |
| 483 | - public static function unlockPage (int $pageID) { |
|
| 483 | + public static function unlockPage(int $pageID) { |
|
| 484 | 484 | Database::getInstance()->execute("UPDATE `{praefix}pages` SET `locked_by` = '-1' WHERE `id` = :pageID; ", array( |
| 485 | 485 | 'pageID' => $pageID |
| 486 | 486 | )); |
@@ -489,7 +489,7 @@ discard block |
||
| 489 | 489 | Cache::clear("pages", "pageID_" . $pageID); |
| 490 | 490 | } |
| 491 | 491 | |
| 492 | - protected static function movePageToTrash (int $pageID) { |
|
| 492 | + protected static function movePageToTrash(int $pageID) { |
|
| 493 | 493 | Database::getInstance()->execute("UPDATE `{praefix}pages` SET `activated` = 2 WHERE `id` = :pageID; ", array( |
| 494 | 494 | 'pageID' => $pageID |
| 495 | 495 | )); |
@@ -498,7 +498,7 @@ discard block |
||
| 498 | 498 | Cache::clear("pages", "pageID_" . $pageID); |
| 499 | 499 | } |
| 500 | 500 | |
| 501 | - protected static function restorePage (int $pageID) { |
|
| 501 | + protected static function restorePage(int $pageID) { |
|
| 502 | 502 | Database::getInstance()->execute("UPDATE `{praefix}pages` SET `activated` = 1 WHERE `id` = :pageID; ", array( |
| 503 | 503 | 'pageID' => $pageID |
| 504 | 504 | )); |
@@ -507,7 +507,7 @@ discard block |
||
| 507 | 507 | Cache::clear("pages", "pageID_" . $pageID); |
| 508 | 508 | } |
| 509 | 509 | |
| 510 | - public static function exists (string $alias) : bool { |
|
| 510 | + public static function exists(string $alias) : bool { |
|
| 511 | 511 | $row = Database::getInstance()->getRow("SELECT * FROM `{praefix}pages` WHERE `alias` = :alias; ", array( |
| 512 | 512 | 'alias' => $alias |
| 513 | 513 | )); |