Deprecated: Assigning the return value of new by reference is deprecated in /home/bluestat/public_html/source/index.php on line 477
input_clean('styleid', TYPE_INT); if ($kalens->in['styleid'] != -1) { $db->query("DELETE FROM " . TABLE_PREFIX . "template WHERE styleid = " . $kalens->in['styleid']); } $admin->redirect("templates.php?do=modify&styleid=" . $kalens->in['styleid']); } // ################################################################### if ($_REQUEST['do'] == 'deleteall') { $admin->page_confirm($lang->string('Are you sure you want to revert all of this styles templates to their default state?'), 'templates.php', 'killall', array('styleid', $kalens->in['styleid'])); } // ################################################################### if ($_POST['do'] == 'kill') { $tpl = new TemplateAPI($kalens); $tpl->set('templateid', $kalens->in['templateid']); $tpl->set_condition(); $tpl->delete(); // Send the user on their merry way $admin->redirect("templates.php?do=modify&styleid=" . $tpl->objdata['styleid']); } // ################################################################### if ($_REQUEST['do'] == 'delete') { $admin->page_confirm(sprintf($lang->string('Are you sure you want to remove the template %1$s (id: %2$s)?'), $kalens->in['template'], $kalens->in['id']), 'templates.php', 'kill', array('templateid' => $kalens->in['templateid'])); } // ################################################################### if ($_POST['do'] == 'insert') { $tpl = new TemplateAPI($kalens); $tpl->set('templatename', $kalens->in['templatename']); $tpl->set('styleid', $kalens->in['styleid']); $tpl->set('template', $_POST['template']); $tpl->insert(); $admin->redirect('templates.php?do=modify&styleid=' . $kalens->in['styleid']); } // ################################################################### if ($_REQUEST['do'] == 'add') { $admin->page_start($lang->string('New Template')); $admin->form_start('templates.php', 'insert'); $admin->form_hidden_field('styleid', $kalens->input_clean('styleid', TYPE_INT)); $admin->table_start(); $admin->table_head($lang->string('New Template')); $admin->row_input($lang->string('Name'), 'templatename'); $admin->row_textarea($lang->string('Data'), 'template', '', 2, 30, 75, true, 'width: 98%'); $admin->row_submit(); $admin->table_end(); $admin->form_end(); $admin->page_end(); } // ################################################################### if ($_POST['do'] == 'update') { $kalens->input_clean('styleid', TYPE_INT); $templateid = $kalens->input_clean('templateid', TYPE_INT); // This is a brand-new customization if ($kalens->in['templateid'] == -1) { if ($kalens->in['styleid'] != -1) { $tpl = new TemplateAPI($kalens); $tpl->set('templatename', $kalens->in['templatename']); $tpl->set('styleid', $kalens->in['styleid']); $tpl->set('template', $_POST['template']); $tpl->insert(); $templateid = $tpl->insertid; } } // Just a boring old update else { $tpl = new TemplateAPI($kalens); $tpl->set('templateid', $kalens->in['templateid']); $tpl->set_condition(); $tpl->set('templatename', $kalens->in['templatename']); $tpl->set('template', $_POST['template']); $tpl->set('dateline', TIMENOW); $tpl->update(); } if ($kalens->in['reload']) { $admin->redirect("templates.php?do=edit&id=" . $templateid); } else { $admin->redirect("templates.php?do=modify&styleid=" . $kalens->in['styleid']); } } // ################################################################### if ($_REQUEST['do'] == 'edit') { $kalens->input_clean_array(array( 'id' => TYPE_INT, 'styleid' => TYPE_INT )); if ($kalens->in['name']) { $template = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "template WHERE templatename = '" . $kalens->input_escape('name') . "' AND styleid = -1"); } else { $template = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "template WHERE templateid = " . $kalens->in['id']); } $admin->page_start($lang->string('Edit Template')); $admin->form_start('templates.php', 'update'); $admin->form_hidden_field('templateid', ($kalens->in['name'] ? -1 : $kalens->in['id'])); $admin->form_hidden_field('styleid', (($template['styleid'] == -1 AND $kalens->in['name']) ? $kalens->in['styleid'] : $template['styleid'])); $admin->table_start(); $admin->table_head(sprintf($lang->string('Edit Template - %1$s (id: %2$d)'), $template['templatename'], $template['templateid'])); if ($template['styleid'] == -1) { $admin->row_input($lang->string('Name'), 'templatename', $template['templatename']); } else { $admin->form_hidden_field('templatename', $template['templatename']); $admin->row_text($lang->string('Name'), $template['templatename']); } $admin->row_textarea($lang->string('Data'), 'template', $kalens->entity_encode($template['template']), 2, 30, 75, true, 'width: 98%'); $admin->row_submit('' . $lang->string('Reload After Save?')); $admin->table_end(); $admin->form_end(); $admin->page_end(); } // ################################################################### if ($_REQUEST['do'] == 'view') { $tpl = new TemplateAPI($kalens); $tpl->dorelations = array(); $tpl->set('templatename', $kalens->in['template']); $tpl->set('styleid', -1); $tpl->set_condition(array('templatename', 'styleid')); $tpl->fetch(); $admin->page_start($lang->string('View Original')); $admin->table_start(); $admin->table_head($lang->string('View Original')); $admin->row_input($lang->string('Name'), 'templatename', $tpl->objdata['templatename']); $admin->row_textarea($lang->string('Data'), 'template', $kalens->entity_encode($tpl->objdata['template']), 2, 30, 75, true, 'width: 98%'); $admin->table_end(); $admin->page_end(); } // ################################################################### if ($_REQUEST['do'] == 'modify') { $admin->page_start($lang->string('Template Manager')); $kalens->input_clean('styleid', TYPE_INT); if ($kalens->in['styleid'] == -1) { $style['styleid'] = -1; } else { $style = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "style WHERE styleid = " . $kalens->in['styleid']); } if ($style['styleid']) { // Get the master style's templates to use as a base $master_style_get = $db->query("SELECT * FROM " . TABLE_PREFIX . "template WHERE styleid = -1 ORDER BY templatename ASC"); while ($master = $db->fetch_array($master_style_get)) { $master['ismaster'] = 1; $templates["$master[templatename]"] = $master; } $db->free_result($master_style_get); // Get the customized templates and replace them over the masters $get_templates = $db->query("SELECT * FROM " . TABLE_PREFIX . "template WHERE styleid = $style[styleid] ORDER BY templatename ASC"); while ($template = $db->fetch_array($get_templates)) { $template['ismaster'] = 0; $templates["$template[templatename]"] = $template; } $db->free_result($get_templates); // unset special templates if (!DEVDEBUG) { unset($templates['STYLE_VARS']); } // Go through each item in the array and break the name apart via underscores // then, group them by the element before the first underscore // Go through the grouped items and merge any upper case groups with the lower case ones -- keeping the upper case as the key foreach ($templates AS $name => $array) { $group = explode('_', $name); $group = $group[0]; $groupup = strtoupper($group); // If there is a template group with an upper case name of a lower case name if (is_array($templatelist["$groupup"])) { // Go through the items in the old case-sensitive groups and reassign them to the all upper-case groups foreach ($templatelist["$groupup"] AS $_value) { $templatelist["$groupup"][] = $_value; unset($templatelist["$group"]["$_value"]); } } // There is no group for this template, so just put it in the list else { $templatelist["$group"][] = $array; } } unset($templates); // Construct depth mark on all of the templates require_once('./includes/date.php'); foreach ($templatelist AS $group => $subtemplates) { if (count($subtemplates) > 1) { sort($subtemplates); unset($orderlist); foreach ($subtemplates AS $_key => $_value) { $orderlist["$_value[templatename]"] = $_key; } ksort($orderlist); $optlist[] = "\tstring('%1$s Group'), $group) . "\">"; foreach ($orderlist AS $key => $value) { $_value = &$subtemplates["$value"]; $templateid = ($style['styleid'] != -1 ? ($_value['ismaster'] ? '^' : $_value['templateid']) : $_value['templateid']); $date = pcdate('standard', $_value['dateline']); $optlist[] = "\t\t"; } $optlist[] = "\t"; } else { $templateid = ($style['styleid'] != -1 ? ($subtemplates[0]['ismaster'] ? '^' : $subtemplates[0]['templateid']) : $subtemplates[0]['templateid']); $date = pcdate('standard', $subtemplates[0]['dateline']); $optlist[] = "\t"; } } $jsout_style = $style['styleid']; unset($templates); $jslang = js_safe_language(array( 'templateinfo' => $lang->string('Welcome to the ProCal template system. Click on a template\'s name to view it\'s information here. You can double click it to edit it or you can use one of the links above.'), 'templateinfo_div_nochange' => $lang->string('
%1$s has not been modified.

To edit this template, use the button above.'), 'templateinfo_div_changed' => $lang->string('
%1$s has been modified

If you want to revert this template to its original state, you can do so with the button above.

Modified on: %2$s'), '[UNDEFINED: %1$s]' )); require('./admin/js.php'); $admin->page_code($js_template_manager); // Render the select menu $admin->table_start(); $admin->table_head(sprintf($lang->string('%1$s Manager'), $lang->string('Template')). ' - ' . $style['stylename'] . ' (styleid: ' . $style['styleid'] . ')'); $admin->form_start('', '', false, 'templatemanager'); $control_box = "
string('Edit') . "\" />  string('Revert') . "\" />  string('View Original') . "\" />
" . $lang->string('Welcome to the ProCal template system. Click on a template\'s name to view it\'s information here. You can double click it to edit it or you can use one of the links above.') . "
" . ($style['styleid'] != -1 ? " " . $lang->string('Resync All Templates') . "

" : '') . "
"; $admin->row_text("\n\n", $control_box); unset($optlist); $admin->form_end(); $admin->row_span('' . sprintf($lang->string('[%1$s]'), $lang->string('New')) . '', 'tfoot', 'center'); $admin->form_start('templates.php', 'styleopts'); $admin->form_hidden_field('styleid', $style['styleid']); $admin->table_head($lang->string('StyleVars Leave StyleVars blank to have them revert to their defaults.')); // ------------------------------------------------------------------- // handle style vars // ------------------------------------------------------------------- // get master stylevars $masterset = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "template WHERE templatename = 'STYLE_VARS' AND styleid = -1"); // get current active stylevars $currentactive = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "template WHERE templatename = 'STYLE_VARS' AND styleid = $style[styleid]"); // evaluate the master set eval($masterset['template']); $mastervars = $stylevar; // evaluate the second set if (trim($currentactive['template'])) { eval($currentactive['template']); } else { $currentactive = array(); } // print out stylevars foreach ($mastervars AS $varname => $var) { $admin->row_input(AdminStrings::fetchStyleVar($varname) . ($var != $stylevar["$varname"] ? "" . $lang->string('Modified') . "" : ''), "stylevar[$varname]", htmlspecialchars(stripslashes($stylevar["$varname"]))); } $admin->row_submit(); $admin->form_end(); $admin->table_end(); } $admin->page_end(); } // ####################### UPDATE STYLE OPTIONS ###################### if ($_POST['do'] == 'styleopts') { $kalens->input_clean('styleid', TYPE_INT); $masterset = $db->query_first("SELECT * FROM " . TABLE_PREFIX . "template WHERE templatename = 'STYLE_VARS' AND styleid = -1"); eval($masterset['template']); foreach ($_POST['stylevar'] AS $var => $value) { $varset[] = "\$stylevar[$var] = '" . (!trim($value) ? ($vars['styleid'] != -1 ? $stylevar["$var"] : '') : addslashes(html_entity_decode($value))) . "';"; } $stylevars = implode("\n\n", $varset); if ($kalens->in['styleid'] == -1 OR $stylevars != $masterset['template']) { if ($db->query_first("SELECT * FROM " . TABLE_PREFIX . "template WHERE templatename = 'STYLE_VARS' AND styleid = $vars[styleid]")) { $db->query("UPDATE " . TABLE_PREFIX . "template SET template = '" . addslashes($stylevars) . "', dateline = " . TIMENOW . " WHERE templatename = 'STYLE_VARS' AND styleid = " . $kalens->in['styleid']); } else { $db->query("INSERT INTO " . TABLE_PREFIX . "template (templatename, styleid, template, dateline) VALUES ('STYLE_VARS', " . $kalens->in['styleid'] . ", '" . addslashes($stylevars) . "', " . TIMENOW . ")"); } } else { $db->query("DELETE FROM " . TABLE_PREFIX . "template WHERE templatename = 'STYLE_VARS' AND styleid = " . $kalens->in['styleid']); } $admin->redirect("templates.php?do=manage&id=" . $kalens->in['styleid']); } /*=====================================================================*\ || ################################################################### || # $HeadURL$ || # $Id$ || ################################################################### \*=====================================================================*/ ?>