/** * Get a specific post. * * @todo Fix links (use functions). Add user check? * * @param string $postid * @return array */ function pivotx_get_post($postid) { global $PIVOTX, $body_separator; $post = $PIVOTX['db']->read_entry($postid); list($yr, $mo, $da, $ho, $mi) = explode("-", $post['date']); $unixtime = mktime($ho, $mi, 0, $mo, $da, $yr); $isoString = iso8601_encode($unixtime); $content = $post['introduction']; if (!empty($post['body'])) { $content = $content . "\n" . $body_separator . "\n" . $post['body']; } $result = array('dateCreated' => new xmlrpcval($isoString, "dateTime.iso8601"), 'userid' => $post['user'], 'postid' => $post['code'], 'content' => $content, 'title' => $post['title'], 'description' => $post['introduction'], 'link' => makeFileURL($post['code'], '', ''), 'permaLink' => makeFileURL($post['code'], '', ''), 'categories' => $post['category']); return $result; }
/** * Creates a feed of comments. * * @todo Do not display comments that haven't been moderated/approved. * @param string $feed_template * @param array $comment * @return string */ function _renderFeedComments($feed_template, $amount = 10, $comments) { global $PIVOTX; $i = 0; $feed_items = ""; // Loop through the comments.. foreach ($comments as $comment) { $tag = safeString($PIVOTX['config']->get('sitename'), TRUE) . "," . date("Y") . ":" . safeString($PIVOTX['weblogs']->get('', 'name'), TRUE); $tag .= '.entry%uid%.comment' . $i; $tag = str_replace("_", "", strtolower($tag)); $date = formatDate($comment['date'], "%year%-%month%-%day%T%hour24%:%minute%:00") . $this->_rssOffset(); $date_rfc = formatDate($comment['date'], "%english_dname%, %day% %english_monname% %year% %hour24%:%minute%:00 ") . $this->_rssOffset("rfc822"); $summary = unentify(strip_tags($comment['comment'])); $summary = trim(str_replace("&", "&", str_replace(" ", " ", $summary))); $summary = relativeToAbsoluteURLS($summary); if (strlen($summary) > 32) { $title = substr($summary, 0, 35) . '...'; } else { $title = $summary; } // Make the link.. $id = makeURI(html_entity_decode($comment['name'], ENT_COMPAT, 'UTF-8')) . "-" . formatDate($comment['date'], "%ye%%month%%day%%hour24%%minute%"); $url = makeFileURL($comment['entry_uid'], '', $id); $replace = array("%title%" => htmlspecialchars(strip_tags($title)), "%link%" => $url, "%summary%" => $summary, "%content%" => $summary, "%description%" => $summary, "%author%" => $comment['name'], "%guid%" => $url, "%date%" => $date, "%date_rfc%" => $date_rfc, "%tag%" => $tag, "%lang%" => smarty_lang()); // Execute the 'feed_comment' hook, if present. $PIVOTX['extensions']->executeHook('feed_comment', $replace); // Replace all items in $replace, unless it's an empty array. This way the feed_comment // hook can set $replace to an empty array, in order to skip it entirely. if (!empty($replace)) { $item = str_replace(array_keys($replace), array_values($replace), $feed_template); // Handling email and url separately. if (isEmail($comment['email'])) { $item = str_replace('%author-email%', $comment['email'], $item); } else { $item = str_replace('<email>%author-email%</email>', '', $item); } if (isUrl($comment['url'])) { if (strpos($comment["url"], "ttp://") < 1) { $comment["url"] = "http://" . $comment["url"]; } $item = str_replace('%author-link%', $comment['url'], $item); } else { $item = str_replace('<uri>%author-link%</uri>', '', $item); } $feed_items .= $item; } } return $feed_items; }