oxadmindetails.php

Go to the documentation of this file.
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         // generate help link
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                 //$sDir = "http://docu.oxid-esales.com/PE/{$oShop->oxshops__oxversion->value}/" . $myConfig->getConfigParam( 'iAdminLanguage' ) . '/admin';
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             // include the config file and editor class:
00063             $sEditorPath = 'wysiwigpro';
00064             $sEditorFile = getShopBasePath()."admin/".$sEditorPath . '/wysiwygPro.class.php';
00065 
00066 
00067             // setting loaded state
00068             $this->_oEditor = false;
00069 
00070             if ( $sEditorFile && file_exists( $sEditorFile ) ) {
00071                 include_once ($sEditorFile);
00072 
00073                 // create a new instance of the wysiwygPro class:
00074                 $this->_oEditor = new wysiwygPro();
00075 
00076                 // set language file name
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                 // document & image directory:
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                 // enabling upload
00090                 $this->_oEditor->upload = true;
00091 
00092                 // setting empty value
00093                 $this->_oEditor->emptyValue = "";
00094 
00095                 //#M432 enabling deleting files and folders
00096                 $this->_oEditor->deleteFiles = true;
00097                 $this->_oEditor->deleteFolders = true;
00098 
00099                 // allowed image extensions
00100                 $this->_oEditor->allowedImageExtensions = '.jpg, .jpeg, .gif, .png';
00101 
00102                 // allowed document extensions
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                 // set name
00106                 $this->_oEditor->name = $sField;
00107 
00108                 // set language file name
00109                 $oLang = oxLang::getInstance();
00110                 $this->_oEditor->lang = $oLang->translateString( 'editor_language', $oLang->getTplLanguage() );
00111 
00112                 // set contents
00113                 if ( $sEditObjectValue = $this->_getEditValue( $oObject, $sField ) ) {
00114                     $this->_oEditor->value = $sEditObjectValue;
00115                 }
00116 
00117                 // parse for styles and add them
00118                 $this->setAdminMode( false );
00119                 $sCSSPath = $myConfig->getResourcePath("styles/{$sStylesheet}", false );
00120                 $sCSSUrl  = $myConfig->getResourceUrl("styles/{$sStylesheet}", false );
00121 
00122                 $aCSSPaths = array();
00123 
00124                 // #1157C - in wysiwigpro editor font problem
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                                     // found one tag
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                 //while there is a bug in editor template filter we cannot use this feature
00164                 // loading template filter plugin
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                     // note: in "[{ $" the space is needed for this parameter not to override previous call. see assign fnc of templateFilter
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             // A. replace ONLY if long description is not processed by smarty, or users will not be able to
00198             // store smarty tags ([{$shop->currenthomedir}]/[{$oViewConf->getCurrentHomeDir()}]) in long
00199             // descriptions, which are filled dynamically
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         // setup editor
00247         if ( $oEditor = $this->_getTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet ) ) {
00248             // generate and return editor code
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         // resetting categories article count cache
00265         $this->resetContentCache();
00266     }
00267 
00273     public function resetNrOfVendorArticles()
00274     {
00275         // resetting vendors cache
00276         $this->resetContentCache();
00277     }
00278 
00284     public function resetNrOfManufacturerArticles()
00285     {
00286         // resetting manufacturers cache
00287         $this->resetContentCache();
00288     }
00289 
00302     protected function _getCategoryTree( $sTplVarName, $sSelectedCatId, $sEditCatId = '', $blForceNonCache = false, $iTreeShopId = null )
00303     {
00304         // caching category tree, to load it once, not many times
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         // copying tree
00312         $oCatTree = $this->oCatTree;
00313         //removing current category
00314         if ( $sEditCatId && isset( $oCatTree[$sEditCatId] ) ) {
00315             unset( $oCatTree[$sEditCatId] );
00316         }
00317 
00318         // add first fake category for not assigned articles
00319         $oRoot = oxNew( 'oxcategory' );
00320         $oRoot->oxcategories__oxtitle = new oxField('--');
00321 
00322         $oCatTree->assign( array_merge( array( '' => $oRoot ), $oCatTree->getArray() ) );
00323 
00324         // mark selected
00325         if ( $sSelectedCatId ) {
00326             // fixed parent category in select list
00327             foreach ($oCatTree as $oCategory) {
00328                 if ($oCategory->getId() == $sSelectedCatId ) {
00329                     $oCategory->selected = 1;
00330                     break;
00331                 }
00332             }
00333         } else { // no category selected - opening first available
00334             $oCatTree->rewind();
00335             if ( $oCat = $oCatTree->current() ) {
00336                 $oCat->selected = 1;
00337                 $sSelectedCatId = $oCat->getId();
00338             }
00339         }
00340 
00341         // passing to view
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         // navigation according to class
00378         if ( $sNode ) {
00379 
00380             $myAdminNavig = $this->getNavigation();
00381 
00382             // default tab
00383             $this->_aViewData['default_edit'] = $myAdminNavig->getActiveTab( $sNode, $this->_iDefEdit );
00384 
00385             // buttons
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 }

Generated on Tue Aug 4 09:09:57 2009 for OXID eShop CE by  doxygen 1.5.5