Vergleich admin/inc/functions_themes.php - 1.8.2 - 1.8.6

  Keine Änderungen   Hinzugefügt   Modifiziert   Entfernt
Zeile 220Zeile 220
	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 327Zeile 327
		}
// 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']))

		);

if(is_array($properties['disporder']))

Zeile 344Zeile 344
			}

$properties['disporder'] = $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='{$theme_id}'");

		}

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

Zeile 441Zeile 441
	@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}";
}


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

Zeile 487Zeile 468
	return $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'])

	{

	{

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

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

	{

	{

		return false;
}


		return false;
}


Zeile 524Zeile 510
	return false;
}


	return false;
}


 
/**
* @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 536Zeile 527
	}
}


	}
}


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

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

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

Zeile 634Zeile 630
	}
if(!empty($stylesheets))
{

	}
if(!empty($stylesheets))
{

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

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

	}

	}

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

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


if(count($updated_theme) > 0)
{


if(count($updated_theme) > 0)
{

Zeile 705Zeile 701
	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 = "";


{
$select = "";


Zeile 741Zeile 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'])
{
$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']);

}








}

/**
* @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 778Zeile 792
function parse_css_properties($values)
{
$css_bits = array();

function parse_css_properties($values)
{
$css_bits = array();





	if(!$values)
{
return null;

	if(!$values)
{
return null;

Zeile 802Zeile 816
			case "font-style":
case "text-decoration":
$css_bits[$property] = trim($css_value);

			case "font-style":
case "text-decoration":
$css_bits[$property] = trim($css_value);

				break;

				break;

			default:
$css_bits['extra'] .= "{$property}: ".trim($css_value).";\n";


			default:
$css_bits['extra'] .= "{$property}: ".trim($css_value).";\n";


Zeile 845Zeile 859
	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 860Zeile 874
		$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)

Zeile 899Zeile 913
	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 918Zeile 938
	$sid = $db->insert_query("themestylesheets", $new_stylesheet);

return $sid;

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

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;

$stylesheets = array();

	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 932Zeile 959
	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", "*", "tid IN ({$tid_list})", array('order_by' => 'tid', 'order_dir' => 'desc'));


// Get our list of stylesheets
$query = $db->simple_select("themestylesheets", "*", "tid IN ({$tid_list})", array('order_by' => 'tid', 'order_dir' => 'desc'));

Zeile 948Zeile 975
			}

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

			}

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

		}
}

		}
}


$theme_stylesheets = array();



$theme_stylesheets = array();


Zeile 978Zeile 1005
						MYBB_ROOT."cache/themes/theme{$theme_id}/{$stylesheet['name']}"
) >= $stylesheet['lastmodified']
)

						MYBB_ROOT."cache/themes/theme{$theme_id}/{$stylesheet['name']}"
) >= $stylesheet['lastmodified']
)

				{

				{

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

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

 
		}

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

		}

$attachedto = $stylesheet['attachedto'];

		}

$attachedto = $stylesheet['attachedto'];

Zeile 993Zeile 1025
		// 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)

		{

		{

			$attached_actions = array();
if(strpos($attached_file, '?') !== false)
{

			$attached_actions = array();
if(strpos($attached_file, '?') !== false)
{

Zeile 1021Zeile 1053

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

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

Zeile 1032Zeile 1064
			$theme_cache = cache_themes();
$theme = $theme_cache[$tid];
}

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





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

if(!is_array($properties))

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

if(!is_array($properties))

		{

		{

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


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


Zeile 1052Zeile 1084
			}

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

			}

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

			{

			{

				$max_disporder = $properties['disporder'][$stylesheet['name']];
}


				$max_disporder = $properties['disporder'][$stylesheet['name']];
}


Zeile 1072Zeile 1104

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

	}

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

Zeile 1091Zeile 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 1111Zeile 1148
	}

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

	}

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

	{

	{

		return false;
}


		return false;
}


Zeile 1134Zeile 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 1154Zeile 1196
	}

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

	}

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

	{

	{

		return null;

		return null;

	}

$themes = array();

	}

$themes = array();


foreach($themes_by_child[$tid] as $theme)
{


foreach($themes_by_child[$tid] as $theme)
{

Zeile 1168Zeile 1210
		if(is_array($children))
{
$themes = array_merge($themes, $children);

		if(is_array($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 1198Zeile 1243
	if(empty($theme_cache['default']))
{
$theme_cache['default'] = 1;

	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 1270Zeile 1319
				$set_default = "<a href=\"index.php?module=style-themes&amp;action=set_default&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}\"><img src=\"styles/{$page->style}/images/icons/make_default.png\" alt=\"{$lang->set_as_default}\" style=\"vertical-align: middle;\" title=\"{$lang->set_as_default}\" /></a>";
}
else

				$set_default = "<a href=\"index.php?module=style-themes&amp;action=set_default&amp;tid={$theme['tid']}&amp;my_post_key={$mybb->post_code}\"><img src=\"styles/{$page->style}/images/icons/make_default.png\" alt=\"{$lang->set_as_default}\" style=\"vertical-align: middle;\" title=\"{$lang->set_as_default}\" /></a>";
}
else

			{

			{

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

Zeile 1284Zeile 1333

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

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

			{

			{

				continue;
}

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

				continue;
}

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

	}


	}


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

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

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

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

	{

	{

		if($ignoretid === $theme['tid'])
{
continue;

		if($ignoretid === $theme['tid'])
{
continue;

Zeile 1329Zeile 1386
	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 1344Zeile 1406

$stylesheets = array();
$inherited_load = array();


$stylesheets = array();
$inherited_load = array();





	// Now we loop through the list of stylesheets for each file
foreach($file_stylesheets as $file => $action_stylesheet)
{

	// Now we loop through the list of stylesheets for each file
foreach($file_stylesheets as $file => $action_stylesheet)
{

Zeile 1388Zeile 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