6 DEFINE(
"ERR_SUCCESS", -2);
7 DEFINE(
"ERR_GENERAL", -1);
8 DEFINE(
"ERR_FILEIO", 1);
128 $aClassVars = get_object_vars($this);
129 while (list($name, $value) = each($aClassVars)) {
130 $this->_aViewData[$name] = $value;
134 $this->_aViewData[
'sDownloadFile'] = $this->
getConfig()->getConfigParam(
'sShopURL') . $this->sExportPath . $this->sExportFileName .
"." .
$this->sExportFileType;
145 $this->_aViewData[
"cattree"] =
oxNew(
"oxCategoryList");
146 $this->_aViewData[
"cattree"]->loadList();
148 $oLangObj =
oxNew(
'oxLang');
149 $aLangs = $oLangObj->getLanguageArray();
150 foreach ($aLangs as $id => $language) {
152 $this->_aViewData[
"aLangs"][$id] = clone $language;
162 $this->fpFile = @fopen($this->_sFilePath,
"w");
163 if (!isset($this->fpFile) || !$this->fpFile) {
165 $this->
stop(ERR_FILEIO);
167 $this->_aViewData[
'refresh'] = 0;
168 $this->_aViewData[
'iStart'] = 0;
169 fclose($this->fpFile);
174 $this->_aViewData[
'iEnd'] = $iEnd;
183 public function stop($iError = 0)
186 $this->_aViewData[
'iError'] = $iError;
212 $sLine = $this->removeSID($sLine);
213 $sLine = str_replace(array(
"\r\n",
"\n"),
"", $sLine);
214 fwrite($this->fpFile, $sLine .
"\r\n");
225 $this->fpFile = @fopen($this->_sFilePath,
"a");
226 if (!isset($this->fpFile) || !$this->fpFile) {
228 $this->
stop(ERR_FILEIO);
236 if (($iExportedItems = $this->
nextTick($i)) ===
false) {
238 $this->
stop(ERR_SUCCESS);
245 $this->_aViewData[
'refresh'] = 0;
246 $this->_aViewData[
'iStart'] = $i;
247 $this->_aViewData[
'iExpItems'] = $iExportedItems;
249 fclose($this->fpFile);
260 if ($this->_iExportPerTick === null) {
262 if (!$this->_iExportPerTick) {
277 $this->_iExportPerTick = $iCount;
292 $sOutput = str_replace(
"sid={$sSid}/",
"", $sInput);
293 $sOutput = str_replace(
"sid/{$sSid}/",
"", $sOutput);
294 $sOutput = str_replace(
"sid={$sSid}&",
"", $sOutput);
295 $sOutput = str_replace(
"sid={$sSid}&",
"", $sOutput);
296 $sOutput = str_replace(
"sid={$sSid}",
"", $sOutput);
310 public function shrink($sInput, $iMaxSize, $blRemoveNewline =
true)
312 if ($blRemoveNewline) {
313 $sInput = str_replace(
"\r\n",
" ", $sInput);
314 $sInput = str_replace(
"\n",
" ", $sInput);
317 $sInput = str_replace(
"\t",
" ", $sInput);
320 $sInput = $this->_unHTMLEntities(strip_tags($sInput));
323 if ($oStr->strlen($sInput) > $iMaxSize - 3) {
324 $sInput = $oStr->substr($sInput, 0, $iMaxSize - 5) .
"...";
345 $sCatView = getViewName(
'oxcategories', $sLang);
346 $sO2CView = getViewName(
'oxobject2category', $sLang);
349 $sQ =
"select $sCatView.oxleft, $sCatView.oxright, $sCatView.oxrootid from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
350 $sQ .=
"where oxobject2category.oxobjectid=" . $oDB->quote($oArticle->getId()) .
" and $sCatView.oxactive = 1 order by oxobject2category.oxtime ";
352 $oRs = $oDB->execute($sQ);
353 if ($oRs !=
false && $oRs->recordCount() > 0) {
354 $sLeft = $oRs->fields[0];
355 $sRight = $oRs->fields[1];
356 $sRootId = $oRs->fields[2];
359 $sQ =
"select oxtitle from $sCatView where oxright >= {$sRight} and oxleft <= {$sLeft} and oxrootid = '{$sRootId}' order by oxleft ";
361 $oRs = $oDB->execute($sQ);
362 if ($oRs !=
false && $oRs->recordCount() > 0) {
365 $sCatStr .= $sSeparator;
367 $sCatStr .= $oRs->fields[0];
388 $sCatView = getViewName(
'oxcategories', $sLang);
389 $sO2CView = getViewName(
'oxobject2category', $sLang);
392 $sQ =
"select $sCatView.oxtitle from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
393 $sQ .=
"where oxobject2category.oxobjectid=" . $oDB->quote($oArticle->getId()) .
" and $sCatView.oxactive = 1 order by oxobject2category.oxtime ";
395 return $oDB->getOne($sQ);
409 return str_replace(array(
" ",
"€",
"|"), array(
" ",
"",
""), $sInput);
421 $sOutput = str_replace(
"&",
"&", $sInput);
422 $sOutput = str_replace(
"\"",
""", $sOutput);
423 $sOutput = str_replace(
">",
">", $sOutput);
424 $sOutput = str_replace(
"<",
"<", $sOutput);
425 $sOutput = str_replace(
"'",
"'", $sOutput);
454 $oRs = $oDB->execute(
"SHOW VARIABLES LIKE 'version'");
465 oxRegistry::getUtils()->showMessageAndExit(
"Could not insert Articles in Table {$sHeapTable}\n<br>");
472 return $oDB->getOne(
"select count(*) from {$sHeapTable}");
489 $myConfig->setConfigParam(
'blExport',
true);
499 $myConfig->setConfigParam(
'blExport',
false);
515 if (!$oStr->strlen($sInput)) {
516 if (!isset($sReplace) || !$oStr->strlen($sReplace)) {
535 $aTransTbl = array_flip(get_html_translation_table(HTML_ENTITIES));
537 return strtr($sInput, $aTransTbl);
548 return "tmp_" . str_replace(
"0",
"", md5($this->
getSession()->getId()));
563 if (version_compare($sMysqlVersion,
'4.1.0',
'>=') > 0) {
565 $oRs = $oDB->execute(
"SHOW FULL COLUMNS FROM `oxarticles` WHERE field like 'OXID'");
566 if (isset($oRs->fields[
'Collation']) && ($sMysqlCollation = $oRs->fields[
'Collation'])) {
567 $oRs = $oDB->execute(
"SHOW COLLATION LIKE '{$sMysqlCollation}'");
568 if (isset($oRs->fields[
'Charset']) && ($sMysqlCharacterSet = $oRs->fields[
'Charset'])) {
569 $sTableCharset =
"DEFAULT CHARACTER SET {$sMysqlCharacterSet} COLLATE {$sMysqlCollation}";
575 return $sTableCharset;
591 $sQ =
"CREATE TABLE IF NOT EXISTS {$sHeapTable} ( `oxid` CHAR(32) NOT NULL default '' ) ENGINE=InnoDB {$sTableCharset}";
592 if (($oDB->execute($sQ)) !==
false) {
594 $oDB->execute(
"TRUNCATE TABLE {$sHeapTable}");
610 if (is_array($aChosenCat) && count($aChosenCat)) {
612 $sCatAdd =
" and ( ";
614 foreach ($aChosenCat as $sCat) {
618 $sCatAdd .=
"oxobject2category.oxcatnid = " . $oDB->quote($sCat);
640 if (!isset($iExpLang)) {
644 $oArticle =
oxNew(
'oxarticle');
645 $oArticle->setLanguage($iExpLang);
647 $sO2CView = getViewName(
'oxobject2category', $iExpLang);
648 $sArticleTable = getViewName(
"oxarticles", $iExpLang);
650 $sSelect =
"insert into {$sHeapTable} select {$sArticleTable}.oxid from {$sArticleTable}, {$sO2CView} as oxobject2category where ";
651 $sSelect .= $oArticle->getSqlActiveSnippet();
654 $sSelect .=
" and {$sArticleTable}.oxid = oxobject2category.oxobjectid and {$sArticleTable}.oxparentid = '' ";
656 $sSelect .=
" and ( {$sArticleTable}.oxid = oxobject2category.oxobjectid or {$sArticleTable}.oxparentid = oxobject2category.oxobjectid ) ";
660 if (isset($sSearchString)) {
661 $sSelect .=
"and ( {$sArticleTable}.OXTITLE like " . $oDB->quote(
"%{$sSearchString}%");
662 $sSelect .=
" or {$sArticleTable}.OXSHORTDESC like " . $oDB->quote(
"%$sSearchString%");
663 $sSelect .=
" or {$sArticleTable}.oxsearchkeys like " . $oDB->quote(
"%$sSearchString%") .
" ) ";
667 $sSelect .= $sCatAdd;
671 $sShopID = $this->
getConfig()->getShopId();
672 $sSelect .=
" and {$sArticleTable}.oxshopid = '$sShopID' ";
677 $dMinStock = str_replace(array(
";",
" ",
"/",
"'"),
"", $dMinStock);
678 $sSelect .=
" and {$sArticleTable}.oxstock >= " . $oDB->quote($dMinStock);
681 $sSelect .=
" group by {$sArticleTable}.oxid";
683 return $oDB->execute($sSelect) ?
true :
false;
696 $sArticleTable = getViewName(
'oxarticles');
699 $sQ =
"select $sHeapTable.oxid from $sHeapTable, $sArticleTable where
700 $sHeapTable.oxid = $sArticleTable.oxparentid group by $sHeapTable.oxid";
702 $oRs = $oDB->execute($sQ);
703 $sDel =
"delete from $sHeapTable where oxid in ( ";
705 if ($oRs !=
false && $oRs->recordCount() > 0) {
710 $sDel .= $oDB->quote($oRs->fields[0]);
716 $oDB->execute($sDel);
728 if (isset($dDelCost)) {
729 $dDelCost = str_replace(array(
";",
" ",
"/",
"'"),
"", $dDelCost);
730 $dDelCost = str_replace(
",",
".", $dDelCost);
736 if (isset($dMinPrice)) {
737 $dMinPrice = str_replace(array(
";",
" ",
"/",
"'"),
"", $dMinPrice);
738 $dMinPrice = str_replace(
",",
".", $dMinPrice);
745 if (isset($sCampaign)) {
746 $sCampaign = str_replace(array(
";",
" ",
"/",
"'"),
"", $sCampaign);
754 if ($blAppendCatToCampaign) {
773 if ($this->_aCatLvlCache === null) {
774 $this->_aCatLvlCache = array();
776 $sCatView = getViewName(
'oxcategories');
780 $sSQL =
"select oxid from $sCatView where oxparentid = 'oxrootid'";
781 $oRs = $oDb->execute($sSQL);
782 if ($oRs !=
false && $oRs->recordCount() > 0) {
785 $sSQL =
"SELECT s.oxid, s.oxtitle,
786 s.oxparentid, count( * ) AS LEVEL FROM $sCatView v,
787 $sCatView s WHERE s.oxrootid = '" . $oRs->fields[0] .
"' and
788 v.oxrootid='" . $oRs->fields[0] .
"' and s.oxleft BETWEEN
789 v.oxleft AND v.oxright AND s.oxhidden = '0' GROUP BY s.oxleft order by level";
791 $oRs2 = $oDb->Execute($sSQL);
792 if ($oRs2 !=
false && $oRs2->recordCount() > 0) {
793 while (!$oRs2->EOF) {
795 $oCat =
new stdClass();
796 $oCat->_sOXID = $oRs2->fields[0];
797 $oCat->oxtitle = $oRs2->fields[1];
798 $oCat->oxparentid = $oRs2->fields[2];
799 $oCat->ilevel = $oRs2->fields[3];
800 $this->_aCatLvlCache[$oCat->_sOXID] = $oCat;
825 $aIds = $oArticle->getCategoryIds();
826 if (is_array($aIds) && count($aIds)) {
830 foreach ($aIds as $sCatId) {
831 if ($dMaxLvl < $aCatLvlCache[$sCatId]->ilevel) {
832 $dMaxLvl = $aCatLvlCache[$sCatId]->ilevel;
834 $sRet = $aCatLvlCache[$sCatId]->oxtitle;
840 if (!isset($aCatLvlCache[$sIdMax]->oxparentid) || $aCatLvlCache[$sIdMax]->oxparentid ==
"oxrootid") {
843 $sIdMax = $aCatLvlCache[$sIdMax]->oxparentid;
844 $sRet = $aCatLvlCache[$sIdMax]->oxtitle .
"/" . $sRet;
865 $oRs =
oxDb::getDb()->selectLimit(
"select oxid from $sHeapTable", 1, $iCnt);
866 if ($oRs !=
false && $oRs->recordCount() > 0) {
867 $oArticle =
oxNew(
'oxarticle');
868 $oArticle->setLoadParentData(
true);
872 if ($oArticle->load($oRs->fields[0])) {
877 if (!isset($dMinPrice) || (isset($dMinPrice) && ($oArticle->getPrice()->getBruttoPrice() >= $dMinPrice))) {
880 $sTitle = $oArticle->oxarticles__oxvarselect->value ?
" " . $oArticle->oxarticles__oxvarselect->value :
"";
881 $oArticle->oxarticles__oxtitle->setValue($oArticle->oxarticles__oxtitle->value . $sTitle);
903 $oArticle->appendLink(
"campaign={$sCampaign}");
908 $oArticle->appendLink(
"/$sCat");
922 return 'dyn_interface';