OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
manufacturer_main.php
Go to the documentation of this file.
1 <?php
2 
8 {
16  public function render()
17  {
19 
20  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
21  if ( $soxId != "-1" && isset( $soxId)) {
22  // load object
23  $oManufacturer = oxNew( "oxmanufacturer" );
24  $oManufacturer->loadInLang( $this->_iEditLang, $soxId );
25 
26  $oOtherLang = $oManufacturer->getAvailableInLangs();
27  if (!isset($oOtherLang[$this->_iEditLang])) {
28  // echo "language entry doesn't exist! using: ".key($oOtherLang);
29  $oManufacturer->loadInLang( key($oOtherLang), $soxId );
30  }
31  $this->_aViewData["edit"] = $oManufacturer;
32 
33  // category tree
34  $this->_createCategoryTree( "artcattree");
35 
36  //Disable editing for derived articles
37  if ($oManufacturer->isDerived())
38  $this->_aViewData['readonly'] = true;
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  if ( oxConfig::getParameter("aoc") ) {
54  $oManufacturerMainAjax = oxNew( 'manufacturer_main_ajax' );
55  $this->_aViewData['oxajax'] = $oManufacturerMainAjax->getColumns();
56 
57  return "popups/manufacturer_main.tpl";
58  }
59  return "manufacturer_main.tpl";
60  }
61 
67  public function save()
68  {
69  parent::save();
70 
71  $soxId = $this->getEditObjectId();
72  $aParams = oxConfig::getParameter( "editval");
73 
74  if ( !isset( $aParams['oxmanufacturers__oxactive']))
75  $aParams['oxmanufacturers__oxactive'] = 0;
76 
77  // shopid
78  $sShopID = oxSession::getVar( "actshop");
79  $aParams['oxmanufacturers__oxshopid'] = $sShopID;
80 
81  $oManufacturer = oxNew( "oxmanufacturer" );
82 
83  if ( $soxId != "-1")
84  $oManufacturer->loadInLang( $this->_iEditLang, $soxId );
85  else {
86  $aParams['oxmanufacturers__oxid'] = null;
87  }
88 
89 
90  //$aParams = $oManufacturer->ConvertNameArray2Idx( $aParams);
91  $oManufacturer->setLanguage(0);
92  $oManufacturer->assign( $aParams);
93  $oManufacturer->setLanguage($this->_iEditLang);
94  $oManufacturer = oxRegistry::get("oxUtilsFile")->processFiles( $oManufacturer );
95  $oManufacturer->save();
96 
97  // set oxid if inserted
98  $this->setEditObjectId( $oManufacturer->getId() );
99  }
100 
106  public function saveinnlang()
107  {
108  $soxId = $this->getEditObjectId();
109  $aParams = oxConfig::getParameter( "editval");
110 
111  if ( !isset( $aParams['oxmanufacturers__oxactive']))
112  $aParams['oxmanufacturers__oxactive'] = 0;
113 
114  // shopid
115  $sShopID = oxSession::getVar( "actshop");
116  $aParams['oxmanufacturers__oxshopid'] = $sShopID;
117 
118  $oManufacturer = oxNew( "oxmanufacturer" );
119 
120  if ( $soxId != "-1")
121  $oManufacturer->loadInLang( $this->_iEditLang, $soxId );
122  else {
123  $aParams['oxmanufacturers__oxid'] = null;
124  }
125 
126 
127  //$aParams = $oManufacturer->ConvertNameArray2Idx( $aParams);
128  $oManufacturer->setLanguage(0);
129  $oManufacturer->assign( $aParams);
130  $oManufacturer->setLanguage($this->_iEditLang);
131  $oManufacturer = oxRegistry::get("oxUtilsFile")->processFiles( $oManufacturer );
132  $oManufacturer->save();
133 
134  // set oxid if inserted
135  $this->setEditObjectId( $oManufacturer->getId() );
136  }
137 }