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 if ( $myConfig->getConfigParam( "blFormerTplSupport" ) ) {
00120 $sCSSPath = $myConfig->getResourcePath("styles/{$sStylesheet}", false );
00121 $sCSSUrl = $myConfig->getResourceUrl("styles/{$sStylesheet}", false );
00122 } else {
00123 $sCSSPath = $myConfig->getResourcePath("{$sStylesheet}", false );
00124 $sCSSUrl = $myConfig->getResourceUrl("{$sStylesheet}", false );
00125 }
00126
00127 $aCSSPaths = array();
00128 $this->setAdminMode( true );
00129
00130 if (is_file($sCSSPath)) {
00131
00132 $aCSSPaths[] = $sCSSUrl;
00133
00134 if (is_readable($sCSSPath)) {
00135 $aCSS = @file( $sCSSPath);
00136 if ( isset( $aCSS) && $aCSS) {
00137 $aClasses = array();
00138 $oStr = getStr();
00139 foreach ( $aCSS as $key => $sLine ) {
00140 $sLine = trim($sLine);
00141
00142 if ( $sLine[0] == '.' && !$oStr->strstr( $sLine, 'default' ) ) {
00143
00144 $sTag = $oStr->substr( $sLine, 1);
00145 $iEnd = $oStr->strpos( $sTag, ' ' );
00146 if ( !isset( $iEnd ) || !$iEnd ) {
00147 $iEnd = $oStr->strpos( $sTag, '\n' );
00148 }
00149
00150 if ( $sTag = $oStr->substr( $sTag, 0, $iEnd ) ) {
00151 $aClasses["span class='{$sTag}'"] = $sTag;
00152 }
00153 }
00154 }
00155 $this->_oEditor->stylesMenu = $aClasses;
00156 }
00157 }
00158 }
00159
00160 foreach ( $aCSSPaths as $sCssPath ) {
00161 $this->_oEditor->addStylesheet( $sCssPath );
00162 }
00163
00164
00165
00166 $this->_oEditor->loadPlugin( 'templateFilter' );
00167 $this->_oEditor->plugins['templateFilter']->protect( '[{', '}]' );
00168 if ( $myConfig->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00169 $this->_oEditor->plugins['templateFilter']->assign( '[{$oViewConf->getCurrentHomeDir()}]', $myConfig->getShopURL() );
00170
00171 $this->_oEditor->plugins['templateFilter']->assign( '[{ $oViewConf->getCurrentHomeDir()}]', $myConfig->getSSLShopURL() );
00172 }
00173 }
00174
00175 return $this->_oEditor;
00176 }
00177 }
00178
00187 protected function _getEditValue( $oObject, $sField )
00188 {
00189 $sEditObjectValue = '';
00190 if ( $oObject && $sField && isset( $oObject->$sField ) ) {
00191
00192 if ( $oObject->$sField instanceof oxField ) {
00193 $sEditObjectValue = $oObject->$sField->getRawValue();
00194 } else {
00195 $sEditObjectValue = $oObject->$sField->value;
00196 }
00197
00198
00199
00200
00201 if ( !$this->getConfig()->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00202 $aReplace = array( '[{$shop->currenthomedir}]', '[{$oViewConf->getCurrentHomeDir()}]' );
00203 $oObject->$sField = new oxField( str_replace( $aReplace, $this->getConfig()->getCurrentShopURL(), $sEditObjectValue ), oxField::T_RAW );
00204 $sEditObjectValue = $oObject->$sField->value;
00205 }
00206 }
00207
00208 return $sEditObjectValue;
00209 }
00210
00221 protected function _getPlainEditor( $iWidth, $iHeight, $oObject, $sField )
00222 {
00223 $sEditObjectValue = $this->_getEditValue( $oObject, $sField );
00224
00225 if ( strpos( $iWidth, '%' ) === false ) {
00226 $iWidth .= 'px';
00227 }
00228 if ( strpos( $iHeight, '%' ) === false ) {
00229 $iHeight .= 'px';
00230 }
00231 return "<textarea id='editor_{$sField}' style='width:{$iWidth}; height:{$iHeight};'>{$sEditObjectValue}</textarea>";
00232 }
00233
00245 protected function _generateTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet = null )
00246 {
00247
00248 if ( $oEditor = $this->_getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet ) ) {
00249
00250 $sEditorHtml = $oEditor->fetch( $iWidth, $iHeight );
00251 } else {
00252 $sEditorHtml = $this->_getPlainEditor( $iWidth, $iHeight, $oObject, $sField );
00253 }
00254
00255 return $sEditorHtml;
00256 }
00257
00263 public function resetNrOfCatArticles()
00264 {
00265
00266 $this->resetContentCache();
00267 }
00268
00274 public function resetNrOfVendorArticles()
00275 {
00276
00277 $this->resetContentCache();
00278 }
00279
00285 public function resetNrOfManufacturerArticles()
00286 {
00287
00288 $this->resetContentCache();
00289 }
00290
00303 protected function _getCategoryTree( $sTplVarName, $sSelectedCatId, $sEditCatId = '', $blForceNonCache = false, $iTreeShopId = null )
00304 {
00305
00306 if ( !isset( $this->oCatTree ) || $blForceNonCache ) {
00307 $this->oCatTree = oxNew( 'oxCategoryList' );
00308 $this->oCatTree->setShopID( $iTreeShopId );
00309 $this->oCatTree->buildList( $this->getConfig()->getConfigParam( 'bl_perfLoadCatTree' ) );
00310 }
00311
00312
00313 $oCatTree = $this->oCatTree;
00314
00315 if ( $sEditCatId && isset( $oCatTree[$sEditCatId] ) ) {
00316 unset( $oCatTree[$sEditCatId] );
00317 }
00318
00319
00320 $oRoot = oxNew( 'oxcategory' );
00321 $oRoot->oxcategories__oxtitle = new oxField('--');
00322
00323 $oCatTree->assign( array_merge( array( '' => $oRoot ), $oCatTree->getArray() ) );
00324
00325
00326 if ( $sSelectedCatId ) {
00327
00328 foreach ($oCatTree as $oCategory) {
00329 if ($oCategory->getId() == $sSelectedCatId ) {
00330 $oCategory->selected = 1;
00331 break;
00332 }
00333 }
00334 } else {
00335
00336 $oCatTree->rewind();
00337 if ( $oCat = $oCatTree->current() ) {
00338 $oCat->selected = 1;
00339 $sSelectedCatId = $oCat->getId();
00340 }
00341 }
00342
00343
00344 $this->_aViewData[$sTplVarName] = $oCatTree;
00345
00346 return $sSelectedCatId;
00347 }
00348
00354 public function changeFolder()
00355 {
00356 $sFolder = oxConfig::getParameter( 'setfolder' );
00357 $sFolderClass = oxConfig::getParameter( 'folderclass' );
00358
00359 if ( $sFolderClass == 'oxcontent' && $sFolder == 'CMSFOLDER_NONE' ) {
00360 $sFolder = '';
00361 }
00362
00363 $oObject = oxNew( $sFolderClass );
00364 if ( $oObject->load( oxConfig::getParameter( 'oxid' ) ) ) {
00365 $oObject->{$oObject->getCoreTableName() . '__oxfolder'} = new oxField($sFolder);
00366 $oObject->save();
00367 }
00368 }
00369
00377 protected function _setupNavigation( $sNode )
00378 {
00379
00380 if ( $sNode ) {
00381
00382 $myAdminNavig = $this->getNavigation();
00383
00384
00385 $this->_aViewData['default_edit'] = $myAdminNavig->getActiveTab( $sNode, $this->_iDefEdit );
00386
00387
00388 $this->_aViewData['bottom_buttons'] = $myAdminNavig->getBtn( $sNode );
00389 }
00390 }
00391
00399 protected function _resetCounts( $aIds )
00400 {
00401 $oUtils = oxUtilsCount::getInstance();
00402 foreach ( $aIds as $sType => $aResetInfo ) {
00403 foreach ( $aResetInfo as $sResetId => $iPos ) {
00404 switch ( $sType ) {
00405 case 'vendor':
00406 $this->resetCounter( "vendorArticle", $sResetId );
00407 break;
00408 case 'manufacturer':
00409 $this->resetCounter( "manufacturerArticle", $sResetId );
00410 break;
00411 }
00412 }
00413 }
00414 }
00415 }