Go to the documentation of this file.00001 <?php
00002
00008 class oxAdminView extends oxView
00009 {
00010
00016 protected $_aSumType = array(
00017 0 => 'abs',
00018 1 => '%',
00019 2 => 'itm'
00020 );
00021
00027 protected $_sThisTemplate = null;
00028
00035 protected $_iDefEdit = 0;
00036
00042 protected static $_oNaviTree = null;
00043
00049 protected $_iEditLang = 0;
00050
00056 protected $_sShopTitle = " - ";
00057
00063 protected $_sShopVersion = null;
00064
00070 protected $_sServiceUrl = null;
00071
00077 protected static $_sAuthUserRights = null;
00078
00084 protected $_oEditShop = null;
00085
00091 protected $_sEditObjectId = null;
00092
00096 public function __construct()
00097 {
00098 $myConfig = $this->getConfig();
00099 $myConfig->setConfigParam('blAdmin', true);
00100 $this->setAdminMode(true);
00101
00102 if ($oShop = $this->_getEditShop($myConfig->getShopId())) {
00103
00104 $this->_sShopTitle = $oShop->oxshops__oxname->getRawValue();
00105 $this->_sShopVersion = $oShop->oxshops__oxversion->value;
00106
00107 }
00108 }
00109
00117 protected function _getEditShop($sShopId)
00118 {
00119 if (!$this->_oEditShop) {
00120 $this->_oEditShop = $this->getConfig()->getActiveShop();
00121 if ($this->_oEditShop->getId() != $sShopId) {
00122 $oEditShop = oxNew('oxshop');
00123 if ($oEditShop->load($sShopId)) {
00124 $this->_oEditShop = $oEditShop;
00125 }
00126 }
00127 }
00128
00129 return $this->_oEditShop;
00130 }
00131
00137 public function init()
00138 {
00139 $myConfig = $this->getConfig();
00140
00141
00142 if (!$this->_authorize()) {
00143 oxRegistry::getUtils()->redirect('index.php', true, 302);
00144 exit;
00145 }
00146
00147 $oLang = oxRegistry::getLang();
00148
00149
00150 $this->_iEditLang = $oLang->getEditLanguage();
00151 $oLang->setBaseLanguage();
00152
00153 parent::init();
00154
00155 $this->_aViewData['malladmin'] = oxRegistry::getSession()->getVariable('malladmin');
00156 }
00157
00166 public function addGlobalParams($oShop = null)
00167 {
00168 $mySession = $this->getSession();
00169 $myConfig = $this->getConfig();
00170 $oLang = oxRegistry::getLang();
00171
00172 $oShop = parent::addGlobalParams($oShop);
00173
00174
00175 $sURL = $myConfig->getConfigParam('sShopURL') . $myConfig->getConfigParam('sAdminDir') . "/";
00176
00177 if ($myConfig->getConfigParam('sAdminSSLURL')) {
00178 $sURL = $myConfig->getConfigParam('sAdminSSLURL');
00179 }
00180
00181 $oViewConf = $this->getViewConfig();
00182 $oViewConf->setViewConfigParam('selflink', oxRegistry::get("oxUtilsUrl")->processUrl($sURL . 'index.php?editlanguage=' . $this->_iEditLang, false));
00183 $oViewConf->setViewConfigParam('ajaxlink', str_replace('&', '&', oxRegistry::get("oxUtilsUrl")->processUrl($sURL . 'oxajax.php?editlanguage=' . $this->_iEditLang, false)));
00184 $oViewConf->setViewConfigParam('sServiceUrl', $this->getServiceUrl());
00185 $oViewConf->setViewConfigParam('blLoadDynContents', $myConfig->getConfigParam('blLoadDynContents'));
00186 $oViewConf->setViewConfigParam('sShopCountry', $myConfig->getConfigParam('sShopCountry'));
00187
00188
00189 $iDynInterfaceLanguage = $myConfig->getConfigParam('iDynInterfaceLanguage');
00190
00191 $this->_aViewData['adminlang'] = isset($iDynInterfaceLanguage) ? $iDynInterfaceLanguage : $oLang->getTplLanguage();
00192 $this->_aViewData['charset'] = $this->getCharSet();
00193
00194
00195 $this->_aViewData["oActCur"] = $myConfig->getActShopCurrencyObject();
00196
00197 return $oShop;
00198 }
00199
00205 protected function _getServiceProtocol()
00206 {
00207 return $this->getConfig()->isSsl() ? 'https' : 'http';
00208 }
00209
00217 public function getServiceUrl($sLangAbbr = null)
00218 {
00219 if ($this->_sServiceUrl === null) {
00220
00221 $sProtocol = $this->_getServiceProtocol();
00222
00223
00224
00225 $sUrl = $sProtocol . '://admin.oxid-esales.com/CE/';
00226
00227 $sCountry = $this->_getCountryByCode($this->getConfig()->getConfigParam('sShopCountry'));
00228
00229 if (!$sLangAbbr) {
00230 $oLang = oxRegistry::getLang();
00231 $sLangAbbr = $oLang->getLanguageAbbr($oLang->getTplLanguage());
00232 }
00233
00234 if ($sLangAbbr != "de") {
00235 $sLangAbbr = "en";
00236 }
00237
00238 $this->_sServiceUrl = $sUrl . $this->_getShopVersionNr() . "/{$sCountry}/{$sLangAbbr}/";
00239 }
00240
00241 return $this->_sServiceUrl;
00242 }
00243
00249 protected function _getShopVersionNr()
00250 {
00251 $myConfig = $this->getConfig();
00252
00253 if ($sShopID = $myConfig->getShopId()) {
00254 $sQ = "select oxversion from oxshops where oxid = '$sShopID' ";
00255 $sVersion = oxDb::getDb()->getOne($sQ, false, false);
00256 }
00257
00258 $sVersion = preg_replace("/(^[^0-9]+)(.+)$/", "$2", $sVersion);
00259
00260 return trim($sVersion);
00261 }
00262
00268 protected function _setupNavigation($sNode)
00269 {
00270
00271 if ($sNode) {
00272
00273 $myAdminNavig = $this->getNavigation();
00274
00275
00276 $iActTab = oxRegistry::getConfig()->getRequestParameter('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
00297 protected function _addNavigationHistory($sNode)
00298 {
00299 $myUtilsServer = oxRegistry::get("oxUtilsServer");
00300
00301
00302 $aHistory = explode('|', $myUtilsServer->getOxCookie('oxidadminhistory'));
00303 if (!is_array($aHistory)) {
00304 $aHistory = array();
00305 }
00306
00307 if (!in_array($sNode, $aHistory)) {
00308 $aHistory[] = $sNode;
00309 }
00310
00311 $myUtilsServer->setOxCookie('oxidadminhistory', implode('|', $aHistory));
00312 }
00313
00320 public function render()
00321 {
00322 $sReturn = parent::render();
00323
00324 $myConfig = $this->getConfig();
00325 $oLang = oxRegistry::getLang();
00326
00327
00328 $this->_setupNavigation(oxRegistry::getConfig()->getRequestParameter('cl'));
00329
00330
00331 $sOxId = $this->getEditObjectId();
00332 $this->_aViewData['oxid'] = (!$sOxId) ? -1 : $sOxId;
00333
00334 $this->_aViewData['sumtype'] = $this->_aSumType;
00335
00336
00337 $this->_aViewData['actshop'] = $this->_sShopTitle;
00338 $this->_aViewData["shopid"] = $myConfig->getShopId();
00339
00340
00341 if ($sActShopId = oxRegistry::getSession()->getVariable('actshop')) {
00342
00343 $this->_aViewData['actshopobj'] = $this->_getEditShop($sActShopId);
00344 }
00345
00346
00347 $this->_aViewData['actlang'] = $iLanguage = $oLang->getBaseLanguage();
00348 $this->_aViewData['editlanguage'] = $this->_iEditLang;
00349 $this->_aViewData['languages'] = $oLang->getLanguageArray($iLanguage);
00350
00351
00352 list($this->_aViewData['iMaxUploadFileSize'], $this->_aViewData['sMaxFormattedFileSize']) = $this->_getMaxUploadFileInfo(@ini_get("upload_max_filesize"));
00353
00354
00355 if (!isset($this->_aViewData['updatelist'])) {
00356 $this->_aViewData['updatelist'] = oxRegistry::getConfig()->getRequestParameter('updatelist');
00357 }
00358
00359 return $sReturn;
00360 }
00361
00370 protected function _getMaxUploadFileInfo($iMaxFileSize, $blFormatted = false)
00371 {
00372 $iMaxFileSize = $iMaxFileSize ? $iMaxFileSize : '2M';
00373
00374
00375 $iMaxFileSize = trim($iMaxFileSize);
00376 $sParam = strtolower($iMaxFileSize{strlen($iMaxFileSize) - 1});
00377 switch ($sParam) {
00378 case 'g':
00379 $iMaxFileSize *= 1024;
00380
00381 case 'm':
00382 $iMaxFileSize *= 1024;
00383
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
00405 public function save()
00406 {
00407 }
00408
00414 public function resetContentCache($blForceReset = null)
00415 {
00416 $blDeleteCacheOnLogout = $this->getConfig()->getConfigParam('blClearCacheOnLogout');
00417
00418 if (!$blDeleteCacheOnLogout || $blForceReset) {
00419
00420
00421 oxRegistry::getUtils()->oxResetFileCache();
00422
00423 }
00424 }
00425
00433 public function resetCounter($sCounterType, $sValue = null)
00434 {
00435 $blDeleteCacheOnLogout = $this->getConfig()->getConfigParam('blClearCacheOnLogout');
00436 $myUtilsCount = oxRegistry::get("oxUtilsCount");
00437
00438 if (!$blDeleteCacheOnLogout) {
00439 switch ($sCounterType) {
00440 case 'priceCatArticle':
00441 $myUtilsCount->resetPriceCatArticleCount($sValue);
00442 break;
00443 case 'catArticle':
00444 $myUtilsCount->resetCatArticleCount($sValue);
00445 break;
00446 case 'vendorArticle':
00447 $myUtilsCount->resetVendorArticleCount($sValue);
00448 break;
00449 case 'manufacturerArticle':
00450 $myUtilsCount->resetManufacturerArticleCount($sValue);
00451 break;
00452 }
00453 $this->_resetContentCache();
00454 }
00455 }
00456
00460 protected function _resetContentCache()
00461 {
00462 }
00463
00472 protected function _allowAdminEdit($sUserId)
00473 {
00474
00475
00476 return true;
00477 }
00478
00486 protected function _getCountryByCode($sCountryCode)
00487 {
00488 $myConfig = $this->getConfig();
00489
00490
00491 $sCountry = 'international';
00492
00493 if (!empty($sCountryCode)) {
00494 $aLangIds = oxRegistry::getLang()->getLanguageIds();
00495 $iEnglishId = array_search("en", $aLangIds);
00496 if (false !== $iEnglishId) {
00497 $sViewName = getViewName("oxcountry", $iEnglishId);
00498 $sQ = "select oxtitle from {$sViewName} where oxisoalpha2 = " . oxDb::getDb()->quote($sCountryCode);
00499 $sCountryName = oxDb::getDb()->getOne($sQ, false, false);
00500 if ($sCountryName) {
00501 $sCountry = $sCountryName;
00502 }
00503 } else {
00504
00505 switch ($sCountryCode) {
00506 case 'de':
00507 return 'germany';
00508 default:
00509 return 'international';
00510 }
00511 }
00512 }
00513
00514 return strtolower($sCountry);
00515 }
00516
00522 protected function _authorize()
00523 {
00524 return ( bool ) (
00525 $this->getSession()->checkSessionChallenge()
00526 && count(oxRegistry::get("oxUtilsServer")->getOxCookie())
00527 && oxRegistry::getUtils()->checkAccessRights()
00528 );
00529 }
00530
00536 public function getNavigation()
00537 {
00538 if (self::$_oNaviTree == null) {
00539 self::$_oNaviTree = oxNew('oxnavigationtree');
00540 }
00541
00542 return self::$_oNaviTree;
00543 }
00544
00550 public function getViewId()
00551 {
00552 $sClassName = strtolower(get_class($this));
00553
00554 return $this->getNavigation()->getClassId($sClassName);
00555 }
00556
00560 public function chshp()
00561 {
00562 $sActShop = oxRegistry::getConfig()->getRequestParameter('shp');
00563 oxRegistry::getSession()->setVariable("shp", $sActShop);
00564 oxRegistry::getSession()->setVariable('currentadminshop', $sActShop);
00565 }
00566
00572 public function resetSeoData($sShopId)
00573 {
00574 $aTypes = array('oxarticle', 'oxcategory', 'oxvendor', 'oxcontent', 'dynamic', 'oxmanufacturer');
00575 $oEncoder = oxRegistry::get("oxSeoEncoder");
00576 foreach ($aTypes as $sType) {
00577 $oEncoder->markAsExpired(null, $sShopId, 1, null, "oxtype = '{$sType}'");
00578 }
00579
00580
00581 $oTagCloud = oxNew('oxtagcloud');
00582 $oTagCloud->resetCache();
00583 }
00584
00590 public function getPreviewId()
00591 {
00592 return oxRegistry::getUtils()->getPreviewId();
00593 }
00594
00600 public function getEditObjectId()
00601 {
00602 if (null === ($sId = $this->_sEditObjectId)) {
00603 if (null === ($sId = oxRegistry::getConfig()->getRequestParameter("oxid"))) {
00604 $sId = oxRegistry::getSession()->getVariable("saved_oxid");
00605 }
00606 }
00607
00608 return $sId;
00609 }
00610
00616 public function setEditObjectId($sId)
00617 {
00618 $this->_sEditObjectId = $sId;
00619 $this->_aViewData["updatelist"] = 1;
00620 }
00621 }