Exemplo n.º 1
0
 /**
  * Add a css file to the page
  * @since 4.0
  * @param string $file The path of the css file relative to the addon folder
  * @param bool $combine Set to false to keep the file from being combined with other css files
  */
 public static function css($file, $combine = true)
 {
     global $page;
     $file = \gp\tool::WinPath($file);
     if ($combine) {
         $page->css_admin[] = self::$current['code_folder_part'] . '/' . ltrim($file, '/');
         return self::$current['code_folder_part'] . '/' . ltrim($file, '/');
     }
     //less file
     $ext = \gp\tool::Ext($file);
     if ($ext === 'less' || $ext === 'scss') {
         $full_path = self::$current['code_folder_full'] . '/' . ltrim($file, '/');
         $path = \gp\tool\Output\Css::Cache($full_path, $ext);
     } else {
         $path = self::$current['code_folder_part'] . '/' . ltrim($file, '/');
     }
     if ($path !== false) {
         $page->head .= "\n" . '<link rel="stylesheet" type="text/css" href="' . \gp\tool::GetDir($path) . '"/>';
     }
     return $path;
 }
Exemplo n.º 2
0
 /**
  * Return a list of css files used by the current layout
  *
  */
 public static function LayoutStyleFiles()
 {
     global $page, $dataDir;
     $files = array();
     $dir = $page->theme_dir . '/' . $page->theme_color;
     $style_type = self::StyleType($dir);
     $custom_file = self::CustomStyleFile($page->gpLayout, $style_type);
     //css file
     if ($style_type == 'css') {
         $files[] = rawurldecode($page->theme_path) . '/style.css';
         if ($page->gpLayout && file_exists($custom_file)) {
             $files[] = \gp\tool\Output\Css::Cache($custom_file, 'less');
         }
         return $files;
     }
     //less or scss file
     $var_file = $dir . '/variables.' . $style_type;
     if (file_exists($var_file)) {
         $files[] = $var_file;
     }
     if ($page->gpLayout && file_exists($custom_file)) {
         $files[] = $custom_file;
     }
     if ($style_type == 'scss') {
         $files[] = $dir . '/style.scss';
         return array(\gp\tool\Output\Css::Cache($files));
     }
     array_unshift($files, $dir . '/style.less');
     return array(\gp\tool\Output\Css::Cache($files, 'less'));
 }
Exemplo n.º 3
0
 /**
  * Order of files for SCSS
  *  Variables.scss
  *  custom.scss
  *  Bootstrap.scss
  */
 protected function PreviewScss($dir)
 {
     global $langmessage;
     $style_files = array();
     // variables.scss
     $var_file = $dir . '/variables.scss';
     if (file_exists($var_file)) {
         $style_files[] = $var_file;
     }
     //custom
     $temp = trim($_REQUEST['css']);
     if (!empty($temp)) {
         $style_files[] = $_REQUEST['css'] . "\n";
         //make sure this is seen as code and not a filename
     }
     $style_files[] = $dir . '/style.scss';
     $compiled = \gp\tool\Output\Css::ParseScss($style_files);
     if ($compiled === false) {
         message($langmessage['OOPS'] . ' (Invalid SCSS)');
         return false;
     }
     $this->page->head .= '<style>' . $compiled . '</style>';
     $this->page->get_theme_css = false;
 }