OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
attribute_main.php
Go to the documentation of this file.
1 <?php
2 
10 {
17  public function render()
18  {
20 
21  $myConfig = $this->getConfig();
22 
23  $oAttr = oxNew( "oxattribute" );
24  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
25 
26  // copy this tree for our article choose
27  if ( $soxId != "-1" && isset( $soxId)) {
28  // generating category tree for select list
29  $this->_createCategoryTree( "artcattree", $soxId);
30  // load object
31  $oAttr->loadInLang( $this->_iEditLang, $soxId );
32 
33 
34  $oOtherLang = $oAttr->getAvailableInLangs();
35  if (!isset($oOtherLang[$this->_iEditLang])) {
36  // echo "language entry doesn't exist! using: ".key($oOtherLang);
37  $oAttr->loadInLang( key($oOtherLang), $soxId );
38  }
39 
40  // remove already created languages
41  $aLang = array_diff ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
42  if ( count( $aLang))
43  $this->_aViewData["posslang"] = $aLang;
44 
45  foreach ( $oOtherLang as $id => $language) {
46  $oLang= new stdClass();
47  $oLang->sLangDesc = $language;
48  $oLang->selected = ($id == $this->_iEditLang);
49  $this->_aViewData["otherlang"][$id] = clone $oLang;
50  }
51  }
52 
53  $this->_aViewData["edit"] = $oAttr;
54 
55  if ( $myConfig->getRequestParameter("aoc") ) {
56  $oAttributeMainAjax = oxNew( 'attribute_main_ajax' );
57  $this->_aViewData['oxajax'] = $oAttributeMainAjax->getColumns();
58 
59  return "popups/attribute_main.tpl";
60  }
61  return "attribute_main.tpl";
62  }
63 
69  public function save()
70  {
71  parent::save();
72 
73  $soxId = $this->getEditObjectId();
74  $aParams = oxConfig::getParameter( "editval");
75 
76  // shopid
77  $aParams['oxattribute__oxshopid'] = oxSession::getVar( "actshop" );
78  $oAttr = oxNew( "oxattribute" );
79 
80  if ( $soxId != "-1")
81  $oAttr->loadInLang( $this->_iEditLang, $soxId );
82  else
83  $aParams['oxattribute__oxid'] = null;
84  //$aParams = $oAttr->ConvertNameArray2Idx( $aParams);
85 
86 
87  $oAttr->setLanguage(0);
88  $oAttr->assign( $aParams);
89  $oAttr->setLanguage($this->_iEditLang);
90  $oAttr = oxRegistry::get("oxUtilsFile")->processFiles( $oAttr );
91  $oAttr->save();
92 
93  $this->setEditObjectId( $oAttr->getId() );
94  }
95 
101  public function saveinnlang()
102  {
103  parent::save();
104 
105  $soxId = $this->getEditObjectId();
106  $aParams = oxConfig::getParameter( "editval");
107 
108  // shopid
109  $aParams['oxattribute__oxshopid'] = oxSession::getVar( "actshop");
110  $oAttr = oxNew( "oxattribute" );
111 
112  if ( $soxId != "-1") {
113  $oAttr->loadInLang( $this->_iEditLang, $soxId );
114  } else {
115  $aParams['oxattribute__oxid'] = null;
116  }
117 
118 
119  $oAttr->setLanguage(0);
120  $oAttr->assign( $aParams);
121 
122  // apply new language
123  $oAttr->setLanguage( oxConfig::getParameter( "new_lang" ) );
124  $oAttr->save();
125 
126  // set oxid if inserted
127  $this->setEditObjectId( $oAttr->getId() );
128  }
129 }