コード例 #1
0
ファイル: store_detail.php プロジェクト: AppChecker/onxshop
 /**
  * main action
  */
 public function mainAction()
 {
     $Store = new ecommerce_store();
     $Taxonomy_Tree = new common_taxonomy_tree();
     $node_id = (int) $this->GET['node_id'];
     $store = $Store->findStoreByNode($node_id);
     $taxonomy = $Taxonomy_Tree->getRelatedTaxonomy($store['id'], "ecommerce_store_taxonomy");
     if ($store) {
         /**
          * get store taxonomy print out
          */
         $_Onxshop_Request = new Onxshop_Request("component/ecommerce/store_taxonomy~store_id={$store['id']}~");
         $this->tpl->assign("STORE_TAXONOMY", $_Onxshop_Request->getContent());
         /**
          * text depending if my selected store
          */
         if ($_SESSION['client']['customer']['store_id'] == $store['id']) {
             $this->tpl->assign('MY_SELECTED_STORE', 'My selected store');
         } else {
             $this->tpl->assign('MY_SELECTED_STORE', 'Save as my own store');
         }
         /**
          * assign and parse
          */
         $this->tpl->assign("STORE", $store);
         $this->tpl->parse("content.store");
     } else {
         $this->tpl->parse("content.no_store");
     }
     return true;
 }
コード例 #2
0
 /**
  * main action
  */
 public function mainAction()
 {
     // get selected store for detail
     $node_id = (int) $this->GET['node_id'];
     if ($node_id > 0) {
         $Node = new common_node();
         $Store = new ecommerce_store();
         $current_store = $Store->findStoreByNode($node_id);
         if ($current_store & is_numeric($current_store['id'])) {
             $distance = 0.2;
             $lat1 = (double) ((double) $current_store['latitude'] - $distance);
             $lat2 = (double) ((double) $current_store['latitude'] + $distance);
             $lng1 = (double) ((double) $current_store['longitude'] - $distance);
             $lng2 = (double) ((double) $current_store['longitude'] + $distance);
             $stores = $Store->listing("id != {$current_store['id']} AND publish = 1 AND " . "latitude BETWEEN {$lat1} AND {$lat2} AND longitude BETWEEN {$lng1} AND {$lng2}");
             if (count($stores) > 0) {
                 $distances = array();
                 foreach ($stores as $i => $store) {
                     $distance = $this->distance($current_store['latitude'], $current_store['longitude'], $store['latitude'], $store['longitude']);
                     $distances[$i] = $distance;
                 }
                 asort($distances, SORT_NUMERIC);
                 $i = 0;
                 foreach ($distances as $store_index => $distance) {
                     $store = $stores[$store_index];
                     if ($distance < 1) {
                         $distance = round($distance * 1000) . " meters";
                     } else {
                         $distance = number_format($distance, 1) . " km";
                     }
                     $store['distance'] = $distance;
                     // get store page for url
                     $page = $Store->getStoreHomepage($store['id']);
                     $store['node_id'] = $page['id'];
                     $this->tpl->assign("STORE", $store);
                     $column = $i % 3 + 1;
                     $this->tpl->parse("content.list.column{$column}");
                     $i++;
                     if ($i == 9) {
                         break;
                     }
                     // 9 sotres is enough
                 }
                 $this->tpl->parse("content.list");
             }
         }
     }
     return true;
 }