<?php
/**
*
*
* @author Benjamin Gillissen <hide@address.com>
*
* **************************************************************
Copyright (C) 2009 Benjamin Gillissen
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details at:
http://www.gnu.org/copyleft/gpl.html
* **************************************************************
*/
class ajx_swapthmvariant extends ajax {
public static function swapthmvariant($type, $new){
parent::$CB = __FUNCTION__;
if ( $type !== 'css' AND $type !== 'img' ){ return parent::getReply('swapthmvariant'); }
$theme = themes::get_active();
parent::addAssign("theme_".$type."var","innerHTML", self::gen_variant($type, $theme, $new) );
return parent::getReply();
}
private static function gen_variant($var, $theme, $new){
$use_custum = configs::get('themes', 'themes', Array($theme,"custum_$var") );
$opts = configs::get('themes', 'themes', Array($theme,'vars', $var) );
if ( $use_custum ){
$opts['custum'] = Array('name'=>'Custum Set');
$custum = themes::get_variant_key('custum_'.$var, $theme);
}
$o = '<select name="'.$var.'_'.$theme.'" onchange="xajax_swapthmvariant(\''.$var.'\', this.value)">';
foreach($opts as $k => &$data ){
if ( $new == $k ){ $sel = 'selected'; } else { $sel = ''; }
$o .= '<option value="'.$k.'" '.$sel.' >'.$data['name'].'</option>';
}
$o .= '</select>';
if ( $use_custum AND $new == 'custum' ){ $o .= '<input type="text" name="custum_'.$var.'_'.$theme.'" value="'.$custum.'" />'; }
return $o;
}
}