main.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Main extends oxAdminView
00009 {
00016     public function render()
00017     {
00018         $myConfig = $this->getConfig();
00019 
00020         parent::render();
00021 
00022         $this->_aViewData['sVersion'] = $myConfig->getConfigParam( 'sVersion' );
00023 
00024         $iDynInterfaceLanguage = $myConfig->getConfigParam( 'dynInterfaceLanguage' );
00025         if ( isset( $iDynInterfaceLanguage ) )
00026             $iLang = $iDynInterfaceLanguage;
00027         else
00028             //$iLang = $myConfig->getConfigParam( 'iAdminLanguage' );
00029             $iLang = oxLang::getInstance()->getTplLanguage();
00030 
00031         $this->_aViewData['dynLanguage'] = $iLang;
00032 
00033         // #661 execute stuff we run each time when we start admin once
00034         $this->_aViewData['sMessage'] = $this->_doStartUpChecks();
00035 
00036         // read RSS from forum
00037         $this->_aViewData['rssfeed'] = array_merge( $this->_readNews("23,21,24"), $this->_readNews("32"));
00038 
00039         return "main.tpl";
00040     }
00041 
00048     protected function _doStartUpChecks()
00049     {   // #661
00050         $sMessage = "";
00051 
00052             // check if there are any links in oxobject2category which are outdated or old
00053             $sSQL = "select oxobject2category.oxid from oxcategories, oxobject2category left join oxarticles on oxarticles.oxid = oxobject2category.oxobjectid  where oxcategories.oxid = oxobject2category.oxcatnid and oxarticles.oxid is null";
00054             $iCnt = 0;
00055             $sDel = "";
00056             $rs = oxDb::getDb()->Execute( $sSQL);
00057             if ($rs != false && $rs->recordCount() > 0) {
00058                 while (!$rs->EOF) {
00059                     if ( $iCnt)
00060                         $sDel .= ",";
00061                     $sDel .= "'".$rs->fields[0]."'";
00062                     $iCnt++;
00063                     $rs->moveNext();
00064                 }
00065                 // delete it now
00066                 oxDb::getDb()->Execute("delete from oxobject2category where oxid in ($sDel)");
00067                 $sMessage = "- Deleted $iCnt old/outdated entries in table oxobject2category.<br>";
00068             }
00069 
00070         // do nothing, checks do need too much time in EE and huge databases
00071 
00072         return $sMessage;
00073     }
00074 
00083     protected function _readNews( $sForumIDs)
00084     {
00085         $aNews = array();
00086         $blReadRSS = $this->getConfig()->getConfigParam( 'blReadRSS' );
00087         if ( isset( $blReadRSS ) && !$blReadRSS )
00088            return $aNews;
00089 
00090         $url    = "http://www.oxid-esales.com/de/forum/external.php?forumids=".$sForumIDs;
00091         $sData  = '';
00092 
00093         $fp = @fopen( $url, "rb");
00094         if ( $fp) {
00095             while ( !feof($fp))
00096                 $sData .= fread( $fp, 8192);
00097             fclose( $fp);
00098         }
00099 
00100         $aIndexes = array();
00101         if ( isset( $sData) && $sData) {
00102             $oParser = @xml_parser_create();
00103             $aValues = array();
00104             if ( $oParser) {
00105                 xml_parser_set_option($oParser, XML_OPTION_CASE_FOLDING, 0);
00106                 xml_parser_set_option($oParser, XML_OPTION_SKIP_WHITE, 1);
00107                 xml_parser_set_option($oParser, XML_OPTION_TARGET_ENCODING, "ISO-8859-1");
00108                 xml_parse_into_struct($oParser, $sData, $aValues, $aIndexes);
00109                 $iErr = xml_get_error_code( $oParser);
00110                 if ( $iErr != false) {
00111                     echo( "Error ! XML : ". xml_error_string( $iErr));
00112                     echo( "\ndata:".$sData);
00113                     die();
00114                 }
00115                 xml_parser_free($oParser);
00116             }
00117 
00118             // build lines for parsing
00119             foreach ( $aValues as $key => $aContent) {
00120                 if ( $aContent['tag'] == "item" && $aContent['type'] == "open") {
00121                     $oLine = new stdClass();
00122                     continue;
00123                 } elseif ( $aContent['tag'] == "item" && $aContent['type'] == "close") {
00124                     //MK: fixed problem when admin logs in he cannot see oxid forum messages on start page
00125                     //$oLine = new stdClass();
00126                     $aTmp = explode( "Erstellt", $oLine->description);
00127                     $oLine->description = $aTmp[1];
00128                     $oLine->description = str_replace("von:", "Erstellt von:", $oLine->description);
00129                     $aTmp2 = explode( "Geschrieben", $oLine->description);
00130                     $oLine->description = $aTmp2[0];
00131                     $oLine->date        = $aTmp2[1];
00132                     $oLine->date = str_replace("am ", "", $oLine->date);
00133                     $oLine->date = str_replace(" um ", ",", $oLine->date);
00134                     $oLine->date .= " Uhr";
00135 
00136                     if ( count( $aNews[$aTmp[0]]) < 3 )
00137                         $aNews[$aTmp[0]][] = $oLine;
00138 
00139                     $oLine = null;
00140                     continue;
00141                 }
00142 
00143                 if ($oLine) {
00144                     // store values
00145                     $sVar = $aContent['tag'];
00146                     if ( isset( $aContent['value']))
00147                         $oLine->$sVar = $aContent['value'];
00148                 }
00149             }
00150         }
00151 
00152         return $aNews;
00153     }
00154 
00155 
00156 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5