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 
00180         $this->fpFile = @fopen( $this->_sFilePath, "a");
00181         if ( !isset( $this->fpFile) || !$this->fpFile) {
00182             // we do have an error !
00183             $this->stop( ERR_FILEIO);
00184         } else {
00185             // file is open
00186             $iStart = oxConfig::getParameter("iStart");
00187             // load from session
00188             $this->_aExportResultset = oxConfig::getParameter( "aExportResultset");
00189 
00190             for ( $i = $iStart; $i < $iStart + $this->iExportPerTick; $i++) {
00191                 if ( !$this->nextTick( $i)) {
00192                     // end reached
00193                     $this->stop( ERR_SUCCESS);
00194                     $blContinue = false;
00195                     break;
00196                 }
00197             }
00198             if ( $blContinue) {
00199                 // make ticker continue
00200                 $this->_aViewData['refresh'] = 0;
00201                 $this->_aViewData['iStart']  = $i;
00202                 $this->_aViewData['iEnd']    = oxConfig::getParameter("iEnd");
00203             }
00204             fclose( $this->fpFile);
00205         }
00206     }
00207 
00215     public function removeSID( $sInput)
00216     {
00217 
00218         $mySession = $this->getSession();
00219 
00220         // remove sid from link
00221         $sOutput = str_replace( "sid=".$mySession->getId()."/", "", $sInput);
00222         $sOutput = str_replace( "sid/".$mySession->getId()."/", "", $sOutput);
00223         $sOutput = str_replace( "sid=".$mySession->getId()."&amp;", "", $sOutput);
00224         $sOutput = str_replace( "sid=".$mySession->getId()."&", "", $sOutput);
00225         $sOutput = str_replace( "sid=".$mySession->getId(), "", $sOutput);
00226 
00227         return $sOutput;
00228     }
00229 
00239     public function shrink( $sInput, $iMaxSize, $blRemoveNewline = true)
00240     {
00241 
00242         if ( $blRemoveNewline) {
00243             $sOutput = str_replace( "\r\n", " ", $sInput);
00244             $sOutput = str_replace( "\n", " ", $sOutput);
00245         } else {
00246             $sOutput = $sInput;
00247         }
00248 
00249         $sOutput = str_replace( "\t", "    ", $sOutput);
00250         // remove html entities, remove html tags
00251         $sOutput = $this->_unHTMLEntities( strip_tags( $sOutput));
00252 
00253         $oStr = getStr();
00254         if ( $oStr->strlen( $sOutput) > $iMaxSize - 3) {
00255             $sOutput = $oStr->substr( $sOutput, 0, $iMaxSize - 5) . "...";
00256         }
00257         return $sOutput;
00258     }
00259 
00268     public function getCategoryString( & $oArticle, $sSeparator = "/")
00269     {
00270         $sLang = oxLang::getInstance()->getBaseLanguage();
00271         $oDB = oxDb::getDb();
00272 
00273         $sCatView = getViewName('oxcategories');
00274         $sO2CView = getViewName('oxobject2category');
00275 
00276         //selecting category
00277         $sQ =  "select oxobject2category.oxcatnid, $sCatView.oxleft, $sCatView.oxright, $sCatView.oxrootid from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
00278         $sQ .= "where oxobject2category.oxobjectid='".$oArticle->getId()."' and $sCatView.oxactive".(($sLang)?"_$sLang":"")." = 1 order by oxobject2category.oxtime ";
00279 
00280         $aRet = array();
00281         $rs = $oDB->execute( $sQ);
00282         if ($rs != false && $rs->recordCount() > 0) {
00283             $sCatID = $rs->fields[0];
00284             $sLeft = $rs->fields[1];
00285             $sRight = $rs->fields[2];
00286             $sRootID = $rs->fields[3];
00287 
00288             //selecting all parent category titles
00289                 $sQ  = "select oxtitle".(($sLang)?"_$sLang":"")." from oxcategories where ";
00290                 $sQ .= "oxrootid = '$sRootID' and oxright >= $sRight and oxleft <= $sLeft order by oxleft ";
00291 
00292             $rs = $oDB->execute( $sQ);
00293             if ($rs != false && $rs->recordCount() > 0) {
00294                 while (!$rs->EOF) {
00295                     $aRet[] = $rs->fields[0];
00296                     $rs->moveNext();
00297                 }
00298             }
00299         }
00300         $sRet = implode($sSeparator, $aRet);
00301         return $sRet;
00302     }
00303 
00311     public function getDefaultCategoryString($oArticle)
00312     {
00313         $sLang = oxLang::getInstance()->getBaseLanguage();
00314         $oDB = oxDb::getDb();
00315 
00316         $sCatView = getViewName('oxcategories');
00317         $sO2CView = getViewName('oxobject2category');
00318 
00319         //selecting category
00320         $sQ =  "select $sCatView.oxtitle".(($sLang)?"_$sLang":"")." from $sO2CView as oxobject2category left join $sCatView on $sCatView.oxid = oxobject2category.oxcatnid ";
00321         $sQ .= "where oxobject2category.oxobjectid='".$oArticle->getId()."' and $sCatView.oxactive".(($sLang)?"_$sLang":"")." = 1 order by oxobject2category.oxtime ";
00322 
00323         $rs = $oDB->getOne( $sQ);
00324 
00325         return $rs;
00326     }
00327 
00335     public function prepareCSV( $sInput)
00336     {
00337         $sInput = oxUtilsString::getInstance()->prepareCSVField( $sInput);
00338         $sOutput = str_replace( "&nbsp;", " ", $sInput);
00339         $sOutput = str_replace( "&euro;", "€", $sOutput);
00340         $sOutput = str_replace( "|", "", $sOutput);
00341 
00342         return $sOutput;
00343     }
00344 
00352     public function prepareXML($sInput)
00353     {
00354 
00355         $sOutput = str_replace("&", "&amp;", $sInput);
00356         $sOutput = str_replace("\"", "&quot;", $sOutput);
00357         $sOutput = str_replace(">", "&gt;", $sOutput);
00358         $sOutput = str_replace("<", "&lt;", $sOutput);
00359         $sOutput = str_replace("'", "&apos;", $sOutput);
00360         return $sOutput;
00361     }
00362 
00370     public function getDeepestCategoryPath( & $oArticle)
00371     {
00372         $sRet = "";
00373         $this->_loadRootCats();
00374         $sRet = $this->_findDeepestCatPath($oArticle);
00375 
00376         return $sRet;
00377     }
00378 
00384     public function prepareExport()
00385     {
00386         $oDB = oxDb::getDb();
00387 
00388         $sHeapTable = $this->_getHeapTableName();
00389 
00390         // #1070 Saulius 2005.11.28
00391         // check mySQL version
00392 
00393         $rs = $oDB->execute("SHOW VARIABLES LIKE 'version'");
00394         $sMysqlVersion = $rs->fields[1];
00395 
00396         $sTableCharset = $this->_generateTableCharSet($sMysqlVersion);
00397 
00398         // create heap table
00399         $blRet = $this->_createHeapTable($sHeapTable, $sTableCharset);
00400         if ( $blRet == false) {
00401             // error
00402             die( "Could not create HEAP Table $sHeapTable\n<br>");
00403         }
00404 
00405         $aChosenCat = oxConfig::getParameter( "acat");
00406         $sCatAdd = $this->_getCatAdd($aChosenCat);
00407 
00408         if ( !$this->_insertArticles($sHeapTable, $sCatAdd) ) {
00409             die( "Could not insert Articles in Table $sHeapTable\n<br>");
00410         }
00411 
00412         /* commented due to upper changes
00413         if( isset( $blExportVars) && $blExportVars)
00414         {   // now add variants if there are some
00415             $oDB->Execute( "insert into ".$sHeapTable." select oxarticles.oxid from oxarticles, $sHeapTable where oxarticles.oxparentid = $sHeapTable.oxid AND ".oxDb::getInstance()->getActiveSnippet( "oxarticles"));
00416         }*/
00417         $this->_removeParentArticles($sHeapTable);
00418         $this->_setSessionParams();
00419 
00420         // get total cnt
00421         $iCnt = $oDB->getOne("select count(*) from $sHeapTable");
00422 
00423         return $iCnt;
00424     }
00425 
00434     public function getOneArticle( $iCnt, & $blContinue)
00435     {
00436         $myConfig  = $this->getConfig();
00437         //[Alfonsas 2006-05-31] setting specific parameter
00438         //to be checked in oxarticle.php init() method
00439         $myConfig->setConfigParam( 'blExport', true );
00440 
00441         $oArticle   = null;
00442         $blContinue = true;
00443 
00444         $sHeapTable = $this->_getHeapTableName();
00445 
00446         $oArticle = $this->_initArticle($sHeapTable, $iCnt);
00447         if (!isset($oArticle)) {
00448             $blContinue = false;
00449             return null;
00450         }
00451 
00452         $oArticle = $this->_setCampaignDetailLink($oArticle);
00453 
00454         //[Alfonsas 2006-05-31] unsetting specific parameter
00455         //to be checked in oxarticle.php init() method
00456         $myConfig->setConfigParam( 'blExport', false );
00457 
00458         return $oArticle;
00459     }
00460 
00469     public function assureContent( $sInput, $sReplace = null)
00470     {
00471         if ( !strlen( $sInput)) {
00472             if ( !isset( $sReplace) || !strlen($sReplace)) {
00473                 $sReplace = "-";
00474             }
00475             $sInput = $sReplace;
00476         }
00477         return $sInput;
00478     }
00479 
00488     protected function _unHTMLEntities( $sInput)
00489     {
00490 
00491         $trans_tbl = get_html_translation_table(HTML_ENTITIES);
00492         $trans_tbl = array_flip($trans_tbl);
00493         return strtr( $sInput, $trans_tbl);
00494     }
00495 
00501     protected function _getHeapTableName()
00502     {
00503         $mySession = $this->getSession();
00504 
00505         // table name must not start with any digit
00506         $sHeapname = "tmp_".str_replace( "0", "", md5($mySession->getId()));
00507 
00508         return $sHeapname;
00509     }
00510 
00518     private function _generateTableCharSet($sMysqlVersion)
00519     {
00520         $oDB = oxDb::getDb(true);
00521 
00522         //if MySQL >= 4.1.0 set charsets and collations
00523         if (version_compare($sMysqlVersion, '4.1.0', '>=')>0) {
00524             $sMysqlCharacterSet = null;
00525             $sMysqlCollation = null;
00526             $rs = $oDB->execute( "SHOW FULL COLUMNS FROM `oxarticles` WHERE field like 'OXID'" );
00527             if ( isset( $rs->fields['Collation'] ) && ( $sMysqlCollation = $rs->fields['Collation'] ) ) {
00528                 $rs = $oDB->execute( "SHOW COLLATION LIKE '{$sMysqlCollation}'" );
00529                 if ( isset( $rs->fields['Charset'] ) ) {
00530                     $sMysqlCharacterSet = $rs->fields['Charset'];
00531                 }
00532             }
00533 
00534             if ( $sMysqlCollation && $sMysqlCharacterSet ) {
00535                 $sTableCharset = "DEFAULT CHARACTER SET ".$sMysqlCharacterSet." COLLATE ".$sMysqlCollation;
00536             } else {
00537                 $sTableCharset = "";
00538             }
00539         } else {
00540             $sTableCharset = "";
00541         }
00542         return $sTableCharset;
00543     }
00544 
00553     private function _createHeapTable($sHeapTable, $sTableCharset)
00554     {
00555 
00556         $oDB = oxDb::getDb();
00557 
00558         $sSQL = "CREATE TABLE if not exists $sHeapTable ( oxid char(32) NOT NULL default '' ) TYPE=HEAP ".$sTableCharset;
00559 
00560         $rs = $oDB->execute( $sSQL);
00561         if ( $rs == false) {
00562             // error
00563             return false;
00564         }
00565         $oDB->execute( "truncate table $sHeapTable ");
00566         return true;
00567     }
00568 
00576     private function _getCatAdd($aChosenCat)
00577     {
00578 
00579         $sCatAdd        = null;
00580         if ( isset( $aChosenCat)) {
00581             $sCatAdd = " and ( ";
00582             $blSep = false;
00583             foreach ( $aChosenCat as $sCat) {
00584                 if ( $blSep) {
00585                     $sCatAdd .= " or ";
00586                 }
00587                 $sCatAdd .= "oxobject2category.oxcatnid = '$sCat'";
00588                 $blSep = true;
00589             }
00590             $sCatAdd .= ")";
00591         }
00592         return $sCatAdd;
00593     }
00594 
00603     private function _insertArticles($sHeapTable, $sCatAdd)
00604     {
00605         $oDB = oxDb::getDb();
00606         $sSearchString = oxConfig::getParameter( "search");
00607         $blExportVars  = oxConfig::getParameter( "blExportVars");
00608 
00609         $language = oxLang::getInstance()->getLanguageTag( 0);
00610         $sShopID = $this->getConfig()->getShopID();
00611 
00612         $sO2CView = getViewName('oxobject2category');
00613         $oArticle = oxNew( 'oxarticle' );
00614         $sArticleTable = $oArticle->getViewName();
00615 
00616         $sSelect  = "insert into $sHeapTable select $sArticleTable.oxid from $sArticleTable, $sO2CView as oxobject2category where ";
00617         $sSelect .= $oArticle->getSqlActiveSnippet();
00618 
00619         if ( !$blExportVars) {
00620             $sSelect .= " and $sArticleTable.oxid = oxobject2category.oxobjectid and $sArticleTable.oxparentid='' ";
00621         } else {
00622             $sSelect .= " and ( $sArticleTable.oxid = oxobject2category.oxobjectid or $sArticleTable.oxparentid = oxobject2category.oxobjectid ) ";
00623         }
00624 
00625         // remove type 3
00626         //if( !$blExportStock3)
00627         //  $sSelect = str_replace( "or oxarticles.oxstockflag = 3", "", $sSelect);
00628 
00629         if ( isset( $sSearchString) && strlen( $sSearchString)) {
00630             $sSelect .= "and ( $sArticleTable.OXTITLE".$language." like '%$sSearchString%' ";
00631             $sSelect .= "or $sArticleTable.OXSHORTDESC".$language."  like '%$sSearchString%' ";
00632             $sSelect .= "or $sArticleTable.oxsearchkeys  like '%$sSearchString%') ";
00633         }
00634         if ( $sCatAdd) {
00635             $sSelect .= $sCatAdd;
00636         }
00637             if( !$sCatAdd)
00638                 $sSelect .= " and oxarticles.oxshopid = '$sShopID' ";
00639 
00640         // add minimum stock value
00641         $dMinStock = oxConfig::getParameter( "sExportMinStock");
00642         if ( isset( $dMinStock) && $dMinStock && $this->getConfig()->getConfigParam( 'blUseStock' ) ) {
00643             $dMinStock = str_replace( array( ";", " ", "/", "'"), "", $dMinStock);
00644             $sSelect .= " and $sArticleTable.oxstock >= $dMinStock";
00645         }
00646         $sSelect .= " group by $sArticleTable.oxid";
00647 
00648         if ( $oDB->execute( $sSelect) ) {
00649             return true;
00650         } else {
00651             return false;
00652         }
00653     }
00654 
00662     private function _removeParentArticles($sHeapTable)
00663     {
00664         $oDB = oxDb::getDb();
00665         $blExportParentVars = oxConfig::getParameter( "blExportMainVars");
00666         $sArticleTable = getViewName('oxarticles');
00667 
00668         if ( !isset( $blExportParentVars) || !$blExportParentVars) {
00669             // we need to remove again parent articles so that we only have the variants itself
00670             $rs = $oDB->execute( "select $sHeapTable.oxid from $sHeapTable, $sArticleTable where $sHeapTable.oxid = $sArticleTable.oxparentid group by $sHeapTable.oxid");
00671             $sDel = "delete from $sHeapTable where oxid in ( ";
00672             $blSep = false;
00673             if ($rs != false && $rs->recordCount() > 0) {
00674                 while (!$rs->EOF) {
00675                     if ( $blSep) {
00676                         $sDel .= ",";
00677                     }
00678                     $sDel .= "'".$rs->fields[0]."'";
00679                     $blSep = true;
00680                     $rs->moveNext();
00681                 }
00682             }
00683             $sDel .= " )";
00684             $oDB->execute( $sDel);
00685 
00686         }
00687     }
00688 
00695     private function _setSessionParams()
00696     {
00697         // reset it from session
00698         oxSession::deleteVar("sExportDelCost");
00699         $dDelCost = oxConfig::getParameter( "sExportDelCost");
00700         if ( isset( $dDelCost)) {
00701             $dDelCost = str_replace( array( ";", " ", "/", "'"), "", $dDelCost);
00702             $dDelCost = str_replace( ",", ".", $dDelCost);
00703             oxSession::setVar( "sExportDelCost", $dDelCost);
00704         }
00705 
00706         oxSession::deleteVar("sExportMinPrice");
00707         $dMinPrice = oxConfig::getParameter( "sExportMinPrice");
00708         if ( isset( $dMinPrice)) {
00709             $dMinPrice = str_replace( array( ";", " ", "/", "'"), "", $dMinPrice);
00710             $dMinPrice = str_replace( ",", ".", $dMinPrice);
00711             oxSession::setVar( "sExportMinPrice", $dMinPrice);
00712         }
00713 
00714         // #827
00715         oxSession::deleteVar("sExportCampaign");
00716         $sCampaign = oxConfig::getParameter( "sExportCampaign");
00717         if ( isset( $sCampaign)) {
00718             $sCampaign = str_replace( array( ";", " ", "/", "'"), "", $sCampaign);
00719             oxSession::setVar( "sExportCampaign", $sCampaign);
00720         }
00721         // reset it from session
00722         oxSession::deleteVar("blAppendCatToCampaign");
00723         // now retrieve it from get or post.
00724         $blAppendCatToCampaign = oxConfig::getParameter( "blAppendCatToCampaign");
00725         if ( isset( $blAppendCatToCampaign) && $blAppendCatToCampaign) {
00726             oxSession::setVar( "blAppendCatToCampaign", $blAppendCatToCampaign);
00727         }
00728     }
00729 
00735     private function _loadRootCats()
00736     {
00737         $myConfig = $this->getConfig();
00738         if ( !isset( $myConfig->aCatLvlCache) || !count( $myConfig->aCatLvlCache)) {
00739             $myConfig->aCatLvlCache = array();
00740 
00741             $sLang = oxLang::getInstance()->getBaseLanguage();
00742             $sCatView = getViewName('oxcategories');
00743             $oDb = oxDb::getDb();
00744 
00745             // Load all root cat's == all trees
00746             $sSQL = "select oxid from $sCatView where oxparentid = 'oxrootid'";
00747             $rs = $oDb->Execute( $sSQL);
00748             if ($rs != false && $rs->recordCount() > 0) {
00749                 while (!$rs->EOF) {
00750                     // now load each tree
00751                     $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";
00752                     $rs2 = $oDb->Execute( $sSQL);
00753                     if ($rs2 != false && $rs2->recordCount() > 0) {
00754                         while (!$rs2->EOF) {
00755                             // store it
00756                             $oCat = new stdClass();
00757                             $oCat->_sOXID        = $rs2->fields[0];
00758                             $oCat->oxtitle      = $rs2->fields[1];
00759                             $oCat->oxparentid   = $rs2->fields[2];
00760                             $oCat->ilevel       = $rs2->fields[3];
00761                             $myConfig->aCatLvlCache[$oCat->_sOXID] = $oCat;
00762 
00763                             $rs2->moveNext();
00764                         }
00765                     }
00766                     $rs->moveNext();
00767                 }
00768             }
00769         }
00770     }
00771 
00779     private function _findDeepestCatPath($oArticle)
00780     {
00781         $myConfig = $this->getConfig();
00782         $sRet = "";
00783 
00784         // find deepest
00785         $aIDs   = $oArticle->getCategoryIds();
00786         if ( isset( $aIDs) && count( $aIDs)) {
00787             $SIDMAX     = null;
00788             $dMaxLvl    = 0;
00789             foreach ( $aIDs as $key => $sCatID) {
00790                 if ( $dMaxLvl < $myConfig->aCatLvlCache[$sCatID]->ilevel) {
00791                     $dMaxLvl = $myConfig->aCatLvlCache[$sCatID]->ilevel;
00792                     $SIDMAX = $sCatID;
00793                 }
00794             }
00795             // generate path
00796             $sRet = $myConfig->aCatLvlCache[$SIDMAX]->oxtitle;
00797             // endless
00798             for ( ;;) {
00799                 $SIDMAX = @$myConfig->aCatLvlCache[$SIDMAX]->oxparentid;
00800                 if ( !isset( $SIDMAX) || $SIDMAX == "oxrootid") {
00801                     break;
00802                 }
00803                 $sRet = $myConfig->aCatLvlCache[$SIDMAX]->oxtitle."/".$sRet;
00804             }
00805         }
00806         return $sRet;
00807     }
00808 
00817     private function _initArticle($sHeapTable, $iCnt)
00818     {
00819         $myConfig = $this->getConfig();
00820         $oDB = oxDb::getDb();
00821 
00822         $oArticle   = null;
00823 
00824         $rs = $oDB->selectLimit( "select oxid from $sHeapTable", 1, $iCnt);
00825         if ($rs != false && $rs->recordCount() > 0) {
00826             $sOXID = $rs->fields[0];
00827 
00828             //$oArticle = oxNewArticle( $sOXID, array('blLoadParentData' => true));
00829             //$oArticle->blLoadParentData = true;
00830             //2007-02-10T
00831             $oArticle = oxNew( 'oxarticle' );
00832             $oArticle->setLoadParentData(true);
00833             $oArticle->Load( $sOXID);
00834 
00835             // check price
00836             $dMinPrice = oxConfig::getParameter( "sExportMinPrice");
00837             if ( isset( $dMinPrice) && ($oArticle->brutPrice < $dMinPrice)) {
00838                 return null;
00839             }
00840         } else {
00841             return null;
00842         }
00843 
00844          //Saulius: variant title added
00845         $sTitle = $oArticle->oxarticles__oxvarselect->value?" ".$oArticle->oxarticles__oxvarselect->value:"";
00846         $oArticle->oxarticles__oxtitle->setValue($oArticle->oxarticles__oxtitle->value.$sTitle);
00847 
00848 
00849         // check for variant url - exporting direct variant links
00850         if ($oArticle->oxarticles__oxparentid->value) {
00851             $oArticle->oxdetaillink = str_replace($oArticle->oxarticles__oxparentid->value, $sOXID, $oArticle->oxdetaillink);
00852         }
00853         return $oArticle;
00854     }
00855 
00863     private function _setCampaignDetailLink($oArticle)
00864     {
00865         // #827
00866         $sCampaign = oxConfig::getParameter( "sExportCampaign" );
00867         if ( $sCampaign ) {
00868             // modify detaillink
00869             //#1166R - pangora - campaign
00870             $oArticle->appendLink( "campaign=$sCampaign" );
00871 
00872             if (oxConfig::getParameter( "blAppendCatToCampaign")) {
00873                 if ( $sCat = $this->getCategoryString($oArticle) ) {
00874                     $oArticle->appendLink( "/$sCat" );
00875                 }
00876             }
00877         }
00878         return $oArticle;
00879     }
00880 
00884     public function getViewId()
00885     {
00886         return 'dyn_interface';
00887     }
00888 }

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5