function displayUserList() { global $serendipity; $userlist = serendipity_fetchUsers(); $content = ""; foreach ($userlist as $user) { if (function_exists('serendipity_authorURL')) { $entryLink = serendipity_authorURL($user); } else { $entryLink = serendipity_rewriteURL(PATH_AUTHORS . '/' . serendipity_makePermalink(PERM_AUTHORS, array('id' => $user['authorid'], 'title' => $user['realname']))); } $content .= sprintf("<a href=\"%s\" title=\"%s\">%s</a><br />\n", $entryLink, function_exists('serendipity_specialchars') ? serendipity_specialchars($user['realname']) : htmlspecialchars($user['realname'], ENT_COMPAT, LANG_CHARSET), function_exists('serendipity_specialchars') ? serendipity_specialchars($user['realname']) : htmlspecialchars($user['realname'], ENT_COMPAT, LANG_CHARSET)); } return $content; }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $authors_query = "SELECT realname, username, authorid FROM {$serendipity['dbPrefix']}authors"; $row_authors = serendipity_db_query($authors_query); echo '<ul class="plainList">'; foreach ($row_authors as $entry) { if (function_exists('serendipity_authorURL')) { $entryLink = serendipity_authorURL($entry); } else { $entryLink = serendipity_rewriteURL(PATH_AUTHORS . '/' . serendipity_makePermalink(PERM_AUTHORS, array('id' => $entry['authorid'], 'title' => $entry['realname']))); } echo '<li><a href="' . $entryLink . '">' . $entry['realname'] . '</a></li>'; } echo '</ul>'; }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title'); $icon = serendipity_getTemplateFile($this->get_config('iconURL', 'img/xml.gif')); $custom_feed = trim($this->get_config('feed_name')); $custom_comm = trim($this->get_config('comment_name')); $custom_img = trim($this->get_config('big_img')); if (empty($custom_feed) || $custom_feed == 'default' || $custom_feed == 'none' || $custom_feed == 'empty') { $FEED = 'feed'; } else { $FEED = $custom_feed; } if (empty($custom_comm) || $custom_comm == 'default' || $custom_comm == 'none' || $custom_comm == 'empty') { $COMMENTS = COMMENTS; } else { $COMMENTS = $custom_comm; } if (!empty($custom_img) && $custom_img != 'default' && $custom_img != 'none' && $custom_img != 'empty') { ?> <div style="padding-bottom: 2px;"> <a class="serendipity_xml_icon" href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/index.rss2', 'serendipityHTTPPath'); ?> "><img src="<?php echo $custom_img; ?> " alt="XML" style="border: 0px" /></a> </div> <?php } ?> <ul class="plainList"><?php if (serendipity_db_bool($this->get_config('show_0.91', true))) { ?> <li> <a class="serendipity_xml_icon" href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/index.rss', 'serendipityHTTPPath'); ?> "><img src="<?php echo $icon; ?> " alt="XML" style="border: 0px" /></a> <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/index.rss', 'serendipityHTTPPath'); ?> ">RSS 0.91 <?php echo $FEED; ?> </a> </li> <?php } if (serendipity_db_bool($this->get_config('show_1.0', true))) { ?> <li> <a class="serendipity_xml_icon" href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/index.rss1', 'serendipityHTTPPath'); ?> "><img src="<?php echo $icon; ?> " alt="XML" style="border: 0px" /></a> <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/index.rss1', 'serendipityHTTPPath'); ?> ">RSS 1.0 <?php echo $FEED; ?> </a> </li> <?php } if (serendipity_db_bool($this->get_config('show_2.0', true))) { ?> <li> <a class="serendipity_xml_icon" href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/index.rss2', 'serendipityHTTPPath'); ?> "><img src="<?php echo $icon; ?> " alt="XML" style="border: 0px" /></a> <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/index.rss2', 'serendipityHTTPPath'); ?> ">RSS 2.0 <?php echo $FEED; ?> </a> </li> <?php } if (serendipity_db_bool($this->get_config('show_atom0.3', true))) { ?> <li> <a class="serendipity_xml_icon" href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/atom03.xml', 'serendipityHTTPPath'); ?> "><img src="<?php echo $icon; ?> " alt="ATOM/XML" style="border: 0px" /></a> <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/atom03.xml', 'serendipityHTTPPath'); ?> ">ATOM 0.3 <?php echo $FEED; ?> </a> </li> <?php } if (serendipity_db_bool($this->get_config('show_atom1.0', true))) { ?> <li> <a class="serendipity_xml_icon" href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/atom10.xml', 'serendipityHTTPPath'); ?> "><img src="<?php echo $icon; ?> " alt="ATOM/XML" style="border: 0px" /></a> <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/atom10.xml', 'serendipityHTTPPath'); ?> ">ATOM 1.0 <?php echo $FEED; ?> </a> </li> <?php } if (serendipity_db_bool($this->get_config('show_2.0c', true))) { ?> <li> <a class="serendipity_xml_icon" href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/comments.rss2', 'serendipityHTTPPath'); ?> "><img src="<?php echo $icon; ?> " alt="XML" style="border: 0px" /></a> <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/comments.rss2', 'serendipityHTTPPath'); ?> "><span style="white-space: nowrap">RSS 2.0 <?php echo $COMMENTS; ?> </span></a> </li> <?php } if (serendipity_db_bool($this->get_config('show_opml1.0', false))) { ?> <li> <a class="serendipity_xml_icon" href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/opml.xml', 'serendipityHTTPPath'); ?> "><img src="<?php echo $icon; ?> " alt="XML" style="border: 0px" /></a> <a href="<?php echo serendipity_rewriteURL(PATH_FEEDS . '/opml.xml', 'serendipityHTTPPath'); ?> ">OPML 1.0 <?php echo $FEED; ?> </a> </li> <?php } if (serendipity_db_bool($this->get_config('show_googlereader', false))) { ?> <li class="serendipity_googlereader"> <a href="http://fusion.google.com/add?source=atgs&feedurl=<?php echo urlencode(rtrim($serendipity['baseURL'], '/') . serendipity_rewriteURL(PATH_FEEDS . '/index.rss2', 'serendipityHTTPPath')); ?> "><img src="http://buttons.googlesyndication.com/fusion/add.gif" border="0" alt="Add to Google"></a> </li> <?php } if (serendipity_db_bool($this->get_config('show_feedburner', false)) || $this->get_config('show_feedburner', false) === 'force') { $alt = $this->get_config('fb_alt'); $fbid = $this->get_config('fb_id'); if (stristr($fbid, 'http://')) { $url = $fbid; } else { $url = 'http://feeds.feedburner.com/' . $fbid; } $img = $this->get_config('fb_img'); if (strlen($img) == 0) { $img = 'http://feeds.feedburner.com/~fc/' . $this->get_config('fb_id') . '?bg=99CCFF&fg=444444&anim=0'; } ?> <li> <a href="<?php echo $url; ?> "<?php if (strlen($alt) > 0) { echo " title=\"{$alt}\""; } ?> ><img src="<?php echo $img; ?> " alt="" style="border:0"/></a> <?php $mytitle = $this->get_config('fb_title'); if (strlen($mytitle) > 0) { ?> <a href="<?php echo $url; ?> "><?php echo $mytitle; ?> </a> <?php } ?> </li> <?php } echo '</ul>'; }
/** * Create a permalink for an archive date * * @access public * @param string The archive's date * @param boolean If true, only summary archive * @param string The base URL/path key * @return string The permalink */ function serendipity_archiveDateUrl($range, $summary = false, $key = 'baseURL') { return serendipity_rewriteURL(PATH_ARCHIVES . '/' . $range . ($summary ? '/summary' : '') . '.html', $key); }
/** * Smarty Function: Get the URL to the archives-path * * @access public * @return string The archive-path */ function getArchiveURL() { global $serendipity; return serendipity_rewriteURL(PATH_ARCHIVES); }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $ts = mktime(0, 0, 0, date('m'), 1); $add_query = ''; $category_set = isset($serendipity['GET']['category']); if ($category_set) { $base_query = 'C' . (int) $serendipity['GET']['category']; $add_query = '/' . $base_query; } $max_x = $this->get_config('count', 3); $show_count = serendipity_db_bool($this->get_config('show_count', false)); $hide_zero_count = serendipity_db_bool($this->get_config('hide_zero_count', false)); $freq = $this->get_config('frequency', 'months'); echo '<ul class="plainList">' . "\n"; if ($serendipity['dbType'] == 'sqlite' || $serendipity['dbType'] == 'sqlite3' || $serendipity['dbType'] == 'sqlite3oo') { $dist_sql = 'count(e.id) AS orderkey'; } else { $dist_sql = 'count(DISTINCT e.id) AS orderkey'; } for ($x = 0; $x < $max_x; $x++) { $current_ts = $ts; switch ($freq) { case 'months': switch ($serendipity['calendar']) { default: case 'gregorian': $linkStamp = date('Y/m', $ts); $ts_title = serendipity_formatTime("%B %Y", $ts, false); $ts = mktime(0, 0, 0, date('m', $ts) - 1, 1, date('Y', $ts)); // Must be last in 'case' statement break; case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; $linkStamp = persian_date_utf('Y/m', $ts); $ts_title = serendipity_formatTime("%B %Y", $ts, false); $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts) - 1, 1, persian_date_utf('Y', $ts)); // Must be last in 'case' statement break; } break; case 'weeks': switch ($serendipity['calendar']) { default: case 'gregorian': $linkStamp = date('Y/\\WW', $ts); $ts_title = WEEK . ' ' . date('W, Y', $ts); $ts = mktime(0, 0, 0, date('m', $ts), date('d', $ts) - 7, date('Y', $ts)); break; case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; $linkStamp = persian_date_utf('Y/\\WW', $ts); $ts_title = WEEK . ' ' . persian_date_utf('W، Y', $ts); $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts), persian_date_utf('d', $ts) - 7, persian_date_utf('Y', $ts)); break; } break; case 'days': switch ($serendipity['calendar']) { default: case 'gregorian': $linkStamp = date('Y/m/d', $ts); $ts_title = serendipity_formatTime("%B %e. %Y", $ts, false); $ts = mktime(0, 0, 0, date('m', $ts), date('d', $ts) - 1, date('Y', $ts)); // Must be last in 'case' statement break; case 'persian-utf8': require_once S9Y_INCLUDE_PATH . 'include/functions_calendars.inc.php'; $linkStamp = persian_date_utf('Y/m/d', $ts); $ts_title = serendipity_formatTime("%e %B %Y", $ts, false); $ts = persian_mktime(0, 0, 0, persian_date_utf('m', $ts), persian_date_utf('d', $ts) - 1, persian_date_utf('Y', $ts)); // Must be last in 'case' statement break; } break; } $link = serendipity_rewriteURL(PATH_ARCHIVES . '/' . $linkStamp . $add_query . '.html', 'serendipityHTTPPath'); $html_count = ''; $hidden_by_zero_count = false; if ($show_count) { switch ($freq) { case 'months': $end_ts = $current_ts + date('t', $current_ts) * 24 * 60 * 60 - 1; break; case 'weeks': $end_ts = $current_ts + 7 * 24 * 60 * 60 - 1; break; case 'days': $end_ts = $current_ts + 24 * 60 * 60 - 1; break; } $ec = serendipity_fetchEntries(array($current_ts, $end_ts), false, '', false, false, null, '', false, true, $dist_sql, '', 'single', false, $category_set); if (is_array($ec)) { if (empty($ec['orderkey'])) { $ec['orderkey'] = '0'; } $hidden_by_zero_count = $hide_zero_count && $ec['orderkey'] == '0'; $html_count .= ' (' . $ec['orderkey'] . ')'; } } if (!$hidden_by_zero_count) { echo '<li><a href="' . $link . '" title="' . $ts_title . '">' . $ts_title . $html_count . '</a></li>' . "\n"; } } echo '<li><a href="' . $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?frontpage">' . RECENT . '</a></li>' . "\n"; echo '<li><a href="' . serendipity_rewriteURL(PATH_ARCHIVE . $add_query) . '">' . OLDER . '</a></li>' . "\n"; echo '</ul>' . "\n"; }
/** * The meat of the plugin, called for each registered hook. * @param string event The name of the hook being called * @param mixed bag An array of configuration options for this plugin * @param mixed eventData An array containing parameters for the hook * @param mixed addData Additional hook data, if any * @return true */ function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; $hooks =& $bag->get('event_hooks'); if (isset($hooks[$event])) { // Update the database on first run if changed. $ver = $this->get_config('dbversion', 0); if ($ver != CATEGORYTEMPLATE_DB_VERSION) { $this->checkScheme($ver); } switch ($event) { // When changing category options, display the new extended // options, such as template, future entries, limit, and order case 'backend_category_showForm': // The $eventData is the category ID $clang = $this->fetchLang($eventData, ''); $cfuture = $this->fetchFuture($eventData, ''); $styles = serendipity_fetchTemplates(); $template = $this->fetchTemplate($eventData, ''); $hide_rss = serendipity_db_query("SELECT hide_rss FROM {$serendipity['dbPrefix']}categorytemplates AS t WHERE t.categoryid = {$eventData}", true); if ($hide_rss !== false) { $hide_rss = serendipity_db_bool($hide_rss['hide_rss']); } ?> <tr> <td valign="top"><label for="template"><?php echo SELECT_TEMPLATE; ?> </label></td> <td><input class="input_textbox" id="template" type="text" name="serendipity[cat][template]" value="<?php echo $template; ?> " /><br /> - <?php echo WORD_OR; ?> -<br /> <select name="serendipity[cat][drop_template]"> <option value=""><?php echo NONE; ?> </option> <?php foreach ($styles as $style => $path) { $templateInfo = serendipity_fetchTemplateInfo($style); ?> <option value="<?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($style) : htmlspecialchars($style, ENT_COMPAT, LANG_CHARSET); ?> " <?php echo $style == $template ? 'selected="selected"' : ''; ?> ><?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($templateInfo['name']) : htmlspecialchars($templateInfo['name'], ENT_COMPAT, LANG_CHARSET); ?> </option> <?php } ?> </select> <?php if (!empty($template)) { ?> <br /><br /><a class="serendipityPrettyButton" href="serendipity_admin.php?serendipity[adminModule]=event_display&serendipity[adminAction]=cattemplate&serendipity[catid]=<?php echo $eventData; ?> &serendipity[cat_template]=<?php echo urlencode($template); ?> "><?php echo STYLE_OPTIONS; ?> </a> <?php } ?> </td> </tr> <tr> <td colspan="2"><em><?php echo PLUGIN_CATEGORYTEMPLATES_SELECT; ?> </em></td> </tr> <!-- TODO: This does not work easily. <tr> <td><label for="language"><?php echo INSTALL_LANG; ?> </label></td> <td><select id="language" name="serendipity[cat][lang]"> <option value="default"><?php echo USE_DEFAULT; ?> </option> <?php foreach ($serendipity['languages'] as $langkey => $lang) { ?> <option value="<?php echo $lang; ?> " <?php echo $langkey == $clang ? 'selected="selected"' : ''; ?> ><?php echo function_exists('serendipity_specialchars') ? serendipity_specialchars($lang) : htmlspecialchars($lang, ENT_COMPAT, LANG_CHARSET); ?> </option> <?php } ?> </select></td> </tr> --> <tr> <td><?php echo INSTALL_SHOWFUTURE; ?> </td> <td> <input class="input_radio" type="radio" id ="futureentries_default" name="serendipity[cat][futureentries]" value="0" <?php echo empty($cfuture) || $cfuture == 0 ? 'checked="checked"' : ''; ?> /><label for="futureentries_default"><?php echo USE_DEFAULT; ?> </label><br /> <input class="input_radio" type="radio" id ="futureentries_no" name="serendipity[cat][futureentries]" value="1" <?php echo $cfuture == 1 ? 'checked="checked"' : ''; ?> /><label for="futureentries_no"><?php echo NO; ?> </label><br /> <input class="input_radio" type="radio" id ="futureentries_yes" name="serendipity[cat][futureentries]" value="2" <?php echo $cfuture == 2 ? 'checked="checked"' : ''; ?> /><label for="futureentries_yes"><?php echo YES; ?> </label> </td> </tr> <tr> <td><label for="fetchlimit"><?php echo PLUGIN_CATEGORYTEMPLATES_FETCHLIMIT; ?> </label></td> <td><input class="input_textbox" id="fetchlimit" type="text" name="serendipity[cat][fetchlimit]" value="<?php echo $this->fetchLimit($eventData, ''); ?> " /></td> </tr> <tr> <td><label for="sort_order"><?php echo SORT_ORDER; ?> </label></td> <td><input class="input_textbox" id="sort_order" type="text" name="serendipity[cat][sort_order]" value="<?php echo $this->fetchSortOrder($eventData, $this->get_config('sort_order')); ?> " /></td> </tr> <tr> <td><label for="hide_rss"><?php echo PLUGIN_CATEGORYTEMPLATES_HIDERSS; ?> </label></td> <td> <input class="input_radio" type="radio" id="hiderss_no" name="serendipity[cat][hide_rss]" value="0" <?php echo $hide_rss ? '' : 'checked="checked"'; ?> /><label for="hiderss_no"><?php echo NO; ?> </label><br /> <input class="input_radio" type="radio" id="hiderss_yes" name="serendipity[cat][hide_rss]" value="1" <?php echo $hide_rss ? 'checked="checked"' : ''; ?> /><label for="hiderss_yes"><?php echo YES; ?> </label><br /> </td> </tr> <?php if (serendipity_db_bool($this->get_config('pass'))) { ?> <tr> <td><label for="pass"><?php echo PLUGIN_CATEGORYTEMPLATES_PASS; ?> </label></td> <td><input class="input_textbox" id="pass" type="text" name="serendipity[cat][pass]" value="<?php echo $this->fetchProp($eventData, 'pass'); ?> " /></td> </tr> <?php } return true; break; // When a category is deleted, delete its custom properties // When a category is deleted, delete its custom properties case 'backend_category_delete': // $eventData is the category ID. This just deletes. $this->setProps($eventData, null, true); // Remove it from the list of template categories, too. $cidstr = $this->get_config('cat_precedence', false); // No need to modify config if no config set, or if no // templates are templatized if ($cidstr) { $cids = explode(',', $cidstr); // Why doesn't PHP have an array_remove(item)? if (in_array($eventData, $cids)) { $newcids = array(); foreach ($cids as $cid) { if ($cid != $eventData) { $newcids[] = $cid; } } $cidstr = implode(',', $newcids); $this->set_config('cat_precedence', $cidstr); } } break; // When a category is updated or added, modify its properties // When a category is updated or added, modify its properties case 'backend_category_update': case 'backend_category_addNew': $orig_tpl = $this->fetchTemplate($eventData, ''); $text_tpl = $serendipity['POST']['cat']['template']; $drop_tpl = $serendipity['POST']['cat']['drop_template']; // Default no change to template $set_tpl = $orig_tpl; // If text template changed, it takes precedence if ($text_tpl != $orig_tpl) { // (even when invalid; no checking) $set_tpl = $text_tpl; } else { if ($drop_tpl != $orig_tpl) { $set_tpl = $drop_tpl; } } $val = array('fetchlimit' => (int) $serendipity['POST']['cat']['fetchlimit'], 'template' => $set_tpl, 'categoryid' => (int) $eventData, 'lang' => $serendipity['POST']['cat']['lang'], 'futureentries' => (int) $serendipity['POST']['cat']['futureentries'], 'pass' => $serendipity['POST']['cat']['pass'], 'sort_order' => serendipity_db_escape_string($serendipity['POST']['cat']['sort_order']), 'hide_rss' => $serendipity['POST']['cat']['hide_rss']); $this->setProps($eventData, $val); // Update list of template categories, too. // // Get the list of customized category IDs, in precedence order $cidstr = $this->get_config('cat_precedence', false); // Only save the new precedence if we can actually // manually change templatized categories precedence if ($cidstr !== false) { if ($cidstr) { // If $cidstr is empty, this returns an array // with an empty string $cids = explode(',', $cidstr); } else { // For instance, set but empty $cids = array(); } // If it had a custom template just added, append it // to the list (user can change precedence later) if (!in_array($eventData, $cids) && !empty($set_tpl)) { $cids[] = $eventData; $cidstr = implode(',', $cids); $this->set_config('cat_precedence', $cidstr); } // If it had a custom template just deleted, remove it // from the list if (in_array($eventData, $cids) && empty($set_tpl)) { // Why doesn't PHP have an array_remove(item)? $newcids = array(); foreach ($cids as $cid) { if ($cid != $eventData) { $newcids[] = $cid; } } $cidstr = implode(',', $newcids); $this->set_config('cat_precedence', $cidstr); } } break; // When an entry or category is displayed, this changes the // CSS to the custom template // When an entry or category is displayed, this changes the // CSS to the custom template case 'external_plugin': $parts = explode('_', $eventData); if (!empty($parts[1])) { $param = (int) $parts[1]; } else { $param = null; } // Shouldn't this just be a string comparison? $methods = array('categorytemplate'); if (!in_array($parts[0], $methods)) { return; } $cid = (int) $parts[1]; $serendipity['template'] = $this->fetchTemplate($cid, $serendipity['template']); $css_mode = 'serendipity.css'; include_once S9Y_INCLUDE_PATH . 'serendipity.css.php'; exit; break; // When Serendipity tries to get the entries, check for // passwords // When Serendipity tries to get the entries, check for // passwords case 'frontend_fetchentries': case 'frontend_fetchentry': // Override sort order if (!empty($this->sort_order)) { $eventData['orderby'] = $this->sort_order . (!empty($eventData['orderby']) ? ',' : '') . $eventData['orderby'] . '/*categorytemplate*/'; } // Password not required on search or calendar, and we // don't do rss for them, either if (!isset($addData['source']) || ($addData['source'] == 'search' || $addData['source'] == 'calendar')) { return true; } // Password and RSS not required for installation if (defined('IN_installer') && IN_installer === true && defined('IN_upgrader') && IN_upgrader === true) { return true; } // Prepare to modify SQL $joins = array(); $conds = array(); $addkeys = array(); // Password protection SQL if (serendipity_db_bool($this->get_config('pass'))) { $conds[] = "(ctpass.pass IS NULL OR ctpass.pass = '******' OR ctpass.pass = '')"; $joins[] = "LEFT OUTER JOIN {$serendipity['dbPrefix']}categorytemplates ctpass\n ON (ec.categoryid = ctpass.categoryid)"; } // RSS hiding SQL if ($serendipity['view'] == 'feed') { $conds[] = "(e.id NOT IN (SELECT e.id FROM {$serendipity['dbPrefix']}entries AS e\n LEFT JOIN {$serendipity['dbPrefix']}entrycat AS ec ON ec.entryid = e.id\n JOIN {$serendipity['dbPrefix']}categorytemplates AS t ON ec.categoryid = t.categoryid AND hide_rss = '1'))"; /* $q = serendipity_db_query("SELECT categoryid FROM {$serendipity['dbPrefix']}categorytemplates WHERE hide_rss = 1"); if (is_array($q)) { $hidecats = array(); foreach($q as $hidden) { $hidecats[] = $hidden['categoryid']; } $hidecats = implode(';', $hidecats); } if (!empty($hidecats)) { $hide_sql = serendipity_getMultiCategoriesSQL($hidecats, true); $conds[] = $hide_sql; } */ /* $addkeys[] = "SUM(ctpass.hide_rss) as cat_hide_rss, "; // Reuse password join if possible if (count($joins) == 0) { $joins[] = "LEFT OUTER JOIN {$serendipity['dbPrefix']}categorytemplates AS ctpass ON (ec.categoryid = ctpass.categoryid)\n"; } //$conds[] = "(cat_hide_rss IS NULL OR cat_hide_rss < 1)"; //$conds[] = "(ctpass.hide_rss IS NULL OR ctpass.hide_rss = 0)"; //$conds[] = "(SUM(ctpass.hide_rss < 1))"; $havings[] = '(cat_hide_rss IS NULL OR cat_hide_rss < 1)'; */ } // Apply query additions // Select keys if (count($addkeys) > 0) { $cond = implode("\n", $addkeys); if (empty($eventData['select'])) { $eventData['addkey'] = $cond; } else { $eventData['addkey'] .= $cond; } } // Conditions if (count($conds) > 0) { $cond = implode(' AND ', $conds); if (empty($eventData['and'])) { $eventData['and'] = " WHERE {$cond} "; } else { $eventData['and'] .= " AND {$cond} "; } } // Joins if (count($joins) > 0) { $cond = implode("\n", $joins); if (empty($eventData['joins'])) { $eventData['joins'] = $cond; } else { $eventData['joins'] .= $cond; } } // Havings if (count($havings) > 0) { $cond = implode(' AND ', $havings); if (empty($eventData['having'])) { $eventData['having'] = "HAVING {$cond} "; } else { $eventData['having'] .= " AND {$cond} "; } } return true; break; // Experimental code: fetch language for entry // Experimental code: fetch language for entry case 'frontend_configure': // TODO: This does not work. The ID is not present! :-() // $cid = $this->getID(true); // $serendipity['lang'] = $this->fetchLang($cid, $serendipity['lang']); return true; break; // When the HTML is generated, apply properties // When the HTML is generated, apply properties case 'genpage': // Get the category in question $cid = $this->getID(); $fc = $this->get_config('fixcat'); if ((string) $fc === 'hard') { $fc = 'true'; } if ($cid != 'default' && serendipity_db_bool($fc)) { // Need this for category_name to be set. (?) $serendipity['GET']['category'] = $cid; header('X-FixEntry-Cat: true'); } // Reset s9y to use the category's properties $serendipity['fetchLimit'] = $this->fetchLimit($cid, $serendipity['fetchLimit']); $serendipity['showFutureEntries'] = $this->fetchFuture($cid, $serendipity['showFutureEntries']); $serendipity['template'] = $this->fetchTemplate($cid, $serendipity['template']); $this->sort_order = $this->fetchSortOrder($cid, $this->get_config('sort_order')); // Set the template options if (!$this->usesDefaultTemplate) { $serendipity['smarty_vars']['template_option'] = $serendipity['template'] . '_' . $cid; } // Check for password if ($cid != 'default' && serendipity_db_bool($this->get_config('pass')) && $this->fetchProp($cid, 'pass') != '') { if (!isset($_SERVER['PHP_AUTH_PW']) || $_SERVER['PHP_AUTH_PW'] != $this->fetchProp($cid, 'pass')) { header('WWW-Authenticate: Basic realm="' . PLUGIN_CATEGORYTEMPLATES_PASS_USER . '"'); header("HTTP/1.0 401 Unauthorized"); header('Status: 401 Unauthorized'); echo PLUGIN_CATEGORYTEMPLATES_PASS_USER; exit; } else { $this->current_pw = $_SERVER['PHP_AUTH_PW']; } } // Set the template stylesheet $serendipity['smarty_vars']['head_link_stylesheet'] = serendipity_rewriteURL('plugin/categorytemplate_' . $cid, 'baseURL', true); return true; break; // When the back end is displayed, use the custom template, too // When the back end is displayed, use the custom template, too case 'backend_sidebar_entries_event_display_cattemplate': if (empty($serendipity['GET']['cat_template'])) { $serendipity['GET']['cat_template'] = $serendipity['POST']['cat_template']; } if (empty($serendipity['GET']['catid'])) { $serendipity['GET']['catid'] = $serendipity['POST']['catid']; } $old = $serendipity['GET']['adminModule']; $serendipity['GET']['adminModule'] = 'templates'; $this->template_options($serendipity['GET']['cat_template'], $serendipity['GET']['catid']); $serendipity['GET']['adminModule'] = $old; return true; break; default: return true; break; } } else { return false; } }
function generateSitemap(&$bag) { global $serendipity; // decide which NULL-function to use switch ($serendipity['dbType']) { case 'postgres': $sqlnullfunction = 'COALESCE'; break; case 'sqlite': case 'mysql': case 'mysqli': $sqlnullfunction = 'IFNULL'; break; default: $sqlnullfunction = ''; } $hooks =& $bag->get('event_hooks'); $do_pingback = serendipity_db_bool($this->get_config('sitemap_pingback', false)); $pingback_url = $this->get_config('sitemap_pingback_urls', false); // start the xml $sitemap_xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $sitemap_xml .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n"; $sitemap_xml .= "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"; $sitemap_xml .= "\txsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\n"; $sitemap_xml .= "\t\t\thttp://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\">\n"; // add link to the main page $this->addtoxml($sitemap_xml, $serendipity['baseURL'], time(), 0.6); // fetch all entries from the db (tested with: mysql, sqlite, postgres) $entries = serendipity_db_query('SELECT entries.id AS id, entries.title AS title, ' . $sqlnullfunction . '(entries.last_modified,0) AS timestamp_1, ' . $sqlnullfunction . '(MAX(comments.timestamp),0) AS timestamp_2 FROM ' . $serendipity['dbPrefix'] . 'entries entries LEFT JOIN ' . $serendipity['dbPrefix'] . 'comments comments ON entries.id = comments.entry_id WHERE entries.isdraft = \'false\' GROUP BY entries.id, entries.title, entries.last_modified ORDER BY entries.id', false, 'assoc'); if (is_array($entries)) { // add entries foreach ($entries as $entry) { $max = max($entry['timestamp_1'] + 0, $entry['timestamp_2'] + 0); $url = serendipity_archiveURL($entry['id'], $entry['title']); $this->addtoxml($sitemap_xml, $url, $max, 0.7); } } // add possible perm links $permlink = serendipity_db_query('SELECT entryid, timestamp, value FROM ' . $serendipity['dbPrefix'] . 'entryproperties AS entryproperties, ' . $serendipity['dbPrefix'] . 'entries AS entries WHERE entryproperties.property = \'permalink\' AND entries.id=entryproperties.entryid', false, 'assoc'); if (is_array($permlink)) { foreach ($permlink as $cur) { $path_quoted = preg_quote($serendipity['serendipityHTTPPath'], '#'); $url = $serendipity['baseURL'] . preg_replace("#{$path_quoted}#", '', $cur['value'], 1); $cur_time = $cur['timestamp'] == 0 ? null : (int) $cur['timestamp']; $this->addtoxml($sitemap_xml, $url, $cur_time, 0.8); } // check for the right order of plugins $order = serendipity_db_query('SELECT name, sort_order FROM ' . $serendipity['dbPrefix'] . 'plugins plugins WHERE plugins.name LIKE \'%serendipity_event_mobile_output%\' OR plugins.name LIKE \'%serendipity_event_custom_permalinks%\' ORDER BY plugins.sort_order', false, 'assoc'); if (is_array($order)) { if (strpos($order[0]['name'], 'serendipity_event_custom_permalinks') === FALSE) { echo '<br/>' . PLUGIN_EVENT_MOBILE_OUTPUT_SITEMAP_PERMALINK_WARNING . '<br/>'; } } } // fetch categories and their last entry date (tested with: mysql, sqlite, postgres) $q = 'SELECT category.categoryid AS id, category_name, category_description, MAX(entries.last_modified) AS last_mod FROM ' . $serendipity['dbPrefix'] . 'category category, ' . $serendipity['dbPrefix'] . 'entrycat entrycat, ' . $serendipity['dbPrefix'] . 'entries entries WHERE category.categoryid = entrycat.categoryid AND entrycat.entryid = entries.id GROUP BY category.categoryid, category.category_name, category.category_description ORDER BY category.categoryid'; $categories = serendipity_db_query($q, false, 'assoc'); // add categories if (is_array($categories)) { foreach ($categories as $category) { $max = 0 + $category['last_mod']; /* v0.9 */ if (version_compare((double) $serendipity['version'], '0.9', '>=')) { $data = array('categoryid' => $category['id'], 'category_name' => $category['category_name'], 'category_description' => $category['category_description']); $url = serendipity_categoryURL($data); } else { $url = serendipity_rewriteURL(PATH_CATEGORIES . '/' . serendipity_makePermalink(PERM_CATEGORIES, array('id' => $category['id'], 'title' => $category['category_name']))); } $this->addtoxml($sitemap_xml, $url, $max, 0.4); } } else { $categories = array(); } // finish the xml $sitemap_xml .= "</urlset>\n"; $do_gzip = serendipity_db_bool($this->get_config('gzip_sitemap', true)); // decide whether to use gzip-output or not if ($do_gzip && function_exists('gzencode')) { $filename = '/mobile_sitemap.xml.gz'; $temp = gzencode($sitemap_xml); // only use the compressed data and filename if no error occured if (!($temp === FALSE)) { $sitemap_xml = $temp; } else { $filename = '/mobile_sitemap.xml'; } } else { $filename = '/mobile_sitemap.xml'; } // write result to file $outfile = fopen($serendipity['serendipityPath'] . $filename, 'w'); if ($outfile === false) { echo '<strong>' . PLUGIN_EVENT_MOBILE_OUTPUT_SITEMAP_FAILEDOPEN . '</strong>'; return false; } flock($outfile, LOCK_EX); fputs($outfile, $sitemap_xml); flock($outfile, LOCK_UN); fclose($outfile); // Walk through the list of pingback-URLs foreach (explode(';', $pingback_url) as $cur_pingback_url) { $pingback_name = PLUGIN_EVENT_MOBILE_OUTPUT_SITEMAP_UNKNOWN_HOST; $cur_url = sprintf($cur_pingback_url, rawurlencode($serendipity['baseURL'] . $filename)); // extract domain-portion from URL if (preg_match('@^https?://([^/]+)@', $cur_pingback_url, $matches) > 0) { $pingback_name = $matches[1]; } if (!serendipity_db_bool($eventData['isdraft']) && $do_pingback && $cur_url) { $answer = $this->send_ping($cur_url); if ($answer) { printf(PLUGIN_EVENT_MOBILE_OUTPUT_SITEMAP_REPORT_OK, $pingback_name); } else { printf(PLUGIN_EVENT_MOBILE_OUTPUT_SITEMAP_REPORT_ERROR, $pingback_name, $cur_url); } } else { printf(PLUGIN_EVENT_MOBILE_OUTPUT_SITEMAP_REPORT_MANUAL, $pingback_name, $cur_url); } } return true; }
/** * Initialize the Smarty framework for use in Serendipity * * @access public * @return null */ function serendipity_smarty_init($vars = array()) { global $serendipity, $template_config, $template_global_config, $template_config_groups; if (!isset($serendipity['smarty'])) { $template_dir = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template']; if (!defined('IN_serendipity_admin') && file_exists($template_dir . '/template.inc.php')) { // If this file exists, a custom template engine will be loaded. // Beware: Smarty is used in the Admin backend, despite of this. include_once $template_dir . '/template.inc.php'; } else { // Backend template overwritten here (NOT earlier due to frontend specific check) if (defined('IN_serendipity_admin')) { $template_dir = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template_backend']; } // Set a session variable if Smarty fails: $prev_smarty = $_SESSION['no_smarty']; $_SESSION['no_smarty'] = true; if (LANG_CHARSET != 'UTF-8') { @define('SMARTY_MBSTRING', false); @define('SMARTY_RESOURCE_CHAR_SET', LANG_CHARSET); } // define cache resources to load with smarty - see smarty cache readme - needs enabled cache! #@define('APC_EXTENSION_LOADED', extension_loaded('apc') && ini_get('apc.enabled')); #@define('MEMCACHE_EXTENSION_LOADED', (class_exists('Memcached',false) || class_exists('Memcache',false)) && (extension_loaded("memcached") || extension_loaded("memcache"))); // Default Smarty Engine will be used @define('SMARTY_DIR', S9Y_PEAR_PATH . 'Smarty/libs/'); if (!class_exists('Smarty')) { include_once SMARTY_DIR . 'Smarty.class.php'; } if (!class_exists('Smarty')) { return false; } // include the serendipity smarty constructor if (!class_exists('Serendipity_Smarty')) { include_once S9Y_INCLUDE_PATH . '/include/serendipity_smarty_class.inc.php'; } if (!class_exists('Serendipity_Smarty')) { return false; } // set smarty instance #$serendipity['smarty'] = new Serendipity_Smarty; // initialize smarty object by instance $serendipity['smarty'] = Serendipity_Smarty::getInstance(); // debug moved to class // Hooray for Smarty: $_SESSION['no_smarty'] = $prev_smarty; // enable security policy by instance of the Smarty_Security class $serendipity['smarty']->enableSecurity('Serendipity_Smarty_Security_Policy'); // debugging... #echo '<pre>';print_r($serendipity['smarty']);echo '</pre>';#exit; #$serendipity['smarty']->testInstall();exit; // extreme debugging with undocumented internal flag which enables a trace output from the parser during debugging #$serendipity['smarty']->_parserdebug = true; // be careful! /** * ToDo: Check for possible API changes in Smarty 3.2 [smarty_modifier_foobar, --> [smarty_modifier_foobar, smarty_function_foobar, smarty_block_foobar] (in class)] * smarty_modifier_foobar(Smarty $smarty, $string, ...) vs. smarty_modifier_foobar($string, ...) **/ $serendipity['smarty']->registerPlugin('modifier', 'makeFilename', 'serendipity_makeFilename'); $serendipity['smarty']->registerPlugin('modifier', 'xhtml_target', 'serendipity_xhtml_target'); $serendipity['smarty']->registerPlugin('modifier', 'emptyPrefix', 'serendipity_emptyPrefix'); $serendipity['smarty']->registerPlugin('modifier', 'formatTime', 'serendipity_smarty_formatTime'); $serendipity['smarty']->registerPlugin('modifier', 'serendipity_utf8_encode', 'serendipity_utf8_encode'); $serendipity['smarty']->registerPlugin('modifier', 'ifRemember', 'serendipity_ifRemember'); $serendipity['smarty']->registerPlugin('modifier', 'checkPermission', 'serendipity_checkPermission'); $serendipity['smarty']->registerPlugin('modifier', 'serendipity_refhookPlugin', 'serendipity_smarty_refhookPlugin'); $serendipity['smarty']->registerPlugin('modifier', 'serendipity_html5time', 'serendipity_smarty_html5time'); $serendipity['smarty']->registerPlugin('modifier', 'rewriteURL', 'serendipity_rewriteURL'); $serendipity['smarty']->registerPlugin('function', 'serendipity_printSidebar', 'serendipity_smarty_printSidebar'); $serendipity['smarty']->registerPlugin('function', 'serendipity_hookPlugin', 'serendipity_smarty_hookPlugin'); $serendipity['smarty']->registerPlugin('function', 'serendipity_showPlugin', 'serendipity_smarty_showPlugin'); $serendipity['smarty']->registerPlugin('function', 'serendipity_getFile', 'serendipity_smarty_getFile'); $serendipity['smarty']->registerPlugin('function', 'serendipity_printComments', 'serendipity_smarty_printComments'); $serendipity['smarty']->registerPlugin('function', 'serendipity_printTrackbacks', 'serendipity_smarty_printTrackbacks'); $serendipity['smarty']->registerPlugin('function', 'serendipity_rss_getguid', 'serendipity_smarty_rss_getguid'); $serendipity['smarty']->registerPlugin('function', 'serendipity_fetchPrintEntries', 'serendipity_smarty_fetchPrintEntries'); $serendipity['smarty']->registerPlugin('function', 'serendipity_getTotalCount', 'serendipity_smarty_getTotalCount'); $serendipity['smarty']->registerPlugin('function', 'pickKey', 'serendipity_smarty_pickKey'); $serendipity['smarty']->registerPlugin('function', 'serendipity_showCommentForm', 'serendipity_smarty_showCommentForm'); $serendipity['smarty']->registerPlugin('function', 'serendipity_getImageSize', 'serendipity_smarty_getImageSize'); $serendipity['smarty']->registerPlugin('function', 'serendipity_getConfigVar', 'serendipity_smarty_getConfigVar'); $serendipity['smarty']->registerPlugin('function', 'serendipity_setFormToken', 'serendipity_smarty_setFormToken'); $serendipity['smarty']->registerFilter('pre', 'serendipity_replaceSmartyVars'); } if (!isset($serendipity['smarty_file'])) { $serendipity['smarty_file'] = 'index.tpl'; } $category = false; $category_info = array(); if (isset($serendipity['GET']['category'])) { $category = (int) $serendipity['GET']['category']; if (isset($GLOBALS['cInfo'])) { $category_info = $GLOBALS['cInfo']; } else { $category_info = serendipity_fetchCategoryInfo($category); } } if (!isset($serendipity['smarty_vars']['head_link_stylesheet'])) { $serendipity['smarty_vars']['head_link_stylesheet_frontend'] = serendipity_rewriteURL('serendipity.css'); if (IN_serendipity_admin === true) { $serendipity['smarty_vars']['head_link_stylesheet'] = serendipity_rewriteURL('serendipity_admin.css'); } else { $serendipity['smarty_vars']['head_link_stylesheet'] = serendipity_rewriteURL('serendipity.css'); } // When templates are switched, append a specific version string to make sure the browser does not cache the CSS if (strstr($serendipity['smarty_vars']['head_link_stylesheet'], '?')) { $serendipity['smarty_vars']['head_link_stylesheet'] .= '&v=' . $serendipity['last_template_change']; $serendipity['smarty_vars']['head_link_stylesheet_frontend'] .= '&v=' . $serendipity['last_template_change']; } else { $serendipity['smarty_vars']['head_link_stylesheet'] .= '?v=' . $serendipity['last_template_change']; $serendipity['smarty_vars']['head_link_stylesheet_frontend'] .= '?v=' . $serendipity['last_template_change']; } } if (!isset($serendipity['smarty_vars']['head_link_script'])) { if (IN_serendipity_admin === true) { $serendipity['smarty_vars']['head_link_script'] = serendipity_rewriteURL('serendipity_admin.js'); } else { $serendipity['smarty_vars']['head_link_script'] = serendipity_rewriteURL('serendipity.js'); } if (strstr($serendipity['smarty_vars']['head_link_script'], '?')) { $serendipity['smarty_vars']['head_link_script'] .= '&v=' . $serendipity['last_template_change']; } else { $serendipity['smarty_vars']['head_link_script'] .= '?v=' . $serendipity['last_template_change']; } } $wysiwyg_customPlugin = $wysiwyg_customConfig = null; if (defined('IN_serendipity_admin') && $serendipity['wysiwyg']) { // check force internal toolbar config file if (strpos($serendipity['wysiwygToolbar'], 'NOCC-') !== false) { $serendipity['wysiwygToolbar'] = substr($serendipity['wysiwygToolbar'], 5); $force_internal_toolbar = true; } // check ckeditor custom plugin file $ccp = serendipity_getTemplateFile('admin/ckeditor_custom_plugin.js', 'serendipityHTTPPath', true); $wysiwyg_customPlugin = !empty($ccp) && !$force_internal_toolbar ? $ccp : $serendipity['serendipityHTTPPath'] . 'htmlarea/ckeditor_s9y_plugin.js'; // check ckeditor custom config file $ccc = serendipity_getTemplateFile('admin/ckeditor_custom_config.js', 'serendipityHTTPPath', true); $wysiwyg_customConfig = !empty($ccc) && !$force_internal_toolbar ? $ccc : $serendipity['serendipityHTTPPath'] . 'htmlarea/ckeditor_s9y_config.js'; } $_force_backendpopups = explode(',', $serendipity['enableBackendPopupGranular']); $force_backendpopups = array(); foreach ($_force_backendpopups as $fbp_key => $fbp_val) { $fbp_val = trim($fbp_val); if (empty($fbp_val)) { continue; } $force_backendpopups[$fbp_val] = $fbp_val; } $serendipity['smarty']->assign(array('head_charset' => LANG_CHARSET, 'head_version' => $serendipity['version'], 'head_title' => $serendipity['head_title'], 'head_subtitle' => $serendipity['head_subtitle'], 'head_link_stylesheet' => $serendipity['smarty_vars']['head_link_stylesheet'], 'head_link_script' => $serendipity['smarty_vars']['head_link_script'], 'head_link_stylesheet_frontend' => $serendipity['smarty_vars']['head_link_stylesheet_frontend'], 'is_xhtml' => true, 'use_popups' => $serendipity['enablePopup'], 'use_backendpopups' => $serendipity['enableBackendPopup'], 'force_backendpopups' => $force_backendpopups, 'is_embedded' => !$serendipity['embed'] || $serendipity['embed'] === 'false' || $serendipity['embed'] === false ? false : true, 'is_raw_mode' => $serendipity['smarty_raw_mode'], 'is_logged_in' => serendipity_userLoggedIn(), 'entry_id' => isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id']) ? $serendipity['GET']['id'] : false, 'is_single_entry' => isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id']), 'blogTitle' => $serendipity['blogTitle'], 'blogSubTitle' => !empty($serendipity['blogSubTitle']) ? $serendipity['blogSubTitle'] : '', 'blogDescription' => $serendipity['blogDescription'], 'serendipityHTTPPath' => $serendipity['serendipityHTTPPath'], 'serendipityDefaultBaseURL' => $serendipity['defaultBaseURL'], 'serendipityBaseURL' => $serendipity['baseURL'], 'serendipityRewritePrefix' => $serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '', 'serendipityIndexFile' => $serendipity['indexFile'], 'serendipityVersion' => $serendipity['expose_s9y'] ? $serendipity['version'] : '', 'lang' => $serendipity['lang'], 'category' => $category, 'category_info' => $category_info, 'template' => $serendipity['template'], 'template_backend' => $serendipity['template_backend'], 'wysiwygToolbar' => $serendipity['wysiwygToolbar'], 'wysiwyg_customPlugin' => $wysiwyg_customPlugin, 'wysiwyg_customConfig' => $wysiwyg_customConfig, 'use_autosave' => serendipity_db_bool($serendipity['use_autosave']) ? 'true' : 'false', 'dateRange' => !empty($serendipity['range']) ? $serendipity['range'] : array())); if (count($vars) > 0) { $serendipity['smarty']->assign($vars); } // For advanced usage, we allow template authors to create a file 'config.inc.php' where they can // setup custom smarty variables, modifiers etc. to use in their templates. // If a template engine is defined we need that config.inc.php file as well. The template's actual file is loaded after that to be able to overwrite config. if (isset($serendipity['template_engine']) && $serendipity['template_engine'] != null) { $p = explode(',', $serendipity['template_engine']); foreach ($p as $te) { $config = $serendipity['serendipityPath'] . $serendipity['templatePath'] . trim($te) . '/config.inc.php'; if (file_exists($config)) { include_once $config; } } } // FIRST: Load config of the currently configured FRONTEND template. We might actually need this in the backend (sidebar configuration, IPTC options, some others). // SECOND: Load config of the currently set template, which can also be the BACKEND template, or be the same as before. include_once takes care of only including the file once. $config = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php'; if (file_exists($config)) { include_once $config; } $config = $serendipity['smarty']->getConfigDir(0) . '/config.inc.php'; if (file_exists($config)) { include_once $config; } if (is_array($template_loaded_config)) { $template_vars =& $template_loaded_config; $serendipity['smarty']->assignByRef('template_option', $template_vars); } elseif (is_array($template_config)) { $template_vars =& serendipity_loadThemeOptions($template_config, $serendipity['smarty_vars']['template_option']); $serendipity['smarty']->assignByRef('template_option', $template_vars); } } return true; }
function generate_button($txtarea, $return_output) { global $serendipity; if (!isset($txtarea)) { $txtarea = 'body'; } $link = serendipity_rewriteURL('plugin/amazonch') . ($serendipity['rewrite'] != 'none' ? '?' : '&') . 'txtarea=' . $txtarea; $open = $serendipity['version'][0] > '1' ? 'serendipity.openPopup' : 'window.open'; if ($return_output) { if ($serendipity['version'][0] > '1') { $button = '<input type="button" class="input_button" name="insAmazonImage" value="' . PLUGIN_EVENT_AMAZONCHOOSER_MEDIA_BUTTON . '" style="" onclick="' . $open . '(\'' . $link . "&simple=1" . '\', \'AmazonImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');">'; } else { $button = '<input type="button" class="serendipityPrettyButton input_button" name="insAmazonImage" value="' . PLUGIN_EVENT_AMAZONCHOOSER_MEDIA_BUTTON . '" style="" onclick="' . $open . '(\'' . $link . "&simple=1" . '\', \'AmazonImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" />'; } return $button; } else { if ($serendipity['version'][0] > '1') { $button = '<input type="button" class="input_button" name="insAmazonImage" value="' . PLUGIN_EVENT_AMAZONCHOOSER_MEDIA_BUTTON . '" style="" onclick="' . $open . '(\'' . $link . '\', \'AmazonImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');">'; } else { $button = '<input type="button" class="serendipityPrettyButton input_button" name="insAmazonImage" value="' . PLUGIN_EVENT_AMAZONCHOOSER_MEDIA_BUTTON . '" style="" onclick="' . $open . '(\'' . $link . '\', \'AmazonImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" />'; } echo $button; } }
/** * Creates a DHTML menu of serendipity categories. * * The menu is echoed out. * * @param string $title (Serves as the top level menu item if present) * @return void * @see http://pear.php.net/HTML_TreeMenu PEAR::HTML_TreeMenu */ function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); // may want to put this in bundled_libs or a sub directory of this directory $pear = false; if (@(include_once 'HTML/TreeMenu.php')) { $pear = true; } elseif (@(include_once 'HTML_TreeMenu/TreeMenu.php')) { $pear = true; } if ($pear) { $which_category = $this->get_config('authorid'); // build an accessible array of categories foreach (serendipity_fetchCategories(empty($which_category) ? 'all' : $which_category) as $cat) { if (!is_array($cat) || !isset($cat['categoryid'])) { continue; } $categories[$cat['categoryid']] = $cat; } // create an array of numbers of entries per category $cat_count = array(); if (serendipity_db_bool($this->get_config('show_count'))) { $cat_sql = "SELECT c.categoryid, c.category_name, count(e.id) as postings\n FROM {$serendipity['dbPrefix']}entrycat ec,\n {$serendipity['dbPrefix']}category c,\n {$serendipity['dbPrefix']}entries e\n WHERE ec.categoryid = c.categoryid\n AND ec.entryid = e.id\n AND e.isdraft = 'false'\n " . (!serendipity_db_bool($serendipity['showFutureEntries']) ? " AND e.timestamp <= " . serendipity_db_time() : '') . "\n GROUP BY c.categoryid, c.category_name\n ORDER BY postings DESC"; $category_rows = serendipity_db_query($cat_sql); if (is_array($category_rows)) { foreach ($category_rows as $cat) { $cat_count[$cat['categoryid']] = $cat['postings']; } } } $image = $this->get_config('image', serendipity_getTemplateFile('img/xml.gif')); $image = $image == "'none'" || $image == 'none' ? '' : $image; // create nodes foreach ($categories as $cid => $cat) { if (function_exists('serendipity_categoryURL')) { $link = serendipity_categoryURL($cat, 'serendipityHTTPPath'); } else { $link = serendipity_rewriteURL(PATH_CATEGORIES . '/' . serendipity_makePermalink(PERM_CATEGORIES, array('id' => $cat['categoryid'], 'title' => $cat['category_name'])), 'serendipityHTTPPath'); } if (!empty($cat_count[$cat['categoryid']])) { // $categories[$cid]['true_category_name'] = $cat['category_name']; $cat['category_name'] .= ' (' . $cat_count[$cat['categoryid']] . ')'; // $categories[$cid]['article_count'] = $cat_count[$cat['categoryid']]; } if (!empty($image)) { $feedURL = serendipity_feedCategoryURL($cat, 'serendipityHTTPPath'); $feed = '<a class="serendipity_xml_icon" href="' . $feedURL . '"><img src="' . $image . '" alt="XML" style="border: 0px;vertical-align:middle"/></a> '; $link = '<a href="' . $link . '" target="_self"><span>' . $cat['category_name'] . '</span></a>'; // work around a problem in HTML_TreeNode: when there is a href in 'text', 'link' is not converted to a link. $cat_nodes[$cat['categoryid']] = new HTML_TreeNode(array('text' => $feed . $link)); } else { $cat_nodes[$cat['categoryid']] = new HTML_TreeNode(array('text' => $feed . $cat['category_name'], 'link' => $link)); } } // create a top level for "all categories" // this serves as the title $cat_nodes[0] = new HTML_TreeNode(array('text' => ALL_CATEGORIES, 'link' => $serendipity['baseURL'])); // nest nodes (thanks to PHP references) foreach ($categories as $category) { $cat_nodes[$category['parentid']]->addItem($cat_nodes[$category['categoryid']]); } // nest the "all categories" category $menu = new HTML_TreeMenu(); $menu->addItem($cat_nodes[0]); $tree = new HTML_TreeMenu_DHTML($menu, array('images' => $serendipity['baseURL'] . $this->get_config('image_path'))); // Add heading for block #$output = '<h2 class="serendipitySideBarTitle" style="font-weight: bold;">'.$title.'</h2><br />'; // Put inside a div with "overflow:hidden" to avoid items of the sidebar plugin running outside the blog // Maybe we can put a config setting to choose if the block should be displayed with or without overflow setting. $output .= '<div style="overflow: hidden;">'; $output .= $tree->toHTML(); $output .= '</div>'; echo '<script type="text/javascript" src="' . $serendipity['baseURL'] . $this->get_config('script_path') . '"></script>'; } else { $output .= "Please install PEAR package HTML_TreeMenu to enable this plugin."; } echo $output; }
function write_sitemap($basefilename = 'sitemap.xml', &$eventData, $gnewsmode = false) { global $serendipity; // start the xml $sitemap_xml = '<?xml version="1.0" encoding="UTF-8"?>' . "\n"; $sitemap_xml .= "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\"\n"; $sitemap_xml .= "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"; if ($gnewsmode) { $sitemap_xml .= "\txmlns:news=\"http://www.google.com/schemas/sitemap-news/0.9\"\n"; } $sitemap_xml .= "\txsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9\n"; $sitemap_xml .= "\t\t\thttp://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" "; $sitemap_xml .= $this->get_config('custom2'); $sitemap_xml .= ">\n"; $this->gnewsmode = false; // If this variable is enabled, each XML article will get its gnews:... counterpart. // This is NOT desired in the usual sitemap! if ($gnewsmode) { $this->gnewsmode = true; } elseif (serendipity_db_bool($this->get_config('gnews_single')) && serendipity_db_bool($this->get_config('gnews'))) { $this->gnewsmode = true; } // add link to the main page $this->addtoxml($sitemap_xml, $serendipity['baseURL'], time(), 0.6); if (!$gnewsmode) { $this->add_entries($sitemap_xml); if ($this->should_add('sm_permalinks')) { $this->add_permalinks($sitemap_xml); } if ($this->should_add('sm_categories')) { $this->add_categories($sitemap_xml); } if ($this->should_add('sm_authors')) { $this->add_authors($sitemap_xml); } if ($this->should_add('sm_archives')) { $this->add_archives($sitemap_xml); // add link to archive-mainpage $this->addtoxml($sitemap_xml, serendipity_rewriteURL(PATH_ARCHIVE), time(), 0.5); } if ($this->should_add('sm_feeds')) { $this->add_feeds($sitemap_xml); } if ($this->should_add('sm_static')) { $this->add_static($sitemap_xml); } if ($this->should_add('sm_tags')) { $this->add_tags($sitemap_xml); } } else { $this->add_entries($sitemap_xml, 900); } $sitemap_xml .= $this->get_config('custom'); // finish the xml $sitemap_xml .= "</urlset>\n"; $do_gzip = serendipity_db_bool($this->get_config('gzip_sitemap', true)); // decide whether to use gzip-output or not if ($do_gzip && function_exists('gzencode')) { $filename = '/' . $basefilename . '.gz'; $temp = gzencode($sitemap_xml); // only use the compressed data and filename if no error occured if (!($temp === FALSE)) { $sitemap_xml = $temp; } else { $filename = '/' . $basefilename; } } else { $filename = '/' . $basefilename; } // write result to file $outfile = fopen($serendipity['serendipityPath'] . $filename, 'w'); if ($outfile === false) { echo '<strong>' . PLUGIN_EVENT_SITEMAP_FAILEDOPEN . ' (' . $serendipity['serendipityPath'] . $filename . ')</strong>'; return false; } flock($outfile, LOCK_EX); fputs($outfile, $sitemap_xml); flock($outfile, LOCK_UN); fclose($outfile); $do_pingback = serendipity_db_bool($this->get_config('report', false)); $pingback_url = $this->get_config('url', false); // Walk through the list of pingback-URLs echo $basefilename . ':<br />'; foreach (explode(';', $pingback_url) as $cur_pingback_url) { $pingback_name = PLUGIN_EVENT_SITEMAP_UNKNOWN_HOST; $cur_url = sprintf($cur_pingback_url, rawurlencode($serendipity['baseURL'] . $filename)); // extract domain-portion from URL if (preg_match('@^https?://([^/]+)@', $cur_pingback_url, $matches) > 0) { $pingback_name = $matches[1]; } if (!serendipity_db_bool($eventData['isdraft']) && $do_pingback && $cur_url) { $answer = $this->send_ping($cur_url); if ($answer) { printf(PLUGIN_EVENT_SITEMAP_REPORT_OK, $pingback_name); } else { printf(PLUGIN_EVENT_SITEMAP_REPORT_ERROR, $pingback_name, $cur_url); } } else { printf(PLUGIN_EVENT_SITEMAP_REPORT_MANUAL, $pingback_name, $cur_url); } } echo PLUGIN_EVENT_SITEMAP_ROBOTS_TXT; }
function event_hook($event, &$bag, &$eventData, $addData = null) { global $serendipity; if ($event == 'frontend_header') { $start_url = $serendipity['baseURL']; $start_title = $serendipity['blogTitle']; echo '<link rel="start" href="' . $start_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($start_title) : htmlspecialchars($start_title, ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n"; if ($serendipity['GET']['action'] == 'read' && !empty($serendipity['GET']['id'])) { // Article detail view echo '<link rel="up" href="' . $start_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($start_title) : htmlspecialchars($start_title, ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n"; $this->backAndForth($this->showPaging($serendipity['GET']['id'])); // END article detail view echo '<link rel="canonical" href="' . $this->getEntry($serendipity['GET']['id']) . '" />' . "\n"; } elseif ($serendipity['GET']['action'] == 'read' && is_array($serendipity['range'])) { // Specific Date Archives view echo '<link rel="up" href="' . serendipity_rewriteURL(PATH_ARCHIVE) . '" title="' . ARCHIVES . '" />' . "\n"; echo '<link rel="canonical" href="' . $this->getArchiveParameters() . '" />' . "\n"; $links = array(); $add_query = ''; $year = date('Y', $serendipity['range'][0]); $month = date('m', $serendipity['range'][0]); $day = date('d', $serendipity['range'][0]); $pageMonthNext = array('day' => '1', 'month' => $month + 1, 'year' => $year); $pageMonthPrev = array('day' => '1', 'month' => $month - 1, 'year' => $year); $pageDayNext = array('day' => $day + 1, 'month' => $month, 'year' => $year); $pageDayPrev = array('day' => $day - 1, 'month' => $month, 'year' => $year); $diff = $serendipity['range'][1] - $serendipity['range'][0]; if (isset($serendipity['GET']['category'])) { $categoryid = (int) serendipity_db_escape_string($serendipity['GET']['category']); $add_query = '/C' . $categoryid; } if ($diff < 86400) { // Paging day by day $ts = mktime(0, 0, 0, $pageDayPrev['month'], $pageDayPrev['day'], $pageDayPrev['year']); $links['prev'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d/%02d', date('Y', $ts), date('m', $ts), date('d', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false))); $ts = mktime(0, 0, 0, $pageDayNext['month'], $pageDayNext['day'], $pageDayNext['year']); $links['next'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d/%02d', date('Y', $ts), date('m', $ts), date('d', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime(DATE_FORMAT_ENTRY, $ts, false))); } elseif ($diff < 86400 * 28) { // Paging by week // TODO - Don't know :-) } else { // Paging by month $ts = mktime(0, 0, 0, $pageMonthPrev['month'], $pageMonthPrev['day'], $pageMonthPrev['year']); $links['prev'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d', date('Y', $ts), date('m', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime('%B %Y', $ts, false))); $ts = mktime(0, 0, 0, $pageMonthNext['month'], $pageMonthNext['day'], $pageMonthNext['year']); $links['next'] = array('link' => serendipity_archiveDateUrl(sprintf('%4d/%02d', date('Y', $ts), date('m', $ts))), 'title' => sprintf(ENTRIES_FOR, serendipity_formatTime('%B %Y', $ts, false))); } $this->backAndForth($links); // END Specific Date Archives view } elseif ($serendipity['GET']['action'] == 'archives') { // Full month/year archives overview echo '<link rel="up" href="' . serendipity_rewriteURL(PATH_ARCHIVE) . '" title="' . ARCHIVES . '" />' . "\n"; // END Full month/year archives overview echo '<link rel="canonical" href="' . $this->getArchiveParameters() . '" />' . "\n"; } elseif (!empty($serendipity['GET']['category'])) { // Category based view $cInfo = serendipity_fetchCategoryInfo($serendipity['GET']['category']); if (function_exists('serendipity_categoryURL')) { $categories_url = serendipity_categoryURL($cInfo, 'serendipityHTTPPath'); } else { $categories_url = serendipity_rewriteURL(PATH_CATEGORIES . '/' . serendipity_makePermalink(PERM_CATEGORIES, array('id' => $cInfo['categoryid'], 'title' => $cInfo['category_name'])), 'serendipityHTTPPath'); } echo '<link rel="up" href="' . $categories_url . '" title="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($cInfo['category_name']) : htmlspecialchars($cInfo['category_name'], ENT_COMPAT, LANG_CHARSET)) . '" />' . "\n"; echo '<link rel="canonical" href="' . $categories_url . '" />' . "\n"; $categories = serendipity_fetchCategories('all'); $links = array(); if (is_array($categories) && count($categories)) { $categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED); $capture_next = false; foreach ($categories as $cat) { if ($capture_next) { $links['next'] = $this->getCat($cat); break; } if (is_array($prev_cat) && $cat['categoryid'] == $serendipity['GET']['category']) { $links['prev'] = $this->getCat($prev_cat); $capture_next = true; } $prev_cat = $cat; } } $this->backAndForth($links); // END Category based view } elseif (!empty($serendipity['GET']['viewAuthor'])) { // User view $uInfo = serendipity_fetchUsers(); $links = array(); if (is_array($uInfo)) { $capture_next = false; foreach ($uInfo as $user) { if ($capture_next) { $links['next'] = $this->getUser($user); break; } if ($user['authorid'] == $serendipity['GET']['viewAuthor']) { $authors_url = $this->getUser($user); echo '<link rel="up" href="' . $authors_url['link'] . '" title="' . $authors_url['title'] . '" />' . "\n"; echo '<link rel="canonical" href="' . $authors_url['link'] . '" />' . "\n"; if (is_array($prev_user)) { $links['prev'] = $this->getUser($prev_user); $capture_next = true; } } $prev_user = $user; } $this->backAndForth($links); } // END User view } else { // Frontpage $this->backAndForth(); // END Frontpage if ($serendipity['view'] == 'start') { echo '<link rel="canonical" href="' . $serendipity['baseURL'] . '" />' . "\n"; } } } }
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title', $this->title); $current_cat = $serendipity['GET']['category']; $current_page = $serendipity['GET']['page']; $current_auth = $serendipity['GET']['viewAuthor']; $current_rng = $serendipity['range']; $serendipity['GET']['page'] = 0; unset($serendipity['GET']['viewAuthor']); unset($serendipity['range']); $c = $this->get_config('category'); if ($c > 0) { $serendipity['GET']['category'] = (int) $c; } $showtitle = serendipity_db_bool($this->get_config('showtitle')); $showext = serendipity_db_bool($this->get_config('showext')); if (serendipity_db_bool($this->get_config('skip'))) { $limit = serendipity_db_limit($serendipity['fetchLimit'], $this->get_config('number')); } else { $limit = serendipity_db_limit(0, $this->get_config('number')); } $entries = serendipity_fetchEntries(null, true, $limit, false, false, 'timestamp DESC', '', false, true); if (is_array($entries)) { foreach ($entries as $i => $entry) { serendipity_plugin_api::hook_event('frontend_display', $entry); /* Pulled from serendipity_printEntries */ $entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])); $entry['commURL'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', false, array('timestamp' => $entry['timestamp'])); $entry['rdf_ident'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', true, array('timestamp' => $entry['timestamp'])); $entry['title'] = function_exists('serendipity_specialchars') ? serendipity_specialchars($entry['title']) : htmlspecialchars($entry['title'], ENT_COMPAT, LANG_CHARSET); $entry['link_allow_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=enable&serendipity[entry]=' . $entry['id']; $entry['link_deny_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=disable&serendipity[entry]=' . $entry['id']; $entry['allow_comments'] = serendipity_db_bool($entry['allow_comments']); $entry['moderate_comments'] = serendipity_db_bool($entry['moderate_comments']); $entry['link_popup_comments'] = $serendipity['serendipityHTTPPath'] . 'comment.php?serendipity[entry_id]=' . $entry['id'] . '&serendipity[type]=comments'; $entry['link_popup_trackbacks'] = $serendipity['serendipityHTTPPath'] . 'comment.php?serendipity[entry_id]=' . $entry['id'] . '&serendipity[type]=trackbacks'; $entry['link_edit'] = $serendipity['baseURL'] . 'serendipity_admin.php?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=edit&serendipity[id]=' . $entry['id']; $entry['link_trackback'] = $serendipity['baseURL'] . 'comment.php?type=trackback&entry_id=' . $entry['id']; $entry['link_rdf'] = serendipity_rewriteURL(PATH_FEEDS . '/ei_' . $entry['id'] . '.rdf'); $entry['link_viewmode_threaded'] = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'] . '&serendipity[cview]=' . VIEWMODE_THREADED; $entry['link_viewmode_linear'] = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'] . '&serendipity[cview]=' . VIEWMODE_LINEAR; if ($_SESSION['serendipityAuthedUser'] === true && ($_SESSION['serendipityAuthorid'] == $entry['authorid'] || serendipity_checkPermission('adminEntriesMaintainOthers'))) { $entry['is_entry_owner'] = true; } if (is_array($entry['categories'])) { foreach ($entry['categories'] as $k => $v) { $entry['categories'][$k]['category_link'] = serendipity_categoryURL($entry['categories'][$k]); } } $entries[$i] = $entry; } } $serendipity['smarty']->assign(array('showtitle' => $showtitle, 'showext' => $showext, 'entries' => $entries)); $tfile = serendipity_getTemplateFile('plugin_showentries.tpl', 'serendipityPath'); if (!$tfile) { $tfile = dirname(__FILE__) . '/plugin_showentries.tpl'; } $inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY]; $serendipity['smarty']->security_settings[INCLUDE_ANY] = true; $content = $serendipity['smarty']->fetch('file:' . $tfile); $serendipity['smarty']->security_settings[INCLUDE_ANY] = $inclusion; echo $content; $serendipity['GET']['category'] = $current_cat; $serendipity['GET']['page'] = $current_page; $serendipity['GET']['viewAuthor'] = $current_auth; $serendipity['range'] = $current_rng; }
function showFeeds() { # Shows feeds in admin area global $serendipity; echo '<h2>' . PLUGIN_AGGREGATOR_TITLE . '</h2>'; if (!empty($serendipity['POST']['aggregatorAction'])) { $this->createFeeds(); } elseif (!empty($serendipity['POST']['aggregatorOPMLImport'])) { $this->importOPML(); } $feeds = $this->getFeeds(); $feeds[] = array('feedid' => 0, 'feedname' => '', 'feedurl' => '', 'charset' => '', 'htmlurl' => '', 'match_expression' => '', 'feedicon' => '', 'categoryids' => array(), 'last_update' => time()); if ($serendipity['version'][0] == '2') { echo '<span class="msg_notice"><span class="icon-info-circled"></span> '; } echo PLUGIN_AGGREGATOR_DESC; if ($serendipity['version'][0] == '1') { echo '<br /><br />'; } else { echo '</span>'; } if ($serendipity['version'][0] == '2') { echo '<span class="msg_hint"><span class="icon-help-circled"></span> '; } echo PLUGIN_AGGREGATOR_FEEDLIST; if ($serendipity['version'][0] == '1') { echo '<br /><br />'; } else { echo '</span>'; } echo ' <form action="?" method="post"> <div> <input type="hidden" name="serendipity[adminModule]" value="event_display" /> <input type="hidden" name="serendipity[adminAction]" value="aggregator" /> </div>'; if ($serendipity['version'][0] == '1') { echo '<table align="center" width="100%" cellpadding="5" cellspacing="0" border=0>'; } else { echo '<table>'; } echo ' <thead> <tr> <th>#</th> <th>' . PLUGIN_AGGREGATOR_FEEDNAME . '</th> <th>' . PLUGIN_AGGREGATOR_FEEDURI . ' / ' . PLUGIN_AGGREGATOR_HTMLURI . '</th> <th>' . PLUGIN_AGGREGATOR_CATEGORIES . '</th> <th>' . PLUGIN_AGGREGATOR_MATCH_EXPRESSION . '* / ' . PLUGIN_AGGREGATOR_FEEDICON . '</th> </tr> </thead> <tbody>'; $evenidx = 0; foreach ($feeds as $idx => $feed) { $cat = $this->fetchCat("serendipity[feed][{$feed['feedid']}][categoryids][]", $feed['categoryids']); $even = $evenidx++ % 2 ? 'even' : 'uneven'; echo ' <tr style="padding: 10px;" class="serendipity_admin_list_item serendipity_admin_list_item_' . $even . '"> <td valign="top"><em>' . $idx . '</em></td> <td valign="top"> <input class="input_textbox" type="text" name="serendipity[feed][' . $feed['feedid'] . '][feedname]" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['feedname']) : htmlspecialchars($feed['feedname'], ENT_COMPAT, LANG_CHARSET)) . '" /> ' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['charset']) : htmlspecialchars($feed['charset'], ENT_COMPAT, LANG_CHARSET)) . ' </td> <td width="100%" valign="top"> <input class="input_textbox" style="width: 100%" type="text" name="serendipity[feed][' . $feed['feedid'] . '][feedurl]" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['feedurl']) : htmlspecialchars($feed['feedurl'], ENT_COMPAT, LANG_CHARSET)) . '" /> <input class="input_textbox" style="width: 65%; margin-top: 2px;" type="text" name="serendipity[feed][' . $feed['feedid'] . '][htmlurl]" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['htmlurl']) : htmlspecialchars($feed['htmlurl'], ENT_COMPAT, LANG_CHARSET)) . '" /> </td> <td valign="top" rowspan="2">' . $cat . '</td> <td valign="top" rowspan="2"><textarea rows=6 cols=25 name="serendipity[feed][' . $feed['feedid'] . '][match_expression]">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['match_expression']) : htmlspecialchars($feed['match_expression'], ENT_COMPAT, LANG_CHARSET)) . '</textarea><br /> <input class="input_textbox" style="width: 65%; margin-top: 2px;" type="text" name="serendipity[feed][' . $feed['feedid'] . '][feedicon]" value="' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($feed['feedicon']) : htmlspecialchars($feed['feedicon'], ENT_COMPAT, LANG_CHARSET)) . '" /> </tr> <tr style="padding: 10px;" class="serendipity_admin_list_item serendipity_admin_list_item_' . $even . '"> <td></td> <td colspan="2" valign="top"> <div style="font-size: 8pt;">' . PLUGIN_AGGREGATOR_FEEDUPDATE . ' ' . serendipity_formatTime(DATE_FORMAT_SHORT, $feed['last_update']) . '</div> </td> </tr>'; } echo ' <tr> <td colspan="4"><br /> <input type="submit" name="serendipity[aggregatorAction]" value="' . GO . '" class="serendipityPrettyButton input_button" /> </td> </tr> </tbody> </table> * ' . PLUGIN_AGGREGATOR_MATCH_EXPRESSION_DESC . ' </form>'; echo ' <form action="?" method="post"> <div> <input type="hidden" name="serendipity[adminModule]" value="event_display" /> <input type="hidden" name="serendipity[adminAction]" value="aggregator" /> </div>'; if ($serendipity['version'][0] == '1') { echo ' <div> <hr /><strong> ' . PLUGIN_AGGREGATOR_IMPORTFEEDLIST . '</strong><br /><br /> ' . PLUGIN_AGGREGATOR_IMPORTFEEDLIST_DESC . '<br /><br /> URL: <input class="input_textbox" type="text" name="serendipity[aggregatorOPML]" value="http://" /><br /> <input class="input_checkbox" type="checkbox" id="import_categories" name="serendipity[aggregatorOPMLCategories]" value="true" /><label for="import_categories">' . PLUGIN_AGGREGATOR_IMPORTCATEGORIES . '</label> <input class="input_checkbox" type="checkbox" id="import_categories2" name="serendipity[aggregatorOPMLCategoriesNoNesting]" value="true" /><label for="import_categories2">' . PLUGIN_AGGREGATOR_IMPORTCATEGORIES2 . '</label> <br /><br /> <input type="submit" name="serendipity[aggregatorOPMLImport]" value="' . PLUGIN_AGGREGATOR_IMPORTFEEDLIST_BUTTON . '" class="serendipityPrettyButton input_button" /> </div>'; } else { echo ' <h3>' . PLUGIN_AGGREGATOR_IMPORTFEEDLIST . '</h3> <span class="msg_hint"><span class="icon-help-circled"></span> ' . PLUGIN_AGGREGATOR_IMPORTFEEDLIST_DESC . '</span> <div class="form_field"> <label for="serendipity_aggregator_opml">URL</label> <input id="serendipity_aggregator_opml" type="text" name="serendipity[aggregatorOPML]" value="http://"> </div> <div class="form_check"> <input type="checkbox" id="import_categories" name="serendipity[aggregatorOPMLCategories]" value="true"><label for="import_categories">' . PLUGIN_AGGREGATOR_IMPORTCATEGORIES . '</label> <input type="checkbox" id="import_categories2" name="serendipity[aggregatorOPMLCategoriesNoNesting]" value="true"><label for="import_categories2">' . PLUGIN_AGGREGATOR_IMPORTCATEGORIES2 . '</label> </div>'; } if ($serendipity['version'][0] == '1') { echo ' <div> <hr /><strong> ' . PLUGIN_AGGREGATOR_EXPORTFEEDLIST . '</strong><br /><br /> <a href="' . serendipity_rewriteURL('plugin/opmlfeeds.xml') . '" class="serendipityPrettyButton">' . PLUGIN_AGGREGATOR_EXPORTFEEDLIST_BUTTON . '</a> </div> </form>'; } else { echo ' <h3>' . PLUGIN_AGGREGATOR_EXPORTFEEDLIST . '</h3> <a class="button_link" href="' . serendipity_rewriteURL('plugin/opmlfeeds.xml') . '"><span class="icon-rss"></span> ' . PLUGIN_AGGREGATOR_EXPORTFEEDLIST_BUTTON . '</a> </form>'; } }
function admin_display() { global $serendipity; global $template_vars; $plugin_list = unserialize($this->get_config('plugin_list')); serendipity_smarty_init(); $template_option = $serendipity['smarty']->get_template_vars('template_option'); if (isset($template_vars['sidebars'])) { $sidebars = explode(',', $template_vars['sidebars']); } elseif (isset($serendipity['sidebars'])) { $sidebars = $serendipity['sidebars']; } elseif (isset($template_option['sidebars'])) { $sidebars = explode(',', $template_option['sidebars']); } else { $sidebars = array('left', 'hide', 'right'); } $opts = array(); ?> <form action="?serendipity[adminModule]=event_display&serendipity[adminAction]=sidebarhider" method="post"> <input type="hidden" name="sbh_action" value="save"> <link rel="stylesheet" type="text/css" href="<?php echo serendipity_rewriteURL('serendipity.css'); ?> " /> <link rel="stylesheet" type="text/css" href="<?php echo serendipity_rewriteURL('serendipity_admin.css'); ?> " /> <h3><?php echo PLUGIN_SIDEBAR_HIDER_CONF; ?> </h3> <div><?php echo PLUGIN_SIDEBAR_HIDER_CONF_DESC; ?> </div> <br /> <input class="serendipityPrettyButton input_button" type="submit" name="submit" value="<?php echo SAVE_CHANGES_TO_LAYOUT; ?> " /><br /><br /> <table id="mainpane"> <tr> <?php foreach ($sidebars as $sidebar) { $plugins = serendipity_plugin_api::enum_plugins($sidebar); $up = strtoupper($sidebar); if ($sidebar == 'hide') { $opts[$sidebar] = HIDDEN; } elseif (defined('SIDEBAR_' . $up)) { $opts[$sidebar] = constant('SIDEBAR_' . $up); } elseif (defined($up)) { $opts[$sidebar] = constant($up); } else { $opts[$sidebar] = $up; } if ($sidebar == 'left') { $pside = 0; } elseif ($sidebar == 'right') { $pside = 1; } else { $pside = $sidebar; } echo '<td valign="top"><strong>' . $opts[$sidebar] . '</strong><br />'; if (is_array($plugins)) { $this->admin_print_sidebar($plugins, $pside, $plugin_list); } echo '</td>' . "\n"; } ?> </tr> </table> </form> <?php }
/** * Initialize the Smarty framework for use in Serendipity * * @access public * @return null */ function serendipity_smarty_init($vars = array()) { global $serendipity, $template_config, $template_global_config, $template_config_groups; if (!isset($serendipity['smarty'])) { $template_dir = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template']; if (!defined('IN_serendipity_admin') && file_exists($template_dir . '/template.inc.php')) { // If this file exists, a custom template engine will be loaded. // Beware: Smarty is used in the Admin backend, despite of this. include $template_dir . '/template.inc.php'; } else { // Set a session variable if Smarty fails: $prev_smarty = $_SESSION['no_smarty']; $_SESSION['no_smarty'] = true; // Default Smarty Engine will be used @define('SMARTY_DIR', S9Y_PEAR_PATH . 'Smarty/libs/'); if (!class_exists('Smarty')) { include SMARTY_DIR . 'Smarty.class.php'; } if (!class_exists('Smarty')) { return false; } // Load serendipity smarty class loading class if (!class_exists('Serendipity_Smarty')) { include 'serendipity_smarty_class.inc.php'; } if (!class_exists('Serendipity_Smarty')) { return false; } // set smarty instance #$serendipity['smarty'] = new Serendipity_Smarty; // initialize smarty object by instance $serendipity['smarty'] = Serendipity_Smarty::getInstance(); // debug moved to class // Hooray for Smarty: $_SESSION['no_smarty'] = $prev_smarty; // enable security policy by instance of the Smarty_Security class $serendipity['smarty']->enableSecurity('Serendipity_Smarty_Security_Policy'); // debugging... #echo '<pre>';print_r($serendipity['smarty']);echo '</pre>';#exit; #$serendipity['smarty']->testInstall();exit; /** * prüfe auf eventuelle API Änderungen in 3.2 [smarty_modifier_foobar, --> [smarty_modifier_foobar, smarty_function_foobar, smarty_block_foobar] (siehe class) ] * smarty_modifier_foobar(Smarty $smarty, $string, …) vs. smarty_modifier_foobar($string, …) **/ $serendipity['smarty']->registerPlugin('modifier', 'makeFilename', 'serendipity_makeFilename'); $serendipity['smarty']->registerPlugin('modifier', 'xhtml_target', 'serendipity_xhtml_target'); $serendipity['smarty']->registerPlugin('modifier', 'emptyPrefix', 'serendipity_emptyPrefix'); $serendipity['smarty']->registerPlugin('modifier', 'formatTime', 'serendipity_smarty_formatTime'); $serendipity['smarty']->registerPlugin('modifier', 'serendipity_utf8_encode', 'serendipity_utf8_encode'); $serendipity['smarty']->registerPlugin('modifier', 'ifRemember', 'serendipity_ifRemember'); $serendipity['smarty']->registerPlugin('modifier', 'checkPermission', 'serendipity_checkPermission'); $serendipity['smarty']->registerPlugin('modifier', 'serendipity_refhookPlugin', 'serendipity_smarty_refhookPlugin'); $serendipity['smarty']->registerPlugin('function', 'serendipity_printSidebar', 'serendipity_smarty_printSidebar'); $serendipity['smarty']->registerPlugin('function', 'serendipity_hookPlugin', 'serendipity_smarty_hookPlugin'); $serendipity['smarty']->registerPlugin('function', 'serendipity_showPlugin', 'serendipity_smarty_showPlugin'); $serendipity['smarty']->registerPlugin('function', 'serendipity_getFile', 'serendipity_smarty_getFile'); $serendipity['smarty']->registerPlugin('function', 'serendipity_printComments', 'serendipity_smarty_printComments'); $serendipity['smarty']->registerPlugin('function', 'serendipity_printTrackbacks', 'serendipity_smarty_printTrackbacks'); $serendipity['smarty']->registerPlugin('function', 'serendipity_rss_getguid', 'serendipity_smarty_rss_getguid'); $serendipity['smarty']->registerPlugin('function', 'serendipity_fetchPrintEntries', 'serendipity_smarty_fetchPrintEntries'); $serendipity['smarty']->registerPlugin('function', 'serendipity_getTotalCount', 'serendipity_smarty_getTotalCount'); $serendipity['smarty']->registerPlugin('function', 'pickKey', 'serendipity_smarty_pickKey'); $serendipity['smarty']->registerPlugin('function', 'serendipity_showCommentForm', 'serendipity_smarty_showCommentForm'); $serendipity['smarty']->registerPlugin('function', 'serendipity_getImageSize', 'serendipity_smarty_getImageSize'); $serendipity['smarty']->registerFilter('pre', 'serendipity_replaceSmartyVars'); } if (!isset($serendipity['smarty_raw_mode'])) { if (file_exists($serendipity['smarty']->getConfigDir(0) . '/layout.php') && $serendipity['template'] != 'default') { $serendipity['smarty_raw_mode'] = true; } else { $serendipity['smarty_raw_mode'] = false; } } if (!isset($serendipity['smarty_file'])) { $serendipity['smarty_file'] = 'index.tpl'; } $category = false; $category_info = array(); if (isset($serendipity['GET']['category'])) { $category = (int) $serendipity['GET']['category']; if (isset($GLOBALS['cInfo'])) { $category_info = $GLOBALS['cInfo']; } else { $category_info = serendipity_fetchCategoryInfo($category); } } if (!isset($serendipity['smarty_vars']['head_link_stylesheet'])) { $serendipity['smarty_vars']['head_link_stylesheet'] = serendipity_rewriteURL('serendipity.css'); } $serendipity['smarty']->assign(array('head_charset' => LANG_CHARSET, 'head_version' => $serendipity['version'], 'head_title' => $serendipity['head_title'], 'head_subtitle' => $serendipity['head_subtitle'], 'head_link_stylesheet' => $serendipity['smarty_vars']['head_link_stylesheet'], 'is_xhtml' => true, 'use_popups' => $serendipity['enablePopup'], 'is_embedded' => !$serendipity['embed'] || $serendipity['embed'] === 'false' || $serendipity['embed'] === false ? false : true, 'is_raw_mode' => $serendipity['smarty_raw_mode'], 'is_logged_in' => serendipity_userLoggedIn(), 'entry_id' => isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id']) ? $serendipity['GET']['id'] : false, 'is_single_entry' => isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id']), 'blogTitle' => $serendipity['blogTitle'], 'blogSubTitle' => !empty($serendipity['blogSubTitle']) ? $serendipity['blogSubTitle'] : '', 'blogDescription' => $serendipity['blogDescription'], 'serendipityHTTPPath' => $serendipity['serendipityHTTPPath'], 'serendipityDefaultBaseURL' => $serendipity['defaultBaseURL'], 'serendipityBaseURL' => $serendipity['baseURL'], 'serendipityRewritePrefix' => $serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '', 'serendipityIndexFile' => $serendipity['indexFile'], 'serendipityVersion' => $serendipity['expose_s9y'] ? $serendipity['version'] : '', 'lang' => $serendipity['lang'], 'category' => $category, 'category_info' => $category_info, 'template' => $serendipity['template'], 'dateRange' => !empty($serendipity['range']) ? $serendipity['range'] : array())); if (count($vars) > 0) { $serendipity['smarty']->assign($vars); } // For advanced usage, we allow template authors to create a file 'config.inc.php' where they can // setup custom smarty variables, modifiers etc. to use in their templates. @(include_once $serendipity['smarty']->getConfigDir(0) . '/config.inc.php'); if (is_array($template_loaded_config)) { $template_vars =& $template_loaded_config; $serendipity['smarty']->assignByRef('template_option', $template_vars); } elseif (is_array($template_config)) { $template_vars =& serendipity_loadThemeOptions($template_config, $serendipity['smarty_vars']['template_option']); $serendipity['smarty']->assignByRef('template_option', $template_vars); } } return true; }
# $Id: serendipity_admin.php 2510 2009-05-22 08:20:51Z garvinhicking $ # Copyright (c) 2003-2005, Jannis Hermanns (on behalf the Serendipity Developer Team) # All rights reserved. See LICENSE file for licensing details define('IN_installer', true); define('IN_upgrader', true); define('IN_serendipity', true); define('IN_serendipity_admin', true); include 'serendipity_config.inc.php'; header('Content-Type: text/html; charset=' . LANG_CHARSET); if (IS_installed === false) { require S9Y_INCLUDE_PATH . 'include/functions_permalinks.inc.php'; require S9Y_INCLUDE_PATH . 'include/functions_installer.inc.php'; require S9Y_INCLUDE_PATH . 'include/functions_config.inc.php'; $css_file = 'serendipity.css.php?serendipity[css_mode]=serendipity_admin.css'; } else { $css_file = serendipity_rewriteURL('serendipity_admin.css'); if (defined('IS_up2date') && IS_up2date === true) { serendipity_plugin_api::hook_event('backend_configure', $serendipity); } } if (isset($serendipity['GET']['adminModule']) && $serendipity['GET']['adminModule'] == 'logout') { serendipity_logout(); } else { if (IS_installed === true) { /* Check author token to insure session not hijacked */ if (!isset($_SESSION['author_token']) || !isset($serendipity['COOKIE']['author_token']) || $_SESSION['author_token'] !== $serendipity['COOKIE']['author_token']) { $_SESSION['serendipityAuthedUser'] = false; serendipity_session_destroy(); } if (!serendipity_userLoggedIn()) { // Try again to log in, this time with enabled external authentication event hook
function generate_content(&$title) { global $serendipity; $title = $this->get_config('title'); $iconURL = $this->get_config('iconURL', 'img/xml.gif'); if ($iconURL != 'none') { $small_icon = serendipity_getTemplateFile($iconURL); } $custom_feed = trim($this->get_config('feed_name')); $custom_comm = trim($this->get_config('comment_name')); $custom_img = trim($this->get_config('big_img', 'img/subtome.png')); if ($custom_img != 'none' && $custom_img != "feedburner") { $custom_img = serendipity_getTemplateFile($custom_img); } $subtome = serendipity_db_bool($this->get_config('subToMe', true)); $fbid = $this->get_config('fb_id'); $custom_url = serendipity_db_bool($this->get_config('custom_url', false)); $feed_format = $this->get_config('feed_format', 'rss'); $useRss = true; if ($feed_format == 'atom') { $useRss = false; $useAtom = true; } else { if ($feed_format == 'rssatom') { $useAtom = true; } } $img = 'http://feeds.feedburner.com/~fc/' . $this->get_config('fb_id') . '?bg=99CCFF&fg=444444&anim=0'; $icon = $small_icon; if (!empty($custom_img) && $custom_img != 'default' && $custom_img != 'none' && $custom_img != 'empty') { $icon = $custom_img; if ($fbid != "" && $custom_img == 'feedburner') { $icon = "http://feeds.feedburner.com/~fc/{$fbid}?bg=99CCFF&fg=444444&anim=0"; } if ($fbid == "" && $custom_img == 'feedburner') { $icon = serendipity_getTemplateFile('img/subtome.png'); } } if (empty($custom_feed) || $custom_feed == 'default' || $custom_feed == 'none' || $custom_feed == 'empty') { $FEED = 'Feed'; } else { $FEED = $custom_feed; } if (empty($custom_comm) || $custom_comm == 'default' || $custom_comm == 'none' || $custom_comm == 'empty') { $COMMENTS = COMMENTS; } else { $COMMENTS = $custom_comm; } if ($custom_url) { $mainFeed = serendipity_get_config_var('feedCustom'); } else { $mainFeed = serendipity_rewriteURL(PATH_FEEDS . '/index.rss2'); if ($fbid != "") { $mainFeed = 'http://feeds.feedburner.com/' . $fbid; } else { if ($useAtom && !$useRss) { $mainFeed = serendipity_rewriteURL(PATH_FEEDS . '/atom10.xml'); } } } $onclick = ""; if ($subtome) { $onclick = $this->getOnclick($mainFeed); } echo "\n" . '<ul id="serendipity_syndication_list" class="plainList">'; echo $this->generateFeedButton($mainFeed, $icon == $small_icon ? $useRss ? "RSS {$FEED}" : "Atom {$FEED}" : "", $onclick, $icon, $icon == $small_icon); if ($useRss && $useAtom) { echo $this->generateFeedButton(serendipity_rewriteURL(PATH_FEEDS . '/atom10.xml'), "Atom {$FEED}", $subtome ? $this->getOnclick(serendipity_rewriteURL(PATH_FEEDS . '/atom10.xml')) : "", $small_icon); } if (serendipity_db_bool($this->get_config('show_2.0c', false)) || serendipity_db_bool($this->get_config('show_comment_feed', false))) { echo $this->generateFeedButton($useAtom && !$useRss ? serendipity_rewriteURL(PATH_FEEDS . '/comments.atom') : serendipity_rewriteURL(PATH_FEEDS . '/comments.rss2'), $COMMENTS, $subtome ? $this->getOnclick(serendipity_rewriteURL(PATH_FEEDS . '/comments.rss2')) : "", $small_icon); } echo "</ul>\n"; }
function universal_setEntry(&$entry, &$tmp) { global $serendipity; $tmp = array('dateCreated' => new XML_RPC_Value(XML_RPC_iso8601_encode($entry['timestamp'], $serendipity['XMLRPC_GMT']) . ($serendipity['XMLRPC_GMT'] ? 'Z' : ''), 'dateTime.iso8601'), 'postid' => new XML_RPC_Value($entry['id'], 'string'), 'userid' => new XML_RPC_Value($entry['authorid'], 'string'), 'description' => new XML_RPC_Value($entry['body'], 'string'), 'mt_excerpt' => new XML_RPC_Value('', 'string'), 'mt_allow_comments' => new XML_RPC_Value(1, 'int'), 'mt_allow_pings' => new XML_RPC_Value(1, 'int'), 'mt_convert_breaks' => new XML_RPC_Value('', 'string'), 'mt_keywords' => new XML_RPC_Value('', 'string'), 'title' => new XML_RPC_Value($entry['title'], 'string'), 'permalink' => new XML_RPC_Value(serendipity_rewriteURL(PATH_ARCHIVES . '/' . $entry['id'] . '_.html', 'baseURL'), 'string'), 'link' => new XML_RPC_Value(serendipity_rewriteURL(PATH_ARCHIVES . '/' . $entry['id'] . '_.html', 'baseURL'), 'string')); return array_merge($entry, $tmp); }
<?php if (IN_serendipity !== true) { die("Don't hack!"); } @serendipity_plugin_api::load_language(dirname(__FILE__)); $serendipity['smarty']->assign('archiveURL', serendipity_rewriteURL(PATH_ARCHIVE)); // show elapsed time in words, such as x hours ago. function distanceOfTimeInWords($fromTime, $toTime = 0) { $distanceInSeconds = round(abs($toTime - $fromTime)); $distanceInMinutes = round($distanceInSeconds / 60); if ($distanceInMinutes <= 1) { if ($distanceInSeconds < 60) { return ELAPSED_LESS_THAN_MINUTE_AGO; } return ELAPSED_ONE_MINUTE_AGO; } if ($distanceInMinutes < 45) { return sprintf(ELAPSED_MINUTES_AGO, $distanceInMinutes); } if ($distanceInMinutes < 90) { return ELAPSED_ABOUT_ONE_HOUR_AGO; } // less than 24 hours if ($distanceInMinutes < 1440) { return sprintf(ELAPSED_HOURS_AGO, round(floatval($distanceInMinutes) / 60.0)); } //less than 48hours if ($distanceInMinutes < 2880) { return ELAPSED_ONE_DAY_AGO;
/** * Passes the list of fetched entries from serendipity_fetchEntries() on to the Smarty layer * * This function contains all the core logic to group and prepare entries to be shown in your * $entries.tpl template. It groups them by date, so that you can easily loop on the set of * entries. * This function is not only used for printing all entries, but also for printing individual * entries. * Several central Event hooks are executed here for the whole page flow, like header+footer data. * * @see serendipity_fetchEntries() * @see serendipity_searchEntries() * @access public * @param array The array of entries with all of its data * @param boolean Toggle whether the extended portion of an entry is requested (via $serendipity['GET']['id'] single entry view) * @param boolean Indicates if this is a preview * @param string The name of the SMARTY block that this gets parsed into * @param boolean Indicates whether the assigned smarty variables should be parsed. When set to "return", no smarty parsing is done. * @param boolean Indicates whether to apply footer/header event hooks * @param boolean Indicates whether the pagination footer should be displayed * @param mixed Indicates whether the input $entries array is already grouped in preparation for the smarty $entries output array [TRUE], or if it shall be grouped by date [FALSE] or if a plugin hook shall be executed to modify data ['plugin']. This setting can also be superseded by a 'entry_display' hook. * @return */ function serendipity_printEntries($entries, $extended = 0, $preview = false, $smarty_block = 'ENTRIES', $smarty_fetch = true, $use_hooks = true, $use_footer = true, $use_grouped_array = false) { global $serendipity; if ($use_hooks) { $addData = array('extended' => $extended, 'preview' => $preview); serendipity_plugin_api::hook_event('entry_display', $entries, $addData); if (isset($entries['clean_page']) && $entries['clean_page'] === true) { if ($serendipity['view'] == '404') { $serendipity['view'] = 'plugin'; } $serendipity['smarty']->assign(array('plugin_clean_page' => true, 'view' => $serendipity['view'])); serendipity_smarty_fetch($smarty_block, 'entries.tpl', true); return; // no display of this item } } // We shouldn't return here, because we want Smarty to handle the output if (!is_array($entries) || $entries[0] == false || !isset($entries[0]['timestamp'])) { $entries = array(); } // A plugin executed in entry_display should be able to change the way of ordering entries. Forward-Thinking. ;) if (isset($entries['use_grouped_array'])) { $use_grouped_array = $entries['use_grouped_array']; } if ($use_grouped_array === false) { // Use grouping by date (default) $dategroup = array(); for ($x = 0, $num_entries = count($entries); $x < $num_entries; $x++) { if (!empty($entries[$x]['properties']['ep_is_sticky']) && serendipity_db_bool($entries[$x]['properties']['ep_is_sticky'])) { $entries[$x]['is_sticky'] = true; $key = 'sticky'; } else { $key = date('Ymd', serendipity_serverOffsetHour($entries[$x]['timestamp'])); } $dategroup[$key]['date'] = $entries[$x]['timestamp']; $dategroup[$key]['is_sticky'] = isset($entries[$x]['is_sticky']) && serendipity_db_bool($entries[$x]['is_sticky']) ? true : false; $dategroup[$key]['entries'][] =& $entries[$x]; } } elseif ($use_grouped_array === 'plugin') { // Let a plugin do the grouping serendipity_plugin_api::hook_event('entry_groupdata', $entries); $dategroup =& $entries; } else { $dategroup =& $entries; } foreach ($dategroup as $dategroup_idx => $properties) { foreach ($properties['entries'] as $x => $_entry) { if ($smarty_fetch === 'return') { $entry =& $dategroup[$dategroup_idx]['entries'][$x]; // PHP4 Compat } else { // DISABLED - made problems with custom plugins // $entry = &$properties['entries'][$x]; // PHP4 Compat $entry =& $dategroup[$dategroup_idx]['entries'][$x]; // PHP4 Compat } if (!empty($entry['properties']['ep_cache_body'])) { $entry['body'] =& $entry['properties']['ep_cache_body']; $entry['is_cached'] = true; } //--JAM: Highlight-span search terms if ($serendipity['action'] == 'search') { $searchterms = str_replace('"', '', $serendipity['GET']['searchterms']); $searchterms = explode($searchterms, ' '); foreach ($searchterms as $searchdx => $searchterm) { $searchclass = "foundterm foundterm" . $searchdx; $entry['body'] = str_replace($searchterm, '<span class="' . $searchclass . '">' . $searchterm . '</span>', $entry['body']); } } if (!empty($entry['properties']['ep_cache_extended'])) { $entry['extended'] =& $entry['properties']['ep_cache_extended']; $entry['is_cached'] = true; } if ($preview) { $entry['author'] = $entry['realname']; $entry['authorid'] = $serendipity['authorid']; } $addData = array('from' => 'functions_entries:printEntries'); if ($entry['is_cached']) { $addData['no_scramble'] = true; } serendipity_plugin_api::hook_event('frontend_display', $entry, $addData); if ($preview) { $entry['author'] = $entry['realname']; $entry['authorid'] = $serendipity['authorid']; } $entry['author'] = htmlspecialchars($entry['author']); $authorData = array('authorid' => $entry['authorid'], 'username' => $entry['loginname'], 'email' => $entry['email'], 'realname' => $entry['author']); $entry['link'] = serendipity_archiveURL($entry['id'], $entry['title'], 'serendipityHTTPPath', true, array('timestamp' => $entry['timestamp'])); $entry['commURL'] = serendipity_archiveURL($entry['id'], $entry['title'], 'baseURL', false, array('timestamp' => $entry['timestamp'])); $entry['html_title'] = $entry['title']; $entry['title'] = htmlspecialchars($entry['title']); $entry['title_rdf'] = preg_replace('@-{2,}@', '-', $entry['html_title']); $entry['rdf_ident'] = serendipity_archiveURL($entry['id'], $entry['title_rdf'], 'baseURL', true, array('timestamp' => $entry['timestamp'])); $entry['link_rdf'] = serendipity_rewriteURL(PATH_FEEDS . '/ei_' . $entry['id'] . '.rdf'); $entry['title_rdf'] = htmlspecialchars($entry['title_rdf']); $entry['link_allow_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=enable&serendipity[entry]=' . $entry['id']; $entry['link_deny_comments'] = $serendipity['baseURL'] . 'comment.php?serendipity[switch]=disable&serendipity[entry]=' . $entry['id']; $entry['allow_comments'] = serendipity_db_bool($entry['allow_comments']); $entry['moderate_comments'] = serendipity_db_bool($entry['moderate_comments']); $entry['viewmode'] = $serendipity['GET']['cview'] == VIEWMODE_LINEAR ? VIEWMODE_LINEAR : VIEWMODE_THREADED; $entry['link_popup_comments'] = $serendipity['serendipityHTTPPath'] . 'comment.php?serendipity[entry_id]=' . $entry['id'] . '&serendipity[type]=comments'; $entry['link_popup_trackbacks'] = $serendipity['serendipityHTTPPath'] . 'comment.php?serendipity[entry_id]=' . $entry['id'] . '&serendipity[type]=trackbacks'; $entry['link_edit'] = $serendipity['baseURL'] . 'serendipity_admin.php?serendipity[action]=admin&serendipity[adminModule]=entries&serendipity[adminAction]=edit&serendipity[id]=' . $entry['id']; $entry['link_trackback'] = $serendipity['baseURL'] . 'comment.php?type=trackback&entry_id=' . $entry['id']; $entry['link_viewmode_threaded'] = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'] . '&serendipity[cview]=' . VIEWMODE_THREADED; $entry['link_viewmode_linear'] = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'] . '&serendipity[cview]=' . VIEWMODE_LINEAR; $entry['link_author'] = serendipity_authorURL($authorData); if (is_array($entry['categories'])) { foreach ($entry['categories'] as $k => $v) { if (!isset($entry['categories'][$k]['category_link'])) { $entry['categories'][$k]['category_link'] = serendipity_categoryURL($entry['categories'][$k]); } } } if (strlen($entry['extended'])) { $entry['has_extended'] = true; } if (isset($entry['exflag']) && $entry['exflag'] && ($extended || $preview)) { $entry['is_extended'] = true; } if (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['comments'] > 0) { $entry['has_comments'] = true; $entry['label_comments'] = $entry['comments'] == 1 ? COMMENT : COMMENTS; } if (serendipity_db_bool($entry['allow_comments']) || !isset($entry['allow_comments']) || $entry['trackbacks'] > 0) { $entry['has_trackbacks'] = true; $entry['label_trackbacks'] = $entry['trackbacks'] == 1 ? TRACKBACK : TRACKBACKS; } if ($_SESSION['serendipityAuthedUser'] === true && ($_SESSION['serendipityAuthorid'] == $entry['authorid'] || serendipity_checkPermission('adminEntriesMaintainOthers'))) { $entry['is_entry_owner'] = true; } $entry['display_dat'] = ''; serendipity_plugin_api::hook_event('frontend_display:html:per_entry', $entry); $entry['plugin_display_dat'] =& $entry['display_dat']; if ($preview) { ob_start(); serendipity_plugin_api::hook_event('backend_preview', $entry); $entry['backend_preview'] = ob_get_contents(); ob_end_clean(); } /* IF WE ARE DISPLAYING A FULL ENTRY */ if (isset($serendipity['GET']['id'])) { $comment_add_data = array('comments_messagestack' => isset($serendipity['messagestack']['comments']) ? (array) $serendipity['messagestack']['comments'] : array(), 'is_comment_added' => isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'true' ? true : false, 'is_comment_moderate' => isset($serendipity['GET']['csuccess']) && $serendipity['GET']['csuccess'] == 'moderate' ? true : false); $serendipity['smarty']->assign($comment_add_data); serendipity_displayCommentForm($entry['id'], $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?url=' . $entry['commURL'], true, $serendipity['POST'], true, serendipity_db_bool($entry['moderate_comments']), $entry); } // END FULL ENTRY LOGIC } // end foreach-loop (entries) } // end foreach-loop (dates) if (!isset($serendipity['GET']['id']) && (!isset($serendipity['hidefooter']) || $serendipity['hidefooter'] == false) && $num_entries <= $serendipity['fetchLimit'] && $use_footer) { serendipity_printEntryFooter(); } if ($smarty_fetch === 'return') { return $dategroup; } $serendipity['smarty']->assign_by_ref('entries', $dategroup); unset($entries, $dategroup); if (isset($serendipity['short_archives']) && $serendipity['short_archives']) { serendipity_smarty_fetch($smarty_block, 'entries_summary.tpl', true); } elseif ($smarty_fetch == true) { serendipity_smarty_fetch($smarty_block, 'entries.tpl', true); } }
serendipity_smarty_init(); if (empty($serendipity['GET']['step']) && $serendipity['GET']['page'] < 1) { $media = array('GET_STRING' => serendipity_build_query($_GET), 'frameset' => true); $serendipity['smarty']->assign_by_ref('media', $media); $serendipity['smarty']->display(serendipity_getTemplateFile('admin/media_choose.tpl', 'serendipityPath')); return; } $import_vars = $serendipity['GET']; unset($import_vars['step']); unset($import_vars['only_path']); $showFile = 'admin/media_choose.tpl'; $body_id = 'serendipityAdminBodyImageSelector'; if ($serendipity['GET']['step'] === 'tree') { $body_id = 'serendipityAdminBodyImageSelectorTree'; } $media = array('body_id' => $body_id, 'only_path' => $serendipity['GET']['only_path'], 'css' => serendipity_rewriteURL('serendipity_admin.css'), 'css_tree' => serendipity_getTemplateFile('treeview/tree.css'), 'css_front' => serendipity_rewriteURL('serendipity.css'), 'token_url' => serendipity_setFormToken('url'), 'imgID' => (int) $serendipity['GET']['image'], 'from' => $serendipity['GET']['from'], 'GET_STRING' => serendipity_build_query($import_vars, 'serendipity', '&'), 'paths' => serendipity_getMediaPaths()); switch ($serendipity['GET']['step']) { case '1': if (isset($serendipity['GET']['adminAction'])) { // Embedded upload form if (!empty($serendipity['POST']['textarea'])) { $serendipity['GET']['textarea'] = $serendipity['POST']['textarea']; } if (!empty($serendipity['POST']['htmltarget'])) { $serendipity['GET']['htmltarget'] = $serendipity['POST']['htmltarget']; } if (!empty($serendipity['POST']['filename_only'])) { $serendipity['GET']['filename_only'] = $serendipity['POST']['filename_only']; } $image_selector_addvars = array('step' => 1, 'textarea' => !empty($serendipity['GET']['textarea']) ? $serendipity['GET']['textarea'] : '', 'htmltarget' => !empty($serendipity['GET']['htmltarget']) ? $serendipity['GET']['htmltarget'] : '', 'filename_only' => !empty($serendipity['GET']['filename_only']) ? $serendipity['GET']['filename_only'] : ''); switch ($serendipity['GET']['adminAction']) {
/** * Send a comment notice to the admin/author of an entry * * @access public * @param int ID of the comment that has been made * @param string Author's email address to send the mail to * @param string The name of the sender * @param string The URL of the sender * @param int The ID of the entry that has been commented * @param string The title of the entry that has been commented * @param string The text of the comment * @param string The type of the comment (normal|trackback) * @param boolean Toggle Whether comments to this entry need approval * @return boolean Return success of sending the mails */ function serendipity_sendComment($comment_id, $to, $fromName, $fromEmail, $fromUrl, $id, $title, $comment, $type = 'NORMAL', $moderate_comment = false) { global $serendipity; if (empty($fromName)) { $fromName = ANONYMOUS; } $entryURI = serendipity_archiveURL($id, $title, 'baseURL'); $path = $type == 'TRACKBACK' ? 'trackback' : 'comment'; // Check for using Tokens if ($serendipity['useCommentTokens']) { $token = md5(uniqid(rand(), 1)); $path = $path . "_token_" . $token; //Delete any comment tokens older than 1 week. serendipity_db_query("DELETE FROM {$serendipity['dbPrefix']}options\n WHERE okey LIKE 'comment_%' AND name < " . (time() - 604800)); // Issue new comment moderation hash serendipity_db_query("INSERT INTO {$serendipity['dbPrefix']}options (name, value, okey)\n VALUES ('" . time() . "', '" . $token . "', 'comment_" . $comment_id . "')"); } $deleteURI = serendipity_rewriteURL(PATH_DELETE . '/' . $path . '/' . $comment_id . '/' . $id . '-' . serendipity_makeFilename($title) . '.html', 'baseURL'); $approveURI = serendipity_rewriteURL(PATH_APPROVE . '/' . $path . '/' . $comment_id . '/' . $id . '-' . serendipity_makeFilename($title) . '.html', 'baseURL'); if ($type == 'TRACKBACK') { /******************* TRACKBACKS *******************/ $subject = ($moderate_comment ? '[' . REQUIRES_REVIEW . '] ' : '') . NEW_TRACKBACK_TO . ' ' . $title; $text = sprintf(A_NEW_TRACKBACK_BLAHBLAH, $title) . "\n" . "\n" . REQUIRES_REVIEW . ': ' . ($moderate_comment ? YES : NO) . (isset($serendipity['moderate_reason']) ? ' (' . $serendipity['moderate_reason'] . ')' : '') . "\n" . LINK_TO_ENTRY . ': ' . $entryURI . "\n" . 'Weblog ' . NAME . ': ' . stripslashes($fromName) . "\n" . LINK_TO_REMOTE_ENTRY . ': ' . $fromUrl . "\n" . "\n" . EXCERPT . ':' . "\n" . strip_tags($comment) . "\n" . "\n" . '----' . "\n" . YOU_HAVE_THESE_OPTIONS . ($moderate_comment ? "\n" . str_repeat(' ', 2) . THIS_TRACKBACK_NEEDS_REVIEW : '') . "\n" . str_repeat(' ', 3) . str_pad(VIEW_ENTRY, 15) . ' -- ' . $entryURI . "\n" . str_repeat(' ', 3) . str_pad(DELETE_TRACKBACK, 15) . ' -- ' . $deleteURI . ($moderate_comment ? "\n" . str_repeat(' ', 3) . str_pad(APPROVE_TRACKBACK, 15) . ' -- ' . $approveURI : ''); } else { /******************* COMMENTS *********************/ $subject = ($moderate_comment ? '[' . REQUIRES_REVIEW . '] ' : '') . NEW_COMMENT_TO . ' ' . $title; $text = sprintf(A_NEW_COMMENT_BLAHBLAH, $serendipity['blogTitle'], $title) . "\n" . LINK_TO_ENTRY . ': ' . $entryURI . "\n" . "\n" . REQUIRES_REVIEW . ': ' . ($moderate_comment ? YES : NO) . (isset($serendipity['moderate_reason']) ? ' (' . $serendipity['moderate_reason'] . ')' : '') . "\n" . USER . ' ' . IP_ADDRESS . ': ' . $_SERVER['REMOTE_ADDR'] . "\n" . USER . ' ' . NAME . ': ' . $fromName . "\n" . USER . ' ' . EMAIL . ': ' . $fromEmail . "\n" . USER . ' ' . HOMEPAGE . ': ' . $fromUrl . "\n" . "\n" . COMMENTS . ': ' . "\n" . strip_tags($comment) . "\n" . "\n" . '----' . "\n" . YOU_HAVE_THESE_OPTIONS . ($moderate_comment ? "\n" . str_repeat(' ', 2) . THIS_COMMENT_NEEDS_REVIEW : '') . "\n" . str_repeat(' ', 3) . str_pad(VIEW_COMMENT, 15) . ' -- ' . $entryURI . '#c' . $comment_id . "\n" . str_repeat(' ', 3) . str_pad(DELETE_COMMENT, 15) . ' -- ' . $deleteURI . ($moderate_comment ? "\n" . str_repeat(' ', 3) . str_pad(APPROVE_COMMENT, 15) . ' -- ' . $approveURI : ''); } return serendipity_sendMail($to, $subject, $text, $fromEmail, null, $fromName); }
/** * Initialize the Smarty framework for use in Serendipity * * @access public * @return null */ function serendipity_smarty_init($vars = array()) { global $serendipity, $template_config; if (!isset($serendipity['smarty'])) { $template_dir = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template']; if (!defined('IN_serendipity_admin') && file_exists($template_dir . '/template.inc.php')) { // If this file exists, a custom template engine will be loaded. // Beware: Smarty is used in the Admin backend, despite of this. include $template_dir . '/template.inc.php'; } else { // Set a session variable if Smarty fails: $prev_smarty = $_SESSION['no_smarty']; $_SESSION['no_smarty'] = true; // Default Smarty Engine will be used @define('SMARTY_DIR', S9Y_PEAR_PATH . 'Smarty/libs/'); if (!class_exists('Smarty')) { include SMARTY_DIR . 'Smarty.class.php'; } if (!class_exists('Smarty')) { return false; } $serendipity['smarty'] = new Smarty(); if ($serendipity['production'] === 'debug') { $serendipity['smarty']->force_compile = true; $serendipity['smarty']->debugging = true; } $serendipity['smarty']->template_dir = array($template_dir); $p = explode(',', $serendipity['template_engine']); foreach ($p as $te) { $serendipity['smarty']->template_dir[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $te; } $serendipity['smarty']->template_dir[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . 'default'; $serendipity['smarty']->compile_dir = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE; if (!is_dir($serendipity['smarty']->compile_dir) || !is_writable($serendipity['smarty']->compile_dir)) { printf(DIRECTORY_WRITE_ERROR, $serendipity['smarty']->compile_dir); return false; } // Hooray for Smarty: $_SESSION['no_smarty'] = $prev_smarty; $serendipity['smarty']->config_dir = $template_dir; $serendipity['smarty']->secure_dir = array($serendipity['serendipityPath'] . $serendipity['templatePath']); $serendipity['smarty']->security_settings['MODIFIER_FUNCS'] = array('sprintf', 'sizeof', 'count', 'rand', 'print_r', 'str_repeat'); $serendipity['smarty']->security_settings['ALLOW_CONSTANTS'] = true; $serendipity['smarty']->security = true; $serendipity['smarty']->use_sub_dirs = false; $serendipity['smarty']->compile_check = true; $serendipity['smarty']->compile_id =& $serendipity['template']; $serendipity['smarty']->register_modifier('makeFilename', 'serendipity_makeFilename'); $serendipity['smarty']->register_modifier('xhtml_target', 'serendipity_xhtml_target'); $serendipity['smarty']->register_modifier('emptyPrefix', 'serendipity_emptyPrefix'); $serendipity['smarty']->register_modifier('formatTime', 'serendipity_smarty_formatTime'); $serendipity['smarty']->register_modifier('serendipity_utf8_encode', 'serendipity_utf8_encode'); $serendipity['smarty']->register_modifier('ifRemember', 'serendipity_ifRemember'); $serendipity['smarty']->register_modifier('checkPermission', 'serendipity_checkPermission'); $serendipity['smarty']->register_modifier('serendipity_refhookPlugin', 'serendipity_smarty_refhookPlugin'); $serendipity['smarty']->register_function('serendipity_printSidebar', 'serendipity_smarty_printSidebar'); $serendipity['smarty']->register_function('serendipity_hookPlugin', 'serendipity_smarty_hookPlugin'); $serendipity['smarty']->register_function('serendipity_showPlugin', 'serendipity_smarty_showPlugin'); $serendipity['smarty']->register_function('serendipity_getFile', 'serendipity_smarty_getFile'); $serendipity['smarty']->register_function('serendipity_printComments', 'serendipity_smarty_printComments'); $serendipity['smarty']->register_function('serendipity_printTrackbacks', 'serendipity_smarty_printTrackbacks'); $serendipity['smarty']->register_function('serendipity_rss_getguid', 'serendipity_smarty_rss_getguid'); $serendipity['smarty']->register_function('serendipity_fetchPrintEntries', 'serendipity_smarty_fetchPrintEntries'); $serendipity['smarty']->register_function('serendipity_getTotalCount', 'serendipity_smarty_getTotalCount'); $serendipity['smarty']->register_function('pickKey', 'serendipity_smarty_pickKey'); $serendipity['smarty']->register_function('serendipity_showCommentForm', 'serendipity_smarty_showCommentForm'); $serendipity['smarty']->register_function('serendipity_getImageSize', 'serendipity_smarty_getImageSize'); $serendipity['smarty']->register_prefilter('serendipity_replaceSmartyVars'); } if (!isset($serendipity['smarty_raw_mode'])) { if (file_exists($serendipity['smarty']->config_dir . '/layout.php') && $serendipity['template'] != 'default') { $serendipity['smarty_raw_mode'] = true; } else { $serendipity['smarty_raw_mode'] = false; } } if (!isset($serendipity['smarty_file'])) { $serendipity['smarty_file'] = 'index.tpl'; } $category = false; $category_info = array(); if (isset($serendipity['GET']['category'])) { $category = (int) $serendipity['GET']['category']; if (isset($GLOBALS['cInfo'])) { $category_info = $GLOBALS['cInfo']; } else { $category_info = serendipity_fetchCategoryInfo($category); } } if (!isset($serendipity['smarty_vars']['head_link_stylesheet'])) { $serendipity['smarty_vars']['head_link_stylesheet'] = serendipity_rewriteURL('serendipity.css'); } $serendipity['smarty']->assign(array('head_charset' => LANG_CHARSET, 'head_version' => $serendipity['version'], 'head_title' => $serendipity['head_title'], 'head_subtitle' => $serendipity['head_subtitle'], 'head_link_stylesheet' => $serendipity['smarty_vars']['head_link_stylesheet'], 'is_xhtml' => true, 'use_popups' => $serendipity['enablePopup'], 'is_embedded' => !$serendipity['embed'] || $serendipity['embed'] === 'false' || $serendipity['embed'] === false ? false : true, 'is_raw_mode' => $serendipity['smarty_raw_mode'], 'is_logged_in' => serendipity_userLoggedIn(), 'entry_id' => isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id']) ? $serendipity['GET']['id'] : false, 'is_single_entry' => isset($serendipity['GET']['id']) && is_numeric($serendipity['GET']['id']), 'blogTitle' => $serendipity['blogTitle'], 'blogSubTitle' => !empty($serendipity['blogSubTitle']) ? $serendipity['blogSubTitle'] : '', 'blogDescription' => $serendipity['blogDescription'], 'serendipityHTTPPath' => $serendipity['serendipityHTTPPath'], 'serendipityBaseURL' => $serendipity['baseURL'], 'serendipityRewritePrefix' => $serendipity['rewrite'] == 'none' ? $serendipity['indexFile'] . '?/' : '', 'serendipityIndexFile' => $serendipity['indexFile'], 'serendipityVersion' => $serendipity['expose_s9y'] ? $serendipity['version'] : '', 'lang' => $serendipity['lang'], 'category' => $category, 'category_info' => $category_info, 'template' => $serendipity['template'], 'dateRange' => !empty($serendipity['range']) ? $serendipity['range'] : array())); if (count($vars) > 0) { $serendipity['smarty']->assign($vars); } // For advanced usage, we allow template authors to create a file 'config.inc.php' where they can // setup custom smarty variables, modifiers etc. to use in their templates. @(include_once $serendipity['smarty']->config_dir . '/config.inc.php'); if (is_array($template_loaded_config)) { $template_vars =& $template_loaded_config; $serendipity['smarty']->assign_by_ref('template_option', $template_vars); } elseif (is_array($template_config)) { $template_vars =& serendipity_loadThemeOptions($template_config, $serendipity['smarty_vars']['template_option']); $serendipity['smarty']->assign_by_ref('template_option', $template_vars); } } return true; }