예제 #1
0
 /**
  * Function is responsible for listing the ALL of the products from
  * the database without querying for any categories.
  * 
  * @return unknown|string
  */
 function getAllServices()
 {
     $db =& $this->getDBO();
     $db->resetTree();
     $db->setTree('SELECT', '`' . $this->_tbl . '`.*');
     $db->setTree('FROM', '`#__rel_serv_cca`');
     $db->setTree('INNER JOIN', '`' . $this->_tbl . '` ON `#__rel_serv_cca`.bizid=' . $this->_tbl . '.bizid');
     $db->setTree('WHERE', '`#__rel_serv_cca`.catid = ' . $db->Quote('108'));
     if (BRequest::getCmd('p', false) == 'h' && BRequest::getCmd('s', false) == 'r' && BRequest::getCmd('r', false) == 'o') {
         $db->setTree('ORDER BY', '`' . $this->_tbl . '`.`price` DESC');
     } elseif (BRequest::getCmd('p', false) == 'l' && BRequest::getCmd('s', false) == 'r' && BRequest::getCmd('r', false) == 'o') {
         $db->setTree('ORDER BY', "`{$this->_tbl}`.`price` ASC");
     } elseif (BRequest::getCmd('s', false) == 'l' && BRequest::getCmd('r', false) == 'o') {
         //@todo doesn't work as expected
         $db->setTree('SELECT', "sum((`likes`.`like`)) AS `tlikes`");
         $db->setTree('LEFT JOIN', "`likes` ON `{$this->_tbl}`.`id` = `likes`.`itemid`");
         $db->setTree('ORDER BY', "tlikes ASC");
     } elseif (BRequest::getCmd('s', false) == 'r' && BRequest::getCmd('r', false) == 'n') {
         $db->setTree('ORDER BY', "`{$this->_tbl}`.`dateAdded` DESC");
     } elseif (BRequest::getCmd('s', false) == 'r' && BRequest::getCmd('r', false) == 'o') {
         $db->setTree('ORDER BY', "`{$this->_tbl}`.`dateAdded` ASC");
     } elseif (BRequest::getCmd('s', false) == 'r') {
         //@todo doesn't work as expected
         $db->setTree('SELECT', "sum((`ratings`.`like`)) AS `ratingsum`");
         $db->setTree('LEFT JOIN', "`ratings` ON `{$this->_tbl}`.`id` = `ratings`.`itemid`");
         $db->setTree('ORDER BY', "ratingsum ASC");
     }
     //default ordering
     if (empty($sql['ORDER BY'])) {
         $db->setTree('ORDER BY', "`{$this->_tbl}`.dateAdded ASC");
     }
     $per_page = config('products.per_page');
     $db->setTree('LIMIT', $per_page);
     if ($offset = (BRequest::getInt('ppage', 1) - 1) * $per_page) {
         $db->setTree('OFFSET', $offset);
     }
     $q = $db->queryTree();
     //echo _520($q);
     if ($results = $db->loadList($this->_tbl_key, $this->_type)) {
         return $results;
     }
     return false;
 }
예제 #2
0
 function old__construct()
 {
     global $path_site;
     global $cl;
     // CONTENT LOGIC FUNCTIONS
     global $meta_desc;
     global $meta_keywords;
     global $title;
     $action = BRequest::getCmd('action');
     $method = BRequest::getCmd('method');
     $call = BRequest::getCmd('call');
     // a call is an ajax call.
     // TRACK LAST PAGE
     // $last = lastURL();
     $returnmsg = NULL;
     // INIT OBJECTS
     if (!BRequest::getVar('category', false)) {
         unset($_SESSION['assortment'], $_SESSION['category'], $_SESSION['collection']);
     }
     if (BRequest::getVar('category', false)) {
         $title .= ucwords(BRequest::getString('category')) . ' - ';
         unset($_SESSION['assortment'], $_SESSION['collection']);
     }
     if (BRequest::getVar('collection', false)) {
         $title .= ucwords(BRequest::getString('collection')) . ' - ';
         unset($_SESSION['assortment']);
     }
     if (BRequest::getVar('category', false) && !isset($_SESSION['category']) || BRequest::getVar('category', false) && $_SESSION['category'] != BRequest::getString('category')) {
         $_SESSION['category'] = BRequest::getVar('category');
     }
     if (BRequest::getVar('collection', false) && !isset($_SESSION['collection']) || BRequest::getVar('collection', false) && $_SESSION['collection'] != BRequest::getVar('collection')) {
         $_SESSION['collection'] = BRequest::getVar('collection');
     }
     if (BRequest::getVar('assortment', false) && !isset($_SESSION['assortment']) || BRequest::getVar('assortment', false) && $_SESSION['assortment'] != BRequest::getVar('assortment')) {
         $title .= ucwords(BRequest::getString('assortment')) . ' - ';
         $_SESSION['assortment'] = BRequest::getVar('assortment');
     }
     // AJAX CALLS START \\
     if ($call == 'sl') {
         if ((BRequest::getVar('i', false) and preg_match('/^[0-9]{1,20}$/i', BRequest::getInt('i'))) && (isset($method) and preg_match('/^[a-z]{4,20}$/i', $method))) {
             $return = $this->set('like');
         } else {
             $return = 0;
         }
         print $return;
         exit;
     }
     if ($call == 'sr') {
         if ((BRequest::getVar('i', false) and preg_match('/^[0-9]{1,20}$/i', BRequest::getInt('i'))) && (isset($method) and preg_match('/^[a-z]{4,20}$/i', $method))) {
             $return = $this->set('rating');
         } else {
             $return = 0;
         }
         print $return;
         exit;
     }
     /*
     		
     		// CALL CONTENT AND REPLACE TAGS INSIDE
     		$content = ABSPATH.'/inc/cb/index.inc';
     		$returnOutput = new main_output($content);
     
     		// replace tags from template
     		@ $returnOutput->replace_tags(array(	
     			'path_site' => SITE_BASEURL,
     			'side_nav' => $cl->get_sideNav(),
     			'collections' => $cl->get_boxOne('collections'),
     			'assortments' => $cl->get_boxOne('assortments'),
     			'sm_icons_index' => $cl->get_smicons('index'),
     			'news_events' => $cl->get_boxTwo('news'),
     			'this_month' => '',
     			'advertise_banner' => rand(1, 2),
     			'think_global_shop_local' => $cl->get_boxSeven('tgsl'),
     			'pm_bill_of_rights' => $cl->get_boxSeven('bor'),
     			'our_favorite_things' => '', // $cl->get_boxSeven('oft'),
     			'category_calendar' => $cl->get_boxSeven('cm'),
     			'banner' => $cl->get_banner(),
     			'content' => $this->get_content()
     			//'page_title' => $page_title_txt,
     		));
     		// Call the output
     		$this->output = $returnOutput->output;*/
 }