oxadmindetails.php

Go to the documentation of this file.
00001 <?php
00002 
00006 require_once "oxajax.php";
00007 
00012 class oxAdminDetails extends oxAdminView
00013 {
00019     protected $_oEditor   = null;
00020 
00026     public function render()
00027     {
00028         $sReturn = parent::render();
00029 
00030         // generate help link
00031         $myConfig = $this->getConfig();
00032         $sDir = $myConfig->getConfigParam( 'sShopDir' ) . '/documentation/admin';
00033         if ( is_dir( $sDir ) ) {
00034             $sDir = $myConfig->getConfigParam( 'sShopURL' ) . 'documentation/admin';
00035         } else {
00036 
00037                 $oShop = oxNew( 'oxshop' );
00038                 $oShop->load( oxSession::getVar( 'actshop' ) );
00039                 //$sDir = "http://docu.oxid-esales.com/PE/{$oShop->oxshops__oxversion->value}/" . $myConfig->getConfigParam( 'iAdminLanguage' ) . '/admin';
00040                 $sDir = "http://docu.oxid-esales.com/PE/{$oShop->oxshops__oxversion->value}/" . oxLang::getInstance()->getTplLanguage() . '/admin';
00041         }
00042 
00043         $this->_aViewData['sHelpURL'] = $sDir;
00044 
00045         return $sReturn;
00046     }
00047 
00059     protected function _generateTextEditor( $iWidth, $iHeight, $oObject, $sField, $sStylesheet = null )
00060     {
00061         $myConfig = $this->getConfig();
00062 
00063         // include the config file and editor class:
00064         $sEditorPath = 'wysiwigpro';
00065         $sEditorFile = getShopBasePath()."admin/".$sEditorPath . '/wysiwygPro.class.php';
00066 
00067 
00068 
00069         $sEditObjectValue = '';
00070         if ( $oObject ) {
00071             $sInitialValue = '';
00072             if ($oObject->$sField instanceof oxField) {
00073                 $sInitialValue = $oObject->$sField->getRawValue();
00074             } else {
00075                 $sInitialValue = $oObject->$sField->value;
00076             }
00077             $oObject->$sField = new oxField(str_replace( '[{$shop->currenthomedir}]', $myConfig->getCurrentShopURL(), $sInitialValue ), oxField::T_RAW);
00078             $sEditObjectValue = $oObject->$sField->value;
00079         }
00080 
00081 
00082         if (!$sEditorFile || !file_exists($sEditorFile)) {
00083             if (strpos($iWidth, '%') === false) {
00084                 $iWidth .= 'px';
00085             }
00086             if (strpos($iHeight, '%') === false) {
00087                 $iHeight .= 'px';
00088             }
00089             return "<textarea id='editor_{$sField}' style='width:{$iWidth}; height:{$iHeight};'>$sEditObjectValue</textarea>";
00090         }
00091 
00092         include_once ($sEditorFile);
00093 
00094         // create a new instance of the wysiwygPro class:
00095         $this->_oEditor = new wysiwygPro();
00096 
00097         // set language file name
00098         $sEditorUrl = $myConfig->getConfigParam( 'sShopURL' ).$myConfig->getConfigParam( 'sAdminDir' )."/{$sEditorPath}/";
00099         if ( $sAdminSSLURL = $myConfig->getConfigParam( 'sAdminSSLURL' ) ) {
00100             $sEditorUrl = "{$sAdminSSLURL}/{$sEditorPath}/";
00101         }
00102 
00103         $this->_oEditor->editorURL = $sEditorUrl;
00104         $this->_oEditor->urlFormat = 'absolute';
00105 
00106         // document & image directory:
00107         $this->_oEditor->documentDir = $this->_oEditor->imageDir = $myConfig->getPictureDir( false ).'wysiwigpro/';
00108         $this->_oEditor->documentURL = $this->_oEditor->imageURL = $myConfig->getPictureUrl( null, false ).'wysiwigpro/';
00109         
00110         // enabling upload
00111         $this->_oEditor->upload = true;
00112 
00113         // allowed image extensions
00114         $this->_oEditor->allowedImageExtensions = '.jpg, .jpeg, .gif, .png';
00115 
00116         // allowed document extensions
00117         $this->_oEditor->allowedDocExtensions   = '.html, .htm, .pdf, .doc, .rtf, .txt, .xl, .xls, .ppt, .pps, .zip, .tar, .swf, .wmv, .rm, .mov, .jpg, .jpeg, .gif, .png';
00118 
00119         // set name
00120         $this->_oEditor->name = $sField;
00121 
00122         // set language file name
00123         $this->_oEditor->lang = oxLang::getInstance()->translateString( 'editor_language', oxLang::getInstance()->getTplLanguage() );
00124 
00125         // set contents
00126         if ( $sEditObjectValue ) {
00127             $this->_oEditor->value = $sEditObjectValue;
00128         }
00129 
00130         // parse for styles and add them
00131         $this->setAdminMode( false );
00132         $sCSSPath = $myConfig->getResourcePath("styles/{$sStylesheet}", false );
00133         $sCSSUrl  = $myConfig->getResourceUrl("styles/{$sStylesheet}", false );
00134 
00135         $aCSSPaths = array();
00136 
00137         // #1157C - in wysiwigpro editor font problem
00138         $aCSSPaths[] = $myConfig->getResourcePath("oxid.css", false );
00139 
00140         $this->setAdminMode( true );
00141 
00142         if (is_file($sCSSPath)) {
00143 
00144                 $aCSSPaths[] = $sCSSUrl;
00145 
00146             if (is_readable($sCSSPath)) {
00147                 $aCSS = @file( $sCSSPath);
00148                 if ( isset( $aCSS) && $aCSS) {
00149                     $aClasses = array();
00150                     foreach ( $aCSS as $key => $sLine ) {
00151                         $sLine = trim($sLine);
00152 
00153                         if ( $sLine[0] == '.' && !strstr( $sLine, 'default' ) ) {
00154                             // found one tag
00155                             $sTag = substr( $sLine, 1);
00156                             $iEnd = strpos( $sTag, ' ' );
00157                             if ( !isset( $iEnd ) || !$iEnd ) {
00158                                 $iEnd = strpos( $sTag, '\n' );
00159                         }
00160 
00161                             if ( $sTag = substr( $sTag, 0, $iEnd ) ) {
00162                                 $aClasses["span class='{$sTag}'"] = $sTag;
00163                     }
00164                 }
00165             }
00166 
00167                     $this->_oEditor->stylesMenu = $aClasses;
00168         }
00169             }
00170         }
00171 
00172         foreach ( $aCSSPaths as $sCssPath ) {
00173             $this->_oEditor->addStylesheet( $sCssPath );
00174         }
00175 
00176         //while there is a bug in editor template filter we cannot use this feature
00177         // loading template filter plugin
00178         $this->_oEditor->loadPlugin( 'templateFilter' );
00179         $this->_oEditor->plugins['templateFilter']->protect( '[{', '}]' );
00180         if ( $myConfig->getConfigParam( 'bl_perfParseLongDescinSmarty' ) ) {
00181             $this->_oEditor->plugins['templateFilter']->assign( '[{$shop->currenthomedir}]', $myConfig->getShopURL() );
00182             $this->_oEditor->plugins['templateFilter']->assign( '[{$shop->currenthomedir}]', $myConfig->getSSLShopURL() );
00183         }
00184 
00185         // generate and return editor code
00186         return $this->_oEditor->fetch( $iWidth, $iHeight );
00187     }
00188 
00194     public function resetNrOfCatArticles()
00195     {
00196 
00197             oxUtils::getInstance()->oxResetFileCache();
00198     }
00199 
00205     public function resetNrOfVendorArticles()
00206     {
00207 
00208             oxUtils::getInstance()->oxResetFileCache();
00209     }
00210 
00223     protected function _getCategoryTree( $sTplVarName, $sSelectedCatId, $sEditCatId = '', $blForceNonCache = false, $iTreeShopId = null )
00224     {
00225         // caching category tree, to load it once, not many times
00226         if ( !isset( $this->oCatTree ) || $blForceNonCache ) {
00227             $this->oCatTree = oxNew( 'oxCategoryList' );
00228             $this->oCatTree->setShopID( $iTreeShopId );
00229             $this->oCatTree->buildList( $this->getConfig()->getConfigParam( 'bl_perfLoadCatTree' ) );
00230         }
00231 
00232         // copying tree
00233         $oCatTree = $this->oCatTree;
00234         //removing current category
00235         if ( $sEditCatId && isset( $oCatTree[$sEditCatId] ) ) {
00236             unset( $oCatTree[$sEditCatId] );
00237         }
00238 
00239         // add first fake category for not assigned articles
00240         $oRoot = oxNew( 'oxcategory' );
00241         $oRoot->oxcategories__oxtitle = new oxField('--');
00242 
00243         $oCatTree->assign( array_merge( array( '' => $oRoot ), $oCatTree->getArray() ) );
00244 
00245         // mark selected
00246         if ( $sSelectedCatId ) {
00247             // fixed parent category in select list
00248             foreach ($oCatTree as $oCategory) {
00249                 if ($oCategory->getId() == $sSelectedCatId ) {
00250                     $oCategory->selected = 1;
00251                 }
00252             }
00253         } else { // no category selected - opening first available
00254             $oCatTree->rewind();
00255             if ( $oCat = $oCatTree->current() ) {
00256                 $oCat->selected = 1;
00257                 $sSelectedCatId = $oCat->getId();
00258             }
00259         }
00260 
00261         // passing to view
00262         $this->_aViewData[$sTplVarName] =  $oCatTree;
00263 
00264         return $sSelectedCatId;
00265     }
00266 
00272     public function changeFolder()
00273     {
00274         $sFolder = oxConfig::getParameter( 'setfolder' );
00275         $sFolderClass = oxConfig::getParameter( 'folderclass' );
00276 
00277         if ( $sFolderClass == 'oxcontent' && $sFolder == 'CMSFOLDER_NONE' ) {
00278             $sFolder = '';
00279         }
00280 
00281         $oObject = oxNew( $sFolderClass );
00282         if ( $oObject->load( oxConfig::getParameter( 'oxid' ) ) ) {
00283             $oObject->{$oObject->getCoreTableName() . '__oxfolder'} = new oxField($sFolder);
00284             $oObject->save();
00285         }
00286     }
00287 
00295     protected function _setupNavigation( $sNode )
00296     {
00297         // navigation according to class
00298         if ( $sNode ) {
00299 
00300             $myAdminNavig = $this->getNavigation();
00301 
00302             // default tab
00303             $this->_aViewData['default_edit'] = $myAdminNavig->getActiveTab( $sNode, $this->_iDefEdit );
00304 
00305             // buttons
00306             $this->_aViewData['bottom_buttons'] = $myAdminNavig->getBtn( $sNode );
00307         }
00308     }
00309 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5