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] == '.' && !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 $this->_oEditor->plugins['templateFilter']->assign( '[{$oViewConf->getCurrentHomeDir()}]', $myConfig->getSSLShopURL() );
00170 }
00171 }
00172
00173 return $this->_oEditor;
00174 }
00175 }
00176
00185 protected function _getEditValue( $oObject, $sField )
00186 {
00187 $sEditObjectValue = '';
00188 if ( $oObject && $sField && isset( $oObject->$sField ) ) {
00189
00190 if ( $oObject->$sField instanceof oxField ) {
00191 $sEditObjectValue = $oObject->$sField->getRawValue();
00192 } else {
00193 $sEditObjectValue = $oObject->$sField->value;
00194 }
00195
00196
00197
00198
00199 if ( !$this->getConfig()->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00200 $aReplace = array( '[{$shop->currenthomedir}]', '[{$oViewConf->getCurrentHomeDir()}]' );
00201 $oObject->$sField = new oxField( str_replace( $aReplace, $this->getConfig()->getCurrentShopURL(), $sEditObjectValue ), oxField::T_RAW );
00202 $sEditObjectValue = $oObject->$sField->value;
00203 }
00204 }
00205
00206 return $sEditObjectValue;
00207 }
00208
00219 protected function _getPlainEditor( $iWidth, $iHeight, $oObject, $sField )
00220 {
00221 $sEditObjectValue = $this->_getEditValue( $oObject, $sField );
00222
00223 if ( strpos( $iWidth, '%' ) === false ) {
00224 $iWidth .= 'px';
00225 }
00226 if ( strpos( $iHeight, '%' ) === false ) {
00227 $iHeight .= 'px';
00228 }
00229 return "<textarea id='editor_{$sField}' style='width:{$iWidth}; height:{$iHeight};'>{$sEditObjectValue}</textarea>";
00230 }
00231
00243 protected function _generateTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet = null )
00244 {
00245
00246 if ( $oEditor = $this->_getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet ) ) {
00247
00248 $sEditorHtml = $oEditor->fetch( $iWidth, $iHeight );
00249 } else {
00250 $sEditorHtml = $this->_getPlainEditor( $iWidth, $iHeight, $oObject, $sField );
00251 }
00252
00253 return $sEditorHtml;
00254 }
00255
00261 public function resetNrOfCatArticles()
00262 {
00263
00264 $this->resetContentCache();
00265 }
00266
00272 public function resetNrOfVendorArticles()
00273 {
00274
00275 $this->resetContentCache();
00276 }
00277
00283 public function resetNrOfManufacturerArticles()
00284 {
00285
00286 $this->resetContentCache();
00287 }
00288
00301 protected function _getCategoryTree( $sTplVarName, $sSelectedCatId, $sEditCatId = '', $blForceNonCache = false, $iTreeShopId = null )
00302 {
00303
00304 if ( !isset( $this->oCatTree ) || $blForceNonCache ) {
00305 $this->oCatTree = oxNew( 'oxCategoryList' );
00306 $this->oCatTree->setShopID( $iTreeShopId );
00307 $this->oCatTree->buildList( $this->getConfig()->getConfigParam( 'bl_perfLoadCatTree' ) );
00308 }
00309
00310
00311 $oCatTree = $this->oCatTree;
00312
00313 if ( $sEditCatId && isset( $oCatTree[$sEditCatId] ) ) {
00314 unset( $oCatTree[$sEditCatId] );
00315 }
00316
00317
00318 $oRoot = oxNew( 'oxcategory' );
00319 $oRoot->oxcategories__oxtitle = new oxField('--');
00320
00321 $oCatTree->assign( array_merge( array( '' => $oRoot ), $oCatTree->getArray() ) );
00322
00323
00324 if ( $sSelectedCatId ) {
00325
00326 foreach ($oCatTree as $oCategory) {
00327 if ($oCategory->getId() == $sSelectedCatId ) {
00328 $oCategory->selected = 1;
00329 break;
00330 }
00331 }
00332 } else {
00333 $oCatTree->rewind();
00334 if ( $oCat = $oCatTree->current() ) {
00335 $oCat->selected = 1;
00336 $sSelectedCatId = $oCat->getId();
00337 }
00338 }
00339
00340
00341 $this->_aViewData[$sTplVarName] = $oCatTree;
00342
00343 return $sSelectedCatId;
00344 }
00345
00351 public function changeFolder()
00352 {
00353 $sFolder = oxConfig::getParameter( 'setfolder' );
00354 $sFolderClass = oxConfig::getParameter( 'folderclass' );
00355
00356 if ( $sFolderClass == 'oxcontent' && $sFolder == 'CMSFOLDER_NONE' ) {
00357 $sFolder = '';
00358 }
00359
00360 $oObject = oxNew( $sFolderClass );
00361 if ( $oObject->load( oxConfig::getParameter( 'oxid' ) ) ) {
00362 $oObject->{$oObject->getCoreTableName() . '__oxfolder'} = new oxField($sFolder);
00363 $oObject->save();
00364 }
00365 }
00366
00374 protected function _setupNavigation( $sNode )
00375 {
00376
00377 if ( $sNode ) {
00378
00379 $myAdminNavig = $this->getNavigation();
00380
00381
00382 $this->_aViewData['default_edit'] = $myAdminNavig->getActiveTab( $sNode, $this->_iDefEdit );
00383
00384
00385 $this->_aViewData['bottom_buttons'] = $myAdminNavig->getBtn( $sNode );
00386 }
00387 }
00388
00396 protected function _resetCounts( $aIds )
00397 {
00398 $oUtils = oxUtilsCount::getInstance();
00399 foreach ( $aIds as $sType => $aResetInfo ) {
00400 foreach ( $aResetInfo as $sResetId => $iPos ) {
00401 switch ( $sType ) {
00402 case 'vendor':
00403 $this->resetCounter( "vendorArticle", $sResetId );
00404 break;
00405 case 'manufacturer':
00406 $this->resetCounter( "manufacturerArticle", $sResetId );
00407 break;
00408 }
00409 }
00410 }
00411 }
00412 }