Daan is sweet to Kelley and delegates himself TestCMS code reflection
[ssproject1617.git] / testcms-final-anon / system / functions / articles.php
1 <?php defined('IN_CMS') or die('No direct access allowed.');
2
3 /**
4 Theme functions for articles
5 */
6 function article_id() {
7 if($itm = IoC::resolve('article')) {
8 return $itm->id;
9 }
10
11 return '';
12 }
13
14 function article_title() {
15 if($itm = IoC::resolve('article')) {
16 return $itm->title;
17 }
18
19 return '';
20 }
21
22 function article_slug() {
23 if($itm = IoC::resolve('article')) {
24 return $itm->slug;
25 }
26
27 return '';
28 }
29
30 function article_url() {
31 if($itm = IoC::resolve('article')) {
32 $page = IoC::resolve('posts_page');
33 return Url::make($page->slug . '/' . $itm->slug);
34 }
35
36 return '';
37 }
38
39 function article_description() {
40 if($itm = IoC::resolve('article')) {
41 return $itm->description;
42 }
43
44 return '';
45 }
46
47 function article_html() {
48 if($itm = IoC::resolve('article')) {
49 return $itm->html;
50 }
51
52 return '';
53 }
54
55 function article_css() {
56 if($itm = IoC::resolve('article')) {
57 return $itm->css;
58 }
59
60 return '';
61 }
62
63 function article_js() {
64 if($itm = IoC::resolve('article')) {
65 return $itm->js;
66 }
67
68 return '';
69 }
70
71 function article_time() {
72 if($itm = IoC::resolve('article')) {
73 return $itm->created;
74 }
75
76 return '';
77 }
78
79 function article_date() {
80 if(article_time() !== '') {
81 return date(Config::get('metadata.date_format'), article_time());
82 }
83
84 return '';
85 }
86
87 function article_status() {
88 if($itm = IoC::resolve('article')) {
89 return $itm->status;
90 }
91
92 return '';
93 }
94
95 function article_total_comments() {
96 if($itm = IoC::resolve('article')) {
97 return $itm->total_comments;
98 }
99
100 return 0;
101 }
102
103 function article_author() {
104 if($itm = IoC::resolve('article')) {
105 return $itm->author;
106 }
107
108 return '';
109 }
110
111 function article_author_bio() {
112 if($itm = IoC::resolve('article')) {
113 return $itm->bio;
114 }
115
116 return '';
117 }
118
119 function article_custom_fields() {
120 if($itm = IoC::resolve('article')) {
121 if(isset($itm->custom_fields)) {
122 // get associative array
123 $data = json_decode($itm->custom_fields, true);
124 return is_array($data) ? $data : array();
125 }
126 }
127
128 return array();
129 }
130
131 function article_custom_field($key, $default = '') {
132 $fields = article_custom_fields();
133 return isset($fields[$key]) ? $fields[$key]['value'] : $default;
134 }
135
136 function customised() {
137 if($itm = IoC::resolve('article')) {
138 return strlen($itm->css) > 0 or strlen($itm->js) > 0;
139 }
140
141 return false;
142 }