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
00029 $iLang = oxLang::getInstance()->getTplLanguage();
00030
00031 $this->_aViewData['dynLanguage'] = $iLang;
00032
00033
00034 $this->_aViewData['sMessage'] = $this->_doStartUpChecks();
00035
00036
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 {
00050 $sMessage = "";
00051
00052
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
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
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
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
00125
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
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 }