/** * Returns the link to the body (more-link) for the current entry (if there is a body). * * @param array $params * @param object $smarty * @return string */ function smarty_more($params, &$smarty) { global $PIVOTX; $params = cleanParams($params); $params['html'] = true; if (isset($smarty)) { $data = $smarty->get_template_vars(); } else { $data = $PIVOTX['db']->entry; } $output = makeMoreLink($data, '', $params); return $output; }
/** * Creates a feed of entries. * * @param string $feed_template * @param array $entries * @return string */ function _renderFeedEntries($feed_template, $entries) { global $PIVOTX; // Getting category display names $categories = $PIVOTX['categories']->getCategories(); $categories = makeValuepairs($categories, 'name', 'display'); // Loop through the entries.. foreach ($entries as $entry) { // Get the full entry.. $entry = $PIVOTX['db']->read_entry($entry['code']); $link = makeFileURL($entry['uid'], "", ""); $title = trim(unentify($entry['title'])); $subtitle = trim(unentify($entry['subtitle'])); // parse fields and remove scripting from the feed. Script in feed is bad.. $introduction = parse_intro_or_body($entry['introduction'], false, $entry['convert_lb']); $introduction = $this->_cleanFeedText($introduction); $body = parse_intro_or_body($entry['body'], false, $entry['convert_lb']); $body = $this->_cleanFeedText($body); $year = formatDate($entry['date'], "%year%"); $tag = safeString($PIVOTX['config']->get('sitename'), TRUE) . "," . $year . ":" . safeString($PIVOTX['weblogs']->get('', 'name'), TRUE) . "." . $entry['uid']; $tag = str_replace("_", "", strtolower($tag)); $date = formatDate($entry['date'], "%year%-%month%-%day%T%hour24%:%minute%:00") . $this->_rssOffset(); $date_rfc = formatDate($entry['date'], "%english_dname%, %day% %english_monname% %year% %hour24%:%minute%:00 ") . $this->_rssOffset("rfc822"); if ($PIVOTX['db']->entry['edit_date'] != "") { $edit_date = formatDate($entry['edit_date'], "%year%-%month%-%day%T%hour24%:%minute%:00") . $this->_rssOffset(); } else { // if the entry was never edited, use the entrydate $edit_date = $date; } $summary = unentify(strip_tags($introduction)); $summary = trim(str_replace("&", "&", str_replace(" ", " ", $summary))); // Set content (Atom 1.0) and description (RSS 2.0) according to completeness settings if ($PIVOTX['weblogs']->get('', 'rss_full') == 0) { // don't put anything in the content. $content = ""; $description = trim($introduction); if (strlen($body) > 5) { $description .= makeMoreLink($entry, '', array('html' => true)); $summary .= ' ...'; } } else { // put the introduction and body in the content.. $content = trim(str_replace(" ", " ", $introduction . $body)); $description = trim($introduction . $body); } // Handling viatitle special to avoid validation errors if (!empty($entry['viatitle'])) { $viatitle = 'title="' . addslashes($entry['viatitle']) . '"'; } else { $viatitle = ""; } // Getting user information.. $user = $PIVOTX['users']->getUser($entry['user']); if (!$user) { $user = array('username' => $entry['user'], 'email' => '', 'nickname' => $entry['user']); } // Setting the category display names $cat_display = array(); foreach ($entry['category'] as $cat) { if (!empty($categories[$cat])) { $cat_display[] = $categories[$cat]; } } $replace = array("%title%" => htmlspecialchars(strip_tags($title)), "%subtitle%" => htmlspecialchars(strip_tags($subtitle)), "%link%" => $link, "%description%" => relativeToAbsoluteURLS($description), "%summary%" => relativeToAbsoluteURLS($summary), "%author%" => $user['username'], "%author-email%" => $user['email'], "%author-nick%" => $user['nickname'], "%guid%" => $entry['uid'] . "@" . str_replace('http://', '', $PIVOTX['paths']['canonical_host']) . $PIVOTX['paths']['site_url'], "%date%" => $date, "%edit_date%" => $edit_date, "%date_rfc%" => $date_rfc, "%category%" => htmlspecialchars(implode(", ", $cat_display)), "%categorynames%" => htmlspecialchars(implode(", ", $entry['category'])), "%content%" => relativeToAbsoluteURLS($content), "%tag%" => $tag, "%lang%" => $PIVOTX['languages']->getCode(), "%vialink%" => $PIVOTX['db']->entry['vialink'], "%viatitle%" => $viatitle); // Execute the 'feed_entry' hook, if present. $PIVOTX['extensions']->executeHook('feed_entry', $replace); // Replace all items in $replace, unless it's an empty array. This way the feed_entry // hook can set $replace to an empty array, in order to skip it entirely. if (!empty($replace)) { $feed .= str_replace(array_keys($replace), array_values($replace), $feed_template); } } return $feed; }