smartifying: template.inc.php, category.inc.php

This commit is contained in:
onli 2012-02-16 20:00:08 +01:00
parent 770f786720
commit 55edda14bf
4 changed files with 420 additions and 247 deletions

View File

@ -11,12 +11,12 @@ if (!serendipity_checkPermission('adminCategories')) {
}
$admin_category = (!serendipity_checkPermission('adminCategoriesMaintainOthers') ? "AND (authorid = 0 OR authorid = " . (int)$serendipity['authorid'] . ")" : '');
$data = array();
/* Add a new category */
if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
$name = $serendipity['POST']['cat']['name'];
$desc = $serendipity['POST']['cat']['description'];
$data['post_save'] = true;
if (is_array($serendipity['POST']['cat']['write_authors']) && in_array(0, $serendipity['POST']['cat']['write_authors'])) {
$authorid = 0;
} else {
@ -27,6 +27,7 @@ if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
$parentid = (isset($serendipity['POST']['cat']['parent_cat']) && is_numeric($serendipity['POST']['cat']['parent_cat'])) ? $serendipity['POST']['cat']['parent_cat'] : 0;
if ($serendipity['GET']['adminAction'] == 'new') {
$data['new'] = true;
if ($parentid != 0) {
// TODO: This doesn't seem to work as expected, serendipity_rebuildCategoryTree(); is still needed! Only activate this optimization function when it's really working :)
// TODO: This works if only one subcategory exists. Otherwise, the first query will return an array.
@ -39,12 +40,10 @@ if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
$catid = serendipity_addCategory($name, $desc, $authorid, $icon, $parentid);
serendipity_ACLGrant($catid, 'category', 'read', $serendipity['POST']['cat']['read_authors']);
serendipity_ACLGrant($catid, 'category', 'write', $serendipity['POST']['cat']['write_authors']);
echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . CATEGORY_SAVED .'</div>';
} elseif ($serendipity['GET']['adminAction'] == 'edit') {
$data['edit'] = true;
if (!serendipity_checkPermission('adminCategoriesMaintainOthers') && !serendipity_ACLCheck($serendipity['authorid'], $serendipity['GET']['cid'], 'category', 'write')) {
echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />'. PERM_DENIED .'</div>';
$data['editPermission'] = false;
} else {
/* Check to make sure parent is not a child of self */
$r = serendipity_db_query("SELECT categoryid FROM {$serendipity['dbPrefix']}category c
@ -53,12 +52,11 @@ if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
if (is_array($r)) {
$r = serendipity_db_query("SELECT category_name FROM {$serendipity['dbPrefix']}category
WHERE categoryid = ". (int)$parentid);
echo sprintf(ALREADY_SUBCATEGORY, htmlspecialchars($r[0]['category_name']), htmlspecialchars($name));
$data['subcat'] = sprintf(ALREADY_SUBCATEGORY, htmlspecialchars($r[0]['category_name']), htmlspecialchars($name));
} else {
serendipity_updateCategory($serendipity['GET']['cid'], $name, $desc, $authorid, $icon, $parentid, $serendipity['POST']['cat']['sort_order'], $serendipity['POST']['cat']['hide_sub']);
serendipity_ACLGrant($serendipity['GET']['cid'], 'category', 'read', $serendipity['POST']['cat']['read_authors']);
serendipity_ACLGrant($serendipity['GET']['cid'], 'category', 'write', $serendipity['POST']['cat']['write_authors']);
echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . CATEGORY_SAVED .'</div>';
}
}
}
@ -69,6 +67,7 @@ if (isset($_POST['SAVE']) && serendipity_checkFormToken()) {
/* Delete a category */
if ($serendipity['GET']['adminAction'] == 'doDelete' && serendipity_checkFormToken()) {
$data['doDelete'] = true;
if ($serendipity['GET']['cid'] != 0) {
$remaining_cat = (int)$serendipity['POST']['cat']['remaining_catid'];
$category_ranges = serendipity_fetchCategoryRange((int)$serendipity['GET']['cid']);
@ -103,192 +102,112 @@ if ($serendipity['GET']['adminAction'] == 'doDelete' && serendipity_checkFormTok
serendipity_ACLGrant($cid, 'category', 'write', array());
}
}
echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . ($remaining_cat ? sprintf(CATEGORY_DELETED_ARTICLES_MOVED, (int)$serendipity['GET']['cid'], $remaining_cat) : sprintf(CATEGORY_DELETED,(int)$serendipity['GET']['cid'])) .'</div>';
$data['deleteSuccess'] = true;
$data['remaining_cat'] = $remaining_cat;
$data['cid'] = (int)$serendipity['GET']['cid'];
$serendipity['GET']['adminAction'] = 'view';
}
} else {
echo '<div class="serendipityAdminMsgError"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_error.png') . '" alt="" />'. INVALID_CATEGORY .'</div>';
$data['deleteSuccess'] = false;
}
}
?>
<?php
if ( $serendipity['GET']['adminAction'] == 'delete' ) {
$this_cat = serendipity_fetchCategoryInfo($serendipity['GET']['cid']);
if ( (serendipity_checkPermission('adminCategoriesDelete') && serendipity_checkPermission('adminCategoriesMaintainOthers'))
|| (serendipity_checkPermission('adminCategoriesDelete') && ($serendipity['authorid'] == $this_cat['authorid'] || $this_cat['authorid'] == '0'))
|| (serendipity_checkPermission('adminCategoriesDelete') && serendipity_ACLCheck($serendipity['authorid'], $serendipity['GET']['cid'], 'category', 'write'))) {
?>
<form method="POST" name="serendipityCategory" action="?serendipity[adminModule]=category&amp;serendipity[adminAction]=doDelete&amp;serendipity[cid]=<?php echo (int)$serendipity['GET']['cid'] ?>">
<?php echo serendipity_setFormToken(); ?>
<h3><?php echo htmlspecialchars($this_cat['category_name']); ?></h3>
<?php echo CATEGORY_REMAINING ?>:
<select name="serendipity[cat][remaining_catid]">
<option value="0">- <?php echo NO_CATEGORY ?> -</option>
<?php
$cats = serendipity_fetchCategories('all');
/* TODO, show dropdown as nested categories */
foreach ($cats as $cat_data) {
if ($cat_data['categoryid'] != $serendipity['GET']['cid'] && (serendipity_checkPermission('adminCategoriesMaintainOthers') || $cat_data['authorid'] == '0' || $cat_data['authorid'] == $serendipity['authorid'])) {
echo '<option value="' . $cat_data['categoryid'] . '">' . htmlspecialchars($cat_data['category_name']) . '</option>' . "\n";
}
}
?>
</select>
<input type="submit" name="REMOVE" value="<?php echo GO ?>" class="serendipityPrettyButton input_button">
</form>
<?php
}
}
?>
<?php if ( $serendipity['GET']['adminAction'] == 'edit' || $serendipity['GET']['adminAction'] == 'new' ) {
if ( $serendipity['GET']['adminAction'] == 'edit' ) {
$cid = (int)$serendipity['GET']['cid'];
$this_cat = serendipity_fetchCategoryInfo($cid);
echo '<strong>'. sprintf(EDIT_THIS_CAT, htmlspecialchars($this_cat['category_name'])) .'</strong>';
$save = SAVE;
$read_groups = serendipity_ACLGet($cid, 'category', 'read');
$write_groups = serendipity_ACLGet($cid, 'category', 'write');
} else {
$cid = false;
$this_cat = array();
echo '<strong>'. CREATE_NEW_CAT .'</strong>';
$save = CREATE;
$read_groups = array(0 => 0);
$write_groups = array(0 => 0);
}
$groups = serendipity_getAllGroups();
?>
<form method="POST" name="serendipityCategory">
<?php echo serendipity_setFormToken(); ?>
<table cellpadding="5" width="100%">
<tr>
<td><?php echo NAME; ?></td>
<td><input class="input_textbox" type="text" name="serendipity[cat][name]" value="<?php echo isset($this_cat['category_name']) ? htmlspecialchars($this_cat['category_name']) : ''; ?>" /></td>
<td rowspan="5" align="center" valign="middle" width="200" style="border: 1px solid #ccc"><img src="<?php echo isset($this_cat['category_icon']) ? htmlspecialchars($this_cat['category_icon']) : '' ?>" id="imagepreview" <?php echo empty($this_cat['category_icon']) ? 'style="display: none"' : '' ?> /></td>
</tr>
<tr>
<td><?php echo DESCRIPTION; ?></td>
<td><input class="input_textbox" type="text" name="serendipity[cat][description]" value="<?php echo isset($this_cat['category_description']) ? htmlspecialchars($this_cat['category_description']) : ''; ?>" /></td>
</tr>
<tr>
<td><?php echo IMAGE; ?></td>
<td>
<script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script>
<input class="input_textbox" type="text" id="img_icon" name="serendipity[cat][icon]" value="<?php echo isset($this_cat['category_icon']) ? htmlspecialchars($this_cat['category_icon']) : ''; ?>" onchange="document.getElementById('imagepreview').src = this.value; document.getElementById('imagepreview').style.display = '';" />
<script type="text/javascript" language="JavaScript">document.write('<input type="button" name="insImage" value="<?php echo IMAGE ; ?>" onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[htmltarget]=img_icon&amp;serendipity[filename_only]=true\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" class="serendipityPrettyButton input_button" />');</script><!-- noscript>FIXXME: Emit a warning if JS is disabled</noscript -->
</td>
</tr>
<tr>
<td><label for="read_authors"><?php echo PERM_READ; ?></label></td>
<td>
<select size="6" id="read_authors" multiple="multiple" name="serendipity[cat][read_authors][]">
<option value="0" <?php echo (!is_array($this_cat) || (isset($this_cat['authorid']) && $this_cat['authorid'] == '0') || isset($read_groups[0])) ? 'selected="selected"' : ''; ?>><?php echo ALL_AUTHORS; ?></option>
<?php
foreach($groups AS $group) {
echo '<option value="' . $group['confkey'] . '" ' . (isset($read_groups[$group['confkey']]) ? 'selected="selected"' : '') . '>' . htmlspecialchars($group['confvalue']) . '</option>' . "\n";
}
?>
</select>
</td>
</tr>
<tr>
<td><label for="write_authors"><?php echo PERM_WRITE; ?></label></td>
<td>
<select size="6" id="write_authors" multiple="multiple" name="serendipity[cat][write_authors][]">
<option value="0" <?php echo (!is_array($this_cat) || (isset($this_cat['authorid']) && $this_cat['authorid'] == '0') || isset($write_groups[0])) ? 'selected="selected"' : ''; ?>><?php echo ALL_AUTHORS; ?></option>
<?php
foreach($groups AS $group) {
echo '<option value="' . $group['confkey'] . '" ' . (isset($write_groups[$group['confkey']]) ? 'selected="selected"' : '') . '>' . htmlspecialchars($group['confvalue']) . '</option>' . "\n";
}
?>
</select>
</td>
</tr>
<tr>
<td><label for="parent_cat"><?php echo PARENT_CATEGORY; ?></label></td>
<td>
<select id="parent_cat" name="serendipity[cat][parent_cat]">
<option value="0"<?php if ( (int)$serendipity['GET']['cid'] == 0 ) echo ' selected="selected"'; ?>>[ <?php echo NO_CATEGORY; ?> ]</option>
<?php
$categories = serendipity_fetchCategories('all');
$categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
foreach ( $categories as $cat ) {
/* We can't be our own parent, the universe will collapse */
if ( $cat['categoryid'] == $serendipity['GET']['cid'] ) {
continue;
if ( $serendipity['GET']['adminAction'] == 'delete' ) {
$data['delete'] = true;
$this_cat = serendipity_fetchCategoryInfo($serendipity['GET']['cid']);
if ( (serendipity_checkPermission('adminCategoriesDelete') && serendipity_checkPermission('adminCategoriesMaintainOthers'))
|| (serendipity_checkPermission('adminCategoriesDelete') && ($serendipity['authorid'] == $this_cat['authorid'] || $this_cat['authorid'] == '0'))
|| (serendipity_checkPermission('adminCategoriesDelete') && serendipity_ACLCheck($serendipity['authorid'], $serendipity['GET']['cid'], 'category', 'write'))) {
$data['deletePermission'] = true;
$data['cid'] = (int)$serendipity['GET']['cid'];
$data['formToken'] = serendipity_setFormToken();
$data['categoryName'] = $this_cat['category_name'];
$cats = serendipity_fetchCategories('all');
$data['cats'] = array();
/* TODO, show dropdown as nested categories */
foreach ($cats as $cat_data) {
if ($cat_data['categoryid'] != $serendipity['GET']['cid'] && (serendipity_checkPermission('adminCategoriesMaintainOthers') || $cat_data['authorid'] == '0' || $cat_data['authorid'] == $serendipity['authorid'])) {
$data['cats'][] = $cat_data;
}
echo '<option value="'. $cat['categoryid'] .'"'. ($this_cat['parentid'] == $cat['categoryid'] ? ' selected="selected"' : '') .'>'. str_repeat('&nbsp;', $cat['depth']) . $cat['category_name'] .'</option>' . "\n";
}
?>
</select>
</td>
</tr>
<tr>
<td><?php echo CATEGORY_HIDE_SUB ?><br /><em><?php echo CATEGORY_HIDE_SUB_DESC; ?></em></td>
<td valign="top">
<input class="input_radio" type="radio" name="serendipity[cat][hide_sub]" value="0" <?php echo ($this_cat['hide_sub'] == 0 ? 'checked="checked"' : ''); ?> id="hide_sub_no" /> <label for="hide_sub_no"><?php echo NO; ?></label>
<input class="input_radio" type="radio" name="serendipity[cat][hide_sub]" value="1" <?php echo ($this_cat['hide_sub'] == 1 ? 'checked="checked"' : ''); ?> id="hide_sub_yes" /> <label for="hide_sub_yes"><?php echo YES; ?></label>
</td>
</tr>
<?php serendipity_plugin_api::hook_event('backend_category_showForm', $cid, $this_cat); ?>
</table>
<div><input type="submit" name="SAVE" value="<?php echo $save; ?>" class="serendipityPrettyButton input_button" /></div>
</form>
<?php } ?>
}
}
if ( $serendipity['GET']['adminAction'] == 'edit' || $serendipity['GET']['adminAction'] == 'new' ) {
if ( $serendipity['GET']['adminAction'] == 'edit' ) {
$data['edit'] = true;
$cid = (int)$serendipity['GET']['cid'];
$this_cat = serendipity_fetchCategoryInfo($cid);
$data['category_name'] = $this_cat['category_name'];
$save = SAVE;
$read_groups = serendipity_ACLGet($cid, 'category', 'read');
$write_groups = serendipity_ACLGet($cid, 'category', 'write');
} else {
$data['new'] = true;
$cid = false;
$this_cat = array();
echo '<strong>'. CREATE_NEW_CAT .'</strong>';
$save = CREATE;
$read_groups = array(0 => 0);
$write_groups = array(0 => 0);
}
$data['cid'] = $cid;
$data['this_cat'] = $this_cat;
$data['save'] = $save;
$groups = serendipity_getAllGroups();
$data['groups'] = $groups;
$data['read_groups'] = $read_groups;
$data['write_groups'] = $write_groups;
$data['formToken'] = serendipity_setFormToken();
$data['cat'] = $this_cat;
if (!is_array($this_cat) || (isset($this_cat['authorid']) && $this_cat['authorid'] == '0') || isset($read_groups[0])) {
$data['selectAllReadAuthors'] = true;
}
if (!is_array($this_cat) || (isset($this_cat['authorid']) && $this_cat['authorid'] == '0') || isset($write_groups[0])) {
$data['selectAllWriteAuthors'] = true;
}
$categories = serendipity_fetchCategories('all');
$categories = serendipity_walkRecursive($categories, 'categoryid', 'parentid', VIEWMODE_THREADED);
$data['categories'] = $categories;
serendipity_plugin_api::hook_event('backend_category_showForm', $cid, $this_cat);
}
<?php
if ( $serendipity['GET']['adminAction'] == 'view' ) {
if (empty($admin_category)) {
$cats = serendipity_fetchCategories('all');
} else {
$cats = serendipity_fetchCategories(null, null, null, 'write');
}
$data['view'] = true;
$data['viewCats'] = $cats;
if ( is_array($cats) && sizeof($cats) > 0 ) {
echo CATEGORY_INDEX .':';
} else {
echo '<div align="center">- '. NO_CATEGORIES .' -</div>';
if ( is_array($cats) ) {
$categories = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
$data['viewCategories'] = $categories;
}
?>
<br /><br />
<table cellspacing="0" cellpadding="4" width="100%" border=0>
<?php
if ( is_array($cats) ) {
$categories = serendipity_walkRecursive($cats, 'categoryid', 'parentid', VIEWMODE_THREADED);
foreach ( $categories as $category ) {
?>
<tr>
<td width="16"><a title="<?php echo EDIT ?>" href="?serendipity[adminModule]=category&amp;serendipity[adminAction]=edit&amp;serendipity[cid]=<?php echo $category['categoryid'] ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/edit.png') ?>" border="0" alt="<?php echo EDIT ?>" /></a></td>
<td width="16"><a title="<?php echo DELETE ?>" href="?serendipity[adminModule]=category&amp;serendipity[adminAction]=delete&amp;serendipity[cid]=<?php echo $category['categoryid'] ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/delete.png') ?>" border="0" alt="<?php echo DELETE ?>" /></a></td>
<td width="16"><?php if ( !empty($category['category_icon']) ) {?><img src="<?php echo serendipity_getTemplateFile('admin/img/thumbnail.png') ?>" alt="" /><?php } else echo '&nbsp;' ?></td>
<td width="300" style="padding-left: <?php echo ($category['depth']*15)+20 ?>px"><img src="<?php echo serendipity_getTemplateFile('admin/img/folder.png') ?>" style="vertical-align: bottom;"> <?php echo htmlspecialchars($category['category_name']) ?></td>
<td><?php echo htmlspecialchars($category['category_description']) ?></td>
<td align="right"><?php echo ($category['authorid'] == '0' ? ALL_AUTHORS : htmlspecialchars($category['realname'])); ?></td>
</tr>
<?php }
} ?>
<tr>
<td colspan="6" align="right">
<a href="?serendipity[adminModule]=category&serendipity[adminAction]=new" class="serendipityPrettyButton input_button"><?php echo CREATE_NEW_CAT ?></a>
</td>
</tr>
</table>
<?php }
}
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
$serendipity['smarty']->assign($data);
$tfile = dirname(__FILE__) . "/category.inc.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;
/* vim: set sts=4 ts=4 expandtab : */

View File

@ -0,0 +1,203 @@
{if $post_save}
{if $new}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
{$CONST.CATEGORY_SAVED}
</div>
{/if}
{if $edit}
{if isset($editPermission) && $editPermission == false}
<div class="serendipityAdminMsgError">
<img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_error.png"}" alt="" />
{$CONST.PERM_DENIED}
</div>
{else}
{if $subcat}
{$subcat}
{else}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
{$CONST.CATEGORY_SAVED}
</div>
{/if}
{/if}
{/if}
{/if}
{if $doDelete}
{if $deleteSuccess}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
{if $remainingCat}
{$CONST.CATEGORY_DELETED_ARTICLES_MOVED|sprintf:$remainingCat:$cid}
{else}
{$cid|string_format:"{$CONST.CATEGORY_DELETED}"}
{/if}
</div>
{else}
<div class="serendipityAdminMsgError">
<img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_error.png"}" alt="" />
{$CONST.INVALID_CATEGORY}
</div>
{/if}
{/if}
{if $delete}
{if $deletePermission == true}
<form method="POST" name="serendipityCategory" action="?serendipity[adminModule]=category&amp;serendipity[adminAction]=doDelete&amp;serendipity[cid]={$cid}">
{$formToken}
<h3>{$categoryName|escape:"html"}</h3>
{$CONST.CATEGORY_REMAINING}:
<select name="serendipity[cat][remaining_catid]">
<option value="0">- {$CONST.NO_CATEGORY} -</option>
{foreach $cats as $cat_data}
<option value="{$cat_data.categoryid}">{$cat_data.category_name|escape:"html"}</option>
{/foreach}
</select>
<input type="submit" name="REMOVE" value="{$CONST.GO}" class="serendipityPrettyButton input_button">
</form>
{/if}
{/if}
{if (! $post_save) && ($edit || $new)}
{if $edit}
<strong>{$category_name|escape:"html"|string_format:"{$CONST.EDIT_THIS_CAT}"}</strong>
{/if}
<form method="POST" name="serendipityCategory">
{$formToken}
<table cellpadding="5" width="100%">
<tr>
<td>{$CONST.NAME}</td>
<td><input class="input_textbox" type="text" name="serendipity[cat][name]" value="{$this_cat.category_name|default:""|escape:"html"}" /></td>
<td rowspan="5" align="center" valign="middle" width="200" style="border: 1px solid #ccc">
<img src="{$this_cat.category_icon|default:""|escape:"html"}" id="imagepreview" {if ! $this_cat.category_icon} style="display: none" {/if} />
</td>
</tr>
<tr>
<td>{$CONST.DESCRIPTION}</td>
<td><input class="input_textbox" type="text" name="serendipity[cat][description]" value="{$this_cat.category_description|default:""|escape:"html"}" /></td>
</tr>
<tr>
<td>{$CONST.IMAGE}</td>
<td>
<script type="text/javascript" language="JavaScript" src="serendipity_editor.js"></script>
<input class="input_textbox" type="text" id="img_icon" name="serendipity[cat][icon]" value="{$this_cat.category_icon|default:""|escape:"html"}" onchange="document.getElementById('imagepreview').src = this.value; document.getElementById('imagepreview').style.display = '';" />
<script type="text/javascript" language="JavaScript">document.write('<input type="button" name="insImage" value="{$CONST.IMAGE}" {literal}onclick="window.open(\'serendipity_admin_image_selector.php?serendipity[htmltarget]=img_icon&amp;serendipity[filename_only]=true\', \'ImageSel\', \'width=800,height=600,toolbar=no,scrollbars=1,scrollbars,resize=1,resizable=1\');" class="serendipityPrettyButton input_button" />');</script><!-- noscript>FIXXME: Emit a warning if JS is disabled</noscript -->{/literal}
</td>
</tr>
<tr>
<td><label for="read_authors">{$CONST.PERM_READ}</label></td>
<td>
<select size="6" id="read_authors" multiple="multiple" name="serendipity[cat][read_authors][]">
<option value="0" {if $selectAllReadAuthors}selected="selected"{/if}>{$CONST.ALL_AUTHORS}</option>
{foreach $groups as $group}
<option value="{$group.confkey}"
{if isset($read_groups.{$group.confkey})}
selected="selected"
{/if} >
{$group.confvalue|escape:"html"}
</option>
{/foreach}
</select>
</td>
</tr>
<tr>
<td><label for="write_authors"><{$CONST.PERM_WRITE}</label></td>
<td>
<select size="6" id="write_authors" multiple="multiple" name="serendipity[cat][write_authors][]">
<option value="0" {if $selectAllReadAuthors}selected="selected"{/if}>{$CONST.ALL_AUTHORS}</option>
{foreach $groups as $group}
<option value="{$group.confkey}" {if isset($read_groups.{$group.confkey})} selected="selected" {/if} > {$group.confvalue|escape:"html"}</option>
{/foreach}
</select>
</td>
</tr>
<tr>
<td><label for="parent_cat">{$CONST.PARENT_CATEGORY}</label></td>
<td>
<select id="parent_cat" name="serendipity[cat][parent_cat]">
<option value="0" {if $cid == 0} selected="selected" {/if}>[ {$CONST.NO_CATEGORY} ]</option>
{foreach $categories as $cat}
{*We can't be our own parent, the universe will collapse *}
{if $cat.categoryid == $cid}
{continue}
{/if}
<option value="{$cat.categoryid}" {if $this_cat.parentid == $cat.categoryid} selected="selected"{/if} >
{for $i=1 to $cat.depth}&nbsp{/for} $cat.category_name
</option>
{/foreach}
</select>
</td>
</tr>
<tr>
<td><{$CONST.CATEGORY_HIDE_SUB}<br /><em>{$CONST.CATEGORY_HIDE_SUB_DESC}</em></td>
<td valign="top">
<input class="input_radio" type="radio" name="serendipity[cat][hide_sub]" value="0"
{if $this_cat.hide_sub == 0}
checked="checked"
{/if}
id="hide_sub_no" />
<label for="hide_sub_no">
{$CONST.NO}
</label>
<input class="input_radio" type="radio" name="serendipity[cat][hide_sub]" value="1" {if $this_cat.hide_sub== 1} checked="checked"{/if} id="hide_sub_yes" /> <label for="hide_sub_yes">{$CONST.YES}</label>
</td>
</tr>
</table>
<div><input type="submit" name="SAVE" value="{$save}" class="serendipityPrettyButton input_button" /></div>
</form>
{/if}
{if $view}
{if is_array($viewCats)}
{$CONST.CATEGORY_INDEX}:
{else}
<div align="center">- {$CONST.NO_CATEGORIES} -</div>
{/if}
<br /><br />
<table cellspacing="0" cellpadding="4" width="100%" border=0>
{foreach $viewCategories as $category}
<tr>
<td width="16">
<a title="{$CONST.EDIT}" href="?serendipity[adminModule]=category&amp;serendipity[adminAction]=edit&amp;serendipity[cid]={$category.categoryid}">
<img src="{serendipity_getFile file="admin/img/edit.png"}" border="0" alt="{$CONST.EDIT}" />
</a>
</td>
<td width="16">
<a title="{$CONST.DELETE}" href="?serendipity[adminModule]=category&amp;serendipity[adminAction]=delete&amp;serendipity[cid]={$category.categoryid}">
<img src="{serendipity_getFile file="admin/img/delete.png"}" border="0" alt="{$CONST.DELETE}" />
</a>
</td>
<td width="16">
{if $category.category_icon}
<img src="{serendipity_getFile file="admin/img/thumbnail.png"}" alt="" />
{else}
&nbsp;
{/if}
</td>
<td width="300" style="padding-left: {$category.depth*15+20}px">
<img src="{serendipity_getFile file="admin/img/folder.png"}" style="vertical-align: bottom;">
{$category.category_name|escape:"html"}
</td>
<td>
{$category.category_description|escape:"html"}
</td>
<td align="right">
{if $category.authorid == 0}
{$CONST.ALL_AUTHORS}
{else}
{$category.realname|escape:"html"}
{/if}
</td>
</tr>
{/foreach}
<tr>
<td colspan="6" align="right">
<a href="?serendipity[adminModule]=category&serendipity[adminAction]=new" class="serendipityPrettyButton input_button">{$CONST.CREATE_NEW_CAT}</a>
</td>
</tr>
</table>
{/if}

View File

@ -56,6 +56,8 @@ class template_option {
}
}
$data = array();
if ($serendipity['GET']['adminAction'] == 'install' ) {
serendipity_plugin_api::hook_event('backend_templates_fetchtemplate', $serendipity);
@ -64,16 +66,17 @@ if ($serendipity['GET']['adminAction'] == 'install' ) {
serendipity_set_config_var('template', htmlspecialchars($serendipity['GET']['theme']));
serendipity_set_config_var('template_engine', isset($themeInfo['engine']) ? $themeInfo['engine'] : 'default');
echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . sprintf(TEMPLATE_SET, htmlspecialchars($serendipity['GET']['theme'])) .'</div>';
$data["adminAction"] = "install";
$data["install_template"] = htmlspecialchars($serendipity['GET']['theme']);
}
?>
<?php
if ( @file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] .'/layout.php') ) {
echo '<div class="serendipityAdminMsgNote"><img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_note.png') . '" alt="" />'. WARNING_TEMPLATE_DEPRECATED .'</div>';
$data["deprecated"] = true;
}
echo '<h3>' . STYLE_OPTIONS . ' (' . $serendipity['template'] . ')</h3>';
$data["cur_template"] = $serendipity['template'];
if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php')) {
serendipity_smarty_init();
include_once $serendipity['serendipityPath'] . $serendipity['templatePath'] . $serendipity['template'] . '/config.inc.php';
@ -81,6 +84,7 @@ if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] .
if (is_array($template_config)) {
serendipity_plugin_api::hook_event('backend_templates_configuration_top', $template_config);
$data["has_config"] = true;
if ($serendipity['POST']['adminAction'] == 'configure' && serendipity_checkFormToken()) {
$storage = new template_option();
@ -88,13 +92,11 @@ if (is_array($template_config)) {
foreach($serendipity['POST']['template'] AS $option => $value) {
$storage->set_config($option, $value);
}
echo '<div class="serendipityAdminMsgSuccess"><img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="' . serendipity_getTemplateFile('admin/img/admin_msg_success.png') . '" alt="" />' . DONE .': '. sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S')) . '</div>';
$data["adminAction"] = "configure";
$data["save_time"] = sprintf(SETTINGS_SAVED_AT, serendipity_strftime('%H:%M:%S'));
}
echo '<form method="post" action="serendipity_admin.php">';
echo '<input type="hidden" name="serendipity[adminModule]" value="templates" />';
echo '<input type="hidden" name="serendipity[adminAction]" value="configure" />';
echo serendipity_setFormToken();
$data["form_token"] = serendipity_setFormToken();
include S9Y_INCLUDE_PATH . 'include/functions_plugins_admin.inc.php';
@ -104,6 +106,7 @@ if (is_array($template_config)) {
$template_options->import($template_config);
$template_options->values =& $template_vars;
ob_start();
serendipity_plugin_config(
$template_options,
$template_vars,
@ -117,100 +120,65 @@ if (is_array($template_config)) {
'template',
$template_config_groups
);
echo '</form><br />';
$data["configuration"] = ob_get_contents();
ob_end_clean();
serendipity_plugin_api::hook_event('backend_templates_configuration_bottom', $template_config);
} else {
echo '<p>' . STYLE_OPTIONS_NONE . '</p>';
serendipity_plugin_api::hook_event('backend_templates_configuration_none', $template_config);
}
echo '<h3>' . SELECT_TEMPLATE . '</h3>';
?>
<br />
<?php
$i = 0;
$stack = array();
serendipity_plugin_api::hook_event('backend_templates_fetchlist', $stack);
$themes = serendipity_fetchTemplates();
$data['templates'] = array();
$data['templates'][$theme] = array();
foreach($themes AS $theme) {
$stack[$theme] = serendipity_fetchTemplateInfo($theme);
}
ksort($stack);
foreach ($stack as $theme => $info) {
$i++;
$data['templates'][$theme]['info'] = $info;
/* Sorry, but we don't display engines */
if ( strtolower($info['engine']) == 'yes' ) {
continue;
}
$preview = '';
$preview_link = false;
if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/preview_fullsize.jpg')) {
$preview .= '<a href="' . $serendipity['baseURL'] . $serendipity['templatePath'] . $theme . '/preview_fullsize.jpg" target="_blank">';
$preview_link = true;
$data['templates'][$theme]['fullsize_preview'] = $serendipity['baseURL'] . $serendipity['templatePath'] . $theme . '/preview_fullsize.jpg';
} elseif (!empty($info['preview_fullsizeURL'])) {
$preview .= '<a href="' . $info['preview_fullsizeURL'] . '" target="_blank">';
$preview_link = true;
# } else {
# echo "No large preview";
$data['templates'][$theme]['fullsize_preview'] = $info['preview_fullsizeURL'];
}
if (file_exists($serendipity['serendipityPath'] . $serendipity['templatePath'] . $theme . '/preview.png')) {
$preview .= '<img src="' . $serendipity['templatePath'] . $theme . '/preview.png" width="100" style="border: 1px #000000 solid" />';
$data['templates'][$theme]['preview'] = $serendipity['templatePath'] . $theme . '/preview.png';
} elseif (!empty($info['previewURL'])) {
$preview .= '<img src="' . $info['previewURL'] . '" width="100" style="border: 1px #000000 solid" />';
} else {
$preview .= '&nbsp;';
}
if ($preview_link) {
$preview .= '</a>';
}
if (empty($info['customURI'])) {
$info['customURI'] = '';
$data['templates'][$theme]['preview'] = $info['previewURL'] ;
}
$unmetRequirements = array();
if ( isset($info['require serendipity']) && version_compare($info['require serendipity'], serendipity_getCoreVersion($serendipity['version']), '>') ) {
$unmetRequirements[] = 'Serendipity '. $info['require serendipity'];
$data['templates'][$theme]['unmetRequirements'] = sprintf(UNMET_REQUIREMENTS, implode(', ', $unmetRequirements));
}
/* TODO: Smarty versioncheck */
$class = (($i % 2 == 0) ? 'even' : 'uneven');
?>
<div class="serendipity_admin_list_item serendipity_admin_list_item_<?php echo $class ?>">
<table width="100%" id="serendipity_theme_<?php echo $theme; ?>">
<tr>
<td colspan="2"><span class="serendipityTemplateSelectName"><strong><?php echo $info['name']; ?></strong></span></td>
<td valign="middle" align="center" width="70" rowspan="2">
<?php
if ( $serendipity['template'] != $theme ) {
if ( !sizeof($unmetRequirements) ) {
?>
<a href="?serendipity[adminModule]=templates&amp;serendipity[adminAction]=install&amp;serendipity[theme]=<?php echo $theme . $info['customURI']; ?>"><img src="<?php echo serendipity_getTemplateFile('admin/img/install_now' . $info['customIcon'] . '.png') ?>" alt="<?php echo SET_AS_TEMPLATE ?>" title="<?php echo SET_AS_TEMPLATE ?>" border="0" /></a>
<?php } else { ?>
<span class="serendipityTemplateSelectUnmetRequirements" style="color: #cccccc"><?php echo sprintf(UNMET_REQUIREMENTS, implode(', ', $unmetRequirements)); ?></span>
<?php
}
} ?>
</td>
</tr>
<tr>
<td width="100" style="padding-left: 10px"><?php echo $preview; ?></td>
<td valign="top">
<span class="serendipityTemplateSelectDetails"><?php echo AUTHOR; ?>: <?php echo $info['author'];?></span><br />
<span class="serendipityTemplateSelectDetails"><?php echo LAST_UPDATED; ?>: <?php echo $info['date']; ?></span><br />
<span class="serendipityTemplateSelectDetails"><?php echo CUSTOM_ADMIN_INTERFACE; ?>: <?php echo $info['custom_admin_interface']; ?></span><br />
</td>
</tr>
</table>
</div>
<?php
}
if (!is_object($serendipity['smarty'])) {
serendipity_smarty_init();
}
$serendipity['smarty']->assign($data);
$tfile = dirname(__FILE__) . "/templates.inc.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;

View File

@ -0,0 +1,83 @@
{if $adminAction == "install"}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
{$install_template|string_format:"{$CONST.TEMPLATE_SET}"}
</div>
{/if}
{if $deprecated}
<div class="serendipityAdminMsgNote">
<img style="width: 22px; height: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_note.png"}" alt="" />
{$CONST.WARNING_TEMPLATE_DEPRECATED}
</div>
{/if}
<h3> {$CONST.STYLE_OPTIONS} ({$cur_template})</h3>
{if $has_config}
{if $adminAction == "configure"}
<div class="serendipityAdminMsgSuccess">
<img style="height: 22px; width: 22px; border: 0px; padding-right: 4px; vertical-align: middle" src="{serendipity_getFile file="admin/img/admin_msg_success.png"}" alt="" />
{$CONST:DONE}: {$save_time}
</div>
{/if}
<form method="post" action="serendipity_admin.php">
<input type="hidden" name="serendipity[adminModule]" value="templates" />
<input type="hidden" name="serendipity[adminAction]" value="configure" />
{$form_token}
{$configuration}
</form><br />
{else}
<p>{$CONST.STYLE_OPTIONS_NONE}</p>
{/if}
<br />
<h3>{$CONST.SELECT_TEMPLATE}</h3>
{foreach $templates as $template=>$info}
{if $info.info.engine == "yes"}
{continue}
{/if}
{if $template@iteration is even}
<div class="serendipity_admin_list_item serendipity_admin_list_item_even">
{else}
<div class="serendipity_admin_list_item serendipity_admin_list_item_uneven">
{/if}
<table width="100%" id="serendipity_theme_{$template}">
<tr>
<td colspan="2"><span class="serendipityTemplateSelectName"><strong>{$info.info.name}</strong></span></td>
<td valign="middle" align="center" width="70" rowspan="2">
{if $template != $cur_template}
{if ! $info.unmetRequirements}
<a href="?serendipity[adminModule]=templates&amp;serendipity[adminAction]=install&amp;serendipity[theme]={$template}{$info.info.customURI}">
<img src="{serendipity_getFile file="admin/img/install_now{$info.info.customIcon}.png"}" alt="{$CONST.SET_AS_TEMPLATE}" title="{$CONST.SET_AS_TEMPLATE}" border="0" />
</a>
{else}
<span class="serendipityTemplateSelectUnmetRequirements" style="color: #cccccc">{$info.unmetRequirements}></span>
{/if}
{/if}
</td>
</tr>
<tr>
<td width="100" style="padding-left: 10px">
{if $info.fullsize_preview}
<a href="{$info.fullsize_preview}" target="_blank">
{if $info.preview}
<img src="{$info.preview}" width="100" style="border: 1px #000000 solid" />
{else}
&nbsp;
{/if}
</a>
{/if}
</td>
<td valign="top">
<span class="serendipityTemplateSelectDetails">{$CONST.AUTHOR}: {$info.info.author}</span><br />
<span class="serendipityTemplateSelectDetails">{$CONST.LAST_UPDATED}: {$info.info.date}</span><br />
<span class="serendipityTemplateSelectDetails">{$CONST.CUSTOM_ADMIN_INTERFACE}: {$info.info.custom_admin_interface}</span><br />
</td>
</tr>
</table>
</div>
{/foreach}