Beispiel #1
0
 /**
  * generateJSMap
  *
  */
 function generateJSMap($tags_names_arr)
 {
     $output = '';
     if (count($tags_names_arr) > 0) {
         $getproductsPath = $this->modx->getOption('core_path') . "components/getproducts/model/getproducts.class.php";
         if (file_exists($getproductsPath)) {
             require_once $getproductsPath;
             $snippetProperties = $this->getSnippetProperties();
             $snippetProperties['limit'] = 0;
             $getProducts = new getProducts($this->modx, $snippetProperties);
             if (!empty($this->config['className']) && $this->config['className'] != 'modResource') {
                 array_push($tags_names_arr, 'id');
                 $getProducts->table_fields = $tags_names_arr;
             } else {
                 $getProducts->table_fields = array('id');
             }
             $getProducts->searchProducts();
             $total = $getProducts->getTotal();
             if ($total > 0) {
                 if (empty($this->config['className']) || $this->config['className'] == 'modResource') {
                     $getProducts->config['includeTVs'] = 1;
                     $getProducts->config['includeTVList'] = implode(',', $tags_names_arr);
                     $getProducts->config['includeTVList_arr'] = $tags_names_arr;
                     $getProducts->appendTVs('');
                 }
                 foreach ($getProducts->ids_arr as $r_id) {
                     if (isset($getProducts->products[$r_id])) {
                         $product = $getProducts->products[$r_id];
                         ksort($product);
                         $output .= $this->php2js(array_merge(array("id" => $r_id), $product)) . ",\n";
                     }
                 }
             }
         } else {
             $this->modx->log(modX::LOG_LEVEL_ERROR, 'tagManager: Unable to find a snippet getProducts.');
         }
     }
     if (strlen($output) > 0) {
         $output = "\n<script type=\"text/javascript\">\n            var flt_data = {\"products\": [\n" . (strlen($output) > 2 ? substr($output, 0, -2) : "") . "\n]};\n\n            </script>\n";
     }
     return $output;
 }