function serendipity_smarty_getConfigVar($params, &$smarty)
{
    if (!isset($params['key'])) {
        trigger_error("Smarty Error: " . __FUNCTION__ . ": missing 'key' parameter", E_USER_WARNING);
        return;
    }
    return serendipity_get_config_var($params['key']);
}
 function get_config($name, $defaultvalue = null, $empty = true)
 {
     $_res = serendipity_get_config_var($this->instance . '/' . $name, '', $empty);
     if (is_null($_res)) {
         // A protected plugin by a specific owner may not have its values stored in $serendipity
         // because of the special authorid. To display such contents, we need to fetch it
         // seperately from the DB.
         $_res = serendipity_get_user_config_var($this->instance . '/' . $name, null, '');
     }
     if (is_null($_res)) {
         return '';
     }
     return $_res;
 }
 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->title;
     // get local configuration (default, true, false)
     $use_links = $this->get_config('use_links', 'default');
     // get global configuration (true, false)
     $global_use_link = serendipity_get_config_var('top_as_links', false, true);
     // if local configuration say to use global default, do so
     if ($use_links === 'default') {
         $use_links = serendipity_db_bool($global_use_link);
     } else {
         $use_links = serendipity_db_bool($use_links);
     }
     echo serendipity_displayTopReferrers($this->get_config('limit', 10), $use_links, $this->get_config('interval', 7));
 }
 function generate_content(&$title)
 {
     global $serendipity;
     $title = $this->get_config('title', $this->title);
     $url = serendipity_currentURL(true);
     echo '<form id="theme_chooser" action="' . $url . '" method="post">';
     echo '<select name="user_template" onchange="document.getElementById(\'theme_chooser\').submit();">';
     foreach (serendipity_fetchTemplates() as $template) {
         $templateInfo = serendipity_fetchTemplateInfo($template);
         echo '<option value="' . $template . '" ' . (serendipity_get_config_var('template', 'default') == $template ? 'selected="selected"' : '') . '>' . substr($templateInfo['name'], 0, 25) . '</option>';
     }
     echo '</select>';
     if ($this->get_config('show_submit', 'false') == 'true') {
         echo '<input type="submit" name="submit" value="' . GO . '" size="4" />';
     }
     echo '</form>';
 }
 /**
  * Get a config value of the plugin
  *
  * @access public
  * @param   string  Name of the config value to fetch
  * @param   mixed   The default value of a configuration item, if not set
  * @param   boolean If true, the default value will only be set if the plugin config item was not set.
  * @return  mixed   The value of the config item
  */
 function get_config($name, $defaultvalue = null, $empty = true)
 {
     $_res = serendipity_get_config_var($this->instance . '/' . $name, $defaultvalue, $empty);
     if (is_null($_res)) {
         // A protected plugin by a specific owner may not have its values stored in $serendipity
         // because of the special authorid. To display such contents, we need to fetch it
         // seperately from the DB.
         $_res = serendipity_get_user_config_var($this->instance . '/' . $name, null, $defaultvalue);
     }
     if (is_null($_res)) {
         $cbag = new serendipity_property_bag();
         $this->introspect_config_item($name, $cbag);
         $_res = $cbag->get('default');
         unset($cbag);
         // Set the fetched value, so the default will not be fetched the next config call time
         $this->set_config($name, $_res);
     }
     return $_res;
 }
 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&amp;fg=444444&amp;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&amp;fg=444444&amp;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";
 }
/**
 * baseURL is now defaultBaseURL in the database, so copy if not already set
 *
 * */
function serendipity_copyBaseURL()
{
    global $serendipity;
    if ((serendipity_get_config_var("defaultBaseURL") === false || serendipity_get_config_var("defaultBaseURL") == "") && serendipity_get_config_var("baseURL") !== false) {
        serendipity_set_config_var("defaultBaseURL", serendipity_get_config_var("baseURL"));
    }
}
Example #8
0
    }
}
$metadata['fullFeed'] = serendipity_get_config_var('feedFull', false);
if ($metadata['fullFeed'] === 'client') {
    if ($_GET['fullFeed'] || $serendipity['GET']['fullFeed']) {
        $metadata['fullFeed'] = true;
    } else {
        $metadata['fullFeed'] = false;
    }
}
if ($_GET['type'] == 'content' && !isset($_GET['category']) && !isset($serendipity['GET']['tag']) && serendipity_db_bool(serendipity_get_config_var('feedForceCustom', false)) && !preg_match('@FeedBurn@i', $_SERVER['HTTP_USER_AGENT']) && !isset($_GET['forceLocal'])) {
    header('Status: 302 Found');
    header('Location: ' . serendipity_get_config_var('feedCustom'));
    exit;
}
$metadata['showMail'] = serendipity_db_bool(serendipity_get_config_var('show_mail', $metadata['showMail']));
$file_version = preg_replace('@[^0-9a-z\\.-_]@i', '', $version);
$metadata['template_file'] = 'feed_' . $file_version . '.tpl';
serendipity_smarty_init();
serendipity_plugin_api::hook_event('frontend_rss', $metadata);
$self_url = ($_SERVER['HTTPS'] == 'on' ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . serendipity_specialchars($_SERVER['REQUEST_URI']);
if (!is_array($entries)) {
    $entries = array();
}
if ($entries[0]['last_modified']) {
    $gm_modified = gmdate('Y-m-d\\TH:i:s\\Z', serendipity_serverOffsetHour($entries[0]['last_modified']));
} else {
    $gm_modified = gmdate('Y-m-d\\TH:i:s\\Z', serendipity_serverOffsetHour());
}
serendipity_printEntries_rss($entries, $version, $comments, $metadata['fullFeed'], $metadata['showMail']);
$namespace_hook = 'frontend_display:unknown:namespace';
 private function setParams()
 {
     global $serendipity;
     // some documentary from the smarty forum
     /*
        Adressing a specific $template_dir (see 3.1 release notes)
     
        Smarty 3.1 introduces the $template_dir index notation.
        $smarty->fetch('[foo]bar.tpl') and {include file="[foo]bar.tpl"} require the template bar.tpl to be loaded from $template_dir['foo'];
        Smarty::setTemplateDir() and Smarty::addTemplateDir() offer ways to define indexes along with the actual directories.
     */
     /*  +++++++++++++++++++++++++++++++++++++++++++
            Set all directory setters
            Smarty will always use the first template found in order of the given array. Move the least significant directory to the end.
         */
     $template_engine = serendipity_get_config_var('template_engine');
     $template_dirs = array();
     if ($template_engine) {
         $p = explode(',', $template_engine);
         foreach ($p as $te) {
             $template_dirs[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . trim($te) . '/';
         }
     } else {
         // this is tested without need actually, but it makes the directory setter fallback chain a little more precise
         $template_dirs[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'];
     }
     $template_dirs[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['defaultTemplate'];
     $template_dirs[] = $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template_backend'];
     // add secure dir to template path, in case engine did have entries
     if (S9Y_TEMPLATE_SECUREDIR != $serendipity['serendipityPath'] . $serendipity['templatePath']) {
         $template_dirs[] = S9Y_TEMPLATE_SECUREDIR;
     }
     // disable plugin dir as added template dir is not adviced, if set security is enabled (backend & frontend need access to fetch plugin templates)
     $template_dirs[] = $serendipity['serendipityPath'] . 'plugins';
     // add default template to addTemplate array, if not already set in engine
     $template_dirs[] = S9Y_TEMPLATE_FALLBACK;
     $this->setTemplateDir($template_dirs);
     if (defined('S9Y_DATA_PATH')) {
         $this->setCompileDir(S9Y_DATA_PATH . PATH_SMARTY_COMPILE);
     } else {
         $this->setCompileDir($serendipity['serendipityPath'] . PATH_SMARTY_COMPILE);
     }
     $this->setConfigDir(array(S9Y_TEMPLATE_USERDEFAULT));
     if ((!is_dir($this->getCompileDir()) || !is_writable($this->getCompileDir())) && IN_installer !== true) {
         if (ini_get('display_errors') == 0 || ini_get('display_errors') == 'off') {
             printf(DIRECTORY_WRITE_ERROR, $this->getCompileDir());
         }
         trigger_error(sprintf(DIRECTORY_WRITE_ERROR, $this->getCompileDir()), E_USER_ERROR);
     }
     /*
         here we go with our other Smarty class properties, which can all be called by their property name (recommended)
         $smarty->use_sub_dirs = true; or by $smarty->setUseSubDirs(true); and echo $smarty->getUseSubDirs();
         as the latter's would run through an internal __call() wrapper function.
         Note: rodneyrehm - From within the Smarty class context you can safely access properties like Smarty::$use_sub_dirs directly.
     */
     /*  +++++++++++++++++++++++++++++++++++
             Set Smarty caching - outsourced to README_SMARTY_CACHING_PURPOSES.txt
             Not usable in Serendipity with current template structure!
         */
     /*  ++++++++++++++++++++++++++++++++++++++++++++++
             Set all other needed Smarty class properties
         */
     #$this->merge_compiled_includes = true; // $this->setMergeCompiledIncludes(true);  // With this option the subtemplate code is stored together with the calling template.
     // default here to be overwritten by $serendipity['production'] == 'debug' - see below!
     $this->debugging = false;
     // $this->setDebugging(false);
     // Smarty will create subdirectories under the compiled templates and cache directories if $use_sub_dirs is set to TRUE, default is FALSE.
     $this->use_sub_dirs = ini_get('safe_mode') ? false : true;
     // $this->setUseSubDirs(false); // cache and compile dir only
     // Smarty should update the cache files automatically if $smarty->compile_check is true.
     $this->compile_check = true;
     // $this->setCompileCheck(true);
     #$this->compile_check = COMPILECHECK_OFF (false) - template files will not be checked
     #$this->compile_check = COMPILECHECK_ON (true)   - template files will always be checked
     #$this->compile_check = COMPILECHECK_CACHEMISS   - template files will be checked, if caching is enabled and there is no existing cache file, or it has expired
     /*
         Note: rodneyrehm
         If you actually manage to build a page from a single template (with inclusions and plugins and stuff)
         in a way that allows smarty to do 304 handling - or implement the serve-stale-while-update approach,
         you should go with CACHEMISS.
     */
     $this->compile_id =& $serendipity['template'];
     // $this->setCompileId(&$serendipity['template'])
     /*
         Note: rodneyrehm
         Please only specify the compile_id if you really need to.
         That means if you pre-process templates for say internationalization.
         Otherwise you don't need this and are better off ignoring it (performance-wise).
     */
     $this->config_overwrite = true;
     // $this->setConfigOverwrite(true);
     // production == debug extends from s9y version information (alpha|beta|cvs) is always debug | USE ===
     if ($serendipity['production'] === 'debug') {
         $this->force_compile = true;
         // $this->setForceCompile(true);
         $this->caching = false;
         // $this->setCaching(false);
         $this->debugging = true;
         // $this->setDebugging(true);
     }
     // set smarty error reporting. General error_reporting is set in serendipity/serendipity_config.inc.php
     $this->error_reporting = E_ALL & ~(E_NOTICE | E_STRICT);
     // we use our own error_handler and get in conflicts with smarty?
     // $this->muteExpectedErrors();
 }