1066 lines
32 KiB
PHP
1066 lines
32 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-10-10 14:08:54 +0100 (Mon, 10 Oct 2005) $
|
|
| > $Revision: 23 $
|
|
| > $Author: matt $
|
|
+---------------------------------------------------------------------------
|
|
|
|
|
| > CSS management functions
|
|
| > Module written by Matt Mecham
|
|
| > Date started: 4th 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_css
|
|
{
|
|
|
|
var $base_url;
|
|
var $template = "";
|
|
var $functions = "";
|
|
|
|
/**
|
|
* Section title name
|
|
*
|
|
* @var string
|
|
*/
|
|
var $perm_main = "lookandfeel";
|
|
|
|
/**
|
|
* Section title name
|
|
*
|
|
* @var string
|
|
*/
|
|
var $perm_child = "style";
|
|
|
|
|
|
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( ROOT_PATH.'sources/lib/admin_template_functions.php' );
|
|
|
|
$this->functions = new admin_template_functions();
|
|
$this->functions->ipsclass =& $this->ipsclass;
|
|
|
|
//-----------------------------------------
|
|
|
|
switch($this->ipsclass->input['code'])
|
|
{
|
|
case 'floateditor':
|
|
$this->functions->build_editor_area_floated(1);
|
|
break;
|
|
|
|
|
|
case 'edit2':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->do_form('edit');
|
|
break;
|
|
|
|
case 'edit':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->do_form('edit');
|
|
break;
|
|
|
|
case 'doedit':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->save_css('edit');
|
|
break;
|
|
|
|
case 'optimize':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->optimize();
|
|
break;
|
|
|
|
case 'easyedit':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->easy_edit();
|
|
break;
|
|
|
|
case 'doresync':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->do_resynch();
|
|
break;
|
|
|
|
case 'colouredit':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->colouredit();
|
|
break;
|
|
|
|
case 'docolour':
|
|
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':edit' );
|
|
$this->do_colouredit();
|
|
break;
|
|
|
|
default:
|
|
print "Äåéñòâèÿ íå âûáðàíû"; exit();
|
|
break;
|
|
|
|
//case 'wrapper':
|
|
// $this->list_sheets();
|
|
// break;
|
|
//case 'add':
|
|
// $this->do_form('add');
|
|
// break;
|
|
//case 'doadd':
|
|
// $this->save_css('add');
|
|
// break;
|
|
//case 'remove':
|
|
// $this->remove();
|
|
// break;
|
|
//case 'css_upload':
|
|
// $this->css_upload('new');
|
|
// break;
|
|
//case 'export':
|
|
// $this->export();
|
|
// break;
|
|
}
|
|
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// RESYNCH STYLE SHEETS
|
|
//-----------------------------------------
|
|
|
|
function do_resynch()
|
|
{
|
|
//-----------------------------------------
|
|
|
|
if ($this->ipsclass->input['id'] == "")
|
|
{
|
|
$this->ipsclass->admin->error("Íå âûáðàí ID øàáëîíà, âåðíèòåñü íàçàä è ïîâòîðèòå ïîïûòêó");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->query("SELECT cssid, css_text, css_name, css_comments FROM ibf_skin_css WHERE cssid='".$this->ipsclass->input['id']."'");
|
|
|
|
if ( ! $cssinfo = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$this->ipsclass->admin->error("Íåëüçÿ ïîëó÷èòü CSS èç áàçû äàííûõ");
|
|
}
|
|
|
|
if ( $this->ipsclass->input['favour'] == 'cache' )
|
|
{
|
|
$cache_file = ROOT_PATH."cache/css_".$this->ipsclass->input['id'].".css";
|
|
|
|
if ( file_exists( $cache_file ) )
|
|
{
|
|
$FH = fopen( $cache_file, 'r' );
|
|
$cache_data = fread( $FH, filesize($cache_file) );
|
|
fclose($FH);
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->admin->error("Íåëüçÿ íàéòè Êåø CSS ôàéëà @ $cache_file");
|
|
}
|
|
|
|
$dbr = $this->ipsclass->DB->compile_db_update_string( array( 'css_text' => $cache_data ) );
|
|
|
|
$this->ipsclass->DB->query("UPDATE ibf_skin_css SET $dbr WHERE cssid='".$this->ipsclass->input['id']."'");
|
|
}
|
|
else
|
|
{
|
|
$cache_file = ROOT_PATH."cache/css_".$this->ipsclass->input['id'].".css";
|
|
|
|
$FH = fopen( $cache_file, 'w' );
|
|
fputs( $FH, $cssinfo['css_text'], strlen($cssinfo['css_text']) );
|
|
fclose($FH);
|
|
}
|
|
|
|
if ( $this->ipsclass->input['return'] != 'colouredit' )
|
|
{
|
|
$this->do_form('edit');
|
|
}
|
|
else
|
|
{
|
|
$this->colouredit();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
//-----------------------------------------
|
|
// RESYNCH SPLASH
|
|
//-----------------------------------------
|
|
|
|
function resync_splash($db_length, $cache_length, $cache_mtime, $db_mtime, $id, $return="")
|
|
{
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->admin->page_detail = "Íàéäåíî íåñîîòâåòñòâèå ìåæäó êåø ñòèëåì ñòðàíèöû è òàáëèöîé ñòèëåé ñîõðàíåííîé â áàçå äàííûõ.";
|
|
$this->ipsclass->admin->page_title = " Ñèíõðîíèçàöèÿ òàáëèöû ñòèëåé";
|
|
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->adskin->td_header[] = array( " " , "50%" );
|
|
$this->ipsclass->adskin->td_header[] = array( " " , "50%" );
|
|
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'doresync' ),
|
|
2 => array( 'act' , 'style' ),
|
|
3 => array( 'id' , $id ),
|
|
4 => array( 'return', $return ),
|
|
5 => array( 'section', $this->ipsclass->section_code ),
|
|
) );
|
|
|
|
$favour = 'db';
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Ñèíõðàíèçèðîâàòü CSS ïåðåä åãî ðåäàêòèðîâàíèåì..." );
|
|
|
|
if ( intval($cache_mtime) > intval($db_mtime) )
|
|
{
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<b>CSS â áàçå äàííûõ, ïîñëåäíåå îáíîâëåíèå:</b> ".$this->ipsclass->admin->get_date($db_mtime, 'LONG'),
|
|
"<b>CSS â áàçå äàííûõ, êîë-âî ñèìâîëîâ:</b> $db_length",
|
|
) );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<span style='color:red'><b>CSS â êåøå, ïîñëåäíåå îáíîâëåíèå:</b> ".$this->ipsclass->admin->get_date($cache_mtime, 'LONG')."</span>",
|
|
"<span style='color:red'><b>CSS â êåøå, êîë-âî ñèìâîëîâ:</b> $cache_length</span>",
|
|
) );
|
|
$favour = 'cache';
|
|
|
|
}
|
|
else
|
|
{
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<span style='color:red'><b>CSS â áàçå äàííûõ, ïîñëåäíåå îáíîâëåíèå:</b> ".$this->ipsclass->admin->get_date($db_mtime, 'LONG')."</span>",
|
|
"<span style='color:red'><b>CSS â áàçå äàííûõ, êîë-âî ñèìâîëîâ:</b> $db_length</span>",
|
|
) );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<b>CSS â êåøå, ïîñëåäíåå îáíîâëåíèå:</b> ".$this->ipsclass->admin->get_date($cache_mtime, 'LONG'),
|
|
"<b>CSS â êåøå, êîë-âî ñèìâîëîâ:</b> $cache_length",
|
|
) );
|
|
}
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"<b>Èñïîëüçîâàòü ñèíõðîíèçàöèÿ....</b>",
|
|
$this->ipsclass->adskin->form_dropdown( 'favour', array(
|
|
0 => array( 'cache', 'Ïåðåïèñàòü âåðñèþ áàçû äàííûõ ñ êåø âåðñèåé'),
|
|
1 => array( 'db' , 'Îáíîâèòü âåðñèþ êåøà èç áàçû äàííûõ' ),
|
|
), $favour ),
|
|
) );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_form("Ñèíõðîíèçèðîâàòü");
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
|
|
|
|
//-----------------------------------------
|
|
//-------------------------------
|
|
|
|
$this->ipsclass->admin->output();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------
|
|
// OPTIMIZE STYLE SHEET
|
|
//-----------------------------------------
|
|
|
|
function optimize()
|
|
{
|
|
if ($this->ipsclass->input['id'] == "")
|
|
{
|
|
$this->ipsclass->admin->error("Âû äîëæíû óòî÷íèòü òåêóùèé CSS ID, âåðíèòåñü è ïîâòîðèòå çàíîâî");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->query("SELECT * from ibf_skin_css WHERE cssid='".$this->ipsclass->input['id']."'");
|
|
|
|
if ( ! $row = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
$this->ipsclass->admin->error("Íåâîçìîæíî çàïðîñèòü èíôîðìàöèþ èç áàçû äàííûõ");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
|
|
$orig_size = strlen($row['css_text']);
|
|
|
|
$orig_text = str_replace( "\r\n", "\n", $row['css_text']);
|
|
$orig_text = str_replace( "\r" , "\n", $orig_text);
|
|
$orig_text = str_replace( "\n\n", "\n", $orig_text);
|
|
|
|
$parsed = array();
|
|
|
|
//-----------------------------------------
|
|
// Remove comments
|
|
//-----------------------------------------
|
|
|
|
$orig_text = preg_replace( "#/\*(.+?)\*/#s", "", $orig_text );
|
|
|
|
//-----------------------------------------
|
|
// Grab all the definitions
|
|
//-----------------------------------------
|
|
|
|
preg_match_all( "/(.+?)\{(.+?)\}/s", $orig_text, $match, PREG_PATTERN_ORDER );
|
|
|
|
for ( $i = 0 ; $i < count($match[0]); $i++ )
|
|
{
|
|
$match[1][$i] = trim($match[1][$i]);
|
|
$parsed[ $match[1][$i] ] = trim($match[2][$i]);
|
|
}
|
|
|
|
//-----------------------------------------
|
|
|
|
if ( count($parsed) < 1)
|
|
{
|
|
$this->ipsclass->admin->error("Òàáëèöû ñòèëÿ íàõîäèòñÿ â ôîðìàòå êîòîðûé íå ïîíèìàåò Invision Power Board, îïòèìèçàöèÿ íå ïðîèçâåäåíà.");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Clean them up
|
|
//-----------------------------------------
|
|
|
|
$final = "";
|
|
|
|
foreach( $parsed as $name => $p )
|
|
{
|
|
//-----------------------------------------
|
|
// Ignore comments
|
|
//-----------------------------------------
|
|
|
|
if ( preg_match( "#^//#", $name) )
|
|
{
|
|
continue;
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Split up the components
|
|
//-----------------------------------------
|
|
|
|
$parts = explode( ";", $p);
|
|
$defs = array();
|
|
|
|
foreach( $parts as $part )
|
|
{
|
|
if ($part != "")
|
|
{
|
|
list($definition, $data) = explode( ":", $part );
|
|
$defs[] = trim($definition).": ".trim($data);
|
|
}
|
|
}
|
|
|
|
$final .= $name . " { ".implode("; ", $defs). " }\n";
|
|
}
|
|
|
|
$final_size = strlen($final);
|
|
|
|
if ($final_size < 1000)
|
|
{
|
|
$this->ipsclass->admin->error("Òàáëèöû ñòèëÿ íàõîäèòñÿ â ôîðìàòå êîòîðûé íå ïîíèìàåò Invision Power Board, îïòèìèçàöèÿ íå ïðîèçâåäåíà.");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Update the DB
|
|
//-----------------------------------------
|
|
|
|
$dbs = $this->ipsclass->DB->compile_db_update_string( array( 'css_text' => $final ) );
|
|
|
|
$this->ipsclass->DB->query("UPDATE ibf_skin_css SET $dbs WHERE cssid='".$this->ipsclass->input['id']."'");
|
|
|
|
$saved = $orig_size - $final_size;
|
|
$pc_saved = 0;
|
|
|
|
if ($saved > 0)
|
|
{
|
|
$pc_saved = sprintf( "%.2f", ($saved / $orig_size) * 100);
|
|
}
|
|
|
|
$this->ipsclass->admin->done_screen("Òàáëèöà ñòèëåé îáíîâëåíà: Èçìåíåíèÿ ñîõðàíåíû: $saved ($pc_saved %)", "Íàñòðîéêà òàáëèöû ñòèëåé", "{$this->ipsclass->form_code}" );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
//-----------------------------------------
|
|
// ADD / EDIT WRAPPERS
|
|
//-----------------------------------------
|
|
|
|
function save_css( $type='add' )
|
|
{
|
|
//-----------------------------------------
|
|
// Check input
|
|
//-----------------------------------------
|
|
|
|
if ($type == 'edit')
|
|
{
|
|
if ($this->ipsclass->input['id'] == "")
|
|
{
|
|
$this->ipsclass->admin->error("Âû äîëæíû óòî÷íèòü òåêóùèé CSS ID, âåðíèòåñü è ïîâòîðèòå çàíîâî");
|
|
}
|
|
|
|
}
|
|
|
|
if ($this->ipsclass->input['txtcss'] == "")
|
|
{
|
|
$this->ipsclass->admin->error("Âàøà òàáëèöà ñòèëåé íå äîëæíà áûòü ïóñòîé");
|
|
}
|
|
|
|
|
|
$css = $this->ipsclass->txt_stripslashes($_POST['txtcss']);
|
|
$css = str_replace( '\\', '\\\\', $css );
|
|
|
|
$this->ipsclass->DB->do_update( 'skin_sets', array( 'set_css' => $css, 'set_css_updated' => time() ), 'set_skin_set_id='.$this->ipsclass->input['id'] );
|
|
|
|
//-----------------------------------------
|
|
// Update cache?
|
|
//-----------------------------------------
|
|
|
|
$extra = "<b>Ôàéë êåøà òàáëèöû ñòèëåé îáíîâëåí</b>";
|
|
|
|
$message = $this->ipsclass->cache_func->_write_css_to_cache( $this->ipsclass->input['id'] );
|
|
|
|
//-----------------------------------------
|
|
// Back to it...
|
|
//-----------------------------------------
|
|
|
|
if ( ! $this->ipsclass->input['savereload'] )
|
|
{
|
|
$this->ipsclass->admin->nav[] = array( $this->ipsclass->form_code ,'Óïðàâëåíèå ñòèëåì' );
|
|
$this->ipsclass->main_msg = "Òàáëèöà ñòèëåé îáíîâëåíà: $extra";
|
|
$this->ipsclass->admin->redirect( $this->ipsclass->base_url.'§ion='.$this->ipsclass->section_code.'&act=sets', "Òàáëèöà ñòèëåé îáíîâëåíà, âåðíèòåñü ê óïðàâëåíèþ ñêèíîì" );
|
|
}
|
|
else
|
|
{
|
|
//-----------------------------------------
|
|
// Reload edit window
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->main_msg = "Òàáëèöà ñòèëåé îáíîâëåíà: $extra";
|
|
$this->do_form('edit');
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
//-----------------------------------------
|
|
// Show Add/Edit form
|
|
//-----------------------------------------
|
|
|
|
function do_form( $type='add' )
|
|
{
|
|
//-----------------------------------------
|
|
|
|
if ($this->ipsclass->input['id'] == "")
|
|
{
|
|
$this->ipsclass->admin->error("Âû äîëæíû óòî÷íèòü ID òåêóùåãî øàáëîíà, âåðíèòåñü è ïîâòîðèòå çàíîâî");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// check tree...
|
|
//-----------------------------------------
|
|
|
|
$found_id = "";
|
|
$found_content = "";
|
|
$this_set = "";
|
|
|
|
if ( $this->ipsclass->input['p'] > 0 )
|
|
{
|
|
$in = ','.$this->ipsclass->input['p'];
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Query
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->cache_add_query( 'stylesheets_do_form_concat', array( 'id' => $this->ipsclass->input['id'], 'parent' => $in ) );
|
|
$this->ipsclass->DB->cache_exec_query();
|
|
|
|
//-----------------------------------------
|
|
// check tree...
|
|
//-----------------------------------------
|
|
|
|
while( $row = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
if ( $row['set_css'] and ! $found_id )
|
|
{
|
|
$found_id = $row['set_skin_set_id'];
|
|
$found_content = $row['set_css'];
|
|
$found_time = $row['set_css_updated'];
|
|
}
|
|
|
|
if ( $this->ipsclass->input['id'] == $row['set_skin_set_id'] )
|
|
{
|
|
$this_set = $row;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
|
|
$css = $found_content;
|
|
|
|
$code = 'doedit';
|
|
$button = 'Ñîõðàíèòü';
|
|
|
|
//-----------------------------------------
|
|
// COLURS!ooO!
|
|
//-----------------------------------------
|
|
|
|
//.class { definitions }
|
|
//#id { definitions }
|
|
|
|
$css_elements = array();
|
|
|
|
preg_match_all( "/(\.|\#)(\S+?)\s{0,}\{.+?\}/s", $css, $match );
|
|
|
|
for ($i=0; $i < count($match[0]); $i++)
|
|
{
|
|
$type = trim($match[1][$i]);
|
|
|
|
$name = trim($match[2][$i]);
|
|
|
|
if ($type == '.')
|
|
{
|
|
$css_elements[] = array( 'class|'.$name, $type.$name );
|
|
}
|
|
else
|
|
{
|
|
$css_elements[] = array( 'id|'.$name, $type.$name );
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->admin->page_detail = "Âû ìîæåòå ïîëíîñòüþ èñïîëüçîâàòü CSS êîãäà äîáàâëÿåòå èëè ðåäàêòèðóåòå òàáëèöó ñòèëåé.";
|
|
$this->ipsclass->admin->page_title = " Íàñòðîéêà òàáëèöû ñòèëåé";
|
|
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= "<script language='javascript'>
|
|
<!--
|
|
function cssSearch(theID)
|
|
{
|
|
cssChosen = document.cssForm.csschoice.options[document.cssForm.csschoice.selectedIndex].value;
|
|
|
|
window.open('{$this->ipsclass->base_url}&act=rtempl&code=css_search&id='+theID+'&element='+cssChosen,'CSSSEARCH','width=400,height=500,resizable=yes,scrollbars=yes');
|
|
}
|
|
|
|
function cssPreview(theID)
|
|
{
|
|
cssChosen = document.cssForm.csschoice.options[document.cssForm.csschoice.selectedIndex].value;
|
|
|
|
window.open('{$this->ipsclass->base_url}&act=rtempl&code=css_preview&id='+theID+'&element='+cssChosen,'CSSSEARCH','width=400,height=500,resizable=yes,scrollbars=yes');
|
|
}
|
|
|
|
//-->
|
|
</script>";
|
|
|
|
//-----------------------------------------
|
|
// Show the form
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , $code ),
|
|
2 => array( 'act' , 'style' ),
|
|
3 => array( 'id' , $this->ipsclass->input['id'] ),
|
|
4 => array( 'section', $this->ipsclass->section_code ),
|
|
), "theform" );
|
|
|
|
//-----------------------------------------
|
|
// Editor section
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= $this->functions->build_generic_editor_area( array( 'section' => $this->ipsclass->section_code, 'act' => 'style', 'title' => '', 'textareaname' => 'css', 'textareainput' => $css ) );
|
|
|
|
$formbuttons = "<div align='center' class='pformstrip'>
|
|
<input type='submit' name='submit' value='$button' class='realdarkbutton'>
|
|
<input type='submit' name='savereload' value='Ñîõðàíèòü è ïåðåçàãðóçèòü' class='realdarkbutton'>
|
|
</div></form>\n";
|
|
|
|
$this->ipsclass->html = str_replace( '<!--IPB.EDITORBOTTOM-->', $formbuttons, $this->ipsclass->html );
|
|
|
|
$this->ipsclass->html .= "<br />";
|
|
|
|
//-----------------------------------------
|
|
// CSS search form
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'css_search' ),
|
|
2 => array( 'act' , 'style' ),
|
|
3 => array( 'id' , $this->ipsclass->input['id'] ),
|
|
4 => array( 'section', $this->ipsclass->section_code ),
|
|
), "cssForm" );
|
|
|
|
|
|
$this->ipsclass->adskin->td_header[] = array( " " , "20%" );
|
|
$this->ipsclass->adskin->td_header[] = array( " " , "80%" );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Èíôîðìàöèÿ îá èñïîëüçîâàíèè CSS êëàññîâ" );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array(
|
|
"Ïîêàçàòü, ãäå â øàáëîíàõ èñïîëüçóåòñÿ: ",
|
|
$this->ipsclass->adskin->form_dropdown('csschoice', $css_elements).' '
|
|
.'<input type="button" value="Ïîêàçàòü!" onClick="cssSearch(\''.$this->ipsclass->input['id'].'\');" id="editbutton">'
|
|
.' <input type="button" value="Ïðåäïðîñìîòð ñòèëÿ" onClick="cssPreview(\''.$this->ipsclass->input['id'].'\');" id="editbutton">'
|
|
) );
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_form();
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
|
|
|
|
$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();
|
|
|
|
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// EDIT COLOURS START
|
|
//-----------------------------------------
|
|
|
|
function colouredit()
|
|
{
|
|
//-----------------------------------------
|
|
|
|
if ($this->ipsclass->input['id'] == "")
|
|
{
|
|
$this->ipsclass->admin->error("Âû äîëæíû óòî÷íèòü ID òåêóùåãî øàáëîíà, âåðíèòåñü è ïîâòîðèòå ïîïûòêó ñíîâà");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// check tree...
|
|
//-----------------------------------------
|
|
|
|
$found_id = "";
|
|
$found_content = "";
|
|
$this_set = "";
|
|
|
|
if ( $this->ipsclass->input['p'] > 0 )
|
|
{
|
|
$in = ','.$this->ipsclass->input['p'];
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Query
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->cache_add_query( 'stylesheets_do_form_concat', array( 'id' => $this->ipsclass->input['id'], 'parent' => $in ) );
|
|
$this->ipsclass->DB->cache_exec_query();
|
|
|
|
//-----------------------------------------
|
|
// check tree...
|
|
//-----------------------------------------
|
|
|
|
while( $row = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
if ( $row['set_css'] and ! $found_id )
|
|
{
|
|
$found_id = $row['set_skin_set_id'];
|
|
$found_content = $row['set_css'];
|
|
$found_time = $row['set_css_updated'];
|
|
}
|
|
|
|
if ( $this->ipsclass->input['id'] == $row['set_skin_set_id'] )
|
|
{
|
|
$this_set = $row;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
|
|
$css = $found_content;
|
|
$css = preg_replace( "#/\*.+?\*/#s", "", $css );
|
|
//print "<pre>"; print $css; exit();
|
|
//-----------------------------------------
|
|
// Start the CSS matcher thingy
|
|
//-----------------------------------------
|
|
|
|
//.class { definitions }
|
|
//#id { definitions }
|
|
|
|
$colours = array();
|
|
|
|
//-----------------------------------------
|
|
// Make http:// safe..
|
|
//-----------------------------------------
|
|
|
|
$css = str_replace( 'http://', 'http|//', $css );
|
|
|
|
preg_match_all( "/([\:\.\#\w\s,\-]+)\{(.+?)\}/s", $css, $match );
|
|
|
|
for ($i=0; $i < count($match[0]); $i++)
|
|
{
|
|
$name = trim($match[1][$i]);
|
|
$content = trim($match[2][$i]);
|
|
|
|
$defs = explode( ';', $content );
|
|
|
|
if ( count( $defs ) > 0 )
|
|
{
|
|
foreach( $defs as $a )
|
|
{
|
|
$a = trim($a);
|
|
|
|
if ( $a != "" )
|
|
{
|
|
list( $property, $value ) = explode( ":", $a, 2 );
|
|
|
|
$property = trim($property);
|
|
$value = trim( str_replace( 'http|//', 'http://', $value) );
|
|
|
|
if ( $property )
|
|
{
|
|
if ( $property == 'color' or $property == 'background-color' )
|
|
{
|
|
$colours[ $name ][$property] = $value;
|
|
}
|
|
else
|
|
{
|
|
$colours[ $name ]['_extra'] .= $property.':'.$value.';'."\n";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
//print "<pre>"; print_r( $colours ); exit();
|
|
|
|
if ( count($colours) < 1 )
|
|
{
|
|
$this->ipsclass->admin->error("CSS ðàáîòàåò íå íàäåæíî! Öâåòà äëÿ ðåäàêòèðîâàíèÿ íå âûáðàíû");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
|
|
// Get $skin_names stuff
|
|
|
|
require './sources/lib/skin_info.php';
|
|
|
|
$this->ipsclass->admin->page_detail = "Íèæå âû ìîæåòå îòðåäàêòèðîâàòü òåêóùèå öâåòà. <strong><a href='skin_acp/IPB2_Standard/colours.html' target='_blank'>Âûáðàòü öâåò</a></center></strong>";
|
|
$this->ipsclass->admin->page_title = " Íàñòðîéêà òàáëèöû ñòèëåé [Öâåòà]";
|
|
|
|
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'docolour' ),
|
|
2 => array( 'act' , 'style' ),
|
|
3 => array( 'id' , $this->ipsclass->input['id'] ),
|
|
4 => array( 'section', $this->ipsclass->section_code ),
|
|
) );
|
|
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->adskin->td_header[] = array( "{none}" , "100%" );
|
|
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->html .= "<input type='hidden' name='initcol' value='' />
|
|
<input type='hidden' name='initformval' value='' />
|
|
<script type='text/javascript'>
|
|
function updatecolor( id )
|
|
{
|
|
itm = my_getbyid( id );
|
|
|
|
if ( itm )
|
|
{
|
|
eval(\"newcol = document.theAdminForm.f\"+id+\".value\");
|
|
itm.style.backgroundColor = newcol;
|
|
}
|
|
|
|
}
|
|
function poppicker( initcolor, formfield )
|
|
{
|
|
if ( initcolor )
|
|
{
|
|
document.theAdminForm.initcol.value = initcolor;
|
|
}
|
|
|
|
document.theAdminForm.initformval.value = formfield;
|
|
|
|
PopUp( 'skin_acp/IPB2_Standard/colours.html', 'PopPicker', 400, 500 );
|
|
}
|
|
</script>";
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Öâåòà CSS" );
|
|
$this->ipsclass->html .= "<td class='tdrow2'>";
|
|
|
|
foreach ( $colours as $prop => $val )
|
|
{
|
|
$tbl_colour = "";
|
|
$tbl_bg = "";
|
|
$tbl_html = "";
|
|
|
|
$desc = $css_names[ $prop ];
|
|
|
|
if ( $desc == "" )
|
|
{
|
|
$desc = 'Íåäîñòóïíî';
|
|
}
|
|
|
|
$name = $prop;
|
|
|
|
$md5 = md5($name);
|
|
|
|
if ( strlen($name) > 80 )
|
|
{
|
|
$name = substr( $name, 0, 80 ) .'...';
|
|
}
|
|
|
|
$font_box = $this->ipsclass->adskin->form_simple_input('f'.$md5.'color' , $val['color'], "14");
|
|
$bgcol_box = $this->ipsclass->adskin->form_simple_input('f'.$md5.'backgroundcolor' , $val['background-color'], "14");
|
|
|
|
$this->ipsclass->html .= "<div class='tdrow1'>
|
|
<fieldset>
|
|
<legend><strong style='font-size:14px'>{$name}</strong></legend>
|
|
<table width='100%' border='0' cellpadding='4' cellspacing='0'>
|
|
<tr>
|
|
<td width='40%' valign='top'>
|
|
<fieldset>
|
|
<legend><strong>Öâåò øðèôòà</strong></legend>
|
|
{$font_box} <input type='text' id='{$md5}color' onclick=\"updatecolor('{$md5}color')\" size='6' style='border:1px solid black;background-color:{$val['color']}' readonly='readonly'> <a href='#' title='íàñòðîéêà öâåòà' onclick=\"poppicker('{$val['color']}', '{$md5}color'); return false;\"><img src='{$this->ipsclass->skin_url}/images/colorselect.png' border='0' /></a>
|
|
</fieldset>
|
|
<br />
|
|
<fieldset>
|
|
<legend><strong>Öâåò çàäíåãî ôîíà</strong></legend>
|
|
{$bgcol_box} <input type='text' id='{$md5}backgroundcolor' onclick=\"updatecolor('{$md5}backgroundcolor')\" size='6' style='border:1px solid black;background-color:{$val['background-color']}' readonly='readonly'> <a href='#' title='íàñòðîéêà öâåòà' onclick=\"poppicker('{$val['background-color']}', '{$md5}backgroundcolor'); return false;\"><img src='{$this->ipsclass->skin_url}/images/colorselect.png' border='0' /></a>
|
|
</fieldset>
|
|
</td>
|
|
<td width='60%' valign='top'>
|
|
<fieldset>
|
|
<legend><strong>Äðóãèå àòðèáóòû CSS</strong></legend>
|
|
<textarea class='textinput' cols='40' rows='5' style='width:100%' name='f{$md5}extra'>{$val['_extra']}</textarea>
|
|
</fieldset>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</fieldset>
|
|
</div>";
|
|
}
|
|
|
|
$this->ipsclass->html .= "</td>";
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_form("Èçìåíèòü");
|
|
|
|
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
|
|
|
|
$this->ipsclass->admin->output();
|
|
|
|
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// EDIT COLOURS START
|
|
//-----------------------------------------
|
|
|
|
function do_colouredit()
|
|
{
|
|
//-----------------------------------------
|
|
|
|
if ($this->ipsclass->input['id'] == "")
|
|
{
|
|
$this->ipsclass->admin->error("Âû äîëæíû óòî÷íèòü ID òåêóùåãî øàáëîíà, âåðíèòåñü è ïîâòîðèòå ïîïûòêó ñíîâà");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// check tree...
|
|
//-----------------------------------------
|
|
|
|
$found_id = "";
|
|
$found_content = "";
|
|
$this_set = "";
|
|
|
|
if ( $this->ipsclass->input['p'] > 0 )
|
|
{
|
|
$in = ','.$this->ipsclass->input['p'];
|
|
}
|
|
|
|
//-----------------------------------------
|
|
// Query
|
|
//-----------------------------------------
|
|
|
|
$this->ipsclass->DB->cache_add_query( 'stylesheets_do_form_concat', array( 'id' => $this->ipsclass->input['id'], 'parent' => $in ) );
|
|
$this->ipsclass->DB->cache_exec_query();
|
|
|
|
//-----------------------------------------
|
|
// check tree...
|
|
//-----------------------------------------
|
|
|
|
while( $row = $this->ipsclass->DB->fetch_row() )
|
|
{
|
|
if ( $row['set_css'] and ! $found_id )
|
|
{
|
|
$found_id = $row['set_skin_set_id'];
|
|
$found_content = $row['set_css'];
|
|
$found_time = $row['set_css_updated'];
|
|
}
|
|
|
|
if ( $this->ipsclass->input['id'] == $row['set_skin_set_id'] )
|
|
{
|
|
$this_set = $row;
|
|
}
|
|
}
|
|
|
|
//-----------------------------------------
|
|
|
|
$css = $found_content;
|
|
$css = preg_replace( "#/\*.+?\*/#s", "", $css );
|
|
|
|
//-----------------------------------------
|
|
// Start the CSS matcher thingy
|
|
//-----------------------------------------
|
|
|
|
$css = str_replace( 'http://', 'http|//', $css );
|
|
|
|
$colours = array();
|
|
|
|
preg_match_all( "/([\:\.\#\w\s,\-]+)\{(.+?)\}/s", $css, $match );
|
|
|
|
for ($i=0; $i < count($match[0]); $i++)
|
|
{
|
|
$name = trim($match[1][$i]);
|
|
$content = trim($match[2][$i]);
|
|
|
|
$md5 = md5($name);
|
|
|
|
$defs = explode( ';', $content );
|
|
|
|
if ( count( $defs ) > 0 )
|
|
{
|
|
foreach( $defs as $a )
|
|
{
|
|
$a = trim($a);
|
|
|
|
if ( $a != "" )
|
|
{
|
|
list( $property, $value ) = explode( ":", $a, 2 );
|
|
|
|
$property = trim($property);
|
|
$value = trim( str_replace( 'http|//', 'http://', $value) );
|
|
|
|
if ( $property )
|
|
{
|
|
$colours[ $name ][$property] = $value;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
foreach( array( 'color', 'backgroundcolor' ) as $prop )
|
|
{
|
|
if ( strlen($_POST['f'.$md5.$prop]) >= 1 )
|
|
{
|
|
$field = $prop == 'backgroundcolor' ? 'background-color' : $prop;
|
|
|
|
$colours[ $name ][$field] = stripslashes($_POST['f'.$md5.$prop]);
|
|
}
|
|
}
|
|
|
|
if ( isset( $_POST['f'.$md5.'extra'] ) )
|
|
{
|
|
$tmp = str_replace( "\n", "", $_POST['f'.$md5.'extra'] );
|
|
$tmp = str_replace( "\r", "", $tmp );
|
|
|
|
$extra_attr = explode( ";", $tmp );
|
|
|
|
if ( is_array( $extra_attr ) and count( $extra_attr ) )
|
|
{
|
|
foreach( $extra_attr as $l )
|
|
{
|
|
$l = str_replace( 'http://', 'http|//', $l );
|
|
|
|
list( $p, $v ) = explode( ":", $l );
|
|
|
|
$colours[ $name ][ trim($p) ] = trim( str_replace( 'http|//', 'http://', $v) );
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ( count($colours) < 1 )
|
|
{
|
|
$this->ipsclass->admin->error("Íåò öâåòîâ äëÿ ðåäàêòèðîâàíèÿ");
|
|
}
|
|
|
|
//-----------------------------------------
|
|
|
|
unset($name);
|
|
unset($property);
|
|
|
|
$final = "";
|
|
|
|
foreach( $colours as $name => $property )
|
|
{
|
|
$final .= $name."\n{\n";
|
|
|
|
if ( is_array($property) and count($property) > 0 )
|
|
{
|
|
foreach( $property as $key => $value )
|
|
{
|
|
if ( $key AND isset($value) )
|
|
{
|
|
$final .= "\t".$key.": ".$value.";\n";
|
|
}
|
|
}
|
|
}
|
|
|
|
$final .= "}\n\n";
|
|
|
|
}
|
|
|
|
$this->ipsclass->input['txtcss'] = $final;
|
|
$_POST['txtcss'] = $final;
|
|
$this->ipsclass->input['savereload'] = 0;
|
|
$this->save_css('edit');
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
?>
|