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
00089 protected $_sEditObjectId = null;
00090
00094 public function __construct()
00095 {
00096 $myConfig = $this->getConfig();
00097 $myConfig->setConfigParam( 'blAdmin', true );
00098 $this->setAdminMode( true );
00099
00100 if ( $oShop = $this->_getEditShop( $myConfig->getShopId() ) ) {
00101
00102 $this->_sShopTitle = $oShop->oxshops__oxname->getRawValue();
00103 $this->_sShopVersion = $oShop->oxshops__oxversion->value;
00104
00105 }
00106 }
00107
00115 protected function _getEditShop( $sShopId )
00116 {
00117 if ( !$this->_oEditShop ) {
00118 $this->_oEditShop = $this->getConfig()->getActiveShop();
00119 if ( $this->_oEditShop->getId() != $sShopId ) {
00120 $oEditShop = oxNew( 'oxshop' );
00121 if ( $oEditShop->load( $sShopId ) ) {
00122 $this->_oEditShop = $oEditShop;
00123 }
00124 }
00125 }
00126 return $this->_oEditShop;
00127 }
00128
00136 public function init()
00137 {
00138 $myConfig = $this->getConfig();
00139
00140
00141 if ( !$this->_authorize() ) {
00142 oxRegistry::getUtils()->redirect( 'index.php', true, 302 );
00143 exit;
00144 }
00145
00146 $oLang = oxRegistry::getLang();
00147
00148
00149 $this->_iEditLang = $oLang->getEditLanguage();
00150 $oLang->setBaseLanguage();
00151
00152 parent::init();
00153
00154 $this->_aViewData['malladmin'] = oxSession::getVar( 'malladmin' );
00155 }
00156
00165 public function addGlobalParams( $oShop = null)
00166 {
00167 $mySession = $this->getSession();
00168 $myConfig = $this->getConfig();
00169 $oLang = oxRegistry::getLang();
00170
00171 $oShop = parent::addGlobalParams( $oShop );
00172
00173
00174 $sURL = $myConfig->getConfigParam( 'sShopURL' ). $myConfig->getConfigParam( 'sAdminDir' ) . "/";
00175
00176 if ($myConfig->getConfigParam('sAdminSSLURL')) {
00177 $sURL = $myConfig->getConfigParam('sAdminSSLURL');
00178 }
00179
00180 $oViewConf = $this->getViewConfig();
00181 $oViewConf->setViewConfigParam( 'selflink', oxRegistry::get("oxUtilsUrl")->processUrl($sURL.'index.php?editlanguage='.$this->_iEditLang, false) );
00182 $oViewConf->setViewConfigParam( 'ajaxlink', str_replace( '&', '&', oxRegistry::get("oxUtilsUrl")->processUrl( $sURL.'oxajax.php?editlanguage='.$this->_iEditLang, false ) ) );
00183 $oViewConf->setViewConfigParam( 'sServiceUrl', $this->getServiceUrl() );
00184 $oViewConf->setViewConfigParam( 'blLoadDynContents', $myConfig->getConfigParam( 'blLoadDynContents' ) );
00185 $oViewConf->setViewConfigParam( 'sShopCountry', $myConfig->getConfigParam( 'sShopCountry' ) );
00186
00187
00188 $iDynInterfaceLanguage = $myConfig->getConfigParam( 'iDynInterfaceLanguage' );
00189
00190 $this->_aViewData['adminlang'] = isset( $iDynInterfaceLanguage )?$iDynInterfaceLanguage:$oLang->getTplLanguage();
00191 $this->_aViewData['charset'] = $this->getCharSet();
00192
00193
00194 $this->_aViewData["oActCur"] = $myConfig->getActShopCurrencyObject();
00195
00196 return $oShop;
00197 }
00198
00204 protected function _getServiceProtocol()
00205 {
00206 return $this->getConfig()->isSsl() ? 'https' : 'http';
00207 }
00208
00216 public function getServiceUrl( $sLangAbbr = null )
00217 {
00218 if ( $this->_sServiceUrl === null ) {
00219
00220 $sProtocol = $this->_getServiceProtocol();
00221
00222
00223
00224 $sUrl = $sProtocol . '://admin.oxid-esales.com/CE/';
00225
00226 $sCountry = $this->_getCountryByCode( $this->getConfig()->getConfigParam( 'sShopCountry' ) );
00227
00228 if ( !$sLangAbbr ) {
00229 $oLang = oxRegistry::getLang();
00230 $sLangAbbr = $oLang->getLanguageAbbr( $oLang->getTplLanguage() );
00231 }
00232
00233 if ( $sLangAbbr != "de" ) {
00234 $sLangAbbr = "en";
00235 }
00236
00237 $this->_sServiceUrl = $sUrl . $this->_getShopVersionNr()."/{$sCountry}/{$sLangAbbr}/";
00238 }
00239
00240 return $this->_sServiceUrl;
00241 }
00242
00248 protected function _getShopVersionNr()
00249 {
00250 $myConfig = $this->getConfig();
00251
00252 if ( $sShopID = $myConfig->getShopId() ) {
00253 $sQ = "select oxversion from oxshops where oxid = '$sShopID' ";
00254 $sVersion = oxDb::getDb()->getOne( $sQ, false, false );
00255 }
00256
00257 $sVersion = preg_replace( "/(^[^0-9]+)(.+)$/", "$2", $sVersion );
00258 return trim( $sVersion );
00259 }
00260
00268 protected function _setupNavigation( $sNode )
00269 {
00270
00271 if ( $sNode ) {
00272
00273 $myAdminNavig = $this->getNavigation();
00274
00275
00276 $iActTab = oxConfig::getParameter( 'actedit' );
00277 $iActTab = $iActTab?$iActTab:$this->_iDefEdit;
00278
00279 $sActTab = $iActTab?"&actedit=$iActTab":'';
00280
00281
00282 $this->_addNavigationHistory($sNode);
00283
00284
00285 $this->_aViewData['listurl'] = $myAdminNavig->getListUrl( $sNode ).$sActTab;
00286
00287
00288 $this->_aViewData['editurl'] = $myAdminNavig->getEditUrl( $sNode, $iActTab ).$sActTab;
00289 }
00290 }
00291
00299 protected function _addNavigationHistory( $sNode )
00300 {
00301 $myUtilsServer = oxRegistry::get("oxUtilsServer");
00302
00303
00304 $aHistory = explode('|', $myUtilsServer->getOxCookie('oxidadminhistory'));
00305 if (!is_array($aHistory)) {
00306 $aHistory = array();
00307 }
00308
00309 if (!in_array($sNode, $aHistory)) {
00310 $aHistory[] = $sNode;
00311 }
00312
00313 $myUtilsServer->setOxCookie('oxidadminhistory', implode('|', $aHistory));
00314 }
00315
00322 public function render()
00323 {
00324 $sReturn = parent::render();
00325
00326 $myConfig = $this->getConfig();
00327 $oLang = oxRegistry::getLang();
00328
00329
00330 $this->_setupNavigation( oxConfig::getParameter( 'cl' ) );
00331
00332
00333 $sOxId = $this->getEditObjectId();
00334 $this->_aViewData['oxid'] = ( !$sOxId )?-1:$sOxId;
00335
00336 $this->_aViewData['sumtype'] = $this->_aSumType;
00337
00338
00339 $this->_aViewData['actshop'] = $this->_sShopTitle;
00340 $this->_aViewData["shopid"] = $myConfig->getShopId();
00341
00342
00343 if ( $sActShopId = oxSession::getVar( 'actshop' ) ) {
00344
00345 $this->_aViewData['actshopobj'] = $this->_getEditShop( $sActShopId );
00346 }
00347
00348
00349 $this->_aViewData['actlang'] = $iLanguage = $oLang->getBaseLanguage();
00350 $this->_aViewData['editlanguage'] = $this->_iEditLang;
00351 $this->_aViewData['languages'] = $oLang->getLanguageArray( $iLanguage );
00352
00353
00354 list( $this->_aViewData['iMaxUploadFileSize'], $this->_aViewData['sMaxFormattedFileSize']) = $this->_getMaxUploadFileInfo( @ini_get("upload_max_filesize") );
00355
00356
00357 if ( !isset( $this->_aViewData['updatelist'] ) ) {
00358 $this->_aViewData['updatelist'] = oxConfig::getParameter( 'updatelist' );
00359 }
00360
00361 return $sReturn;
00362 }
00363
00372 protected function _getMaxUploadFileInfo( $iMaxFileSize, $blFormatted = false )
00373 {
00374 $iMaxFileSize = $iMaxFileSize?$iMaxFileSize:'2M';
00375
00376
00377 $iMaxFileSize = trim( $iMaxFileSize );
00378 $sParam = strtolower( $iMaxFileSize{ strlen( $iMaxFileSize )-1 } );
00379 switch( $sParam ) {
00380 case 'g':
00381 $iMaxFileSize *= 1024;
00382 case 'm':
00383 $iMaxFileSize *= 1024;
00384 case 'k':
00385 $iMaxFileSize *= 1024;
00386 }
00387
00388
00389 $aMarkers = array ( 'KB', 'MB', 'GB' );
00390 $sFormattedMaxSize = '';
00391
00392 $iSize = floor( $iMaxFileSize / 1024 );
00393 while ( $iSize && current( $aMarkers ) ) {
00394 $sFormattedMaxSize = $iSize . " " . current( $aMarkers );
00395 $iSize = floor( $iSize / 1024 );
00396 next( $aMarkers );
00397 }
00398
00399 return array( $iMaxFileSize, $sFormattedMaxSize );
00400 }
00401
00407 public function save()
00408 {
00409 }
00410
00418 public function resetContentCache( $blForceReset = null )
00419 {
00420 $blDeleteCacheOnLogout = $this->getConfig()->getConfigParam( 'blClearCacheOnLogout' );
00421
00422 if ( !$blDeleteCacheOnLogout || $blForceReset ) {
00423
00424
00425 oxRegistry::getUtils()->oxResetFileCache();
00426
00427 }
00428 }
00429
00439 public function resetCounter( $sCounterType, $sValue = null )
00440 {
00441 $blDeleteCacheOnLogout = $this->getConfig()->getConfigParam( 'blClearCacheOnLogout' );
00442 $myUtilsCount = oxRegistry::get("oxUtilsCount");
00443
00444 if ( !$blDeleteCacheOnLogout ) {
00445 switch ( $sCounterType ) {
00446 case 'priceCatArticle':
00447 $myUtilsCount->resetPriceCatArticleCount( $sValue );
00448 break;
00449 case 'catArticle':
00450 $myUtilsCount->resetCatArticleCount( $sValue );
00451 break;
00452 case 'vendorArticle':
00453 $myUtilsCount->resetVendorArticleCount( $sValue );
00454 break;
00455 case 'manufacturerArticle':
00456 $myUtilsCount->resetManufacturerArticleCount( $sValue );
00457 break;
00458 }
00459 }
00460 }
00461
00470 protected function _allowAdminEdit( $sUserId )
00471 {
00472
00473
00474 return true;
00475 }
00476
00484 protected function _getCountryByCode( $sCountryCode )
00485 {
00486 $myConfig = $this->getConfig();
00487
00488
00489 $sCountry = 'international';
00490
00491 if ( !empty( $sCountryCode ) ) {
00492 $aLangIds = oxRegistry::getLang()->getLanguageIds();
00493 $iEnglishId = array_search("en", $aLangIds);
00494 if ( false !== $iEnglishId ) {
00495 $sViewName = getViewName( "oxcountry", $iEnglishId );
00496 $sQ = "select oxtitle from {$sViewName} where oxisoalpha2 = " . oxDb::getDb()->quote( $sCountryCode );
00497 $sCountryName = oxDb::getDb()->getOne( $sQ, false, false );
00498 if ( $sCountryName ) {
00499 $sCountry = $sCountryName;
00500 }
00501 } else {
00502
00503 switch ( $sCountryCode ) {
00504 case 'de':
00505 return 'germany';
00506 default:
00507 return 'international';
00508 }
00509 }
00510 }
00511 return strtolower( $sCountry );
00512 }
00513
00519 protected function _authorize()
00520 {
00521 return ( bool ) (
00522 $this->getSession()->checkSessionChallenge()
00523 && count( oxRegistry::get("oxUtilsServer")->getOxCookie() )
00524 && oxRegistry::getUtils()->checkAccessRights()
00525 );
00526 }
00527
00533 public function getNavigation()
00534 {
00535 if ( self::$_oNaviTree == null ) {
00536 self::$_oNaviTree = oxNew( 'oxnavigationtree' );
00537 }
00538 return self::$_oNaviTree;
00539 }
00540
00546 public function getViewId()
00547 {
00548 $sClassName = strtolower( get_class( $this ) );
00549 return $this->getNavigation()->getClassId( $sClassName );
00550 }
00551
00557 public function chshp()
00558 {
00559 $sActShop = oxConfig::getParameter( 'shp' );
00560 oxSession::setVar( "shp", $sActShop );
00561 oxSession::setVar( 'currentadminshop', $sActShop );
00562 }
00563
00571 public function resetSeoData( $sShopId )
00572 {
00573 $aTypes = array( 'oxarticle', 'oxcategory', 'oxvendor', 'oxcontent', 'dynamic', 'oxmanufacturer' );
00574 $oEncoder = oxRegistry::get("oxSeoEncoder");
00575 foreach ( $aTypes as $sType ) {
00576 $oEncoder->markAsExpired( null, $sShopId, 1, null, "oxtype = '{$sType}'" );
00577 }
00578
00579
00580 $oTagCloud = oxNew('oxtagcloud');
00581 $oTagCloud->resetCache();
00582 }
00583
00589 public function getPreviewId()
00590 {
00591 return oxRegistry::getUtils()->getPreviewId();
00592 }
00593
00599 public function getEditObjectId()
00600 {
00601 if ( null === ( $sId = $this->_sEditObjectId ) ) {
00602 if ( null === ( $sId = oxConfig::getParameter( "oxid" ) ) ) {
00603 $sId = oxSession::getVar( "saved_oxid" );
00604 }
00605 }
00606 return $sId;
00607 }
00608
00616 public function setEditObjectId( $sId )
00617 {
00618 $this->_sEditObjectId = $sId;
00619 $this->_aViewData["updatelist"] = 1;
00620 }
00621 }