本文整理汇总了PHP中serendipity_smarty_init函数的典型用法代码示例。如果您正苦于以下问题:PHP serendipity_smarty_init函数的具体用法?PHP serendipity_smarty_init怎么用?PHP serendipity_smarty_init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了serendipity_smarty_init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchTemplate
static function fetchTemplate($filename, $oembed, $url)
{
global $serendipity;
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
// Declare the oembed to smarty
$serendipity['smarty']->assign('oembedurl', $url);
$serendipity['smarty']->assign('oembed', (array) $oembed);
$tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
if (!$tfile || $filename == $tfile) {
$tfile = dirname(__FILE__) . '/' . $filename;
}
$inclusion = $serendipity['smarty']->security_settings[@INCLUDE_ANY];
$serendipity['smarty']->security_settings[@INCLUDE_ANY] = true;
if (version_compare($serendipity['version'], '1.7-alpha1') >= 0) {
$serendipity['smarty']->disableSecurity();
}
/* in earlier versions this is not needed.
else {
$serendipity['smarty']->security = false;
}
*/
// be smarty 3 compat including the serendipity_smarty class wrappers ->fetch and ->display methods and remove changed parameter number 4
$content = @$serendipity['smarty']->fetch('file:' . $tfile);
//, false
$serendipity['smarty']->security_settings[@INCLUDE_ANY] = $inclusion;
return $content;
}
示例2: show
function show()
{
global $serendipity;
if ($serendipity['GET']['page'] == 'thumbs') {
$title = '';
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
$_ENV['staticpage_pagetitle'] = 'thumbs';
$serendipity['smarty']->assign('staticpage_pagetitle', 'thumbs');
$this->generate_content($title);
}
}
示例3: smartymarkup
function smartymarkup($input, &$eventData)
{
global $serendipity;
if (!isset($serendipity['smarty'])) {
serendipity_smarty_init();
}
if (!isset($serendipity['plugindata']['smartymarkupplugin'])) {
$serendipity['smarty']->registerResource("smartymarkupplugin", array(array($this, "smarty_resource_smartymarkupplugin_template"), array($this, "smarty_resource_smartymarkupplugin_timestamp"), array($this, "smarty_resource_smartymarkupplugin_secure"), array($this, "smarty_resource_smartymarkupplugin_trusted")));
}
$serendipity['plugindata']['smartymarkupplugin'] =& $input;
$serendipity['smarty']->assign('smartymarkup_eventData', $eventData);
// avoid non existing or empty template fetch calls
if (isset($serendipity['plugindata']['smartymarkupplugin']) && !empty($serendipity['plugindata']['smartymarkupplugin'])) {
return $serendipity['smarty']->fetch('smartymarkupplugin:' . crc32($serendipity['plugindata']['smartymarkupplugin']));
}
}
示例4: show
function show()
{
global $serendipity;
if ($this->selected()) {
if (!headers_sent()) {
header('HTTP/1.0 200');
header('Status: 200');
}
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
$_ENV['staticpage_pagetitle'] = preg_replace('@[^a-z0-9]@i', '_', $this->get_config('pagetitle'));
$serendipity['smarty']->assign('staticpage_pagetitle', $_ENV['staticpage_pagetitle']);
echo '<div class="serendipity_poll">';
if (serendipity_db_bool($this->get_config('articleformat'))) {
echo '<div class="serendipity_Entry_Date">
<h3 class="serendipity_date">' . $this->get_config('articleformattitle') . '</h3>';
}
echo '<h4 class="serendipity_title"><a href="#">' . $this->get_polldata('title') . '</a></h4>';
if (serendipity_db_bool($this->get_config('articleformat'))) {
echo '<div class="serendipity_entry"><div class="serendipity_entry_body">';
}
echo '<div class="serendipity_poll_body">';
if (isset($serendipity['GET']['voteId'])) {
serendipity_common_pollbox::poll($serendipity['GET']['voteId']);
} else {
serendipity_common_pollbox::poll();
}
echo '</div>';
echo '<br /><div class="serendipity_poll_archive">';
PLUGIN_POLL_ARCHIVE . '<br />';
$polls =& $this->fetchPolls();
if (is_array($polls)) {
foreach ($polls as $poll) {
echo '<a href="' . $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[subpage]=' . $this->get_config('pagetitle') . '&serendipity[voteId]=' . $poll['id'] . '">' . (function_exists('serendipity_specialchars') ? serendipity_specialchars($poll['title']) : htmlspecialchars($poll['title'], ENT_COMPAT, LANG_CHARSET)) . '</a>, ' . serendipity_strftime(DATE_FORMAT_ENTRY, $poll['timestamp']) . '<br />';
}
}
echo '</div>';
if (serendipity_db_bool($this->get_config('articleformat'))) {
echo '</div></div></div>';
}
echo '</div>';
}
}
示例5: show
function show()
{
global $serendipity;
if ($this->selected()) {
if (!headers_sent()) {
header('HTTP/1.0 200');
header('Status: 200 OK');
}
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
$_ENV['staticpage_pagetitle'] = preg_replace('@[^a-z0-9]@i', '_', $this->get_config('pagetitle'));
$serendipity['smarty']->assign('staticpage_pagetitle', $_ENV['staticpage_pagetitle']);
if ($this->get_config('articleformat') == TRUE) {
echo '<div class="serendipity_Entry_Date">
<h3 class="serendipity_date">' . $this->get_config('pagetitle') . '</h3>';
}
echo '<h4 class="serendipity_title"><a href="#">' . $this->get_config('headline') . '</a></h4>';
if ($this->get_config('articleformat') == TRUE) {
echo '<div class="serendipity_entry"><div class="serendipity_entry_body">';
}
$include_file = realpath($this->get_config('include'));
ob_start();
include $include_file;
$content = ob_get_contents();
ob_end_clean();
if ($this->get_config('markup') == TRUE) {
$entry = array('body' => $content);
serendipity_plugin_api::hook_event('frontend_display', $entry);
echo $entry['body'];
} else {
echo $content;
}
if ($this->get_config('articleformat') == TRUE) {
echo '</div></div></div>';
}
}
}
示例6: die
# All rights reserved. See LICENSE file for licensing details
if (IN_serendipity !== true) {
die("Don't hack!");
}
include_once 'serendipity_config.inc.php';
include_once S9Y_INCLUDE_PATH . 'include/plugin_api.inc.php';
$uri = $_SERVER['REQUEST_URI'];
// need to define this again here, as index.php no longer includes this file
$uri_addData = array('startpage' => false, 'uriargs' => implode('/', serendipity_getUriArguments($uri, true)), 'view' => $serendipity['view'], 'viewtype' => isset($serendipity['viewtype']) ? $serendipity['viewtype'] : '');
if ((empty($uri_addData['uriargs']) || trim($uri_addData['uriargs']) == $serendipity['indexFile']) && empty($serendipity['GET']['subpage'])) {
$uri_addData['startpage'] = true;
}
$serendipity['plugindata']['smartyvars'] = $uri_addData;
// Plugins can change this global variable
serendipity_plugin_api::hook_event('genpage', $uri, $uri_addData);
serendipity_smarty_init($serendipity['plugindata']['smartyvars']);
$leftSidebarElements = serendipity_plugin_api::count_plugins('left');
$rightSidebarElements = serendipity_plugin_api::count_plugins('right');
$serendipity['smarty']->assignByRef('leftSidebarElements', $leftSidebarElements);
$serendipity['smarty']->assignByRef('rightSidebarElements', $rightSidebarElements);
switch ($serendipity['GET']['action']) {
// User wants to read the diary
case 'read':
if (isset($serendipity['GET']['id'])) {
$entry = array(serendipity_fetchEntry('id', $serendipity['GET']['id']));
if (!is_array($entry) || count($entry) < 1 || !is_array($entry[0])) {
unset($serendipity['GET']['id']);
$entry = array(array());
$serendipity['head_title'] = serendipity_specialchars($serendipity['blogTitle']);
$serendipity['head_subtitle'] = '';
$serendipity['smarty']->assign('head_title', $serendipity['head_title']);
示例7: elseif
}
if ($ajax) {
// if that is an ajax request we can stop here, since we by convention don't want to wrap the content in the usual backend code
echo $main_content;
} elseif (!$use_installer) {
$poll_admin_vars = array('main_content', 'no_banner', 'no_sidebar', 'no_footer', 'post_action', 'is_logged_in', 'admin_installed', 'self_info', 'use_installer', 'title');
$admin_vars = array();
foreach ($poll_admin_vars as $poll_admin_var) {
$admin_vars[$poll_admin_var] =& ${$poll_admin_var};
}
$admin_vars['out'] = array();
$admin_vars['no_create'] = $serendipity['no_create'];
$admin_vars['title'] = $admin_section;
if ($serendipity['expose_s9y']) {
$admin_vars['version_info'] = sprintf(ADMIN_FOOTER_POWERED_BY, $serendipity['versionInstalled'], phpversion());
} else {
$admin_vars['version_info'] = sprintf(ADMIN_FOOTER_POWERED_BY, '', '');
}
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
$serendipity['smarty']->assignByRef('admin_vars', $admin_vars);
$serendipity['smarty']->display(serendipity_getTemplateFile('admin/index.tpl', 'serendipityPath'));
} else {
if (IS_installed === false) {
$file = 'include/admin/installer.inc.php';
} elseif (IS_up2date === false) {
$file = 'include/admin/upgrader.inc.php';
}
require S9Y_INCLUDE_PATH . $file;
}
示例8: event_hook
function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity;
static $login_url = null;
if ($login_url === null) {
$login_url = $serendipity['baseURL'] . $serendipity['indexFile'] . '?/plugin/loginbox';
}
$hooks =& $bag->get('event_hooks');
if (isset($hooks[$event])) {
switch ($event) {
case 'frontend_saveComment':
if (!isset($serendipity['csuccess'])) {
$serendipity['csuccess'] = 'true';
}
if (serendipity_db_bool($this->get_config('registered_only')) && !serendipity_userLoggedIn() && $addData['source2'] != 'adduser') {
$eventData = array('allow_comments' => false);
$serendipity['messagestack']['comments'][] = PLUGIN_ADDUSER_REGISTERED_ONLY_REASON;
return false;
}
if (serendipity_db_bool($this->get_config('registered_only')) && !$this->inGroup() && $addData['source2'] != 'adduser') {
$eventData = array('allow_comments' => false);
$serendipity['messagestack']['comments'][] = PLUGIN_ADDUSER_REGISTERED_ONLY_REASON;
return false;
}
if (serendipity_db_bool($this->get_config('true_identities')) && !serendipity_userLoggedIn()) {
$user = str_replace(" b", '', $addData['name']);
$user = serendipity_db_escape_string(preg_replace('@\\s+@', ' ', trim($user)));
$user = trim($user);
$authors = serendipity_db_query("SELECT authorid FROM {$serendipity['dbPrefix']}authors WHERE realname = '" . $user . "'");
if (is_array($authors) && isset($authors[0]['authorid'])) {
$eventData = array('allow_comments' => false);
$serendipity['messagestack']['comments'][] = sprintf(PLUGIN_ADDUSER_REGISTERED_CHECK_REASON, $login_url, 'onclick="javascript:loginbox = window.open(this.href, \'loginbox\', \'width=300,height=300,locationbar=no,menubar=no,personalbar=no,statusbar=yes,status=yes,toolbar=no\'); return false;"');
}
}
break;
case 'external_plugin':
if ($eventData != 'loginbox') {
return true;
}
$out = array();
serendipity_plugin_api::hook_event('backend_login_page', $out);
serendipity_smarty_init();
$serendipity['smarty']->assign(array('loginform_add' => $out, 'loginform_url' => $login_url, 'loginform_user' => $_SESSION['serendipityUser'], 'loginform_mail' => $_SESSION['serendipityEmail'], 'close_window' => defined('LOGIN_ACTION'), 'is_logged_in' => serendipity_userLoggedIn(), 'is_error' => defined('LOGIN_ERROR')));
$filename = 'loginbox.tpl';
$tfile = serendipity_getTemplateFile($filename, 'serendipityPath');
if (!$tfile || $tfile == $filename) {
$tfile = dirname(__FILE__) . '/' . $filename;
}
$inclusion = $serendipity['smarty']->security_settings[INCLUDE_ANY];
$serendipity['smarty']->security_settings[INCLUDE_ANY] = true;
$serendipity['smarty']->display($tfile);
break;
case 'frontend_display':
if (serendipity_db_bool($this->get_config('registered_only')) && !serendipity_userLoggedIn()) {
$serendipity['messagestack']['comments'][] = sprintf(PLUGIN_ADDUSER_REGISTERED_ONLY_REASON, $serendipity['baseURL'] . $serendipity['indexFile'] . '?serendipity[subpage]=adduser', $serendipity['baseURL'] . 'serendipity_admin.php');
$eventData['allow_comments'] = false;
}
break;
case 'frontend_configure':
if (isset($serendipity['POST']['action']) && isset($serendipity['POST']['user']) && isset($serendipity['POST']['pass'])) {
serendipity_login();
if (serendipity_userLoggedIn()) {
define('LOGIN_ACTION', 'login');
header('X-s9y-auth: Login');
} else {
define('LOGIN_ERROR', true);
}
} elseif (isset($serendipity['POST']['action']) && isset($serendipity['POST']['logout'])) {
serendipity_logout();
if (!serendipity_userLoggedIn()) {
header('X-s9y-auth: Logout');
define('LOGIN_ACTION', 'logout');
}
}
if ((serendipity_db_bool($this->get_config('registered_only')) || serendipity_db_bool($this->get_config('true_identities'))) && $_SESSION['serendipityAuthedUser']) {
if (defined('IN_serendipity_admin') && $serendipity['GET']['adminAction'] == 'doEdit') {
// void
} else {
$serendipity['COOKIE']['name'] = isset($_SESSION['serendipityRealname']) ? $_SESSION['serendipityRealname'] : $_SESSION['serendipityUser'];
$serendipity['COOKIE']['email'] = $_SESSION['serendipityEmail'];
if ($serendipity['POST']['comment']) {
$serendipity['POST']['name'] = $serendipity['COOKIE']['name'];
$serendipity['POST']['email'] = $serendipity['COOKIE']['email'];
}
}
}
return true;
break;
case 'entry_display':
if ($serendipity['GET']['subpage'] == 'adduser' || $serendipity['POST']['subpage'] == 'adduser' || !empty($serendipity['GET']['adduser_activation']) || !empty($this->clean_page)) {
if (is_array($eventData)) {
$eventData['clean_page'] = true;
}
}
break;
case 'entries_header':
if ($serendipity['GET']['subpage'] == 'adduser' || $serendipity['POST']['subpage'] == 'adduser' || !empty($serendipity['GET']['adduser_activation'])) {
$this->clean_page = true;
$url = $serendipity['baseURL'] . $serendipity['indexFile'];
$hidden['subpage'] = 'adduser';
//.........这里部分代码省略.........
示例9: serveCSS
function serveCSS($css_mode)
{
global $serendipity;
serendipity_smarty_init();
$serendipity['view'] = 'css';
include S9Y_INCLUDE_PATH . 'serendipity.css.php';
}
示例10: serendipity_is_iframe
/**
* Performs a check whether an iframe for the admin section shall be emitted
*
* The iframe is used for previewing an entry with the stylesheet of the frontend.
* It fetches its data from the session input data.
*
* @access private
* @return boolean True, if iframe was requested, false if not.
*/
function serendipity_is_iframe()
{
global $serendipity;
if ($serendipity['GET']['is_iframe'] && is_array($_SESSION['save_entry'])) {
if (!is_object($serendipity['smarty'])) {
// We need smarty also in the iframe to load a template's config.inc.php and register possible event hooks.
serendipity_smarty_init();
}
return true;
}
return false;
}
示例11: media_insert
function media_insert($text, &$eventData)
{
global $serendipity;
// find in text parts which are mediainsert
$entry_parts = preg_split('@(<mediainsert>[\\S\\s]*?</mediainsert>)@', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
// parse mediainserts
// (if xml parser is present at php installation
// - SimpleXMLElement in PHP > 5.0, users of older version could have troubles )
// text is splitted into parts
if (class_exists('SimpleXMLElement')) {
for ($i = 0, $pcount = count($entry_parts); $i < $pcount; $i++) {
if (!(strpos($entry_parts[$i], "<mediainsert>") === false)) {
// There was a problem with wysiwyg-ckeditor: which removes linebreaks and sometimes inserts ending tags
// To not error, we remove at least the ending tags and possibly single-tags missing trailing slashes
$epart = str_replace(array('</media>', '</gallery>', '">'), array('', '', '" />'), $entry_parts[$i]);
$xml = new SimpleXMLElement($epart);
$gallery = $xml->gallery['name'];
$medias = array();
$whole_gallery = false;
foreach ($xml->media as $medium) {
switch ((string) $medium['type']) {
// Get attributes as element indices
case 'single':
$medias[] = serendipity_db_escape_string($medium['name']);
break;
case 'range':
for ($j = intval($medium['start']); $j <= intval($medium['stop']); $j++) {
$medias[] = serendipity_db_escape_string($medium['prefix']) . $j;
}
break;
case 'gallery':
$whole_gallery = true;
break;
case 'hideafter':
$hideafter = intval($medium['nr']);
break;
case 'picperrow':
$picperrow = intval($medium['pr']);
break;
default:
break;
}
}
// here we have desired gallery and desired pictures
// now read available ones from database
if ($whole_gallery) {
$q = "SELECT id,name,extension,thumbnail_name,realname,path,value as comment1,dimensions_width as width, dimensions_height as height\n FROM {$serendipity['dbPrefix']}images as i \n LEFT JOIN {$serendipity['dbPrefix']}mediaproperties as p ON (p.mediaid = i.id AND p.property='COMMENT1') \n WHERE i.path = '" . serendipity_db_escape_string($gallery) . "' ";
} else {
$images_suggestions = "'" . implode("','", $medias) . "'";
$q = "SELECT id,name,extension,thumbnail_name,realname,path,value as comment1,dimensions_width as width, dimensions_height as height\n FROM {$serendipity['dbPrefix']}images as i \n LEFT JOIN {$serendipity['dbPrefix']}mediaproperties as p ON (p.mediaid = i.id AND p.property='COMMENT1') \n WHERE i.path = '" . serendipity_db_escape_string($gallery) . "' AND i.name IN ({$images_suggestions})";
}
$t = serendipity_db_query($q, false, 'assoc');
// here we have to order the results from database to respect
// the order of pictures in xml entry
// and at the same time we calculate thumbs size
$thumb_size = $serendipity['thumbSize'];
$order = array();
if (is_array($t)) {
for ($j = 0, $tcount = count($t); $j < $tcount; $j++) {
$h = intval($t[$j]['height']);
$w = intval($t[$j]['width']);
$h = $h == 0 ? 1 : $h;
// avoid 'Division by zero' errors for height
$w = $w == 0 ? 1 : $w;
// dito for width
if ($w > $h) {
$t[$j]['thumbheight'] = round($thumb_size * $h / $w);
$t[$j]['thumbwidth'] = round($thumb_size);
} else {
$t[$j]['thumbheight'] = round($thumb_size);
$t[$j]['thumbwidth'] = round($thumb_size * $w / $h);
}
if (strlen($t[$j]['comment1']) == 0) {
#$t[$j][6] = $t[$j]['name'];// add missing new num key if not using assoc select
$t[$j]['comment1'] = $t[$j]['name'];
}
$order[$j] = array_search($t[$j]['name'], $medias);
if (strlen($t[$j]['thumbnail_name']) == 0) {
array_splice($t, $j, 1);
$j--;
$tcount--;
}
}
if (count($t) + 1 == count($order)) {
// remove last $order array element, since else we might get a Fatal error: Uncaught exception 'ErrorException' with message 'Warning: array_multisort(): Array sizes are inconsistent'
array_pop($order);
}
array_multisort($order, SORT_ASC, SORT_NUMERIC, $t);
// now make an output using template
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
$serendipity['smarty']->assign(array('plugin_mediainsert_media' => $t, 'plugin_mediainsert_entry' => $eventData, 'plugin_mediainsert_hideafter' => $hideafter, 'plugin_mediainsert_picperrow' => $picperrow));
$content = $this->parseTemplate('plugin_mediainsert.tpl');
} else {
// if there are no available images, do no output
$content = '';
}
// fetch the output
$entry_parts[$i] = $content;
//.........这里部分代码省略.........
示例12: serendipity_smarty_show
/**
* Render a smarty-template
* $template: path to the template-file
* $data: map with the variables to assign
* $debugtype: If set, debug string is prepended. Can be set to HTML or JS.
* $debug: Possible debug string that is prepended to output
*/
function serendipity_smarty_show($template, $data = null, $debugtype = null, $debug = null)
{
global $serendipity;
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
$serendipity['smarty']->assign($data);
$tplfile = $template == 'preview_iframe.tpl' ? serendipity_getTemplateFile($template, 'serendipityPath', true) : serendipity_getTemplateFile($template, 'serendipityPath');
if ($debug !== null) {
if ($debugtype == "HTML") {
$debug = "<!-- Dynamically fetched " . htmlspecialchars(str_replace($serendipity['serendipityPath'], '', $tplfile)) . " on " . date('Y-m-d H:i') . ", called from: " . $debug . " -->\n";
} else {
$debug = "/* Dynamically fetched " . htmlspecialchars(str_replace($serendipity['serendipityPath'], '', $tplfile)) . " on " . date('Y-m-d H:i') . ", called from: " . $debug . " */\n";
}
}
return $debug . $serendipity['smarty']->fetch('file:' . $tplfile);
}
示例13: admin_save
function admin_save()
{
global $serendipity;
global $template_vars;
serendipity_smarty_init();
if (isset($template_vars['sidebars'])) {
$sidebars = explode(',', $template_vars['sidebars']);
} elseif (isset($serendipity['sidebars'])) {
$sidebars = $serendipity['sidebars'];
} else {
$sidebars = array('left', 'hide', 'right');
}
$plugin_list = array();
$view_list = array();
$category_view_list = array();
$usergroups_view_list = array();
foreach ($sidebars as $sidebar) {
$plugins = serendipity_plugin_api::enum_plugins($sidebar);
$i = 0;
if (is_array($plugins)) {
if ($sidebar == 'left') {
$pside = 0;
} elseif ($sidebar == 'right') {
$pside = 1;
} else {
$pside = $sidebar;
}
foreach ($plugins as $plugin) {
if (isset($_REQUEST['plugin_' . $pside . '_' . $i])) {
$plugin_list[$pside][$i] = 0;
} else {
$plugin_list[$pside][$i] = 1;
}
$i++;
}
}
}
$this->set_config('plugin_list', serialize($plugin_list));
foreach ((array) $_REQUEST['plugin_view'] as $instance => $prop) {
if ($prop == 'myself') {
$view_list[base64_decode($instance)] = $serendipity['authorid'];
} elseif ($prop == 'member') {
$view_list[base64_decode($instance)] = 'member';
} elseif ($prop == 'everyone') {
//--JAM: 2005-10-18
$view_list[base64_decode($instance)] = 'everyone';
}
}
$this->set_config('view_list', serialize($view_list));
foreach ((array) $_REQUEST['plugin_category_view'] as $instance => $prop) {
$category_view_list[base64_decode($instance)] = implode(',', $prop);
}
$this->set_config('category_view_list', serialize($category_view_list));
foreach ((array) $_REQUEST['plugin_usergroups_view'] as $instance => $prop) {
$usergroups_view_list[base64_decode($instance)] = implode(',', $prop);
}
$this->set_config('usergroups_view_list', serialize($usergroups_view_list));
echo '<div class="serendipityAdminMsgSuccess"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%T')) . "<br /><br />\n</div>";
}
示例14: event_hook
function event_hook($event, &$bag, &$eventData, $addData = null)
{
global $serendipity;
$hooks =& $bag->get('event_hooks');
if (isset($hooks[$event])) {
switch ($event) {
case 'genpage':
$args = implode('/', serendipity_getUriArguments($eventData, true));
if ($serendipity['rewrite'] != 'none') {
$nice_url = $serendipity['serendipityHTTPPath'] . $args;
} else {
$nice_url = $serendipity['serendipityHTTPPath'] . $serendipity['indexFile'] . '?/' . $args;
}
if ($this->selected()) {
$serendipity['head_title'] = $this->get_config('pagetitle');
$serendipity['head_subtitle'] = $serendipity['blogTitle'];
}
if (empty($serendipity['GET']['subpage'])) {
$serendipity['GET']['subpage'] = $nice_url;
}
serendipity_smarty_init();
$serendipity['smarty']->register_function('customArchive', array($this, 'smarty_customArchive'));
break;
case 'entry_display':
if ($this->selected()) {
if (is_array($eventData)) {
$eventData['clean_page'] = true;
// This is important to not display an entry list!
} else {
$eventData = array('clean_page' => true);
}
}
if (version_compare($serendipity['version'], '0.7.1', '<=')) {
$this->show();
}
return true;
break;
case 'entries_header':
$this->show();
return true;
break;
default:
return false;
break;
}
} else {
return false;
}
}
示例15: serendipity_printEntries
/**
* 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 (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
// if not set, start Smarty templating to avoid member function "method()" on a non-object errors (was draft preview error, now at line 1239)
}
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['pre_body'] = $entry['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['pre_extended'] = $entry['extended'];
$entry['extended'] =& $entry['properties']['ep_cache_extended'];
//.........这里部分代码省略.........