Example #1
0
 /**
  * Returns a string containing the value that should be used for the theme_data column in the theme database table.
  * Includes contents of files loaded via @import
  *
  * @param array $theme_row is an associative array containing the theme's current database entry
  * @param mixed $stylesheet can either be the new content for the stylesheet or false to load from the standard file
  * @param string $root_path should only be used in case you want to use a different root path than "{$phpbb_root_path}styles/{$theme_row['theme_path']}"
  *
  * @return string Stylesheet data for theme_data column in the theme table
  */
 function db_theme_data($theme_row, $stylesheet = false, $root_path = '')
 {
     global $phpbb_root_path;
     if (!$root_path) {
         $root_path = $phpbb_root_path . 'styles/' . $theme_row['theme_path'];
     }
     if (!$stylesheet) {
         $stylesheet = '';
         if (file_exists($root_path . '/theme/stylesheet.css')) {
             $stylesheet = file_get_contents($root_path . '/theme/stylesheet.css');
         }
     }
     // Match CSS imports
     $matches = array();
     preg_match_all('/@import url\\(["\'](.*)["\']\\);/i', $stylesheet, $matches);
     if (sizeof($matches)) {
         foreach ($matches[0] as $idx => $match) {
             $stylesheet = str_replace($match, acp_styles::load_css_file($theme_row['theme_path'], $matches[1][$idx]), $stylesheet);
         }
     }
     // adjust paths
     return str_replace('./', 'styles/' . $theme_row['theme_path'] . '/theme/', $stylesheet);
 }
Example #2
0
 /**
  * Returns a string containing the value that should be used for the theme_data column in the theme database table.
  * Includes contents of files loaded via @import
  *
  * @param array $theme_row is an associative array containing the theme's current database entry
  * @param mixed $stylesheet can either be the new content for the stylesheet or false to load from the standard file
  * @param string $root_path should only be used in case you want to use a different root path than "{$phpbb_root_path}styles/{$theme_row['theme_path']}"
  *
  * @return string Stylesheet data for theme_data column in the theme table
  */
 function db_theme_data($theme_row, $stylesheet = false, $root_path = '')
 {
     global $phpbb_root_path;
     if (!$root_path) {
         $root_path = $phpbb_root_path . 'styles/' . $theme_row['theme_path'];
     }
     if (!$stylesheet) {
         $stylesheet = '';
         if (file_exists($root_path . '/theme/stylesheet.css')) {
             $stylesheet = file_get_contents($root_path . '/theme/stylesheet.css');
         }
     }
     // Match CSS imports
     $matches = array();
     preg_match_all('/@import url\\((["\'])(.*)\\1\\);/i', $stylesheet, $matches);
     // remove commented stylesheets (very simple parser, allows only whitespace
     // around an @import statement)
     preg_match_all('#/\\*\\s*@import url\\((["\'])(.*)\\1\\);\\s\\*/#i', $stylesheet, $commented);
     $matches[2] = array_diff($matches[2], $commented[2]);
     if (sizeof($matches)) {
         foreach ($matches[0] as $idx => $match) {
             if (isset($matches[2][$idx])) {
                 $stylesheet = str_replace($match, acp_styles::load_css_file($theme_row['theme_path'], $matches[2][$idx]), $stylesheet);
             }
         }
     }
     // adjust paths
     return str_replace('./', 'styles/' . $theme_row['theme_path'] . '/theme/', $stylesheet);
 }