1316 lines
43 KiB
PHP
1316 lines
43 KiB
PHP
<?php
|
|
|
|
/*
|
|
+--------------------------------------------------------------------------
|
|
| Invision Power Board 2.1.7
|
|
| =============================================
|
|
| by Matthew Mecham
|
|
| (c) 2001 - 2005 Invision Power Services, Inc.
|
|
| http://www.invisionpower.com
|
|
| =============================================
|
|
| Web: http://www.invisionboard.com
|
|
| http://www.ibresource.ru/products/invisionpowerboard/
|
|
| Time: Tuesday 18th of July 2006 05:56:00 PM
|
|
| Release: 52f408a29988b02f45b5e6f4ba5af0ae
|
|
| Licence Info: http://www.invisionboard.com/?license
|
|
| http://www.ibresource.ru/license
|
|
+---------------------------------------------------------------------------
|
|
| INVISION POWER BOARD IS NOT FREE / OPEN SOURCE!
|
|
+---------------------------------------------------------------------------
|
|
| INVISION POWER BOARD ÍÅ ßÂËßÅÒÑß ÁÅÑÏËÀÒÍÛÌ ÏÐÎÃÐÀÌÌÍÛÌ ÎÁÅÑÏÅ×ÅÍÈÅÌ!
|
|
| Ïðàâà íà ÏÎ ïðèíàäëåæàò Invision Power Services
|
|
+---------------------------------------------------------------------------
|
|
| > $Date: 2005-12-08 16:32:40 +0000 (Thu, 08 Dec 2005) $
|
|
| > $Revision: 96 $
|
|
| > $Author: bfarber $
|
|
+---------------------------------------------------------------------------
|
|
|
|
|
| > Skin -> Templates functions
|
|
| > Module written by Matt Mecham
|
|
| > Date started: 15th April 2002
|
|
|
|
|
| > Module Version Number: 1.0.0
|
|
| > DBA Checked: Tue 25th May 2004
|
|
+--------------------------------------------------------------------------
|
|
*/
|
|
|
|
if ( ! defined( 'IN_ACP' ) )
|
|
{
|
|
print "<h1>Íåâåðíûé âõîä</h1> Ó Âàñ íåò äîñòóïà ê äèðåêòèâå ýòîãî ôàéëà. Åñëè Âû ïðîâîäèëè îáíîâëåíèÿ, óáåäèòåñü, ÷òî íå çàáûëè îáíîâèòü 'admin.php'.";
|
|
exit();
|
|
}
|
|
|
|
|
|
class ad_skin_template_bits
|
|
{
|
|
var $base_url;
|
|
var $template = "";
|
|
var $functions = "";
|
|
|
|
/**
|
|
* Section title name
|
|
*
|
|
* @var string
|
|
*/
|
|
var $perm_main = "lookandfeel";
|
|
|
|
/**
|
|
* Section title name
|
|
*
|
|
* @var string
|
|
*/
|
|
var $perm_child = "templ";
|
|
|
|
/**
|
|
* Search template bits
|
|
*
|
|
* var array
|
|
*/
|
|
|
|
function auto_run()
|
|
{
|
|
//-----------------------------------------
|
|
// Kill globals - globals bad, Homer good.
|
|
//-----------------------------------------
|
|
|
|
$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
|
|
|
|
foreach ( $tmp_in as $k => $v )
|
|
{
|
|
unset($$k);
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get the libraries
|
|
//-----------------------------------------
|
|
|
|
require_once( KERNEL_PATH.'class_template.php' );
|
|
|
|
$this->template = new class_template();
|
|
|
|
$this->template->root_path = ROOT_PATH;
|
|
|
|
//-----------------------------------------
|
|
// LOAD HTML
|
|
//-----------------------------------------
|
|
|
|
$this->html = $this->ipsclass->acp_load_template('cp_skin_lookandfeel');
|
|
|
|
//-----------------------------------------
|
|
|
|
require_once( ROOT_PATH.'sources/lib/admin_template_functions.php' );
|
|
|
|
$this->functions = new admin_template_functions();
|
|
$this->functions->ipsclass =& $this->ipsclass;
|
|
|
|
//-----------------------------------------
|
|
|
|
$this->unaltered = "<img src='{$this->ipsclass->skin_url}/images/skin_item_unaltered.gif' border='0' alt='-' title='Íå èçìåíåí îò íà÷àëüíîãî âàðèàíòà øàáëîíà' /> ";
|
|
$this->altered = "<img src='{$this->ipsclass->skin_url}/images/skin_item_altered.gif' border='0' alt='+' title='Èçìåíåí îò íà÷àëüíîãî âàðèàíòà øàáëîíà' /> ";
|
|
$this->inherited = "<img src='{$this->ipsclass->skin_url}/images/skin_item_inherited.gif' border='0' alt='|' title='Óíàñëåäîâàííûé îò íà÷àëüíîãî âàðèàíòà øàáëîíà' /> ";
|
|
|
|
//-----------------------------------------
|
|
|
|
switch($this->ipsclass->input['code'])
|
|
{
|
|
case 'template-sections-list':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
|
|
$this->template_sections_list();
|
|
break;
|
|
|
|
case 'template-bits-list':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
|
|
$this->template_bits_list();
|
|
break;
|
|
|
|
case 'template-edit-bit-complete':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->template_edit_bit_complete();
|
|
break;
|
|
|
|
case 'template_remove_bit':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':remove' );
|
|
$this->template_revert_bit();
|
|
break;
|
|
|
|
case 'template-edit-bit':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->template_edit_bit();
|
|
break;
|
|
|
|
case 'floateditor':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->functions->build_editor_area_floated();
|
|
break;
|
|
|
|
case 'addbit':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' );
|
|
$this->add_bit();
|
|
break;
|
|
|
|
case 'doadd':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':add' );
|
|
$this->do_add_bit();
|
|
break;
|
|
|
|
default:
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
|
|
$this->template_sections_list();
|
|
break;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Show template bits for a group
|
|
//-----------------------------------------
|
|
|
|
function template_bits_list( $type='' )
|
|
{
|
|
//-----------------------------------------
|
|
// INIT
|
|
//-----------------------------------------
|
|
|
|
$groups = array();
|
|
$group_bits = array();
|
|
$content = "";
|
|
$master_names = array();
|
|
$group_name = trim( $this->ipsclass->input['group_name'] );
|
|
$id = intval( $this->ipsclass->input['id'] );
|
|
$p = intval( $this->ipsclass->input['p'] );
|
|
$type = $type != '' ? $type : trim( $this->ipsclass->input['type'] );
|
|
|
|
//-----------------------------------------
|
|
// Get $skin_names stuff
|
|
//-----------------------------------------
|
|
|
|
require_once( ROOT_PATH.'sources/lib/skin_info.php' );
|
|
|
|
//-----------------------------------------
|
|
// Get skin set
|
|
//-----------------------------------------
|
|
|
|
$this_set = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => "set_skin_set_id=".$id ) );
|
|
|
|
//-----------------------------------------
|
|
// Check
|
|
//-----------------------------------------
|
|
|
|
if ( ! $id )
|
|
{
|
|
$this->ipsclass->admin->error("Âû äîëæíû óêàçàòü ID øàáëîíà, âåðíèòåñü íàçàä è ïîïðîáóéòå åùå ðàç");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Parent?
|
|
//-----------------------------------------
|
|
|
|
if ( ! $p )
|
|
{
|
|
if ( $this_set['set_skin_set_parent'] )
|
|
{
|
|
$p = $this_set['set_skin_set_parent'];
|
|
}
|
|
}
|
|
|
|
if ( $p > 0 )
|
|
{
|
|
$in = ','.$p;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get template bits master names..
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => 'func_name', 'from' => 'skin_templates', 'where' => "group_name='{$group_name}' AND set_id=1" ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
//-----------------------------------------
|
|
// Compile...
|
|
//-----------------------------------------
|
|
|
|
while ( $m = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$master_names[ $m['func_name'] ] = $m['func_name'];
|
|
}
|
|
|
|
$group['easy_name'] = $skin_names[ $group_name ][0];
|
|
$group['group_name'] = $group_name;
|
|
|
|
//-----------------------------------------
|
|
// Get group bits
|
|
//-----------------------------------------
|
|
|
|
$group_bits = $this->ipsclass->cache_func->_get_templates($id, $p, 'groups', $group_name );
|
|
|
|
$add_button = "<div class='realbutton' style='padding:4px;width:105px'>
|
|
<a style='text-decoration:none' href='#' onclick=\"parent.template_add_bit('{$this->ipsclass->base_url}&{$this->ipsclass->form_code}&code=addbit&id={$this->ipsclass->input['id']}&p={$this->ipsclass->input['p']}&expand={$group['group_name']}', event)\">Äîáàâèòü øàáëîí</a>
|
|
</div>";
|
|
|
|
//-----------------------------------------
|
|
// Add to HTML
|
|
//-----------------------------------------
|
|
|
|
$temp = "";
|
|
$sec_arry = array();
|
|
|
|
//-----------------------------------------
|
|
// Stuff array to sort on name
|
|
//-----------------------------------------
|
|
|
|
foreach( $group_bits as $eye => $i )
|
|
{
|
|
$sec_arry[ $i['suid'] ] = $i;
|
|
$sec_arry[ $i['suid'] ]['easy_name'] = $i['func_name'];
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Sort by easy_name
|
|
//-----------------------------------------
|
|
|
|
usort($sec_arry, array( 'ad_skin_template_bits', 'perly_alpha_sort' ) );
|
|
|
|
//-----------------------------------------
|
|
// Loop and print main display
|
|
//-----------------------------------------
|
|
|
|
foreach( $sec_arry as $i => $sec )
|
|
{
|
|
$custom_bit = "";
|
|
|
|
$sec['_p'] = intval( $p );
|
|
$sec['_id'] = intval( $this->ipsclass->input['id'] );
|
|
|
|
//-----------------------------------------
|
|
// Altered?
|
|
//-----------------------------------------
|
|
|
|
if ( $sec['set_id'] == $id )
|
|
{
|
|
$altered_image = $this->html->template_bits_bit_row_image( $sec['suid'], 'skin_item_altered.gif' );
|
|
}
|
|
else if ( $sec['set_id'] == 1 )
|
|
{
|
|
$altered_image = $this->html->template_bits_bit_row_image( $sec['suid'], 'skin_item_unaltered.gif' );
|
|
}
|
|
else
|
|
{
|
|
$altered_image = $this->html->template_bits_bit_row_image( $sec['suid'], 'skin_item_inherited.gif' );
|
|
}
|
|
|
|
$remove_button = "<a id='link-remove-{$sec['suid']}' title='Âåðíóòü ïðåæíåå ñîñòîÿíèå' href=\"javascript:confirm_action('{$this->ipsclass->base_url}&{$this->ipsclass->form_code}&code=template_remove_bit&bitname={$sec['func_name']}&id={$this->ipsclass->input['id']}&p={$this->ipsclass->input['p']}&group_name={$sec['group_name']}&type=frame')\"><img id='img-remove-{$sec['suid']}' src='{$this->ipsclass->skin_url}/images/blank.gif' alt='' border='0' width='1' height='1' /></a> ";
|
|
|
|
if ( $sec['set_id'] == $id )
|
|
{
|
|
if ( $master_names[ $sec['func_name'] ] )
|
|
{
|
|
$remove_button = "<a id='link-remove-{$sec['suid']}' title='Âåðíóòü ïðåæíåå ñîñòîÿíèå' href=\"javascript:confirm_action('{$this->ipsclass->base_url}&{$this->ipsclass->form_code}&code=template_remove_bit&bitname={$sec['func_name']}&id={$this->ipsclass->input['id']}&p={$this->ipsclass->input['p']}&group_name={$sec['group_name']}&type=frame')\"><img id='img-remove-{$sec['suid']}'src='{$this->ipsclass->skin_url}/images/te_revert.gif' alt='X' border='0' /></a> ";
|
|
}
|
|
else
|
|
{
|
|
$custom_bit = ' (custom bit)';
|
|
$remove_button = "<a id='link-remove-{$sec['suid']}' title='Óäàëèòü âûáðàííûå ÷àñòè' href=\"javascript:confirm_action('{$this->ipsclass->base_url}&{$this->ipsclass->form_code}&code=template_remove_bit&bitname={$sec['func_name']}&id={$this->ipsclass->input['id']}&p={$this->ipsclass->input['p']}&group_name={$sec['group_name']}&type=frame&custombit=1')\"><img id='img-remove-{$sec['suid']}' src='{$this->ipsclass->skin_url}/images/te_remove.gif' alt='X' border='0' /></a> ";
|
|
}
|
|
}
|
|
|
|
$content .= $this->html->template_bits_bit_row( $sec, $custom_bit, $remove_button, $altered_image );
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Just showing the XML?
|
|
//-----------------------------------------
|
|
|
|
if ( $type == 'xml' )
|
|
{
|
|
@header("Content-Type: text/plain");
|
|
print $content;
|
|
exit();
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->html = $this->html->template_bits_bit_overview( $group, $content, $add_button );
|
|
|
|
$this->ipsclass->admin->print_popup();
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Show template groups/categories
|
|
//-----------------------------------------
|
|
|
|
function template_sections_list()
|
|
{
|
|
//-----------------------------------------
|
|
// INIT
|
|
//-----------------------------------------
|
|
|
|
$groups = array();
|
|
$group_bits = array();
|
|
$content = "";
|
|
$javascript = '';
|
|
$js_groups = '';
|
|
$js_bits = '';
|
|
$js_matches = '';
|
|
|
|
$this->ipsclass->input['id'] = intval( $this->ipsclass->input['id'] );
|
|
$this->ipsclass->input['p'] = intval( $this->ipsclass->input['p'] );
|
|
|
|
//-----------------------------------------
|
|
// Get $skin_names stuff
|
|
//-----------------------------------------
|
|
|
|
require_once( ROOT_PATH.'sources/lib/skin_info.php' );
|
|
|
|
//-----------------------------------------
|
|
// Get skin set
|
|
//-----------------------------------------
|
|
|
|
$this_set = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => "set_skin_set_id=".$this->ipsclass->input['id'] ) );
|
|
|
|
//-----------------------------------------
|
|
// Check
|
|
//-----------------------------------------
|
|
|
|
if ( $this->ipsclass->input['id'] == "")
|
|
{
|
|
$this->ipsclass->admin->error("Âû äîëæíû óêàçàòü ID øàáëîíà, âåðíèòåñü íàçàä è ïîïðîáóéòå åùå ðàç");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Parent?
|
|
//-----------------------------------------
|
|
|
|
if ( ! $this->ipsclass->input['p'] )
|
|
{
|
|
if ( $this_set['set_skin_set_parent'] )
|
|
{
|
|
$this->ipsclass->input['p'] = $this_set['set_skin_set_parent'];
|
|
}
|
|
}
|
|
|
|
if ( $this->ipsclass->input['p'] > 0 )
|
|
{
|
|
$in = ','.$this->ipsclass->input['p'];
|
|
}
|
|
|
|
$this->ipsclass->admin->page_detail = "Â ýòîé ñåêöèè âû ìîæåòå äîáàâèòü íîâûé ôðàãìåíò øàáëîíà.";
|
|
$this->ipsclass->admin->page_title = "Èçìåíåíèå øàáëîíà";
|
|
|
|
//-----------------------------------------
|
|
// Generate inline JS
|
|
//-----------------------------------------
|
|
|
|
if ( is_array( $this->search_bits ) and count( $this->search_bits ) )
|
|
{
|
|
foreach( $this->search_bits as $group => $idx )
|
|
{
|
|
$js_matches .= "\t'$group' : ". count( $this->search_bits[ $group ] ).",\n";
|
|
$js_groups .= "\t'$group' : 1,\n";
|
|
|
|
foreach( $this->search_bits[ $group ] as $idx2 => $data )
|
|
{
|
|
$js_bits .= "\t'{$group}_{$data['func_name']}' : 1,\n";
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Trim off trailing commas
|
|
//-----------------------------------------
|
|
|
|
$js_matches = preg_replace( "#,\n?$#", "", $js_matches );
|
|
$js_groups = preg_replace( "#,\n?$#", "", $js_groups );
|
|
$js_bits = preg_replace( "#,\n?$#", "", $js_bits );
|
|
|
|
$javascript = "var template_search = 1;\n".
|
|
"var search_template_sections = {\n". $js_groups ."\n};\n".
|
|
"var search_template_bits = {\n" . $js_bits ."\n};\n".
|
|
"var search_template_matches = {\n" . $js_matches."\n};\n";
|
|
|
|
}
|
|
else
|
|
{
|
|
$javascript = "var template_search = 0;\nvar search_template_sections = {};\nvar search_template_bits = {};\nvar search_template_matches = {};\n";
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get the groups...
|
|
//-----------------------------------------
|
|
|
|
$group_titles = $this->ipsclass->cache_func->_get_templates($this->ipsclass->input['id'], $this->ipsclass->input['p'], 'groups');
|
|
|
|
foreach( $group_titles as $title => $g )
|
|
{
|
|
//-----------------------------------------
|
|
// Fix up names
|
|
//-----------------------------------------
|
|
|
|
$g['easy_name'] = "<b>".$g['group_name']."</b>";
|
|
$g['easy_desc'] = "";
|
|
|
|
//-----------------------------------------
|
|
// If available, change group name to easy name
|
|
//-----------------------------------------
|
|
|
|
if ( isset($skin_names[ $g['group_name'] ]) )
|
|
{
|
|
$g['easy_name'] = "<b>".$skin_names[ $g['group_name'] ][0]."</b>";
|
|
$g['easy_desc'] = str_replace( '"', '"', $skin_names[ $g['group_name'] ][1] );
|
|
}
|
|
else
|
|
{
|
|
$g['easy_name'] = "<b>".$g['group_name']."</b> (Ãðóïïà íå ïî óìîë÷àíèþ)";
|
|
$g['easy_desc'] = "Ýòà ãðóïïà íå ÿâëÿåòñÿ ÷àñòüþ ñòàíäàðòíîé èíñòàëëÿöèè IPB è íå èìååò äîñòóïíîãî îïèñàíèÿ";
|
|
}
|
|
|
|
if ( $skin_names[ $g['group_name'] ][2] )
|
|
{
|
|
$g['easy_preview'] = "<a title='Íîâîå îêíî: Ïîêàçàòü âàæíóþ IPB-ñòðàíèöó' href='{$this->ipsclass->vars['board_url']}/index.{$this->ipsclass->vars['php_ext']}?{$skin_names[ $g['group_name'] ][2]}' target='_blank'><img src='{$this->ipsclass->skin_url}/images/te_previewon.gif' alt='Ïðåäïðîñìîòð' border='0' /></a>";
|
|
}
|
|
else
|
|
{
|
|
$g['easy_preview'] = "<img src='{$this->ipsclass->skin_url}/images/te_previewoff.gif' alt='Íåò äîñòóïíûõ ïðåäïðîñìîòðîâ' border='0' title='Íåò äîñòóïíûõ ïðåäïðîñìîòðîâ' />";
|
|
}
|
|
|
|
$groups[] = $g;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Sort by easy_name
|
|
//-----------------------------------------
|
|
|
|
usort($groups, array( 'ad_skin_template_bits', 'perly_alpha_sort' ) );
|
|
|
|
//-----------------------------------------
|
|
// Loop and print
|
|
//-----------------------------------------
|
|
|
|
foreach( $groups as $group )
|
|
{
|
|
$eid = $group['suid'];
|
|
$exp_content = "";
|
|
|
|
$altered = sprintf( '%02d', intval($this->ipsclass->cache_func->template_count[$this->ipsclass->input['id']][ $group['group_name'] ]['count']) );
|
|
$original = sprintf( '%02d', intval($this->ipsclass->cache_func->template_count[1][ $group['group_name'] ]['count']) );
|
|
$inherited = sprintf( '%02d', intval($this->ipsclass->cache_func->template_count[$this->ipsclass->input['p']][ $group['group_name'] ]['count']) );
|
|
$count_string = "";
|
|
|
|
if ( $this->ipsclass->input['p'] > 0 )
|
|
{
|
|
$count_string = "$original {$this->unaltered} $inherited {$this->inherited} $altered {$this->altered}";
|
|
}
|
|
else
|
|
{
|
|
$count_string = "$original {$this->unaltered} $altered {$this->altered}";
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Folder blob
|
|
//-----------------------------------------
|
|
|
|
if ( $altered > 0 )
|
|
{
|
|
$folder_blob = $this->altered;
|
|
}
|
|
else if ( $this->ipsclass->input['p'] > 0 and $inherited > 0 )
|
|
{
|
|
$folder_blob = $this->inherited;
|
|
}
|
|
else
|
|
{
|
|
$folder_blob = $this->unaltered;
|
|
}
|
|
|
|
$group['_p'] = intval( $this->ipsclass->input['p'] );
|
|
$group['_id'] = intval( $this->ipsclass->input['id'] );
|
|
|
|
//-----------------------------------------
|
|
// Print normal rows
|
|
//-----------------------------------------
|
|
|
|
$content .= $this->html->template_bits_overview_row_normal( $group, $folder_blob, $count_string );
|
|
}
|
|
|
|
$this->ipsclass->html .= $this->html->template_bits_overview( $content, $javascript );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->skin_jump_menu_wrap();
|
|
|
|
$this->ipsclass->admin->nav[] = array( 'section='.$this->ipsclass->section_code.'&act=sets' ,'Óïðàâëåíèå ñòèëÿìè' );
|
|
$this->ipsclass->admin->nav[] = array( '' ,'Óïðàâëåíèå øàáëîíîì "'.$this_set['set_name'].'"' );
|
|
|
|
$this->ipsclass->admin->output();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Sneaky sorting.
|
|
// We use the format "1: name". without this hack
|
|
// 1: name, 2: other name, 11: other name
|
|
// will sort as 1: name, 11: other name, 2: other name
|
|
// There is natsort and such in PHP, but it causes some
|
|
// problems on older PHP installs, this is hackish but works
|
|
// by simply adding '0' to a number less than 2 characters long.
|
|
// of course, this won't work with three numerics in the hundreds
|
|
// but we don't have to worry about more that 99 bits in a template
|
|
// at this stage.
|
|
//-----------------------------------------
|
|
|
|
function perly_word_sort($a, $b)
|
|
{
|
|
$nat_a = intval( $a['easy_name'] );
|
|
$nat_b = intval( $b['easy_name'] );
|
|
|
|
if (strlen($nat_a) < 2)
|
|
{
|
|
$nat_a = '0'.$nat_a;
|
|
}
|
|
if (strlen($nat_b) < 2)
|
|
{
|
|
$nat_b = '0'.$nat_b;
|
|
}
|
|
|
|
return strcmp($nat_a, $nat_b);
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Sort by group name
|
|
//-----------------------------------------
|
|
|
|
function perly_alpha_sort($a, $b)
|
|
{
|
|
return strcmp( strtolower($a['easy_name']), strtolower($b['easy_name']) );
|
|
}
|
|
|
|
|
|
//-----------------------------------------
|
|
// ADD TEMPLATE BIT
|
|
//-----------------------------------------
|
|
|
|
function add_bit()
|
|
{
|
|
$this->ipsclass->admin->page_detail = "Â ýòîé ñåêöèè âû ìîæåòå äîáàâèòü íîâûé ôðàãìåíò øàáëîíà.";
|
|
$this->ipsclass->admin->page_title = "Èçìåíåíèå øàáëîíà";
|
|
|
|
$groupname = $this->ipsclass->input['expand'];
|
|
|
|
$this_set = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => "set_skin_set_id=".$this->ipsclass->input['id'] ) );
|
|
|
|
//-----------------------------------------
|
|
// Sort out group titles
|
|
//-----------------------------------------
|
|
|
|
$group_titles = $this->ipsclass->cache_func->_get_templates( $this->ipsclass->input['id'], $this->ipsclass->input['p'], 'groups' );
|
|
|
|
$formatted_groups = array();
|
|
|
|
foreach ( $group_titles as $name => $d )
|
|
{
|
|
$formatted_groups[] = array( $d['group_name'], $d['group_name'] );
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Good form old boy
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'doadd' ),
|
|
2 => array( 'act' , 'templ' ),
|
|
3 => array( 'id' , $this->ipsclass->input['id'] ),
|
|
4 => array( 'p' , $this->ipsclass->input['p'] ),
|
|
5 => array( 'expand', $this->ipsclass->input['expand'] ),
|
|
6 => array( 'section', $this->ipsclass->section_code ),
|
|
) , "theform" );
|
|
|
|
//-----------------------------------------
|
|
// Editor prefs strip
|
|
//-----------------------------------------
|
|
|
|
|
|
|
|
$options .= "<div class='maintitle'>Íàñòðîéêè íîâîãî ôðàãìåíòà øàáëîíà</div>
|
|
<div class='tdrow1'>
|
|
<table width='100%' cellpadding='5' cellspacing='0' border='0'>
|
|
<tr>
|
|
<td width='40%' class='tdrow1'>Íàçâàíèå ôðàãìåíòà øàáëîíà<br /><span style='color:gray'>Äîïóñêàþòñÿ òîëüêî ëàòèíñêèå ñèìâîëû, öèôðû è çíàêè ïîä÷åðêèâàíèÿ, áåç ïðîáåëîâ.</span></td>
|
|
<td width='60%' class='tdrow1'>".$this->ipsclass->adskin->form_input('func_name', $this->ipsclass->txt_stripslashes($_POST['func_name']))."</td>
|
|
</tr>
|
|
<tr>
|
|
<td width='40%' class='tdrow1'>Âõîäÿùèå ïåðåìåííûå<br /><span style='color:gray'>Îïðåäåëåíèå ïåðåìåííûõ îáðàáàòûâàåìûõ â ýòîì ôðàãìåíòå øàáëîíà.</span></td>
|
|
<td width='60%' class='tdrow1'>".$this->ipsclass->adskin->form_input('func_data', str_replace( "'", ''', $this->ipsclass->txt_stripslashes($_POST['func_data']) ) )."</td>
|
|
</tr>
|
|
<tr>
|
|
<td width='40%' class='tdrow1'>Ãðóïïà äëÿ ôðàãìåíòà...</td>
|
|
<td width='60%' class='tdrow1'>".$this->ipsclass->adskin->form_dropdown('group_name', $formatted_groups, $this->ipsclass->input['group_name'] ? $this->ipsclass->input['group_name'] : $this->ipsclass->input['expand'] )."</td>
|
|
</tr>
|
|
<tr>
|
|
<td width='40%' class='tdrow1'>Èëè ñîçäàéòå íîâóþ ãðóïïó...<br /><span style='color:gray'>Îñòàâüòå ïóñòûì äëÿ èñïîëüçîâàíèÿ ñóùåñòâóþùåé ãðóïïû.<br />Äîïóñêàþòñÿ òîëüêî ëàòèíñêèå ñèìâîëû, öèôðû è çíàêè ïîä÷åðêèâàíèÿ, áåç ïðîáåëîâ</span></td>
|
|
<td width='60%' class='tdrow1'>skin_".$this->ipsclass->adskin->form_input('new_group_name', $this->ipsclass->txt_stripslashes($_POST['new_group_name']))."</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
<div class='pformstrip' align='center' style='padding:4px'><input type='submit' name='submit' value='Ïðîäîëæèòü...' class='realdarkbutton'></div>
|
|
</form>";
|
|
|
|
$this->ipsclass->html .= $options;
|
|
|
|
$this->ipsclass->admin->print_popup();
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// DO ADD NEW BIT
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function do_add_bit()
|
|
{
|
|
//-----------------------------------------
|
|
// Check incoming
|
|
//-----------------------------------------
|
|
|
|
$this_set = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_sets', 'where' => "set_skin_set_id=".$this->ipsclass->input['id'] ) );
|
|
|
|
if ( $_POST['new_group_name'] )
|
|
{
|
|
if ( preg_match( "#[^\w_]#s", $_POST['new_group_name'] ) )
|
|
{
|
|
$this->ipsclass->main_msg = 'Íàçâàíèå ãðóïïû ôðàãìåíòîâ øàáëîíà ìîæåò ñîñòîÿòü òîëüêî èç ëàòèíñêèõ ñèìâîëîâ, öèôð è çíàêîâ ïîä÷åðêèâàíèÿ.';
|
|
$this->add_bit();
|
|
}
|
|
}
|
|
|
|
if ( ! $_POST['func_name'] )
|
|
{
|
|
$this->ipsclass->main_msg = 'Íàçâàíèå ôðàãìåíòà øàáëîíà íå ìîæåò áûòü ïóñòûì.';
|
|
$this->add_bit();
|
|
}
|
|
else
|
|
{
|
|
if ( preg_match( "#[^\w_]#s", $_POST['func_name'] ) )
|
|
{
|
|
$this->ipsclass->main_msg = 'Íàçâàíèå ôðàãìåíòà øàáëîíà ìîæåò ñîñòîÿòü òîëüêî èç ëàòèíñêèõ ñèìâîëîâ, öèôð è çíàêîâ ïîä÷åðêèâàíèÿ.';
|
|
$this->add_bit();
|
|
}
|
|
}
|
|
|
|
|
|
$new_group_name = strtolower(str_replace( 'skin_', '', trim($this->ipsclass->input['new_group_name']) ));
|
|
$func_name = strtolower(trim($this->ipsclass->input['func_name']));
|
|
$group_name = $new_group_name ? 'skin_'.$new_group_name : $this->ipsclass->input['group_name'];
|
|
$func_data = preg_replace( "#,$#", "", str_replace( ''', "'", trim($this->ipsclass->txt_stripslashes($_POST['func_data'])) ) );
|
|
$text = '';
|
|
|
|
//-----------------------------------------
|
|
// Make sure bit doesn't exist
|
|
//-----------------------------------------
|
|
|
|
if ( $row = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'suid', 'from' => 'skin_templates', 'where' => "set_id={$this->ipsclass->input['id']} AND group_name='$group_name' AND func_name='$func_name'" ) ) )
|
|
{
|
|
$this->ipsclass->main_msg = "Ôðàãìåíò '$func_name' óæå ñóùåñòâóåò â ãðóïïå '$group_name'.";
|
|
$this->add_bit();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Make sure it's not called "end"
|
|
//-----------------------------------------
|
|
|
|
if ( strtolower($func_name) == 'end' )
|
|
{
|
|
$this->ipsclass->main_msg = "Èìÿ ôðàãìåíòà íå ìîæåò áûòü 'end'";
|
|
$this->add_bit();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// INSERT NEW BIT
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->do_insert( 'skin_templates', array (
|
|
'set_id' => $this->ipsclass->input['id'],
|
|
'group_name' => $group_name,
|
|
'section_content' => $text,
|
|
'func_name' => $func_name,
|
|
'func_data' => $func_data,
|
|
'updated' => time(),
|
|
) );
|
|
|
|
$new_id = $this->ipsclass->DB->get_insert_id();
|
|
|
|
//-----------------------------------------
|
|
// Rebuild the PHP file
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->cache_func->_recache_templates( $this->ipsclass->input['id'], $this->ipsclass->input['p'], $real_name );
|
|
|
|
//-----------------------------------------
|
|
// Back we go...
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->input[ 'cb_'.$new_id ] = 1;
|
|
$this->ipsclass->input[ 'suid' ] = $new_id;
|
|
$this->ipsclass->input['type'] = 'single';
|
|
$this->template_edit_bit( $reload=1 );
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// EDIT TEMPLATE BIT
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function template_edit_bit( $reload=0 )
|
|
{
|
|
//-----------------------------------------
|
|
// INIT
|
|
//-----------------------------------------
|
|
|
|
$suid = intval( $this->ipsclass->input['suid'] );
|
|
$type = trim( $this->ipsclass->input['type'] );
|
|
$id = intval( $this->ipsclass->input['id'] );
|
|
$p = intval( $this->ipsclass->input['p'] );
|
|
$bitname = $this->ipsclass->parse_clean_value( urldecode( $_REQUEST['bitname'] ) );
|
|
$group_name = trim( $this->ipsclass->input['group_name'] );
|
|
|
|
$template_bit_ids = array();
|
|
$ids = array();
|
|
|
|
//-----------------------------------------
|
|
// PAGE HEADER
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->admin->page_detail = "Âû ìîæåòå ðåäàêòèðîâàòü HTML êîä ýòîãî øàáëîíà.";
|
|
$this->ipsclass->admin->page_title = "Óïðàâëåíèå ñòèëÿìè";
|
|
|
|
//-----------------------------------------
|
|
// Get $skin_names stuff
|
|
//-----------------------------------------
|
|
|
|
require ROOT_PATH.'sources/lib/skin_info.php';
|
|
|
|
$this->functions->type = $type;
|
|
|
|
//-----------------------------------------
|
|
// Group bits
|
|
//-----------------------------------------
|
|
|
|
$group_bits = $this->ipsclass->cache_func->_get_templates($id, $p, 'groups', $group_name );
|
|
|
|
//-----------------------------------------
|
|
// Check for valid input...
|
|
//-----------------------------------------
|
|
|
|
if ( $type == 'single' )
|
|
{
|
|
if ( $suid == "" )
|
|
{
|
|
//-----------------------------------------
|
|
// Grab relevant SUID based on IDs
|
|
//-----------------------------------------
|
|
|
|
if ( $bitname == "" )
|
|
{
|
|
$this->ipsclass->admin->error("Íå âûáðàíû ID ôðàãìåíòîâ, ïîæàëóéñòà, âåðíèòåñü íàçàä è âûáåðèòå ÷òî-íèáóäü");
|
|
}
|
|
|
|
foreach( $group_bits as $eye => $i )
|
|
{
|
|
if ( $bitname == $i['func_name'] )
|
|
{
|
|
$suid = $i['suid'];
|
|
}
|
|
}
|
|
}
|
|
|
|
$ids[] = $suid;
|
|
}
|
|
else
|
|
{
|
|
//-----------------------------------------
|
|
// Bit names?
|
|
//-----------------------------------------
|
|
|
|
if ( $bitname )
|
|
{
|
|
foreach( explode( '|', $bitname ) as $name )
|
|
{
|
|
foreach( $group_bits as $eye => $i )
|
|
{
|
|
if ( $name == $i['func_name'] )
|
|
{
|
|
$ids[] = $i['suid'];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach ( $this->ipsclass->input as $key => $value )
|
|
{
|
|
if ( preg_match( "/^cb_(\d+)$/", $key, $match ) )
|
|
{
|
|
if ($this->ipsclass->input[$match[0]])
|
|
{
|
|
$ids[] = $match[1];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( count($ids) < 1 )
|
|
{
|
|
$this->ipsclass->admin->error("Íè îäíîãî ID íå âûáðàíî, ïîæàëóéñòà, âåðíèòåñü íàçàä è çàïîëíèòå âñå, ÷òî íåîáõîäèìî ïåðåä ïîäòâåðæäåíèåì ôîðìû");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Build form
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->js_template_tools();
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'template-edit-bit-complete' ),
|
|
2 => array( 'act' , 'templ' ),
|
|
3 => array( 'suid' , $suid ),
|
|
4 => array( 'type' , $type ),
|
|
5 => array( 'id' , $id ),
|
|
6 => array( 'p' , $p ),
|
|
7 => array( 'section' , $this->ipsclass->section_code ),
|
|
8 => array( 'bitname' , $bitname ),
|
|
9 => array( 'group_name', $group_name ),
|
|
) , "theform", "", 'template-bits-form' );
|
|
|
|
|
|
//-----------------------------------------
|
|
// Get template bits
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'skin_templates', 'where' => "suid IN (".implode(",",$ids).")" ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while ( $i = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$sec_arry[ $i['suid'] ] = $i;
|
|
$sec_arry[ $i['suid'] ]['easy_name'] = $i['func_name'];
|
|
|
|
//-----------------------------------------
|
|
// If easy name is available, use it
|
|
//-----------------------------------------
|
|
|
|
if ($bit_names[ $i['group_name'] ][ $i['func_name'] ] != "")
|
|
{
|
|
$sec_arry[ $i['suid'] ]['easy_name'] = $bit_names[ $i['group_name'] ][ $i['func_name'] ];
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Sort by easy_name
|
|
//-----------------------------------------
|
|
|
|
usort($sec_arry, array( 'ad_skin_template_bits', 'perly_alpha_sort' ) );
|
|
|
|
//-----------------------------------------
|
|
// Editor prefs strip
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= $this->functions->html_build_editor_top();
|
|
|
|
//-----------------------------------------
|
|
// Loop and print
|
|
//-----------------------------------------
|
|
|
|
foreach( $sec_arry as $idx => $template )
|
|
{
|
|
//-----------------------------------------
|
|
// Swop < and > into ascii entities
|
|
// to prevent textarea breaking html
|
|
//-----------------------------------------
|
|
|
|
$setid = $template['set_id'];
|
|
$groupname = $template['group_name'];
|
|
|
|
if ( ! $this->ipsclass->input['error_raw_'.$template['suid']] )
|
|
{
|
|
$templ = $template['section_content'];
|
|
}
|
|
else
|
|
{
|
|
$templ = $this->ipsclass->input['error_raw_'.$template['suid']];
|
|
}
|
|
|
|
$templ = str_replace( "&" , "&" , $templ );
|
|
$templ = str_replace( "<" , "<" , $templ );
|
|
$templ = str_replace( ">" , ">" , $templ );
|
|
$templ = str_replace( '\n', '\n', $templ );
|
|
|
|
//-----------------------------------------
|
|
// Altered?
|
|
//-----------------------------------------
|
|
|
|
if ( $template['set_id'] == $id )
|
|
{
|
|
$altered_image = $this->altered;
|
|
}
|
|
else if ( $template['set_id'] == 1 )
|
|
{
|
|
$altered_image = $this->unaltered;
|
|
}
|
|
else
|
|
{
|
|
$altered_image = $this->inherited;
|
|
}
|
|
|
|
$this->ipsclass->html .= $this->functions->build_editor_area( $templ, $template, $altered_image );
|
|
|
|
$template_bit_ids[] = "t{$template['suid']}";
|
|
}
|
|
|
|
$this->ipsclass->html .= $this->functions->html_build_editor_bottom() . "</form>";
|
|
|
|
if ( $type != 'single' AND $type != 'multiple' )
|
|
{
|
|
$formbuttons = "<div align='center' class='pformstrip'>
|
|
<input type='submit' name='submit' value='Ñîõðàíèòü ôðàãìåíò(û) øàáëîíà' class='realdarkbutton'>
|
|
<input type='submit' name='savereload' value='Ñîõðàíèòü è ïåðåçàãðóçèòü ôðàãìåíò(û) øàáëîíà(îâ)' class='realdarkbutton'>
|
|
</div>\n";
|
|
|
|
$this->ipsclass->html = str_replace( '<!--IPB.EDITORBOTTOM-->', $formbuttons, $this->ipsclass->html );
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Let the JS know which IDs to
|
|
// look for (clever, no?)
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html = str_replace( "<!--IPB.TEMPLATE_BIT_IDS-->", implode(",",$template_bit_ids), $this->ipsclass->html );
|
|
|
|
//-----------------------------------------
|
|
// Find easy name for group
|
|
//-----------------------------------------
|
|
|
|
$old_groupname = $groupname;
|
|
|
|
if ( $skin_names[ $groupname ][0] != "" )
|
|
{
|
|
$groupname = $skin_names[ $groupname ][0];
|
|
}
|
|
|
|
$this->ipsclass->admin->nav[] = array( $this->ipsclass->form_code ,'Skin Manager Home' );
|
|
$this->ipsclass->admin->nav[] = array( "{$this->ipsclass->form_code}&code=edit&id={$id}&groupname={$old_groupname}", $groupname );
|
|
|
|
//-----------------------------------------
|
|
// Force reload of template bits?
|
|
//-----------------------------------------
|
|
|
|
if ( $reload )
|
|
{
|
|
$this->ipsclass->html .= "<script type='text/javascript'>
|
|
try
|
|
{
|
|
parent.iframe_template_bits.src = parent.iframe_template_bits.src;
|
|
parent.iframe_template_edit.style.height = '300px';
|
|
parent.div_template_edit.style.height = '300px';
|
|
}
|
|
catch(e){ alert(e) }
|
|
</script>\n";
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Type of output
|
|
//-----------------------------------------
|
|
|
|
if ( $type != 'single' AND $type != 'multiple' )
|
|
{
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->skin_jump_menu_wrap();
|
|
$this->ipsclass->admin->output();
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->admin->print_popup();
|
|
}
|
|
}
|
|
|
|
/*-------------------------------------------------------------------------*/
|
|
// COMPLETE EDIT
|
|
/*-------------------------------------------------------------------------*/
|
|
|
|
function template_edit_bit_complete()
|
|
{
|
|
//-----------------------------------------
|
|
// INIT
|
|
//-----------------------------------------
|
|
|
|
$ids = array();
|
|
$cb_ids = array();
|
|
$error_bits = array();
|
|
$type = trim( $this->ipsclass->input['type'] );
|
|
|
|
$this->ipsclass->input['id'] = intval($this->ipsclass->input['id']);
|
|
$this->ipsclass->input['p'] = intval($this->ipsclass->input['p']);
|
|
|
|
//-----------------------------------------
|
|
// CHECK FOR INPUT
|
|
//-----------------------------------------
|
|
|
|
foreach ($this->ipsclass->input as $key => $value)
|
|
{
|
|
if ( preg_match( "/^txt(\d+)$/", $key, $match ) )
|
|
{
|
|
if ( $this->ipsclass->input[ $match[0] ] )
|
|
{
|
|
//-----------------------------------------
|
|
// If multiple - only save clicked bit
|
|
//-----------------------------------------
|
|
|
|
$cb_ids[ $match[1] ] = 'cb_'.$match[1];
|
|
|
|
if ( $type == 'multiple' )
|
|
{
|
|
if ( $this->ipsclass->input[ 'edited-'.$match[1] ] )
|
|
{
|
|
$ids[] = $match[1];
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Not multiple - continue
|
|
//-----------------------------------------
|
|
|
|
else
|
|
{
|
|
$ids[] = $match[1];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( count($ids) < 1 )
|
|
{
|
|
$this->ipsclass->main_msg = "Íå÷åãî ñîõðàíÿòü";
|
|
|
|
foreach( $cb_ids as $i => $cb )
|
|
{
|
|
$this->ipsclass->input[ $cb ] = 1;
|
|
}
|
|
|
|
$this->template_edit_bit();
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Get the group name, etc
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'skin_templates', 'where' => "suid IN (".implode(",",$ids).")" ) );
|
|
$this->ipsclass->DB->simple_exec();
|
|
|
|
while ( $r = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$template[ $r['suid'] ] = $r;
|
|
$real_name = $r['group_name'];
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Process my bits :o
|
|
//-----------------------------------------
|
|
|
|
foreach( $ids as $id )
|
|
{
|
|
$text = $this->ipsclass->txt_stripslashes($_POST['txt'.$id]);
|
|
|
|
//-----------------------------------------
|
|
// Sw(o|a)p back < & >
|
|
//-----------------------------------------
|
|
|
|
$text = preg_replace("/</", "<", $text);
|
|
$text = preg_replace("/>/", ">", $text);
|
|
$text = preg_replace("/&/", "&", $text);
|
|
$text = str_replace( '\n', '\n',$text );
|
|
$text = str_replace( '\\n' , '\\\\\\n', $text );
|
|
|
|
$text = str_replace( '\' , '\\',$text );
|
|
|
|
//-----------------------------------------
|
|
// Convert \r to nowt
|
|
//-----------------------------------------
|
|
|
|
$text = preg_replace("/\r/", "", $text);
|
|
|
|
$func = preg_replace( "#,$#", "", str_replace( ''', "'", trim($this->ipsclass->txt_stripslashes($_POST['funcdata_'.$id])) ) );
|
|
|
|
//-----------------------------------------
|
|
// Test to ensure they are legal
|
|
// - catch warnings, etc
|
|
//-----------------------------------------
|
|
|
|
ob_start();
|
|
eval( $this->template->convert_html_to_php( $template[ $id ]['func_name'], $func, $text ) );
|
|
$return = ob_get_contents();
|
|
ob_end_clean();
|
|
|
|
if ( $return )
|
|
{
|
|
$error_bits[] = $id;
|
|
continue;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Is this in our template id group?
|
|
//-----------------------------------------
|
|
|
|
if ( $template[ $id ]['set_id'] == $this->ipsclass->input['id'] )
|
|
{
|
|
//-----------------------------------------
|
|
// Okay, update...
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->do_update( 'skin_templates', array( 'section_content' => $text, 'updated' => time(), 'func_data' => $func ), 'suid='.$id );
|
|
}
|
|
else
|
|
{
|
|
//-----------------------------------------
|
|
// No? OK - best add it as a 'new' bit
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->do_insert( 'skin_templates', array (
|
|
'set_id' => $this->ipsclass->input['id'],
|
|
'group_name' => $template[ $id ]['group_name'],
|
|
'section_content' => $text,
|
|
'func_name' => $template[ $id ]['func_name'],
|
|
'func_data' => $func,
|
|
'updated' => time(),
|
|
) );
|
|
|
|
if ( $this->ipsclass->input['type'] == 'single' )
|
|
{
|
|
$this->ipsclass->input['suid'] = $this->ipsclass->DB->get_insert_id();
|
|
}
|
|
else
|
|
{
|
|
$cb_ids[ $id ] = 'cb_'.$this->ipsclass->DB->get_insert_id();
|
|
unset($this->ipsclass->input['cb_'.$id ]);
|
|
}
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Rebuild the PHP file
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->cache_func->_recache_templates( $this->ipsclass->input['id'], $this->ipsclass->input['p'], $real_name );
|
|
|
|
//-----------------------------------------
|
|
// Back we go...
|
|
//-----------------------------------------
|
|
|
|
if ( count( $error_bits ) )
|
|
{
|
|
foreach( $error_bits as $id )
|
|
{
|
|
$this->ipsclass->input['cb_'.$id ] = 1;
|
|
$this->ipsclass->input['error_raw_'.$id] = $this->ipsclass->txt_stripslashes($_POST['txt'.$id]);
|
|
$this->ipsclass->main_msg = "Ýòè ôðàãìåíòû øàáëîíà íå ìîãóò áûòü ñîõðàíåíû, òàê êàê íàéäåíà îøèáêà ïðè ïàðñèíãå. Ïðîâåðüòå ââåäåííûé HTML-êîä è âñå âõîäÿùèå ïåðåìåííûå.";
|
|
|
|
$this->template_edit_bit();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if ( ( $type != 'single' AND $type != 'multiple' ) AND ( ! $this->ipsclass->input['savereload'] ) )
|
|
{
|
|
$this->ipsclass->admin->nav[] = array( $this->ipsclass->form_code ,'Skin Manager Home' );
|
|
$this->ipsclass->admin->redirect( "{$this->ipsclass->form_code}&code=template-edit-bit&id={$this->ipsclass->input['id']}&group_name={$real_name}", "Ôðàãìåíò(û) øàáëîíà îáíîâëåíû, âîçâðàùåíèå ê îêíó âûáîðà ôðàãìåíòîâ øàáëîíà" );
|
|
}
|
|
else
|
|
{
|
|
//-----------------------------------------
|
|
// Reload edit window
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->main_msg = "Ôðàãìåíò(û) øàáëîíà îáíîâëåíû";
|
|
|
|
foreach( $cb_ids as $i => $cb )
|
|
{
|
|
$this->ipsclass->input[ $cb ] = 1;
|
|
}
|
|
|
|
$this->template_edit_bit();
|
|
}
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// REMOVE CUSTOMIZATION
|
|
//-----------------------------------------
|
|
|
|
function template_revert_bit()
|
|
{
|
|
//-----------------------------------------
|
|
// INIT
|
|
//-----------------------------------------
|
|
|
|
$suid = $this->ipsclass->input['suid'];
|
|
$type = $this->ipsclass->input['type'];
|
|
$bitname = $this->ipsclass->parse_clean_value( urldecode( $_REQUEST['bitname'] ) );
|
|
$group_name = trim( $this->ipsclass->input['group_name'] );
|
|
$id = intval( $this->ipsclass->input['id'] );
|
|
$p = intval( $this->ipsclass->input['p'] );
|
|
|
|
//-----------------------------------------
|
|
// Check
|
|
//-----------------------------------------
|
|
|
|
if ( ! $suid )
|
|
{
|
|
if ( $bitname == "" )
|
|
{
|
|
$this->ipsclass->admin->error("Âû äîëæíû ââåñòè ïðàâèëüíûé ID ôðàãìåíòà øàáëîíà");
|
|
}
|
|
|
|
$group_bits = $this->ipsclass->cache_func->_get_templates($id, $p, 'groups', $group_name );
|
|
|
|
foreach( $group_bits as $eye => $i )
|
|
{
|
|
if ( $bitname == $i['func_name'] )
|
|
{
|
|
$suid = $i['suid'];
|
|
}
|
|
}
|
|
}
|
|
|
|
$row = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'skin_templates', 'where' => 'suid='.$suid ) );
|
|
|
|
if ( $row['set_id'] == 1 )
|
|
{
|
|
$this->ipsclass->admin->error("û íå ìîæåòå óäàëèòü ôðàãìåíò øàáëîíà èç îñíîâíîãî øàáëîíà.");
|
|
}
|
|
|
|
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'skin_templates', 'where' => 'suid='.$suid ) );
|
|
|
|
//-----------------------------------------
|
|
// Rebuild the PHP file
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->cache_func->_recache_templates( $this->ipsclass->input['id'], $this->ipsclass->input['p'], $row['group_name'] );
|
|
|
|
//-----------------------------------------
|
|
// Reload template list or redirect?
|
|
//-----------------------------------------
|
|
|
|
if ( $type == 'xml' )
|
|
{
|
|
@header( "Content-Type: text/html" );
|
|
print "done";
|
|
exit();
|
|
}
|
|
else if ( $type == 'frame' )
|
|
{
|
|
$this->template_bits_list();
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->admin->redirect( "{$this->ipsclass->form_code}&code=edit&id={$row['set_id']}&p={$this->ipsclass->input['p']}&group_name={$row['group_name']}&#{$row['group_name']}", "Ôðàãìåíò(û) øàáëîíà âîçâðàùåíû ê íà÷àëüíîìó ñîñòîÿíèþ, âîçâðàùåíèå ê îêíó âûáîðà ôðàãìåíòîâ øàáëîíà" );
|
|
}
|
|
}
|
|
|
|
//====================================================================================================================
|
|
// OLD - DEPRECIATED
|
|
//====================================================================================================================
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
?>
|