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             $aParams['oxcategories__oxshopid'] = oxSession::getVar( "actshop" );
00115         $oCategory = oxNew( "oxcategory" );
00116 
00117         if ( $soxId != "-1") {
00118             $this->resetCounter( "catArticle", $soxId );
00119             $oCategory->load( $soxId);
00120             $oCategory->loadInLang( $this->_iEditLang, $soxId );
00121                 $myUtilsPic = oxUtilsPic::getInstance();
00122                 // #1173M - not all pic are deleted, after article is removed
00123                 $myUtilsPic->overwritePic( $oCategory, 'oxcategories', 'oxthumb', 'TC', '0', $aParams, $myConfig->getAbsDynImageDir() );
00124                 $myUtilsPic->overwritePic( $oCategory, 'oxcategories', 'oxicon', 'CICO', 'icon', $aParams, $myConfig->getAbsDynImageDir() );
00125 
00126         } else {
00127             //#550A - if new category is made then is must be default activ
00128             $aParams['oxcategories__oxactive'] = 1;
00129             $aParams['oxcategories__oxid'] = null;
00130         }
00131         //$aParams = $oCategory->ConvertNameArray2Idx( $aParams);
00132 
00133 
00134         $oCategory->setLanguage(0);
00135         $oCategory->assign( $aParams);
00136 
00137         $oCategory->setLanguage($this->_iEditLang);
00138 
00139         $oCategory = oxUtilsFile::getInstance()->processFiles( $oCategory );
00140         $oCategory->save();
00141         $this->_aViewData["updatelist"] = "1";
00142 
00143         // set oxid if inserted
00144         if ( $soxId == "-1")
00145             oxSession::setVar( "saved_oxid", $oCategory->oxcategories__oxid->value);
00146     }
00147 
00153     public function saveinnlang()
00154     {
00155 
00156         $soxId      = oxConfig::getParameter( "oxid");
00157         $aParams    = oxConfig::getParameter( "editval");
00158         // checkbox handling
00159         if ( !isset( $aParams['oxcategories__oxactive']))
00160             $aParams['oxcategories__oxactive'] = 0;
00161         if ( !isset( $aParams['oxcategories__oxdefsortmode']))
00162             $aParams['oxcategories__oxdefsortmode'] = 0;
00163 
00164         // null values
00165         if ($aParams['oxcategories__oxvat'] === '')
00166             $aParams['oxcategories__oxvat'] = null;
00167 
00168             // shopid
00169             $aParams['oxcategories__oxshopid'] = oxSession::getVar( "actshop" );
00170 
00171         $oCategory = oxNew( "oxcategory" );
00172 
00173         if ( $soxId != "-1") {
00174             $oCategory->loadInLang( $this->_iEditLang, $soxId );
00175         } else {
00176             $aParams['oxcategories__oxid'] = null;
00177         }
00178 
00179 
00180         //$aParams = $oCategory->ConvertNameArray2Idx( $aParams);
00181         $oCategory->setLanguage(0);
00182         $oCategory->assign( $aParams);
00183 
00184         // apply new language
00185         $sNewLanguage = oxConfig::getParameter( "new_lang");
00186         $oCategory->setLanguage( $sNewLanguage);
00187         $oCategory->save();
00188         $this->_aViewData["updatelist"] = "1";
00189 
00190         // set for reload
00191         oxSession::setVar( "new_lang", $sNewLanguage);
00192 
00193         // set oxid if inserted
00194         if ( $soxId == "-1") {
00195             oxSession::setVar( "saved_oxid", $oCategory->oxcategories__oxid->value);
00196         }
00197     }
00198 }

Generated by  doxygen 1.6.2