1 <?php
2
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
20 class rex_var_article extends rex_var
21 {
22 23 24
25 protected function getOutput()
26 {
27 $id = $this->getParsedArg('id', 0, true);
28 $clang = $this->getParsedArg('clang', 'null');
29 $ctype = $this->getParsedArg('ctype', -1);
30 $field = $this->getParsedArg('field');
31
32 $noId = $id == 0;
33 if ($noId) {
34 $id = '$this->getValue(\'id\')';
35 }
36
37 if ($field) {
38 return self::class . '::getArticleValue(' . $id . ', ' . $field . ', ' . $clang . ')';
39 }
40 if (!$noId || !in_array($this->getContext(), ['module', 'action'])) {
41
42
43 if ($noId && $clang == 'null') {
44 return '$this->getArticle(' . $ctype . ')';
45 }
46 return self::class . '::getArticle(' . $id . ', ' . $ctype . ', ' . $clang . ')';
47 }
48
49 return false;
50 }
51
52 public static function getArticleValue($id, $field, $clang = null)
53 {
54 if ($clang === null) {
55 $clang = rex_clang::getCurrentId();
56 }
57 $article = rex_article::get($id, $clang);
58 return rex_escape($article->getValue($field));
59 }
60
61 public static function getArticle($id, $ctype = -1, $clang = null)
62 {
63 if ($clang === null) {
64 $clang = rex_clang::getCurrentId();
65 }
66 $article = new rex_article_content($id, $clang);
67 return $article->getArticle($ctype);
68 }
69 }
70