Vergleich admin/inc/functions_themes.php - 1.8.3 - 1.8.27

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 19Zeile 19
{
global $mybb, $db;


{
global $mybb, $db;


	require_once MYBB_ROOT."inc/class_xml.php";

$parser = new XMLParser($xml);

	$parser = create_xml_parser($xml);



	$tree = $parser->get_tree();

	$tree = $parser->get_tree();





	if(!is_array($tree) || !is_array($tree['theme']))
{
return -1;
}

	if(!is_array($tree) || !is_array($tree['theme']))
{
return -1;
}





	$theme = $tree['theme'];

// Do we have MyBB 1.2 template's we're importing?

	$theme = $tree['theme'];

// Do we have MyBB 1.2 template's we're importing?

Zeile 42Zeile 40
		{
$css_120 .= "{$name} {\n";
foreach($values as $property => $value)

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

			{

			{

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

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

Zeile 123Zeile 121
		$name = $theme['attributes']['name'];
}
else

		$name = $theme['attributes']['name'];
}
else

	{

	{

		$name = $mybb->input['name'];
}
$version = $theme['attributes']['version'];

$query = $db->simple_select("themes", "tid", "name='".$db->escape_string($name)."'", array("limit" => 1));
$existingtheme = $db->fetch_array($query);

		$name = $mybb->input['name'];
}
$version = $theme['attributes']['version'];

$query = $db->simple_select("themes", "tid", "name='".$db->escape_string($name)."'", array("limit" => 1));
$existingtheme = $db->fetch_array($query);

	if(!empty($options['force_name_check']) && $existingtheme['tid'])

	if(!empty($options['force_name_check']) && !empty($existingtheme['tid']))

	{
return -3;

	{
return -3;

	}
else if($existingtheme['tid'])
{

	}
else if(!empty($existingtheme['tid']))
{

		$options['tid'] = $existingtheme['tid'];

		$options['tid'] = $existingtheme['tid'];

	}


	}


	if($mybb->version_code != $version && $options['version_compat'] != 1)

	if($mybb->version_code != $version && $options['version_compat'] != 1)

	{

	{

		return -2;
}

		return -2;
}





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

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

	{
if($options['templateset'])
{
$sid = $options['templateset'];
}
else
{
$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 166Zeile 155
			}
}


			}
}


 
		// Security check

		$security_check = false;

		$security_check = false;

		$templatecache = array();

 
		foreach($templates as $template)
{
if(check_template($template['value']))

		foreach($templates as $template)
{
if(check_template($template['value']))

Zeile 175Zeile 164
				$security_check = true;
break;
}

				$security_check = true;
break;
}

 
		}

if($security_check == true)
{
return -4;
}

if(!empty($options['templateset']))
{
$sid = (int)$options['templateset'];
}
else
{
$sid = $db->insert_query("templatesets", array('title' => $db->escape_string($name)." Templates"));
}





 
		$templatecache = array();
foreach($templates as $template)
{

			$templatecache[] = array(
"title" => $db->escape_string($template['attributes']['name']),
"template" => $db->escape_string($template['value']),
"sid" => $db->escape_string($sid),
"version" => $db->escape_string($template['attributes']['version']),
"dateline" => TIME_NOW

			$templatecache[] = array(
"title" => $db->escape_string($template['attributes']['name']),
"template" => $db->escape_string($template['value']),
"sid" => $db->escape_string($sid),
"version" => $db->escape_string($template['attributes']['version']),
"dateline" => TIME_NOW

			);
}

if($security_check == true)
{
return -4;
}

foreach($templatecache as $template)

			);
}

foreach($templatecache as $template)






		{
// PostgreSQL causes apache to stop sending content sometimes and
// causes the page to stop loading during many queries all at one time

		{
// PostgreSQL causes apache to stop sending content sometimes and
// causes the page to stop loading during many queries all at one time

Zeile 199Zeile 201
				echo " ";
flush();
}

				echo " ";
flush();
}





			$db->insert_query("templates", $template);
}

$properties['templateset'] = $sid;

			$db->insert_query("templates", $template);
}

$properties['templateset'] = $sid;

	}

	}


// Not overriding an existing theme
if(empty($options['tid']))


// Not overriding an existing theme
if(empty($options['tid']))

Zeile 220Zeile 222
	else
{
$db->delete_query("themestylesheets", "tid='{$options['tid']}'");

	else
{
$db->delete_query("themestylesheets", "tid='{$options['tid']}'");

		$db->update_query("themes", array("properties" => $db->escape_string(serialize($properties))), "tid='{$options['tid']}'");

		$db->update_query("themes", array("properties" => $db->escape_string(my_serialize($properties))), "tid='{$options['tid']}'");

		$theme_id = $options['tid'];
}


		$theme_id = $options['tid'];
}


Zeile 239Zeile 241
		if($db->num_rows($query))
{
$inherited_stylesheets = my_unserialize($db->fetch_field($query, "stylesheets"));

		if($db->num_rows($query))
{
$inherited_stylesheets = my_unserialize($db->fetch_field($query, "stylesheets"));


if(is_array($inherited_stylesheets['inherited']))
{


if(isset($inherited_stylesheets['inherited']) && is_array($inherited_stylesheets['inherited']))
{

				$loop = 1;
foreach($inherited_stylesheets['inherited'] as $action => $stylesheets)
{

				$loop = 1;
foreach($inherited_stylesheets['inherited'] as $action => $stylesheets)
{

Zeile 251Zeile 253
						{
continue;
}

						{
continue;
}





						$properties['disporder'][basename($filename)] = $loop;
++$loop;
}

						$properties['disporder'][basename($filename)] = $loop;
++$loop;
}

				}
}
}


				}
}
}


		$loop = 1;
foreach($theme['stylesheets']['stylesheet'] as $stylesheet)
{

		$loop = 1;
foreach($theme['stylesheets']['stylesheet'] as $stylesheet)
{

 
			$stylesheet['attributes']['name'] = my_substr($stylesheet['attributes']['name'], 0, 30);


			if(substr($stylesheet['attributes']['name'], -4) != ".css")
{
continue;

			if(substr($stylesheet['attributes']['name'], -4) != ".css")
{
continue;

			}


			}


			if(empty($stylesheet['attributes']['lastmodified']))
{
$stylesheet['attributes']['lastmodified'] = TIME_NOW;

			if(empty($stylesheet['attributes']['lastmodified']))
{
$stylesheet['attributes']['lastmodified'] = TIME_NOW;

Zeile 275Zeile 279
			if(empty($stylesheet['attributes']['disporder']))
{
$stylesheet['attributes']['disporder'] = $loop;

			if(empty($stylesheet['attributes']['disporder']))
{
$stylesheet['attributes']['disporder'] = $loop;

			}

			}


if(empty($stylesheet['attributes']['attachedto']))
{


if(empty($stylesheet['attributes']['attachedto']))
{

Zeile 327Zeile 331
		}
// Now we have our list of built stylesheets, save them
$updated_theme = array(

		}
// Now we have our list of built stylesheets, save them
$updated_theme = array(

			"stylesheets" => $db->escape_string(serialize($theme_stylesheets))

			"stylesheets" => $db->escape_string(my_serialize($theme_stylesheets))

		);

		);


if(is_array($properties['disporder']))
{
asort($properties['disporder'], SORT_NUMERIC);

// Because inherited stylesheets can mess this up
$loop = 1;
$orders = array();
foreach($properties['disporder'] as $filename => $order)
{
$orders[$filename] = $loop;
++$loop;
}

$properties['disporder'] = $orders;
$updated_theme['properties'] = $db->escape_string(serialize($properties));
}

 

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


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

Zeile 388Zeile 375
{
global $mybb;


{
global $mybb;


	$filename = str_replace('/', '', $filename);

	$filename = basename($filename);

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

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

 

if(substr($filename, -4) != ".css")
{
return false;
}


// If we're in safe mode save to the main theme folder by default
if($mybb->safemode)


// If we're in safe mode save to the main theme folder by default
if($mybb->safemode)

Zeile 420Zeile 412
		"theme" => $theme_directory
);
$stylesheet = parse_theme_variables($stylesheet, $theme_vars);

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

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

	$stylesheet = preg_replace_callback("#url\((\"|'|)([^\"'\s]*?)\\1\)#", 'fix_css_urls_callback', $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);


@fwrite($fp, $stylesheet);
@fclose($fp);

Zeile 441Zeile 433
	@fwrite($fp_min, $stylesheet_min);
@fclose($fp_min);


	@fwrite($fp_min, $stylesheet_min);
@fclose($fp_min);


	if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath']))
{
$cdn_path = rtrim($mybb->settings['cdnpath'], '/\\');
$cache_themes_dir = $cdn_path . '/' . $theme_directory;

$copy_to_cdn = true;

if(!is_dir($cache_themes_dir))
{
if(!@mkdir($cache_themes_dir))
{
$copy_to_cdn = false;
}
}

if($copy_to_cdn)
{
@copy(MYBB_ROOT . "{$theme_directory}/{$filename}", "{$cache_themes_dir}/{$filename}");
@copy(MYBB_ROOT . "{$theme_directory}/{$filename_min}", "{$cache_themes_dir}/{$filename_min}");
}
}


	copy_file_to_cdn(MYBB_ROOT . "{$theme_directory}/{$filename}");
copy_file_to_cdn(MYBB_ROOT . "{$theme_directory}/{$filename_min}");





















	return "{$theme_directory}/{$filename}";
}

/**
* Minify a stylesheet to remove comments, linebreaks, whitespace,
* unnecessary semicolons, and prefers #rgb over #rrggbb.

	return "{$theme_directory}/{$filename}";
}

/**
* Minify a stylesheet to remove comments, linebreaks, whitespace,
* unnecessary semicolons, and prefers #rgb over #rrggbb.

 *

 *

 * @param $stylesheet string The stylesheet in it's untouched form.
* @return string The minified stylesheet
*/

 * @param $stylesheet string The stylesheet in it's untouched form.
* @return string The minified stylesheet
*/

Zeile 485Zeile 458
	$stylesheet = preg_replace('@#([a-f0-9])\1([a-f0-9])\2([a-f0-9])\3@i','#\1\2\3',$stylesheet);
$stylesheet = trim($stylesheet);
return $stylesheet;

	$stylesheet = preg_replace('@#([a-f0-9])\1([a-f0-9])\2([a-f0-9])\3@i','#\1\2\3',$stylesheet);
$stylesheet = trim($stylesheet);
return $stylesheet;

}







}

/**
* @param array $stylesheet
*
* @return bool
*/

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'])
{

Zeile 502Zeile 480
	if(!$stylesheet['cachefile'] || strpos($stylesheet['cachefile'], 'css.php') !== false)
{
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(!file_exists(MYBB_ROOT."cache/themes/theme{$stylesheet['tid']}/{$stylesheet['name']}") && !file_exists(MYBB_ROOT."cache/themes/{$stylesheet['tid']}_{$stylesheet['name']}"))
{

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


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


			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']}'");

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

Zeile 519Zeile 497
		}

return true;

		}

return true;

	}

	}


return false;


return false;

}








}

/**
* @deprecated
* @param string $url
*
* @return string
*/

function fix_css_urls($url)

function fix_css_urls($url)

{

{

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

	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})";
}
}


 
/**
* @param array $matches Matches.
*
* @return string
*/
function fix_css_urls_callback($matches)
{
return fix_css_urls($matches[2]);
}

/**
* @deprecated
* @param string $url
*
* @return string
*/

function unfix_css_urls($url)
{
return str_replace("../../../", "", $url);

function unfix_css_urls($url)
{
return str_replace("../../../", "", $url);

Zeile 569Zeile 569
	{
$query = $db->simple_select("themes", "*", "tid='".(int)$parent."'");
$parent_theme = $db->fetch_array($query);

	{
$query = $db->simple_select("themes", "*", "tid='".(int)$parent."'");
$parent_theme = $db->fetch_array($query);

		if(count($properties) == 0 || !is_array($properties))

		if(!is_array($properties) || count($properties) == 0)

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

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

Zeile 632Zeile 632
		);
$properties['logo'] = parse_theme_variables($properties['logo'], $theme_vars);
}

		);
$properties['logo'] = parse_theme_variables($properties['logo'], $theme_vars);
}

 

$updated_theme = array();

	if(!empty($stylesheets))

	if(!empty($stylesheets))

	{
$updated_theme['stylesheets'] = $db->escape_string(serialize($stylesheets));
}
$updated_theme['properties'] = $db->escape_string(serialize($properties));

	{
$updated_theme['stylesheets'] = $db->escape_string(my_serialize($stylesheets));
}
$updated_theme['properties'] = $db->escape_string(my_serialize($properties));


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


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

	}

	}


return $tid;
}


return $tid;
}

Zeile 703Zeile 705
	}

return $parsed_css;

	}

return $parsed_css;

}

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

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








}

/**
* @param array|string $css
* @param int $selected_item
*
* @return string
*/
function get_selectors_as_options($css, $selected_item=null)
{
$select = "";

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


	$selected = false;

if(is_array($css))

	$selected = false;

if(is_array($css))

Zeile 741Zeile 749
	return $select;
}


	return $select;
}


 
/**
* @param array $a
* @param array $b
*
* @return int
*/

function css_selectors_sort_cmp($a, $b)
{
if(!$a['name'])

function css_selectors_sort_cmp($a, $b)
{
if(!$a['name'])

	{

	{

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

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

	}


	}


	if(!$b['name'])
{
$b['name'] = $b['class_name'];

	if(!$b['name'])
{
$b['name'] = $b['class_name'];

Zeile 755Zeile 769
	return strcmp($a['name'], $b['name']);
}


	return strcmp($a['name'], $b['name']);
}


 
/**
* @param array|string $css
* @param string $id
*
* @return array|bool
*/

function get_css_properties($css, $id)
{
if(!is_array($css))

function get_css_properties($css, $id)
{
if(!is_array($css))

Zeile 776Zeile 796
 * @return array Array of CSS properties
*/
function parse_css_properties($values)

 * @return array Array of CSS properties
*/
function parse_css_properties($values)

{
$css_bits = array();



{
$css_bits = array(
'extra' => null,
);


if(!$values)
{


if(!$values)
{

Zeile 860Zeile 882
		$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*([a-z0-9a+\\\[\]\-\"=_:>\*\.\#\,\s\(\)\|~\^]+)(\s*)\{(\n*)#isu", "\n$1 {\n", $css);
$css = preg_replace("#\s{1,}\{#", " {", $css);
$existing_block = $parsed_css[$selector];





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

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

		{

		{

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

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

		}


		}


		if(!$actual_occurance)

		if(!$actual_occurance)

		{

		{

			$actual_occurance = 1;
}


			$actual_occurance = 1;
}


Zeile 879Zeile 901
		{
$pos = strpos($css, "\n".$existing_block['class_name']." {", $pos);
if($pos === false)

		{
$pos = strpos($css, "\n".$existing_block['class_name']." {", $pos);
if($pos === false)

			{
break;

			{
break;

			}
if($occurance == $actual_occurance)
{

			}
if($occurance == $actual_occurance)
{

Zeile 899Zeile 921
	return $css;
}


	return $css;
}


 
/**
* @param array $stylesheet
* @param int $tid
*
* @return bool|int
*/

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

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

Zeile 920Zeile 948
	return $sid;
}


	return $sid;
}


 
/**
* @param int $tid
* @param bool|array $theme
* @param bool $update_disporders
*
* @return bool
*/

function update_theme_stylesheet_list($tid, $theme = false, $update_disporders = true)
{

function update_theme_stylesheet_list($tid, $theme = false, $update_disporders = true)
{

	global $db, $cache;


	global $mybb, $db, $cache, $plugins;


	$stylesheets = array();

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

	$stylesheets = array();

$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);

// Get our list of stylesheets

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

// Get our list of stylesheets

Zeile 943Zeile 978
		if(empty($stylesheets[$stylesheet['name']]))
{
if($stylesheet['tid'] != $tid)

		if(empty($stylesheets[$stylesheet['name']]))
{
if($stylesheet['tid'] != $tid)

			{

			{

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

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





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

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

Zeile 960Zeile 995

foreach($parent_list as $theme_id)
{


foreach($parent_list as $theme_id)
{

			if($mybb->settings['usecdn'] && !empty($mybb->settings['cdnpath']))

			if(!empty($mybb->settings['usecdn']) && !empty($mybb->settings['cdnpath']))

			{
$cdnpath = rtrim($mybb->settings['cdnpath'], '/\\').'/';
if(file_exists($cdnpath."cache/themes/theme{$theme_id}/{$stylesheet['name']}") && filemtime(
$cdnpath."cache/themes/theme{$theme_id}/{$stylesheet['name']}"

			{
$cdnpath = rtrim($mybb->settings['cdnpath'], '/\\').'/';
if(file_exists($cdnpath."cache/themes/theme{$theme_id}/{$stylesheet['name']}") && filemtime(
$cdnpath."cache/themes/theme{$theme_id}/{$stylesheet['name']}"

					) >= $stylesheet['lastmodified']
)
{
$css_url = "cache/themes/theme{$theme_id}/{$stylesheet['name']}";
break;
}

					) >= $stylesheet['lastmodified']
)
{
$css_url = "cache/themes/theme{$theme_id}/{$stylesheet['name']}";
break;
}

			}
else
{

			}
else
{

Zeile 983Zeile 1018
					break;
}
}

					break;
}
}

 
		}

if(is_object($plugins))
{
$plugins->run_hooks('update_theme_stylesheet_list_set_css_url', $css_url);

		}

$attachedto = $stylesheet['attachedto'];

		}

$attachedto = $stylesheet['attachedto'];

Zeile 1005Zeile 1045
			if(count($attached_actions) == 0)
{
$attached_actions = array("global");

			if(count($attached_actions) == 0)
{
$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 1021Zeile 1061

// Now we have our list of built stylesheets, save them
$updated_theme = array(


// Now we have our list of built stylesheets, save them
$updated_theme = array(

		"stylesheets" => $db->escape_string(serialize($theme_stylesheets))

		"stylesheets" => $db->escape_string(my_serialize($theme_stylesheets))

	);

// Do we have a theme present? If so, update the stylesheet display orders
if($update_disporders)
{
if(!is_array($theme) || !$theme)

	);

// Do we have a theme present? If so, update the stylesheet display orders
if($update_disporders)
{
if(!is_array($theme) || !$theme)

		{

		{

			$theme_cache = cache_themes();
$theme = $theme_cache[$tid];

			$theme_cache = cache_themes();
$theme = $theme_cache[$tid];

		}

		}


$orders = $orphaned_stylesheets = array();
$properties = $theme['properties'];


$orders = $orphaned_stylesheets = array();
$properties = $theme['properties'];

Zeile 1040Zeile 1080
		{
$properties = my_unserialize($theme['properties']);
}

		{
$properties = my_unserialize($theme['properties']);
}

		



		$max_disporder = 0;

foreach($stylesheets as $stylesheet)

		$max_disporder = 0;

foreach($stylesheets as $stylesheet)

Zeile 1048Zeile 1088
			if(!isset($properties['disporder'][$stylesheet['name']]))
{
$orphaned_stylesheets[] = $stylesheet['name'];

			if(!isset($properties['disporder'][$stylesheet['name']]))
{
$orphaned_stylesheets[] = $stylesheet['name'];

				continue;
}


				continue;
}


			if($properties['disporder'][$stylesheet['name']] > $max_disporder)
{
$max_disporder = $properties['disporder'][$stylesheet['name']];

			if($properties['disporder'][$stylesheet['name']] > $max_disporder)
{
$max_disporder = $properties['disporder'][$stylesheet['name']];

Zeile 1072Zeile 1112

asort($orders);
$properties['disporder'] = $orders;


asort($orders);
$properties['disporder'] = $orders;

		$updated_theme['properties'] = $db->escape_string(serialize($properties));

		$updated_theme['properties'] = $db->escape_string(my_serialize($properties));

	}

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

// Do we have any children themes that need updating too?

	}

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

// Do we have any children themes that need updating too?

	if(count($child_list) > 0)

	if(is_array($child_list) && count($child_list) > 0)

	{
foreach($child_list as $id)
{

	{
foreach($child_list as $id)
{

Zeile 1091Zeile 1131
	return true;
}


	return true;
}


 
/**
* @param int $tid
*
* @return array|bool
*/

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 1110Zeile 1155
		}
}


		}
}


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


	if(!isset($themes_by_parent[$tid]) || !is_array($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();

foreach($themes_by_parent[$tid] as $key => $theme)

	$themes = array();

foreach($themes_by_parent[$tid] as $key => $theme)

Zeile 1130Zeile 1175
			$themes = array_merge($themes, $parents);
}
}

			$themes = array_merge($themes, $parents);
}
}





	return $themes;
}


	return $themes;
}


 
/**
* @param int $tid
*
* @return array|null
*/

function make_child_theme_list($tid)

function make_child_theme_list($tid)

{

{

	static $themes_by_child;

$themes = array();

	static $themes_by_child;

$themes = array();

Zeile 1156Zeile 1206
	if(!isset($themes_by_child[$tid]) || !is_array($themes_by_child[$tid]))
{
return null;

	if(!isset($themes_by_child[$tid]) || !is_array($themes_by_child[$tid]))
{
return null;

	}

	}


$themes = array();


$themes = array();





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

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

Zeile 1174Zeile 1224
	return $themes;
}


	return $themes;
}


 
/**
* @return array
*/

function cache_themes()
{
global $db, $theme_cache;

function cache_themes()
{
global $db, $theme_cache;

Zeile 1183Zeile 1236
		$query = $db->simple_select("themes", "*", "", array('order_by' => "pid, name"));
while($theme = $db->fetch_array($query))
{

		$query = $db->simple_select("themes", "*", "", array('order_by' => "pid, name"));
while($theme = $db->fetch_array($query))
{

 
			$theme['users'] = 0;

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

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

Zeile 1203Zeile 1257
	return $theme_cache;
}


	return $theme_cache;
}


 
/**
* @param int $parent
* @param int $depth
*/

function build_theme_list($parent=0, $depth=0)
{
global $mybb, $db, $table, $lang, $page; // Global $table is bad, but it will have to do for now

function build_theme_list($parent=0, $depth=0)
{
global $mybb, $db, $table, $lang, $page; // Global $table is bad, but it will have to do for now

Zeile 1217Zeile 1275
		while($user_themes = $db->fetch_array($query))
{
if($user_themes['style'] == 0)

		while($user_themes = $db->fetch_array($query))
{
if($user_themes['style'] == 0)

			{

			{

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

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

			}

if($themes[$user_themes['style']]['users'] > 0)
{
$themes[$user_themes['style']]['users'] += (int)$user_themes['users'];

			}

if(isset($themes[$user_themes['style']]['users']) && $themes[$user_themes['style']]['users'] > 0)
{
$themes[$user_themes['style']]['users'] += (int)$user_themes['users'];

			}
else

			}
else

			{

			{

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

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

			}
}

// 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;

			}
}

// 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['num_themes'] = count($themes);
unset($themes);
}


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

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

	{
return;
}

	{
return;
}

Zeile 1253Zeile 1311
	foreach($theme_cache[$parent] as $theme)
{
$popup = new PopupMenu("theme_{$theme['tid']}", $lang->options);

	foreach($theme_cache[$parent] as $theme)
{
$popup = new PopupMenu("theme_{$theme['tid']}", $lang->options);

 
		$set_default = '';

		if($theme['tid'] > 1)
{
$popup->add_item($lang->edit_theme, "index.php?module=style-themes&action=edit&tid={$theme['tid']}");

		if($theme['tid'] > 1)
{
$popup->add_item($lang->edit_theme, "index.php?module=style-themes&action=edit&tid={$theme['tid']}");

Zeile 1274Zeile 1333
				$set_default = "<img src=\"styles/{$page->style}/images/icons/default.png\" alt=\"{$lang->default_theme}\" style=\"vertical-align: middle;\" title=\"{$lang->default_theme}\" />";
}
$popup->add_item($lang->force_on_users, "index.php?module=style-themes&amp;action=force&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_forced}')");

				$set_default = "<img src=\"styles/{$page->style}/images/icons/default.png\" alt=\"{$lang->default_theme}\" style=\"vertical-align: middle;\" title=\"{$lang->default_theme}\" />";
}
$popup->add_item($lang->force_on_users, "index.php?module=style-themes&amp;action=force&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_forced}')");

 
			$set_default = "<div class=\"float_right\">{$set_default}</div>";

		}
$popup->add_item($lang->export_theme, "index.php?module=style-themes&amp;action=export&amp;tid={$theme['tid']}");
$popup->add_item($lang->duplicate_theme, "index.php?module=style-themes&amp;action=duplicate&amp;tid={$theme['tid']}");

		}
$popup->add_item($lang->export_theme, "index.php?module=style-themes&amp;action=export&amp;tid={$theme['tid']}");
$popup->add_item($lang->duplicate_theme, "index.php?module=style-themes&amp;action=duplicate&amp;tid={$theme['tid']}");

		$table->construct_cell("<div class=\"float_right\">{$set_default}</div><div style=\"margin-left: {$padding}px;\"><strong>{$theme['name']}</strong></div>");

		$table->construct_cell("{$set_default}<div style=\"margin-left: {$padding}px;\"><strong>{$theme['name']}</strong></div>");

		$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


// Fetch & build any child themes

		build_theme_list($theme['tid'], ++$depth);
}
}


		build_theme_list($theme['tid'], ++$depth);
}
}


// returns an array which can be sent to generate_select_box()









/**
* returns an array which can be sent to generate_select_box()
*
* @param int $ignoretid
* @param int $parent
* @param int $depth
*
* @return null|string
*/

function build_theme_array($ignoretid = null, $parent=0, $depth=0)
{
global $list;

function build_theme_array($ignoretid = null, $parent=0, $depth=0)
{
global $list;

Zeile 1309Zeile 1377
		unset($theme);
}


		unset($theme);
}


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

	if(!isset($theme_cache[$parent]) || !is_array($theme_cache[$parent]) || $ignoretid === $parent)

	{
return null;
}

	{
return null;
}

Zeile 1332Zeile 1400
	}
}


	}
}


 
/**
* @param array $theme
*
* @return array|bool
*/

function fetch_theme_stylesheets($theme)
{
// Fetch list of all of the stylesheets for this theme

function fetch_theme_stylesheets($theme)
{
// Fetch list of all of the stylesheets for this theme

Zeile 1358Zeile 1431
			foreach($style as $stylesheet2)
{
$stylesheets[$stylesheet2]['applied_to'][$file][] = $action;

			foreach($style as $stylesheet2)
{
$stylesheets[$stylesheet2]['applied_to'][$file][] = $action;

				if(is_array($file_stylesheets['inherited'][$file."_".$action]) && in_array($stylesheet2, array_keys($file_stylesheets['inherited'][$file."_".$action])))

				if(isset($file_stylesheets['inherited'][$file."_".$action]) && is_array($file_stylesheets['inherited'][$file."_".$action]) && in_array($stylesheet2, array_keys($file_stylesheets['inherited'][$file."_".$action])))

				{
$stylesheets[$stylesheet2]['inherited'] = $file_stylesheets['inherited'][$file."_".$action];
foreach($file_stylesheets['inherited'][$file."_".$action] as $value)

				{
$stylesheets[$stylesheet2]['inherited'] = $file_stylesheets['inherited'][$file."_".$action];
foreach($file_stylesheets['inherited'][$file."_".$action] as $value)

Zeile 1366Zeile 1439
						$inherited_load[] = $value;
}
}

						$inherited_load[] = $value;
}
}

			}
}
}

			}
}
}


foreach($stylesheets as $file => $stylesheet2)
{


foreach($stylesheets as $file => $stylesheet2)
{

		if(is_array($stylesheet2['inherited']))

		if(isset($stylesheet2['inherited']) && is_array($stylesheet2['inherited']))

		{
foreach($stylesheet2['inherited'] as $inherited_file => $tid)
{

		{
foreach($stylesheet2['inherited'] as $inherited_file => $tid)
{

Zeile 1384Zeile 1457
		$stylesheets[basename($file)] = $stylesheet2;
unset($stylesheets[$file]);
}

		$stylesheets[basename($file)] = $stylesheet2;
unset($stylesheets[$file]);
}





	return $stylesheets;
}


	return $stylesheets;
}


 
/**
* @param string $css
*
* @return string
*/

function upgrade_css_120_to_140($css)
{

function upgrade_css_120_to_140($css)
{

 
	global $mybb;

	// 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);