OXID eShop CE  4.8.11
 All Classes Files Functions Variables Pages
actions_main.php
Go to the documentation of this file.
1 <?php
2 
10 {
17  public function render()
18  {
20 
21  // check if we right now saved a new entry
22  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
23  if ( $soxId != "-1" && isset( $soxId)) {
24  // load object
25  $oAction = oxNew( "oxactions" );
26  $oAction->loadInLang( $this->_iEditLang, $soxId);
27 
28  $oOtherLang = $oAction->getAvailableInLangs();
29  if (!isset($oOtherLang[$this->_iEditLang])) {
30  // echo "language entry doesn't exist! using: ".key($oOtherLang);
31  $oAction->loadInLang( key($oOtherLang), $soxId );
32  }
33 
34  $this->_aViewData["edit"] = $oAction;
35 
36  // remove already created languages
37  $aLang = array_diff ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang );
38 
39  if ( count( $aLang))
40  $this->_aViewData["posslang"] = $aLang;
41 
42  foreach ( $oOtherLang as $id => $language) {
43  $oLang= new stdClass();
44  $oLang->sLangDesc = $language;
45  $oLang->selected = ($id == $this->_iEditLang);
46  $this->_aViewData["otherlang"][$id] = clone $oLang;
47  }
48  }
49 
50  if ( oxConfig::getParameter("aoc") ) {
51  // generating category tree for select list
52  $this->_createCategoryTree( "artcattree", $soxId);
53 
54  $oActionsMainAjax = oxNew( 'actions_main_ajax' );
55  $this->_aViewData['oxajax'] = $oActionsMainAjax->getColumns();
56 
57  return "popups/actions_main.tpl";
58  }
59 
60 
61  if ( ( $oPromotion = $this->getViewDataElement( "edit" ) ) ) {
62  if ( ($oPromotion->oxactions__oxtype->value == 2) || ($oPromotion->oxactions__oxtype->value == 3) ) {
63  if ( $iAoc = oxConfig::getParameter( "oxpromotionaoc" ) ) {
64  $sPopup = false;
65  switch( $iAoc ) {
66  case 'article':
67  // generating category tree for select list
68  $this->_createCategoryTree( "artcattree", $soxId);
69 
70  if ($oArticle = $oPromotion->getBannerArticle()) {
71  $this->_aViewData['actionarticle_artnum'] = $oArticle->oxarticles__oxartnum->value;
72  $this->_aViewData['actionarticle_title'] = $oArticle->oxarticles__oxtitle->value;
73  }
74 
75  $sPopup = 'actions_article';
76  break;
77  case 'groups':
78  $sPopup = 'actions_groups';
79  break;
80  }
81 
82  if ( $sPopup ) {
83  $aColumns = array();
84  $oActionsArticleAjax = oxNew( $sPopup.'_ajax' );
85  $this->_aViewData['oxajax'] = $oActionsArticleAjax->getColumns();
86  return "popups/{$sPopup}.tpl";
87  }
88  } else {
89  if ( $oPromotion->oxactions__oxtype->value == 2) {
90  $this->_aViewData["editor"] = $this->_generateTextEditor( "100%", 300, $oPromotion, "oxactions__oxlongdesc", "details.tpl.css" );
91  }
92  }
93  }
94  }
95 
96  return "actions_main.tpl";
97  }
98 
99 
105  public function save()
106  {
107  $myConfig = $this->getConfig();
108 
109 
110  parent::save();
111 
112  $soxId = $this->getEditObjectId();
113  $aParams = oxConfig::getParameter( "editval");
114 
115  $oPromotion = oxNew( "oxactions" );
116  if ( $soxId != "-1" ) {
117  $oPromotion->load( $soxId );
118  } else {
119  $aParams['oxactions__oxid'] = null;
120  }
121 
122  if ( !$aParams['oxactions__oxactive'] ) {
123  $aParams['oxactions__oxactive'] = 0;
124  }
125 
126  $oPromotion->setLanguage( 0 );
127  $oPromotion->assign( $aParams );
128  $oPromotion->setLanguage( $this->_iEditLang );
129  $oPromotion = oxRegistry::get("oxUtilsFile")->processFiles( $oPromotion );
130  $oPromotion->save();
131 
132  // set oxid if inserted
133  $this->setEditObjectId( $oPromotion->getId() );
134  }
135 
141  public function saveinnlang()
142  {
143  $this->save();
144  }
145 }