Exemple #1
0
 /**
  * Return current category childs
  *
  * @param integer $lang_id Language ID
  * @param boolean $published return only active categories
  * @return array Categories
  */
 public function getSubCategories($lang_id, $published = true)
 {
     $sql_groups_where = '';
     $sql_groups_join = '';
     $db = JFactory::getDBO();
     if (JeproshopGroupModelGroup::isFeaturePublished()) {
         $sql_groups_join = " LEFT JOIN " . $db->quoteName('#__jeproshop_category_group') . " AS category_group ON (category_group." . $db->quoteName('category_id') . " = category." . $db->quoteName('category_id') . ")";
         $groups = JeproshopController::getCurrentCustomerGroups();
         $sql_groups_where = " AND category_group." . $db->quoteName('group_id') . " " . (count($groups) ? " IN (" . implode(',', $groups) . ")" : " = " . (int) JeproshopGroupModelGroup::getCurrent()->group_id);
     }
     $query = "SELECT category.*, category_lang.lang_id, category_lang.name, category_lang.description, category_lang.link_rewrite, category_lang.meta_title, category_lang.meta_keywords, ";
     $query .= " category_lang.meta_description FROM " . $db->quoteName('#__jeproshop_category') . " AS category " . JeproshopShopModelShop::addSqlAssociation('category') . " LEFT JOIN ";
     $query .= $db->quoteName('#__jeproshop_category_lang') . " AS category_lang ON (category." . $db->quoteName('category_id') . " = category_lang." . $db->quoteName('category_id');
     $query .= " AND " . $db->quoteName('lang_id') . " = " . (int) $lang_id . " " . JeproshopShopModelShop::addSqlRestrictionOnLang('category_lang') . ") " . $sql_groups_join;
     $query .= " WHERE " . $db->quoteName('parent_id') . " = " . (int) $this->category_id . ($published ? " AND " . $db->quoteName('published') . " = 1 " : "") . $sql_groups_where;
     $query .= "\tGROUP BY category." . $db->quoteName('category_id') . " ORDER BY " . $db->quoteName('depth_level') . " ASC, category_shop." . $db->quoteName('position') . " ASC";
     $db->setQuery($query);
     $result = $db->loadObjectList();
     foreach ($result as &$row) {
         $row->image_id = JeproshopTools::file_exists_cache(COM_JEPROSHOP_CATEGORY_IMAGE_DIRECTORY . $row->category_id . '.jpg') ? (int) $row->category_id : JeproshopLanguageModelLanguage::getIsoById($lang_id) . '_default';
         $row->legend = JText::_('COM_JEPROSHOP_NO_PICTURE_LABEL');
     }
     return $result;
 }
Exemple #2
0
 /**
  * Change language in cookie while clicking on a flag
  *
  * @param null $cookie
  * @return string iso code
  */
 public static function setCookieLanguage($cookie = null)
 {
     if (!$cookie) {
         $cookie = JeproshopContext::getContext()->cookie;
     }
     /* If language does not exist or is disabled, erase it */
     if ($cookie->lang_id) {
         $lang = new JeproshopLanguageModelLanguage((int) $cookie->lang_id);
         if (!JeproshopTools::isLoadedObject($lang, 'lang_id') || !$lang->published || !$lang->isAssociatedToShop()) {
             $cookie->lang_id = null;
         }
     }
     /* Automatically detect language if not already defined, detect_language is set in Cookie::update **/
     if ((!$cookie->lang_id || isset($cookie->detect_language)) && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
         $array = explode(',', strtolower($_SERVER['HTTP_ACCEPT_LANGUAGE']));
         $string = $array[0];
         if (JeproshopTools::isLanguageCode($string)) {
             $lang = JeproshopLanguageModelLanguage::getLanguageByIETFCode($string);
             if (JeproshopTools::isLoadedObject($lang, 'lang_id') && $lang->published && $lang->isAssociatedToShop()) {
                 JeproshopContext::getContext()->language = $lang;
                 $cookie->lang_id = (int) $lang->lang_id;
             }
         }
     }
     if (isset($cookie->detect_language)) {
         unset($cookie->detect_language);
     }
     /* If language file not present, you must use default language file **/
     if (!$cookie->lang_id || !JeproshopTools::isUnsignedInt($cookie->lang_id)) {
         $cookie->lang_id = (int) JeproshopSettingModelSetting::getValue('default_lang');
     }
     $iso = JeproshopLanguageModelLanguage::getIsoById((int) $cookie->lang_id);
     //@include_once(_PS_THEME_DIR_.'lang/'.$iso.'.php');
     return $iso;
 }
Exemple #3
0
 public static function defineProductImage($row, $lang_id)
 {
     if (isset($row->image_id) && $row->image_id) {
         return $row->product_id . '_' . $row->image_id;
     }
     return JeproshopLanguageModelLanguage::getIsoById((int) $lang_id) . '_default';
 }