/** * Echo Javascript code to set a cookie variable * * This function is useful if your HTTP headers were already sent, but you still want to set a cookie * Note that contents are echo'd, not return'd. Can be used by plugins. * * @access public * @param string The name of the cookie variable * @param string The contents of the cookie variable * @return null */ function serendipity_JSsetCookie($name, $value) { $name = serendipity_entities($name); $value = urlencode($value); echo '<script type="text/javascript">serendipity.SetCookie("' . $name . '", unescape("' . $value . '"))</script>' . "\n"; }
/** * Get a list of Sidebar plugins and pass them to Smarty * * @access public * @param string The side of plugins to show (left/right/hide/event/eventh) * @param string deprecated: Indicated which wrapping HTML element to use for plugins * @param boolean Indicates whether only all plugins should be shown that are not in the $side list * @param string Only show plugins of this plugin class * @param string Only show a plugin with this instance ID * @return string Smarty HTML output */ static function generate_plugins($side, $negate = false, $class = null, $id = null, $tpl = 'sidebar.tpl') { global $serendipity; $plugins = serendipity_plugin_api::enum_plugins($side, $negate, $class, $id); if (!is_array($plugins)) { return; } if (!isset($serendipity['smarty'])) { $serendipity['smarty_raw_mode'] = true; serendipity_smarty_init(); } $pluginData = array(); $addData = func_get_args(); serendipity_plugin_api::hook_event('frontend_generate_plugins', $plugins, $addData); if (count($plugins) == 0) { $serendipity['prevent_sidebar_plugins_' . $side] = true; } $loggedin = false; if (serendipity_userLoggedIn() && serendipity_checkPermission('adminPlugins')) { $loggedin = true; } foreach ($plugins as $plugin_data) { $plugin =& serendipity_plugin_api::load_plugin($plugin_data['name'], $plugin_data['authorid'], $plugin_data['path']); if (is_object($plugin)) { $class = get_class($plugin); $title = ''; /* TODO: make generate_content NOT echo its output */ ob_start(); $show_plugin = $plugin->generate_content($title); $content = ob_get_contents(); ob_end_clean(); if ($loggedin) { $content .= '<div class="serendipity_edit_nugget"><a href="' . $serendipity['serendipityHTTPPath'] . 'serendipity_admin.php?serendipity[adminModule]=plugins&serendipity[plugin_to_conf]=' . serendipity_entities($plugin->instance) . '">' . EDIT . '</a></div>'; } if ($show_plugin !== false) { $pluginData[] = array('side' => $side, 'class' => $class, 'title' => $title, 'content' => $content, 'id' => $plugin->instance); } } else { $pluginData[] = array('side' => $side, 'title' => ERROR, 'class' => $class, 'content' => sprintf(INCLUDE_ERROR, $plugin_data['name'])); } } serendipity_plugin_api::hook_event('frontend_sidebar_plugins', $pluginData, $addData); $serendipity['smarty']->assignByRef('plugindata', $pluginData); $serendipity['smarty']->assign('pluginside', ucfirst($side)); return serendipity_smarty_fetch('sidebar_' . $side, $tpl, true); }