Zeile 220 | Zeile 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 262 | Zeile 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 304 | Zeile 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 327 | Zeile 329 |
---|
} // 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}'"); }
update_theme_stylesheet_list($theme_id);
| update_theme_stylesheet_list($theme_id);
|
// And done? return $theme_id;
| // And done? return $theme_id;
|
Zeile 388 | Zeile 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 420 | Zeile 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 441 | Zeile 431 |
---|
@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 472 | Zeile 443 |
---|
* * @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
|
*/
| */
|
function minify_stylesheet($stylesheet) { // Remove comments.
| function minify_stylesheet($stylesheet) { // Remove comments.
|
Zeile 487 | Zeile 458 |
---|
return $stylesheet; }
|
return $stylesheet; }
|
| /** * @param array $stylesheet * * @return bool */
|
function resync_stylesheet($stylesheet) { global $db;
// Try and fix any missing cache file names if(!$stylesheet['cachefile'] && $stylesheet['name'])
|
function resync_stylesheet($stylesheet) { global $db;
// 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']}'"); }
| $stylesheet['cachefile'] = $stylesheet['name']; $db->update_query("themestylesheets", array('cachefile' => $db->escape_string($stylesheet['name'])), "sid='{$stylesheet['sid']}'"); }
|
Zeile 524 | Zeile 500 |
---|
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 569 | Zeile 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))
|
Zeile 632 | Zeile 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)) {
|
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 705 | Zeile 705 |
---|
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 741 | Zeile 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'])
|
{
| {
|
$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 832 | Zeile 850 |
---|
foreach($new_css as $css_line) { $generated_css .= "\t".trim($css_line)."\n";
|
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)
|
// Parse out the CSS if($css)
|
{
| {
|
$parsed_css = css_to_array($css); }
if(!$class_id) { $class_id = $parsed_css[$selector]['class_name'];
|
$parsed_css = css_to_array($css); }
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 866 | Zeile 884 |
---|
if($break !== false) { $actual_occurance = (int)substr($selector, ($break+1));
|
if($break !== false) { $actual_occurance = (int)substr($selector, ($break+1));
|
}
| }
|
if(!$actual_occurance) { $actual_occurance = 1;
| if(!$actual_occurance) { $actual_occurance = 1;
|
Zeile 897 | Zeile 915 |
---|
$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 920 | Zeile 944 |
---|
return $sid; }
|
return $sid; }
|
function update_theme_stylesheet_list($tid, $theme = false, $update_disporders = false)
| /** * @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 $db, $cache;
| global $mybb, $db, $cache, $plugins;
|
$stylesheets = array();
| $stylesheets = array();
|
Zeile 983 | Zeile 1014 |
---|
break; } }
|
break; } }
|
| } if(is_object($plugins)) { $plugins->run_hooks('update_theme_stylesheet_list_set_css_url', $css_url);
|
}
$attachedto = $stylesheet['attachedto']; if(!$attachedto)
|
}
$attachedto = $stylesheet['attachedto']; if(!$attachedto)
|
{
| {
|
$attachedto = "global"; } // private.php?compose,folders|usercp.php,global|global
| $attachedto = "global"; } // private.php?compose,folders|usercp.php,global|global
|
Zeile 996 | Zeile 1032 |
---|
{ $attached_actions = array(); if(strpos($attached_file, '?') !== false)
|
{ $attached_actions = array(); if(strpos($attached_file, '?') !== false)
|
{
| {
|
$attached_file = explode('?', $attached_file); $attached_actions = explode(",", $attached_file[1]); $attached_file = $attached_file[0];
| $attached_file = explode('?', $attached_file); $attached_actions = explode(",", $attached_file[1]); $attached_file = $attached_file[0];
|
Zeile 1021 | Zeile 1057 |
---|
// 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 1045 | Zeile 1081 |
---|
foreach($stylesheets as $stylesheet) {
|
foreach($stylesheets as $stylesheet) {
|
if(!$properties['disporder'][$stylesheet['name']])
| if(!isset($properties['disporder'][$stylesheet['name']]))
|
{ $orphaned_stylesheets[] = $stylesheet['name']; continue;
| { $orphaned_stylesheets[] = $stylesheet['name']; continue;
|
Zeile 1072 | Zeile 1108 |
---|
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 1091 | Zeile 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 1134 | Zeile 1175 |
---|
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 1150 | Zeile 1196 |
---|
}
$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])) { 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 1168 | Zeile 1214 |
---|
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;
|
|
|
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 1203 | Zeile 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 1287 | Zeile 1340 |
---|
} }
|
} }
|
// 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 1300 | Zeile 1361 |
---|
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;
|
if(!is_array($theme_cache[$parent]) || $ignoretid === $parent) { return null;
|
}
| }
|
foreach($theme_cache[$parent] as $theme) { if($ignoretid === $theme['tid'])
| foreach($theme_cache[$parent] as $theme) { if($ignoretid === $theme['tid'])
|
Zeile 1332 | Zeile 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 1351 | Zeile 1417 |
---|
if($file == 'inherited') { continue;
|
if($file == 'inherited') { continue;
|
}
| }
|
foreach($action_stylesheet as $action => $style) {
| foreach($action_stylesheet as $action => $style) {
|
Zeile 1388 | Zeile 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);
|