Ejemplo n.º 1
0
 /**
  * main action
  */
 public function mainAction()
 {
     $taxonomy_id = $this->GET['taxonomy_id'];
     $store_to_select = $this->GET['store_id'];
     if (is_numeric($this->GET['zoom'])) {
         $this->tpl->assign('ZOOM', $this->GET['zoom']);
     } else {
         $this->tpl->assign('ZOOM', 13);
     }
     $Mapping = new common_uri_mapping();
     $this->Store = new ecommerce_store();
     $store_pages = $this->getStorePages();
     $stores = $this->getAllStores($taxonomy_id);
     // display pins
     foreach ($stores as $store) {
         if ($store['latitude'] != 0 && $store['longitude'] != 0) {
             // pre-select this item?
             if ($store['id'] == $store_to_select) {
                 $selected_store = $store;
             }
             // find page and url
             $page = $store_pages[$store['id']];
             $store['url'] = $Mapping->stringToSeoUrl("/page/{$page['id']}");
             $store['node_id'] = $page['id'];
             $store['icon'] = $store['id'] == $selected_store['id'] ? 'false' : 'true';
             $store['open'] = $store['id'] == $selected_store['id'] ? 'true' : 'false';
             // parse item
             $this->tpl->assign("STORE", $store);
             $this->tpl->parse("content.map.store_marker");
         }
     }
     // center map to a selected store
     if ($selected_store) {
         $map['latitude'] = $selected_store['latitude'];
         $map['longitude'] = $selected_store['longitude'];
     } else {
         $map['latitude'] = $this->Store->conf['latitude'];
         $map['longitude'] = $this->Store->conf['longitude'];
         $this->fitMapToBounds($stores);
     }
     $this->tpl->assign("MAP", $map);
     $this->tpl->parse("content.map");
     return true;
 }
Ejemplo n.º 2
0
/**
 * global function to translate URLs using common_uri_mapping
 *
 * @param unknown_type $request
 * @return unknown
 */
function translateURL($request)
{
    require_once 'models/common/common_uri_mapping.php';
    $Mapping = new common_uri_mapping();
    if ($Mapping->conf['seo']) {
        $seo = $Mapping->stringToSeoUrl("/{$request}");
        return $seo;
    } else {
        return "/{$request}";
    }
}
Ejemplo n.º 3
0
 /**
  * main action
  */
 public function mainAction()
 {
     // init URI mapping object and store object
     $Mapping = new common_uri_mapping();
     $this->Store = new ecommerce_store();
     // get selected store for detail
     $node_id = (int) $this->GET['node_id'];
     // load stores, store pages and related categories
     $store_pages = $this->getStorePages();
     $stores = $this->getAllStores();
     $categories = $this->getAllStoreTaxonomyIds();
     $selected_store = $this->getStoreAssociatedToNode($node_id);
     $page_categories = $this->getPageTaxonomyIds($node_id);
     // process request to save store as my own store
     if ($this->GET['set_home_store'] == 'true' && $selected_store['id'] > 0) {
         if ($this->updateCustomersHomeStore($selected_store['id'])) {
             msg("Your store has been updated.");
         } else {
             msg("Please login into your account to save your store.");
         }
         return true;
     }
     // init map bounds
     $bounds['latitude']['max'] = -9999;
     $bounds['latitude']['min'] = 9999;
     $bounds['longitude']['max'] = -9999;
     $bounds['longitude']['min'] = 9999;
     // display pins
     foreach ($stores as $store) {
         if ($store['latitude'] != 0 && $store['longitude'] != 0) {
             // find page and url
             $page = $store_pages[$store['id']];
             $store['url'] = $Mapping->stringToSeoUrl("/page/{$page['id']}");
             $store['node_id'] = $page['id'];
             $store['icon'] = $store['id'] == $selected_store['id'] ? 'false' : 'true';
             $store['open'] = $store['id'] == $selected_store['id'] ? 'true' : 'false';
             if ($store['id'] == $_SESSION['client']['customer']['store_id']) {
                 $store['icon'] = 'false';
             }
             // adjust bounds (by province/county)
             if (array_intersect($page_categories, $categories[$store['id']])) {
                 if ($store['latitude'] > $bounds['latitude']['max']) {
                     $bounds['latitude']['max'] = $store['latitude'];
                 }
                 if ($store['latitude'] < $bounds['latitude']['min']) {
                     $bounds['latitude']['min'] = $store['latitude'];
                 }
                 if ($store['longitude'] > $bounds['longitude']['max']) {
                     $bounds['longitude']['max'] = $store['longitude'];
                 }
                 if ($store['longitude'] < $bounds['longitude']['min']) {
                     $bounds['longitude']['min'] = $store['longitude'];
                 }
             }
             $store['street_view_options'] = unserialize($store['street_view_options']);
             switch ($store['street_view_options']['image']) {
                 case 1:
                     $lat = $store['street_view_options']['latitude'];
                     $lng = $store['street_view_options']['longitude'];
                     if (empty($lat)) {
                         $lat = $store['latitude'];
                     }
                     if (empty($lng)) {
                         $lng = $store['longitude'];
                     }
                     $store['image'] = 'http://maps.googleapis.com/maps/api/streetview?size=130x130' . '&location=' . $lat . "," . $lng . '&fov=' . (int) $store['street_view_options']['fov'] . '&heading=' . (int) $store['street_view_options']['heading'] . '&pitch=' . (int) $store['street_view_options']['pitch'] . '&sensor=false' . '&key=' . ONXSHOP_GOOGLE_API_KEY;
                     break;
                 case 2:
                     $store['image'] = "/thumbnail/130x130/" . $this->getStoreImage($store['id']) . '?fill=1';
                     break;
                 case 0:
                 default:
                     $store['image'] = '/image/var/files/generic_store.jpg';
             }
             // parse item
             $this->tpl->assign("STORE", $store);
             $this->tpl->parse("content.map.store_marker");
         }
     }
     // center map to ...
     if ($selected_store) {
         // ... to a selected store
         $map['latitude'] = $selected_store['latitude'] + 0.004;
         $map['longitude'] = $selected_store['longitude'];
     } else {
         // ... to bounds of a selected region (province/county)
         if ($bounds['latitude']['min'] != 9999) {
             $this->tpl->assign("BOUNDS", $bounds);
             $this->tpl->parse("content.map.fit_to_bounds");
         }
         $map['latitude'] = $this->Store->conf['latitude'];
         $map['longitude'] = $this->Store->conf['longitude'];
     }
     $this->tpl->assign("MAP", $map);
     $this->tpl->parse("content.map");
     return true;
 }