Allow possibility to style the backend (surrounding layout + entry editor so far)
This commit is contained in:
@ -336,8 +336,24 @@ function serendipity_load_configuration($author = null) {
|
||||
*/
|
||||
function serendipity_logout() {
|
||||
$_SESSION['serendipityAuthedUser'] = false;
|
||||
@session_destroy();
|
||||
serendipity_session_destroy();
|
||||
serendipity_deleteCookie('author_information');
|
||||
serendipity_deleteCookie('author_token');
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys a session, keeps important stuff intact.
|
||||
* @access public
|
||||
* @return null
|
||||
*/
|
||||
function serendipity_session_destroy() {
|
||||
$no_smarty = $_SESSION['no_smarty'];
|
||||
@session_destroy();
|
||||
session_regenerate_id();
|
||||
session_start();
|
||||
|
||||
$_SESSION['SERVER_GENERATED_SID'] = true;
|
||||
$_SESSION['no_smarty'] = $no_smarty;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -437,7 +453,7 @@ function serendipity_checkAutologin($ident, $iv) {
|
||||
|
||||
if ($autologin['name'] < (time()-86400)) {
|
||||
// Issued autologin cookie has been issued more than 1 day ago. Re-Issue new cookie, invalidate old one to prevent abuse
|
||||
serendipity_header('X-ReIssue-Cookie: +' . (time() - $autologin['name']) . 's');
|
||||
if ($serendipity['expose_s9y']) serendipity_header('X-ReIssue-Cookie: +' . (time() - $autologin['name']) . 's');
|
||||
serendipity_issueAutologin($cookie);
|
||||
}
|
||||
|
||||
@ -445,9 +461,9 @@ function serendipity_checkAutologin($ident, $iv) {
|
||||
}
|
||||
|
||||
function serendipity_setAuthorToken() {
|
||||
$hash = sha1(uniqid(rand(), true));
|
||||
serendipity_setCookie('author_token', $hash);
|
||||
$_SESSION['author_token'] = $hash;
|
||||
$hash = sha1(uniqid(rand(), true));
|
||||
serendipity_setCookie('author_token', $hash);
|
||||
$_SESSION['author_token'] = $hash;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -516,7 +532,7 @@ function serendipity_authenticate_author($username = '', $password = '', $is_md5
|
||||
return true;
|
||||
} else {
|
||||
$_SESSION['serendipityAuthedUser'] = false;
|
||||
@session_destroy();
|
||||
serendipity_session_destroy();
|
||||
}
|
||||
}
|
||||
|
||||
@ -613,7 +629,12 @@ function serendipity_setCookie($name, $value, $securebyprot = true) {
|
||||
function serendipity_deleteCookie($name) {
|
||||
global $serendipity;
|
||||
|
||||
setcookie("serendipity[$name]", '', time()-4000);
|
||||
$host = $_SERVER['HTTP_HOST'];
|
||||
if ($pos = strpos($host, ":")) {
|
||||
$host = substr($host, 0, $pos);
|
||||
}
|
||||
|
||||
setcookie("serendipity[$name]", '', time()-4000, $serendipity['serendipityHTTPPath'], $host);
|
||||
unset($_COOKIE[$name]);
|
||||
unset($serendipity['COOKIE'][$name]);
|
||||
}
|
||||
@ -874,7 +895,7 @@ function serendipity_getSessionLanguage() {
|
||||
return $serendipity['lang'];
|
||||
} else {
|
||||
$_SESSION['serendipityLanguage'] = $lang;
|
||||
if (! is_null($serendipity['detected_lang'])) {
|
||||
if (!is_null($serendipity['detected_lang'])) {
|
||||
if ($serendipity['expose_s9y']) serendipity_header('X-Serendipity-InterfaceLang: ' . $lang);
|
||||
}
|
||||
}
|
||||
|
@ -36,31 +36,41 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
|
||||
$draftP = '';
|
||||
$categoryselector_expanded = false;
|
||||
|
||||
$template_vars = array();
|
||||
|
||||
serendipity_plugin_api::hook_event('backend_entryform', $entry);
|
||||
|
||||
if ( (isset($entry['isdraft']) && serendipity_db_bool($entry['isdraft'])) ||
|
||||
(!isset($entry['isdraft']) && $serendipity['publishDefault'] == 'draft') ) {
|
||||
$draftD = ' selected="selected"';
|
||||
$template_vars['draft_mode'] = 'draft';
|
||||
} else {
|
||||
$draftP = ' selected="selected"';
|
||||
$template_vars['draft_mode'] = 'publish';
|
||||
}
|
||||
|
||||
if (isset($entry['moderate_comments']) && (serendipity_db_bool($entry['moderate_comments']))) {
|
||||
$template_vars['moderate_comments'] = true;
|
||||
$moderate_comments = ' checked="checked"';
|
||||
} elseif (!isset($entry['moderate_comments']) && ($serendipity['moderateCommentsDefault'] == 'true' || $serendipity['moderateCommentsDefault'] === true)) {
|
||||
// This is the default on creation of a new entry and depends on the "moderateCommentsDefault" variable of the configuration.
|
||||
$moderate_comments = ' checked="checked"';
|
||||
$template_vars['moderate_comments'] = true;
|
||||
} else {
|
||||
$moderate_comments = '';
|
||||
$template_vars['moderate_comments'] = false;
|
||||
}
|
||||
|
||||
|
||||
if (isset($entry['allow_comments']) && (serendipity_db_bool($entry['allow_comments']))) {
|
||||
$template_vars['allow_comments'] = true;
|
||||
$allow_comments = ' checked="checked"';
|
||||
} elseif ((!isset($entry['allow_comments']) || $entry['allow_comments'] !== 'false') && (!isset($serendipity['allowCommentsDefault']) || $serendipity['allowCommentsDefault'] == 'true' || $serendipity['allowCommentsDefault'] === true)) {
|
||||
// This is the default on creation of a new entry and depends on the "allowCommentsDefault" variable of the configuration.
|
||||
$template_vars['allow_comments'] = true;
|
||||
$allow_comments = ' checked="checked"';
|
||||
} else {
|
||||
$template_vars['allow_comments'] = false;
|
||||
$allow_comments = '';
|
||||
}
|
||||
|
||||
@ -94,10 +104,19 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
|
||||
|
||||
if (is_array($cats = serendipity_fetchCategories())) {
|
||||
$cats = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
|
||||
foreach ( $cats as $cat ) {
|
||||
$cat_list .= '<option value="'. $cat['categoryid'] .'"'. (in_array($cat['categoryid'], $selected) ? ' selected="selected"' : '') .'>'. str_repeat(' ', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
|
||||
foreach ($cats as $cat) {
|
||||
|
||||
if (in_array($cat['categoryid'], $selected)) {
|
||||
$cat['is_selected'] = true;
|
||||
}
|
||||
|
||||
$cat['depth_pad'] = str_repeat(' ', $cat['depth']);
|
||||
|
||||
$template_vars['category_options'][] = $cat;
|
||||
$cat_list .= '<option value="'. $cat['categoryid'] .'"'. ($cat['is_selected'] ? ' selected="selected"' : '') .'>'. $cat['depth_pad'] . $cat['category_name'] .'</option>' . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
$cat_list .= '</select>' . $n;
|
||||
|
||||
if (!empty($serendipity['GET']['title'])) {
|
||||
@ -120,6 +139,42 @@ function serendipity_printEntryForm($targetURL, $hiddens = array(), $entry = arr
|
||||
$hidden .= ' <input type="hidden" name="serendipity[timestamp]" value="' . (isset($entry['timestamp']) ? serendipity_serverOffsetHour($entry['timestamp']) : serendipity_serverOffsetHour(time())) . '" />' . $n;
|
||||
$hidden .= ' <input type="hidden" name="serendipity[preview]" value="false" />';
|
||||
$hidden .= ' ' . serendipity_setFormToken();
|
||||
|
||||
if (is_object($serendipity['smarty'])) {
|
||||
if (isset($serendipity['allowDateManipulation']) && $serendipity['allowDateManipulation']) {
|
||||
$template_vars['allowDateManipulation'] = true;
|
||||
}
|
||||
|
||||
if ((!empty($entry['extended']) || !empty($serendipity['COOKIE']['toggle_extended'])) && !$serendipity['wysiwyg']) {
|
||||
$template_vars['show_wysiwyg'] = true;
|
||||
}
|
||||
|
||||
if (eregi($serendipity['EditorBrowsers'], $_SERVER['HTTP_USER_AGENT']) ) {
|
||||
$template_vars['wysiwyg_advanced'] = true;
|
||||
}
|
||||
|
||||
$template_vars['timestamp'] = serendipity_serverOffsetHour(isset($entry['timestamp']) && $entry['timestamp'] > 0 ? $entry['timestamp'] : time());
|
||||
$template_vars['reset_timestamp'] = serendipity_serverOffsetHour(time());
|
||||
$template_vars['hidden'] = $hidden;
|
||||
$template_vars['errMsG'] = $errMsg;
|
||||
$template_vars['entry'] =& $entry;
|
||||
$template_vars['targetURL'] = $targetURL;
|
||||
$template_vars['cat_count'] = count($cats)+1;
|
||||
$template_vars['cat_state'] = $categoryselector_expanded ? 'on' : 'off';
|
||||
$template_vars['wysiwyg'] = $serendipity['wysiwyg'];
|
||||
$template_vars['serendipityRightPublish'] = $_SESSION['serendipityRightPublish'];
|
||||
$template_vars['wysiwyg_blocks'] = array(
|
||||
'body' => 'serendipity[body]',
|
||||
'extended' => 'serendipity[extended]'
|
||||
);
|
||||
$serendipity['smarty']->register_modifier('emit_htmlarea_code', 'serendipity_emit_htmlarea_code');
|
||||
$serendipity['smarty']->assign('admin_view', 'entryform');
|
||||
$serendipity['smarty']->assign_by_ref('entry_vars', $template_vars);
|
||||
$serendipity['smarty']->display(serendipity_getTemplateFile('admin/entries.tpl', 'serendipityPath'));
|
||||
return true;
|
||||
}
|
||||
|
||||
/* HTML CODE BELOW IS FOR FALLBACK PORTABILITY ONLY - MODIFY CODE IN TEMPLATE ADMIN/ENTRIES.TPL INSTEAD! */
|
||||
if (!empty($errMsg)) {
|
||||
?>
|
||||
<div class="serendipityAdminMsgError"><?php echo $errMsg; ?></div>
|
||||
|
@ -695,12 +695,20 @@ function serendipity_smarty_init($vars = array()) {
|
||||
// Beware: Smarty is used in the Admin backend, despite of this.
|
||||
include $template_dir . '/template.inc.php';
|
||||
} else {
|
||||
// Default Smarty Engine will be used
|
||||
// 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')) {
|
||||
require SMARTY_DIR . 'Smarty.class.php';
|
||||
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;
|
||||
@ -714,9 +722,13 @@ function serendipity_smarty_init($vars = array()) {
|
||||
$serendipity['smarty']->compile_dir = $serendipity['serendipityPath'] . PATH_SMARTY_COMPILE;
|
||||
|
||||
if (!is_dir($serendipity['smarty']->compile_dir) || !is_writable($serendipity['smarty']->compile_dir)) {
|
||||
serendipity_die(sprintf(DIRECTORY_WRITE_ERROR, $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');
|
||||
@ -732,6 +744,7 @@ function serendipity_smarty_init($vars = array()) {
|
||||
$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_function('serendipity_printSidebar', 'serendipity_smarty_printSidebar');
|
||||
$serendipity['smarty']->register_function('serendipity_hookPlugin', 'serendipity_smarty_hookPlugin');
|
||||
|
Reference in New Issue
Block a user