|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* @package Cadmium\System\Modules\Page |
|
5
|
|
|
* @author Anton Romanov |
|
6
|
|
|
* @copyright Copyright (c) 2015-2017, Anton Romanov |
|
7
|
|
|
* @link http://cadmium-cms.com |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Modules { |
|
11
|
|
|
|
|
12
|
|
|
use Frames, Utils\SEO, Utils\View, Template; |
|
13
|
|
|
|
|
14
|
|
|
class Page extends Frames\Site\Area\Common { |
|
15
|
|
|
|
|
16
|
|
|
private $page = null, $path = []; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Get the contents block |
|
20
|
|
|
*/ |
|
21
|
|
|
|
|
22
|
|
|
private function getContents() : Template\Block { |
|
23
|
|
|
|
|
24
|
|
|
$contents = View::get('Blocks/Page'); |
|
25
|
|
|
|
|
26
|
|
|
# Set breadcrumbs |
|
27
|
|
|
|
|
28
|
|
|
if (count($this->path) <= 1) $contents->getBlock('breadcrumbs')->disable(); |
|
29
|
|
|
|
|
30
|
|
|
else $contents->getBlock('breadcrumbs')->path = $this->path; |
|
|
|
|
|
|
31
|
|
|
|
|
32
|
|
|
# Set contents |
|
33
|
|
|
|
|
34
|
|
|
$contents->contents = Template::createBlock($this->page->contents); |
|
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
# ------------------------ |
|
37
|
|
|
|
|
38
|
|
|
return $contents; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
/** |
|
42
|
|
|
* Handle the request |
|
43
|
|
|
* |
|
44
|
|
|
* @return Template\Block|false : a block object on success or false if a page was not found |
|
45
|
|
|
*/ |
|
46
|
|
|
|
|
47
|
|
|
protected function handle() { |
|
48
|
|
|
|
|
49
|
|
|
# Get page entity |
|
50
|
|
|
|
|
51
|
|
|
$this->page = Entitizer::get(TABLE_PAGES); |
|
52
|
|
|
|
|
53
|
|
|
# Init page by requested url |
|
54
|
|
|
|
|
55
|
|
|
$slug = $this->_url->getSlug(); |
|
56
|
|
|
|
|
57
|
|
|
if ('' !== $slug) $this->page->initBySlug($slug); else $this->page->init(1); |
|
|
|
|
|
|
58
|
|
|
|
|
59
|
|
|
# Display error if not found |
|
60
|
|
|
|
|
61
|
|
|
if (0 === $this->page->id) return false; |
|
|
|
|
|
|
62
|
|
|
|
|
63
|
|
|
# Get path |
|
64
|
|
|
|
|
65
|
|
|
if (false !== ($path = $this->page->getPath())) $this->path = $path; |
|
66
|
|
|
|
|
67
|
|
|
# Set data |
|
68
|
|
|
|
|
69
|
|
|
if ($this->page->id !== 1) SEO::set('title', $this->page->title); else $this->_layout = 'Index'; |
|
|
|
|
|
|
70
|
|
|
|
|
71
|
|
|
SEO::set('description', $this->page->description); |
|
|
|
|
|
|
72
|
|
|
SEO::set('keywords', $this->page->keywords); |
|
|
|
|
|
|
73
|
|
|
SEO::set('robots_index', $this->page->robots_index); |
|
|
|
|
|
|
74
|
|
|
SEO::set('robots_follow', $this->page->robots_follow); |
|
|
|
|
|
|
75
|
|
|
SEO::set('canonical', $this->page->canonical); |
|
|
|
|
|
|
76
|
|
|
|
|
77
|
|
|
# ------------------------ |
|
78
|
|
|
|
|
79
|
|
|
return $this->getContents(); |
|
80
|
|
|
} |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|
Since your code implements the magic setter
_set, this function will be called for any write access on an undefined variable. You can add the@propertyannotation to your class or interface to document the existence of this variable.Since the property has write access only, you can use the @property-write annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.