/system/cp/cp.templates.php
PHP | 4143 lines | 2890 code | 979 blank | 274 comment | 591 complexity | 51ea15fb5788f46a56557681b0221451 MD5 | raw file
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- =====================================================
- ExpressionEngine - by EllisLab
- -----------------------------------------------------
- http://expressionengine.com/
- -----------------------------------------------------
- Copyright (c) 2003 - 2010 EllisLab, Inc.
- =====================================================
- THIS IS COPYRIGHTED SOFTWARE
- PLEASE READ THE LICENSE AGREEMENT
- http://expressionengine.com/docs/license.html
- =====================================================
- File: cp.templates.php
- -----------------------------------------------------
- Purpose: The template management functions
- =====================================================
- */
- if ( ! defined('EXT'))
- {
- exit('Invalid file request');
- }
- class Templates {
- var $template_map = array();
-
- // Reserved Template names
- var $reserved_names = array('act', 'css', 'trackback');
-
- // Reserved Global Variable names
- var $reserved_vars = array(
- 'lang',
- 'charset',
- 'homepage',
- 'debug_mode',
- 'gzip_mode',
- 'version',
- 'elapsed_time',
- 'hits',
- 'total_queries',
- 'XID_HASH'
- );
-
- function Templates()
- {
- global $IN, $DSP, $PREFS;
-
- if ($PREFS->ini("use_category_name") == 'y' AND $PREFS->ini("reserved_category_word") != '')
- {
- $this->reserved_names[] = $PREFS->ini("reserved_category_word");
- }
-
- if ($PREFS->ini("forum_is_installed") == 'y' AND $PREFS->ini("forum_trigger") != '')
- {
- $this->reserved_names[] = $PREFS->ini("forum_trigger");
- }
-
- if ($PREFS->ini("profile_trigger") != '')
- {
- $this->reserved_names[] = $PREFS->ini("profile_trigger");
- }
-
- if ($IN->GBL('tgpref', 'GP') AND $IN->GBL('M') != '')
- {
- $DSP->url_append = AMP.'tgpref='.$IN->GBL('tgpref', 'GP');
- }
- switch($IN->GBL('M'))
- {
- case 'global_variables' : $this->global_variables();
- break;
- case 'edit_global_var' : $this->edit_global_variable();
- break;
- case 'update_global_var' : $this->update_global_variable();
- break;
- case 'delete_global_var' : $this->global_variable_delete_conf();
- break;
- case 'do_delete_global_var' : $this->delete_global_variable();
- break;
- case 'new_tg_form' : $this->edit_template_group_form();
- break;
- case 'edit_tg_form' : $this->edit_template_group_form();
- break;
- case 'update_tg' : $this->update_template_group();
- break;
- case 'edit_tg_order' : $this->edit_template_group_order_form();
- break;
- case 'update_tg_order' : $this->update_template_group_order();
- break;
- case 'tg_del_conf' : $this->template_group_del_conf();
- break;
- case 'delete_tg' : $this->template_group_delete();
- break;
- case 'new_templ_form' : $this->new_template_form();
- break;
- case 'new_template' : $this->create_new_template();
- break;
- case 'tmpl_del_conf' : $this->template_del_conf();
- break;
- case 'delete_template' : $this->delete_template();
- break;
- case 'edit_template' : $this->edit_template();
- break;
- case 'update_template' : $this->update_template();
- break;
- case 'edit_preferences' : $this->edit_preferences();
- break;
- case 'update_template_prefs' : $this->update_template_prefs();
- break;
- case 'template_access' : $this->template_access();
- break;
- case 'update_template_access' : $this->update_template_access();
- break;
- case 'revision_history' : $this->view_template_revision();
- break;
- case 'clear_revisions' : $this->clear_revision_history();
- break;
- case 'export_tmpl' : $this->export_templates_form();
- break;
- case 'export' : $this->export_templates();
- break;
- case 'export_template' : $this->export_template();
- break;
- case 'template_prefs_manager': $this->template_prefs_manager();
- break;
- case 'update_manager_prefs' : $this->update_manager_prefs();
- break;
- default : $this->template_manager();
- break;
- }
- }
- /* END */
- /** -----------------------------
- /** Template Preferences Manager
- /** -----------------------------*/
-
- function template_prefs_manager($message = '', $group_id = '')
- {
- global $IN, $DSP, $DB, $SESS, $LANG, $REGX, $PREFS;
-
- if ( ! $DSP->allowed_group('can_admin_templates'))
- {
- return $DSP->no_access_message();
- }
-
- if ($IN->GBL('id') !== FALSE)
- {
- $group_id = $IN->GBL('id');
- }
-
- $user_blog = FALSE;
-
- $DSP->crumbline = TRUE;
- if ($SESS->userdata['tmpl_group_id'] != 0)
- {
- $user_blog = TRUE;
- }
-
- /** -------------------------------------
- /** Opening Remarks
- /** -------------------------------------*/
-
- $DSP->title = $LANG->line('template_preferences_manager');
- $DSP->crumb = $LANG->line('template_preferences_manager');
- $r = $DSP->qdiv('tableHeading', $LANG->line('template_preferences_manager'));
-
- ob_start();
- ?>
- <script type="text/javascript">
- function showHideTemplate(htmlObj)
- {
- if (isNaN(htmlObj.value) || htmlObj.value == '') return;
-
- for (var g = 0; g < htmlObj.options.length; g++)
- {
- if (document.getElementById('template_group_div_' + htmlObj.options[g].value))
- {
- extTextDiv = document.getElementById('template_group_div_' + htmlObj.options[g].value);
-
- if (htmlObj.options[g].selected == true)
- {
- if (extTextDiv.style.display != 'block')
- {
- extTextDiv.style.display = "block";
- }
- }
- else if(extTextDiv.style.display != 'none')
- {
- extTextDiv.style.display = "none";
- }
- }
- }
- }
- </script>
- <?php
- $r .= ob_get_contents();
- ob_end_clean();
-
- /** -------------------------------------
- /** Retrieve Valid Template Groups and Templates
- /** -------------------------------------*/
-
- if ($SESS->userdata['group_id'] != 1 && (sizeof($SESS->userdata['assigned_template_groups']) == 0 OR $DSP->allowed_group('can_admin_templates') == FALSE))
- {
- $r .= $DSP->qdiv('', $LANG->line('no_templates_assigned'));
- return $DSP->body = $r;
- }
-
- $sql = "SELECT tg.group_id, tg.group_name, t.template_id, t.template_name
- FROM exp_template_groups tg , exp_templates t
- WHERE tg.group_id = t.group_id
- AND tg.site_id = '".$DB->escape_str($PREFS->ini('site_id'))."'";
-
- if ($user_blog === TRUE)
- {
- $sql .= " AND t.group_id = '".$SESS->userdata['tmpl_group_id']."'";
- }
- else
- {
- $sql .= " AND is_user_blog = 'n'";
- }
- if ($SESS->userdata['group_id'] != 1)
- {
- $sql .= " AND t.group_id IN (";
-
- foreach ($SESS->userdata['assigned_template_groups'] as $key => $val)
- {
- $sql .= "'$key',";
- }
-
- $sql = substr($sql, 0, -1).")";
- }
-
- $sql .= " ORDER BY tg.group_order, t.group_id, t.template_name";
-
- $query = $DB->query($sql);
-
- /** -------------------------------------
- /** Nothing?
- /** -------------------------------------*/
-
- if ($query->num_rows == 0)
- {
- $DSP->body .= $DSP->qdiv('alert', $LANG->line('no_templates_available'));
- $DSP->body .= $DSP->qdiv('itemWrapper', $DSP->anchor(BASE.AMP.'C=templates', $LANG->line('back')));
- return;
- }
-
- /** -------------------------------------
- /** Create Our MultiSelect Lists
- /** -------------------------------------*/
-
- $current_group = 0;
-
- $groups = "<select onchange='showHideTemplate(this);' name='template_groups' class='multiselect' size='10' multiple='multiple' style='width:160px'>";
- $templates = $DSP->div('default', '', 'template_group_div_'.$query->row['group_id'], '', ($group_id == $query->row['group_id']) ? '' : 'style="display: none; padding:0;"').
- $DSP->input_select_header('template_group_'.$query->row['group_id'].'[]', 'y', 8);
-
- foreach ($query->result as $row)
- {
- if ($row['group_id'] != $current_group)
- {
- $groups .= $DSP->input_select_option($row['group_id'], $REGX->form_prep($row['group_name']), ($group_id == $row['group_id']) ? 'y' : '');
-
- if ($current_group != 0)
- {
- $templates .= $DSP->input_select_footer().
- $DSP->div_c().
- $DSP->div('default', '', 'template_group_div_'.$row['group_id'], '', ($group_id == $row['group_id']) ? '' : 'style="display: none; padding:0;"').
- $DSP->input_select_header('template_group_'.$row['group_id'].'[]', 'y', 8);
- }
- }
-
- $templates .= $DSP->input_select_option($row['template_id'], $REGX->form_prep($row['template_name']), '');
-
- $current_group = $row['group_id'];
- }
-
- $groups .= $DSP->input_select_footer();
- $templates .= $DSP->input_select_footer().$DSP->div_c();
-
- /** -------------------------------------
- /** Templates and Form
- /** -------------------------------------*/
- $r .= $DSP->form_open(array('action' => 'C=templates'.AMP.'M=update_manager_prefs', 'name' => 'templateManagement', 'id' => 'templateManagement'));
-
- if ($message != '')
- {
- $r .= $DSP->table('tableBorder', '0', '', '100%')
- . $DSP->tr()
- . $DSP->table_qcell('tableCellOne', $DSP->qspan('success', $LANG->line('preferences_updated')))
- . $DSP->tr_c()
- .$DSP->table_c();
- }
-
- $r .= $DSP->table('tableBorder', '0', '', '100%')
- .$DSP->tr()
- .$DSP->table_qcell('tableHeadingAlt', $LANG->line('template_groups'))
- .$DSP->table_qcell('tableHeadingAlt', $LANG->line('selected_templates'))
- .$DSP->td_c()
- .$DSP->tr_c()
- .$DSP->tr()
- .$DSP->table_qcell('tableCellOne', $groups, '400px', 'top')
- .$DSP->table_qcell('tableCellOne', $templates, '400px', 'top')
- .$DSP->tr_c()
- .$DSP->table_c();
-
- /** -------------------------------------
- /** Preferences
- /** -------------------------------------*/
-
- $r .= BR.$DSP->table('tableBorder', '0', '', '100%')
- .$DSP->tr()
- .$DSP->table_qcell('tableHeadingAlt', $LANG->line('type'));
-
-
- $r .= $DSP->td('tableHeadingAlt', '', '1').$LANG->line('cache_enable').$DSP->td_c();
-
- $r .= $DSP->table_qcell('tableHeadingAlt', $LANG->line('refresh_interval'));
-
- if ($SESS->userdata['group_id'] == 1)
- {
- $r .= $DSP->td('tableHeadingAlt').$LANG->line('enable_php').$DSP->td_c();
- $r .= $DSP->td('tableHeadingAlt').$LANG->line('parse_stage').$DSP->td_c();
- }
-
- if ($PREFS->ini('save_tmpl_files') == 'y' AND $PREFS->ini('tmpl_file_basepath') != '')
- {
- $r .= $DSP->table_qcell('tableHeadingAlt', $LANG->line('save_template_file'));
- }
-
- $r .= $DSP->table_qcell('tableHeadingAlt', $LANG->line('hit_counter'));
-
- $r .= $DSP->tr_c();
-
- $r .= $DSP->tr();
- $r .= $DSP->td('tableCellOne', '', '1').NBS.$DSP->td_c()
- .$DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', ''))
- .$DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', $LANG->line('refresh_in_minutes')));
-
- if ($SESS->userdata['group_id'] == 1)
- {
- $r .= $DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', ''))
- .$DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', ''));
- }
-
- if ($PREFS->ini('save_tmpl_files') == 'y' AND $PREFS->ini('tmpl_file_basepath') != '')
- {
- $r .= $DSP->td('tableCellOne', '', '1').NBS.$DSP->td_c();
- }
-
- $r .= $DSP->td('tableCellOne', '', '1').NBS.$DSP->td_c();
-
- $r .= $DSP->tr_c();
-
- $style = 'tableCellOne';
-
- $r .= $DSP->tr();
-
- $t = $DSP->input_select_header('template_type');
- $t .= $DSP->input_select_option('null', $LANG->line('do_not_change'), 1);
- $t .= $DSP->input_select_option('css', $LANG->line('css_stylesheet'));
- $t .= $DSP->input_select_option('js', $LANG->line('js'));
- $t .= $DSP->input_select_option('rss', $LANG->line('rss'));
- $t .= $DSP->input_select_option('static', $LANG->line('static'));
- $t .= $DSP->input_select_option('webpage', $LANG->line('webpage'));
- $t .= $DSP->input_select_option('xml', $LANG->line('xml'));
- $t .= $DSP->input_select_footer();
- $r .= $DSP->table_qcell($style, $t);
-
- $t = $DSP->input_select_header('cache');
- $t .= $DSP->input_select_option('null', $LANG->line('do_not_change'),'');
- $t .= $DSP->input_select_option('y', $LANG->line('yes'));
- $t .= $DSP->input_select_option('n', $LANG->line('no'));
- $t .= $DSP->input_select_footer();
-
- $r .= $DSP->table_qcell($style, $t);
-
- $r .= $DSP->table_qcell($style, $DSP->input_text('refresh', '0', '8', '6', 'input', '50px'));
-
-
- if ($SESS->userdata['group_id'] == 1)
- {
- $t = $DSP->input_select_header('allow_php');
- $t .= $DSP->input_select_option('null', $LANG->line('do_not_change'),'');
- $t .= $DSP->input_select_option('y', $LANG->line('yes'));
- $t .= $DSP->input_select_option('n', $LANG->line('no'));
- $t .= $DSP->input_select_footer();
-
- $r .= $DSP->table_qcell($style, $t);
-
- $t = $DSP->input_select_header('php_parse_location');
- $t .= $DSP->input_select_option('null', $LANG->line('do_not_change'),'');
- $t .= $DSP->input_select_option('i', $LANG->line('input'));
- $t .= $DSP->input_select_option('o', $LANG->line('output'));
- $t .= $DSP->input_select_footer();
-
- $r .= $DSP->table_qcell($style, $t);
- }
-
- if ($PREFS->ini('save_tmpl_files') == 'y' AND $PREFS->ini('tmpl_file_basepath') != '')
- {
- $t = $DSP->input_select_header('save_template_file');
- $t .= $DSP->input_select_option('null', $LANG->line('do_not_change'),'');
- $t .= $DSP->input_select_option('y', $LANG->line('yes'));
- $t .= $DSP->input_select_option('n', $LANG->line('no'));
- $t .= $DSP->input_select_footer();
-
- $r .= $DSP->table_qcell($style, $t);
- }
- $r .= $DSP->table_qcell($style, $DSP->input_text('hits', '', '6', '13', 'input', '50px'));
-
- $r .=$DSP->tr_c();
-
- $r .= $DSP->table_c();
-
- if ($SESS->userdata['group_id'] == 1)
- {
- $r .= $DSP->qdiv('itemWrapper', $DSP->qdiv('highlight', $LANG->line('security_warning')));
- }
-
- /** -------------------------------------
- /** Access
- /** -------------------------------------*/
- $r .= BR.$DSP->table('tableBorder', '0', '', '100%').
- $DSP->tr().
- $DSP->td('tableHeadingAlt', '', 2).
- $LANG->line('template_access').
- $DSP->tr_c().
- $DSP->tr().
- $DSP->td('tableCellOne', '', '').
- $DSP->qdiv('defaultBold', $LANG->line('member_group')).
- $DSP->td_c().
- $DSP->td('tableCellOne', '', '').
- $DSP->qdiv('defaultBold', $LANG->line('can_view_template')).
- $DSP->td_c().
- $DSP->tr_c();
-
- $i = 0;
-
- $query = $DB->query("SELECT group_id, group_title FROM exp_member_groups WHERE site_id = '".$DB->escape_str($PREFS->ini('site_id'))."' AND group_id != '1' ORDER BY group_title");
- $access_e = array();
-
- foreach ($query->result as $row)
- {
- $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';
-
- $r .= $DSP->tr().
- $DSP->td($style, '40%').
- $row['group_title'].
- $DSP->td_c().
- $DSP->td($style, '60%');
-
- $r .= $LANG->line('yes').NBS.
- $DSP->input_radio('access_'.$row['group_id'], 'y', '').$DSP->nbs(3);
-
- $r .= $LANG->line('no').NBS.
- $DSP->input_radio('access_'.$row['group_id'], 'n', '').$DSP->nbs(3);
-
- $r .= $LANG->line('do_not_change').NBS.
- $DSP->input_radio('access_'.$row['group_id'], 'null', 1).$DSP->nbs(3);
-
- $r .= $DSP->td_c()
- .$DSP->tr_c();
-
- $access_e[] = "access_{$row['group_id']}";
- }
-
- $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';
-
- $r .= $this->template_access_toggle($access_e);
- $r .= $DSP->tr().
- $DSP->td($style, '40%').
- $DSP->qdiv('defaultBold', $LANG->line('select_all')).
- $DSP->td_c().
- $DSP->td($style, '60%');
- $r .= $LANG->line('yes').NBS.
- $DSP->input_radio('can_view', 'y', '', "onclick=\"toggle_access(this);\"").$DSP->nbs(3).
- $LANG->line('no').NBS.
- $DSP->input_radio('can_view', 'n', '', "onclick=\"toggle_access(this);\"").$DSP->nbs(3).
- $LANG->line('do_not_change').NBS.
- $DSP->input_radio('can_view', 'null', '', "onclick=\"toggle_access(this);\"").$DSP->nbs(3);
-
- $r .= $DSP->td_c().
- $DSP->tr_c();
-
- $r .= $DSP->table_c();
-
- $r .= $DSP->div('box');
- $r .= $DSP->heading($LANG->line('no_access_select_blurb'), 5);
- $r .= $DSP->qdiv('itemWrapper', $LANG->line('no_access_instructions'));
-
- $sql = "SELECT exp_template_groups.group_name, exp_templates.template_name, exp_templates.template_id
- FROM exp_template_groups, exp_templates
- WHERE exp_template_groups.group_id = exp_templates.group_id
- AND exp_template_groups.site_id = '".$DB->escape_str($PREFS->ini('site_id'))."'";
-
- if (USER_BLOG !== FALSE)
- {
- $sql .= " AND exp_template_groups.group_id = '".$DB->escape_str(UB_TMP_GRP)."'";
- }
- else
- {
- $sql .= " AND exp_template_groups.is_user_blog = 'n'";
- }
-
- $sql .= " ORDER BY exp_template_groups.group_name, exp_templates.template_name";
-
- $query = $DB->query($sql);
-
- $r .= $DSP->div()
- .$DSP->input_select_header('no_auth_bounce')
- .$DSP->input_select_option('null', $LANG->line('do_not_change'), '1');
-
- foreach ($query->result as $row)
- {
- $r .= $DSP->input_select_option($row['template_id'], $row['group_name'].'/'.$row['template_name'], '');
- }
-
- $r .= $DSP->input_select_footer().BR.BR;
-
- $t = $DSP->input_select_header('enable_http_auth');
- $t .= $DSP->input_select_option('null', $LANG->line('do_not_change'), 1);
- $t .= $DSP->input_select_option('y', $LANG->line('yes'));
- $t .= $DSP->input_select_option('n', $LANG->line('no'));
- $t .= $DSP->input_select_footer();
-
- $r .= $DSP->div('paddedTop');
- $r .= $DSP->heading($LANG->line('enable_http_authentication'), 5);
- $r .= $DSP->qdiv('itemWrapper', $t);
- $r .= $DSP->div_c();
- $r .= $DSP->div_c();
- $r .= $DSP->div_c().BR;
-
- $r .= $DSP->qdiv('itemWrapper', $DSP->input_submit($LANG->line('update')))
- .$DSP->form_close();
- $DSP->body = $r;
- }
- /* END */
-
-
- /** -----------------------------
- /** Template Preferences Manager - UPDATE
- /** -----------------------------*/
-
- function update_manager_prefs()
- {
- global $IN, $DSP, $DB, $SESS, $LANG, $REGX, $OUT, $PREFS;
-
- if ( ! $DSP->allowed_group('can_admin_templates'))
- {
- return $DSP->no_access_message();
- }
-
- $user_blog = ($SESS->userdata['tmpl_group_id'] != 0) ? TRUE : FALSE;
-
- /** -------------------------------------
- /** Determine Valid Template Groups and Templates
- /** -------------------------------------*/
-
- if ($SESS->userdata['group_id'] != 1 && (sizeof($SESS->userdata['assigned_template_groups']) == 0 OR $DSP->allowed_group('can_admin_templates') == FALSE))
- {
- return $DSP->no_access_message();
- }
-
- $sql = "SELECT t.template_id, t.group_id
- FROM exp_template_groups tg , exp_templates t
- WHERE tg.group_id = t.group_id
- AND tg.site_id = '".$DB->escape_str($PREFS->ini('site_id'))."'";
-
- if ($user_blog === TRUE)
- {
- $sql .= " AND t.group_id = '".$SESS->userdata['tmpl_group_id']."'";
- }
- else
- {
- $sql .= " AND is_user_blog = 'n'";
- }
-
- if ($SESS->userdata['group_id'] != 1)
- {
- $sql .= " AND t.group_id IN (";
-
- foreach ($SESS->userdata['assigned_template_groups'] as $key => $val)
- {
- $sql .= "'$key',";
- }
-
- $sql = substr($sql, 0, -1).")";
- }
-
- $query = $DB->query($sql);
-
- if ($query->num_rows == 0)
- {
- return $DSP->no_access_message();
- }
-
- $templates = array();
-
- foreach($_POST as $key => $value)
- {
- if (substr($key, 0, strlen('template_group_')) == 'template_group_' && is_array($value))
- {
- foreach($value as $template)
- {
- $templates[] = $DB->escape_str($template);
- }
- }
- }
-
- if (sizeof($templates) == 0)
- {
- $OUT->show_user_error('submission', $LANG->line('no_templates_selected'));
- }
-
- /** -------------------------------------
- /** Template Preferences
- /** -------------------------------------*/
-
- $data = array();
-
- if (in_array($_POST['template_type'], array('css', 'js', 'rss', 'static', 'webpage', 'xml')))
- {
- $data['template_type'] = $_POST['template_type'];
- }
-
- if ($_POST['cache'] == 'y' OR $_POST['cache'] == 'n')
- {
- $data['cache'] = $_POST['cache'];
-
- if ($_POST['refresh'] != '' && is_numeric($_POST['refresh']))
- {
- $data['refresh'] = $_POST['refresh'];
- }
- }
-
- if ($SESS->userdata['group_id'] == 1)
- {
- if ($_POST['allow_php'] == 'y' OR $_POST['allow_php'] == 'n')
- {
- $data['allow_php'] = $_POST['allow_php'];
-
- if ($_POST['php_parse_location'] == 'i' OR $_POST['php_parse_location'] == 'o')
- {
- $data['php_parse_location'] = $_POST['php_parse_location'];
- }
- }
- }
-
- if ($_POST['hits'] != '' && is_numeric($_POST['hits']))
- {
- $data['hits'] = $_POST['hits'];
- }
-
- if ($_POST['enable_http_auth'] == 'y' OR $_POST['enable_http_auth'] == 'n')
- {
- $data['enable_http_auth'] = $_POST['enable_http_auth'];
- }
-
- if ($_POST['no_auth_bounce'] != 'null')
- {
- $data['no_auth_bounce'] = $_POST['no_auth_bounce'];
- }
-
- if ($PREFS->ini('save_tmpl_files') == 'y' AND $PREFS->ini('tmpl_file_basepath') != '')
- {
- if ($_POST['save_template_file'] != 'null')
- {
- $data['save_template_file'] = $_POST['save_template_file'];
- }
- }
-
- if (sizeof($data) > 0)
- {
- $DB->query($DB->update_string('exp_templates', $data, "template_id IN ('".implode("','", $templates)."')"));
- }
-
- /** -------------------------------------
- /** Template Access
- /** -------------------------------------*/
-
- $yes = array();
- $no = array();
-
- $query = $DB->query("SELECT group_id FROM exp_member_groups WHERE site_id = '".$DB->escape_str($PREFS->ini('site_id'))."' AND group_id != '1' ORDER BY group_title");
-
- if ($query->num_rows > 0)
- {
- foreach($query->result as $row)
- {
- if ( isset($_POST['access_'.$row['group_id']]))
- {
- if ($_POST['access_'.$row['group_id']] == 'y')
- {
- $yes[] = $row['group_id'];
- }
- elseif($_POST['access_'.$row['group_id']] == 'n')
- {
- $no[] = $row['group_id'];
- }
- }
- }
- }
-
- if ( ! empty($yes) OR ! empty($no))
- {
- $access = array();
-
- if (sizeof($no) > 0)
- {
- foreach($templates as $template)
- {
- $access[$template] = $no;
- }
- }
-
- $query = $DB->query("SELECT * FROM exp_template_no_access WHERE template_id IN ('".implode("','", $templates)."')");
-
- if ($query->num_rows > 0)
- {
- foreach($query->result as $row)
- {
- if ( ! in_array($row['member_group'], $yes) && ! in_array($row['member_group'], $no))
- {
- $access[$row['template_id']][] = $row['member_group'];
- }
- }
- }
-
- $query = $DB->query("DELETE FROM exp_template_no_access WHERE template_id IN ('".implode("','", $templates)."')");
-
- foreach($access as $template => $groups)
- {
- if ( empty($groups)) continue;
-
- foreach($groups as $group)
- {
- $DB->query($DB->insert_string('exp_template_no_access', array('template_id' => $template, 'member_group' => $group)));
- }
- }
- }
-
- $this->template_prefs_manager('y');
- }
- /* END */
- /** -----------------------------
- /** Verify access privileges
- /** -----------------------------*/
- function template_access_privs($data = '')
- {
- global $SESS, $DB;
-
- // If the user is a Super Admin, return true
-
- if ($SESS->userdata['group_id'] == 1)
- {
- return TRUE;
- }
-
- $template_id = '';
- $group_id = '';
-
- if (is_array($data))
- {
- if (isset($data['template_id']))
- {
- $template_id = $data['template_id'];
- }
-
- if (isset($data['group_id']))
- {
- $group_id = $data['group_id'];
- }
- }
-
-
- if ($group_id == '')
- {
- if ($template_id == '')
- {
- return FALSE;
- }
- else
- {
- $query = $DB->query("SELECT group_id, template_name FROM exp_templates WHERE template_id = '".$DB->escape_str($template_id)."'");
-
- $group_id = $query->row['group_id'];
- }
- }
-
-
- if ($SESS->userdata['tmpl_group_id'] == 0)
- {
- $access = FALSE;
-
- foreach ($SESS->userdata['assigned_template_groups'] as $key => $val)
- {
- if ($group_id == $key)
- {
- $access = TRUE;
- break;
- }
- }
-
- if ($access == FALSE)
- {
- return FALSE;
- }
- }
- else
- {
- if ($group_id != $SESS->userdata['tmpl_group_id'] )
- {
- return FALSE;
- }
- }
- return TRUE;
- }
- /* END */
- /** -----------------------------
- /** Template Preferences
- /** -----------------------------*/
-
- function edit_preferences($group_id = '')
- {
- global $IN, $DSP, $DB, $SESS, $LANG, $PREFS;
-
- if ( ! $DSP->allowed_group('can_admin_templates'))
- {
- return $DSP->no_access_message();
- }
-
- if ($group_id == '')
- {
- if ( ! $group_id = $IN->GBL('id'))
- {
- return false;
- }
-
- $message = '';
- }
- else
- {
- $message = $DSP->qdiv('success', $LANG->line('preferences_updated'));
- }
-
- if ( ! is_numeric($group_id))
- {
- return FALSE;
- }
-
- $query = $DB->query("SELECT group_name FROM exp_template_groups WHERE group_id = '$group_id'");
-
- if ($query->num_rows == 0)
- {
- return FALSE;
- }
-
- $DSP->title = $LANG->line('template_preferences');
- $DSP->crumb = $LANG->line('template_preferences');
- $r = $DSP->form_open(array('action' => 'C=templates'.AMP.'M=update_template_prefs'))
- .$DSP->input_hidden('group_id', $group_id);
-
-
- $r .= $DSP->qdiv('tableHeading', $LANG->line('template_preferences').NBS.NBS.'('.$query->row['group_name'].')');
-
- if ($message != '')
- {
- $r .= $DSP->table('tableBorder', '0', '', '100%')
- . $DSP->tr()
- . $DSP->table_qcell('tableCellOne', $message)
- . $DSP->tr_c()
- .$DSP->table_c();
- }
-
- $r .= $DSP->table('tableBorder', '0', '', '100%')
- .$DSP->tr()
- .$DSP->table_qcell('tableHeadingAlt', $LANG->line('name_of_template'))
- .$DSP->table_qcell('tableHeadingAlt', $LANG->line('type'));
-
-
- $r .= $DSP->td('tableHeadingAlt', '', '2').$LANG->line('cache_enable').$DSP->td_c();
-
- $r .= $DSP->table_qcell('tableHeadingAlt', $LANG->line('refresh_interval'));
-
- if ($SESS->userdata['group_id'] == 1)
- {
- $r .= $DSP->td('tableHeadingAlt', '', '2').$LANG->line('enable_php').$DSP->td_c();
- $r .= $DSP->td('tableHeadingAlt', '', '2').$LANG->line('parse_stage').$DSP->td_c();
- }
-
- if ($PREFS->ini('save_tmpl_files') == 'y' AND $PREFS->ini('tmpl_file_basepath') != '')
- {
- $r .= $DSP->td('tableHeadingAlt', '', '2').$LANG->line('save_template_file').$DSP->td_c();
- }
-
- $r .= $DSP->table_qcell('tableHeadingAlt', $LANG->line('hit_counter'));
-
- $r .= $DSP->tr_c();
-
- $r .= $DSP->tr();
- $r .= $DSP->td('tableCellOne', '', '2').NBS.$DSP->td_c()
- .$DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', $LANG->line('yes')))
- .$DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', $LANG->line('no')))
- .$DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', $LANG->line('refresh_in_minutes')));
-
- if ($SESS->userdata['group_id'] == 1)
- {
- $r .= $DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', $LANG->line('yes')))
- .$DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', $LANG->line('no')))
- .$DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', $LANG->line('input')))
- .$DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', $LANG->line('output')));
- }
-
- if ($PREFS->ini('save_tmpl_files') == 'y' AND $PREFS->ini('tmpl_file_basepath') != '')
- {
- $r .= $DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', $LANG->line('yes')))
- .
- $DSP->table_qcell('tableCellOne', $DSP->qdiv('defaultBold', $LANG->line('no')));
- }
-
- $r .= $DSP->td('tableCellOne', '', '1').NBS.$DSP->td_c();
-
- $r .= $DSP->tr_c();
- $i = 0;
-
- // Fetch template preferences
-
- $query = $DB->query("SELECT template_id, template_name, template_type, group_id, save_template_file, allow_php, php_parse_location, no_auth_bounce, cache, refresh, hits FROM exp_templates WHERE group_id = '$group_id' ORDER BY template_name");
-
- foreach ($query->result as $row)
- {
- $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';
-
- $id = $row['template_id'].'__';
-
- $r .= $DSP->tr();
-
- $old = $DSP->input_hidden($id.'old_name', $row['template_name']);
-
- if ($row['template_name'] == 'index')
- {
- $r .= $DSP->table_qcell($style, $DSP->qdiv('defaultBold', $row['template_name']).$old);
- }
- else
- {
- $r .= $DSP->table_qcell($style, $DSP->input_text($id.'template_name', $row['template_name'], '15', '50', 'input', '110px').$old);
- }
-
- $t = $DSP->input_select_header($id.'template_type');
- $t .= $DSP->input_select_option('css', $LANG->line('css_stylesheet'), ($row['template_type'] == 'css') ? 1 : '');
- $t .= $DSP->input_select_option('js', $LANG->line('js'), ($row['template_type'] == 'js') ? 1 : '');
- $t .= $DSP->input_select_option('rss', $LANG->line('rss'), ($row['template_type'] == 'rss') ? 1 : '');
- $t .= $DSP->input_select_option('static', $LANG->line('static'), ($row['template_type'] == 'static') ? 1 : '');
- $t .= $DSP->input_select_option('webpage', $LANG->line('webpage'), ($row['template_type'] == 'webpage') ? 1 : '');
- $t .= $DSP->input_select_option('xml', $LANG->line('xml'), ($row['template_type'] == 'xml') ? 1 : '');
- $t .= $DSP->input_select_footer();
- $r .= $DSP->table_qcell($style, $t);
-
- $r .= $DSP->table_qcell($style, $DSP->input_radio($id.'cache', 'y', ($row['cache'] == 'y') ? 1 : ''));
- $r .= $DSP->table_qcell($style, $DSP->input_radio($id.'cache', 'n', ($row['cache'] == 'n') ? 1 : ''));
-
- $r .= $DSP->table_qcell($style, $DSP->input_text($id.'refresh', $row['refresh'], '8', '6', 'input', '50px'));
-
-
- if ($SESS->userdata['group_id'] == 1)
- {
- $r .= $DSP->table_qcell($style, $DSP->input_radio($id.'allow_php', 'y', ($row['allow_php'] == 'y') ? 1 : ''));
- $r .= $DSP->table_qcell($style, $DSP->input_radio($id.'allow_php', 'n', ($row['allow_php'] == 'n') ? 1 : ''));
-
- $r .= $DSP->table_qcell($style, $DSP->input_radio($id.'php_parse_location', 'i', ($row['php_parse_location'] == 'i') ? 1 : ''));
- $r .= $DSP->table_qcell($style, $DSP->input_radio($id.'php_parse_location', 'o', ($row['php_parse_location'] == 'o') ? 1 : ''));
- }
-
- if ($PREFS->ini('save_tmpl_files') == 'y' AND $PREFS->ini('tmpl_file_basepath') != '')
- {
- $r .= $DSP->table_qcell($style, $DSP->input_radio($id.'save_template_file', 'y', ($row['save_template_file'] == 'y') ? 1 : ''));
- $r .= $DSP->table_qcell($style, $DSP->input_radio($id.'save_template_file', 'n', ($row['save_template_file'] == 'n') ? 1 : ''));
- }
-
- $r .= $DSP->table_qcell($style, $DSP->input_text($id.'hits', $row['hits'], '6', '13', 'input', '50px'));
-
- $r .=$DSP->tr_c();
- }
-
- $r .= $DSP->table_c();
-
- if ($SESS->userdata['group_id'] == 1)
- {
- $r .= $DSP->qdiv('itemWrapper', $DSP->qdiv('highlight', $LANG->line('security_warning')));
- }
-
- $r .= $DSP->qdiv('itemWrapper', $DSP->input_submit($LANG->line('update')))
- .$DSP->form_close();
- $DSP->body = $r;
- }
- /* END */
-
- /** -------------------------------
- /** Update Template Preferences
- /** -------------------------------*/
-
- function update_template_prefs()
- {
- global $IN, $DSP, $DB, $SESS, $LANG, $PREFS;
-
-
- if ( ! $group_id = $IN->GBL('group_id', 'POST'))
- {
- return false;
- }
-
- if ($SESS->userdata['tmpl_group_id'] == 0)
- {
- if ( ! $DSP->allowed_group('can_admin_templates'))
- {
- return $DSP->no_access_message();
- }
- }
- else
- {
- if ($group_id != $SESS->userdata['tmpl_group_id'] )
- {
- return $DSP->no_access_message();
- }
- }
-
- $idx = array();
-
- foreach ($_POST as $k => $val)
- {
- if ( ! stristr($k, "__"))
- continue;
-
- $temp = explode("__", $k);
- $id = $temp['0'];
- $idx[] = $temp['0'];
-
- if (isset($_POST[$id.'__template_name']))
- {
- if ($_POST[$id.'__template_name'] == '')
- {
- return $DSP->error_message($LANG->line('missing_name'));
- }
- if ( ! preg_match("#^[a-zA-Z0-9_\.-]+$#i", $_POST[$id.'__template_name']))
- {
- return $DSP->error_message($LANG->line('illegal_characters'));
- }
-
- if (in_array($_POST[$id.'__template_name'], $this->reserved_names))
- {
- return $DSP->error_message($LANG->line('reserved_name'));
- }
-
- if ($_POST[$id.'__template_name'] != $_POST[$id.'__old_name'])
- {
- $query = $DB->query("SELECT COUNT(*) AS count FROM exp_templates WHERE template_name='".$DB->escape_str($_POST[$id.'__template_name'])."' AND group_id = '$group_id'");
-
- if ($query->row['count'] > 0)
- {
- return $DSP->error_message($LANG->line('template_name_taken'));
- }
- }
- }
- }
-
- foreach ($idx as $id)
- {
- $data = array();
-
- if (isset($_POST[$id.'__template_name']))
- {
- $data['template_name'] = $_POST[$id.'__template_name'];
- }
-
- $data['cache'] = $_POST[$id.'__cache'];
- $data['refresh'] = ( ! is_numeric($_POST[$id.'__refresh'])) ? '1' : $_POST[$id.'__refresh'];
- $data['hits'] = ( ! is_numeric($_POST[$id.'__hits'])) ? '0' : $_POST[$id.'__hits'];
- $data['template_type'] = $_POST[$id.'__template_type'];
-
- if ($PREFS->ini('save_tmpl_files') == 'y' AND $PREFS->ini('tmpl_file_basepath') != '')
- {
- $data['save_template_file'] = $_POST[$id.'__save_template_file'];
- }
-
- if ($SESS->userdata['group_id'] == 1)
- {
- $data['php_parse_location'] = $_POST[$id.'__php_parse_location'];
- $data['allow_php'] = (isset($_POST[$id.'__allow_php']) AND $_POST[$id.'__allow_php'] == 'y' AND $SESS->userdata['group_id'] == 1) ? 'y' : 'n';
- }
- $DB->query($DB->update_string('exp_templates', $data, "template_id = '$id'"));
- }
-
- return $this->edit_preferences($group_id);
- }
- /* END */
- /** -----------------------------
- /** Template default page
- /** -----------------------------*/
-
- function template_manager()
- {
- global $IN, $DSP, $DB, $PREFS, $FNS, $SESS, $LANG, $REGX, $EXT;
-
- // -------------------------------------------
- // 'template_manager_start' hook.
- // - Allows complete rewrite of Templates page.
- //
- $edata = $EXT->call_extension('template_manager_start');
- if ($EXT->end_script === TRUE) return;
- //
- // -------------------------------------------
-
- $user_blog = FALSE;
-
- $DSP->crumbline = TRUE;
- if ($SESS->userdata['tmpl_group_id'] != 0)
- {
- $user_blog = TRUE;
- }
- switch ($IN->GBL('MSG'))
- {
- case '01' : $message = $LANG->line('template_group_created');
- break;
- case '02' : $message = $LANG->line('template_group_updated');
- break;
- case '03' : $message = $LANG->line('template_group_deleted');
- break;
- case '04' : $message = $LANG->line('template_created');
- break;
- case '05' : $message = $LANG->line('template_deleted');
- break;
- default : $message = "";
- break;
- }
-
- $DSP->title = $LANG->line('design');
- $DSP->crumb = $DSP->anchor(BASE.AMP.'C=templates', $LANG->line('design')).$DSP->crumb_item($LANG->line('template_management'));
- if ($user_blog === FALSE AND $DSP->allowed_group('can_admin_templates'))
- {
- $DSP->right_crumb($LANG->line('create_new_template_group'), BASE.AMP.'C=templates'.AMP.'M=new_tg_form');
- }
- ob_start();
- ?>
- <script type="text/javascript">
- function showHideTemplate(htmlObj)
- {
- if (isNaN(htmlObj.value) || htmlObj.value == '') return;
-
- for (var g = 0; g < htmlObj.options.length; g++)
- {
- if (document.getElementById('extText' + htmlObj.options[g].value))
- {
- extTextDiv = document.getElementById('extText' + htmlObj.options[g].value);
-
- if (htmlObj.options[g].selected == true)
- {
- if (extTextDiv.style.display != 'block')
- {
- extTextDiv.style.display = "block";
- }
- }
- else if(extTextDiv.style.display != 'none')
- {
- extTextDiv.style.display = "none";
- }
- }
- }
- }
- </script>
- <?php
- $r = ob_get_contents();
- ob_end_clean();
-
- $r .= $DSP->table('', '', '', '97%')
- .$DSP->tr()
- .$DSP->td('', '', '', '', 'top')
- .$DSP->heading($LANG->line('template_management'));
-
- if ($message != '')
- {
- $r .= $DSP->qdiv('success', $message);
- }
-
- if ($IN->GBL('keywords', 'POST') !== FALSE && trim($IN->GBL('keywords', 'POST')) != '')
- {
- $r .= $DSP->qspan('defaultBold', $LANG->line('search_terms')).NBS.NBS.$DSP->qspan('success', stripslashes($IN->GBL('keywords', 'POST')));
- }
- $r .= $DSP->td_c()
- .$DSP->td('', '', '', '', 'top');
-
- $r .= $DSP->div('defaultRight');
-
- if ($DSP->allowed_group('can_admin_templates') || $user_blog !== FALSE)
- {
- $r .= $DSP->anchor(BASE.AMP.'C=templates'.AMP.'M=global_variables', '<b>'.$LANG->line('global_variables').'</b>');
- }
-
- if ($user_blog === FALSE AND $DSP->allowed_group('can_admin_templates'))
- {
- $r .= NBS.NBS.'|'.NBS.NBS.$DSP->anchor(BASE.AMP.'C=admin'.AMP.'M=config_mgr'.AMP.'P=template_cfg'.AMP.'class_override=templates', '<b>'.$LANG->line('global_template_preferences').'</b>');
- $r .= NBS.NBS.'|'.NBS.NBS.$DSP->anchor(BASE.AMP.'C=templates'.AMP.'M=edit_tg_order', '<b>'.$LANG->line('edit_template_group_order').'</b>');
- $r .= NBS.NBS.'|'.NBS.NBS.$DSP->anchor(BASE.AMP.'C=templates'.AMP.'M=template_prefs_manager', '<b>'.$LANG->line('template_preferences_manager').'</b>');
- }
-
- $r .= $DSP->div_c();
-
- $r .= $DSP->td_c()
- .$DSP->tr_c()
- .$DSP->table_c();
-
- $qs = ($PREFS->ini('force_query_string') == 'y') ? '' : '?';
- $sitepath = $FNS->fetch_site_index(0, 0).$qs.'URL='.$FNS->fetch_site_index();
-
- $sitepath = rtrim($sitepath, '/').'/';
-
- if ($SESS->userdata['group_id'] != 1 && (sizeof($SESS->userdata['assigned_template_groups']) == 0 OR $DSP->allowed_group('can_admin_templates') == FALSE))
- {
- $r .= $DSP->qdiv('', $LANG->line('no_templates_assigned'));
- return $DSP->body = $r;
- }
- else
- {
- $sql = "SELECT tg.group_id, tg.group_name, tg.is_site_default,
- t.template_id, t.template_name, t.template_type, t.hits, t.enable_http_auth
- FROM exp_template_groups tg , exp_templates t
- WHERE tg.group_id = t.group_id
- AND tg.site_id = '".$DB->escape_str($PREFS->ini('site_id'))."'";
-
- if ($user_blog === TRUE)
- {
- $sql .= " AND t.group_id = '".$SESS->userdata['tmpl_group_id']."'";
- }
- else
- {
- $sql .= " AND is_user_blog = 'n'";
- }
-
- if ($SESS->userdata['group_id'] != 1)
- {
- $sql .= " AND t.group_id IN (";
-
- foreach ($SESS->userdata['assigned_template_groups'] as $key => $val)
- {
- $sql .= "'$key',";
- }
-
- $sql = substr($sql, 0, -1).")";
- }
-
- if ($IN->GBL('keywords', 'POST') !== FALSE && trim($IN->GBL('keywords', 'POST')) != '')
- {
- $keywords = $REGX->keyword_clean(stripslashes($IN->GBL('keywords', 'POST')));
-
- if (trim($keywords) == '')
- {
- $DSP->body .= $DSP->qdiv('alert', $LANG->line('no_results'));
- $DSP->body .= $DSP->qdiv('itemWrapper', $DSP->anchor(BASE.AMP.'C=templates', $LANG->line('back')));
- return;
- }
-
- $terms = array();
-
- if (preg_match_all("/\-*\"(.*?)\"/", $keywords, $matches))
- {
- for($m=0; $m < sizeof($matches['1']); $m++)
- {
- $terms[] = trim(str_replace('"','',$matches['0'][$m]));
- $keywords = str_replace($matches['0'][$m],'', $keywords);
- }
- }
-
- if (trim($keywords) != '')
- {
- $terms = array_merge($terms, preg_split("/\s+/", trim($keywords)));
- }
-
- rsort($terms);
- $not_and = (sizeof($terms) > 2) ? ') AND (' : 'AND';
- $criteria = 'AND';
-
- $mysql_function = (substr($terms['0'], 0,1) == '-') ? 'NOT LIKE' : 'LIKE';
- $search_term = (substr($terms['0'], 0,1) == '-') ? substr($terms['0'], 1) : $terms['0'];
-
- // We have two parentheses in the beginning in case
- // there are any NOT LIKE's being used
- $sql .= "\nAND (t.template_data $mysql_function '%".$DB->escape_like_str($search_term)."%' ";
-
- for ($i=1; $i < sizeof($terms); $i++)
- {
- if (trim($terms[$i]) == '') continue;
- $mysql_criteria = ($mysql_function == 'NOT LIKE' OR substr($terms[$i], 0,1) == '-') ? $not_and : $criteria;
- $mysql_function = (substr($terms[$i], 0,1) == '-') ? 'NOT LIKE' : 'LIKE';
- $search_term = (substr($terms[$i], 0,1) == '-') ? substr($terms[$i], 1) : $terms[$i];
-
- $sql .= "$mysql_criteria t.template_data $mysql_function '%".$DB->escape_like_str($search_term)."%' ";
- }
-
- $sql .= ") \n";
- }
-
- $sql .= " ORDER BY tg.group_order, t.group_id, t.template_name";
-
- $query = $DB->query($sql);
-
- if ($query->num_rows == 0)
- {
- if (isset($keywords))
- {
- $DSP->body .= $DSP->qdiv('alert', $LANG->line(isset($keywords) ? 'no_results' : 'no_templates_available'));
- $DSP->body .= $DSP->qdiv('itemWrapper', $DSP->anchor(BASE.AMP.'C=templates', $LANG->line('back')));
- }
- else
- {
- $DSP->body .= $DSP->qdiv('alert', $LANG->line('no_templates_available'));
- }
- return;
- }
-
- $r .= $DSP->table_open(array('width' => '99%', 'cellpadding' => '1'))
- .$DSP->tr()
- ."<td valign='top' style='width:180px; padding-top:1px'>"
- .$DSP->div('itemWrapper')
- .$DSP->div('templateEditBox')
- .$DSP->qdiv('tableHeadingAlt', $LANG->line('choose_group'))
- .$DSP->div('templatePrefBox')
- .$DSP->div('defaultCenter')
- ."<select onchange='showHideTemplate(this);' name='template_groups' class='multiselect' size='15' multiple='multiple' style='width:160px'>";
- $current_group = 0;
- foreach($query->result as $e => $row)
- {
- if ($row['group_id'] == $current_group) continue;
- $current_group = $row['group_id'];
-
- if (isset($_GET['tgpref']) && is_numeric($_GET['tgpref']) && $_GET['tgpref'] == $row['group_id'])
- {
- if ($row['is_site_default'] == 'y')
- {
- $r .= $DSP->input_select_option($row['group_id'], '* '.$REGX->form_prep($row['group_name']), 'y', "class='highlight_alt2'");
- }
- else
- {
- $r .= $DSP->input_select_option($row['group_id'], $REGX->form_prep($row['group_name']), 'y');
- }
- }
- else
- {
- if ($row['is_site_default'] == 'y')
- {
- $r .= $DSP->input_select_option($row['group_id'], '* '.$REGX->form_prep($row['group_name']), ($e > 0 OR isset($_GET['tgpref'])) ? '' : 'y', "class='highlight_alt2'");
- }
- else
- {
- $r .= $DSP->input_select_option($row['group_id'], $REGX->form_prep($row['group_name']), ($e > 0 OR isset($_GET['tgpref'])) ? '' : 'y');
- }
- }
-
- if ($row['is_site_default'] == 'y')
- {
- $default_group = $row['group_name'];
- }
- }
-
- $default_text = '';
-
- if (isset($default_group))
- {
- $default_text = $DSP->div('defaultCenter').
- $DSP->qspan('defaultBold', $LANG->line('default_template_group')).NBS.
- $default_group.
- $DSP->div_c();
- }
-
- $r .= $DSP->input_select_footer().
- $default_text.
- $DSP->div_c().
- $DSP->div_c().
- $DSP->div_c().
- $DSP->div_c().
- $DSP->qdiv('tableHeadingAlt', $LANG->line('search'))
- .$DSP->div('profileMenuInner')
- . $DSP->form_open(array('action' => 'C=templates'))
- . $DSP->input_text('keywords', '', '20', '120', 'input', '100%')
- . $DSP->qdiv('itemWrapper', $DSP->qdiv('defaultRight', $DSP->input_submit($LANG->line('search'))))
- . $DSP->form_close()
- .$DSP->div_c().
- $DSP->td_c().
- $DSP->table_qcell('', '', '8px').
- $DSP->td('', '', '', '', 'top');
-
- $x = 1;
- $j = 1;
-
- $out = '';
- $current_group = 0;
-
- $t = '';
-
- foreach ($query->result as $row)
- {
- if ($row['group_id'] != $current_group)
- {
- if ($current_group != 0)
- {
- $t .= $DSP->table_c();
-
- $t .= $DSP->td_c()
- .$DSP->tr_c()
- .$DSP->table_c();
-
- if ($user_blog === FALSE AND $reqflag == TRUE)
- {
- $t .= $DSP->qdiv('itemWrapper', $DSP->required($LANG->line('default_site_page')));
- }
-
- if (isset($_GET['tgpref']) && is_numeric($_GET['tgpref']) && $_GET['tgpref'] == $current_group)
- {
- $r .= '<div id="extText'.$current_group.'"><div class="itemWrapper">'.$t.'</div></div>'.NL.NL;
- }
- elseif ( ! isset($_GET['tgpref']) && $query->row['group_id'] == $current_group)
- {
- $r .= '<div id="extText'.$current_group.'"><div class="itemWrapper">'.$t.'</div></div>'.NL.NL;
- }
- else
- {
- $r .= '<div id="extText'.$current_group.'" style="display: none; padding:0;"><div class="itemWrapper">'.$t.'</div></div>'.NL.NL;
- }
-
- $t = '';
-
- $x++;
- }
-
- $template_group = $row['group_name'];
- $is_site_default = $row['is_site_default'];
-
- $t .= $DSP->table('', '', '', '100%')
- .$DSP->tr()
- .$DSP->td('templateEditBox', '20%', '', '', 'top');
-
- $t .= "<div class='tableHeadingAlt'>".NBS.'<b>'.$template_group."</b></div>";
-
- $t .= $DSP->table('', '', '', '100%')
- .$DSP->tr()
- .$DSP->td('templatePrefBox', '', '', '', 'top');
-
- $t .= $DSP->div('templateprefpad');
-
- $t .= $DSP->div('leftPad');
-
- if ($DSP->allowed_group('can_admin_templates'))
- {
- $t .= $DSP->qdiv('itemWrapper', $DSP->anchor(BASE.AMP.'C=templates'.AMP.'M=edit_preferences'.AMP.'id='.$row['group_id'].AMP.'tgpref='.$row['group_id'], $LANG->line('preferences')));
- }
-
- $t .= $DSP->qdiv('itemWrapper', $DSP->anchor(BASE.AMP.'C=templates'.AMP.'M=new_templ_form'.AMP.'id='.$row['group_id'].AMP.'tgpref='.$row['group_id'], $LANG->line('create_new_template')));
-
- if ($user_blog === FALSE AND $DSP->allowed_group('can_admin_templates'))
- {
- $t .= $DSP->qdiv('itemWrapper', $DSP->anchor(BASE.AMP.'C=templates'.AMP.'M=edit_tg_form'.AMP.'id='.$row['group_id'].AMP.'tgpref='.$row['group_id'], $LANG->line('edit_template_group')))
- .$DSP->qdiv('itemWrapper', $DSP->anchor(BASE.AMP.'C=templates'.AMP.'M=tg_del_conf'.AMP.'id='.$row['group_id'].AMP.'tgpref='.$row['group_id'], $LANG->line('delete_template_group')));
- }
-
- // TEMPLATE EXPORT LINK
- $t .= $DSP->qdiv('itemWrapper', $DSP->anchor(BASE.AMP.'C=templates'.AMP.'M=export_tmpl'.AMP.'id='.$row['group_id'].AMP.'tgpref='.$row['group_id'], $LANG->line('export_templates')));
-
- $t .= $DSP->div_c();
- $t .= $DSP->div_c();
-
- $t .= $DSP->td_c()
- .$DSP->tr_c()
- .$DSP->table_c();
-
- $t .= $DSP->td_c()
- .$DSP->td('defaultSmall', '1%').NBS;
-
- $t .= $DSP->td_c()
- .$DSP->td('templateEditBox', '79%', '', '', 'top');
-
-
- $t .= $DSP->table('', '0', '', '100%')
- .$DSP->tr()
- .$DSP->table_qcell('tableHeading', $LANG->line('template_name').' / '.$LANG->line('edit'), '40%')
- .$DSP->table_qcell('tableHeading', $LANG->line('hits'), '15%')
- .$DSP->table_qcell('tableHeading', $LANG->line('view'), '15%')
- .$DSP->table_qcell('tableHeading', $LANG->line('access'), '15%')
- .$DSP->table_qcell('tableHeading', $LANG->line('delete'), '15%')
- .$DSP->tr_c();
-
- $i = 0;
- $reqflag = FALSE;
- }
-
- $current_group = $row['group_id'];
-
- $style = ($i++ % 2) ? 'tableCellOne' : 'tableCellTwo';
-
- $t .= $DSP->tr();
-
- $default = …
Large files files are truncated, but you can click here to view the full file