1 <?php
2
3 4 5 6 7
8 class rex_article extends rex_structure_element
9 {
10 11 12 13 14
15 public static function getCurrentId()
16 {
17 return rex_addon::get('structure')->getProperty('article_id', 1);
18 }
19
20 21 22 23 24 25 26
27 public static function getCurrent($clang = null)
28 {
29 return self::get(self::getCurrentId(), $clang);
30 }
31
32 33 34 35 36
37 public static function getSiteStartArticleId()
38 {
39 return rex_addon::get('structure')->getProperty('start_article_id', 1);
40 }
41
42 43 44 45 46 47 48
49 public static function getSiteStartArticle($clang = null)
50 {
51 return self::get(self::getSiteStartArticleId(), $clang);
52 }
53
54 55 56 57 58
59 public static function getNotfoundArticleId()
60 {
61 return rex_addon::get('structure')->getProperty('notfound_article_id', 1);
62 }
63
64 65 66 67 68 69 70
71 public static function getNotfoundArticle($clang = null)
72 {
73 return self::get(self::getNotfoundArticleId(), $clang);
74 }
75
76 77 78 79 80 81 82 83
84 public static function getRootArticles($ignoreOfflines = false, $clang = null)
85 {
86 return self::getChildElements(0, 'alist', $ignoreOfflines, $clang);
87 }
88
89 90 91 92 93
94 public function getCategoryId()
95 {
96 return $this->isStartArticle() ? $this->getId() : $this->getParentId();
97 }
98
99 100 101 102 103
104 public function getCategory()
105 {
106 return rex_category::get($this->getCategoryId(), $this->getClang());
107 }
108
109 110 111 112 113
114 public function getParent()
115 {
116 return self::get($this->parent_id, $this->clang_id);
117 }
118
119 120 121 122 123
124 public function getPath()
125 {
126 if ($this->isStartArticle()) {
127 return $this->path . $this->id . '|';
128 }
129
130 return $this->path;
131 }
132
133 134 135
136 public function getValue($value)
137 {
138 if ('category_id' === $value) {
139
140
141 return $this->getCategoryId();
142 }
143 return parent::getValue($value);
144 }
145
146 147 148 149 150
151 public static function hasValue($value)
152 {
153 return parent::_hasValue($value, ['art_']);
154 }
155
156 157 158
159 public function isPermitted()
160 {
161 return (bool) rex_extension::registerPoint(new rex_extension_point('ART_IS_PERMITTED', true, ['element' => $this]));
162 }
163 }
164