navigation.php

Go to the documentation of this file.
00001 <?php
00002 
00006 class Navigation extends oxAdminView
00007 {
00014     public function render()
00015     {
00016         parent::render();
00017         $myUtilsServer = oxUtilsServer::getInstance();
00018 
00019         $sItem = oxConfig::getParameter( "item");
00020         if ( !isset( $sItem) || !$sItem ) {
00021             $sItem = "nav_frame.tpl";
00022 
00023             $aFavorites = oxConfig::getParameter( "favorites");
00024             if(is_array($aFavorites)) {
00025                 $myUtilsServer->setOxCookie('oxidadminfavorites',implode('|',$aFavorites));
00026             }
00027 
00028         } else {
00029 
00030             // set menu structure
00031             $this->_aViewData["menustructure"] =  $this->getNavigation()->getDomXml()->documentElement->childNodes;
00032 
00033             // version patch strin
00034             $sVersion = str_replace( array("EE.","PE."), "", $this->_sShopVersion);
00035             $this->_aViewData["sVersion"] =  trim($sVersion);
00036 
00037             //checking requirements if this is not nav frame reload
00038             if ( !oxConfig::getParameter( "navReload" ) ) {
00039                 // #661 execute stuff we run each time when we start admin once
00040                 if ('home.tpl' == $sItem) {
00041                     $this->_aViewData['aMessage'] = $this->_doStartUpChecks();
00042                 }
00043             } else {
00044                 //removing reload param to force requirements checking next time
00045                 oxSession::deleteVar( "navReload" );
00046             }
00047 
00048             // favorite navigation
00049             $aFavorites = explode('|',$myUtilsServer->getOxCookie('oxidadminfavorites'));
00050 
00051             if ( is_array ( $aFavorites ) && count( $aFavorites ) ) {
00052                  $this->_aViewData["menufavorites"] = $this->getNavigation()->getListNodes($aFavorites);
00053                  $this->_aViewData["aFavorites"]    = $aFavorites;
00054             }
00055 
00056             // history navigation
00057             $aHistory = explode('|',$myUtilsServer->getOxCookie('oxidadminhistory'));
00058             if(is_array($aHistory) && count($aHistory)) {
00059                 $this->_aViewData["menuhistory"] = $this->getNavigation()->getListNodes($aHistory);
00060             }
00061 
00062             // open history node ?
00063             $this->_aViewData["blOpenHistory"] = oxConfig::getParameter( 'openHistory' );
00064         }
00065 
00066         $oShoplist = oxNew( 'oxshoplist' );
00067         $oBaseShop = $oShoplist->getBaseObject();
00068 
00069         $sWhere = '';
00070         $blisMallAdmin = oxSession::getVar( 'malladmin' );
00071         if ( !$blisMallAdmin) {
00072             // we only allow to see our shop
00073             $sShopID = oxSession::getVar( "actshop" );
00074             $sWhere = "where oxshops.oxid = '$sShopID'";
00075         }
00076 
00077         $oShoplist->selectString( "select ".$oBaseShop->getSelectFields()." from " . $oBaseShop->getViewName() . " $sWhere" );
00078         $this->_aViewData['shoplist'] = $oShoplist;
00079 
00080         return $sItem;
00081     }
00082 
00088     public function logout()
00089     {
00090         $mySession = $this->getSession();
00091         $myConfig  = $this->getConfig();
00092 
00093         $oUser = oxNew( "oxuser" );
00094         $oUser->logout();
00095 
00096         // dodger - Task #1364 - Logout-Button
00097         // store
00098         $sSID = $mySession->getId();
00099 
00100         // kill session
00101         $mySession->destroy();
00102 
00103         // delete also, this is usually not needed but for security reasons we execute still
00104         if ( $myConfig->getConfigParam( 'blAdodbSessionHandler' ) ) {
00105             $oDb = oxDb::getDb();
00106             $sSQL = "delete from oxsessions where SessionID = ".$oDb->quote( $sSID );
00107             $oDb->execute( $sSQL );
00108         }
00109 
00110         //reseting content cache if needed
00111         $blDeleteCache = $this->getConfig()->getConfigParam( 'blClearCacheOnLogout' );
00112         if ( $blDeleteCache ) {
00113             $this->resetContentCache( $blDeleteCache );
00114         }
00115 
00116         oxUtils::getInstance()->redirect( 'index.php' );
00117     }
00118 
00124     public function exturl()
00125     {
00126         $myOxUtlis         = oxUtils::getInstance();
00127         $blLoadDynContents = $this->getConfig()->getConfigParam( 'blLoadDynContents' );
00128         $sAllowedHost      = "http://admin.oxid-esales.com";
00129 
00130         $sUrl = oxConfig::getParameter( "url");
00131         if ( isset( $sUrl) || $sUrl ) {
00132 
00133              // Limit external url's only allowed host
00134             if( $blLoadDynContents && strpos($sUrl,$sAllowedHost) === 0 ) {
00135 
00136                 $sPath = $this->getConfig()->getConfigParam( 'sCompileDir' ) . "/".md5($sUrl).'.html';
00137                 $sBase = dirname($sUrl).'/';
00138 
00139                 if( $myOxUtlis->getRemoteCachePath($sUrl, $sPath) ) {
00140 
00141                     // Get ceontent
00142                     $sOutput = file_get_contents($sPath);
00143 
00144                     // Fix base path
00145                     $sOutput = preg_replace("/<\/head>/i", "<base href=\"{$sBase}\"></head>\n  <!-- OXID eShop {$sEdition}, Version {$sVersion}, Shopping Cart System (c) OXID eSales AG 2003 - {$sCurYear} - http://www.oxid-esales.com -->", $sOutput);
00146 
00147                     // Fix self url's
00148                     $sOutput = preg_replace("/href=\"#\"/i", 'href="javascript::void();"', $sOutput);
00149 
00150                     die($sOutput);
00151                }
00152 
00153             }else{
00154                 // Caching not allowed, redirecting
00155                 header('Location: '.$sUrl);
00156             }
00157         }
00158 
00159         die;
00160     }
00161 
00168     protected function _doStartUpChecks()
00169     {   // #661
00170         $aMessage = array();
00171 /*
00172             // check if there are any links in oxobject2category which are outdated or old
00173             $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";
00174             $iCnt = 0;
00175             $sDel = "";
00176             $rs = oxDb::getDb()->Execute( $sSQL);
00177             if ($rs != false && $rs->recordCount() > 0) {
00178                 while (!$rs->EOF) {
00179                     if ( $iCnt)
00180                         $sDel .= ",";
00181                     $sDel .= "'".$rs->fields[0]."'";
00182                     $iCnt++;
00183                     $rs->moveNext();
00184                 }
00185                 // delete it now
00186                 oxDb::getDb()->Execute("delete from oxobject2category where oxid in ($sDel)");
00187                 $aMessage['message'] = "- Deleted $iCnt old/outdated entries in table oxobject2category.<br>";
00188             }
00189 */
00190         // check if system reguirements are ok
00191         $oSysReq = new oxSysRequirements();
00192 
00193 
00194         if ( !$oSysReq->getSysReqStatus() ) {
00195             $aMessage['warning']  = oxLang::getInstance()->translateString('NAVIGATION_SYSREQ_MESSAGE');
00196             $aMessage['warning'] .= '<a href="?cl=sysreq" target="basefrm">';
00197             $aMessage['warning'] .= oxLang::getInstance()->translateString('NAVIGATION_SYSREQ_MESSAGE2').'</a>';
00198         }
00199 
00200         // version check
00201         if ( $this->getConfig()->getConfigParam( 'blCheckForUpdates' ) ) {
00202             if ( $sVersionNotice = $this->_checkVersion() ) {
00203                 $aMessage['message'] .= $sVersionNotice;
00204             }
00205         }
00206 
00207 
00208         // check if setup dir is deleted
00209         if ( file_exists( $this->getConfig()->getConfigParam( 'sShopDir' ) . '/setup/index.php' ) ) {
00210             $aMessage['warning']  .= ( ( !empty($aMessage['warning']) ) ? "<br>" : '' ) . oxLang::getInstance()->translateString('SETUP_DIRNOTDELETED_WARNING');
00211         }
00212 
00213         // check if config file is writable
00214         $sConfPath = $this->getConfig()->getConfigParam( 'sShopDir' )."/config.inc.php";
00215         $sPerms = substr( decoct( fileperms($sConfPath) ), 2 );
00216         if ( $sPerms > 644 ) {
00217             $aMessage['warning']  .= ( ( !empty($aMessage['warning']) ) ? "<br>" : '' ) . oxLang::getInstance()->translateString('SETUP_CONFIGPERMISSIONS_WARNING');
00218         }
00219 
00220         return $aMessage;
00221     }
00222 
00228     protected function _checkVersion()
00229     {
00230             $sVersion = 'CE';
00231 
00232         $sQuery = 'http://admin.oxid-esales.com/'.$sVersion.'/onlinecheck.php?getlatestversion';
00233         if ( $sVersion = oxUtilsFile::getInstance()->readRemoteFileAsString( $sQuery ) ) {
00234             // current version is older ..
00235             if ( version_compare( $this->getConfig()->getVersion(), $sVersion ) == '-1' ) {
00236                 return sprintf( oxLang::getInstance()->translateString( 'NAVIGATION_NEWVERSIONAVAILABLE' ), $sVersion );
00237             }
00238         }
00239     }
00240 }

Generated on Mon Oct 26 20:07:16 2009 for OXID eShop CE by  doxygen 1.5.5