[ADDED] Template Editor

This commit is contained in:
Sebastian Grewe 2014-03-03 11:44:06 +01:00
parent b59f878c22
commit 0ce22ebf7a
4 changed files with 91 additions and 77 deletions

View File

@ -27,7 +27,7 @@ $sOriginalTemplate = $template->getTemplateContent($sTemplate);
if (@$_REQUEST['do'] == 'save') {
if ($template->updateEntry(@$_REQUEST['template'], @$_REQUEST['content'], @$_REQUEST['active'])) {
$_SESSION['POPUP'][] = array('CONTENT' => 'Page updated', 'TYPE' => 'success');
$_SESSION['POPUP'][] = array('CONTENT' => 'Page updated', 'TYPE' => 'alert alert-success');
} else {
$_SESSION['POPUP'][] = array('CONTENT' => 'Page update failed: ' . $template->getError(), 'TYPE' => 'alert alert-danger');
}
@ -36,7 +36,7 @@ if (@$_REQUEST['do'] == 'save') {
$oDatabaseTemplate = $template->getEntry($sTemplate);
if ( $oDatabaseTemplate === false ) {
$_SESSION['POPUP'][] = array('CONTENT' => 'Can\'t fetch template from Database. Have you created `templates` table? Run 005_create_templates_table.sql from sql folder', 'TYPE' => 'danger');
$_SESSION['POPUP'][] = array('CONTENT' => 'Can\'t fetch template from Database. Have you created `templates` table? Run 005_create_templates_table.sql from sql folder', 'TYPE' => 'alert alert-danger');
}
$smarty->assign("TEMPLATES", $aTemplates);

View File

@ -0,0 +1,48 @@
<div class="col-lg-3">
<div class="panel panel-info">
<div class="panel-heading">
Select Page
</div>
<div class="panel-content templates-tree" id="templates-tree">
{include file="admin/templates/tree.tpl" files=$TEMPLATES prefix=""}
</div>
<link rel='stylesheet' type='text/css' href='{$PATH}/js/dynatree/skin/ui.dynatree.css'>
<script type="text/javascript" src="{$PATH}/js/jquery.cookie.js"></script>
<script type="text/javascript" src="{$PATH}/js/jquery-ui.custom.min.js"></script>
<script type="text/javascript" src="{$PATH}/js/dynatree/jquery.dynatree.min.js"></script>
<script>
$(function() {
$("#templates-tree").each(function() {
$(this).find("li").each(function() {
if($(this).find("li.dynatree-activated").length) {
$(this).attr("data", "addClass:'dynatree-has-activated'");
}
});
}).dynatree({
minExpandLevel: 2,
clickFolderMode: 2,
selectMode: 1,
persist: true,
//To show the active template onLoad
onPostInit: function(isReloading, isError) {
this.reactivate();
},
onActivate: function(node) {
if( node.tree.isUserEvent() && node.data.href )
location.href = node.data.href;
}
});
});
</script>
<style>
.templates-tree .dynatree-container { border: none; }
.templates-tree span.dynatree-folder a { font-weight: normal; }
.templates-tree span.dynatree-active a,
.templates-tree span.dynatree-has-activated a,
.templates-tree span.dynatree-activated a { font-weight: bold; }
</style>
<div class="panel-footer">
<ul><li>Bold templates are activated</li></ul>
</div>
</div>
</div>

View File

@ -1,75 +1,4 @@
<article class="module width_quarter">
<header><h3>Select Page</h3></header>
<div class="templates-tree" id="templates-tree">
{include file="admin/templates/tree.tpl" files=$TEMPLATES prefix=""}
</div>
<link rel='stylesheet' type='text/css' href='{$PATH}/js/dynatree/skin/ui.dynatree.css'>
<script type="text/javascript" src="{$PATH}/js/jquery.cookie.js"></script>
<script type="text/javascript" src="{$PATH}/js/jquery-ui.custom.min.js"></script>
<script type="text/javascript" src="{$PATH}/js/dynatree/jquery.dynatree.min.js"></script>
<script>
$(function() {
$("#templates-tree").each(function() {
$(this).find("li").each(function() {
if($(this).find("li.dynatree-activated").length) {
$(this).attr("data", "addClass:'dynatree-has-activated'");
}
});
}).dynatree({
minExpandLevel: 2,
clickFolderMode: 2,
selectMode: 1,
persist: true,
//To show the active template onLoad
onPostInit: function(isReloading, isError) {
this.reactivate();
},
onActivate: function(node) {
if( node.tree.isUserEvent() && node.data.href )
location.href = node.data.href;
}
});
});
</script>
<style>
.templates-tree .dynatree-container { border: none; }
.templates-tree span.dynatree-folder a { font-weight: normal; }
.templates-tree span.dynatree-active a,
.templates-tree span.dynatree-has-activated a,
.templates-tree span.dynatree-activated a { font-weight: bold; }
</style>
<footer>
<ul><li>Bold templates are activated</li></ul>
</footer>
</article>
<article class="module width_3_quarter">
<header><h3> Edit template '{$CURRENT_TEMPLATE}' </h3></header>
<form method="POST" action="{$smarty.server.SCRIPT_NAME}">
<input type="hidden" name="page" value="{$smarty.request.page}">
<input type="hidden" name="action" value="{$smarty.request.action}">
<input type="hidden" name="template" value="{$CURRENT_TEMPLATE}">
<input type="hidden" name="do" value="save">
<div class="module_content">
<fieldset>
<label>Active</label>
<input type="hidden" name="active" value="0" />
<input type="checkbox" name="active" value="1" id="active" {nocache}{if $DATABASE_TEMPLATE.active}checked{/if}{/nocache} />
<label for="active" style="margin: -1px 0px 0px -186px;"></label>
</fieldset>
<fieldset>
<label>Content</label>
<textarea name="content" rows="15" type="text" required>{nocache}{$DATABASE_TEMPLATE.content nofilter}{/nocache}</textarea>
</fieldset>
<fieldset>
<label>Original Template Content</label>
<textarea readonly rows="15" type="text" required>{nocache}{$ORIGINAL_TEMPLATE nofilter}{/nocache}</textarea>
</fieldset>
</div>
<footer>
<div class="submit_link">
<input type="submit" value="Save" class="alt_btn">
</div>
</footer>
</form>
</article>
<div class="row">
{include file="admin/templates/browser.tpl"}
{include file="admin/templates/editor.tpl"}
</div>

View File

@ -0,0 +1,37 @@
<form class="col-lg-9" method="POST" action="{$smarty.server.SCRIPT_NAME}">
<input type="hidden" name="page" value="{$smarty.request.page}">
<input type="hidden" name="action" value="{$smarty.request.action}">
<input type="hidden" name="template" value="{$CURRENT_TEMPLATE}">
<input type="hidden" name="do" value="save">
<div class="panel panel-info">
<div class="panel-heading">
<i class="fa fa-pencil fa-fw"></i> Edit template '{$CURRENT_TEMPLATE}'
</div>
<div class="panel-body no-padding">
<table class="table table-striped table-bordered table-hover">
<tr>
<td><label>Active</label></td>
<td>
<input type="hidden" name="active" value="0" />
<input type="checkbox" data-size="small" class="switch" name="active" value="1" id="active" {nocache}{if $DATABASE_TEMPLATE.active}checked{/if}{/nocache} />
</td>
</tr>
<tr>
<td><label>Content</label></td>
<td>
<textarea name="content" rows="15" type="text" class="form-control" required>{nocache}{$DATABASE_TEMPLATE.content nofilter}{/nocache}</textarea>
</td>
</tr>
<tr>
<td><label>Original Template Content</label></td>
<td>
<textarea readonly rows="15" type="text" class="form-control">{nocache}{$ORIGINAL_TEMPLATE nofilter}{/nocache}</textarea>
</td>
</tr>
</table>
</div>
<div class="panel-footer">
<input type="submit" value="Save" class="btn btn-success">
</div>
</div>
</form>