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 
00010 
00016 class DynExportBase extends oxAdminDetails
00017 {
00018     public $sClass_do            = "";
00019     public $sClass_main          = "";
00020 
00021     //output paths and files
00022     public $sExportPath          = "export/";
00023     public $sExportFileType      = "txt";
00024     public $sExportFileName      = "dynexport";
00025     public $fpFile               = null;
00026     public $iExportPerTick       = 30;
00027 
00028     // protected
00029     protected $_sFilePath        = null;
00030     protected $_aExportResultset = array();
00031 
00032     protected $_sThisTemplate = "dynexportbase.tpl";
00033 
00034 
00039     public function __construct()
00040     {
00041         parent::__construct();
00042 
00043         // set generic frame template
00044         $this->_sFilePath = $this->getConfig()->getConfigParam( 'sShopDir' ) . "/". $this->sExportPath . $this->sExportFileName . "." . $this->sExportFileType;
00045 
00046     }
00047 
00054     public function render()
00055     {
00056         parent::render();
00057 
00058         // assign all member variables to template
00059         $aClass_vars = get_object_vars( $this);
00060         while (list($name, $value) = each($aClass_vars)) {
00061             $this->_aViewData[$name] = $value;
00062         }
00063 
00064         $this->_aViewData['sOutputFile']     = $this->_sFilePath;
00065         $this->_aViewData['sDownloadFile']   = $this->getConfig()->getConfigParam( 'sShopURL' ) . $this->sExportPath . $this->sExportFileName . "." . $this->sExportFileType;
00066 
00067         return $this->_sThisTemplate;
00068     }
00069 
00075     public function createMainExportView()
00076     {
00077         $myConfig = $this->getConfig();
00078         // parent categorie tree
00079         $oCatTree = oxNew( "oxCategoryList" );
00080         $oCatTree->buildList($myConfig->getConfigParam( 'bl_perfLoadCatTree' ));
00081         $this->_aViewData["cattree"] =  $oCatTree;
00082 
00083         // Countries for calculating delivery costs
00084         //$oCountries = oxNew( "oxCountryList" );
00085         //$oCountries->select();
00086 
00087         /*$aCountries = array("Deutschland", "Österreich", "Schweiz", "Liechtenstein", "Italien",
00088                             "Luxemburg", "Frankreich", "Schweden", "Finnland", "Grossbritannien",
00089                             "Irland", "Holland", "Belgien", "Portugal", "Spanien", "Griechenland");
00090 
00091         foreach ($aCountries as $sCountry)
00092         {
00093             $oCountry->oxcountry__oxid->value = $sCountry;
00094             $oCountry->oxcountry__oxtitle->value = $sCountry;
00095             $oCountries[] = $oCountry;
00096         }
00097 
00098         $this->_aViewData["countrylist"] =  $oCountries;
00099         */
00100     }
00101 
00107     public function start()
00108     {
00109         // delete file, if its already there
00110         $this->fpFile = @fopen( $this->_sFilePath, "w");
00111         if ( !isset( $this->fpFile) || !$this->fpFile) {
00112             // we do have an error !
00113             $this->stop( ERR_FILEIO);
00114         } else {
00115             $this->_aViewData['refresh'] = 0;
00116             $this->_aViewData['iStart']  = 0;
00117             fclose( $this->fpFile);
00118 
00119             // prepare it
00120             $iEnd = $this->prepareExport();
00121             oxSession::setVar( "iEnd", $iEnd);
00122             $this->_aViewData['iEnd'] = $iEnd;
00123         }
00124     }
00125 
00133     public function stop( $iError = 0)
00134     {
00135         if ( $iError) {
00136             $this->_aViewData['iError'] = $iError;
00137         }
00138 
00139         // delete temporary heap table
00140         $sHeapTable = $this->_getHeapTableName();
00141         oxDb::getDb()->Execute( "drop TABLE if exists $sHeapTable ");
00142     }
00143 
00151     public function nextTick( $iCnt)
00152     {
00153         return false;
00154     }
00155 
00163     public function write( $sLine)
00164     {
00165 
00166         $sLine = $this->removeSID( $sLine);
00167         $sLine = str_replace( array("\r\n","\n"), "", $sLine);
00168         fwrite( $this->fpFile, $sLine."\r\n");
00169     }
00170 
00176     public function run()
00177     {
00178         $blContinue = true;
00179         $iExportedItems = 0;
00180 
00181         $this->fpFile = @fopen( $this->_sFilePath, "a");
00182         if ( !isset( $this->fpFile) || !$this->fpFile) {
00183             // we do have an error !
00184             $this->stop( ERR_FILEIO);
00185         } else {
00186             // file is open
00187             $iStart = oxConfig::getParameter("iStart");
00188             // load from session
00189             $this->_aExportResultset = oxConfig::getParameter( "aExportResultset");
00190 
00191             for ( $i = $iStart; $i < $iStart + $this->iExportPerTick; $i++) {
00192                 if ( ( $iExportedItems = $this->nextTick( $i ) ) === false ) {
00193                     // end reached
00194                     $this->stop( ERR_SUCCESS);
00195                     $blContinue = false;
00196                     break;
00197                 }
00198             }
00199             if ( $blContinue) {
00200                 // make ticker continue
00201                 $this->_aViewData['refresh'] = 0;
00202                 $this->_aViewData['iStart']  = $i;
00203                 $this->_aViewData['iExpItems'] = $iExportedItems;
00204             }
00205             fclose( $this->fpFile);
00206         }
00207     }
00208 
00216     public function removeSID( $sInput)
00217     {
00218 
00219         $mySession = $this->getSession();
00220 
00221         // remove sid from link
00222         $sOutput = str_replace( "sid=".$mySession->getId()."/", "", $sInput);
00223         $sOutput = str_replace( "sid/".$mySession->getId()."/", "", $sOutput);
00224         $sOutput = str_replace( "sid=".$mySession->getId()."&amp;", "", $sOutput);
00225         $sOutput = str_replace( "sid=".$mySession->getId()."&", "", $sOutput);
00226         $sOutput = str_replace( "sid=".$mySession->getId(), "", $sOutput);
00227 
00228         return $sOutput;
00229     }
00230 
00240     public function shrink( $sInput, $iMaxSize, $blRemoveNewline = true)
00241     {
00242 
00243         if ( $blRemoveNewline) {
00244             $sOutput = str_replace( "\r\n", " ", $sInput);
00245             $sOutput = str_replace( "\n", " ", $sOutput);
00246         } else {
00247             $sOutput = $sInput;
00248         }
00249 
00250         $sOutput = str_replace( "\t", "    ", $sOutput);
00251         // remove html entities, remove html tags
00252         $sOutput = $this->_unHTMLEntities( strip_tags( $sOutput));
00253 
00254         $oStr = getStr();
00255         if ( $oStr->strlen( $sOutput) > $iMaxSize - 3) {
00256             $sOutput = $oStr->substr( $sOutput, 0, $iMaxSize - 5) . "...";
00257         }
00258         return $sOutput;
00259     }
00260 
00269     public function getCategoryString( & $oArticle, $sSeparator = "/")
00270     {
00271         $sLang = oxLang::getInstance()->getBaseLanguage();
00272         $oDB = oxDb::getDb();
00273 
00274         $sCatView = getViewName('oxcategories');
00275         $sO2CView = getViewName('oxobject2category');
00276 
00277         //selecting category
00278         $sQ =  "select oxobject2category.oxcatnid, $sCatView.oxleft, $sCatView.oxright, $sCatView.oxrootid from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
00279         $sQ .= "where oxobject2category.oxobjectid='".$oArticle->getId()."' and $sCatView.oxactive".(($sLang)?"_$sLang":"")." = 1 order by oxobject2category.oxtime ";
00280 
00281         $aRet = array();
00282         $rs = $oDB->execute( $sQ);
00283         if ($rs != false && $rs->recordCount() > 0) {
00284             $sCatID = $rs->fields[0];
00285             $sLeft = $rs->fields[1];
00286             $sRight = $rs->fields[2];
00287             $sRootID = $rs->fields[3];
00288 
00289             //selecting all parent category titles
00290                 $sQ  = "select oxtitle".(($sLang)?"_$sLang":"")." from oxcategories where ";
00291                 $sQ .= "oxrootid = '$sRootID' and oxright >= $sRight and oxleft <= $sLeft order by oxleft ";
00292 
00293             $rs = $oDB->execute( $sQ);
00294             if ($rs != false && $rs->recordCount() > 0) {
00295                 while (!$rs->EOF) {
00296                     $aRet[] = $rs->fields[0];
00297                     $rs->moveNext();
00298                 }
00299             }
00300         }
00301         $sRet = implode($sSeparator, $aRet);
00302         return $sRet;
00303     }
00304 
00312     public function getDefaultCategoryString($oArticle)
00313     {
00314         $sLang = oxLang::getInstance()->getBaseLanguage();
00315         $oDB = oxDb::getDb();
00316 
00317         $sCatView = getViewName('oxcategories');
00318         $sO2CView = getViewName('oxobject2category');
00319 
00320         //selecting category
00321         $sQ =  "select $sCatView.oxtitle".(($sLang)?"_$sLang":"")." from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
00322         $sQ .= "where oxobject2category.oxobjectid='".$oArticle->getId()."' and $sCatView.oxactive".(($sLang)?"_$sLang":"")." = 1 order by oxobject2category.oxtime ";
00323 
00324         $rs = $oDB->getOne( $sQ);
00325 
00326         return $rs;
00327     }
00328 
00336     public function prepareCSV( $sInput)
00337     {
00338         $sInput = oxUtilsString::getInstance()->prepareCSVField( $sInput);
00339         $sOutput = str_replace( "&nbsp;", " ", $sInput);
00340         $sOutput = str_replace( "&euro;", "€", $sOutput);
00341         $sOutput = str_replace( "|", "", $sOutput);
00342 
00343         return $sOutput;
00344     }
00345 
00353     public function prepareXML($sInput)
00354     {
00355 
00356         $sOutput = str_replace("&", "&amp;", $sInput);
00357         $sOutput = str_replace("\"", "&quot;", $sOutput);
00358         $sOutput = str_replace(">", "&gt;", $sOutput);
00359         $sOutput = str_replace("<", "&lt;", $sOutput);
00360         $sOutput = str_replace("'", "&apos;", $sOutput);
00361         return $sOutput;
00362     }
00363 
00371     public function getDeepestCategoryPath( & $oArticle)
00372     {
00373         $sRet = "";
00374         $this->_loadRootCats();
00375         $sRet = $this->_findDeepestCatPath($oArticle);
00376 
00377         return $sRet;
00378     }
00379 
00385     public function prepareExport()
00386     {
00387         $oDB = oxDb::getDb();
00388 
00389         $sHeapTable = $this->_getHeapTableName();
00390 
00391         // #1070 Saulius 2005.11.28
00392         // check mySQL version
00393 
00394         $rs = $oDB->execute("SHOW VARIABLES LIKE 'version'");
00395         $sMysqlVersion = $rs->fields[1];
00396 
00397         $sTableCharset = $this->_generateTableCharSet($sMysqlVersion);
00398 
00399         // create heap table
00400         $blRet = $this->_createHeapTable($sHeapTable, $sTableCharset);
00401         if ( $blRet == false) {
00402             // error
00403             die( "Could not create HEAP Table $sHeapTable\n<br>");
00404         }
00405 
00406         $aChosenCat = oxConfig::getParameter( "acat");
00407         $sCatAdd = $this->_getCatAdd($aChosenCat);
00408 
00409         if ( !$this->_insertArticles($sHeapTable, $sCatAdd) ) {
00410             die( "Could not insert Articles in Table $sHeapTable\n<br>");
00411         }
00412 
00413         /* commented due to upper changes
00414         if( isset( $blExportVars) && $blExportVars)
00415         {   // now add variants if there are some
00416             $oDB->Execute( "insert into ".$sHeapTable." select oxarticles.oxid from oxarticles, $sHeapTable where oxarticles.oxparentid = $sHeapTable.oxid AND ".oxDb::getInstance()->getActiveSnippet( "oxarticles"));
00417         }*/
00418         $this->_removeParentArticles($sHeapTable);
00419         $this->_setSessionParams();
00420 
00421         // get total cnt
00422         $iCnt = $oDB->getOne("select count(*) from $sHeapTable");
00423 
00424         return $iCnt;
00425     }
00426 
00435     public function getOneArticle( $iCnt, & $blContinue)
00436     {
00437         $myConfig  = $this->getConfig();
00438         //[Alfonsas 2006-05-31] setting specific parameter
00439         //to be checked in oxarticle.php init() method
00440         $myConfig->setConfigParam( 'blExport', true );
00441 
00442         $oArticle   = null;
00443         $blContinue = true;
00444 
00445         $sHeapTable = $this->_getHeapTableName();
00446 
00447         $oArticle = $this->_initArticle($sHeapTable, $iCnt);
00448         if (!isset($oArticle)) {
00449             $blContinue = false;
00450             return null;
00451         }
00452 
00453         $oArticle = $this->_setCampaignDetailLink($oArticle);
00454 
00455         //[Alfonsas 2006-05-31] unsetting specific parameter
00456         //to be checked in oxarticle.php init() method
00457         $myConfig->setConfigParam( 'blExport', false );
00458 
00459         return $oArticle;
00460     }
00461 
00470     public function assureContent( $sInput, $sReplace = null)
00471     {
00472         if ( !strlen( $sInput)) {
00473             if ( !isset( $sReplace) || !strlen($sReplace)) {
00474                 $sReplace = "-";
00475             }
00476             $sInput = $sReplace;
00477         }
00478         return $sInput;
00479     }
00480 
00489     protected function _unHTMLEntities( $sInput)
00490     {
00491 
00492         $trans_tbl = get_html_translation_table(HTML_ENTITIES);
00493         $trans_tbl = array_flip($trans_tbl);
00494         return strtr( $sInput, $trans_tbl);
00495     }
00496 
00502     protected function _getHeapTableName()
00503     {
00504         $mySession = $this->getSession();
00505 
00506         // table name must not start with any digit
00507         $sHeapname = "tmp_".str_replace( "0", "", md5($mySession->getId()));
00508 
00509         return $sHeapname;
00510     }
00511 
00519     private function _generateTableCharSet($sMysqlVersion)
00520     {
00521         $oDB = oxDb::getDb(true);
00522 
00523         //if MySQL >= 4.1.0 set charsets and collations
00524         if (version_compare($sMysqlVersion, '4.1.0', '>=')>0) {
00525             $sMysqlCharacterSet = null;
00526             $sMysqlCollation = null;
00527             $rs = $oDB->execute( "SHOW FULL COLUMNS FROM `oxarticles` WHERE field like 'OXID'" );
00528             if ( isset( $rs->fields['Collation'] ) && ( $sMysqlCollation = $rs->fields['Collation'] ) ) {
00529                 $rs = $oDB->execute( "SHOW COLLATION LIKE '{$sMysqlCollation}'" );
00530                 if ( isset( $rs->fields['Charset'] ) ) {
00531                     $sMysqlCharacterSet = $rs->fields['Charset'];
00532                 }
00533             }
00534 
00535             if ( $sMysqlCollation && $sMysqlCharacterSet ) {
00536                 $sTableCharset = "DEFAULT CHARACTER SET ".$sMysqlCharacterSet." COLLATE ".$sMysqlCollation;
00537             } else {
00538                 $sTableCharset = "";
00539             }
00540         } else {
00541             $sTableCharset = "";
00542         }
00543         return $sTableCharset;
00544     }
00545 
00554     private function _createHeapTable($sHeapTable, $sTableCharset)
00555     {
00556 
00557         $oDB = oxDb::getDb();
00558 
00559         $sSQL = "CREATE TABLE if not exists $sHeapTable ( oxid char(32) NOT NULL default '' ) TYPE=HEAP ".$sTableCharset;
00560 
00561         $rs = $oDB->execute( $sSQL);
00562         if ( $rs == false) {
00563             // error
00564             return false;
00565         }
00566         $oDB->execute( "truncate table $sHeapTable ");
00567         return true;
00568     }
00569 
00577     private function _getCatAdd($aChosenCat)
00578     {
00579 
00580         $sCatAdd        = null;
00581         if ( isset( $aChosenCat)) {
00582             $sCatAdd = " and ( ";
00583             $blSep = false;
00584             foreach ( $aChosenCat as $sCat) {
00585                 if ( $blSep) {
00586                     $sCatAdd .= " or ";
00587                 }
00588                 $sCatAdd .= "oxobject2category.oxcatnid = '$sCat'";
00589                 $blSep = true;
00590             }
00591             $sCatAdd .= ")";
00592         }
00593         return $sCatAdd;
00594     }
00595 
00604     private function _insertArticles($sHeapTable, $sCatAdd)
00605     {
00606         $oDB = oxDb::getDb();
00607         $sSearchString = oxConfig::getParameter( "search");
00608         $blExportVars  = oxConfig::getParameter( "blExportVars");
00609 
00610         $language = oxLang::getInstance()->getLanguageTag( 0);
00611         $sShopID = $this->getConfig()->getShopID();
00612 
00613         $sO2CView = getViewName('oxobject2category');
00614         $oArticle = oxNew( 'oxarticle' );
00615         $sArticleTable = $oArticle->getViewName();
00616 
00617         $sSelect  = "insert into $sHeapTable select $sArticleTable.oxid from $sArticleTable, $sO2CView as oxobject2category where ";
00618         $sSelect .= $oArticle->getSqlActiveSnippet();
00619 
00620         if ( !$blExportVars) {
00621             $sSelect .= " and $sArticleTable.oxid = oxobject2category.oxobjectid and $sArticleTable.oxparentid='' ";
00622         } else {
00623             $sSelect .= " and ( $sArticleTable.oxid = oxobject2category.oxobjectid or $sArticleTable.oxparentid = oxobject2category.oxobjectid ) ";
00624         }
00625 
00626         // remove type 3
00627         //if( !$blExportStock3)
00628         //  $sSelect = str_replace( "or oxarticles.oxstockflag = 3", "", $sSelect);
00629 
00630         if ( isset( $sSearchString) && strlen( $sSearchString)) {
00631             $sSelect .= "and ( $sArticleTable.OXTITLE".$language." like '%$sSearchString%' ";
00632             $sSelect .= "or $sArticleTable.OXSHORTDESC".$language."  like '%$sSearchString%' ";
00633             $sSelect .= "or $sArticleTable.oxsearchkeys  like '%$sSearchString%') ";
00634         }
00635         if ( $sCatAdd) {
00636             $sSelect .= $sCatAdd;
00637         }
00638             if( !$sCatAdd)
00639                 $sSelect .= " and oxarticles.oxshopid = '$sShopID' ";
00640 
00641         // add minimum stock value
00642         $dMinStock = oxConfig::getParameter( "sExportMinStock");
00643         if ( isset( $dMinStock) && $dMinStock && $this->getConfig()->getConfigParam( 'blUseStock' ) ) {
00644             $dMinStock = str_replace( array( ";", " ", "/", "'"), "", $dMinStock);
00645             $sSelect .= " and $sArticleTable.oxstock >= $dMinStock";
00646         }
00647         $sSelect .= " group by $sArticleTable.oxid";
00648 
00649         if ( $oDB->execute( $sSelect) ) {
00650             return true;
00651         } else {
00652             return false;
00653         }
00654     }
00655 
00663     private function _removeParentArticles($sHeapTable)
00664     {
00665         $oDB = oxDb::getDb();
00666         $blExportParentVars = oxConfig::getParameter( "blExportMainVars");
00667         $sArticleTable = getViewName('oxarticles');
00668 
00669         if ( !isset( $blExportParentVars) || !$blExportParentVars) {
00670             // we need to remove again parent articles so that we only have the variants itself
00671             $rs = $oDB->execute( "select $sHeapTable.oxid from $sHeapTable, $sArticleTable where $sHeapTable.oxid = $sArticleTable.oxparentid group by $sHeapTable.oxid");
00672             $sDel = "delete from $sHeapTable where oxid in ( ";
00673             $blSep = false;
00674             if ($rs != false && $rs->recordCount() > 0) {
00675                 while (!$rs->EOF) {
00676                     if ( $blSep) {
00677                         $sDel .= ",";
00678                     }
00679                     $sDel .= "'".$rs->fields[0]."'";
00680                     $blSep = true;
00681                     $rs->moveNext();
00682                 }
00683             }
00684             $sDel .= " )";
00685             $oDB->execute( $sDel);
00686 
00687         }
00688     }
00689 
00696     private function _setSessionParams()
00697     {
00698         // reset it from session
00699         oxSession::deleteVar("sExportDelCost");
00700         $dDelCost = oxConfig::getParameter( "sExportDelCost");
00701         if ( isset( $dDelCost)) {
00702             $dDelCost = str_replace( array( ";", " ", "/", "'"), "", $dDelCost);
00703             $dDelCost = str_replace( ",", ".", $dDelCost);
00704             oxSession::setVar( "sExportDelCost", $dDelCost);
00705         }
00706 
00707         oxSession::deleteVar("sExportMinPrice");
00708         $dMinPrice = oxConfig::getParameter( "sExportMinPrice");
00709         if ( isset( $dMinPrice)) {
00710             $dMinPrice = str_replace( array( ";", " ", "/", "'"), "", $dMinPrice);
00711             $dMinPrice = str_replace( ",", ".", $dMinPrice);
00712             oxSession::setVar( "sExportMinPrice", $dMinPrice);
00713         }
00714 
00715         // #827
00716         oxSession::deleteVar("sExportCampaign");
00717         $sCampaign = oxConfig::getParameter( "sExportCampaign");
00718         if ( isset( $sCampaign)) {
00719             $sCampaign = str_replace( array( ";", " ", "/", "'"), "", $sCampaign);
00720             oxSession::setVar( "sExportCampaign", $sCampaign);
00721         }
00722         // reset it from session
00723         oxSession::deleteVar("blAppendCatToCampaign");
00724         // now retrieve it from get or post.
00725         $blAppendCatToCampaign = oxConfig::getParameter( "blAppendCatToCampaign");
00726         if ( isset( $blAppendCatToCampaign) && $blAppendCatToCampaign) {
00727             oxSession::setVar( "blAppendCatToCampaign", $blAppendCatToCampaign);
00728         }
00729     }
00730 
00736     private function _loadRootCats()
00737     {
00738         $myConfig = $this->getConfig();
00739         if ( !isset( $myConfig->aCatLvlCache) || !count( $myConfig->aCatLvlCache)) {
00740             $myConfig->aCatLvlCache = array();
00741 
00742             $sLang = oxLang::getInstance()->getBaseLanguage();
00743             $sCatView = getViewName('oxcategories');
00744             $oDb = oxDb::getDb();
00745 
00746             // Load all root cat's == all trees
00747             $sSQL = "select oxid from $sCatView where oxparentid = 'oxrootid'";
00748             $rs = $oDb->Execute( $sSQL);
00749             if ($rs != false && $rs->recordCount() > 0) {
00750                 while (!$rs->EOF) {
00751                     // now load each tree
00752                     $sSQL = "SELECT s.oxid, s.oxtitle".(($sLang)?"_$sLang":"").", s.oxparentid, count( * ) AS LEVEL FROM oxcategories v, oxcategories s WHERE s.oxrootid = '".$rs->fields[0]."' and v.oxrootid='".$rs->fields[0]."' and s.oxleft BETWEEN v.oxleft AND v.oxright  AND s.oxhidden = '0' GROUP BY s.oxleft order by level";
00753                     $rs2 = $oDb->Execute( $sSQL);
00754                     if ($rs2 != false && $rs2->recordCount() > 0) {
00755                         while (!$rs2->EOF) {
00756                             // store it
00757                             $oCat = new stdClass();
00758                             $oCat->_sOXID        = $rs2->fields[0];
00759                             $oCat->oxtitle      = $rs2->fields[1];
00760                             $oCat->oxparentid   = $rs2->fields[2];
00761                             $oCat->ilevel       = $rs2->fields[3];
00762                             $myConfig->aCatLvlCache[$oCat->_sOXID] = $oCat;
00763 
00764                             $rs2->moveNext();
00765                         }
00766                     }
00767                     $rs->moveNext();
00768                 }
00769             }
00770         }
00771     }
00772 
00780     private function _findDeepestCatPath($oArticle)
00781     {
00782         $myConfig = $this->getConfig();
00783         $sRet = "";
00784 
00785         // find deepest
00786         $aIDs   = $oArticle->getCategoryIds();
00787         if ( isset( $aIDs) && count( $aIDs)) {
00788             $SIDMAX     = null;
00789             $dMaxLvl    = 0;
00790             foreach ( $aIDs as $key => $sCatID) {
00791                 if ( $dMaxLvl < $myConfig->aCatLvlCache[$sCatID]->ilevel) {
00792                     $dMaxLvl = $myConfig->aCatLvlCache[$sCatID]->ilevel;
00793                     $SIDMAX = $sCatID;
00794                 }
00795             }
00796             // generate path
00797             $sRet = $myConfig->aCatLvlCache[$SIDMAX]->oxtitle;
00798             // endless
00799             for ( ;;) {
00800                 $SIDMAX = @$myConfig->aCatLvlCache[$SIDMAX]->oxparentid;
00801                 if ( !isset( $SIDMAX) || $SIDMAX == "oxrootid") {
00802                     break;
00803                 }
00804                 $sRet = $myConfig->aCatLvlCache[$SIDMAX]->oxtitle."/".$sRet;
00805             }
00806         }
00807         return $sRet;
00808     }
00809 
00818     private function _initArticle($sHeapTable, $iCnt)
00819     {
00820         $myConfig = $this->getConfig();
00821         $oDB = oxDb::getDb();
00822 
00823         $oArticle   = null;
00824 
00825         $rs = $oDB->selectLimit( "select oxid from $sHeapTable", 1, $iCnt);
00826         if ($rs != false && $rs->recordCount() > 0) {
00827             $sOXID = $rs->fields[0];
00828 
00829             //$oArticle = oxNewArticle( $sOXID, array('blLoadParentData' => true));
00830             //$oArticle->blLoadParentData = true;
00831             //2007-02-10T
00832             $oArticle = oxNew( 'oxarticle' );
00833             $oArticle->setLoadParentData(true);
00834             $oArticle->Load( $sOXID);
00835 
00836             // check price
00837             $dMinPrice = oxConfig::getParameter( "sExportMinPrice");
00838             if ( isset( $dMinPrice) && ($oArticle->brutPrice < $dMinPrice)) {
00839                 return null;
00840             }
00841         } else {
00842             return null;
00843         }
00844 
00845          //Saulius: variant title added
00846         $sTitle = $oArticle->oxarticles__oxvarselect->value?" ".$oArticle->oxarticles__oxvarselect->value:"";
00847         $oArticle->oxarticles__oxtitle->setValue($oArticle->oxarticles__oxtitle->value.$sTitle);
00848 
00849 
00850         // check for variant url - exporting direct variant links
00851         if ($oArticle->oxarticles__oxparentid->value) {
00852             $oArticle->oxdetaillink = str_replace($oArticle->oxarticles__oxparentid->value, $sOXID, $oArticle->oxdetaillink);
00853         }
00854         return $oArticle;
00855     }
00856 
00864     private function _setCampaignDetailLink($oArticle)
00865     {
00866         // #827
00867         $sCampaign = oxConfig::getParameter( "sExportCampaign" );
00868         if ( $sCampaign ) {
00869             // modify detaillink
00870             //#1166R - pangora - campaign
00871             $oArticle->appendLink( "campaign=$sCampaign" );
00872 
00873             if (oxConfig::getParameter( "blAppendCatToCampaign")) {
00874                 if ( $sCat = $this->getCategoryString($oArticle) ) {
00875                     $oArticle->appendLink( "/$sCat" );
00876                 }
00877             }
00878         }
00879         return $oArticle;
00880     }
00881 
00885     public function getViewId()
00886     {
00887         return 'dyn_interface';
00888     }
00889 }

Generated on Tue Aug 18 09:21:04 2009 for OXID eShop CE by  doxygen 1.5.5