oxwidgetcontrol.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxWidgetControl extends oxShopControl
00009 {
00010 
00011 
00017     protected $_blHandlerSet = true;
00018 
00024     protected $_blMainTasksExecuted = true;
00025 
00029     public function __construct()
00030     {
00031         parent::__construct();
00032     }
00033 
00045     public function start($sClass = null, $sFunction = null, $aParams = null, $aViewsChain = null)
00046     {
00047         //$aParams = ( isset($aParams) ) ? $aParams : oxRegistry::getConfig()->getRequestParameter( 'oxwparams' );
00048 
00049         if (!isset($aViewsChain) && oxRegistry::getConfig()->getRequestParameter('oxwparent')) {
00050             $aViewsChain = explode("|", oxRegistry::getConfig()->getRequestParameter('oxwparent'));
00051         }
00052 
00053         parent::start($sClass, $sFunction, $aParams, $aViewsChain);
00054 
00055         //perform tasks that should be done at the end of widget processing
00056         $this->_runLast();
00057     }
00058 
00066     protected function _runOnce()
00067     {
00068 
00069         return;
00070     }
00071 
00075     protected function _runLast()
00076     {
00077         $oConfig = $this->getConfig();
00078 
00079         if ($oConfig->hasActiveViewsChain()) {
00080             // Removing current active view.
00081             $oConfig->dropLastActiveView();
00082 
00083             // Setting back last active view.
00084             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00085             $oSmarty->assign('oView', $oConfig->getActiveView());
00086         }
00087     }
00088 
00099     protected function _initializeViewObject($sClass, $sFunction, $aParams = null, $aViewsChain = null)
00100     {
00101         $oConfig = $this->getConfig();
00102         $aActiveViewsNames = $oConfig->getActiveViewsNames();
00103         $aActiveViewsNames = array_map("strtolower", $aActiveViewsNames);
00104 
00105         // if exists views chain, initializing these view at first
00106         if (is_array($aViewsChain) && !empty($aViewsChain)) {
00107 
00108             foreach ($aViewsChain as $sParentClassName) {
00109                 if ($sParentClassName != $sClass && !in_array(strtolower($sParentClassName), $aActiveViewsNames)) {
00110                     // creating parent view object
00111                     if (strtolower($sParentClassName) == 'oxubase') {
00112                         $oViewObject = oxNew('oxubase');
00113                         $oConfig->setActiveView($oViewObject);
00114                     } else {
00115                         $oViewObject = oxNew($sParentClassName);
00116                         $oViewObject->setClassName($sParentClassName);
00117                         $oConfig->setActiveView($oViewObject);
00118                     }
00119                 }
00120             }
00121         }
00122 
00123         $oWidgetViewObject = parent::_initializeViewObject($sClass, $sFunction, $aParams);
00124 
00125         // Set template name for current widget.
00126         if (!empty($aParams['oxwtemplate'])) {
00127             $oWidgetViewObject->setTemplateName($aParams['oxwtemplate']);
00128         }
00129 
00130         return $oWidgetViewObject;
00131     }
00132 }