Go to the documentation of this file.00001 <?php
00002
00008 class oxAdminView extends oxView
00009 {
00015 protected $_aSumType = array(
00016 0 => 'abs',
00017 1 => '%',
00018 2 => 'itm'
00019 );
00020
00026 protected $_sThisTemplate = null;
00027
00034 protected $_iDefEdit = 0;
00035
00041 protected static $_oNaviTree = null;
00042
00048 protected $_iEditLang = 0;
00049
00055 protected $_sShopTitle = " - ";
00056
00062 protected $_sShopVersion = null;
00063
00069 protected $_sServiceUrl = null;
00070
00076 protected static $_sAuthUserRights = null;
00077
00082 protected $_oEditShop = null;
00083
00087 public function __construct()
00088 {
00089 $myConfig = $this->getConfig();
00090 $myConfig->setConfigParam( 'blAdmin', true );
00091
00092 if ( $oShop = $this->_getEditShop( $myConfig->getShopId() ) ) {
00093
00094 $this->_sShopTitle = $oShop->oxshops__oxname->getRawValue();
00095 $this->_sShopVersion = $oShop->oxshops__oxversion->value;
00096
00097 }
00098 }
00099
00107 protected function _getEditShop( $sShopId )
00108 {
00109 if ( !$this->_oEditShop ) {
00110 $this->_oEditShop = $this->getConfig()->getActiveShop();
00111 if ( $this->_oEditShop->getId() != $sShopId ) {
00112 $oEditShop = oxNew( 'oxshop' );
00113 if ( $oEditShop->load( $sShopId ) ) {
00114 $this->_oEditShop = $oEditShop;
00115 }
00116 }
00117 }
00118 return $this->_oEditShop;
00119 }
00120
00128 public function init()
00129 {
00130 $myConfig = $this->getConfig();
00131
00132
00133 if ( !$this->_authorize() ) {
00134 oxUtils::getInstance()->redirect( 'index.php');
00135 exit;
00136 }
00137
00138 $oLang = oxLang::getInstance();
00139
00140
00141 $this->_iEditLang = $oLang->getEditLanguage();
00142 $oLang->setBaseLanguage();
00143
00144 parent::init();
00145
00146 $this->_aViewData['malladmin'] = oxSession::getVar( 'malladmin' );
00147 }
00148
00157 public function addGlobalParams( $oShop = null)
00158 {
00159 $mySession = $this->getSession();
00160 $myConfig = $this->getConfig();
00161 $oLang = oxLang::getInstance();
00162
00163 $oShop = parent::addGlobalParams( $oShop );
00164
00165
00166 $sURL = $myConfig->getConfigParam( 'sShopURL' ). $myConfig->getConfigParam( 'sAdminDir' );
00167
00168 if ($myConfig->getConfigParam('sAdminSSLURL')) {
00169 $sURL = $myConfig->getConfigParam('sAdminSSLURL');
00170 }
00171
00172 $oViewConf = $this->getViewConfig();
00173 $oViewConf->setViewConfigParam( 'selflink', $mySession->url($sURL.'/index.php') );
00174 $oViewConf->setViewConfigParam( 'ajaxlink', str_replace( '&', '&', $mySession->url( $sURL.'/oxajax.php' ) ) );
00175 $oViewConf->setViewConfigParam( 'sServiceUrl', $this->getServiceUrl() );
00176 $oViewConf->setViewConfigParam( 'blLoadDynContents', $myConfig->getConfigParam( 'blLoadDynContents' ) );
00177 $oViewConf->setViewConfigParam( 'sShopCountry', $myConfig->getConfigParam( 'sShopCountry' ) );
00178
00179 if ( $sURL = $myConfig->getConfigParam( 'sAdminSSLURL') ) {
00180 $oViewConf->setViewConfigParam( 'selflink', $mySession->url($sURL.'/index.php') );
00181 $oViewConf->setViewConfigParam( 'ajaxlink', str_replace( '&', '&', $mySession->url( $sURL.'/oxajax.php' ) ) );
00182 }
00183
00184
00185 $iDynInterfaceLanguage = $myConfig->getConfigParam( 'iDynInterfaceLanguage' );
00186
00187 $this->_aViewData['adminlang'] = isset( $iDynInterfaceLanguage )?$iDynInterfaceLanguage:$oLang->getTplLanguage();
00188 $this->_aViewData['charset'] = $oLang->translateString( 'charset' );
00189
00190
00191 $this->_aViewData["oActCur"] = $myConfig->getActShopCurrencyObject();
00192
00193 return $oShop;
00194 }
00195
00201 protected function _getServiceProtocol()
00202 {
00203 return $this->getConfig()->isSsl() ? 'https' : 'http';
00204 }
00205
00213 public function getServiceUrl( $sLangAbbr = null )
00214 {
00215 if ( $this->_sServiceUrl === null ) {
00216
00217 $sProtocol = $this->_getServiceProtocol();
00218
00219
00220
00221 $sUrl = $sProtocol . '://admin.oxid-esales.com/CE/';
00222
00223 $sCountry = $this->_getCountryByCode( $this->getConfig()->getConfigParam( 'sShopCountry' ) );
00224
00225 if ( !$sLangAbbr ) {
00226 $oLang = oxLang::getInstance();
00227 $sLangAbbr = $oLang->getLanguageAbbr( $oLang->getObjectTplLanguage() );
00228 }
00229
00230 $this->_sServiceUrl = $sUrl . $this->_getShopVersionNr()."/{$sCountry}/{$sLangAbbr}/";
00231 }
00232
00233 return $this->_sServiceUrl;
00234 }
00235
00241 protected function _getShopVersionNr()
00242 {
00243 $myConfig = $this->getConfig();
00244
00245 if ( $sShopID = $myConfig->getShopId() ) {
00246 $sQ = "select oxversion from oxshops where oxid = '$sShopID' ";
00247 $sVersion = oxDb::getDb()->getOne( $sQ );
00248 }
00249
00250 $sVersion = preg_replace( "/(^[^0-9]+)(.+)$/", "$2", $sVersion );
00251 return trim( $sVersion );
00252 }
00253
00261 protected function _setupNavigation( $sNode )
00262 {
00263
00264 if ( $sNode ) {
00265
00266 $myAdminNavig = $this->getNavigation();
00267
00268
00269 $iActTab = oxConfig::getParameter( 'actedit' );
00270 $iActTab = $iActTab?$iActTab:$this->_iDefEdit;
00271
00272 $sActTab = $iActTab?"&actedit=$iActTab":'';
00273
00274
00275 $this->_addNavigationHistory($sNode);
00276
00277
00278 $this->_aViewData['listurl'] = $myAdminNavig->getListUrl( $sNode ).$sActTab;
00279
00280
00281 $this->_aViewData['editurl'] = $myAdminNavig->getEditUrl( $sNode, $iActTab ).$sActTab;
00282 }
00283 }
00284
00292 protected function _addNavigationHistory( $sNode )
00293 {
00294 $myUtilsServer = oxUtilsServer::getInstance();
00295
00296
00297 $aHistory = explode('|', $myUtilsServer->getOxCookie('oxidadminhistory'));
00298 if (!is_array($aHistory)) {
00299 $aHistory = array();
00300 }
00301
00302 if (!in_array($sNode, $aHistory)) {
00303 $aHistory[] = $sNode;
00304 }
00305
00306 $myUtilsServer->setOxCookie('oxidadminhistory', implode('|', $aHistory));
00307 }
00308
00315 public function render()
00316 {
00317 $sReturn = parent::render();
00318
00319 $myConfig = $this->getConfig();
00320 $oLang = oxLang::getInstance();
00321
00322
00323 $this->_setupNavigation( oxConfig::getParameter( 'cl' ) );
00324
00325
00326 $sOxId = oxConfig::getParameter( 'oxid' );
00327 $this->_aViewData['oxid'] = ( !$sOxId )?-1:$sOxId;
00328
00329 $this->_aViewData['sumtype'] = $this->_aSumType;
00330
00331
00332 $this->_aViewData['actshop'] = $this->_sShopTitle;
00333 $this->_aViewData["shopid"] = $myConfig->getShopId();
00334
00335
00336 if ( $sActShopId = oxSession::getVar( 'actshop' ) ) {
00337
00338 $this->_aViewData['actshopobj'] = $this->_getEditShop( $sActShopId );
00339 }
00340
00341
00342 $this->_aViewData['actlang'] = $iLanguage = $oLang->getBaseLanguage();
00343 $this->_aViewData['editlanguage'] = $this->_iEditLang;
00344 $this->_aViewData['languages'] = $oLang->getLanguageArray( $iLanguage );
00345
00346
00347 list( $this->_aViewData['iMaxUploadFileSize'], $this->_aViewData['sMaxFormattedFileSize']) = $this->_getMaxUploadFileInfo( @ini_get("upload_max_filesize") );
00348
00349
00350 if ( !isset( $this->_aViewData['updatelist'] ) ) {
00351 $this->_aViewData['updatelist'] = oxConfig::getParameter( 'updatelist' );
00352 }
00353
00354 return $sReturn;
00355 }
00356
00365 protected function _getMaxUploadFileInfo( $iMaxFileSize, $blFormatted = false )
00366 {
00367 $iMaxFileSize = $iMaxFileSize?$iMaxFileSize:'2M';
00368
00369
00370 $iMaxFileSize = trim( $iMaxFileSize );
00371 $sParam = strtolower( $iMaxFileSize{ strlen( $iMaxFileSize )-1 } );
00372 switch( $sParam ) {
00373 case 'g':
00374 $iMaxFileSize *= 1024;
00375 case 'm':
00376 $iMaxFileSize *= 1024;
00377 case 'k':
00378 $iMaxFileSize *= 1024;
00379 }
00380
00381
00382 $aMarkers = array ( 'KB', 'MB', 'GB' );
00383 $sFormattedMaxSize = '';
00384
00385 $iSize = floor( $iMaxFileSize / 1024 );
00386 while ( $iSize && current( $aMarkers ) ) {
00387 $sFormattedMaxSize = $iSize . current( $aMarkers );
00388 $iSize = floor( $iSize / 1024 );
00389 next( $aMarkers );
00390 }
00391
00392 return array( $iMaxFileSize, $sFormattedMaxSize );
00393 }
00394
00400 public function save()
00401 {
00402 }
00403
00411 public function resetContentCache( $blForceReset = null )
00412 {
00413 $blDeleteCacheOnLogout = $this->getConfig()->getConfigParam( 'blClearCacheOnLogout' );
00414
00415
00416 if ( !$blDeleteCacheOnLogout || $blForceReset ) {
00417 oxUtils::getInstance()->oxResetFileCache();
00418 }
00419 }
00420
00430 public function resetCounter( $sCounterType, $sValue = null )
00431 {
00432 $blDeleteCacheOnLogout = $this->getConfig()->getConfigParam( 'blClearCacheOnLogout' );
00433 $myUtilsCount = oxUtilsCount::getInstance();
00434
00435 if ( !$blDeleteCacheOnLogout ) {
00436 switch ( $sCounterType ) {
00437 case 'priceCatArticle':
00438 $myUtilsCount->resetPriceCatArticleCount( $sValue );
00439 break;
00440 case 'catArticle':
00441 $myUtilsCount->resetCatArticleCount( $sValue );
00442 break;
00443 case 'vendorArticle':
00444 $myUtilsCount->resetVendorArticleCount( $sValue );
00445 break;
00446 case 'manufacturerArticle':
00447 $myUtilsCount->resetManufacturerArticleCount( $sValue );
00448 break;
00449 }
00450 }
00451 }
00452
00453
00462 protected function _allowAdminEdit( $sUserId )
00463 {
00464
00465
00466 return true;
00467 }
00468
00476 protected function _getCountryByCode( $sCountryCode )
00477 {
00478 $myConfig = $this->getConfig();
00479
00480
00481 $sCountry = 'international';
00482
00483 if ( !empty($sCountryCode) ) {
00484 $aLangIds = oxLang::getInstance()->getLanguageIds();
00485 $iEnglishId = array_search("en", $aLangIds);
00486 if (false !== $iEnglishId) {
00487 $sEnTag = oxLang::getInstance()->getLanguageTag($iEnglishId);
00488 $sQ = "select oxtitle$sEnTag from oxcountry where oxisoalpha2 = " . oxDb::getDb()->quote( $sCountryCode );
00489 $sCountry = oxDb::getDb()->getOne( $sQ );
00490 } else {
00491
00492 switch ($sCountryCode) {
00493 case 'de':
00494 return 'germany';
00495 default:
00496 return 'international';
00497 }
00498 }
00499 }
00500
00501 return strtolower( $sCountry );
00502 }
00503
00509 protected function _authorize()
00510 {
00511 return ( bool ) ( $this->getSession()->checkSessionChallenge() && count( oxUtilsServer::getInstance()->getOxCookie() ) && oxUtils::getInstance()->checkAccessRights() );
00512 }
00513
00519 public function getNavigation()
00520 {
00521 if ( self::$_oNaviTree == null ) {
00522 self::$_oNaviTree = oxNew( 'oxnavigationtree' );
00523 }
00524 return self::$_oNaviTree;
00525 }
00526
00532 public function getViewId()
00533 {
00534 $sClassName = strtolower( get_class( $this ) );
00535 return $this->getNavigation()->getClassId( $sClassName );
00536 }
00537
00543 public function chshp()
00544 {
00545 $sActShop = oxConfig::getParameter( 'shp' );
00546 oxSession::setVar( "shp", $sActShop );
00547 oxSession::setVar( 'currentadminshop', $sActShop );
00548 }
00549
00557 public function resetSeoData( $sShopId )
00558 {
00559 $oEncoder = oxSeoEncoder::getInstance();
00560 $oEncoder->markAsExpired( null, $sShopId );
00561
00562
00563 $oTagCloud = oxNew('oxtagcloud');
00564 $oTagCloud->resetTagCache();
00565 }
00566
00574 public function resetArtSeoUrl( $aArtIds )
00575 {
00576 if ( !is_array($aArtIds) ) {
00577 $aArtIds = array($aArtIds);
00578 }
00579 foreach ( $aArtIds as $sArtId ) {
00580 oxSeoEncoder::getInstance()->markAsExpired( $sArtId );
00581 }
00582 }
00583
00589 public function getPreviewId()
00590 {
00591 $sAdminSid = oxUtilsServer::getInstance()->getOxCookie( 'admin_sid' );
00592 $oUser = $this->getUser();
00593 return md5( $sAdminSid . $oUser->getId() . $oUser->oxuser__oxpassword->value . $oUser->oxuser__oxrights->value );
00594 }
00595 }