public static function getInstance()
 {
     if (is_null(self::$instance)) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 public function generator_cache($mode, $simulate)
 {
     $this->load->model('tool/seo_package');
     $this->load->model('localisation/language');
     $languages = $this->model_localisation_language->getLanguages();
     foreach ($languages as $language) {
         $lang_code[$language['language_id']] = $language['code'];
         $lang_img[$language['language_id']] = $language['image'];
     }
     if ($mode == 'delete') {
         $values = array();
         $values['lang_img'] = '';
         $values['no_old'] = true;
         $values['rows'] = array();
         foreach ($this->request->get['langs'] as $lang) {
             $res = Powercache::delete('seo_rewrite.' . (int) $lang);
             if ($res) {
                 $values['rows'][] = array('link' => 0, 'name' => '/system/cache/pcache.seo_rewrite.' . $lang, 'old_value' => '', 'value' => $this->language->get('text_deleted'), 'changed' => 0);
             }
         }
         $this->data['langs'][$lang] = $values;
         $this->data['langs'][$lang]['count'] = count($values['rows']);
         return;
     }
     $this->data['simulate'] = false;
     require_once VQMod::modCheck(DIR_CATALOG . 'controller/common/seo_url.php');
     $seo_url = new ControllerCommonSeoUrl($this->registry);
     $seo_url->index();
     foreach ($this->request->get['langs'] as $lang) {
         $values = array();
         $values['lang_img'] = $lang_img[$lang];
         $values['no_old'] = true;
         $values['rows'] = array();
         Powercache::delete('seo_rewrite.' . (int) $lang);
         $this->config->set('config_language_id', (int) $lang);
         $this->config->set('config_language', $lang_code[$lang]);
         $this->session->data['language'] = $lang_code[$lang];
         $types = array('product', 'information');
         foreach ($types as $type) {
             switch ($type) {
                 case 'information':
                     $route = 'information/information';
                     $field = $param = 'information_id';
                     break;
                 case 'product':
                     $route = 'product/product';
                     $field = $param = 'product_id';
                     break;
                 case 'category':
                     $route = 'product/category';
                     $field = 'category_id';
                     $param = 'path';
                     break;
             }
             $rows = $this->db->query("SELECT " . $field . ", seo_keyword, language_id FROM " . DB_PREFIX . $type . "_description WHERE language_id=" . (int) $lang . " ORDER BY " . $field)->rows;
             foreach ($rows as $row) {
                 $url = $this->url->link($route, $param . '=' . $row[$field]);
                 $values['rows'][] = array('link' => $url, 'name' => 'index.php?route=' . $route . '&' . $param . '=' . $row[$field], 'old_value' => '', 'value' => str_replace(HTTP_SERVER, '/', $url), 'changed' => 0);
                 // product link from categories
                 if ($type == 'product') {
                     $paths = $this->model_tool_seo_package->getFullProductPaths($row['product_id']);
                     foreach ($paths as $path) {
                         $url = $this->url->link('product/product', 'path=' . $path . '&product_id=' . $row['product_id']);
                         $values['rows'][] = array('link' => $url, 'name' => 'index.php?route=product/product&path=' . $path . '&product_id=' . $row['product_id'], 'old_value' => '', 'value' => str_replace(HTTP_SERVER, '/', $url), 'changed' => 0);
                     }
                 }
                 //Powercache::add('seo_rewrite', $row['language_id'] . '-route=product/product&product_id=' . $row['product_id'], $url);
             }
         }
         $this->data['langs'][$lang] = $values;
         $this->data['langs'][$lang]['count'] = count($values['rows']);
     }
 }