Esempio n. 1
0
 public function action_related()
 {
     $request = $this->request->current();
     $limit = $request->query('limit');
     if (empty($limit)) {
         $limit = $this->default_limit;
     }
     $exclude = $request->query('exclude');
     $category = (int) $request->query('category');
     $orm_helper = ORM_Helper::factory('catalog_Element');
     $helper_property = $orm_helper->property_helper();
     $orm = $orm_helper->orm();
     if (!empty($exclude)) {
         $orm->where('id', 'NOT IN', $exclude);
     }
     if (!empty($category)) {
         $orm->where('category_id', '=', $category);
     }
     $db_list = $orm->order_by(DB::expr('RAND()'))->limit($limit)->find_all();
     $keys = $db_list->as_array(NULL, 'id');
     $list = $db_list->as_array();
     $catalog_category = new Catalog_Category();
     $list_categories = $catalog_category->get_list();
     $this->template = View_Theme::factory('widgets/template/catalog/related', array('list' => $list, 'list_categories' => $list_categories));
 }
Esempio n. 2
0
 public function delete()
 {
     if ($this->show->itemID) {
         $Br = new Catalog_Category();
         if ($Br->isEmptyBrand($this->show->itemID)) {
             $oBrand = new Catalog_Brand();
             $oBrand->delete($this->show->itemID);
         }
     }
     redirect(BASE_PATH . 'admin/catalog/brand');
 }
Esempio n. 3
0
 public function delete()
 {
     if ($this->show->itemID) {
         $Cat = new Catalog();
         $prop = new Catalog_Property();
         if ($Cat->isEmptyCategory($this->show->itemID) && $prop->isEmptyProperty($this->show->itemID)) {
             $oCategory = new Catalog_Category();
             $oCategory->delete($this->show->itemID);
         }
     }
     redirect(BASE_PATH . 'admin/catalog/category');
 }
Esempio n. 4
0
 public function index()
 {
     $oProperty = new Catalog_Property();
     $oCategory = new Catalog_Category();
     if (isset($_COOKIE['categoryID'])) {
         $this->show->categoryID = $_COOKIE['categoryID'];
     } else {
         $this->show->categoryID = $oCategory->getFirstCategory();
         setcookie('categoryID', $this->show->categoryID, null, '/');
     }
     $this->show->itemList = $oProperty->getList($this->show->categoryID);
     $this->show->categoryList = $oCategory->getList(-1);
 }
Esempio n. 5
0
File: Page.php Progetto: kizz66/meat
 public function index()
 {
     if ($this->show->indexPage) {
         $oNewsPage = new Page();
         $oNewsPage->loadByID($this->show->Page);
         $this->show->Content = $oNewsPage->Content;
         $brand = new Catalog_Brand();
         $sub = new Catalog_Category();
         $this->show->subbrand = new object();
         $this->show->categorylist = $sub->getList(-1);
         $this->show->brand = $brand->getList();
         foreach ($this->show->brand as $item) {
             $this->show->subbrand[$item['Title']] = $sub->getList($item['BrandID']);
         }
         $this->show->sliders = Slider::getSlides();
     }
 }
Esempio n. 6
0
 public function edit()
 {
     $oCatalog = new Catalog();
     $prop = new Catalog_Property();
     if ($this->show->itemID) {
         $row = $oCatalog->getById($this->show->itemID);
         $this->show->categoryID = $row['CategoryID'];
         $this->show->propertyID = $row['PropertyID'];
     } else {
         $this->show->brandID = $this->post['BrandID'];
         $this->show->categoryID = $this->post['CategoryID'];
     }
     $this->show->propertyList = $prop->getList($this->show->categoryID);
     setcookie("brandID", $this->show->brandID, null, '/');
     $this->show->status = $oCatalog->getStatusList();
     if (!empty($this->post['Save'])) {
         if ($this->show->itemID) {
             $oCatalogID = $oCatalog->update($this->post, $this->show->itemID);
         } else {
             $oCatalogID = $oCatalog->insert($this->post);
         }
         if ($oCatalogID) {
             redirect(BASE_PATH . 'admin/catalog/');
         }
     }
     if ($this->show->itemID) {
         $this->show->item = $oCatalog->getByID($this->show->itemID);
         $this->show->breadcrumbs[] = array('url' => BASE_PATH . 'admin/catalog/' . $this->show->itemID, 'title' => $this->show->item['Title']);
     } else {
         $this->show->item = $oCatalog->get();
         $this->show->breadcrumbs[] = array('url' => BASE_PATH . 'admin/catalog/' . $this->show->itemID, 'title' => 'Создание');
         $oCategory = new Catalog_Category();
         $this->show->categoryList = $oCategory->getList($this->show->brandID);
         $oBrand = new Catalog_Brand();
         $this->show->brandList = $oBrand->getList();
     }
     if (!empty($this->post['Save'])) {
         $this->show->item->merge($this->post);
     }
 }
Esempio n. 7
0
 private function _get_category($id)
 {
     $result = NULL;
     $catalog_category = new Catalog_Category();
     $path = $catalog_category->get_path($id);
     $list = array();
     $category_uri = URL::base() . Page_Route::uri($this->page_id, 'catalog');
     do {
         $result = current($path);
         $category_uri .= '/' . $result->uri;
         $this->breadcrumbs[] = array('title' => $result->title, 'link' => $category_uri);
     } while (next($path));
     return $result;
 }