Esempio n. 1
0
 public function templateData()
 {
     $uAuthor = ObjectCache::getByType('\\Kiki\\User', $this->userId);
     $data = array('id' => $this->id, 'url' => $this->url(), 'ctime' => strtotime($this->ctime), 'relTime' => Misc::relativeTime($this->ctime), 'title' => $this->title(), 'body' => $this->body, 'author' => $uAuthor->name(), 'publications' => array(), 'likes' => $this->likes(), 'comments' => Comments::count($this->objectId), 'html' => array('comments' => Comments::show($this->objectId)));
     $publications = $this->publications();
     foreach ($publications as $publication) {
         $data['publications'][] = $publication->templateData();
     }
     return $data;
 }
Esempio n. 2
0
    private function show($comments)
    {
        global $CFG;
        if ($comments) {
            echo '<ul>';
            foreach ($comments as $comment) {
                $elapsed = time() + Settings::mysqlTimeDiff() * 3600 - strtotime($comment['date']);
                if ($elapsed < 60) {
                    $time_ago = $CFG->comments_less_than_minute;
                } elseif ($elapsed > 60 && $elapsed < 60 * 60) {
                    $minutes = floor($elapsed / 60);
                    $time_ago = str_ireplace('[field]', $minutes, $CFG->comments_minutes_ago);
                } elseif ($elapsed > 60 * 60 && $elapsed < 60 * 60 * 24) {
                    $hours = floor($elapsed / 60 / 60);
                    $time_ago = str_ireplace('[field]', $hours, $CFG->comments_hours_ago);
                } elseif ($elapsed > 60 * 60 * 24 && $elapsed < 60 * 60 * 24 * 30.4) {
                    $days = floor($elapsed / 60 / 60 / 24);
                    $time_ago = str_ireplace('[field]', $days, $CFG->comments_days_ago);
                } else {
                    $months = floor($elapsed / 60 / 60 / 24 / 30.4);
                    $time_ago = str_ireplace('[field]', $months, $CFG->comments_months_ago);
                }
                if ($comment['user_id'] > 0) {
                    $user = DB::getRecord($this->user_table, $comment['user_id'], false, true);
                    $name = !empty($comment['website']) ? Link::url($comment['website'], $user['user']) : $user['user'];
                } else {
                    $name = !empty($comment['website']) ? Link::url($comment['website'], $comment['name']) : $comment['name'];
                }
                $short = $this->short_version ? '_short' : '';
                $icon = $comment['type'] ? eval('return $CFG->comment_type_' . $comment['type'] . ';') : $CFG->comment_type_1;
                $action = $comment['type'] ? eval('return $CFG->comments_action_' . $comment['type'] . $short . ';') : $CFG->comments_wrote_label;
                $action = String::doFormulaReplacements($action, unserialize($comment['f_table_row']), 1, 1);
                echo '
				<li id="comment_' . $comment['id'] . '" class="level_' . $comment['type'] . '">
					<div class="c_head">';
                if ($this->fields) {
                    foreach ($this->fields as $f_name => $field) {
                        $CFG->o_method_id = $field['method_id'];
                        $CFG->o_method_name = 'field';
                        $record = new Record($field['table'], $comment['record_id']);
                        echo '<div class="added_field">' . $record->field($field['name'], $field['caption'], $field['subtable'], $field['subtable_fields'], $field['link_url'], $field['concat_char'], true, $field['f_id_field'], $field['order_by'], $field['order_asc'], $comment['record_id'], $field['link_is_tab'], $field['limit_is_curdate'], false, $field['link_id_field']) . '</div>';
                    }
                }
                echo '
						' . $icon . ' ' . $name . ' (' . $time_ago . ') ' . $action . '
					</div>';
                if (!$this->short_version) {
                    echo '
						<div class="c_comment">
							' . (strlen($comment['comments']) != strlen(strip_tags($comment['comments'])) ? $comment['comments'] : nl2br($comment['comments'])) . '
						</div>';
                }
                echo '
					' . ($comment['type'] <= 1 && !$this->short_version ? '<div class="c_reply"><a href="#" onclick="showReplyBox(' . $comment['id'] . ',' . $this->i . ');return false;">' . $CFG->comments_reply_label . '</a></div>' : '') . '
					<div class="c_form"></div>
				</li>';
                if (is_array($comment['children'])) {
                    Comments::show($comment['children']);
                }
            }
            echo '<div style="clear:both;height:0;"></div></ul>';
        }
    }
Esempio n. 3
0
	/**
	 * class constructor
	 */
	public static function __static() {
		if (isset($_GET['open']) and is_array($_GET['open'])) self::$open = $_GET['open'];
		if (isset($_GET['show']) and is_array($_GET['show'])) self::$show = $_GET['show'];
		if (isset($_GET['parent'])) self::$parent = $_GET['parent'];
	}
Esempio n. 4
0
// require_once "../lib/init.php";
use Kiki\Comment;
if ($_POST) {
    $errors = array();
    list($dummy, $objectId, $last) = explode("_", $_POST['last']);
    if (!$user->id()) {
        $errors[] = "Je bent niet ingelogd.";
    }
    if (!($body = $_POST['comment'])) {
        $errors[] = "Je kunt geen leeg berichtje opslaan!";
    }
    if (!count($errors)) {
        $comment = new Comment();
        $comment->setInReplyToId($objectId);
        $comment->setUserId($user->id());
        $comment->setBody($body);
        $comment->setIpAddr($_SERVER['REMOTE_ADDR']);
        $comment->save();
    }
    if ($_POST['json']) {
        $response = array();
        $response['formId'] = $_POST['formId'];
        $response['objectId'] = $objectId;
        $response['comments'] = Comments::show($objectId, $last);
        $response['errors'] = $errors;
        header('Content-type: application/json');
        echo json_encode($response);
        exit;
    }
    Router::redirect($_SERVER['HTTP_REFERER'], 303);
}
Esempio n. 5
0
 public function templateData()
 {
     $uAuthor = ObjectCache::getByType('\\Kiki\\User', $this->userId);
     $prevArticle = $this->getPrev();
     $nextArticle = $this->getNext();
     $data = array('id' => $this->id, 'url' => $this->url(), 'ctime' => strtotime($this->ctime), 'relTime' => Misc::relativeTime($this->ctime), 'title' => $this->title, 'body' => $this->body, 'author' => $uAuthor->name(), 'images' => array(), 'publications' => array(), 'likes' => $this->likes(), 'comments' => Comments::count($this->objectId), 'html' => array('comments' => Comments::show($this->objectId), 'editform' => $this->form(true, 'articles')));
     if ($nextArticle = $this->getNext()) {
         $data['next'] = array('id' => $nextArticle->id(), 'url' => $nextArticle->url(), 'title' => $nextArticle->title());
     }
     if ($prevArticle = $this->getPrev()) {
         $data['prev'] = array('id' => $prevArticle->id(), 'url' => $prevArticle->url(), 'title' => $prevArticle->title());
     }
     $publications = $this->publications();
     foreach ($publications as $publication) {
         $data['publications'][] = $publication->templateData();
     }
     $images = $this->images();
     foreach ($images as $image) {
         $data['images'][] = Storage::url($image);
     }
     // print_r( $data['images'] );
     return $data;
 }