OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
wrapping_main.php
Go to the documentation of this file.
1 <?php
2 
9 {
17  public function render()
18  {
20 
21  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
22  if ( $soxId != "-1" && isset( $soxId)) {
23  // load object
24  $oWrapping = oxNew( "oxwrapping" );
25  $oWrapping->loadInLang( $this->_iEditLang, $soxId );
26 
27  $oOtherLang = $oWrapping->getAvailableInLangs();
28  if (!isset($oOtherLang[$this->_iEditLang])) {
29  // echo "language entry doesn't exist! using: ".key($oOtherLang);
30  $oWrapping->loadInLang( key($oOtherLang), $soxId );
31  }
32  $this->_aViewData["edit"] = $oWrapping;
33 
34 
35  // remove already created languages
36  $aLang = array_diff ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang );
37  if ( count( $aLang))
38  $this->_aViewData["posslang"] = $aLang;
39 
40  foreach ( $oOtherLang as $id => $language) {
41  $oLang= new stdClass();
42  $oLang->sLangDesc = $language;
43  $oLang->selected = ($id == $this->_iEditLang);
44  $this->_aViewData["otherlang"][$id] = clone $oLang;
45  }
46  }
47 
48  return "wrapping_main.tpl";
49  }
50 
56  public function save()
57  {
58  parent::save();
59 
60  $soxId = $this->getEditObjectId();
61  $aParams = oxConfig::getParameter( "editval");
62 
63  // checkbox handling
64  if ( !isset( $aParams['oxwrapping__oxactive']))
65  $aParams['oxwrapping__oxactive'] = 0;
66 
67  // shopid
68  $aParams['oxwrapping__oxshopid'] = oxSession::getVar( "actshop" );
69 
70  $oWrapping = oxNew( "oxwrapping" );
71 
72  if ( $soxId != "-1") {
73  $oWrapping->loadInLang( $this->_iEditLang, $soxId );
74  // #1173M - not all pic are deleted, after article is removed
75  oxRegistry::get("oxUtilsPic")->overwritePic( $oWrapping, 'oxwrapping', 'oxpic', 'WP', '0', $aParams, $this->getConfig()->getPictureDir(false) );
76  } else
77  $aParams['oxwrapping__oxid'] = null;
78  //$aParams = $oWrapping->ConvertNameArray2Idx( $aParams);
79 
80 
81  $oWrapping->setLanguage(0);
82  $oWrapping->assign( $aParams);
83  $oWrapping->setLanguage($this->_iEditLang);
84 
85  $oWrapping = oxRegistry::get("oxUtilsFile")->processFiles( $oWrapping );
86  $oWrapping->save();
87 
88  // set oxid if inserted
89  $this->setEditObjectId( $oWrapping->getId() );
90  }
91 
97  public function saveinnlang()
98  {
99  $soxId = $this->getEditObjectId();
100  $aParams = oxConfig::getParameter( "editval");
101 
102  // checkbox handling
103  if ( !isset( $aParams['oxwrapping__oxactive']))
104  $aParams['oxwrapping__oxactive'] = 0;
105 
106  // shopid
107  $aParams['oxwrapping__oxshopid'] = oxSession::getVar( "actshop" );
108 
109  $oWrapping = oxNew( "oxwrapping" );
110  if ( $soxId != "-1")
111  $oWrapping->load( $soxId);
112  else
113  $aParams['oxwrapping__oxid'] = null;
114  //$aParams = $oWrapping->ConvertNameArray2Idx( $aParams);
115 
116 
117  $oWrapping->setLanguage(0);
118  $oWrapping->assign( $aParams);
119  $oWrapping->setLanguage($this->_iEditLang);
120 
121  $oWrapping = oxRegistry::get("oxUtilsFile")->processFiles( $oWrapping );
122  $oWrapping->save();
123 
124  // set oxid if inserted
125  $this->setEditObjectId( $oWrapping->getId() );
126  }
127 }