OXID eShop CE  4.9.5
 All Classes Files Functions Variables Pages
oxwidgetcontrol.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
11 
17  protected $_blHandlerSet = true;
18 
24  protected $_blMainTasksExecuted = true;
25 
29  public function __construct()
30  {
32  }
33 
45  public function start($sClass = null, $sFunction = null, $aParams = null, $aViewsChain = null)
46  {
47  //$aParams = ( isset($aParams) ) ? $aParams : oxRegistry::getConfig()->getRequestParameter( 'oxwparams' );
48 
49  if (!isset($aViewsChain) && oxRegistry::getConfig()->getRequestParameter('oxwparent')) {
50  $aViewsChain = explode("|", oxRegistry::getConfig()->getRequestParameter('oxwparent'));
51  }
52 
53  parent::start($sClass, $sFunction, $aParams, $aViewsChain);
54 
55  //perform tasks that should be done at the end of widget processing
56  $this->_runLast();
57  }
58 
66  protected function _runOnce()
67  {
68 
69  return;
70  }
71 
75  protected function _runLast()
76  {
77  $oConfig = $this->getConfig();
78 
79  if ($oConfig->hasActiveViewsChain()) {
80  // Removing current active view.
81  $oConfig->dropLastActiveView();
82 
83  // Setting back last active view.
84  $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
85  $oSmarty->assign('oView', $oConfig->getActiveView());
86  }
87  }
88 
99  protected function _initializeViewObject($sClass, $sFunction, $aParams = null, $aViewsChain = null)
100  {
101  $oConfig = $this->getConfig();
102  $aActiveViewsNames = $oConfig->getActiveViewsNames();
103  $aActiveViewsNames = array_map("strtolower", $aActiveViewsNames);
104 
105  // if exists views chain, initializing these view at first
106  if (is_array($aViewsChain) && !empty($aViewsChain)) {
107 
108  foreach ($aViewsChain as $sParentClassName) {
109  if ($sParentClassName != $sClass && !in_array(strtolower($sParentClassName), $aActiveViewsNames)) {
110  // creating parent view object
111  if (strtolower($sParentClassName) == 'oxubase') {
112  $oViewObject = oxNew('oxubase');
113  $oConfig->setActiveView($oViewObject);
114  } else {
115  $oViewObject = oxNew($sParentClassName);
116  $oViewObject->setClassName($sParentClassName);
117  $oConfig->setActiveView($oViewObject);
118  }
119  }
120  }
121  }
122 
123  $oWidgetViewObject = parent::_initializeViewObject($sClass, $sFunction, $aParams);
124 
125  // Set template name for current widget.
126  if (!empty($aParams['oxwtemplate'])) {
127  $oWidgetViewObject->setTemplateName($aParams['oxwtemplate']);
128  }
129 
130  return $oWidgetViewObject;
131  }
132 }