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