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