Esempio n. 1
0
 public function createXml($loadfile = '')
 {
     require_once JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'models' . DS . 'xmlexport.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'config.php';
     require_once JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'helpers' . DS . 'xmlexport.php';
     if (!function_exists('simplexml_load_file')) {
         return;
     }
     $xmlexport = new JModelXmlexport();
     //$this->addModelPath( JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_onepage' . DS . 'models' );
     //$xmlexport = $this->getModel('xmlexport');
     $files = $xmlexport->getPhpExportThemes();
     $general = new stdClass();
     $xmlexport->getGeneral($general);
     OPCXmlExport::$config = $general;
     // single file creation:
     $onlyf = JRequest::getVar('file', '');
     $arr2 = array();
     $langs = array();
     foreach ($files as $k => $f) {
         $config = $xmlexport->getThemeConfig($f);
         if (empty($config) || empty($config->enabled)) {
             continue;
         } else {
             if (empty($config->language)) {
                 continue;
             }
             $arr2[$k]['file'] = $f;
             $arr2[$k]['config'] = $config;
             $langs[$config->language] = $config->language;
         }
     }
     foreach ($arr2 as $x) {
         $file = $x['file'];
         // special case:
         if (!empty($loadfile)) {
             if ($loadfile != $file) {
                 continue;
             }
         }
         if (!empty($onlyf) && $onlyf != $file) {
             continue;
         }
         $config = $x['config'];
         jimport('joomla.filesystem.file');
         $file = JFile::makeSafe($file);
         $xmlpath = JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'xmlexport' . DS . 'php' . DS . $file . '.xml';
         $phppath = JPATH_SITE . DS . 'components' . DS . 'com_onepage' . DS . 'xmlexport' . DS . 'php' . DS . $file . '.php';
         if (!file_exists($phppath)) {
             continue;
         }
         $xml = simplexml_load_file($xmlpath);
         if (!empty($xml->element)) {
             $class = ucfirst(strtolower($xml->element)) . 'Xml';
         } else {
             $class = ucfirst(strtolower($file)) . 'Xml';
         }
         if (!class_exists($class)) {
             include $phppath;
         }
         if (!class_exists($class)) {
             continue;
         }
         OPCXmlExport::addClass($class, $config, $xml, $file);
         if (!empty($loadfile)) {
             return OPCXmlExport::$classes[$class];
         }
     }
     if (empty($loadfile)) {
         OPCXmlExport::doWork($langs);
     }
 }
Esempio n. 2
0
 public static function addItem($product, $vm1m)
 {
     // internal error:
     if (empty($product->virtuemart_product_id)) {
         return;
     }
     foreach (OPCXmlExport::$classes as $class) {
         if (method_exists($class, 'addItem')) {
             // check the shopper group:
             if (empty($product->shoppergroups) || in_array($class->config->shopper_group, $product->shoppergroups)) {
                 if (in_array($class->config->child_type, $product->child_type)) {
                     $product2 = $product;
                     OPCXmlExport::updateProduct($product2, $class, $vm1);
                     //get pairing info:
                     //if (!empty($product->categories))
                     if (!empty($vm1['cats'])) {
                         //$product2->paired_category_name = reset($vm1['cats']);
                         $deepestcat = $vm1['longest_cats'][count($vm1['longest_cats']) - 1];
                         $product2->paired_category_name = $deepestcat;
                         if (!empty($vm1['longest_cat_id'])) {
                             // take the first:
                             $cat_id = $vm1['longest_cat_id'];
                             //$product->categories[0];
                             $default = new stdClass();
                             $entity = $class->entity;
                             $res = OPCconfig::getValue('xmlexport_pairing', $entity, $cat_id, $default);
                             if (!empty($res) && !empty($res->txt)) {
                                 $product2->paired_category_name = $res->txt;
                             }
                             $product2->pairedObj = $res;
                         }
                     } else {
                         $product2->paired_category_name = '';
                     }
                     $ret = $class->addItem($product2, $vm1);
                     $class->writer->write($ret);
                 }
             }
         }
     }
 }