You are here

function tb_megamenu_add_css in The Better Mega Menu 7

2 calls to tb_megamenu_add_css()
tb_megamenu_block_view in ./tb_megamenu.module
tb_megamenu_configure_form in ./tb_megamenu.admin.inc

File

./tb_megamenu.functions.inc, line 36

Code

function tb_megamenu_add_css($file) {
  $path_info = pathinfo($file);
  if ($path_info['extension'] == 'less') {
    $uri = "public://tb_megamenu";
    if (!is_dir($uri)) {
      mkdir($uri, 0777);
    }
    $css_uri = "public://tb_megamenu/css";
    if (!is_dir($css_uri)) {
      mkdir($css_uri, 0777);
    }
    if (!class_exists('lessc')) {
      include_once drupal_get_path('module', 'tb_megamenu') . '/includes/lessphp/lessc.inc.php';
    }
    $less = new lessc();
    $output = $less
      ->compileFile($file);
    file_put_contents($css_uri . "/" . $path_info['filename'] . ".css", $output);
    drupal_add_css($css_uri . "/" . $path_info['filename'] . ".css", array(
      'group' => CSS_DEFAULT,
      'basename' => 'tb-megamenu-' . $path_info['filename'] . ".css",
    ));
  }
  else {
    drupal_add_css($file, array(
      'group' => CSS_DEFAULT,
      'basename' => 'tb-megamenu-' . $path_info['basename'],
    ));
  }
}