Пример #1
0
 protected static function mergeTable($hierarchyTypeId)
 {
     $mcfg = new baseXmlConfig(SYS_KERNEL_PATH . "subsystems/manifest/manifests/MergeContentTable.xml");
     $mcfg->addParam('hierarchy-type-id', $hierarchyTypeId);
     $mf = new manifest($mcfg);
     $manifest->hibernationsCountLeft = -1;
     $mf->setCallback(new jsonManifestCallback());
     $mf->execute();
 }
Пример #2
0
		public function onCronSyncCurrency(iUmiEventPoint $event) {
			$regedit = regedit::getInstance();
			if(!$regedit->getVal('//modules/emarket/enable-currency')) return false;
			
			$config = mainConfiguration::getInstance();
			$sourceUrl = $config->get('modules', 'emarket.currency.sync.source');
			$xslPath = CURRENT_WORKING_DIR .'/xsl/currencies/' . $config->get('modules', 'emarket.currency.sync.xsl');
			
			$originalXml = umiRemoteFileGetter::get($sourceUrl);
			if(function_exists('mb_detect_encoding') && (mb_detect_encoding($originalXml, "UTF-8, ISO-8859-1, GBK, CP1251") != "UTF-8")) {
				$originalXml = iconv ("CP1251", "UTF-8", $originalXml);
				$originalXml = preg_replace("/(encoding=\"windows-1251\")/i", "encoding=\"UTF-8\"", $originalXml);
			}
			
			$xslt = new xsltProcessor;
			$dom = new DomDocument();
			$dom->loadXML($originalXml);
			$xslt->importStyleSheet(DomDocument::load($xslPath));
			$resultXml = $xslt->transformToXML($dom);
			$tmpPath = SYS_CACHE_RUNTIME . 'tmpcurrencies.xml';
			file_put_contents($tmpPath, $resultXml);
			
			$currenciesList = new baseXmlConfig($tmpPath);
			$currencies = $currenciesList->getList('/Exchange/Exchange_Rates', array (
				'code'		=> '/New_Country',
				'rate'		=> '/Rate',
				'nominal'	=> '/Nominal'
			));
			
			foreach($currencies as $currencyInfo) {
				$code = getArrayKey($currencyInfo, 'code');
				
				try {
					if($currency = $this->getCurrency($code)) {
						$currency->nominal = getArrayKey($currencyInfo, 'nominal');
						$currency->rate = getArrayKey($currencyInfo, 'rate');
						$currency->commit();
					}
				} catch(privateException $e) {}
			}
			
			unlink($tmpPath);
		}