attribute_main.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class Attribute_Main extends oxAdminDetails
00010 {
00017     public function render()
00018     {   $myConfig = $this->getConfig();
00019 
00020         parent::render();
00021 
00022         $soxId = oxConfig::getParameter( "oxid");
00023         // check if we right now saved a new entry
00024         $sSavedID = oxConfig::getParameter( "saved_oxid");
00025         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00026             $soxId = $sSavedID;
00027             oxSession::deleteVar( "saved_oxid");
00028             $this->_aViewData["oxid"] =  $soxId;
00029             // for reloading upper frame
00030             $this->_aViewData["updatelist"] =  "1";
00031         }
00032 
00033         $sArticleTable = getViewName('oxarticles');
00034 
00035         // copy this tree for our article choose
00036         $sChosenArtCat = oxConfig::getParameter( "artcat");
00037         if ( $soxId != "-1" && isset( $soxId)) {
00038             // generating category tree for select list
00039             $sChosenArtCat = $this->_getCategoryTree( "artcattree", $sChosenArtCat, $soxId);
00040 
00041             // load object
00042             $oAttr = oxNew( "oxattribute" );
00043             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00044 
00045 
00046             $oOtherLang = $oAttr->getAvailableInLangs();
00047             if (!isset($oOtherLang[$this->_iEditLang])) {
00048                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00049                 $oAttr->loadInLang( key($oOtherLang), $soxId );
00050             }
00051 
00052             $this->_aViewData["edit"] =  $oAttr;
00053 
00054             // remove already created languages
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 ( oxConfig::getParameter("aoc") ) {
00067 
00068             $aColumns = array();
00069             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00070             $this->_aViewData['oxajax'] = $aColumns;
00071 
00072             return "popups/attribute_main.tpl";
00073         }
00074         return "attribute_main.tpl";
00075     }
00076 
00082     public function save()
00083     {
00084 
00085         $soxId   = oxConfig::getParameter( "oxid");
00086         $aParams = oxConfig::getParameter( "editval");
00087 
00088             // shopid
00089             $aParams['oxattribute__oxshopid'] = oxSession::getVar( "actshop" );
00090         $oAttr = oxNew( "oxattribute" );
00091 
00092         if ( $soxId != "-1")
00093             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00094         else
00095             $aParams['oxattribute__oxid'] = null;
00096         //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
00097 
00098 
00099         $oAttr->setLanguage(0);
00100         $oAttr->assign( $aParams);
00101         $oAttr->setLanguage($this->_iEditLang);
00102         $oAttr = oxUtilsFile::getInstance()->processFiles( $oAttr );
00103         $oAttr->save();
00104         $this->_aViewData["updatelist"] = "1";
00105 
00106         // set oxid if inserted
00107         if ( $soxId == "-1")
00108             oxSession::setVar( "saved_oxid", $oAttr->oxattribute__oxid->value);
00109     }
00110 
00116     public function saveinnlang()
00117     {
00118 
00119         $soxId      = oxConfig::getParameter( "oxid");
00120         $aParams    = oxConfig::getParameter( "editval");
00121 
00122             // shopid
00123             $aParams['oxattribute__oxshopid'] = oxSession::getVar( "actshop");
00124         $oAttr = oxNew( "oxattribute" );
00125 
00126         if ( $soxId != "-1") {
00127             $oAttr->loadInLang( $this->_iEditLang, $soxId );
00128         } else {
00129             $aParams['oxattribute__oxid'] = null;
00130         }
00131 
00132 
00133         $oAttr->setLanguage(0);
00134         $oAttr->assign( $aParams);
00135 
00136         // apply new language
00137         $sNewLanguage = oxConfig::getParameter( "new_lang");
00138         $oAttr->setLanguage( $sNewLanguage);
00139         $oAttr->save();
00140         $this->_aViewData["updatelist"] = "1";
00141 
00142         // set for reload
00143         oxSession::setVar( "new_lang", $sNewLanguage);
00144 
00145         // set oxid if inserted
00146         if ( $soxId == "-1")
00147             oxSession::setVar( "saved_oxid", $oAttr->oxattribute__oxid->value);
00148     }
00149 }