6 DEFINE(
"ERR_SUCCESS", -2);
7 DEFINE(
"ERR_GENERAL", -1);
8 DEFINE(
"ERR_FILEIO", 1);
112 $this->_sFilePath = $this->
getConfig()->getConfigParam(
'sShopDir' ) .
"/". $this->sExportPath . $this->sExportFileName .
"." .
$this->sExportFileType;
126 $aClassVars = get_object_vars( $this );
127 while ( list( $name, $value ) = each( $aClassVars ) ) {
128 $this->_aViewData[$name] = $value;
132 $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;
164 $this->fpFile = @fopen( $this->_sFilePath,
"w" );
165 if ( !isset( $this->fpFile ) || !$this->fpFile ) {
167 $this->
stop( ERR_FILEIO );
169 $this->_aViewData[
'refresh'] = 0;
170 $this->_aViewData[
'iStart'] = 0;
171 fclose( $this->fpFile );
176 $this->_aViewData[
'iEnd'] = $iEnd;
187 public function stop( $iError = 0 )
190 $this->_aViewData[
'iError'] = $iError;
218 $sLine = $this->removeSID( $sLine );
219 $sLine = str_replace( array(
"\r\n",
"\n"),
"", $sLine);
220 fwrite( $this->fpFile, $sLine.
"\r\n");
233 $this->fpFile = @fopen( $this->_sFilePath,
"a");
234 if ( !isset( $this->fpFile) || !$this->fpFile) {
236 $this->
stop( ERR_FILEIO);
244 if ( ( $iExportedItems = $this->
nextTick( $i ) ) ===
false ) {
246 $this->
stop( ERR_SUCCESS);
253 $this->_aViewData[
'refresh'] = 0;
254 $this->_aViewData[
'iStart'] = $i;
255 $this->_aViewData[
'iExpItems'] = $iExportedItems;
257 fclose( $this->fpFile);
268 if ( $this->_iExportPerTick === null ) {
270 if ( !$this->_iExportPerTick ) {
286 $this->_iExportPerTick = $iCount;
301 $sOutput = str_replace(
"sid={$sSid}/",
"", $sInput);
302 $sOutput = str_replace(
"sid/{$sSid}/",
"", $sOutput);
303 $sOutput = str_replace(
"sid={$sSid}&",
"", $sOutput);
304 $sOutput = str_replace(
"sid={$sSid}&",
"", $sOutput);
305 $sOutput = str_replace(
"sid={$sSid}",
"", $sOutput);
319 public function shrink( $sInput, $iMaxSize, $blRemoveNewline =
true )
321 if ( $blRemoveNewline ) {
322 $sInput = str_replace(
"\r\n",
" ", $sInput );
323 $sInput = str_replace(
"\n",
" ", $sInput );
326 $sInput = str_replace(
"\t",
" ", $sInput );
329 $sInput = $this->_unHTMLEntities( strip_tags( $sInput ) );
332 if ( $oStr->strlen( $sInput ) > $iMaxSize - 3 ) {
333 $sInput = $oStr->substr( $sInput, 0, $iMaxSize - 5 ) .
"...";
354 $sCatView = getViewName(
'oxcategories', $sLang );
355 $sO2CView = getViewName(
'oxobject2category', $sLang );
358 $sQ =
"select $sCatView.oxleft, $sCatView.oxright, $sCatView.oxrootid from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
359 $sQ .=
"where oxobject2category.oxobjectid=".$oDB->quote( $oArticle->getId() ).
" and $sCatView.oxactive = 1 order by oxobject2category.oxtime ";
361 $oRs = $oDB->execute( $sQ );
362 if ( $oRs !=
false && $oRs->recordCount() > 0 ) {
363 $sLeft = $oRs->fields[0];
364 $sRight = $oRs->fields[1];
365 $sRootId = $oRs->fields[2];
368 $sQ =
"select oxtitle from $sCatView where oxright >= {$sRight} and oxleft <= {$sLeft} and oxrootid = '{$sRootId}' order by oxleft ";
370 $oRs = $oDB->execute( $sQ );
371 if ( $oRs !=
false && $oRs->recordCount() > 0 ) {
372 while ( !$oRs->EOF ) {
374 $sCatStr .= $sSeparator;
376 $sCatStr .= $oRs->fields[0];
397 $sCatView = getViewName(
'oxcategories', $sLang );
398 $sO2CView = getViewName(
'oxobject2category', $sLang );
401 $sQ =
"select $sCatView.oxtitle from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
402 $sQ .=
"where oxobject2category.oxobjectid=".$oDB->quote( $oArticle->getId() ).
" and $sCatView.oxactive = 1 order by oxobject2category.oxtime ";
404 return $oDB->getOne( $sQ);
416 $sInput =
oxRegistry::get(
"oxUtilsString")->prepareCSVField( $sInput );
417 return str_replace( array(
" ",
"€",
"|" ), array(
" ",
"",
"" ), $sInput );
429 $sOutput = str_replace(
"&",
"&", $sInput );
430 $sOutput = str_replace(
"\"",
""", $sOutput );
431 $sOutput = str_replace(
">",
">", $sOutput );
432 $sOutput = str_replace(
"<",
"<", $sOutput );
433 $sOutput = str_replace(
"'",
"'", $sOutput );
462 $oRs = $oDB->execute(
"SHOW VARIABLES LIKE 'version'" );
468 oxRegistry::getUtils()->showMessageAndExit(
"Could not create HEAP Table {$sHeapTable}\n<br>" );
473 oxRegistry::getUtils()->showMessageAndExit(
"Could not insert Articles in Table {$sHeapTable}\n<br>" );
480 return $oDB->getOne(
"select count(*) from {$sHeapTable}" );
497 $myConfig->setConfigParam(
'blExport',
true );
507 $myConfig->setConfigParam(
'blExport',
false );
523 if ( !$oStr->strlen( $sInput ) ) {
524 if ( !isset( $sReplace ) || !$oStr->strlen( $sReplace ) ) {
542 $aTransTbl = array_flip( get_html_translation_table( HTML_ENTITIES ) );
543 return strtr( $sInput, $aTransTbl );
554 return "tmp_".str_replace(
"0",
"", md5( $this->
getSession()->getId() ) );
569 if ( version_compare( $sMysqlVersion,
'4.1.0',
'>=' ) > 0 ) {
571 $oRs = $oDB->execute(
"SHOW FULL COLUMNS FROM `oxarticles` WHERE field like 'OXID'" );
572 if ( isset( $oRs->fields[
'Collation'] ) && ( $sMysqlCollation = $oRs->fields[
'Collation'] ) ) {
573 $oRs = $oDB->execute(
"SHOW COLLATION LIKE '{$sMysqlCollation}'" );
574 if ( isset( $oRs->fields[
'Charset'] ) && ( $sMysqlCharacterSet = $oRs->fields[
'Charset'] ) ) {
575 $sTableCharset =
"DEFAULT CHARACTER SET {$sMysqlCharacterSet} COLLATE {$sMysqlCollation}";
580 return $sTableCharset;
596 $sQ =
"CREATE TABLE IF NOT EXISTS {$sHeapTable} ( `oxid` CHAR(32) NOT NULL default '' ) ENGINE=InnoDB {$sTableCharset}";
597 if ( ( $oDB->execute( $sQ ) ) !==
false ) {
599 $oDB->execute(
"TRUNCATE TABLE {$sHeapTable}" );
615 if ( is_array( $aChosenCat ) && count( $aChosenCat ) ) {
617 $sCatAdd =
" and ( ";
619 foreach ( $aChosenCat as $sCat ) {
623 $sCatAdd .=
"oxobject2category.oxcatnid = ".$oDB->quote( $sCat );
644 if (!isset($iExpLang)) {
648 $oArticle =
oxNew(
'oxarticle' );
649 $oArticle->setLanguage( $iExpLang );
651 $sO2CView = getViewName(
'oxobject2category', $iExpLang );
652 $sArticleTable = getViewName(
"oxarticles", $iExpLang );
654 $sSelect =
"insert into {$sHeapTable} select {$sArticleTable}.oxid from {$sArticleTable}, {$sO2CView} as oxobject2category where ";
655 $sSelect .= $oArticle->getSqlActiveSnippet();
658 $sSelect .=
" and {$sArticleTable}.oxid = oxobject2category.oxobjectid and {$sArticleTable}.oxparentid = '' ";
660 $sSelect .=
" and ( {$sArticleTable}.oxid = oxobject2category.oxobjectid or {$sArticleTable}.oxparentid = oxobject2category.oxobjectid ) ";
664 if ( isset( $sSearchString ) ) {
665 $sSelect .=
"and ( {$sArticleTable}.OXTITLE like ".$oDB->quote(
"%{$sSearchString}%" );
666 $sSelect .=
" or {$sArticleTable}.OXSHORTDESC like ".$oDB->quote(
"%$sSearchString%" );
667 $sSelect .=
" or {$sArticleTable}.oxsearchkeys like ".$oDB->quote(
"%$sSearchString%" ) .
" ) ";
671 $sSelect .= $sCatAdd;
675 $sShopID = $this->
getConfig()->getShopId();
676 $sSelect .=
" and {$sArticleTable}.oxshopid = '$sShopID' ";
681 $dMinStock = str_replace( array(
";",
" ",
"/",
"'"),
"", $dMinStock );
682 $sSelect .=
" and {$sArticleTable}.oxstock >= ".$oDB->quote( $dMinStock );
685 $sSelect .=
" group by {$sArticleTable}.oxid";
687 return $oDB->execute( $sSelect ) ?
true :
false;
702 $sArticleTable = getViewName(
'oxarticles');
705 $sQ =
"select $sHeapTable.oxid from $sHeapTable, $sArticleTable where
706 $sHeapTable.oxid = $sArticleTable.oxparentid group by $sHeapTable.oxid";
708 $oRs = $oDB->execute( $sQ );
709 $sDel =
"delete from $sHeapTable where oxid in ( ";
711 if ($oRs !=
false && $oRs->recordCount() > 0) {
712 while ( !$oRs->EOF ) {
716 $sDel .= $oDB->quote( $oRs->fields[0] );
722 $oDB->execute( $sDel );
737 if ( isset( $dDelCost ) ) {
738 $dDelCost = str_replace( array(
";",
" ",
"/",
"'"),
"", $dDelCost );
739 $dDelCost = str_replace(
",",
".", $dDelCost );
745 if ( isset( $dMinPrice ) ) {
746 $dMinPrice = str_replace( array(
";",
" ",
"/",
"'"),
"", $dMinPrice);
747 $dMinPrice = str_replace(
",",
".", $dMinPrice);
754 if ( isset( $sCampaign ) ) {
755 $sCampaign = str_replace( array(
";",
" ",
"/",
"'"),
"", $sCampaign );
763 if ( $blAppendCatToCampaign ) {
782 if ( $this->_aCatLvlCache === null ) {
783 $this->_aCatLvlCache = array();
785 $sCatView = getViewName(
'oxcategories');
789 $sSQL =
"select oxid from $sCatView where oxparentid = 'oxrootid'";
790 $oRs = $oDb->execute( $sSQL);
791 if ( $oRs !=
false && $oRs->recordCount() > 0 ) {
792 while ( !$oRs->EOF ) {
794 $sSQL =
"SELECT s.oxid, s.oxtitle,
795 s.oxparentid, count( * ) AS LEVEL FROM $sCatView v,
796 $sCatView s WHERE s.oxrootid = '".$oRs->fields[0].
"' and
797 v.oxrootid='".$oRs->fields[0].
"' and s.oxleft BETWEEN
798 v.oxleft AND v.oxright AND s.oxhidden = '0' GROUP BY s.oxleft order by level";
800 $oRs2 = $oDb->Execute( $sSQL );
801 if ( $oRs2 !=
false && $oRs2->recordCount() > 0 ) {
802 while ( !$oRs2->EOF ) {
804 $oCat =
new stdClass();
805 $oCat->_sOXID = $oRs2->fields[0];
806 $oCat->oxtitle = $oRs2->fields[1];
807 $oCat->oxparentid = $oRs2->fields[2];
808 $oCat->ilevel = $oRs2->fields[3];
809 $this->_aCatLvlCache[$oCat->_sOXID] = $oCat;
834 $aIds = $oArticle->getCategoryIds();
835 if ( is_array( $aIds ) && count( $aIds ) ) {
839 foreach ( $aIds as $sCatId ) {
840 if ( $dMaxLvl < $aCatLvlCache[$sCatId]->ilevel ) {
841 $dMaxLvl = $aCatLvlCache[$sCatId]->ilevel;
843 $sRet = $aCatLvlCache[$sCatId]->oxtitle;
849 if ( !isset( $aCatLvlCache[$sIdMax]->oxparentid ) || $aCatLvlCache[$sIdMax]->oxparentid ==
"oxrootid" ) {
852 $sIdMax = $aCatLvlCache[$sIdMax]->oxparentid;
853 $sRet = $aCatLvlCache[$sIdMax]->oxtitle.
"/".$sRet;
873 $oRs =
oxDb::getDb()->selectLimit(
"select oxid from $sHeapTable", 1, $iCnt );
874 if ( $oRs !=
false && $oRs->recordCount() > 0 ) {
875 $oArticle =
oxNew(
'oxarticle' );
876 $oArticle->setLoadParentData(
true );
880 if ( $oArticle->load( $oRs->fields[0] ) ) {
885 if ( !isset( $dMinPrice ) || ( isset( $dMinPrice ) && ( $oArticle->getPrice()->getBruttoPrice() >= $dMinPrice ) ) ) {
888 $sTitle = $oArticle->oxarticles__oxvarselect->value ?
" " .$oArticle->oxarticles__oxvarselect->value :
"";
889 $oArticle->oxarticles__oxtitle->setValue( $oArticle->oxarticles__oxtitle->value . $sTitle );
911 $oArticle->appendLink(
"campaign={$sCampaign}" );
915 $oArticle->appendLink(
"/$sCat" );
928 return 'dyn_interface';