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 if ( $sLangAbbr != "de" ) {
00231 $sLangAbbr = "en";
00232 }
00233
00234 $this->_sServiceUrl = $sUrl . $this->_getShopVersionNr()."/{$sCountry}/{$sLangAbbr}/";
00235 }
00236
00237 return $this->_sServiceUrl;
00238 }
00239
00245 protected function _getShopVersionNr()
00246 {
00247 $myConfig = $this->getConfig();
00248
00249 if ( $sShopID = $myConfig->getShopId() ) {
00250 $sQ = "select oxversion from oxshops where oxid = '$sShopID' ";
00251 $sVersion = oxDb::getDb()->getOne( $sQ );
00252 }
00253
00254 $sVersion = preg_replace( "/(^[^0-9]+)(.+)$/", "$2", $sVersion );
00255 return trim( $sVersion );
00256 }
00257
00265 protected function _setupNavigation( $sNode )
00266 {
00267
00268 if ( $sNode ) {
00269
00270 $myAdminNavig = $this->getNavigation();
00271
00272
00273 $iActTab = oxConfig::getParameter( 'actedit' );
00274 $iActTab = $iActTab?$iActTab:$this->_iDefEdit;
00275
00276 $sActTab = $iActTab?"&actedit=$iActTab":'';
00277
00278
00279 $this->_addNavigationHistory($sNode);
00280
00281
00282 $this->_aViewData['listurl'] = $myAdminNavig->getListUrl( $sNode ).$sActTab;
00283
00284
00285 $this->_aViewData['editurl'] = $myAdminNavig->getEditUrl( $sNode, $iActTab ).$sActTab;
00286 }
00287 }
00288
00296 protected function _addNavigationHistory( $sNode )
00297 {
00298 $myUtilsServer = oxUtilsServer::getInstance();
00299
00300
00301 $aHistory = explode('|', $myUtilsServer->getOxCookie('oxidadminhistory'));
00302 if (!is_array($aHistory)) {
00303 $aHistory = array();
00304 }
00305
00306 if (!in_array($sNode, $aHistory)) {
00307 $aHistory[] = $sNode;
00308 }
00309
00310 $myUtilsServer->setOxCookie('oxidadminhistory', implode('|', $aHistory));
00311 }
00312
00319 public function render()
00320 {
00321 $sReturn = parent::render();
00322
00323 $myConfig = $this->getConfig();
00324 $oLang = oxLang::getInstance();
00325
00326
00327 $this->_setupNavigation( oxConfig::getParameter( 'cl' ) );
00328
00329
00330 $sOxId = oxConfig::getParameter( 'oxid' );
00331 $this->_aViewData['oxid'] = ( !$sOxId )?-1:$sOxId;
00332
00333 $this->_aViewData['sumtype'] = $this->_aSumType;
00334
00335
00336 $this->_aViewData['actshop'] = $this->_sShopTitle;
00337 $this->_aViewData["shopid"] = $myConfig->getShopId();
00338
00339
00340 if ( $sActShopId = oxSession::getVar( 'actshop' ) ) {
00341
00342 $this->_aViewData['actshopobj'] = $this->_getEditShop( $sActShopId );
00343 }
00344
00345
00346 $this->_aViewData['actlang'] = $iLanguage = $oLang->getBaseLanguage();
00347 $this->_aViewData['editlanguage'] = $this->_iEditLang;
00348 $this->_aViewData['languages'] = $oLang->getLanguageArray( $iLanguage );
00349
00350
00351 list( $this->_aViewData['iMaxUploadFileSize'], $this->_aViewData['sMaxFormattedFileSize']) = $this->_getMaxUploadFileInfo( @ini_get("upload_max_filesize") );
00352
00353
00354 if ( !isset( $this->_aViewData['updatelist'] ) ) {
00355 $this->_aViewData['updatelist'] = oxConfig::getParameter( 'updatelist' );
00356 }
00357
00358 return $sReturn;
00359 }
00360
00369 protected function _getMaxUploadFileInfo( $iMaxFileSize, $blFormatted = false )
00370 {
00371 $iMaxFileSize = $iMaxFileSize?$iMaxFileSize:'2M';
00372
00373
00374 $iMaxFileSize = trim( $iMaxFileSize );
00375 $sParam = strtolower( $iMaxFileSize{ strlen( $iMaxFileSize )-1 } );
00376 switch( $sParam ) {
00377 case 'g':
00378 $iMaxFileSize *= 1024;
00379 case 'm':
00380 $iMaxFileSize *= 1024;
00381 case 'k':
00382 $iMaxFileSize *= 1024;
00383 }
00384
00385
00386 $aMarkers = array ( 'KB', 'MB', 'GB' );
00387 $sFormattedMaxSize = '';
00388
00389 $iSize = floor( $iMaxFileSize / 1024 );
00390 while ( $iSize && current( $aMarkers ) ) {
00391 $sFormattedMaxSize = $iSize . current( $aMarkers );
00392 $iSize = floor( $iSize / 1024 );
00393 next( $aMarkers );
00394 }
00395
00396 return array( $iMaxFileSize, $sFormattedMaxSize );
00397 }
00398
00404 public function save()
00405 {
00406 }
00407
00415 public function resetContentCache( $blForceReset = null )
00416 {
00417 $blDeleteCacheOnLogout = $this->getConfig()->getConfigParam( 'blClearCacheOnLogout' );
00418
00419
00420 if ( !$blDeleteCacheOnLogout || $blForceReset ) {
00421 oxUtils::getInstance()->oxResetFileCache();
00422 }
00423 }
00424
00434 public function resetCounter( $sCounterType, $sValue = null )
00435 {
00436 $blDeleteCacheOnLogout = $this->getConfig()->getConfigParam( 'blClearCacheOnLogout' );
00437 $myUtilsCount = oxUtilsCount::getInstance();
00438
00439 if ( !$blDeleteCacheOnLogout ) {
00440 switch ( $sCounterType ) {
00441 case 'priceCatArticle':
00442 $myUtilsCount->resetPriceCatArticleCount( $sValue );
00443 break;
00444 case 'catArticle':
00445 $myUtilsCount->resetCatArticleCount( $sValue );
00446 break;
00447 case 'vendorArticle':
00448 $myUtilsCount->resetVendorArticleCount( $sValue );
00449 break;
00450 case 'manufacturerArticle':
00451 $myUtilsCount->resetManufacturerArticleCount( $sValue );
00452 break;
00453 }
00454 }
00455 }
00456
00457
00466 protected function _allowAdminEdit( $sUserId )
00467 {
00468
00469
00470 return true;
00471 }
00472
00480 protected function _getCountryByCode( $sCountryCode )
00481 {
00482 $myConfig = $this->getConfig();
00483
00484
00485 $sCountry = 'international';
00486
00487 if ( !empty($sCountryCode) ) {
00488 $aLangIds = oxLang::getInstance()->getLanguageIds();
00489 $iEnglishId = array_search("en", $aLangIds);
00490 if (false !== $iEnglishId) {
00491 $sEnTag = oxLang::getInstance()->getLanguageTag($iEnglishId);
00492 $sQ = "select oxtitle$sEnTag from oxcountry where oxisoalpha2 = " . oxDb::getDb()->quote( $sCountryCode );
00493 $sCountry = oxDb::getDb()->getOne( $sQ );
00494 } else {
00495
00496 switch ($sCountryCode) {
00497 case 'de':
00498 return 'germany';
00499 default:
00500 return 'international';
00501 }
00502 }
00503 }
00504
00505 return strtolower( $sCountry );
00506 }
00507
00513 protected function _authorize()
00514 {
00515 return ( bool ) ( $this->getSession()->checkSessionChallenge() && count( oxUtilsServer::getInstance()->getOxCookie() ) && oxUtils::getInstance()->checkAccessRights() );
00516 }
00517
00523 public function getNavigation()
00524 {
00525 if ( self::$_oNaviTree == null ) {
00526 self::$_oNaviTree = oxNew( 'oxnavigationtree' );
00527 }
00528 return self::$_oNaviTree;
00529 }
00530
00536 public function getViewId()
00537 {
00538 $sClassName = strtolower( get_class( $this ) );
00539 return $this->getNavigation()->getClassId( $sClassName );
00540 }
00541
00547 public function chshp()
00548 {
00549 $sActShop = oxConfig::getParameter( 'shp' );
00550 oxSession::setVar( "shp", $sActShop );
00551 oxSession::setVar( 'currentadminshop', $sActShop );
00552 }
00553
00561 public function resetSeoData( $sShopId )
00562 {
00563 $aTypes = array( 'oxarticle', 'oxcategory', 'oxvendor', 'oxcontent', 'dynamic', 'oxmanufacturer' );
00564 $oEncoder = oxSeoEncoder::getInstance();
00565 foreach ( $aTypes as $sType ) {
00566 $oEncoder->markAsExpired( null, $sShopId, 1, null, "oxtype = '{$sType}'" );
00567 }
00568
00569
00570 $oTagCloud = oxNew('oxtagcloud');
00571 $oTagCloud->resetTagCache();
00572 }
00573
00581 public function resetArtSeoUrl( $aArtIds )
00582 {
00583 if ( empty( $aArtIds ) ) {
00584 return;
00585 }
00586
00587 if ( !is_array($aArtIds) ) {
00588 $aArtIds = array($aArtIds);
00589 }
00590
00591 $sShopId = $this->getConfig()->getShopId();
00592 foreach ( $aArtIds as $sArtId ) {
00593 oxSeoEncoder::getInstance()->markAsExpired( $sArtId, $sShopId, 1, null, "oxtype='oxarticle'" );
00594 }
00595 }
00596
00602 public function getPreviewId()
00603 {
00604 return oxUtils::getInstance()->getPreviewId();
00605 }
00606 }