00001 <?php
00002
00010 class Category_Main extends oxAdminDetails
00011 {
00018 public function render()
00019 {
00020 $myConfig = $this->getConfig();
00021
00022 parent::render();
00023
00024 $this->_aViewData["edit"] = $oCategory = oxNew( "oxcategory" );;
00025
00026
00027 $soxId = oxConfig::getParameter( "oxid");
00028 $sChosenArtCat = oxConfig::getParameter( "artcat");
00029
00030 $sSavedID = oxConfig::getParameter( "saved_oxid");
00031 if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00032 $soxId = $sSavedID;
00033 oxSession::deleteVar( "saved_oxid");
00034 $this->_aViewData["oxid"] = $soxId;
00035
00036 $this->_aViewData["updatelist"] = "1";
00037 }
00038
00039 if ( $soxId != "-1" && isset( $soxId)) {
00040
00041
00042 $sChosenArtCat = $this->_getCategoryTree( "artcattree", $sChosenArtCat, $soxId );
00043
00044
00045 $oCategory->loadInLang( $this->_iEditLang, $soxId );
00046
00047
00048 $oOtherLang = $oCategory->getAvailableInLangs();
00049 if (!isset($oOtherLang[$this->_iEditLang])) {
00050
00051 $oCategory->loadInLang( key($oOtherLang), $soxId );
00052 }
00053
00054
00055 $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang );
00056 if ( count( $aLang))
00057 $this->_aViewData["posslang"] = $aLang;
00058
00059 foreach ( $oOtherLang as $id => $language) {
00060 $oLang = new oxStdClass();
00061 $oLang->sLangDesc = $language;
00062 $oLang->selected = ($id == $this->_iEditLang);
00063 $this->_aViewData["otherlang"][$id] = clone $oLang;
00064 }
00065
00066 if ( $oCategory->oxcategories__oxparentid->value == 'oxrootid')
00067 $oCategory->oxcategories__oxparentid->setValue('');
00068
00069 $this->_getCategoryTree( "cattree", $oCategory->oxcategories__oxparentid->value, $oCategory->oxcategories__oxid->value, true, $oCategory->oxcategories__oxshopid->value);
00070
00071 $this->_aViewData["defsort"] = $oCategory->oxcategories__oxdefsort->value;
00072 } else
00073 $this->_getCategoryTree( "cattree", "", "", true, $myConfig->getShopId());
00074
00075 $oArticle = oxNew( "oxarticle" );
00076 $this->_aViewData["pwrsearchfields"] = $oArticle->getSearchableFields();
00077
00078 if ( oxConfig::getParameter("aoc") ) {
00079
00080 $aColumns = array();
00081 include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00082 $this->_aViewData['oxajax'] = $aColumns;
00083
00084 return "popups/category_main.tpl";
00085 }
00086 return "category_main.tpl";
00087 }
00088
00094 public function save()
00095 {
00096 $myConfig = $this->getConfig();
00097
00098
00099 $soxId = oxConfig::getParameter( "oxid");
00100 $aParams = oxConfig::getParameter( "editval");
00101
00102
00103 if ( !isset( $aParams['oxcategories__oxactive']))
00104 $aParams['oxcategories__oxactive'] = 0;
00105 if ( !isset( $aParams['oxcategories__oxhidden']))
00106 $aParams['oxcategories__oxhidden'] = 0;
00107 if ( !isset( $aParams['oxcategories__oxdefsortmode']))
00108 $aParams['oxcategories__oxdefsortmode'] = 0;
00109
00110
00111 if ($aParams['oxcategories__oxvat'] === '')
00112 $aParams['oxcategories__oxvat'] = null;
00113
00114
00115 $sShopID = oxSession::getVar( "actshop");
00116 $aParams['oxcategories__oxshopid'] = $sShopID;
00117 $oCategory = oxNew( "oxcategory" );
00118
00119 if ( $soxId != "-1") {
00120 oxUtilsCount::getInstance()->resetCatArticleCount($soxId);
00121 $oCategory->load( $soxId);
00122 $oCategory->loadInLang( $this->_iEditLang, $soxId );
00123
00124 oxUtilsPic::getInstance()->overwritePic( $oCategory, 'oxcategories', 'oxthumb', 'TC', '0', $aParams, $myConfig->getAbsDynImageDir() );
00125 oxUtilsPic::getInstance()->overwritePic( $oCategory, 'oxcategories', 'oxicon', 'CICO', 'icon', $aParams, $myConfig->getAbsDynImageDir() );
00126
00127 } else {
00128
00129 $aParams['oxcategories__oxactive'] = 1;
00130 $aParams['oxcategories__oxid'] = null;
00131 }
00132
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
00145 if ( $soxId == "-1")
00146 oxSession::setVar( "saved_oxid", $oCategory->oxcategories__oxid->value);
00147
00148 return $this->autosave();
00149 }
00150
00156 public function saveinnlang()
00157 {
00158
00159 $soxId = oxConfig::getParameter( "oxid");
00160 $aParams = oxConfig::getParameter( "editval");
00161
00162 if ( !isset( $aParams['oxcategories__oxactive']))
00163 $aParams['oxcategories__oxactive'] = 0;
00164 if ( !isset( $aParams['oxcategories__oxdefsortmode']))
00165 $aParams['oxcategories__oxdefsortmode'] = 0;
00166
00167
00168 if ($aParams['oxcategories__oxvat'] === '')
00169 $aParams['oxcategories__oxvat'] = null;
00170
00171
00172 $sShopID = oxSession::getVar( "actshop");
00173 $aParams['oxcategories__oxshopid'] = $sShopID;
00174
00175 $oCategory = oxNew( "oxcategory" );
00176
00177 if ( $soxId != "-1")
00178 $oCategory->loadInLang( $this->_iEditLang, $soxId );
00179 else {
00180 $aParams['oxcategories__oxid'] = null;
00181 }
00182
00183
00184
00185 $oCategory->setLanguage(0);
00186 $oCategory->assign( $aParams);
00187
00188
00189 $sNewLanguage = oxConfig::getParameter( "new_lang");
00190 $oCategory->setLanguage( $sNewLanguage);
00191 $oCategory->save();
00192 $this->_aViewData["updatelist"] = "1";
00193
00194
00195 oxSession::setVar( "new_lang", $sNewLanguage);
00196
00197
00198 if ( $soxId == "-1")
00199 oxSession::setVar( "saved_oxid", $oCategory->oxcategories__oxid->value);
00200 }
00201 }