コード例 #1
0
ファイル: xmlcron.php プロジェクト: jaanusnurmoja/redjoomla
 public function xmlImportFileUpdate()
 {
     $currenttime = time();
     $xmlHelper = new xmlHelper();
     $db = JFactory::getDbo();
     $query = "SELECT * FROM " . $this->_table_prefix . "xml_import AS x " . "WHERE x.published=1 " . "AND x.auto_sync=1 " . "AND x.sync_on_request=0 " . "AND x.auto_sync_interval!=0 ";
     $db->setQuery($query);
     $importlist = $db->loadObjectlist();
     for ($i = 0; $i < count($importlist); $i++) {
         $db = JFactory::getDbo();
         $query = "SELECT * FROM " . $this->_table_prefix . "xml_import_log AS xl " . "WHERE xl.xmlimport_id = " . (int) $importlist[$i]->xmlimport_id . " " . "ORDER BY xl.xmlimport_date DESC ";
         $db->setQuery($query);
         $lastrs = $db->loadObject();
         if (count($lastrs) > 0) {
             $difftime = $currenttime - $lastrs->xmlimport_date;
             $hours = $difftime / (60 * 60);
             if ($importlist[$i]->auto_sync_interval < $hours) {
                 $xmlHelper->importXMLFile($lastrs->xmlimport_id);
             }
         }
     }
 }
コード例 #2
0
 /**
  * Method to store the information
  *
  * @access public
  * @return boolean
  */
 public function store($data, $import = 0)
 {
     $xmlhelper = new xmlHelper();
     $resarray = array();
     if (array_key_exists("xmlfiletag", $data)) {
         $xmlfiletag = $data['xmlfiletag'];
         $updatefiletag = isset($data['updatefiletag']) ? $data['updatefiletag'] : array();
         for ($i = 0; $i < count($xmlfiletag); $i++) {
             $xmltag = trim($data[$xmlfiletag[$i]]);
             $updatetag = isset($updatefiletag[$i]) && $updatefiletag[$i] == 1 ? 1 : 0;
             $resarray[] = $xmlfiletag[$i] . "=" . $xmltag . "=" . $updatetag;
         }
     }
     $data['xmlimport_filetag'] = implode(";", $resarray);
     $resarray = array();
     if (array_key_exists("xmlbillingtag", $data)) {
         $xmlfiletag = $data['xmlbillingtag'];
         $updatefiletag = isset($data['updatebillingtag']) ? $data['updatebillingtag'] : array();
         for ($i = 0; $i < count($xmlfiletag); $i++) {
             $xmltag = trim($data["bill_" . $xmlfiletag[$i]]);
             $updatetag = isset($updatefiletag[$i]) && $updatefiletag[$i] == 1 ? 1 : 0;
             $resarray[] = $xmlfiletag[$i] . "=" . $xmltag . "=" . $updatetag;
         }
     }
     $data['xmlimport_billingtag'] = implode(";", $resarray);
     $resarray = array();
     if (array_key_exists("xmlshippingtag", $data)) {
         $xmlfiletag = $data['xmlshippingtag'];
         $updatefiletag = isset($data['updateshippingtag']) ? $data['updateshippingtag'] : array();
         for ($i = 0; $i < count($xmlfiletag); $i++) {
             $xmltag = trim($data["shipp_" . $xmlfiletag[$i]]);
             $updatetag = isset($updatefiletag[$i]) && $updatefiletag[$i] == 1 ? 1 : 0;
             $resarray[] = $xmlfiletag[$i] . "=" . $xmltag . "=" . $updatetag;
         }
     }
     $data['xmlimport_shippingtag'] = implode(";", $resarray);
     $resarray = array();
     if (array_key_exists("xmlitemtag", $data)) {
         $xmlfiletag = $data['xmlitemtag'];
         $updatefiletag = isset($data['updateitemtag']) ? $data['updateitemtag'] : array();
         for ($i = 0; $i < count($xmlfiletag); $i++) {
             $xmltag = trim($data["item_" . $xmlfiletag[$i]]);
             $updatetag = isset($updatefiletag[$i]) && $updatefiletag[$i] == 1 ? 1 : 0;
             $resarray[] = $xmlfiletag[$i] . "=" . $xmltag . "=" . $updatetag;
         }
     }
     $data['xmlimport_orderitemtag'] = implode(";", $resarray);
     $resarray = array();
     if (array_key_exists("xmlstocktag", $data)) {
         $xmlfiletag = $data['xmlstocktag'];
         $updatefiletag = isset($data['updatestocktag']) ? $data['updatestocktag'] : array();
         for ($i = 0; $i < count($xmlfiletag); $i++) {
             $xmltag = trim($data["stock_" . $xmlfiletag[$i]]);
             $updatetag = isset($updatefiletag[$i]) && $updatefiletag[$i] == 1 ? 1 : 0;
             $resarray[] = $xmlfiletag[$i] . "=" . $xmltag . "=" . $updatetag;
         }
     }
     $data['xmlimport_stocktag'] = implode(";", $resarray);
     $resarray = array();
     if (array_key_exists("xmlprdextrafieldtag", $data)) {
         $xmlfiletag = $data['xmlprdextrafieldtag'];
         $updatefiletag = isset($data['updateprdexttag']) ? $data['updateprdexttag'] : array();
         for ($i = 0; $i < count($xmlfiletag); $i++) {
             $xmltag = trim($data["prdext_" . $xmlfiletag[$i]]);
             $updatetag = isset($updatefiletag[$i]) && $updatefiletag[$i] == 1 ? 1 : 0;
             $resarray[] = $xmlfiletag[$i] . "=" . $xmltag . "=" . $updatetag;
         }
     }
     $data['xmlimport_prdextrafieldtag'] = implode(";", $resarray);
     if ($data['override_existing'] == 0 && trim($data['add_prefix_for_existing']) == "") {
         $data['add_prefix_for_existing'] = "xml_";
     }
     $row =& $this->getTable();
     if (!$row->bind($data)) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $row->published = $data['xmlpublished'];
     if (!$row->store()) {
         $this->setError($this->_db->getErrorMsg());
         return false;
     }
     $filename = $xmlhelper->writeXMLImportFile($row->xmlimport_id, $data['tmpxmlimport_url']);
     if ($import == 1) {
         $xmlhelper->importXMLFile($row->xmlimport_id);
     }
     return $row;
 }