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 
00015 class DynExportBase extends oxAdminDetails
00016 {
00022     public $sClassDo            = "";
00023 
00029     public $sClassMain          = "";
00030 
00036     public $sExportPath          = "export/";
00037 
00043     public $sExportFileType      = "txt";
00044 
00050     public $sExportFileName      = "dynexport";
00051 
00057     public $fpFile               = null;
00058 
00065     public $iExportPerTick       = 30;
00066 
00072     protected $_iExportPerTick   = null;
00073 
00079     protected $_sFilePath        = null;
00080 
00086     protected $_aExportResultset = array();
00087 
00093     protected $_sThisTemplate = "dynexportbase.tpl";
00094 
00100     protected $_aCatLvlCache = null;
00101 
00107     public function __construct()
00108     {
00109         parent::__construct();
00110 
00111         // set generic frame template
00112         $this->_sFilePath = $this->getConfig()->getConfigParam( 'sShopDir' ) . "/". $this->sExportPath . $this->sExportFileName . "." . $this->sExportFileType;
00113     }
00114 
00121     public function render()
00122     {
00123         parent::render();
00124 
00125         // assign all member variables to template
00126         $aClassVars = get_object_vars( $this );
00127         while ( list( $name, $value ) = each( $aClassVars ) ) {
00128             $this->_aViewData[$name] = $value;
00129         }
00130 
00131         $this->_aViewData['sOutputFile']     = $this->_sFilePath;
00132         $this->_aViewData['sDownloadFile']   = $this->getConfig()->getConfigParam( 'sShopURL' ) . $this->sExportPath . $this->sExportFileName . "." . $this->sExportFileType;
00133 
00134         return $this->_sThisTemplate;
00135     }
00136 
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 
00161     public function start()
00162     {
00163         // delete file, if its already there
00164         $this->fpFile = @fopen( $this->_sFilePath, "w" );
00165         if ( !isset( $this->fpFile ) || !$this->fpFile ) {
00166             // we do have an error !
00167             $this->stop( ERR_FILEIO );
00168         } else {
00169             $this->_aViewData['refresh'] = 0;
00170             $this->_aViewData['iStart']  = 0;
00171             fclose( $this->fpFile );
00172 
00173             // prepare it
00174             $iEnd = $this->prepareExport();
00175             oxSession::setVar( "iEnd", $iEnd );
00176             $this->_aViewData['iEnd'] = $iEnd;
00177         }
00178     }
00179 
00187     public function stop( $iError = 0 )
00188     {
00189         if ( $iError ) {
00190             $this->_aViewData['iError'] = $iError;
00191         }
00192 
00193         // delete temporary heap table
00194         oxDb::getDb()->execute( "drop TABLE if exists ". $this->_getHeapTableName() );
00195     }
00196 
00204     public function nextTick( $iCnt)
00205     {
00206         return false;
00207     }
00208 
00216     public function write( $sLine )
00217     {
00218         $sLine = $this->removeSID( $sLine );
00219         $sLine = str_replace( array("\r\n","\n"), "", $sLine);
00220         fwrite( $this->fpFile, $sLine."\r\n");
00221     }
00222 
00228     public function run()
00229     {
00230         $blContinue = true;
00231         $iExportedItems = 0;
00232 
00233         $this->fpFile = @fopen( $this->_sFilePath, "a");
00234         if ( !isset( $this->fpFile) || !$this->fpFile) {
00235             // we do have an error !
00236             $this->stop( ERR_FILEIO);
00237         } else {
00238             // file is open
00239             $iStart = oxConfig::getParameter("iStart");
00240             // load from session
00241             $this->_aExportResultset = oxConfig::getParameter( "aExportResultset");
00242             $iExportPerTick = $this->getExportPerTick();
00243             for ( $i = $iStart; $i < $iStart + $iExportPerTick; $i++) {
00244                 if ( ( $iExportedItems = $this->nextTick( $i ) ) === false ) {
00245                     // end reached
00246                     $this->stop( ERR_SUCCESS);
00247                     $blContinue = false;
00248                     break;
00249                 }
00250             }
00251             if ( $blContinue) {
00252                 // make ticker continue
00253                 $this->_aViewData['refresh'] = 0;
00254                 $this->_aViewData['iStart']  = $i;
00255                 $this->_aViewData['iExpItems'] = $iExportedItems;
00256             }
00257             fclose( $this->fpFile);
00258         }
00259     }
00260 
00266     public function getExportPerTick()
00267     {
00268         if ( $this->_iExportPerTick === null ) {
00269             $this->_iExportPerTick = (int) oxRegistry::getConfig()->getConfigParam("iExportNrofLines");
00270             if ( !$this->_iExportPerTick ) {
00271                 $this->_iExportPerTick = $this->iExportPerTick;
00272             }
00273         }
00274         return $this->_iExportPerTick;
00275     }
00276 
00284     public function setExportPerTick( $iCount )
00285     {
00286         $this->_iExportPerTick = $iCount;
00287     }
00288 
00296     public function removeSid( $sInput )
00297     {
00298         $sSid = $this->getSession()->getId();
00299 
00300         // remove sid from link
00301         $sOutput = str_replace( "sid={$sSid}/", "", $sInput);
00302         $sOutput = str_replace( "sid/{$sSid}/", "", $sOutput);
00303         $sOutput = str_replace( "sid={$sSid}&amp;", "", $sOutput);
00304         $sOutput = str_replace( "sid={$sSid}&", "", $sOutput);
00305         $sOutput = str_replace( "sid={$sSid}", "", $sOutput);
00306 
00307         return $sOutput;
00308     }
00309 
00319     public function shrink( $sInput, $iMaxSize, $blRemoveNewline = true )
00320     {
00321         if ( $blRemoveNewline ) {
00322             $sInput = str_replace( "\r\n", " ", $sInput );
00323             $sInput = str_replace( "\n", " ", $sInput );
00324         }
00325 
00326         $sInput = str_replace( "\t", "    ", $sInput );
00327 
00328         // remove html entities, remove html tags
00329         $sInput = $this->_unHTMLEntities( strip_tags( $sInput ) );
00330 
00331         $oStr = getStr();
00332         if ( $oStr->strlen( $sInput ) > $iMaxSize - 3 ) {
00333             $sInput = $oStr->substr( $sInput, 0, $iMaxSize - 5 ) . "...";
00334         }
00335 
00336         return $sInput;
00337     }
00338 
00347     public function getCategoryString( $oArticle, $sSeparator = "/" )
00348     {
00349         $sCatStr = '';
00350 
00351         $sLang = oxRegistry::getLang()->getBaseLanguage();
00352         $oDB = oxDb::getDb();
00353 
00354         $sCatView = getViewName( 'oxcategories', $sLang );
00355         $sO2CView = getViewName( 'oxobject2category', $sLang );
00356 
00357         //selecting category
00358         $sQ  = "select $sCatView.oxleft, $sCatView.oxright, $sCatView.oxrootid from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
00359         $sQ .= "where oxobject2category.oxobjectid=".$oDB->quote( $oArticle->getId() )." and $sCatView.oxactive = 1 order by oxobject2category.oxtime ";
00360 
00361         $oRs = $oDB->execute( $sQ );
00362         if ( $oRs != false && $oRs->recordCount() > 0 ) {
00363             $sLeft   = $oRs->fields[0];
00364             $sRight  = $oRs->fields[1];
00365             $sRootId = $oRs->fields[2];
00366 
00367             //selecting all parent category titles
00368             $sQ = "select oxtitle from $sCatView where oxright >= {$sRight} and oxleft <= {$sLeft} and oxrootid = '{$sRootId}' order by oxleft ";
00369 
00370             $oRs = $oDB->execute( $sQ );
00371             if ( $oRs != false && $oRs->recordCount() > 0 ) {
00372                 while ( !$oRs->EOF ) {
00373                     if ( $sCatStr ) {
00374                         $sCatStr .= $sSeparator;
00375                     }
00376                     $sCatStr .= $oRs->fields[0];
00377                     $oRs->moveNext();
00378                 }
00379             }
00380         }
00381 
00382         return $sCatStr;
00383     }
00384 
00392     public function getDefaultCategoryString( $oArticle )
00393     {
00394         $sLang = oxRegistry::getLang()->getBaseLanguage();
00395         $oDB = oxDb::getDb();
00396 
00397         $sCatView = getViewName( 'oxcategories', $sLang );
00398         $sO2CView = getViewName( 'oxobject2category', $sLang );
00399 
00400         //selecting category
00401         $sQ =  "select $sCatView.oxtitle from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
00402         $sQ .= "where oxobject2category.oxobjectid=".$oDB->quote( $oArticle->getId() )." and $sCatView.oxactive = 1 order by oxobject2category.oxtime ";
00403 
00404         return $oDB->getOne( $sQ);
00405     }
00406 
00414     public function prepareCSV( $sInput )
00415     {
00416         $sInput = oxRegistry::get("oxUtilsString")->prepareCSVField( $sInput );
00417         return str_replace( array( "&nbsp;", "&euro;", "|" ), array( " ", "", "" ), $sInput );
00418     }
00419 
00427     public function prepareXML( $sInput )
00428     {
00429         $sOutput = str_replace( "&", "&amp;", $sInput );
00430         $sOutput = str_replace( "\"", "&quot;", $sOutput );
00431         $sOutput = str_replace( ">", "&gt;", $sOutput );
00432         $sOutput = str_replace( "<", "&lt;", $sOutput );
00433         $sOutput = str_replace( "'", "&apos;", $sOutput );
00434 
00435         return $sOutput;
00436     }
00437 
00445     public function getDeepestCategoryPath( $oArticle )
00446     {
00447         return $this->_findDeepestCatPath( $oArticle );
00448     }
00449 
00455     public function prepareExport()
00456     {
00457         $oDB = oxDb::getDb();
00458         $sHeapTable = $this->_getHeapTableName();
00459 
00460         // #1070 Saulius 2005.11.28
00461         // check mySQL version
00462         $oRs = $oDB->execute( "SHOW VARIABLES LIKE 'version'" );
00463         $sTableCharset = $this->_generateTableCharSet( $oRs->fields[1] );
00464 
00465         // create heap table
00466         if ( !( $this->_createHeapTable( $sHeapTable, $sTableCharset ) ) ) {
00467             // error
00468             oxRegistry::getUtils()->showMessageAndExit( "Could not create HEAP Table {$sHeapTable}\n<br>" );
00469         }
00470 
00471         $sCatAdd = $this->_getCatAdd( oxConfig::getParameter( "acat" ) );
00472         if ( !$this->_insertArticles( $sHeapTable, $sCatAdd ) ) {
00473             oxRegistry::getUtils()->showMessageAndExit( "Could not insert Articles in Table {$sHeapTable}\n<br>" );
00474         }
00475 
00476         $this->_removeParentArticles( $sHeapTable );
00477         $this->_setSessionParams();
00478 
00479         // get total cnt
00480         return $oDB->getOne( "select count(*) from {$sHeapTable}" );
00481     }
00482 
00491     public function getOneArticle( $iCnt, & $blContinue )
00492     {
00493         $myConfig  = $this->getConfig();
00494 
00495         //[Alfonsas 2006-05-31] setting specific parameter
00496         //to be checked in oxarticle.php init() method
00497         $myConfig->setConfigParam( 'blExport', true );
00498         $blContinue = false;
00499 
00500         if ( ( $oArticle = $this->_initArticle( $this->_getHeapTableName(), $iCnt, $blContinue ) ) ) {
00501             $blContinue = true;
00502             $oArticle = $this->_setCampaignDetailLink( $oArticle );
00503         }
00504 
00505         //[Alfonsas 2006-05-31] unsetting specific parameter
00506         //to be checked in oxarticle.php init() method
00507         $myConfig->setConfigParam( 'blExport', false );
00508 
00509         return $oArticle;
00510     }
00511 
00520     public function assureContent( $sInput, $sReplace = null)
00521     {
00522         $oStr = getStr();
00523         if ( !$oStr->strlen( $sInput ) ) {
00524             if ( !isset( $sReplace ) || !$oStr->strlen( $sReplace ) ) {
00525                 $sReplace = "-";
00526             }
00527             $sInput = $sReplace;
00528         }
00529         return $sInput;
00530     }
00531 
00540     protected function _unHtmlEntities( $sInput )
00541     {
00542         $aTransTbl = array_flip( get_html_translation_table( HTML_ENTITIES ) );
00543         return strtr( $sInput, $aTransTbl );
00544     }
00545 
00551     protected function _getHeapTableName()
00552     {
00553         // table name must not start with any digit
00554         return "tmp_".str_replace( "0", "", md5( $this->getSession()->getId() ) );
00555     }
00556 
00564     protected function _generateTableCharSet( $sMysqlVersion )
00565     {
00566         $sTableCharset = "";
00567 
00568         //if MySQL >= 4.1.0 set charsets and collations
00569         if ( version_compare( $sMysqlVersion, '4.1.0', '>=' ) > 0 ) {
00570             $oDB = oxDb::getDb( oxDB::FETCH_MODE_ASSOC );
00571             $oRs = $oDB->execute( "SHOW FULL COLUMNS FROM `oxarticles` WHERE field like 'OXID'" );
00572             if ( isset( $oRs->fields['Collation'] ) && ( $sMysqlCollation = $oRs->fields['Collation'] ) ) {
00573                 $oRs = $oDB->execute( "SHOW COLLATION LIKE '{$sMysqlCollation}'" );
00574                 if ( isset( $oRs->fields['Charset'] ) && ( $sMysqlCharacterSet = $oRs->fields['Charset'] ) ) {
00575                     $sTableCharset = "DEFAULT CHARACTER SET {$sMysqlCharacterSet} COLLATE {$sMysqlCollation}";
00576                 }
00577             }
00578 
00579         }
00580         return $sTableCharset;
00581     }
00582 
00591     protected function _createHeapTable( $sHeapTable, $sTableCharset )
00592     {
00593         $blDone = false;
00594 
00595         $oDB = oxDb::getDb();
00596         $sQ = "CREATE TABLE IF NOT EXISTS {$sHeapTable} ( `oxid` CHAR(32) NOT NULL default '' ) ENGINE=InnoDB {$sTableCharset}";
00597         if ( ( $oDB->execute( $sQ ) ) !== false ) {
00598             $blDone = true;
00599             $oDB->execute( "TRUNCATE TABLE {$sHeapTable}" );
00600         }
00601 
00602         return $blDone;
00603     }
00604 
00612     protected function _getCatAdd( $aChosenCat )
00613     {
00614         $sCatAdd = null;
00615         if ( is_array( $aChosenCat ) && count( $aChosenCat ) ) {
00616             $oDB = oxDb::getDb();
00617             $sCatAdd = " and ( ";
00618             $blSep = false;
00619             foreach ( $aChosenCat as $sCat ) {
00620                 if ( $blSep ) {
00621                     $sCatAdd .= " or ";
00622                 }
00623                 $sCatAdd .= "oxobject2category.oxcatnid = ".$oDB->quote( $sCat );
00624                 $blSep = true;
00625             }
00626             $sCatAdd .= ")";
00627         }
00628         return $sCatAdd;
00629     }
00630 
00639     protected function _insertArticles( $sHeapTable, $sCatAdd )
00640     {
00641         $oDB = oxDb::getDb();
00642 
00643         $iExpLang = oxConfig::getParameter( "iExportLanguage" );
00644         if (!isset($iExpLang)) {
00645             $iExpLang = oxSession::getVar( "iExportLanguage" );
00646         }
00647 
00648         $oArticle = oxNew( 'oxarticle' );
00649         $oArticle->setLanguage( $iExpLang );
00650 
00651         $sO2CView = getViewName( 'oxobject2category', $iExpLang );
00652         $sArticleTable = getViewName( "oxarticles", $iExpLang );
00653 
00654         $sSelect  = "insert into {$sHeapTable} select {$sArticleTable}.oxid from {$sArticleTable}, {$sO2CView} as oxobject2category where ";
00655         $sSelect .= $oArticle->getSqlActiveSnippet();
00656 
00657         if ( ! oxConfig::getParameter( "blExportVars" ) ) {
00658             $sSelect .= " and {$sArticleTable}.oxid = oxobject2category.oxobjectid and {$sArticleTable}.oxparentid = '' ";
00659         } else {
00660             $sSelect .= " and ( {$sArticleTable}.oxid = oxobject2category.oxobjectid or {$sArticleTable}.oxparentid = oxobject2category.oxobjectid ) ";
00661         }
00662 
00663         $sSearchString = oxConfig::getParameter( "search" );
00664         if ( isset( $sSearchString ) ) {
00665             $sSelect .= "and ( {$sArticleTable}.OXTITLE like ".$oDB->quote( "%{$sSearchString}%" );
00666             $sSelect .= " or {$sArticleTable}.OXSHORTDESC like ".$oDB->quote( "%$sSearchString%" );
00667             $sSelect .= " or {$sArticleTable}.oxsearchkeys like ".$oDB->quote( "%$sSearchString%" ) ." ) ";
00668         }
00669 
00670         if ( $sCatAdd ) {
00671             $sSelect .= $sCatAdd;
00672         }
00673 
00674             if ( !$sCatAdd ) {
00675                 $sShopID = $this->getConfig()->getShopId();
00676                 $sSelect .= " and {$sArticleTable}.oxshopid = '$sShopID' ";
00677             }
00678 
00679         // add minimum stock value
00680         if ( $this->getConfig()->getConfigParam( 'blUseStock' ) && ( $dMinStock = oxConfig::getParameter( "sExportMinStock" ) ) ) {
00681             $dMinStock = str_replace( array( ";", " ", "/", "'"), "", $dMinStock );
00682             $sSelect .= " and {$sArticleTable}.oxstock >= ".$oDB->quote( $dMinStock );
00683         }
00684 
00685         $sSelect .= " group by {$sArticleTable}.oxid";
00686 
00687         return $oDB->execute( $sSelect ) ? true : false;
00688     }
00689 
00697     protected function _removeParentArticles( $sHeapTable )
00698     {
00699         if ( !( oxConfig::getParameter( "blExportMainVars" ) ) ) {
00700 
00701             $oDB = oxDb::getDb();
00702             $sArticleTable = getViewName('oxarticles');
00703 
00704             // we need to remove again parent articles so that we only have the variants itself
00705             $sQ = "select $sHeapTable.oxid from $sHeapTable, $sArticleTable where
00706                           $sHeapTable.oxid = $sArticleTable.oxparentid group by $sHeapTable.oxid";
00707 
00708             $oRs = $oDB->execute( $sQ );
00709             $sDel = "delete from $sHeapTable where oxid in ( ";
00710             $blSep = false;
00711             if ($oRs != false && $oRs->recordCount() > 0) {
00712                 while ( !$oRs->EOF ) {
00713                     if ( $blSep ) {
00714                         $sDel .= ",";
00715                     }
00716                     $sDel .= $oDB->quote( $oRs->fields[0] );
00717                     $blSep = true;
00718                     $oRs->moveNext();
00719                 }
00720             }
00721             $sDel .= " )";
00722             $oDB->execute( $sDel );
00723         }
00724     }
00725 
00732     protected function _setSessionParams()
00733     {
00734         // reset it from session
00735         oxSession::deleteVar( "sExportDelCost" );
00736         $dDelCost = oxConfig::getParameter( "sExportDelCost");
00737         if ( isset( $dDelCost ) ) {
00738             $dDelCost = str_replace( array( ";", " ", "/", "'"), "", $dDelCost );
00739             $dDelCost = str_replace( ",", ".", $dDelCost );
00740             oxSession::setVar( "sExportDelCost", $dDelCost );
00741         }
00742 
00743         oxSession::deleteVar( "sExportMinPrice" );
00744         $dMinPrice = oxConfig::getParameter( "sExportMinPrice" );
00745         if ( isset( $dMinPrice ) ) {
00746             $dMinPrice = str_replace( array( ";", " ", "/", "'"), "", $dMinPrice);
00747             $dMinPrice = str_replace( ",", ".", $dMinPrice);
00748             oxSession::setVar( "sExportMinPrice", $dMinPrice);
00749         }
00750 
00751         // #827
00752         oxSession::deleteVar( "sExportCampaign" );
00753         $sCampaign = oxConfig::getParameter( "sExportCampaign" );
00754         if ( isset( $sCampaign ) ) {
00755             $sCampaign = str_replace( array( ";", " ", "/", "'"), "", $sCampaign );
00756             oxSession::setVar( "sExportCampaign", $sCampaign );
00757         }
00758 
00759         // reset it from session
00760         oxSession::deleteVar("blAppendCatToCampaign" );
00761         // now retrieve it from get or post.
00762         $blAppendCatToCampaign = oxConfig::getParameter( "blAppendCatToCampaign" );
00763         if ( $blAppendCatToCampaign ) {
00764             oxSession::setVar( "blAppendCatToCampaign", $blAppendCatToCampaign );
00765         }
00766 
00767         // reset it from session
00768         oxSession::deleteVar("iExportLanguage" );
00769         oxSession::setVar( "iExportLanguage", oxConfig::getParameter( "iExportLanguage" ) );
00770 
00771         //setting the custom header
00772         oxSession::setVar("sExportCustomHeader", oxConfig::getParameter( "sExportCustomHeader" ));
00773     }
00774 
00780     protected function _loadRootCats()
00781     {
00782         if ( $this->_aCatLvlCache === null ) {
00783             $this->_aCatLvlCache = array();
00784 
00785             $sCatView = getViewName('oxcategories');
00786             $oDb = oxDb::getDb();
00787 
00788             // Load all root cat's == all trees
00789             $sSQL = "select oxid from $sCatView where oxparentid = 'oxrootid'";
00790             $oRs = $oDb->execute( $sSQL);
00791             if ( $oRs != false && $oRs->recordCount() > 0 ) {
00792                 while ( !$oRs->EOF ) {
00793                     // now load each tree
00794                     $sSQL = "SELECT s.oxid, s.oxtitle,
00795                              s.oxparentid, count( * ) AS LEVEL FROM $sCatView v,
00796                              $sCatView s WHERE s.oxrootid = '".$oRs->fields[0]."' and
00797                              v.oxrootid='".$oRs->fields[0]."' and s.oxleft BETWEEN
00798                              v.oxleft AND v.oxright AND s.oxhidden = '0' GROUP BY s.oxleft order by level";
00799 
00800                     $oRs2 = $oDb->Execute( $sSQL );
00801                     if ( $oRs2 != false && $oRs2->recordCount() > 0 ) {
00802                         while ( !$oRs2->EOF ) {
00803                             // store it
00804                             $oCat = new stdClass();
00805                             $oCat->_sOXID     = $oRs2->fields[0];
00806                             $oCat->oxtitle    = $oRs2->fields[1];
00807                             $oCat->oxparentid = $oRs2->fields[2];
00808                             $oCat->ilevel     = $oRs2->fields[3];
00809                             $this->_aCatLvlCache[$oCat->_sOXID] = $oCat;
00810 
00811                             $oRs2->moveNext();
00812                         }
00813                     }
00814                     $oRs->moveNext();
00815                 }
00816             }
00817         }
00818 
00819         return $this->_aCatLvlCache;
00820     }
00821 
00829     protected function _findDeepestCatPath( $oArticle )
00830     {
00831         $sRet = "";
00832 
00833         // find deepest
00834         $aIds = $oArticle->getCategoryIds();
00835         if ( is_array( $aIds ) && count( $aIds ) ) {
00836             if ( $aCatLvlCache = $this->_loadRootCats() ) {
00837                 $sIdMax  = null;
00838                 $dMaxLvl = 0;
00839                 foreach ( $aIds as $sCatId ) {
00840                     if ( $dMaxLvl < $aCatLvlCache[$sCatId]->ilevel ) {
00841                         $dMaxLvl = $aCatLvlCache[$sCatId]->ilevel;
00842                         $sIdMax  = $sCatId;
00843                         $sRet    = $aCatLvlCache[$sCatId]->oxtitle;
00844                     }
00845                 }
00846 
00847                 // endless
00848                 for ( ;; ) {
00849                     if ( !isset( $aCatLvlCache[$sIdMax]->oxparentid ) || $aCatLvlCache[$sIdMax]->oxparentid == "oxrootid" ) {
00850                         break;
00851                     }
00852                     $sIdMax = $aCatLvlCache[$sIdMax]->oxparentid;
00853                     $sRet = $aCatLvlCache[$sIdMax]->oxtitle."/".$sRet;
00854                 }
00855             }
00856         }
00857         return $sRet;
00858     }
00859 
00869     protected function _initArticle( $sHeapTable, $iCnt, & $blContinue )
00870     {
00871 
00872 
00873         $oRs = oxDb::getDb()->selectLimit( "select oxid from $sHeapTable", 1, $iCnt );
00874         if ( $oRs != false && $oRs->recordCount() > 0 ) {
00875             $oArticle = oxNew( 'oxarticle' );
00876             $oArticle->setLoadParentData( true );
00877 
00878             $oArticle->setLanguage( oxSession::getVar( "iExportLanguage" ) );
00879 
00880             if ( $oArticle->load( $oRs->fields[0] ) ) {
00881                 // if article exists, do not stop export
00882                 $blContinue = true;
00883                 // check price
00884                 $dMinPrice = oxConfig::getParameter( "sExportMinPrice" );
00885                 if ( !isset( $dMinPrice ) || ( isset( $dMinPrice ) && ( $oArticle->getPrice()->getBruttoPrice() >= $dMinPrice ) ) ) {
00886 
00887                     //Saulius: variant title added
00888                     $sTitle = $oArticle->oxarticles__oxvarselect->value ? " " .$oArticle->oxarticles__oxvarselect->value : "";
00889                     $oArticle->oxarticles__oxtitle->setValue( $oArticle->oxarticles__oxtitle->value . $sTitle );
00890 
00891 
00892                     return $oArticle;
00893                 }
00894             }
00895         }
00896     }
00897 
00905     protected function _setCampaignDetailLink( $oArticle )
00906     {
00907         // #827
00908         if ( $sCampaign = oxConfig::getParameter( "sExportCampaign" ) ) {
00909             // modify detaillink
00910             //#1166R - pangora - campaign
00911             $oArticle->appendLink( "campaign={$sCampaign}" );
00912 
00913             if ( oxConfig::getParameter( "blAppendCatToCampaign") &&
00914                  ( $sCat = $this->getCategoryString( $oArticle ) ) ) {
00915                 $oArticle->appendLink( "/$sCat" );
00916             }
00917         }
00918         return $oArticle;
00919     }
00920 
00926     public function getViewId()
00927     {
00928         return 'dyn_interface';
00929     }
00930 }
00931