/**
  * return jqueryUI component path.
  *
  * @param mixed $component
  * @return string
  */
 public static function getJqueryUIPath($component, $theme, $check_dependencies)
 {
     $ui_path = array('js' => array(), 'css' => array());
     $folder = _PS_JS_DIR_ . 'jquery/ui/';
     $file = 'jquery.' . $component . '.min.js';
     $url_data = parse_url($folder . $file);
     $file_uri = _PS_ROOT_DIR_ . Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']);
     $file_uri_host_mode = _PS_CORE_DIR_ . Tools::str_replace_once(__PS_BASE_URI__, DIRECTORY_SEPARATOR, $url_data['path']);
     $ui_tmp = array();
     if (isset(Media::$jquery_ui_dependencies[$component]) && Media::$jquery_ui_dependencies[$component]['theme'] && $check_dependencies) {
         $theme_css = Media::getCSSPath($folder . 'themes/' . $theme . '/jquery.ui.theme.css');
         $comp_css = Media::getCSSPath($folder . 'themes/' . $theme . '/jquery.' . $component . '.css');
         if (!empty($theme_css) || $theme_css) {
             $ui_path['css'] = array_merge($ui_path['css'], $theme_css);
         }
         if (!empty($comp_css) || $comp_css) {
             $ui_path['css'] = array_merge($ui_path['css'], $comp_css);
         }
     }
     if ($check_dependencies && array_key_exists($component, self::$jquery_ui_dependencies)) {
         foreach (self::$jquery_ui_dependencies[$component]['dependencies'] as $dependency) {
             $ui_tmp[] = Media::getJqueryUIPath($dependency, $theme, false);
             if (self::$jquery_ui_dependencies[$dependency]['theme']) {
                 $dep_css = Media::getCSSPath($folder . 'themes/' . $theme . '/jquery.' . $dependency . '.css');
             }
             if (isset($dep_css) && (!empty($dep_css) || $dep_css)) {
                 $ui_path['css'] = array_merge($ui_path['css'], $dep_css);
             }
         }
     }
     if (@filemtime($file_uri) || defined('_PS_HOST_MODE_') && @filemtime($file_uri_host_mode)) {
         if (!empty($ui_tmp)) {
             foreach ($ui_tmp as $ui) {
                 if (!empty($ui['js'])) {
                     $ui_path['js'][] = $ui['js'];
                 }
                 if (!empty($ui['css'])) {
                     $ui_path['css'][] = $ui['css'];
                 }
             }
             $ui_path['js'][] = Media::getJSPath($folder . $file);
         } else {
             $ui_path['js'] = Media::getJSPath($folder . $file);
         }
     }
     //add i18n file for datepicker
     if ($component == 'ui.datepicker') {
         if (!is_array($ui_path['js'])) {
             $ui_path['js'] = array($ui_path['js']);
         }
         $ui_path['js'][] = Media::getJSPath($folder . 'i18n/jquery.ui.datepicker-' . Context::getContext()->language->iso_code . '.js');
     }
     return $ui_path;
 }
 /**
  * Add a new javascript file in page header.
  *
  * @param mixed $js_uri
  * @return void
  */
 public function addJqueryUI($component, $theme = 'base', $check_dependencies = true)
 {
     $ui_path = array();
     if (!is_array($component)) {
         $component = array($component);
     }
     foreach ($component as $ui) {
         $ui_path = Media::getJqueryUIPath($ui, $theme, $check_dependencies);
         $this->addCSS($ui_path['css']);
         $this->addJS($ui_path['js']);
     }
 }
Beispiel #3
0
 public function displayAccount()
 {
     if (!isset($this->context->cookie->stats_date_from)) {
         $this->context->cookie->stats_date_from = date('Y-m-01');
     }
     if (!isset($this->context->cookie->stats_date_to)) {
         $this->context->cookie->stats_date_to = date('Y-m-t');
     }
     Referrer::refreshCache(array(array('id_referrer' => (int) $this->context->cookie->tracking_id)));
     $referrer = new Referrer((int) $this->context->cookie->tracking_id);
     $this->smarty->assign('referrer', $referrer);
     $this->smarty->assign('datepickerFrom', $this->context->cookie->stats_date_from);
     $this->smarty->assign('datepickerTo', $this->context->cookie->stats_date_to);
     $display_tab = array('uniqs' => $this->l('Unique visitors'), 'visitors' => $this->l('Visitors'), 'visits' => $this->l('Visits'), 'pages' => $this->l('Pages viewed'), 'registrations' => $this->l('Registrations'), 'orders' => $this->l('Orders'), 'base_fee' => $this->l('Base fee'), 'percent_fee' => $this->l('Percent fee'), 'click_fee' => $this->l('Click fee'), 'sales' => $this->l('Sales'), 'cart' => $this->l('Average cart'), 'reg_rate' => $this->l('Registration rate'), 'order_rate' => $this->l('Order rate'));
     $this->smarty->assign('displayTab', $display_tab);
     $products = Product::getSimpleProducts($this->context->language->id);
     $products_array = array();
     foreach ($products as $product) {
         $products_array[] = $product['id_product'];
     }
     $js_files = array();
     $jquery_files = Media::getJqueryPath();
     if (is_array($jquery_files)) {
         $js_files = array_merge($js_files, $jquery_files);
     } else {
         $js_files[] = $jquery_files;
     }
     $jquery_ui_files = Media::getJqueryUIPath('ui.datepicker', 'base', true);
     $js_files = array_merge($js_files, $jquery_ui_files['js']);
     $css_files = $jquery_ui_files['css'];
     $js_files[] = $this->_path . 'js/trackingfront.js';
     $js_tpl_var = array('product_ids' => implode(', ', $products_array), 'referrer_id' => $referrer->id, 'token' => $this->context->cookie->tracking_passwd, 'display_tab' => implode('", "', array_keys($display_tab)));
     $this->smarty->assign(array('js' => $js_files, 'css' => $css_files, 'js_tpl_var' => $js_tpl_var));
     return $this->display(__FILE__, 'views/templates/front/account.tpl');
 }