Skip to content

Commit

Permalink
5686 added handler to hold edit mode state when advanced mode is enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
gregrgay committed Jun 30, 2016
1 parent e6295ae commit d85fc7b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
16 changes: 9 additions & 7 deletions template_editor/edit_layout.php
Expand Up @@ -12,8 +12,12 @@
define('TR_INCLUDE_PATH', '../include/');
require(TR_INCLUDE_PATH.'vitals.inc.php');
require_once(TR_INCLUDE_PATH.'classes/DAO/UsersDAO.class.php');
$_custom_head .= '<link rel="stylesheet" href="themes/'.$_SESSION['prefs']['PREF_THEME'].'/template_editor/style.css" type="text/css" />';
$_custom_head .= '<script type="text/javascript" src="template_editor/js/layout.js"></script>';
$_custom_head .= "\n".'<link rel="stylesheet" href="themes/'.$_SESSION['prefs']['PREF_THEME'].'/template_editor/style.css" type="text/css" />';
$_custom_head .= "\n".'<script type="text/javascript" src="template_editor/js/layout.js"></script>';

$template=strip_tags($addslashes($_GET['temp']));
$_custom_css = "templates/layouts"."/". $template."/".$template.".css";
$_custom_head .= "\n".'<link rel="stylesheet" href="'.$_custom_css.'" type="text/css" />';

$type="layouts";
$temp=htmlspecialchars($_GET['temp'], ENT_QUOTES, 'UTF-8');
Expand All @@ -25,19 +29,17 @@


require('classes/TemplateCommons.php');

$commons=new TemplateCommons('../templates');

$template=strip_tags($addslashes($_GET['temp']));

// non existing template name
if(!$commons->template_exists('layouts', $template)) {
header('Location: index.php');
exit;
}
if(isset ($_POST['submit'])) {
$commons->save_file("layouts/".$template,$template.".css",$_POST['css_text']);
header('Location:'.$_SERVER['PHP_SELF'].'?temp='.urlencode($template).SEP.'lastelement='.urlencode($_REQUEST['lastelement']));
$msg->addFeedback('TEMPLATE_UPDATED');
header('Location:'.$_SERVER['PHP_SELF'].'?mode='.intval($_POST['edit_mode']).SEP.'temp='.urlencode($template).SEP.'lastelement='.urlencode($_REQUEST['lastelement']));
exit;
}
if(isset ($_POST['upload'])) {
Expand All @@ -46,14 +48,14 @@
exit;

}elseif(isset ($_POST['uploadscrn'])) {

echo $commons->upload_image("layouts/".$template,"screenshot-". $template.".png");
header('Location:'.$_SERVER['PHP_SELF'].'?temp='.urlencode($template).SEP.'lastelement='.urlencode($_REQUEST['lastelement']));
exit;
}

$css_path=realpath("../templates/layouts")."/". $template."/".$template.".css";
$screenshot_path=realpath("../templates/layouts")."/". $template."/screenshot-".$template.".png";

require(TR_INCLUDE_PATH.'header.inc.php');

if(file_exists($css_path)) {
Expand Down
18 changes: 14 additions & 4 deletions themes/default/template_editor/layout_tool.tmpl.php
Expand Up @@ -25,7 +25,17 @@
});
</script>
<?php } ?>

<?php if($_GET['mode'] == 1){ ?>
<script type="text/javascript">
$( document ).ready(function() {
editmode = 1;
setup_toolbar();
});
</script>
<?php } ?>
<style>
<?php echo $this->css_code; ?>
</style>
<div id="subnavlistcontainer">
<div id="sub-navigation">
<span style="width:3em; float:left;margin-left:2em;margin-right:-2em;">
Expand All @@ -47,12 +57,11 @@
<div id='layout_topbar' tabindex="0" accesskey="e" aria-label="<?php echo _AT('template_editor_howto'); ?>">
<label for="selector"><?php echo _AT('selector'); ?>:</label>
<input id="selector" type="text" size="15" disabled aria-live="assertive">

<label for="mode_radios" style="margin-left:15px;"><?php echo _AT('edit_mode'); ?></label>
<span class="bordered" id="mode_radios">
<input type="radio" name="edit_mode" value="0" id="basic_mode" title="<?php echo _AT('basic'); ?>" checked="checked" accesskey="b">
<input type="radio" name="edit_mode" value="0" id="basic_mode" title="<?php echo _AT('basic'); ?>" <?php if($_GET['mode'] == 0){ echo 'checked="checked"';} ?> accesskey="b">
<label for="basic_mode"><?php echo _AT('basic'); ?></label>
<input type="radio" name="edit_mode" value="1" id="adv_mode" title="<?php echo _AT('advanced'); ?>" accesskey="a">
<input type="radio" name="edit_mode" value="1" id="adv_mode" title="<?php echo _AT('advanced'); ?>" accesskey="a" <?php if($_GET['mode'] == 1){ echo 'checked="checked"';} ?>>
<label for="adv_mode"><?php echo _AT('advanced'); ?></label>
</span>
<input type="submit" name="submit" value="<?php echo _AT('cancel'); ?>" title="<?php echo _AT('cancel'); ?>"accesskey="c" style="float:right;"/>
Expand Down Expand Up @@ -184,6 +193,7 @@
<li><?php echo _AT('template_list_item'); ?></li>
</ol>
<table title="table" >
<caption><?php echo _AT('template_table_caption'); ?></caption>
<tr><th title="TH"><?php echo _AT('template_table_header'); ?></th><th><?php echo _AT('template_table_header'); ?></th></tr>
<tr><td title="TD"><?php echo _AT('template_table_data'); ?></td><td><?php echo _AT('template_table_data'); ?></td></tr>
</table>
Expand Down

0 comments on commit d85fc7b

Please sign in to comment.