navigation.php

Go to the documentation of this file.
00001 <?php
00005 class Navigation extends oxAdminView
00006 {
00007 
00013     protected $_sAllowedHost = "http://admin.oxid-esales.com";
00014 
00021     public function render()
00022     {
00023         parent::render();
00024         $myUtilsServer = oxRegistry::get("oxUtilsServer");
00025 
00026         $sItem = oxRegistry::getConfig()->getRequestParameter("item");
00027         $sItem = $sItem ? basename($sItem) : false;
00028         if (!$sItem) {
00029             $sItem = "nav_frame.tpl";
00030             $aFavorites = oxRegistry::getConfig()->getRequestParameter("favorites");
00031             if (is_array($aFavorites)) {
00032                 $myUtilsServer->setOxCookie('oxidadminfavorites', implode('|', $aFavorites));
00033             }
00034         } else {
00035             $oNavTree = $this->getNavigation();
00036 
00037             // set menu structure
00038             $this->_aViewData["menustructure"] = $oNavTree->getDomXml()->documentElement->childNodes;
00039 
00040             // version patch strin
00041             $sVersion = str_replace(array("EE.", "PE."), "", $this->_sShopVersion);
00042             $this->_aViewData["sVersion"] = trim($sVersion);
00043 
00044             //checking requirements if this is not nav frame reload
00045             if (!oxRegistry::getConfig()->getRequestParameter("navReload")) {
00046                 // #661 execute stuff we run each time when we start admin once
00047                 if ('home.tpl' == $sItem) {
00048                     $this->_aViewData['aMessage'] = $this->_doStartUpChecks();
00049                 }
00050             } else {
00051                 //removing reload param to force requirements checking next time
00052                 oxRegistry::getSession()->deleteVariable("navReload");
00053             }
00054 
00055             // favorite navigation
00056             $aFavorites = explode('|', $myUtilsServer->getOxCookie('oxidadminfavorites'));
00057 
00058             if (is_array($aFavorites) && count($aFavorites)) {
00059                 $this->_aViewData["menufavorites"] = $oNavTree->getListNodes($aFavorites);
00060                 $this->_aViewData["aFavorites"] = $aFavorites;
00061             }
00062 
00063             // history navigation
00064             $aHistory = explode('|', $myUtilsServer->getOxCookie('oxidadminhistory'));
00065             if (is_array($aHistory) && count($aHistory)) {
00066                 $this->_aViewData["menuhistory"] = $oNavTree->getListNodes($aHistory);
00067             }
00068 
00069             // open history node ?
00070             $this->_aViewData["blOpenHistory"] = oxRegistry::getConfig()->getRequestParameter('openHistory');
00071         }
00072 
00073         $sWhere = '';
00074         $blisMallAdmin = oxRegistry::getSession()->getVariable('malladmin');
00076         $oShoplist = oxNew('oxShopList');
00077         if (!$blisMallAdmin) {
00078             // we only allow to see our shop
00079             $iShopId = oxRegistry::getSession()->getVariable("actshop");
00081             $oShop = oxNew('oxShop');
00082             $oShop->load($iShopId);
00083             $oShoplist->add($oShop);
00084         } else {
00085             $oShoplist->getIdTitleList();
00086         }
00087 
00088         $this->_aViewData['shoplist'] = $oShoplist;
00089         return $sItem;
00090     }
00091 
00095     public function chshp()
00096     {
00097         parent::chshp();
00098 
00099         // informing about basefrm parameters
00100         $this->_aViewData['loadbasefrm'] = true;
00101         $sListView = oxRegistry::getConfig()->getRequestParameter('listview');
00102         $sEditView = oxRegistry::getConfig()->getRequestParameter('editview');
00103         $iActEdit = oxRegistry::getConfig()->getRequestParameter('actedit');
00104 
00105 
00106         $this->_aViewData['listview'] = $sListView;
00107         $this->_aViewData['editview'] = $sEditView;
00108         $this->_aViewData['actedit'] = $iActEdit;
00109     }
00110 
00114     public function logout()
00115     {
00116         $mySession = $this->getSession();
00117         $myConfig = $this->getConfig();
00118 
00119         $oUser = oxNew("oxuser");
00120         $oUser->logout();
00121 
00122         // kill session
00123         $mySession->destroy();
00124 
00125         // delete also, this is usually not needed but for security reasons we execute still
00126         if ($myConfig->getConfigParam('blAdodbSessionHandler')) {
00127             $oDb = oxDb::getDb();
00128             $oDb->execute("delete from oxsessions where SessionID = " . $oDb->quote($mySession->getId()));
00129         }
00130 
00131         //reseting content cache if needed
00132         if ($myConfig->getConfigParam('blClearCacheOnLogout')) {
00133             $this->resetContentCache();
00134         }
00135 
00136         oxRegistry::getUtils()->redirect('index.php', true, 302);
00137     }
00138 
00142     public function exturl()
00143     {
00144         $myUtils = oxRegistry::getUtils();
00145         if ($sUrl = oxRegistry::getConfig()->getRequestParameter("url")) {
00146 
00147             // Limit external url's only allowed host
00148             $myConfig = $this->getConfig();
00149             if ($myConfig->getConfigParam('blLoadDynContents') && strpos($sUrl, $this->_sAllowedHost) === 0) {
00150 
00151                 $sPath = $myConfig->getConfigParam('sCompileDir') . "/" . md5($sUrl) . '.html';
00152                 if ($myUtils->getRemoteCachePath($sUrl, $sPath)) {
00153 
00154                     $oStr = getStr();
00155                     $sVersion = $myConfig->getVersion();
00156                     $sEdition = $myConfig->getFullEdition();
00157                     $sCurYear = date("Y");
00158 
00159                     // Get ceontent
00160                     $sOutput = file_get_contents($sPath);
00161 
00162                     // Fix base path
00163                     $sOutput = $oStr->preg_replace("/<\/head>/i", "<base href=\"" . dirname($sUrl) . '/' . "\"></head>\n  <!-- OXID eShop {$sEdition}, Version {$sVersion}, Shopping Cart System (c) OXID eSales AG 2003 - {$sCurYear} - http://www.oxid-esales.com -->", $sOutput);
00164 
00165                     // Fix self url's
00166                     $myUtils->showMessageAndExit($oStr->preg_replace("/href=\"#\"/i", 'href="javascript::void();"', $sOutput));
00167                 }
00168             } else {
00169                 // Caching not allowed, redirecting
00170                 $myUtils->redirect($sUrl, true, 302);
00171             }
00172         }
00173 
00174         $myUtils->showMessageAndExit("");
00175     }
00176 
00183     protected function _doStartUpChecks()
00184     { // #661
00185         $aMessage = array();
00186 
00187         // check if system reguirements are ok
00188         $oSysReq = new oxSysRequirements();
00189         if (!$oSysReq->getSysReqStatus()) {
00190             $aMessage['warning'] = oxRegistry::getLang()->translateString('NAVIGATION_SYSREQ_MESSAGE');
00191             $aMessage['warning'] .= '<a href="?cl=sysreq&amp;stoken=' . $this->getSession()->getSessionChallengeToken() . '" target="basefrm">';
00192             $aMessage['warning'] .= oxRegistry::getLang()->translateString('NAVIGATION_SYSREQ_MESSAGE2') . '</a>';
00193         }
00194 
00195         // version check
00196         if ($this->getConfig()->getConfigParam('blCheckForUpdates')) {
00197             if ($sVersionNotice = $this->_checkVersion()) {
00198                 $aMessage['message'] .= $sVersionNotice;
00199             }
00200         }
00201 
00202 
00203         // check if setup dir is deleted
00204         if (file_exists($this->getConfig()->getConfigParam('sShopDir') . '/setup/index.php')) {
00205             $aMessage['warning'] .= ((!empty($aMessage['warning'])) ? "<br>" : '') . oxRegistry::getLang()->translateString('SETUP_DIRNOTDELETED_WARNING');
00206         }
00207 
00208         // check if updateApp dir is deleted or empty
00209         $sUpdateDir = $this->getConfig()->getConfigParam('sShopDir') . '/updateApp/';
00210         if (file_exists($sUpdateDir) && !(count(glob("$sUpdateDir/*")) === 0)) {
00211             $aMessage['warning'] .= ((!empty($aMessage['warning'])) ? "<br>" : '') . oxRegistry::getLang()->translateString('UPDATEAPP_DIRNOTDELETED_WARNING');
00212         }
00213 
00214         // check if config file is writable
00215         $sConfPath = $this->getConfig()->getConfigParam('sShopDir') . "/config.inc.php";
00216         if (!is_readable($sConfPath) || is_writable($sConfPath)) {
00217             $aMessage['warning'] .= ((!empty($aMessage['warning'])) ? "<br>" : '') . oxRegistry::getLang()->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 = oxRegistry::get("oxUtilsFile")->readRemoteFileAsString($sQuery)) {
00234             // current version is older ..
00235             if (version_compare($this->getConfig()->getVersion(), $sVersion) == '-1') {
00236                 return sprintf(oxRegistry::getLang()->translateString('NAVIGATION_NEWVERSIONAVAILABLE'), $sVersion);
00237             }
00238         }
00239     }
00240 }