Vergleich admin/inc/functions_themes.php - 1.8.7 - 1.8.25

  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 511Zeile 501
}

/**

}

/**

 
 * @deprecated

 * @param string $url
*
* @return string

 * @param string $url
*
* @return string

Zeile 528Zeile 519
}

/**

}

/**

 
 * @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)

 * @param string $url
*
* @return string
*/
function unfix_css_urls($url)

{

{

	return str_replace("../../../", "", $url);
}


	return str_replace("../../../", "", $url);
}


Zeile 548Zeile 550
function build_new_theme($name, $properties=null, $parent=1)
{
global $db;

function build_new_theme($name, $properties=null, $parent=1)
{
global $db;





	$new_theme = array(
"name" => $db->escape_string($name),
"pid" => (int)$parent,

	$new_theme = array(
"name" => $db->escape_string($name),
"pid" => (int)$parent,

Zeile 565Zeile 567
	{
$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))

			{

			{

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

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

					{

					{

						continue;

						continue;

					}

					}


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


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

					{

					{

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

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

					}

					}

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

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

					}
}

					}
}

				$inherited_properties = true;
}
}

				$inherited_properties = true;
}
}

Zeile 628Zeile 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 710Zeile 714
function get_selectors_as_options($css, $selected_item=null)
{
$select = "";

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

Zeile 1110Zeile 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 1161Zeile 1165
	{
$themes[] = $theme['tid'];
$parents = make_parent_theme_list($theme['pid']);

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


	return $themes;
}


Zeile 1179Zeile 1183
function make_child_theme_list($tid)
{
static $themes_by_child;

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 1193Zeile 1197

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


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

	}

	}


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


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

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

			}

			}

		}
}


		}
}


Zeile 1309Zeile 1313

// We must have at least the master and 1 other active theme
if($theme_cache['num_themes'] > 2)


// 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&action=delete&tid={$theme['tid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_deletion}')");
}


				$popup->add_item($lang->delete_theme, "index.php?module=style-themes&action=delete&tid={$theme['tid']}&my_post_key={$mybb->post_code}", "return AdminCP.deleteConfirmation(this, '{$lang->confirm_theme_deletion}')");
}


Zeile 1346Zeile 1350
 * @return null|string
*/
function build_theme_array($ignoretid = null, $parent=0, $depth=0)

 * @return null|string
*/
function build_theme_array($ignoretid = null, $parent=0, $depth=0)

{

{

	global $list;
static $theme_cache;


	global $list;
static $theme_cache;


Zeile 1364Zeile 1368
			$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 null;

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

Zeile 1457Zeile 1461
 */
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);