Vergleich admin/inc/functions_themes.php - 1.8.4 - 1.8.9

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 388Zeile 388
{
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}";


Zeile 468Zeile 468
	return $stylesheet;
}


	return $stylesheet;
}


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

function resync_stylesheet($stylesheet)
{
global $db;

function resync_stylesheet($stylesheet)
{
global $db;

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

			}

			}

		}

		}





		return true;
}

return false;
}


		return true;
}

return false;
}


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

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

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

	}

	}

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


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


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

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

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

Zeile 566Zeile 581
					if(!empty($parent_properties['inherited'][$property]))
{
$properties['inherited'][$property] = $parent_properties['inherited'][$property];

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

					}

					}

					else
{
$properties['inherited'][$property] = $parent;

					else
{
$properties['inherited'][$property] = $parent;

Zeile 580Zeile 595
		if(!empty($parent_stylesheets))
{
foreach($parent_stylesheets as $location => $value)

		if(!empty($parent_stylesheets))
{
foreach($parent_stylesheets as $location => $value)

			{

			{

				if($location == "inherited")
{
continue;

				if($location == "inherited")
{
continue;

Zeile 603Zeile 618
					}
}
}

					}
}
}

		}
}


		}
}


	if(!$inherited_properties)

	if(!$inherited_properties)

	{

	{

		$theme_vars = array(
"theme" => "cache/themes/theme{$tid}"
);
$properties['logo'] = parse_theme_variables($properties['logo'], $theme_vars);

		$theme_vars = array(
"theme" => "cache/themes/theme{$tid}"
);
$properties['logo'] = parse_theme_variables($properties['logo'], $theme_vars);

	}

	}

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

	if(!empty($stylesheets))
{
$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}'");

Zeile 670Zeile 685
		}
$class_id = md5($class_name);
if(isset($already_parsed[$class_id]))

		}
$class_id = md5($class_name);
if(isset($already_parsed[$class_id]))

		{

		{

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

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

Zeile 683Zeile 698
		$parsed_css[$class_id] = array("class_name" => $class_name, "name" => $name, "description" => $description, "values" => $values);
}


		$parsed_css[$class_id] = array("class_name" => $class_name, "name" => $name, "description" => $description, "values" => $values);
}


	return $parsed_css;
}

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

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

$selected = false;







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

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

Zeile 709Zeile 730
			}

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 722Zeile 743
	return $select;
}


	return $select;
}


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

function css_selectors_sort_cmp($a, $b)

function css_selectors_sort_cmp($a, $b)

{

{

	if(!$a['name'])

	if(!$a['name'])

	{

	{

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

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

	}

	}


if(!$b['name'])
{


if(!$b['name'])
{

Zeile 736Zeile 763
	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)

function get_css_properties($css, $id)

{

{

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

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

Zeile 807Zeile 840
	$new_css = str_replace(array("\r\n", "\n", "\r"), "\n", $new_css);

$generated_css = '';

	$new_css = str_replace(array("\r\n", "\n", "\r"), "\n", $new_css);

$generated_css = '';





	// Build the new CSS properties list
$new_css = explode("\n", $new_css);
foreach($new_css as $css_line)
{
$generated_css .= "\t".trim($css_line)."\n";

	// Build the new CSS properties list
$new_css = explode("\n", $new_css);
foreach($new_css as $css_line)
{
$generated_css .= "\t".trim($css_line)."\n";

	}

$parsed_css = array();

	}

$parsed_css = array();


// Parse out the CSS
if($css)
{
$parsed_css = css_to_array($css);


// Parse out the CSS
if($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'];

Zeile 850Zeile 883
		}

if(!$actual_occurance)

		}

if(!$actual_occurance)

		{

		{

			$actual_occurance = 1;
}


			$actual_occurance = 1;
}


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

	$css = preg_replace("#{\n*#s", "{\n", $css);
$css = preg_replace("#\s*\}\s*#", "\n}\n\n", $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 901Zeile 940
	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)
{
global $mybb, $db, $cache, $plugins;

$stylesheets = array();

function update_theme_stylesheet_list($tid, $theme = false, $update_disporders = true)
{
global $mybb, $db, $cache, $plugins;

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


Zeile 920Zeile 966
	// Get our list of stylesheets
$query = $db->simple_select("themestylesheets", "*", "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", "*", "tid IN ({$tid_list})", array('order_by' => 'tid', 'order_dir' => 'desc'));
while($stylesheet = $db->fetch_array($query))

	{

	{

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

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

Zeile 1077Zeile 1123
	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;

Zeile 1093Zeile 1144
			}

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

			}

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

		}

		}

	}

if(!isset($themes_by_parent[$tid]) || !is_array($themes_by_parent[$tid]))

	}

if(!isset($themes_by_parent[$tid]) || !is_array($themes_by_parent[$tid]))

Zeile 1103Zeile 1154

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 1120Zeile 1171
	return $themes;
}


	return $themes;
}


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

function make_child_theme_list($tid)
{
static $themes_by_child;

function make_child_theme_list($tid)
{
static $themes_by_child;

Zeile 1160Zeile 1216
	return $themes;
}


	return $themes;
}


 
/**
* @return array
*/

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

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





	if(empty($theme_cache) || !is_array($theme_cache))
{
$query = $db->simple_select("themes", "*", "", array('order_by' => "pid, name"));

	if(empty($theme_cache) || !is_array($theme_cache))
{
$query = $db->simple_select("themes", "*", "", array('order_by' => "pid, name"));

Zeile 1178Zeile 1237
				$theme_cache['default'] = $theme['tid'];
}
}

				$theme_cache['default'] = $theme['tid'];
}
}

	}

	}


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


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





	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 1273Zeile 1336
	}
}


	}
}


// 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 1286Zeile 1357
		foreach($themes as $key => $theme)
{
if($key == "default")

		foreach($themes as $key => $theme)
{
if($key == "default")

			{

			{

				continue;
}

				continue;
}





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

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

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

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

	}


	}


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


 
/**
* @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 1374Zeile 1450
	return $stylesheets;
}


	return $stylesheets;
}


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

function upgrade_css_120_to_140($css)
{
// Update our CSS to the new stuff in 1.4

function upgrade_css_120_to_140($css)
{
// Update our CSS to the new stuff in 1.4