00001 <?php
00002
00006 require_once "oxajax.php";
00007
00011 class oxAdminDetails extends oxAdminView
00012 {
00018 protected $_oEditor = null;
00019
00025 public function render()
00026 {
00027 $sReturn = parent::render();
00028
00029
00030 $myConfig = $this->getConfig();
00031 $sDir = $myConfig->getConfigParam( 'sShopDir' ) . '/documentation/admin';
00032 if ( is_dir( $sDir ) ) {
00033 $sDir = $myConfig->getConfigParam( 'sShopURL' ) . 'documentation/admin';
00034 } else {
00035
00036 $oShop = $this->_getEditShop( oxSession::getVar( 'actshop' ) );
00037
00038 $sDir = "http://docu.oxid-esales.com/PE/{$oShop->oxshops__oxversion->value}/" . oxLang::getInstance()->getTplLanguage() . '/admin';
00039 }
00040
00041 $this->_aViewData['sHelpURL'] = $sDir;
00042
00043 return $sReturn;
00044 }
00045
00057 protected function _getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet = null )
00058 {
00059 if ( $this->_oEditor === null ) {
00060 $myConfig = $this->getConfig();
00061
00062
00063 $sEditorPath = 'wysiwigpro';
00064 $sEditorFile = getShopBasePath()."admin/".$sEditorPath . '/wysiwygPro.class.php';
00065
00066
00067
00068 $this->_oEditor = false;
00069
00070 if ( $sEditorFile && file_exists( $sEditorFile ) ) {
00071 include_once ($sEditorFile);
00072
00073
00074 $this->_oEditor = new wysiwygPro();
00075
00076
00077 $sEditorUrl = $myConfig->getConfigParam( 'sShopURL' ).$myConfig->getConfigParam( 'sAdminDir' )."/{$sEditorPath}/";
00078 if ( $sAdminSSLURL = $myConfig->getConfigParam( 'sAdminSSLURL' ) ) {
00079 $sEditorUrl = "{$sAdminSSLURL}/{$sEditorPath}/";
00080 }
00081
00082 $this->_oEditor->editorURL = $sEditorUrl;
00083 $this->_oEditor->urlFormat = 'preserve';
00084
00085
00086 $this->_oEditor->documentDir = $this->_oEditor->imageDir = $myConfig->getPictureDir( false ).'wysiwigpro/';
00087 $this->_oEditor->documentURL = $this->_oEditor->imageURL = $myConfig->getPictureUrl( null, false ).'wysiwigpro/';
00088
00089
00090 $this->_oEditor->upload = true;
00091
00092
00093 $this->_oEditor->emptyValue = "";
00094
00095
00096 $this->_oEditor->deleteFiles = true;
00097 $this->_oEditor->deleteFolders = true;
00098
00099
00100 $this->_oEditor->allowedImageExtensions = '.jpg, .jpeg, .gif, .png';
00101
00102
00103 $this->_oEditor->allowedDocExtensions = '.html, .htm, .pdf, .doc, .rtf, .txt, .xl, .xls, .ppt, .pps, .zip, .tar, .swf, .wmv, .rm, .mov, .jpg, .jpeg, .gif, .png';
00104
00105
00106 $this->_oEditor->name = $sField;
00107
00108
00109 $oLang = oxLang::getInstance();
00110 $this->_oEditor->lang = $oLang->translateString( 'editor_language', $oLang->getTplLanguage() );
00111
00112
00113 if ( $sEditObjectValue = $this->_getEditValue( $oObject, $sField ) ) {
00114 $this->_oEditor->value = $sEditObjectValue;
00115 }
00116
00117
00118 $this->setAdminMode( false );
00119 $sCSSPath = $myConfig->getResourcePath("styles/{$sStylesheet}", false );
00120 $sCSSUrl = $myConfig->getResourceUrl("styles/{$sStylesheet}", false );
00121
00122 $aCSSPaths = array();
00123
00124
00125 $aCSSPaths[] = $myConfig->getResourcePath("oxid.css", false );
00126
00127 $this->setAdminMode( true );
00128
00129 if (is_file($sCSSPath)) {
00130
00131 $aCSSPaths[] = $sCSSUrl;
00132
00133 if (is_readable($sCSSPath)) {
00134 $aCSS = @file( $sCSSPath);
00135 if ( isset( $aCSS) && $aCSS) {
00136 $aClasses = array();
00137 $oStr = getStr();
00138 foreach ( $aCSS as $key => $sLine ) {
00139 $sLine = trim($sLine);
00140
00141 if ( $sLine[0] == '.' && !$oStr->strstr( $sLine, 'default' ) ) {
00142
00143 $sTag = $oStr->substr( $sLine, 1);
00144 $iEnd = $oStr->strpos( $sTag, ' ' );
00145 if ( !isset( $iEnd ) || !$iEnd ) {
00146 $iEnd = $oStr->strpos( $sTag, '\n' );
00147 }
00148
00149 if ( $sTag = $oStr->substr( $sTag, 0, $iEnd ) ) {
00150 $aClasses["span class='{$sTag}'"] = $sTag;
00151 }
00152 }
00153 }
00154 $this->_oEditor->stylesMenu = $aClasses;
00155 }
00156 }
00157 }
00158
00159 foreach ( $aCSSPaths as $sCssPath ) {
00160 $this->_oEditor->addStylesheet( $sCssPath );
00161 }
00162
00163
00164
00165 $this->_oEditor->loadPlugin( 'templateFilter' );
00166 $this->_oEditor->plugins['templateFilter']->protect( '[{', '}]' );
00167 if ( $myConfig->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00168 $this->_oEditor->plugins['templateFilter']->assign( '[{$oViewConf->getCurrentHomeDir()}]', $myConfig->getShopURL() );
00169
00170 $this->_oEditor->plugins['templateFilter']->assign( '[{ $oViewConf->getCurrentHomeDir()}]', $myConfig->getSSLShopURL() );
00171 }
00172 }
00173
00174 return $this->_oEditor;
00175 }
00176 }
00177
00186 protected function _getEditValue( $oObject, $sField )
00187 {
00188 $sEditObjectValue = '';
00189 if ( $oObject && $sField && isset( $oObject->$sField ) ) {
00190
00191 if ( $oObject->$sField instanceof oxField ) {
00192 $sEditObjectValue = $oObject->$sField->getRawValue();
00193 } else {
00194 $sEditObjectValue = $oObject->$sField->value;
00195 }
00196
00197
00198
00199
00200 if ( !$this->getConfig()->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00201 $aReplace = array( '[{$shop->currenthomedir}]', '[{$oViewConf->getCurrentHomeDir()}]' );
00202 $oObject->$sField = new oxField( str_replace( $aReplace, $this->getConfig()->getCurrentShopURL(), $sEditObjectValue ), oxField::T_RAW );
00203 $sEditObjectValue = $oObject->$sField->value;
00204 }
00205 }
00206
00207 return $sEditObjectValue;
00208 }
00209
00220 protected function _getPlainEditor( $iWidth, $iHeight, $oObject, $sField )
00221 {
00222 $sEditObjectValue = $this->_getEditValue( $oObject, $sField );
00223
00224 if ( strpos( $iWidth, '%' ) === false ) {
00225 $iWidth .= 'px';
00226 }
00227 if ( strpos( $iHeight, '%' ) === false ) {
00228 $iHeight .= 'px';
00229 }
00230 return "<textarea id='editor_{$sField}' style='width:{$iWidth}; height:{$iHeight};'>{$sEditObjectValue}</textarea>";
00231 }
00232
00244 protected function _generateTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet = null )
00245 {
00246
00247 if ( $oEditor = $this->_getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet ) ) {
00248
00249 $sEditorHtml = $oEditor->fetch( $iWidth, $iHeight );
00250 } else {
00251 $sEditorHtml = $this->_getPlainEditor( $iWidth, $iHeight, $oObject, $sField );
00252 }
00253
00254 return $sEditorHtml;
00255 }
00256
00262 public function resetNrOfCatArticles()
00263 {
00264
00265 $this->resetContentCache();
00266 }
00267
00273 public function resetNrOfVendorArticles()
00274 {
00275
00276 $this->resetContentCache();
00277 }
00278
00284 public function resetNrOfManufacturerArticles()
00285 {
00286
00287 $this->resetContentCache();
00288 }
00289
00302 protected function _getCategoryTree( $sTplVarName, $sSelectedCatId, $sEditCatId = '', $blForceNonCache = false, $iTreeShopId = null )
00303 {
00304
00305 if ( !isset( $this->oCatTree ) || $blForceNonCache ) {
00306 $this->oCatTree = oxNew( 'oxCategoryList' );
00307 $this->oCatTree->setShopID( $iTreeShopId );
00308 $this->oCatTree->buildList( $this->getConfig()->getConfigParam( 'bl_perfLoadCatTree' ) );
00309 }
00310
00311
00312 $oCatTree = $this->oCatTree;
00313
00314 if ( $sEditCatId && isset( $oCatTree[$sEditCatId] ) ) {
00315 unset( $oCatTree[$sEditCatId] );
00316 }
00317
00318
00319 $oRoot = oxNew( 'oxcategory' );
00320 $oRoot->oxcategories__oxtitle = new oxField('--');
00321
00322 $oCatTree->assign( array_merge( array( '' => $oRoot ), $oCatTree->getArray() ) );
00323
00324
00325 if ( $sSelectedCatId ) {
00326
00327 foreach ($oCatTree as $oCategory) {
00328 if ($oCategory->getId() == $sSelectedCatId ) {
00329 $oCategory->selected = 1;
00330 break;
00331 }
00332 }
00333 } else {
00334 $oCatTree->rewind();
00335 if ( $oCat = $oCatTree->current() ) {
00336 $oCat->selected = 1;
00337 $sSelectedCatId = $oCat->getId();
00338 }
00339 }
00340
00341
00342 $this->_aViewData[$sTplVarName] = $oCatTree;
00343
00344 return $sSelectedCatId;
00345 }
00346
00352 public function changeFolder()
00353 {
00354 $sFolder = oxConfig::getParameter( 'setfolder' );
00355 $sFolderClass = oxConfig::getParameter( 'folderclass' );
00356
00357 if ( $sFolderClass == 'oxcontent' && $sFolder == 'CMSFOLDER_NONE' ) {
00358 $sFolder = '';
00359 }
00360
00361 $oObject = oxNew( $sFolderClass );
00362 if ( $oObject->load( oxConfig::getParameter( 'oxid' ) ) ) {
00363 $oObject->{$oObject->getCoreTableName() . '__oxfolder'} = new oxField($sFolder);
00364 $oObject->save();
00365 }
00366 }
00367
00375 protected function _setupNavigation( $sNode )
00376 {
00377
00378 if ( $sNode ) {
00379
00380 $myAdminNavig = $this->getNavigation();
00381
00382
00383 $this->_aViewData['default_edit'] = $myAdminNavig->getActiveTab( $sNode, $this->_iDefEdit );
00384
00385
00386 $this->_aViewData['bottom_buttons'] = $myAdminNavig->getBtn( $sNode );
00387 }
00388 }
00389
00397 protected function _resetCounts( $aIds )
00398 {
00399 $oUtils = oxUtilsCount::getInstance();
00400 foreach ( $aIds as $sType => $aResetInfo ) {
00401 foreach ( $aResetInfo as $sResetId => $iPos ) {
00402 switch ( $sType ) {
00403 case 'vendor':
00404 $this->resetCounter( "vendorArticle", $sResetId );
00405 break;
00406 case 'manufacturer':
00407 $this->resetCounter( "manufacturerArticle", $sResetId );
00408 break;
00409 }
00410 }
00411 }
00412 }
00413 }