Vergleich admin/inc/functions_themes.php - 1.8.5 - 1.8.23

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 262Zeile 262
		$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")

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

			{

			{

				continue;

				continue;

			}


			}


			if(empty($stylesheet['attributes']['lastmodified']))

			if(empty($stylesheet['attributes']['lastmodified']))

			{

			{

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

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

			}

			}


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 304Zeile 306
			if(!$attachedto)
{
$attachedto = "global";

			if(!$attachedto)
{
$attachedto = "global";

			}

			}


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


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

Zeile 330Zeile 332
			"stylesheets" => $db->escape_string(my_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(my_serialize($properties));
}

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



















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

update_theme_stylesheet_list($theme_id);

	update_theme_stylesheet_list($theme_id);





// And done?
return $theme_id;


// And done?
return $theme_id;

Zeile 364Zeile 349
 * @return string Parsed string with variables replaced
*/
function parse_theme_variables($string, $variables=array())

 * @return string Parsed string with variables replaced
*/
function parse_theme_variables($string, $variables=array())

{

{

	$find = array();
$replace = array();
foreach(array_keys($variables) as $variable)

	$find = array();
$replace = array();
foreach(array_keys($variables) as $variable)

Zeile 388Zeile 373
{
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 410
		"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)

Zeile 468Zeile 458
	return $stylesheet;
}


	return $stylesheet;
}


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

function resync_stylesheet($stylesheet)
{
global $db;

function resync_stylesheet($stylesheet)
{
global $db;

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

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

	}

	}


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


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

Zeile 505Zeile 500
	return false;
}


	return false;
}


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

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

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

Zeile 517Zeile 518
	}
}


	}
}


 
/**
* @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 547Zeile 564
	$inherited_properties = false;
$stylesheets = array();
if($parent > 0)

	$inherited_properties = false;
$stylesheets = array();
if($parent > 0)

	{

	{

		$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 558Zeile 575
				foreach($parent_properties as $property => $value)
{
if($property == "inherited")

				foreach($parent_properties as $property => $value)
{
if($property == "inherited")

					{

					{

						continue;
}

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

						continue;
}

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

					{

					{

						$properties['inherited'][$property] = $parent_properties['inherited'][$property];
}
else

						$properties['inherited'][$property] = $parent_properties['inherited'][$property];
}
else

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

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

 
	
$updated_theme = array();

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

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

Zeile 649Zeile 668
	// Fetch out classes and comments
preg_match_all('#(\/\*(.|[\r\n])*?\*\/)?([a-z0-9a+\\\[\]\-\"=_:>\*\.\#\,\s\(\)\|~|@\^]+)(\s*)\{(.*?)\}\n#msi', $stripped_css, $matches, PREG_PATTERN_ORDER);
$total = count($matches[1]);

	// Fetch out classes and comments
preg_match_all('#(\/\*(.|[\r\n])*?\*\/)?([a-z0-9a+\\\[\]\-\"=_:>\*\.\#\,\s\(\)\|~|@\^]+)(\s*)\{(.*?)\}\n#msi', $stripped_css, $matches, PREG_PATTERN_ORDER);
$total = count($matches[1]);





	$parsed_css = array();

for($i=0; $i < $total; $i++)

	$parsed_css = array();

for($i=0; $i < $total; $i++)

Zeile 684Zeile 703
	}

return $parsed_css;

	}

return $parsed_css;

}

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







}

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

	$select = "";

if(!is_array($css))

	$select = "";

if(!is_array($css))

Zeile 722Zeile 747
	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'])

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

	{

	{

		$css = css_to_array($css);
}


		$css = css_to_array($css);
}


Zeile 807Zeile 844
	$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();

// Parse out the CSS

	$parsed_css = array();

// Parse out the CSS

Zeile 824Zeile 861
	}

if(!$class_id)

	}

if(!$class_id)

	{

	{

		$class_id = $parsed_css[$selector]['class_name'];
}


		$class_id = $parsed_css[$selector]['class_name'];
}


Zeile 852Zeile 889
		if(!$actual_occurance)
{
$actual_occurance = 1;

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

		}


		}


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

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

			{
break;
}

			{
break;
}

			if($occurance == $actual_occurance)
{
// This is the part we want to replace, now we need to fetch the opening & closing braces

			if($occurance == $actual_occurance)
{
// This is the part we want to replace, now we need to fetch the opening & closing braces

Zeile 880Zeile 917
	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 901Zeile 944
	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;

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

Zeile 1064Zeile 1114
	$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 1077Zeile 1127
	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 1091Zeile 1146
			{
continue;
}

			{
continue;
}





			$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]))
{
return false;
}


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


	reset($themes_by_parent);

	reset($themes_by_parent);

	reset($themes_by_parent[$tid]);

$themes = array();

	reset($themes_by_parent[$tid]);

$themes = array();


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


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

Zeile 1114Zeile 1169
		if(is_array($parents))
{
$themes = array_merge($themes, $parents);

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

		}
}

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 1152Zeile 1212
		$children = make_child_theme_list($theme['tid']);

if(is_array($children))

		$children = make_child_theme_list($theme['tid']);

if(is_array($children))

		{

		{

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

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





	return $themes;
}


	return $themes;
}


 
/**
* @return array
*/

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

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

Zeile 1189Zeile 1252
	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 1203Zeile 1270
		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'];
}


Zeile 1232Zeile 1299
	}

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 = new PopupMenu("theme_{$theme['tid']}", $lang->options);
if($theme['tid'] > 1)
{

Zeile 1270Zeile 1337

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


// Fetch & build any child themes
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 1318Zeile 1393
	}
}


	}
}


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

function fetch_theme_stylesheets($theme)
{
// Fetch list of all of the stylesheets for this theme
$file_stylesheets = my_unserialize($theme['stylesheets']);

if(!is_array($file_stylesheets))

function fetch_theme_stylesheets($theme)
{
// Fetch list of all of the stylesheets for this theme
$file_stylesheets = my_unserialize($theme['stylesheets']);

if(!is_array($file_stylesheets))

	{

	{

		return false;
}


		return false;
}


Zeile 1374Zeile 1454
	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);