Vergleich admin/inc/functions_themes.php - 1.6.10 - 1.6.11

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 9Zeile 9
function import_theme_xml($xml, $options=array())
{
global $mybb, $db;

function import_theme_xml($xml, $options=array())
{
global $mybb, $db;

	
require_once MYBB_ROOT."inc/class_xml.php";


require_once MYBB_ROOT."inc/class_xml.php";


$parser = new XMLParser($xml);
$tree = $parser->get_tree();


$parser = new XMLParser($xml);
$tree = $parser->get_tree();

Zeile 19Zeile 19
	{
return -1;
}

	{
return -1;
}

	



	$theme = $tree['theme'];

	$theme = $tree['theme'];

	



	// Do we have MyBB 1.2 template's we're importing?
$css_120 = "";

	// Do we have MyBB 1.2 template's we're importing?
$css_120 = "";

	



	if(is_array($theme['cssbits']))
{
$cssbits = kill_tags($theme['cssbits']);

	if(is_array($theme['cssbits']))
{
$cssbits = kill_tags($theme['cssbits']);

		



		foreach($cssbits as $name => $values)
{
$css_120 .= "{$name} {\n";

		foreach($cssbits as $name => $values)
{
$css_120 .= "{$name} {\n";

Zeile 37Zeile 37
				if(is_array($value))
{
$property = str_replace('_', ':', $property);

				if(is_array($value))
{
$property = str_replace('_', ':', $property);

					



					$css_120 .= "}\n{$name} {$property} {\n";
foreach($value as $property2 => $value2)
{

					$css_120 .= "}\n{$name} {$property} {\n";
foreach($value as $property2 => $value2)
{

Zeile 50Zeile 50
				}
}
$css_120 .= "}\n";

				}
}
$css_120 .= "}\n";

		}

		}

	}

	}

	



	if(is_array($theme['themebits']))
{
$themebits = kill_tags($theme['themebits']);

	if(is_array($theme['themebits']))
{
$themebits = kill_tags($theme['themebits']);

		



		$theme['properties']['tag'] = 'properties';

		$theme['properties']['tag'] = 'properties';

		



		foreach($themebits as $name => $value)
{
if($name == "extracss")

		foreach($themebits as $name => $value)
{
if($name == "extracss")

Zeile 66Zeile 66
				$css_120 .= $value;
continue;
}

				$css_120 .= $value;
continue;
}

			



			$theme['properties'][$name] = $value;
}
}

			$theme['properties'][$name] = $value;
}
}

	



	if($css_120)

	if($css_120)

	{

	{

		$css_120 = upgrade_css_120_to_140($css_120);
$theme['stylesheets']['tag'] = 'stylesheets';
$theme['stylesheets']['stylesheet'][0]['tag'] = 'stylesheet';
$theme['stylesheets']['stylesheet'][0]['attributes'] = array('name' => 'global.css', 'version' => $mybb->version_code);
$theme['stylesheets']['stylesheet'][0]['value'] = $css_120;

		$css_120 = upgrade_css_120_to_140($css_120);
$theme['stylesheets']['tag'] = 'stylesheets';
$theme['stylesheets']['stylesheet'][0]['tag'] = 'stylesheet';
$theme['stylesheets']['stylesheet'][0]['attributes'] = array('name' => 'global.css', 'version' => $mybb->version_code);
$theme['stylesheets']['stylesheet'][0]['value'] = $css_120;

		



		unset($theme['cssbits']);
unset($theme['themebits']);
}

		unset($theme['cssbits']);
unset($theme['themebits']);
}

	



	if(is_array($theme['properties']))
{
foreach($theme['properties'] as $property => $value)

	if(is_array($theme['properties']))
{
foreach($theme['properties'] as $property => $value)

Zeile 91Zeile 91
			{
continue;
}

			{
continue;
}

			



			$properties[$property] = $value['value'];

			$properties[$property] = $value['value'];

		}

		}

	}

	}

	



	if(empty($mybb->input['name']))
{
$name = $theme['attributes']['name'];

	if(empty($mybb->input['name']))
{
$name = $theme['attributes']['name'];

Zeile 121Zeile 121
	{
return -2;
}

	{
return -2;
}

	



	// Do we have any templates to insert?
if(!empty($theme['templates']['template']) && !$options['no_templates'])

	// Do we have any templates to insert?
if(!empty($theme['templates']['template']) && !$options['no_templates'])

	{		
if($options['templateset'])
{

	{
if($options['templateset'])
{

			$sid = $options['templateset'];

			$sid = $options['templateset'];

		} 
else
{

		}
else
{

			$sid = $db->insert_query("templatesets", array('title' => $db->escape_string($name)." Templates"));
}

			$sid = $db->insert_query("templatesets", array('title' => $db->escape_string($name)." Templates"));
}

		



		$templates = $theme['templates']['template'];
if(is_array($templates))
{

		$templates = $theme['templates']['template'];
if(is_array($templates))
{

Zeile 143Zeile 143
				$templates = array($templates);
}
}

				$templates = array($templates);
}
}

	



		$security_check = false;
$templatecache = array();
foreach($templates as $template)

		$security_check = false;
$templatecache = array();
foreach($templates as $template)

Zeile 173Zeile 173
			// PostgreSQL causes apache to stop sending content sometimes and
// causes the page to stop loading during many queries all at one time
if($db->engine == "pgsql")

			// PostgreSQL causes apache to stop sending content sometimes and
// causes the page to stop loading during many queries all at one time
if($db->engine == "pgsql")

			{

			{

				echo " ";
flush();
}

				echo " ";
flush();
}

Zeile 206Zeile 206
		{
// Trick the system into thinking we have a good array =P
$theme['stylesheets']['stylesheet'] = array($theme['stylesheets']['stylesheet']);

		{
// Trick the system into thinking we have a good array =P
$theme['stylesheets']['stylesheet'] = array($theme['stylesheets']['stylesheet']);

		}


		}


		foreach($theme['stylesheets']['stylesheet'] as $stylesheet)
{
if(substr($stylesheet['attributes']['name'], -4) != ".css")

		foreach($theme['stylesheets']['stylesheet'] as $stylesheet)
{
if(substr($stylesheet['attributes']['name'], -4) != ".css")

Zeile 219Zeile 219
			{
$stylesheet['attributes']['lastmodified'] = TIME_NOW;
}

			{
$stylesheet['attributes']['lastmodified'] = TIME_NOW;
}

			



			$new_stylesheet = array(
"name" => $db->escape_string($stylesheet['attributes']['name']),
"tid" => $theme_id,

			$new_stylesheet = array(
"name" => $db->escape_string($stylesheet['attributes']['name']),
"tid" => $theme_id,

Zeile 235Zeile 235
			{
$css_url = $cached;
}

			{
$css_url = $cached;
}

			



			$attachedto = $stylesheet['attributes']['attachedto'];
if(!$attachedto)
{
$attachedto = "global";
}

			$attachedto = $stylesheet['attributes']['attachedto'];
if(!$attachedto)
{
$attachedto = "global";
}

			



			// private.php?compose,folders|usercp.php,global|global
$attachedto = explode("|", $attachedto);
foreach($attachedto as $attached_file)

			// private.php?compose,folders|usercp.php,global|global
$attachedto = explode("|", $attachedto);
foreach($attachedto as $attached_file)

Zeile 252Zeile 252
				{
$attached_actions = array("global");
}

				{
$attached_actions = array("global");
}

				



				foreach($attached_actions as $action)
{
$theme_stylesheets[$attached_file][$action][] = $css_url;

				foreach($attached_actions as $action)
{
$theme_stylesheets[$attached_file][$action][] = $css_url;

Zeile 265Zeile 265
		);
$db->update_query("themes", $updated_theme, "tid='{$theme_id}'");
}

		);
$db->update_query("themes", $updated_theme, "tid='{$theme_id}'");
}

	



	update_theme_stylesheet_list($theme_id);

// And done?

	update_theme_stylesheet_list($theme_id);

// And done?

Zeile 281Zeile 281
 */
function parse_theme_variables($string, $variables=array())
{

 */
function parse_theme_variables($string, $variables=array())
{

	foreach(array_keys($variables) as $variable) 

	foreach(array_keys($variables) as $variable)

	{
$find[] = "{{$variable}}";
$replace[] = $variables[$variable];

	{
$find[] = "{{$variable}}";
$replace[] = $variables[$variable];

Zeile 323Zeile 323
			$fp = @fopen(MYBB_ROOT."cache/themes/theme{$tid}/index.html", "w");
@fwrite($fp, "");
@fclose($fp);

			$fp = @fopen(MYBB_ROOT."cache/themes/theme{$tid}/index.html", "w");
@fwrite($fp, "");
@fclose($fp);

			



			$theme_directory = "cache/themes/theme{$tid}";
}
}
// Seems like we're all good
else

			$theme_directory = "cache/themes/theme{$tid}";
}
}
// Seems like we're all good
else

	{

	{

		$theme_directory = "cache/themes/theme{$tid}";

		$theme_directory = "cache/themes/theme{$tid}";

	}

	}


$theme_vars = array(
"theme" => $theme_directory
);
$stylesheet = parse_theme_variables($stylesheet, $theme_vars);


$theme_vars = array(
"theme" => $theme_directory
);
$stylesheet = parse_theme_variables($stylesheet, $theme_vars);

	$stylesheet = preg_replace("#url\((\"|'|)(.*)\\1\)#e", "fix_css_urls('$2')", $stylesheet);


	$stylesheet = preg_replace_callback("#url\((\"|'|)(.*)\\1\)#", create_function('$matches', 'return fix_css_urls($matches[2]);'), $stylesheet);


	$fp = @fopen(MYBB_ROOT."{$theme_directory}/{$filename}", "wb");
if(!$fp)

	$fp = @fopen(MYBB_ROOT."{$theme_directory}/{$filename}", "wb");
if(!$fp)

	{
return false;
}


	{
return false;
}


	@fwrite($fp, $stylesheet);
@fclose($fp);
return "{$theme_directory}/{$filename}";
}

	@fwrite($fp, $stylesheet);
@fclose($fp);
return "{$theme_directory}/{$filename}";
}





function resync_stylesheet($stylesheet)
{
global $db;

function resync_stylesheet($stylesheet)
{
global $db;

	



	// Try and fix any missing cache file names
if(!$stylesheet['cachefile'] && $stylesheet['name'])
{

	// Try and fix any missing cache file names
if(!$stylesheet['cachefile'] && $stylesheet['name'])
{

		$stylesheet['cachefile'] = $stylesheet['name'];		

		$stylesheet['cachefile'] = $stylesheet['name'];

		$db->update_query("themestylesheets", array('cachefile' => $db->escape_string($stylesheet['name'])), "sid='{$stylesheet['sid']}'", 1);
}

		$db->update_query("themestylesheets", array('cachefile' => $db->escape_string($stylesheet['name'])), "sid='{$stylesheet['sid']}'", 1);
}

	



	// Still don't have the cache file name or is it not a flat file? Return false
if(!$stylesheet['cachefile'] || strpos($stylesheet['cachefile'], 'css.php') !== false)
{
return false;
}

	// Still don't have the cache file name or is it not a flat file? Return false
if(!$stylesheet['cachefile'] || strpos($stylesheet['cachefile'], 'css.php') !== false)
{
return false;
}

	



	if(!file_exists(MYBB_ROOT."cache/themes/theme{$stylesheet['tid']}/{$stylesheet['name']}") && !file_exists(MYBB_ROOT."cache/themes/{$stylesheet['tid']}_{$stylesheet['name']}"))
{
if(cache_stylesheet($stylesheet['tid'], $stylesheet['cachefile'], $stylesheet['stylesheet']) !== false)
{
$db->update_query("themestylesheets", array('cachefile' => $db->escape_string($stylesheet['name'])), "sid='{$stylesheet['sid']}'", 1);

	if(!file_exists(MYBB_ROOT."cache/themes/theme{$stylesheet['tid']}/{$stylesheet['name']}") && !file_exists(MYBB_ROOT."cache/themes/{$stylesheet['tid']}_{$stylesheet['name']}"))
{
if(cache_stylesheet($stylesheet['tid'], $stylesheet['cachefile'], $stylesheet['stylesheet']) !== false)
{
$db->update_query("themestylesheets", array('cachefile' => $db->escape_string($stylesheet['name'])), "sid='{$stylesheet['sid']}'", 1);

			



			update_theme_stylesheet_list($stylesheet['tid']);

			update_theme_stylesheet_list($stylesheet['tid']);

			



			if($stylesheet['sid'] != 1)
{
$db->update_query("themestylesheets", array('lastmodified' => TIME_NOW), "sid='{$stylesheet['sid']}'", 1);
}
}

			if($stylesheet['sid'] != 1)
{
$db->update_query("themestylesheets", array('lastmodified' => TIME_NOW), "sid='{$stylesheet['sid']}'", 1);
}
}

	



		return true;
}
else if($stylesheet['sid'] != 1 && @filemtime(MYBB_ROOT."cache/themes/theme{$stylesheet['tid']}/{$stylesheet['name']}") > $stylesheet['lastmodified'])

		return true;
}
else if($stylesheet['sid'] != 1 && @filemtime(MYBB_ROOT."cache/themes/theme{$stylesheet['tid']}/{$stylesheet['name']}") > $stylesheet['lastmodified'])

Zeile 389Zeile 389
		$db->update_query("themestylesheets", array('stylesheet' => $db->escape_string($contents), 'lastmodified' => TIME_NOW), "sid='{$stylesheet['sid']}'", 1);
return true;
}

		$db->update_query("themestylesheets", array('stylesheet' => $db->escape_string($contents), 'lastmodified' => TIME_NOW), "sid='{$stylesheet['sid']}'", 1);
return true;
}

	



	return false;
}

function fix_css_urls($url)
{
if(!preg_match("#^([a-z0-9]+\:|/)#i", $url) && strpos($url, "../../../") === false)

	return false;
}

function fix_css_urls($url)
{
if(!preg_match("#^([a-z0-9]+\:|/)#i", $url) && strpos($url, "../../../") === false)

	{

	{

		return "url(../../../{$url})";

		return "url(../../../{$url})";

	}

	}

	else
{
return "url({$url})";
}

	else
{
return "url({$url})";
}

}

}


function unfix_css_urls($url)
{


function unfix_css_urls($url)
{

Zeile 437Zeile 437
		$query = $db->simple_select("themes", "*", "tid='".intval($parent)."'");
$parent_theme = $db->fetch_array($query);
if(count($properties) == 0 || !is_array($properties))

		$query = $db->simple_select("themes", "*", "tid='".intval($parent)."'");
$parent_theme = $db->fetch_array($query);
if(count($properties) == 0 || !is_array($properties))

		{

		{

			$parent_properties = unserialize($parent_theme['properties']);
if(!empty($parent_properties))
{

			$parent_properties = unserialize($parent_theme['properties']);
if(!empty($parent_properties))
{

Zeile 447Zeile 447
					{
continue;
}

					{
continue;
}

					



					$properties[$property] = $value;
if($parent_properties['inherited'][$property])
{

					$properties[$property] = $value;
if($parent_properties['inherited'][$property])
{

Zeile 473Zeile 473
					{
continue;
}

					{
continue;
}

					



					foreach($value as $action => $sheets)
{
foreach($sheets as $stylesheet)

					foreach($value as $action => $sheets)
{
foreach($sheets as $stylesheet)

Zeile 576Zeile 576
function get_selectors_as_options($css, $selected_item="")
{
$select = "";

function get_selectors_as_options($css, $selected_item="")
{
$select = "";

	



	if(!is_array($css))
{
$css = css_to_array($css);
}

	if(!is_array($css))
{
$css = css_to_array($css);
}

	



	$selected = false;

	$selected = false;

	



	if(is_array($css))
{
uasort($css, "css_selectors_sort_cmp");

	if(is_array($css))
{
uasort($css, "css_selectors_sort_cmp");

		



		foreach($css as $id => $css_array)
{
if(!$css_array['name'])
{
$css_array['name'] = $css_array['class_name'];
}

		foreach($css as $id => $css_array)
{
if(!$css_array['name'])
{
$css_array['name'] = $css_array['class_name'];
}

			



			if($selected_item == $id || (!$selected_item && !$selected))

			if($selected_item == $id || (!$selected_item && !$selected))

			{

			{

				$select .= "<option value=\"{$id}\" selected=\"selected\">{$css_array['name']}</option>\n";
$selected = true;
}

				$select .= "<option value=\"{$id}\" selected=\"selected\">{$css_array['name']}</option>\n";
$selected = true;
}

Zeile 615Zeile 615
	{
$a['name'] = $a['class_name'];
}

	{
$a['name'] = $a['class_name'];
}

	



	if(!$b['name'])
{
$b['name'] = $b['class_name'];
}
return strcmp($a['name'], $b['name']);

	if(!$b['name'])
{
$b['name'] = $b['class_name'];
}
return strcmp($a['name'], $b['name']);

}


}


function get_css_properties($css, $id)
{
if(!is_array($css))
{
$css = css_to_array($css);
}

function get_css_properties($css, $id)
{
if(!is_array($css))
{
$css = css_to_array($css);
}

	



	if(!isset($css[$id]))
{
return false;

	if(!isset($css[$id]))
{
return false;

Zeile 649Zeile 649
	{
return;
}

	{
return;
}

	



	$values = explode(";", $values);
foreach($values as $value)
{

	$values = explode(";", $values);
foreach($values as $value)
{

Zeile 694Zeile 694
	foreach($new_css as $css_line)
{
$generated_css .= "\t".trim($css_line)."\n";

	foreach($new_css as $css_line)
{
$generated_css .= "\t".trim($css_line)."\n";

	}


	}


	// Parse out the CSS
if($css)

	// Parse out the CSS
if($css)

	{

	{

		$parsed_css = css_to_array($css);

		$parsed_css = css_to_array($css);

	}


	}


	if(!$class_id)
{
$class_id = $parsed_css[$selector]['class_name'];
}

	if(!$class_id)
{
$class_id = $parsed_css[$selector]['class_name'];
}

	



	// The specified class ID cannot be found, add CSS to end of file
if(!$css || !$parsed_css[$selector])
{

	// The specified class ID cannot be found, add CSS to end of file
if(!$css || !$parsed_css[$selector])
{

Zeile 717Zeile 717
	{
$css = str_replace(array("\r\n", "\n", "\r"), "\n", $css);
$css = preg_replace('#(?<!\\")\}#', "}\n", $css);

	{
$css = str_replace(array("\r\n", "\n", "\r"), "\n", $css);
$css = preg_replace('#(?<!\\")\}#', "}\n", $css);

		$css = preg_replace("#\s*([a-z0-9a+\\\[\]\-\"=_:>\*\.\#\,\s\(\)\|~\^]+)(\s*)\{(\n*)#isu", "\n$1 {\n", $css);

		$css = preg_replace("#^(?!@)\s*([a-z0-9a+\\\[\]\-\"=_:>\*\.\#\,\s\(\)\|~\^]+)(\s*)\{(\n*)#isu", "\n$1 {\n", $css);

		$css = preg_replace("#\s{1,}\{#", " {", $css);
$existing_block = $parsed_css[$selector];

		$css = preg_replace("#\s{1,}\{#", " {", $css);
$existing_block = $parsed_css[$selector];

		



		$break = strrpos($selector, "_");
if($break !== false)

		$break = strrpos($selector, "_");
if($break !== false)

		{

		{

			$actual_occurance = intval(substr($selector, ($break+1)));

			$actual_occurance = intval(substr($selector, ($break+1)));

		}


		}


		if(!$actual_occurance)
{
$actual_occurance = 1;
}

		if(!$actual_occurance)
{
$actual_occurance = 1;
}

		



		$occurance = 1;
$pos = 0;
do

		$occurance = 1;
$pos = 0;
do

Zeile 755Zeile 755
	}
$css = preg_replace("#{\n*#s", "{\n", $css);
$css = preg_replace("#\s*\}\s*#", "\n}\n\n", $css);

	}
$css = preg_replace("#{\n*#s", "{\n", $css);
$css = preg_replace("#\s*\}\s*#", "\n}\n\n", $css);

	return $css;	

	return $css;

}

function copy_stylesheet_to_theme($stylesheet, $tid)
{
global $db;

}

function copy_stylesheet_to_theme($stylesheet, $tid)
{
global $db;

	



	$stylesheet['tid'] = $tid;
unset($stylesheet['sid']);

	$stylesheet['tid'] = $tid;
unset($stylesheet['sid']);

	



	foreach($stylesheet as $key => $value)
{
$stylesheet[$db->escape_string($key)] = $db->escape_string($value);
}

	foreach($stylesheet as $key => $value)
{
$stylesheet[$db->escape_string($key)] = $db->escape_string($value);
}

	



	$sid = $db->insert_query("themestylesheets", $stylesheet);

	$sid = $db->insert_query("themestylesheets", $stylesheet);

	



	return $sid;
}

function update_theme_stylesheet_list($tid)

	return $sid;
}

function update_theme_stylesheet_list($tid)

{

{

	global $db;

	global $db;

	



	$stylesheets = array();

	$stylesheets = array();

	



	$child_list = make_child_theme_list($tid);
$parent_list = make_parent_theme_list($tid);

	$child_list = make_child_theme_list($tid);
$parent_list = make_parent_theme_list($tid);

	



	if(!is_array($parent_list))
{
return false;
}

	if(!is_array($parent_list))
{
return false;
}

	



	$tid_list = implode(',', $parent_list);

	$tid_list = implode(',', $parent_list);

	



	// Get our list of stylesheets
$query = $db->simple_select("themestylesheets", "sid,cachefile,attachedto,tid,lastmodified,name", "tid IN ({$tid_list})", array('order_by' => 'tid', 'order_dir' => 'desc'));
while($stylesheet = $db->fetch_array($query))

	// Get our list of stylesheets
$query = $db->simple_select("themestylesheets", "sid,cachefile,attachedto,tid,lastmodified,name", "tid IN ({$tid_list})", array('order_by' => 'tid', 'order_dir' => 'desc'));
while($stylesheet = $db->fetch_array($query))

Zeile 801Zeile 801
			{
$stylesheet['inherited'] = $stylesheet['tid'];
}

			{
$stylesheet['inherited'] = $stylesheet['tid'];
}

			



			$stylesheets[$stylesheet['name']] = $stylesheet;

			$stylesheets[$stylesheet['name']] = $stylesheet;

		}

		}

	}

	}

	



	foreach($stylesheets as $name => $stylesheet)
{
$sid = $stylesheet['sid'];
$css_url = "css.php?stylesheet={$sid}";

	foreach($stylesheets as $name => $stylesheet)
{
$sid = $stylesheet['sid'];
$css_url = "css.php?stylesheet={$sid}";

		



		foreach($parent_list as $theme_id)
{
if(file_exists(MYBB_ROOT."cache/themes/theme{$theme_id}/{$stylesheet['name']}") && filemtime(MYBB_ROOT."cache/themes/theme{$theme_id}/{$stylesheet['name']}") >= $stylesheet['lastmodified'])

		foreach($parent_list as $theme_id)
{
if(file_exists(MYBB_ROOT."cache/themes/theme{$theme_id}/{$stylesheet['name']}") && filemtime(MYBB_ROOT."cache/themes/theme{$theme_id}/{$stylesheet['name']}") >= $stylesheet['lastmodified'])

Zeile 819Zeile 819
				break;
}
}

				break;
}
}

		



		$attachedto = $stylesheet['attachedto'];
if(!$attachedto)
{

		$attachedto = $stylesheet['attachedto'];
if(!$attachedto)
{

Zeile 836Zeile 836
				$attached_actions = explode(",", $attached_file[1]);
$attached_file = $attached_file[0];
}

				$attached_actions = explode(",", $attached_file[1]);
$attached_file = $attached_file[0];
}

			



			if(count($attached_actions) == 0)

			if(count($attached_actions) == 0)

			{

			{

				$attached_actions = array("global");
}

				$attached_actions = array("global");
}

			



			foreach($attached_actions as $action)
{
$theme_stylesheets[$attached_file][$action][] = $css_url;

			foreach($attached_actions as $action)
{
$theme_stylesheets[$attached_file][$action][] = $css_url;

				



				if($stylesheet['inherited'])
{
$theme_stylesheets['inherited']["{$attached_file}_{$action}"][$css_url] = $stylesheet['inherited'];

				if($stylesheet['inherited'])
{
$theme_stylesheets['inherited']["{$attached_file}_{$action}"][$css_url] = $stylesheet['inherited'];

Zeile 859Zeile 859
		"stylesheets" => $db->escape_string(serialize($theme_stylesheets))
);
$db->update_query("themes", $updated_theme, "tid='{$tid}'");

		"stylesheets" => $db->escape_string(serialize($theme_stylesheets))
);
$db->update_query("themes", $updated_theme, "tid='{$tid}'");

	



	// Do we have any children themes that need updating too?
if(count($child_list) > 0)
{

	// Do we have any children themes that need updating too?
if(count($child_list) > 0)
{

Zeile 868Zeile 868
			update_theme_stylesheet_list($id);
}
}

			update_theme_stylesheet_list($id);
}
}

	



	return true;
}

	return true;
}





function make_parent_theme_list($tid)
{
static $themes_by_parent;

function make_parent_theme_list($tid)
{
static $themes_by_parent;

	



	$themes = array();
if(!is_array($themes_by_parent))
{

	$themes = array();
if(!is_array($themes_by_parent))
{

Zeile 886Zeile 886
			{
continue;
}

			{
continue;
}

			



			$themes_by_parent[$theme['tid']][$theme['pid']] = $theme;
}

			$themes_by_parent[$theme['tid']][$theme['pid']] = $theme;
}

	}


	}


	if(!isset($themes_by_parent[$tid]))
{
return false;
}

	if(!isset($themes_by_parent[$tid]))
{
return false;
}

	



	reset($themes_by_parent);
reset($themes_by_parent[$tid]);

	reset($themes_by_parent);
reset($themes_by_parent[$tid]);

	



	$themes = array();

	$themes = array();

	



	foreach($themes_by_parent[$tid] as $key => $theme)
{
$themes[] = $theme['tid'];
$parents = make_parent_theme_list($theme['pid']);

	foreach($themes_by_parent[$tid] as $key => $theme)
{
$themes[] = $theme['tid'];
$parents = make_parent_theme_list($theme['pid']);

		



		if(is_array($parents))
{
$themes = array_merge($themes, $parents);
}
}

		if(is_array($parents))
{
$themes = array_merge($themes, $parents);
}
}

	



	return $themes;
}

function make_child_theme_list($tid)
{
static $themes_by_child;

	return $themes;
}

function make_child_theme_list($tid)
{
static $themes_by_child;

	
$themes = array();


$themes = array();

	if(!is_array($themes_by_child))
{
$theme_cache = cache_themes();

	if(!is_array($themes_by_child))
{
$theme_cache = cache_themes();

Zeile 929Zeile 929
			{
continue;
}

			{
continue;
}

			



			$themes_by_child[$theme['pid']][$theme['tid']] = $theme;
}
}

			$themes_by_child[$theme['pid']][$theme['tid']] = $theme;
}
}

	



	if(!is_array($themes_by_child[$tid]))
{
return;
}

	if(!is_array($themes_by_child[$tid]))
{
return;
}

	



	$themes = array();

	$themes = array();

	



	foreach($themes_by_child[$tid] as $theme)
{
$themes[] = $theme['tid'];
$children = make_child_theme_list($theme['tid']);

	foreach($themes_by_child[$tid] as $theme)
{
$themes[] = $theme['tid'];
$children = make_child_theme_list($theme['tid']);

		



		if(is_array($children))
{
$themes = array_merge($themes, $children);
}
}

		if(is_array($children))
{
$themes = array_merge($themes, $children);
}
}

	



	return $themes;
}


	return $themes;
}


Zeile 967Zeile 967
			$theme['properties'] = unserialize($theme['properties']);
$theme['stylesheets'] = unserialize($theme['stylesheets']);
$theme_cache[$theme['tid']] = $theme;

			$theme['properties'] = unserialize($theme['properties']);
$theme['stylesheets'] = unserialize($theme['stylesheets']);
$theme_cache[$theme['tid']] = $theme;

			



			if($theme['def'] == 1)
{
$theme_cache['default'] = $theme['tid'];
}
}

			if($theme['def'] == 1)
{
$theme_cache['default'] = $theme['tid'];
}
}

	}


	}


	// Do we have no themes assigned as default?
if(!$theme_cache['default'])
{
$theme_cache['default'] = 1;
}

	// Do we have no themes assigned as default?
if(!$theme_cache['default'])
{
$theme_cache['default'] = 1;
}

	



	return $theme_cache;
}


	return $theme_cache;
}


Zeile 992Zeile 992
	$padding = $depth*20; // Padding

if(!is_array($theme_cache))

	$padding = $depth*20; // Padding

if(!is_array($theme_cache))

	{		

	{

		$themes = cache_themes();
$query = $db->query("
SELECT style, COUNT(uid) AS users

		$themes = cache_themes();
$query = $db->query("
SELECT style, COUNT(uid) AS users

Zeile 1005Zeile 1005
			{
$user_themes['style'] = $themes['default'];
}

			{
$user_themes['style'] = $themes['default'];
}

			



			if($themes[$user_themes['style']]['users'] > 0)

			if($themes[$user_themes['style']]['users'] > 0)

			{

			{

				$themes[$user_themes['style']]['users'] += intval($user_themes['users']);

				$themes[$user_themes['style']]['users'] += intval($user_themes['users']);

			}

			}

			else

			else

			{

			{

				$themes[$user_themes['style']]['users'] = intval($user_themes['users']);
}

				$themes[$user_themes['style']]['users'] = intval($user_themes['users']);
}

		}

// Restrucure the theme array to something we can "loop-de-loop" with
foreach($themes as $key => $theme)
{
if($key == "default")
{
continue;
}


		}

// Restrucure the theme array to something we can "loop-de-loop" with
foreach($themes as $key => $theme)
{
if($key == "default")
{
continue;
}


			$theme_cache[$theme['pid']][$theme['tid']] = $theme;
}
$theme_cache['num_themes'] = count($themes);
unset($themes);

			$theme_cache[$theme['pid']][$theme['tid']] = $theme;
}
$theme_cache['num_themes'] = count($themes);
unset($themes);

	}


	}


	if(!is_array($theme_cache[$parent]))

	if(!is_array($theme_cache[$parent]))

	{

	{

		return;
}

foreach($theme_cache[$parent] as $theme)

		return;
}

foreach($theme_cache[$parent] as $theme)

	{		

	{

		$popup = new PopupMenu("theme_{$theme['tid']}", $lang->options);
if($theme['tid'] > 1)
{
$popup->add_item($lang->edit_theme, "index.php?module=style-themes&amp;action=edit&amp;tid={$theme['tid']}");
$theme['name'] = "<a href=\"index.php?module=style-themes&amp;action=edit&amp;tid={$theme['tid']}\">".htmlspecialchars_uni($theme['name'])."</a>";

		$popup = new PopupMenu("theme_{$theme['tid']}", $lang->options);
if($theme['tid'] > 1)
{
$popup->add_item($lang->edit_theme, "index.php?module=style-themes&amp;action=edit&amp;tid={$theme['tid']}");
$theme['name'] = "<a href=\"index.php?module=style-themes&amp;action=edit&amp;tid={$theme['tid']}\">".htmlspecialchars_uni($theme['name'])."</a>";

			



			// We must have at least the master and 1 other active theme
if($theme_cache['num_themes'] > 2)
{
$popup->add_item($lang->delete_theme, "index.php?module=style-themes&amp;action=delete&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_deletion}')");
}

			// We must have at least the master and 1 other active theme
if($theme_cache['num_themes'] > 2)
{
$popup->add_item($lang->delete_theme, "index.php?module=style-themes&amp;action=delete&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_deletion}')");
}

			



			if($theme['def'] != 1)
{
$popup->add_item($lang->set_as_default, "index.php?module=style-themes&amp;action=set_default&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}");

			if($theme['def'] != 1)
{
$popup->add_item($lang->set_as_default, "index.php?module=style-themes&amp;action=set_default&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}");

Zeile 1065Zeile 1065
		$table->construct_cell(my_number_format($theme['users']), array("class" => "align_center"));
$table->construct_cell($popup->fetch(), array("class" => "align_center"));
$table->construct_row();

		$table->construct_cell(my_number_format($theme['users']), array("class" => "align_center"));
$table->construct_cell($popup->fetch(), array("class" => "align_center"));
$table->construct_row();

		



		// Fetch & build any child themes
build_theme_list($theme['tid'], ++$depth);
}

		// Fetch & build any child themes
build_theme_list($theme['tid'], ++$depth);
}

Zeile 1087Zeile 1087
			{
continue;
}

			{
continue;
}

			



			$theme_cache[$theme['pid']][$theme['tid']] = $theme;
}
unset($theme);

			$theme_cache[$theme['pid']][$theme['tid']] = $theme;
}
unset($theme);

	}


	}


	if(!is_array($theme_cache[$parent]) || $ignoretid === $parent)
{
return;

	if(!is_array($theme_cache[$parent]) || $ignoretid === $parent)
{
return;

	}


	}


	foreach($theme_cache[$parent] as $theme)
{
if($ignoretid === $theme['tid'])
{
continue;
}

	foreach($theme_cache[$parent] as $theme)
{
if($ignoretid === $theme['tid'])
{
continue;
}

		



		$list[$theme['tid']] = str_repeat("--", $depth).$theme['name'];
// Fetch & build any child themes
build_theme_array($ignoretid, $theme['tid'], $depth+1);
}

		$list[$theme['tid']] = str_repeat("--", $depth).$theme['name'];
// Fetch & build any child themes
build_theme_array($ignoretid, $theme['tid'], $depth+1);
}

	



	if(!$parent)
{
return $list;

	if(!$parent)
{
return $list;

Zeile 1120Zeile 1120
{
// Update our CSS to the new stuff in 1.4
$parsed_css = css_to_array($css);

{
// Update our CSS to the new stuff in 1.4
$parsed_css = css_to_array($css);

	



	if(!is_array($parsed_css))

	if(!is_array($parsed_css))

	{

	{

		return "";
}

		return "";
}

	



	foreach($parsed_css as $class_id => $array)
{
$parsed_css[$class_id]['values'] = str_replace('#eea8a1', '#ffdde0', $array['values']);
$parsed_css[$class_id]['values'] = str_replace('font-family: Verdana;', 'font-family: Verdana, Arial, Sans-Serif;', $array['values']);

	foreach($parsed_css as $class_id => $array)
{
$parsed_css[$class_id]['values'] = str_replace('#eea8a1', '#ffdde0', $array['values']);
$parsed_css[$class_id]['values'] = str_replace('font-family: Verdana;', 'font-family: Verdana, Arial, Sans-Serif;', $array['values']);

		



		switch($array['class_name'])
{
case '.bottommenu':

		switch($array['class_name'])
{
case '.bottommenu':

Zeile 1158Zeile 1158
				unset($parsed_css[$class_id]);
break;
default:

				unset($parsed_css[$class_id]);
break;
default:

		}		

		}

	}

	}

	



	$to_add = array(
md5('.trow_selected td') => array("class_name" => '.trow_selected td', "values" => 'background: #FFFBD9;'),
md5('blockquote') => array("class_name" => 'blockquote', "values" => "border: 1px solid #ccc;\n\tmargin: 0;\n\tbackground: #fff;\n\tpadding: 4px;"),

	$to_add = array(
md5('.trow_selected td') => array("class_name" => '.trow_selected td', "values" => 'background: #FFFBD9;'),
md5('blockquote') => array("class_name" => 'blockquote', "values" => "border: 1px solid #ccc;\n\tmargin: 0;\n\tbackground: #fff;\n\tpadding: 4px;"),

Zeile 1173Zeile 1173
		md5('.highlight') => array("class_name" => '.highlight', "values" => "background: #FFFFCC;\n\tpadding: 3px;"),
md5('.pm_alert') => array("class_name" => '.pm_alert', "values" => "background: #FFF6BF;\n\tborder: 1px solid #FFD324;\n\ttext-align: center;\n\tpadding: 5px 20px;\n\tfont-size: 11px;"),
md5('.red_alert') => array("class_name" => '.red_alert', "values" => "background: #FBE3E4;\n\tborder: 1px solid #A5161A;\n\tcolor: #A5161A;\n\ttext-align: center;\n\tpadding: 5px 20px;\n\tfont-size: 11px;"),

		md5('.highlight') => array("class_name" => '.highlight', "values" => "background: #FFFFCC;\n\tpadding: 3px;"),
md5('.pm_alert') => array("class_name" => '.pm_alert', "values" => "background: #FFF6BF;\n\tborder: 1px solid #FFD324;\n\ttext-align: center;\n\tpadding: 5px 20px;\n\tfont-size: 11px;"),
md5('.red_alert') => array("class_name" => '.red_alert', "values" => "background: #FBE3E4;\n\tborder: 1px solid #A5161A;\n\tcolor: #A5161A;\n\ttext-align: center;\n\tpadding: 5px 20px;\n\tfont-size: 11px;"),

		md5('.high_warning') => array("class_name" => '.high_warning', "values" => "color: #CC0000;"),
md5('.moderate_warning') => array("class_name" => '.moderate_warning', "values" => "color: #F3611B;"),

		md5('.high_warning') => array("class_name" => '.high_warning', "values" => "color: #CC0000;"),
md5('.moderate_warning') => array("class_name" => '.moderate_warning', "values" => "color: #F3611B;"),

		md5('.low_warning') => array("class_name" => '.low_warning', "values" => "color: #AE5700;"),
md5('div.error') => array("class_name" => 'div.error', "values" => "padding: 5px 10px;\n\tborder-top: 2px solid #FFD324;\n\tborder-bottom: 2px solid #FFD324;\n\tbackground: #FFF6BF\n\tfont-size: 12px;"),
md5('.high_warning') => array("class_name" => '.high_warning', "values" => "color: #CC0000;"),
md5('.moderate_warning') => array("class_name" => '.moderate_warning', "values" => "color: #F3611B;"),
md5('.low_warning') => array("class_name" => '.low_warning', "values" => "color: #AE5700;"),
md5('div.error') => array("class_name" => 'div.error', "values" => "padding: 5px 10px;\n\tborder-top: 2px solid #FFD324;\n\tborder-bottom: 2px solid #FFD324;\n\tbackground: #FFF6BF;\n\tfont-size: 12px;"),

		md5('.low_warning') => array("class_name" => '.low_warning', "values" => "color: #AE5700;"),
md5('div.error') => array("class_name" => 'div.error', "values" => "padding: 5px 10px;\n\tborder-top: 2px solid #FFD324;\n\tborder-bottom: 2px solid #FFD324;\n\tbackground: #FFF6BF\n\tfont-size: 12px;"),
md5('.high_warning') => array("class_name" => '.high_warning', "values" => "color: #CC0000;"),
md5('.moderate_warning') => array("class_name" => '.moderate_warning', "values" => "color: #F3611B;"),
md5('.low_warning') => array("class_name" => '.low_warning', "values" => "color: #AE5700;"),
md5('div.error') => array("class_name" => 'div.error', "values" => "padding: 5px 10px;\n\tborder-top: 2px solid #FFD324;\n\tborder-bottom: 2px solid #FFD324;\n\tbackground: #FFF6BF;\n\tfont-size: 12px;"),

		md5('div.error p') => array("class_name" => 'div.error p', "values" => "margin: 0;\n\tcolor: #000;\n\tfont-weight: normal;"),		

		md5('div.error p') => array("class_name" => 'div.error p', "values" => "margin: 0;\n\tcolor: #000;\n\tfont-weight: normal;"),

		md5('div.error p em') => array("class_name" => 'div.error p em', "values" => "font-style: normal;\n\tfont-weight: bold;\n\tpadding-left: 24px;\n\tdisplay: block;\n\tcolor: #C00;\n\tbackground: url({$mybb->settings['bburl']}/images/error.gif) no-repeat 0;"),
md5('div.error.ul') => array("class_name" => 'div.error.ul', "values" => "margin-left: 24px;"),
md5('.online') => array("class_name" => '.online', "values" => "color: #15A018;"),

		md5('div.error p em') => array("class_name" => 'div.error p em', "values" => "font-style: normal;\n\tfont-weight: bold;\n\tpadding-left: 24px;\n\tdisplay: block;\n\tcolor: #C00;\n\tbackground: url({$mybb->settings['bburl']}/images/error.gif) no-repeat 0;"),
md5('div.error.ul') => array("class_name" => 'div.error.ul', "values" => "margin-left: 24px;"),
md5('.online') => array("class_name" => '.online', "values" => "color: #15A018;"),

Zeile 1209Zeile 1209
		md5('.validation_success') => array("class_name" => '.validation_success', "values" => "background: url(images/valid.gif) no-repeat center left;\n\tcolor: #00b200;\n\tmargin: 5px 0;\n\tpadding: 5px;\n\tfont-weight: bold;\n\tfont-size: 11px;\n\tpadding-left: 22px;"),
md5('.validation_loading') => array("class_name" => '.validation_loading', "values" => "background: url(images/spinner.gif) no-repeat center left;\n\tcolor: #555;\n\tmargin: 5px 0;\n\tpadding: 5px;\n\tfont-weight: bold;\n\tfont-size: 11px;\n\tpadding-left: 22px;"),
);

		md5('.validation_success') => array("class_name" => '.validation_success', "values" => "background: url(images/valid.gif) no-repeat center left;\n\tcolor: #00b200;\n\tmargin: 5px 0;\n\tpadding: 5px;\n\tfont-weight: bold;\n\tfont-size: 11px;\n\tpadding-left: 22px;"),
md5('.validation_loading') => array("class_name" => '.validation_loading', "values" => "background: url(images/spinner.gif) no-repeat center left;\n\tcolor: #555;\n\tmargin: 5px 0;\n\tpadding: 5px;\n\tfont-weight: bold;\n\tfont-size: 11px;\n\tpadding-left: 22px;"),
);

	



	foreach($to_add as $class_id => $array)

	foreach($to_add as $class_id => $array)

	{

	{

		if($already_parsed[$class_id])

		if($already_parsed[$class_id])

		{

		{

			$already_parsed[$class_id]++;
$class_id .= "_".$already_parsed[$class_id];

			$already_parsed[$class_id]++;
$class_id .= "_".$already_parsed[$class_id];

		}

		}

		else
{
$already_parsed[$class_id] = 1;
}

		else
{
$already_parsed[$class_id] = 1;
}

		



		$array['name'] = "";
$array['description'] = "";

		$array['name'] = "";
$array['description'] = "";

		



		$parsed_css[$class_id] = $array;
}

		$parsed_css[$class_id] = $array;
}

	



	$css = "";
foreach($parsed_css as $class_id => $array)
{

	$css = "";
foreach($parsed_css as $class_id => $array)
{

Zeile 1237Zeile 1237
			if($array['name'])
{
$array['css'] .= "Name: {$array['name']}";

			if($array['name'])
{
$array['css'] .= "Name: {$array['name']}";

				



				if($array['description'])
{
$array['css'] .= "\n";
}

				if($array['description'])
{
$array['css'] .= "\n";
}

			}


			}


			if($array['description'])
{
$array['css'] .= "Description: {$array['description']}";
}

			if($array['description'])
{
$array['css'] .= "Description: {$array['description']}";
}

			



			$array['css'] .= " */\n";
}

			$array['css'] .= " */\n";
}

		



		$css .= "{$array['class_name']} {\n\t{$array['values']}\n}\n";
}

		$css .= "{$array['class_name']} {\n\t{$array['values']}\n}\n";
}

		



	return $css;
}
?>

	return $css;
}
?>