/**
  * Add one or several CSS for front, checking if css files are overriden in theme/css/modules/ directory
  *
  * @see Controller::addCSS()
  */
 public function addCSS($css_uri, $css_media_type = 'all')
 {
     if (!is_array($css_uri)) {
         $css_uri = array($css_uri => $css_media_type);
     }
     $list_uri = array();
     foreach ($css_uri as $file => $media) {
         $different = 0;
         $override_path = str_replace(__PS_BASE_URI__ . 'modules/', _PS_ROOT_DIR_ . '/themes/' . _THEME_NAME_ . '/css/modules/', $file, $different);
         if ($different && file_exists($override_path)) {
             $file = str_replace(__PS_BASE_URI__ . 'modules/', __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/css/modules/', $file, $different);
         }
         $list_uri[$file] = $media;
     }
     return parent::addCSS($list_uri, $css_media_type);
 }
 public function addMedia($media_uri, $css_media_type = null, $offset = null, $remove = false)
 {
     if (!is_array($media_uri)) {
         if ($css_media_type) {
             $media_uri = array($media_uri => $css_media_type);
         } else {
             $media_uri = array($media_uri);
         }
     }
     $list_uri = array();
     foreach ($media_uri as $file => $media) {
         if (!preg_match('/^http(s?):\\/\\//i', $media)) {
             $different = 0;
             $different_css = 0;
             $type = 'css';
             if (!$css_media_type) {
                 $type = 'js';
                 $file = $media;
             }
             $override_path = str_replace(__PS_BASE_URI__ . 'modules/', _PS_ROOT_DIR_ . '/themes/' . _THEME_NAME_ . '/' . $type . '/modules/', $file, $different);
             $override_path_css = str_replace(basename($file), $type . '/' . basename($file), str_replace(__PS_BASE_URI__, _PS_ROOT_DIR_ . '/', $file), $different_css);
             if ($different && file_exists($override_path)) {
                 $file = str_replace(__PS_BASE_URI__ . 'modules/', __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/' . $type . '/modules/', $file, $different);
             } elseif ($different_css && file_exists($override_path_css)) {
                 $file = $override_path_css;
             }
             if ($css_media_type) {
                 $list_uri[$file] = $media;
             } else {
                 $list_uri[] = $file;
             }
         } else {
             $list_uri[$file] = $media;
         }
     }
     if ($remove) {
         if ($css_media_type) {
             return parent::removeCSS($list_uri, $css_media_type);
         }
         return parent::removeJS($list_uri);
     }
     if ($css_media_type) {
         return parent::addCSS($list_uri, $css_media_type, $offset);
     }
     return parent::addJS($list_uri);
 }
 /**
  * Adds a media file(s) (CSS, JS) to page header
  *
  * @param string|array $media_uri Path to file, or an array of paths like: array(array(uri => media_type), ...)
  * @param string|null $css_media_type CSS media type
  * @param int|null $offset
  * @param bool $remove If True, removes media files
  * @param bool $check_path If true, checks if files exists
  * @return true|void
  */
 public function addMedia($media_uri, $css_media_type = null, $offset = null, $remove = false, $check_path = true)
 {
     if (!is_array($media_uri)) {
         if ($css_media_type) {
             $media_uri = array($media_uri => $css_media_type);
         } else {
             $media_uri = array($media_uri);
         }
     }
     $list_uri = array();
     foreach ($media_uri as $file => $media) {
         if (!Validate::isAbsoluteUrl($media)) {
             $different = 0;
             $different_css = 0;
             $type = 'css';
             if (!$css_media_type) {
                 $type = 'js';
                 $file = $media;
             }
             if (strpos($file, __PS_BASE_URI__ . 'modules/') === 0) {
                 $override_path = str_replace(__PS_BASE_URI__ . 'modules/', _PS_ROOT_DIR_ . '/themes/' . _THEME_NAME_ . '/' . $type . '/modules/', $file, $different);
                 if (strrpos($override_path, $type . '/' . basename($file)) !== false) {
                     $override_path_css = str_replace($type . '/' . basename($file), basename($file), $override_path, $different_css);
                 }
                 if ($different && @filemtime($override_path)) {
                     $file = str_replace(__PS_BASE_URI__ . 'modules/', __PS_BASE_URI__ . 'themes/' . _THEME_NAME_ . '/' . $type . '/modules/', $file, $different);
                 } elseif ($different_css && @filemtime($override_path_css)) {
                     $file = $override_path_css;
                 }
                 if ($css_media_type) {
                     $list_uri[$file] = $media;
                 } else {
                     $list_uri[] = $file;
                 }
             } else {
                 $list_uri[$file] = $media;
             }
         } else {
             $list_uri[$file] = $media;
         }
     }
     if ($remove) {
         if ($css_media_type) {
             return parent::removeCSS($list_uri, $css_media_type);
         }
         return parent::removeJS($list_uri);
     }
     if ($css_media_type) {
         return parent::addCSS($list_uri, $css_media_type, $offset, $check_path);
     }
     return parent::addJS($list_uri, $check_path);
 }