dynexportbase.php

Go to the documentation of this file.
00001 <?php
00002 
00006 DEFINE("ERR_SUCCESS", -2);
00007 DEFINE("ERR_GENERAL", -1);
00008 DEFINE("ERR_FILEIO", 1);
00009 
00016 class DynExportBase extends oxAdminDetails
00017 {
00018 
00024     public $sClassDo = "";
00025 
00031     public $sClassMain = "";
00032 
00038     public $sExportPath = "export/";
00039 
00045     public $sExportFileType = "txt";
00046 
00052     public $sExportFileName = "dynexport";
00053 
00059     public $fpFile = null;
00060 
00067     public $iExportPerTick = 30;
00068 
00074     protected $_iExportPerTick = null;
00075 
00081     protected $_sFilePath = null;
00082 
00088     protected $_aExportResultset = array();
00089 
00095     protected $_sThisTemplate = "dynexportbase.tpl";
00096 
00102     protected $_aCatLvlCache = null;
00103 
00109     public function __construct()
00110     {
00111         parent::__construct();
00112 
00113         // set generic frame template
00114         $this->_sFilePath = $this->getConfig()->getConfigParam('sShopDir') . "/" . $this->sExportPath . $this->sExportFileName . "." . $this->sExportFileType;
00115     }
00116 
00123     public function render()
00124     {
00125         parent::render();
00126 
00127         // assign all member variables to template
00128         $aClassVars = get_object_vars($this);
00129         while (list($name, $value) = each($aClassVars)) {
00130             $this->_aViewData[$name] = $value;
00131         }
00132 
00133         $this->_aViewData['sOutputFile'] = $this->_sFilePath;
00134         $this->_aViewData['sDownloadFile'] = $this->getConfig()->getConfigParam('sShopURL') . $this->sExportPath . $this->sExportFileName . "." . $this->sExportFileType;
00135 
00136         return $this->_sThisTemplate;
00137     }
00138 
00142     public function createMainExportView()
00143     {
00144         // parent categorie tree
00145         $this->_aViewData["cattree"] = oxNew("oxCategoryList");
00146         $this->_aViewData["cattree"]->loadList();
00147 
00148         $oLangObj = oxNew('oxLang');
00149         $aLangs = $oLangObj->getLanguageArray();
00150         foreach ($aLangs as $id => $language) {
00151             $language->selected = ($id == $this->_iEditLang);
00152             $this->_aViewData["aLangs"][$id] = clone $language;
00153         }
00154     }
00155 
00159     public function start()
00160     {
00161         // delete file, if its already there
00162         $this->fpFile = @fopen($this->_sFilePath, "w");
00163         if (!isset($this->fpFile) || !$this->fpFile) {
00164             // we do have an error !
00165             $this->stop(ERR_FILEIO);
00166         } else {
00167             $this->_aViewData['refresh'] = 0;
00168             $this->_aViewData['iStart'] = 0;
00169             fclose($this->fpFile);
00170 
00171             // prepare it
00172             $iEnd = $this->prepareExport();
00173             oxRegistry::getSession()->setVariable("iEnd", $iEnd);
00174             $this->_aViewData['iEnd'] = $iEnd;
00175         }
00176     }
00177 
00183     public function stop($iError = 0)
00184     {
00185         if ($iError) {
00186             $this->_aViewData['iError'] = $iError;
00187         }
00188 
00189         // delete temporary heap table
00190         oxDb::getDb()->execute("drop TABLE if exists " . $this->_getHeapTableName());
00191     }
00192 
00200     public function nextTick($iCnt)
00201     {
00202         return false;
00203     }
00204 
00210     public function write($sLine)
00211     {
00212         $sLine = $this->removeSID($sLine);
00213         $sLine = str_replace(array("\r\n", "\n"), "", $sLine);
00214         fwrite($this->fpFile, $sLine . "\r\n");
00215     }
00216 
00220     public function run()
00221     {
00222         $blContinue = true;
00223         $iExportedItems = 0;
00224 
00225         $this->fpFile = @fopen($this->_sFilePath, "a");
00226         if (!isset($this->fpFile) || !$this->fpFile) {
00227             // we do have an error !
00228             $this->stop(ERR_FILEIO);
00229         } else {
00230             // file is open
00231             $iStart = oxRegistry::getConfig()->getRequestParameter("iStart");
00232             // load from session
00233             $this->_aExportResultset = oxRegistry::getConfig()->getRequestParameter("aExportResultset");
00234             $iExportPerTick = $this->getExportPerTick();
00235             for ($i = $iStart; $i < $iStart + $iExportPerTick; $i++) {
00236                 if (($iExportedItems = $this->nextTick($i)) === false) {
00237                     // end reached
00238                     $this->stop(ERR_SUCCESS);
00239                     $blContinue = false;
00240                     break;
00241                 }
00242             }
00243             if ($blContinue) {
00244                 // make ticker continue
00245                 $this->_aViewData['refresh'] = 0;
00246                 $this->_aViewData['iStart'] = $i;
00247                 $this->_aViewData['iExpItems'] = $iExportedItems;
00248             }
00249             fclose($this->fpFile);
00250         }
00251     }
00252 
00258     public function getExportPerTick()
00259     {
00260         if ($this->_iExportPerTick === null) {
00261             $this->_iExportPerTick = (int) oxRegistry::getConfig()->getConfigParam("iExportNrofLines");
00262             if (!$this->_iExportPerTick) {
00263                 $this->_iExportPerTick = $this->iExportPerTick;
00264             }
00265         }
00266 
00267         return $this->_iExportPerTick;
00268     }
00269 
00275     public function setExportPerTick($iCount)
00276     {
00277         $this->_iExportPerTick = $iCount;
00278     }
00279 
00287     public function removeSid($sInput)
00288     {
00289         $sSid = $this->getSession()->getId();
00290 
00291         // remove sid from link
00292         $sOutput = str_replace("sid={$sSid}/", "", $sInput);
00293         $sOutput = str_replace("sid/{$sSid}/", "", $sOutput);
00294         $sOutput = str_replace("sid={$sSid}&amp;", "", $sOutput);
00295         $sOutput = str_replace("sid={$sSid}&", "", $sOutput);
00296         $sOutput = str_replace("sid={$sSid}", "", $sOutput);
00297 
00298         return $sOutput;
00299     }
00300 
00310     public function shrink($sInput, $iMaxSize, $blRemoveNewline = true)
00311     {
00312         if ($blRemoveNewline) {
00313             $sInput = str_replace("\r\n", " ", $sInput);
00314             $sInput = str_replace("\n", " ", $sInput);
00315         }
00316 
00317         $sInput = str_replace("\t", "    ", $sInput);
00318 
00319         // remove html entities, remove html tags
00320         $sInput = $this->_unHTMLEntities(strip_tags($sInput));
00321 
00322         $oStr = getStr();
00323         if ($oStr->strlen($sInput) > $iMaxSize - 3) {
00324             $sInput = $oStr->substr($sInput, 0, $iMaxSize - 5) . "...";
00325         }
00326 
00327         return $sInput;
00328     }
00329 
00338     public function getCategoryString($oArticle, $sSeparator = "/")
00339     {
00340         $sCatStr = '';
00341 
00342         $sLang = oxRegistry::getLang()->getBaseLanguage();
00343         $oDB = oxDb::getDb();
00344 
00345         $sCatView = getViewName('oxcategories', $sLang);
00346         $sO2CView = getViewName('oxobject2category', $sLang);
00347 
00348         //selecting category
00349         $sQ = "select $sCatView.oxleft, $sCatView.oxright, $sCatView.oxrootid from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
00350         $sQ .= "where oxobject2category.oxobjectid=" . $oDB->quote($oArticle->getId()) . " and $sCatView.oxactive = 1 order by oxobject2category.oxtime ";
00351 
00352         $oRs = $oDB->execute($sQ);
00353         if ($oRs != false && $oRs->recordCount() > 0) {
00354             $sLeft = $oRs->fields[0];
00355             $sRight = $oRs->fields[1];
00356             $sRootId = $oRs->fields[2];
00357 
00358             //selecting all parent category titles
00359             $sQ = "select oxtitle from $sCatView where oxright >= {$sRight} and oxleft <= {$sLeft} and oxrootid = '{$sRootId}' order by oxleft ";
00360 
00361             $oRs = $oDB->execute($sQ);
00362             if ($oRs != false && $oRs->recordCount() > 0) {
00363                 while (!$oRs->EOF) {
00364                     if ($sCatStr) {
00365                         $sCatStr .= $sSeparator;
00366                     }
00367                     $sCatStr .= $oRs->fields[0];
00368                     $oRs->moveNext();
00369                 }
00370             }
00371         }
00372 
00373         return $sCatStr;
00374     }
00375 
00383     public function getDefaultCategoryString($oArticle)
00384     {
00385         $sLang = oxRegistry::getLang()->getBaseLanguage();
00386         $oDB = oxDb::getDb();
00387 
00388         $sCatView = getViewName('oxcategories', $sLang);
00389         $sO2CView = getViewName('oxobject2category', $sLang);
00390 
00391         //selecting category
00392         $sQ = "select $sCatView.oxtitle from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
00393         $sQ .= "where oxobject2category.oxobjectid=" . $oDB->quote($oArticle->getId()) . " and $sCatView.oxactive = 1 order by oxobject2category.oxtime ";
00394 
00395         return $oDB->getOne($sQ);
00396     }
00397 
00405     public function prepareCSV($sInput)
00406     {
00407         $sInput = oxRegistry::get("oxUtilsString")->prepareCSVField($sInput);
00408 
00409         return str_replace(array("&nbsp;", "&euro;", "|"), array(" ", "", ""), $sInput);
00410     }
00411 
00419     public function prepareXML($sInput)
00420     {
00421         $sOutput = str_replace("&", "&amp;", $sInput);
00422         $sOutput = str_replace("\"", "&quot;", $sOutput);
00423         $sOutput = str_replace(">", "&gt;", $sOutput);
00424         $sOutput = str_replace("<", "&lt;", $sOutput);
00425         $sOutput = str_replace("'", "&apos;", $sOutput);
00426 
00427         return $sOutput;
00428     }
00429 
00437     public function getDeepestCategoryPath($oArticle)
00438     {
00439         return $this->_findDeepestCatPath($oArticle);
00440     }
00441 
00447     public function prepareExport()
00448     {
00449         $oDB = oxDb::getDb();
00450         $sHeapTable = $this->_getHeapTableName();
00451 
00452         // #1070 Saulius 2005.11.28
00453         // check mySQL version
00454         $oRs = $oDB->execute("SHOW VARIABLES LIKE 'version'");
00455         $sTableCharset = $this->_generateTableCharSet($oRs->fields[1]);
00456 
00457         // create heap table
00458         if (!($this->_createHeapTable($sHeapTable, $sTableCharset))) {
00459             // error
00460             oxRegistry::getUtils()->showMessageAndExit("Could not create HEAP Table {$sHeapTable}\n<br>");
00461         }
00462 
00463         $sCatAdd = $this->_getCatAdd(oxRegistry::getConfig()->getRequestParameter("acat"));
00464         if (!$this->_insertArticles($sHeapTable, $sCatAdd)) {
00465             oxRegistry::getUtils()->showMessageAndExit("Could not insert Articles in Table {$sHeapTable}\n<br>");
00466         }
00467 
00468         $this->_removeParentArticles($sHeapTable);
00469         $this->_setSessionParams();
00470 
00471         // get total cnt
00472         return $oDB->getOne("select count(*) from {$sHeapTable}");
00473     }
00474 
00483     public function getOneArticle($iCnt, & $blContinue)
00484     {
00485         $myConfig = $this->getConfig();
00486 
00487         //[Alfonsas 2006-05-31] setting specific parameter
00488         //to be checked in oxarticle.php init() method
00489         $myConfig->setConfigParam('blExport', true);
00490         $blContinue = false;
00491 
00492         if (($oArticle = $this->_initArticle($this->_getHeapTableName(), $iCnt, $blContinue))) {
00493             $blContinue = true;
00494             $oArticle = $this->_setCampaignDetailLink($oArticle);
00495         }
00496 
00497         //[Alfonsas 2006-05-31] unsetting specific parameter
00498         //to be checked in oxarticle.php init() method
00499         $myConfig->setConfigParam('blExport', false);
00500 
00501         return $oArticle;
00502     }
00503 
00512     public function assureContent($sInput, $sReplace = null)
00513     {
00514         $oStr = getStr();
00515         if (!$oStr->strlen($sInput)) {
00516             if (!isset($sReplace) || !$oStr->strlen($sReplace)) {
00517                 $sReplace = "-";
00518             }
00519             $sInput = $sReplace;
00520         }
00521 
00522         return $sInput;
00523     }
00524 
00533     protected function _unHtmlEntities($sInput)
00534     {
00535         $aTransTbl = array_flip(get_html_translation_table(HTML_ENTITIES));
00536 
00537         return strtr($sInput, $aTransTbl);
00538     }
00539 
00545     protected function _getHeapTableName()
00546     {
00547         // table name must not start with any digit
00548         return "tmp_" . str_replace("0", "", md5($this->getSession()->getId()));
00549     }
00550 
00558     protected function _generateTableCharSet($sMysqlVersion)
00559     {
00560         $sTableCharset = "";
00561 
00562         //if MySQL >= 4.1.0 set charsets and collations
00563         if (version_compare($sMysqlVersion, '4.1.0', '>=') > 0) {
00564             $oDB = oxDb::getDb(oxDB::FETCH_MODE_ASSOC);
00565             $oRs = $oDB->execute("SHOW FULL COLUMNS FROM `oxarticles` WHERE field like 'OXID'");
00566             if (isset($oRs->fields['Collation']) && ($sMysqlCollation = $oRs->fields['Collation'])) {
00567                 $oRs = $oDB->execute("SHOW COLLATION LIKE '{$sMysqlCollation}'");
00568                 if (isset($oRs->fields['Charset']) && ($sMysqlCharacterSet = $oRs->fields['Charset'])) {
00569                     $sTableCharset = "DEFAULT CHARACTER SET {$sMysqlCharacterSet} COLLATE {$sMysqlCollation}";
00570                 }
00571             }
00572 
00573         }
00574 
00575         return $sTableCharset;
00576     }
00577 
00586     protected function _createHeapTable($sHeapTable, $sTableCharset)
00587     {
00588         $blDone = false;
00589 
00590         $oDB = oxDb::getDb();
00591         $sQ = "CREATE TABLE IF NOT EXISTS {$sHeapTable} ( `oxid` CHAR(32) NOT NULL default '' ) ENGINE=InnoDB {$sTableCharset}";
00592         if (($oDB->execute($sQ)) !== false) {
00593             $blDone = true;
00594             $oDB->execute("TRUNCATE TABLE {$sHeapTable}");
00595         }
00596 
00597         return $blDone;
00598     }
00599 
00607     protected function _getCatAdd($aChosenCat)
00608     {
00609         $sCatAdd = null;
00610         if (is_array($aChosenCat) && count($aChosenCat)) {
00611             $oDB = oxDb::getDb();
00612             $sCatAdd = " and ( ";
00613             $blSep = false;
00614             foreach ($aChosenCat as $sCat) {
00615                 if ($blSep) {
00616                     $sCatAdd .= " or ";
00617                 }
00618                 $sCatAdd .= "oxobject2category.oxcatnid = " . $oDB->quote($sCat);
00619                 $blSep = true;
00620             }
00621             $sCatAdd .= ")";
00622         }
00623 
00624         return $sCatAdd;
00625     }
00626 
00635     protected function _insertArticles($sHeapTable, $sCatAdd)
00636     {
00637         $oDB = oxDb::getDb();
00638 
00639         $iExpLang = oxRegistry::getConfig()->getRequestParameter("iExportLanguage");
00640         if (!isset($iExpLang)) {
00641             $iExpLang = oxRegistry::getSession()->getVariable("iExportLanguage");
00642         }
00643 
00644         $oArticle = oxNew('oxarticle');
00645         $oArticle->setLanguage($iExpLang);
00646 
00647         $sO2CView = getViewName('oxobject2category', $iExpLang);
00648         $sArticleTable = getViewName("oxarticles", $iExpLang);
00649 
00650         $sSelect = "insert into {$sHeapTable} select {$sArticleTable}.oxid from {$sArticleTable}, {$sO2CView} as oxobject2category where ";
00651         $sSelect .= $oArticle->getSqlActiveSnippet();
00652 
00653         if (!oxRegistry::getConfig()->getRequestParameter("blExportVars")) {
00654             $sSelect .= " and {$sArticleTable}.oxid = oxobject2category.oxobjectid and {$sArticleTable}.oxparentid = '' ";
00655         } else {
00656             $sSelect .= " and ( {$sArticleTable}.oxid = oxobject2category.oxobjectid or {$sArticleTable}.oxparentid = oxobject2category.oxobjectid ) ";
00657         }
00658 
00659         $sSearchString = oxRegistry::getConfig()->getRequestParameter("search");
00660         if (isset($sSearchString)) {
00661             $sSelect .= "and ( {$sArticleTable}.OXTITLE like " . $oDB->quote("%{$sSearchString}%");
00662             $sSelect .= " or {$sArticleTable}.OXSHORTDESC like " . $oDB->quote("%$sSearchString%");
00663             $sSelect .= " or {$sArticleTable}.oxsearchkeys like " . $oDB->quote("%$sSearchString%") . " ) ";
00664         }
00665 
00666         if ($sCatAdd) {
00667             $sSelect .= $sCatAdd;
00668         }
00669 
00670         if (!$sCatAdd) {
00671             $sShopID = $this->getConfig()->getShopId();
00672             $sSelect .= " and {$sArticleTable}.oxshopid = '$sShopID' ";
00673         }
00674 
00675         // add minimum stock value
00676         if ($this->getConfig()->getConfigParam('blUseStock') && ($dMinStock = oxRegistry::getConfig()->getRequestParameter("sExportMinStock"))) {
00677             $dMinStock = str_replace(array(";", " ", "/", "'"), "", $dMinStock);
00678             $sSelect .= " and {$sArticleTable}.oxstock >= " . $oDB->quote($dMinStock);
00679         }
00680 
00681         $sSelect .= " group by {$sArticleTable}.oxid";
00682 
00683         return $oDB->execute($sSelect) ? true : false;
00684     }
00685 
00691     protected function _removeParentArticles($sHeapTable)
00692     {
00693         if (!(oxRegistry::getConfig()->getRequestParameter("blExportMainVars"))) {
00694 
00695             $oDB = oxDb::getDb();
00696             $sArticleTable = getViewName('oxarticles');
00697 
00698             // we need to remove again parent articles so that we only have the variants itself
00699             $sQ = "select $sHeapTable.oxid from $sHeapTable, $sArticleTable where
00700                           $sHeapTable.oxid = $sArticleTable.oxparentid group by $sHeapTable.oxid";
00701 
00702             $oRs = $oDB->execute($sQ);
00703             $sDel = "delete from $sHeapTable where oxid in ( ";
00704             $blSep = false;
00705             if ($oRs != false && $oRs->recordCount() > 0) {
00706                 while (!$oRs->EOF) {
00707                     if ($blSep) {
00708                         $sDel .= ",";
00709                     }
00710                     $sDel .= $oDB->quote($oRs->fields[0]);
00711                     $blSep = true;
00712                     $oRs->moveNext();
00713                 }
00714             }
00715             $sDel .= " )";
00716             $oDB->execute($sDel);
00717         }
00718     }
00719 
00723     protected function _setSessionParams()
00724     {
00725         // reset it from session
00726         oxRegistry::getSession()->deleteVariable("sExportDelCost");
00727         $dDelCost = oxRegistry::getConfig()->getRequestParameter("sExportDelCost");
00728         if (isset($dDelCost)) {
00729             $dDelCost = str_replace(array(";", " ", "/", "'"), "", $dDelCost);
00730             $dDelCost = str_replace(",", ".", $dDelCost);
00731             oxRegistry::getSession()->setVariable("sExportDelCost", $dDelCost);
00732         }
00733 
00734         oxRegistry::getSession()->deleteVariable("sExportMinPrice");
00735         $dMinPrice = oxRegistry::getConfig()->getRequestParameter("sExportMinPrice");
00736         if (isset($dMinPrice)) {
00737             $dMinPrice = str_replace(array(";", " ", "/", "'"), "", $dMinPrice);
00738             $dMinPrice = str_replace(",", ".", $dMinPrice);
00739             oxRegistry::getSession()->setVariable("sExportMinPrice", $dMinPrice);
00740         }
00741 
00742         // #827
00743         oxRegistry::getSession()->deleteVariable("sExportCampaign");
00744         $sCampaign = oxRegistry::getConfig()->getRequestParameter("sExportCampaign");
00745         if (isset($sCampaign)) {
00746             $sCampaign = str_replace(array(";", " ", "/", "'"), "", $sCampaign);
00747             oxRegistry::getSession()->setVariable("sExportCampaign", $sCampaign);
00748         }
00749 
00750         // reset it from session
00751         oxRegistry::getSession()->deleteVariable("blAppendCatToCampaign");
00752         // now retrieve it from get or post.
00753         $blAppendCatToCampaign = oxRegistry::getConfig()->getRequestParameter("blAppendCatToCampaign");
00754         if ($blAppendCatToCampaign) {
00755             oxRegistry::getSession()->setVariable("blAppendCatToCampaign", $blAppendCatToCampaign);
00756         }
00757 
00758         // reset it from session
00759         oxRegistry::getSession()->deleteVariable("iExportLanguage");
00760         oxRegistry::getSession()->setVariable("iExportLanguage", oxRegistry::getConfig()->getRequestParameter("iExportLanguage"));
00761 
00762         //setting the custom header
00763         oxRegistry::getSession()->setVariable("sExportCustomHeader", oxRegistry::getConfig()->getRequestParameter("sExportCustomHeader"));
00764     }
00765 
00771     protected function _loadRootCats()
00772     {
00773         if ($this->_aCatLvlCache === null) {
00774             $this->_aCatLvlCache = array();
00775 
00776             $sCatView = getViewName('oxcategories');
00777             $oDb = oxDb::getDb();
00778 
00779             // Load all root cat's == all trees
00780             $sSQL = "select oxid from $sCatView where oxparentid = 'oxrootid'";
00781             $oRs = $oDb->execute($sSQL);
00782             if ($oRs != false && $oRs->recordCount() > 0) {
00783                 while (!$oRs->EOF) {
00784                     // now load each tree
00785                     $sSQL = "SELECT s.oxid, s.oxtitle,
00786                              s.oxparentid, count( * ) AS LEVEL FROM $sCatView v,
00787                              $sCatView s WHERE s.oxrootid = '" . $oRs->fields[0] . "' and
00788                              v.oxrootid='" . $oRs->fields[0] . "' and s.oxleft BETWEEN
00789                              v.oxleft AND v.oxright AND s.oxhidden = '0' GROUP BY s.oxleft order by level";
00790 
00791                     $oRs2 = $oDb->Execute($sSQL);
00792                     if ($oRs2 != false && $oRs2->recordCount() > 0) {
00793                         while (!$oRs2->EOF) {
00794                             // store it
00795                             $oCat = new stdClass();
00796                             $oCat->_sOXID = $oRs2->fields[0];
00797                             $oCat->oxtitle = $oRs2->fields[1];
00798                             $oCat->oxparentid = $oRs2->fields[2];
00799                             $oCat->ilevel = $oRs2->fields[3];
00800                             $this->_aCatLvlCache[$oCat->_sOXID] = $oCat;
00801 
00802                             $oRs2->moveNext();
00803                         }
00804                     }
00805                     $oRs->moveNext();
00806                 }
00807             }
00808         }
00809 
00810         return $this->_aCatLvlCache;
00811     }
00812 
00820     protected function _findDeepestCatPath($oArticle)
00821     {
00822         $sRet = "";
00823 
00824         // find deepest
00825         $aIds = $oArticle->getCategoryIds();
00826         if (is_array($aIds) && count($aIds)) {
00827             if ($aCatLvlCache = $this->_loadRootCats()) {
00828                 $sIdMax = null;
00829                 $dMaxLvl = 0;
00830                 foreach ($aIds as $sCatId) {
00831                     if ($dMaxLvl < $aCatLvlCache[$sCatId]->ilevel) {
00832                         $dMaxLvl = $aCatLvlCache[$sCatId]->ilevel;
00833                         $sIdMax = $sCatId;
00834                         $sRet = $aCatLvlCache[$sCatId]->oxtitle;
00835                     }
00836                 }
00837 
00838                 // endless
00839                 while (true) {
00840                     if (!isset($aCatLvlCache[$sIdMax]->oxparentid) || $aCatLvlCache[$sIdMax]->oxparentid == "oxrootid") {
00841                         break;
00842                     }
00843                     $sIdMax = $aCatLvlCache[$sIdMax]->oxparentid;
00844                     $sRet = $aCatLvlCache[$sIdMax]->oxtitle . "/" . $sRet;
00845                 }
00846             }
00847         }
00848 
00849         return $sRet;
00850     }
00851 
00861     protected function _initArticle($sHeapTable, $iCnt, & $blContinue)
00862     {
00863 
00864 
00865         $oRs = oxDb::getDb()->selectLimit("select oxid from $sHeapTable", 1, $iCnt);
00866         if ($oRs != false && $oRs->recordCount() > 0) {
00867             $oArticle = oxNew('oxarticle');
00868             $oArticle->setLoadParentData(true);
00869 
00870             $oArticle->setLanguage(oxRegistry::getSession()->getVariable("iExportLanguage"));
00871 
00872             if ($oArticle->load($oRs->fields[0])) {
00873                 // if article exists, do not stop export
00874                 $blContinue = true;
00875                 // check price
00876                 $dMinPrice = oxRegistry::getConfig()->getRequestParameter("sExportMinPrice");
00877                 if (!isset($dMinPrice) || (isset($dMinPrice) && ($oArticle->getPrice()->getBruttoPrice() >= $dMinPrice))) {
00878 
00879                     //Saulius: variant title added
00880                     $sTitle = $oArticle->oxarticles__oxvarselect->value ? " " . $oArticle->oxarticles__oxvarselect->value : "";
00881                     $oArticle->oxarticles__oxtitle->setValue($oArticle->oxarticles__oxtitle->value . $sTitle);
00882 
00883 
00884                     return $oArticle;
00885                 }
00886             }
00887         }
00888     }
00889 
00897     protected function _setCampaignDetailLink($oArticle)
00898     {
00899         // #827
00900         if ($sCampaign = oxRegistry::getConfig()->getRequestParameter("sExportCampaign")) {
00901             // modify detaillink
00902             //#1166R - pangora - campaign
00903             $oArticle->appendLink("campaign={$sCampaign}");
00904 
00905             if (oxRegistry::getConfig()->getRequestParameter("blAppendCatToCampaign") &&
00906                 ($sCat = $this->getCategoryString($oArticle))
00907             ) {
00908                 $oArticle->appendLink("/$sCat");
00909             }
00910         }
00911 
00912         return $oArticle;
00913     }
00914 
00920     public function getViewId()
00921     {
00922         return 'dyn_interface';
00923     }
00924 }