public function index()
 {
     if ($this->config->get('google_sitemap_blog_status')) {
         $cache = new sitemapCache();
         $output = '<?xml version="1.0" encoding="UTF-8"?>';
         $output .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
         // $this->load->model('catalog/product');
         // $output .= '<url>';
         // $output .= '<loc>' . $this->config->get('config_url') . '</loc>';
         // $output .= '<changefreq>always</changefreq>';
         // $output .= '<priority>1.0</priority>';
         // $output .= '</url>';
         // $cache_file = 'blog.sitemap.products.' . (int) $this->config->get('config_store_id') . '.' . (int) $this->config->get('config_language_id');
         // $product_cache = $cache->get($cache_file);
         // if (!isset($product_cache)) {
         // $product_output = '';
         // $products       = $this->model_catalog_product->getProducts();
         // foreach ($products as $product) {
         // $product_output .= '<url>';
         // $product_output .= '<loc>' . str_replace('&', '&amp;', str_replace('&amp;', '&', $this->url->link('product/product', 'product_id=' . $product['product_id']))) . '</loc>';
         // $product_output .= '<lastmod>' . substr(max($product['date_added'], $product['date_modified']), 0, 10) . '</lastmod>';
         // $product_output .= '<changefreq>weekly</changefreq>';
         // $product_output .= '<priority>1.0</priority>';
         // $product_output .= '</url>';
         // } //$products as $product
         // $cache->set($cache_file, $product_output);
         // $output .= $product_output;
         // } //!isset($product_cache)
         // else {
         // $output .= $product_cache;
         // }
         // $this->load->model('catalog/category');
         // $cache_file = 'blog.sitemap.categories.' . (int) $this->config->get('config_store_id') . '.' . (int) $this->config->get('config_language_id');
         // $categories_cache = $cache->get($cache_file);
         // if (!isset($categories_cache)) {
         // $categories_output = $this->getCategories(0);
         // $cache->set($cache_file, $categories_output);
         // $output .= $categories_output;
         // } //!isset($categories_cache)
         // else {
         // $output .= $categories_cache;
         // }
         // $this->load->model('catalog/manufacturer');
         // $cache_file = 'blog.sitemap.manufacturer.' . (int) $this->config->get('config_store_id') . '.' . (int) $this->config->get('config_language_id');
         // $manufacturer_cache = $cache->get($cache_file);
         // if (!isset($manufacturer_cache)) {
         // $manufacturers_output = '';
         // $manufacturers        = $this->model_catalog_manufacturer->getManufacturers();
         // foreach ($manufacturers as $manufacturer) {
         // $manufacturers_output .= '<url>';
         // $manufacturers_output .= '<loc>' . str_replace('&', '&amp;', str_replace('&amp;', '&', $this->url->link('product/manufacturer/product', 'manufacturer_id=' . $manufacturer['manufacturer_id']))) . '</loc>';
         // $manufacturers_output .= '<changefreq>weekly</changefreq>';
         // $manufacturers_output .= '<priority>0.7</priority>';
         // $manufacturers_output .= '</url>';
         // } //$manufacturers as $manufacturer
         // $cache->set($cache_file, $manufacturers_output);
         // $output .= $manufacturers_output;
         // } //!isset($manufacturer_cache)
         // else {
         // $output .= $manufacturer_cache;
         // }
         // $this->load->model('catalog/information');
         // $cache_file = 'blog.sitemap.information.' . (int) $this->config->get('config_store_id') . '.' . (int) $this->config->get('config_language_id');
         // $information_cache = $cache->get($cache_file);
         // if (!isset($information_cache)) {
         // $information_output = '';
         // $informations       = $this->model_catalog_information->getInformations();
         // foreach ($informations as $information) {
         // $information_output .= '<url>';
         // $information_output .= '<loc>' . str_replace('&', '&amp;', str_replace('&amp;', '&', $this->url->link('information/information', 'information_id=' . $information['information_id']))) . '</loc>';
         // $information_output .= '<changefreq>weekly</changefreq>';
         // $information_output .= '<priority>0.5</priority>';
         // $information_output .= '</url>';
         // } //$informations as $information
         // $cache->set($cache_file, $information_output);
         // $output .= $information_output;
         // } //!isset($information_cache)
         // else {
         // $output .= $information_cache;
         // }
         $this->load->model('catalog/record');
         $cache_file = 'blog.sitemap.records.' . (int) $this->config->get('config_store_id') . '.' . (int) $this->config->get('config_language_id');
         $records_cache = $cache->get($cache_file);
         if (!isset($records_cache)) {
             $records_output = '';
             $this->getChild('common/seoblog');
             $records = $this->model_catalog_record->getRecords();
             if ($records) {
                 foreach ($records as $record) {
                     $records_output .= '<url>';
                     $records_output .= '<loc>' . str_replace('&', '&amp;', str_replace('&amp;', '&', $this->url->link('record/record', 'record_id=' . $record['record_id']))) . '</loc>';
                     $records_output .= '<lastmod>' . substr(max($record['date_available'], $record['date_modified']), 0, 10) . '</lastmod>';
                     $records_output .= '<changefreq>weekly</changefreq>';
                     $records_output .= '<priority>0.5</priority>';
                     $records_output .= '</url>';
                 }
                 //$records as $record
             }
             //$records
             $cache->set($cache_file, $records_output);
             $output .= $records_output;
         } else {
             $output .= $records_cache;
         }
         $this->load->model('catalog/blog');
         $cache_file = 'blog.sitemap.blogies.' . (int) $this->config->get('config_store_id') . '.' . (int) $this->config->get('config_language_id');
         $blogies_cache = $cache->get($cache_file);
         if (!isset($blogies_cache)) {
             $blogies_output = $this->getBlogies(0);
             $cache->set($cache_file, $blogies_output);
             $output .= $blogies_output;
         } else {
             $output .= $blogies_cache;
         }
         $output .= '</urlset>';
         $this->response->addHeader('Content-Type: application/xml');
         $this->response->setOutput($output);
     }
     //$this->config->get('google_sitemap_status')
 }
Example #2
0
 public function getascp()
 {
     $output = '';
     $url_tmp = $url = '';
     $cache_status = true;
     $cache = new sitemapCache($this->expire);
     $this->load->model('catalog/record', DIR_CATALOG);
     $this->load->model('catalog/blog', DIR_CATALOG);
     $cache_file = 'blog.sitemap.records.' . (int) $this->config->get('config_store_id') . '.' . (int) $this->config->get('config_language_id');
     $records_cache = $cache->get($cache_file);
     if (!isset($records_cache) || !$this->cache) {
         $records_output = '';
         if (!$this->registry->get('admin_work')) {
             if (SCP_VERSION > 1) {
                 $this->load->controller('common/seoblog');
             } else {
                 $this->getChild('common/seoblog');
             }
         }
         $records = $this->model_catalog_record->getRecords();
         if ($records) {
             foreach ($records as $record) {
                 foreach ($this->languages as $code => $lang) {
                     if ($this->google_sitemap_blog_language_status) {
                         $this->switchLanguage($this->languages[$code]['language_id'], $code);
                     }
                     $url = str_replace('&', '&amp;', str_replace('&amp;', '&', $this->url->link('record/record', 'record_id=' . $record['record_id'])));
                     if ($url != $url_tmp) {
                         $records_output .= '<url>';
                         $records_output .= '<loc>' . rawurldecode($url) . '</loc>';
                         $records_output .= '<lastmod>' . substr(max($record['date_available'], $record['date_modified']), 0, 10) . '</lastmod>';
                         $records_output .= '<changefreq>weekly</changefreq>';
                         $records_output .= '<priority>1.0</priority>';
                         $records_output .= '</url>';
                     }
                     $url_tmp = $url;
                 }
             }
             //$records as $record
         }
         //$records
         $cache->set($cache_file, $records_output);
         $output .= $records_output;
     } else {
         $output .= $records_cache;
     }
     $cache_file = 'blog.sitemap.blogies.' . (int) $this->config->get('config_store_id') . '.' . (int) $this->config->get('config_language_id');
     $blogies_cache = $cache->get($cache_file);
     if (!isset($blogies_cache) || !$this->cache) {
         if (!$this->registry->get('admin_work')) {
             if (SCP_VERSION > 1) {
                 $this->load->controller('common/seoblog');
             } else {
                 $this->getChild('common/seoblog');
             }
         }
         $blogies_output = $this->getBlogies(0);
         $cache->set($cache_file, $blogies_output);
         $output .= $blogies_output;
     } else {
         $output .= $blogies_cache;
     }
     $this->switchLanguage($this->config_language_id, $this->config_language_code);
     return $output;
 }