category_main.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Category_Main extends oxAdminDetails
00010 {
00017     public function render()
00018     {
00019         $myConfig  = $this->getConfig();
00020 
00021         parent::render();
00022 
00023         $this->_aViewData["edit"] = $oCategory = oxNew( "oxcategory" );;
00024 
00025 
00026         $soxId = oxConfig::getParameter( "oxid");
00027         $sChosenArtCat = oxConfig::getParameter( "artcat");
00028         // check if we right now saved a new entry
00029         $sSavedID = oxConfig::getParameter( "saved_oxid");
00030         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00031             $soxId = $sSavedID;
00032             oxSession::deleteVar( "saved_oxid");
00033             $this->_aViewData["oxid"] =  $soxId;
00034             // for reloading upper frame
00035             $this->_aViewData["updatelist"] =  "1";
00036         }
00037 
00038         if ( $soxId != "-1" && isset( $soxId)) {
00039 
00040             // generating category tree for select list
00041             $sChosenArtCat = $this->_getCategoryTree( "artcattree", $sChosenArtCat, $soxId );
00042 
00043             // load object
00044             $oCategory->loadInLang( $this->_iEditLang, $soxId );
00045 
00046 
00047             $oOtherLang = $oCategory->getAvailableInLangs();
00048             if (!isset($oOtherLang[$this->_iEditLang])) {
00049                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00050                 $oCategory->loadInLang( key($oOtherLang), $soxId );
00051             }
00052 
00053             // remove already created languages
00054             $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang );
00055             if ( count( $aLang))
00056                 $this->_aViewData["posslang"] = $aLang;
00057 
00058             foreach ( $oOtherLang as $id => $language) {
00059                 $oLang = new oxStdClass();
00060                 $oLang->sLangDesc = $language;
00061                 $oLang->selected = ($id == $this->_iEditLang);
00062                 $this->_aViewData["otherlang"][$id] =  clone $oLang;
00063             }
00064 
00065             if ( $oCategory->oxcategories__oxparentid->value == 'oxrootid')
00066                 $oCategory->oxcategories__oxparentid->setValue('');
00067 
00068             $this->_getCategoryTree( "cattree", $oCategory->oxcategories__oxparentid->value, $oCategory->oxcategories__oxid->value, true, $oCategory->oxcategories__oxshopid->value);
00069 
00070             $this->_aViewData["defsort"] = $oCategory->oxcategories__oxdefsort->value;
00071         } else
00072             $this->_getCategoryTree( "cattree", "", "", true, $myConfig->getShopId());
00073 
00074         $oArticle = oxNew( "oxarticle" );
00075         $this->_aViewData["pwrsearchfields"] = $oArticle->getSearchableFields();
00076 
00077         if ( oxConfig::getParameter("aoc") ) {
00078 
00079             $aColumns = array();
00080             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00081             $this->_aViewData['oxajax'] = $aColumns;
00082 
00083             return "popups/category_main.tpl";
00084         }
00085         return "category_main.tpl";
00086     }
00087 
00093     public function save()
00094     {
00095         $myConfig  = $this->getConfig();
00096 
00097 
00098         $soxId      = oxConfig::getParameter( "oxid");
00099         $aParams    = oxConfig::getParameter( "editval");
00100 
00101         // checkbox handling
00102         if ( !isset( $aParams['oxcategories__oxactive']))
00103             $aParams['oxcategories__oxactive'] = 0;
00104         if ( !isset( $aParams['oxcategories__oxhidden']))
00105             $aParams['oxcategories__oxhidden'] = 0;
00106         if ( !isset( $aParams['oxcategories__oxdefsortmode']))
00107             $aParams['oxcategories__oxdefsortmode'] = 0;
00108 
00109         // null values
00110         if ($aParams['oxcategories__oxvat'] === '')
00111             $aParams['oxcategories__oxvat'] = null;
00112 
00113             // shopid
00114             $sShopID = oxSession::getVar( "actshop");
00115             $aParams['oxcategories__oxshopid'] = $sShopID;
00116         $oCategory = oxNew( "oxcategory" );
00117 
00118         if ( $soxId != "-1") {
00119             $this->resetCounter( "catArticle", $soxId );
00120             $oCategory->load( $soxId);
00121             $oCategory->loadInLang( $this->_iEditLang, $soxId );
00122                 $myUtilsPic = oxUtilsPic::getInstance();
00123                 // #1173M - not all pic are deleted, after article is removed
00124                 $myUtilsPic->overwritePic( $oCategory, 'oxcategories', 'oxthumb', 'TC', '0', $aParams, $myConfig->getAbsDynImageDir() );
00125                 $myUtilsPic->overwritePic( $oCategory, 'oxcategories', 'oxicon', 'CICO', 'icon', $aParams, $myConfig->getAbsDynImageDir() );
00126 
00127         } else {
00128             //#550A - if new category is made then is must be default activ
00129             $aParams['oxcategories__oxactive'] = 1;
00130             $aParams['oxcategories__oxid'] = null;
00131         }
00132         //$aParams = $oCategory->ConvertNameArray2Idx( $aParams);
00133 
00134 
00135         $oCategory->setLanguage(0);
00136         $oCategory->assign( $aParams);
00137 
00138         $oCategory->setLanguage($this->_iEditLang);
00139 
00140         $oCategory = oxUtilsFile::getInstance()->processFiles( $oCategory );
00141         $oCategory->save();
00142         $this->_aViewData["updatelist"] = "1";
00143 
00144         // set oxid if inserted
00145         if ( $soxId == "-1")
00146             oxSession::setVar( "saved_oxid", $oCategory->oxcategories__oxid->value);
00147     }
00148 
00154     public function saveinnlang()
00155     {
00156 
00157         $soxId      = oxConfig::getParameter( "oxid");
00158         $aParams    = oxConfig::getParameter( "editval");
00159         // checkbox handling
00160         if ( !isset( $aParams['oxcategories__oxactive']))
00161             $aParams['oxcategories__oxactive'] = 0;
00162         if ( !isset( $aParams['oxcategories__oxdefsortmode']))
00163             $aParams['oxcategories__oxdefsortmode'] = 0;
00164 
00165         // null values
00166         if ($aParams['oxcategories__oxvat'] === '')
00167             $aParams['oxcategories__oxvat'] = null;
00168 
00169             // shopid
00170             $sShopID = oxSession::getVar( "actshop");
00171             $aParams['oxcategories__oxshopid'] = $sShopID;
00172 
00173         $oCategory = oxNew( "oxcategory" );
00174 
00175         if ( $soxId != "-1")
00176             $oCategory->loadInLang( $this->_iEditLang, $soxId );
00177         else {
00178             $aParams['oxcategories__oxid'] = null;
00179         }
00180 
00181 
00182         //$aParams = $oCategory->ConvertNameArray2Idx( $aParams);
00183         $oCategory->setLanguage(0);
00184         $oCategory->assign( $aParams);
00185 
00186         // apply new language
00187         $sNewLanguage = oxConfig::getParameter( "new_lang");
00188         $oCategory->setLanguage( $sNewLanguage);
00189         $oCategory->save();
00190         $this->_aViewData["updatelist"] = "1";
00191 
00192         // set for reload
00193         oxSession::setVar( "new_lang", $sNewLanguage);
00194 
00195         // set oxid if inserted
00196         if ( $soxId == "-1")
00197             oxSession::setVar( "saved_oxid", $oCategory->oxcategories__oxid->value);
00198     }
00199 }

Generated on Wed Apr 22 12:26:29 2009 for OXID eShop CE by  doxygen 1.5.5