1 <?php
defined('IN_CMS') or die('No direct access allowed.');
4 Theme functions for comments
7 function has_comments() {
8 if(($itm = IoC
::resolve('article')) === false) {
12 if(($items = IoC
::resolve('comments')) === false) {
13 $items = Comments
::list_all(array('status' => 'published', 'post' => $itm->id
));
14 IoC
::instance('comments', $items, true);
17 return $items->length() > 0;
20 function total_comments() {
21 if(has_comments() === false) {
25 $items = IoC
::resolve('comments');
26 return $items->length();
31 if(has_comments() === false) {
35 $items = IoC
::resolve('comments');
37 if($result = $items->valid()) {
38 // register single comment
39 IoC
::instance('comment', $items->current(), true);
49 function comment_id() {
50 if($itm = IoC
::resolve('comment')) {
57 function comment_time() {
58 if($itm = IoC
::resolve('comment')) {
65 function comment_date() {
66 if($itm = IoC
::resolve('comment')) {
67 return date(Config
::get('metadata.date_format'), $itm->date
);
73 function comment_name() {
74 if($itm = IoC
::resolve('comment')) {
81 function comment_text() {
82 if($itm = IoC
::resolve('comment')) {
89 function comments_open() {
90 if($itm = IoC
::resolve('article')) {
91 return $itm->comments ?
true : false;
98 function comment_form_notifications() {
99 return Notifications
::read();
102 function comment_form_input_name($extra = '') {
103 return '<input name="name" id="name" type="text" ' . $extra . '>';
106 function comment_form_input_email($extra = '') {
107 return '<input name="email" id="email" type="email" ' . $extra . '>';
110 function comment_form_input_text($extra = '') {
111 return '<textarea name="text" id="text" ' . $extra . '></textarea>';
114 function comment_form_button($text = 'Post Comment', $extra = '') {
115 return '<button class="btn" type="submit" ' . $extra . '>' . $text . '</button>';