shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

theme.php (1599B)


      1 <?php
      2 class ModelDesignTheme extends Model {
      3 	public function editTheme($store_id, $theme, $route, $code) {
      4 		$this->db->query("DELETE FROM `" . DB_PREFIX . "theme` WHERE store_id = '" . (int)$store_id . "' AND theme = '" . $this->db->escape($theme) . "' AND route = '" . $this->db->escape($route) . "'");
      5 		
      6 		$this->db->query("INSERT INTO `" . DB_PREFIX . "theme` SET store_id = '" . (int)$store_id . "', theme = '" . $this->db->escape($theme) . "', route = '" . $this->db->escape($route) . "', code = '" . $this->db->escape($code) . "', date_added = NOW()");
      7 	}
      8 
      9 	public function deleteTheme($theme_id) {
     10 		$this->db->query("DELETE FROM `" . DB_PREFIX . "theme` WHERE theme_id = '" . (int)$theme_id . "'");
     11 	}
     12 
     13 	public function getTheme($store_id, $theme, $route) {
     14 		$query = $this->db->query("SELECT * FROM `" . DB_PREFIX . "theme` WHERE store_id = '" . (int)$store_id . "' AND theme = '" . $this->db->escape($theme) . "' AND route = '" . $this->db->escape($route) . "'");
     15 
     16 		return $query->row;
     17 	}
     18 	
     19 	public function getThemes($start = 0, $limit = 10) {
     20 		if ($start < 0) {
     21 			$start = 0;
     22 		}
     23 
     24 		if ($limit < 1) {
     25 			$limit = 10;
     26 		}		
     27 		
     28 		$query = $this->db->query("SELECT *, (SELECT name FROM `" . DB_PREFIX . "store` s WHERE s.store_id = t.store_id) AS store FROM `" . DB_PREFIX . "theme` t ORDER BY t.date_added DESC LIMIT " . (int)$start . "," . (int)$limit);
     29 
     30 		return $query->rows;
     31 	}	
     32 	
     33 	public function getTotalThemes() {
     34 		$query = $this->db->query("SELECT COUNT(*) AS total FROM `" . DB_PREFIX . "theme`");
     35 
     36 		return $query->row['total'];
     37 	}	
     38 }