Exemple #1
0
 /**
  * Get all scenes of a category
  *
  * @param $category_id
  * @param null $lang_id
  * @param bool $only_published
  * @param bool $lite_result
  * @param bool $hide_scene_position
  * @param JeproshopContext $context
  * @return array Products
  */
 public static function getScenes($category_id, $lang_id = null, $only_published = true, $lite_result = true, $hide_scene_position = true, JeproshopContext $context = null)
 {
     if (!JeproshopSceneModelScene::isFeaturePublished()) {
         return array();
     }
     $cache_key = 'jeproshop_scene_get_scenes_' . $category_id . '_' . (int) $lite_result;
     if (!JeproshopCache::isStored($cache_key)) {
         if (!$context) {
             $context = JeproshopContext::getContext();
         }
         $lang_id = is_null($lang_id) ? $context->language->lang_id : $lang_id;
         $db = JFactory::getDBO();
         $query = "SELECT scene.* FROM " . $db->quoteName('#__jeproshop_scene_category') . " scene_category LEFT JOIN " . $db->quoteName('#__jeproshop_scene');
         $query .= " AS scene ON (scene_category.scene_id = scene.scene_id) " . JeproshopShopModelShop::addSqlAssociation('scene') . " LEFT JOIN ";
         $query .= $db->quoteName('#__jeproshop_scene_lang') . " AS scene_lang ON (scene_lang.scene_id = scene.scene_id) WHERE scene_category.category_id = ";
         $query .= (int) $category_id . "\tAND scene_lang.lang_id = " . (int) $lang_id . ($only_published ? " AND scene.published = 1" : "") . " ORDER BY scene_lang.name ASC";
         $db->setQuery($query);
         $scenes = $db->loadObjectList();
         if (!$lite_result && $scenes) {
             foreach ($scenes as &$scene) {
                 $scene = new Scene($scene->scene_id, $lang_id, false, $hide_scene_position);
             }
         }
         JeproshopCache::store($cache_key, $scenes);
     }
     $scenes = JeproshopCache::retrieve($cache_key);
     return $scenes;
 }
Exemple #2
0
 /**
  * Assign scenes template vars
  */
 protected function assignScenes()
 {
     // Scenes (could be externalised to another controller if you need them)
     $scenes = JeproshopSceneModelScene::getScenes($this->category->category_id, $this->context->language->lang_id, true, false);
     $this->assignRef('scenes', $scenes);
     // Scenes images formats
     if ($scenes && ($sceneImageTypes = JeproshopImageTypeModelImageType::getImagesTypes('scenes'))) {
         foreach ($sceneImageTypes as $sceneImageType) {
             if ($sceneImageType->name == JeproshopImageTypeModelImageType::getFormatedName('m_scene')) {
                 $thumbSceneImageType = $sceneImageType;
             } elseif ($sceneImageType->name == JeproshopImageTypeModelImageType::getFormatedName('scene')) {
                 $largeSceneImageType = $sceneImageType;
             }
         }
         $this->assignRef('thumbSceneImageType', isset($thumbSceneImageType) ? $thumbSceneImageType : null);
         $this->assignRef('largeSceneImageType', isset($largeSceneImageType) ? $largeSceneImageType : null);
     }
 }