oxwidgetcontrol.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class oxWidgetControl extends oxShopControl
00009 {
00015     protected $_blHandlerSet = true;
00016 
00022     protected $_blMainTasksExecuted = true;
00023 
00027     function __construct()
00028     {
00029         parent::__construct();
00030     }
00031 
00045     public function start( $sClass = null, $sFunction = null, $aParams = null, $aViewsChain = null )
00046     {
00047         //$aParams = ( isset($aParams) ) ? $aParams : oxConfig::getParameter( 'oxwparams' );
00048 
00049         if ( !isset($aViewsChain) && oxConfig::getParameter( 'oxwparent' ) ) {
00050             $aViewsChain =  explode( "|", oxConfig::getParameter( '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 
00077     protected function _runLast()
00078     {
00079         $oConfig = $this->getConfig();
00080 
00081         if ( $oConfig->hasActiveViewsChain() ) {
00082             //removing current active view
00083             $oConfig->dropLastActiveView();
00084 
00085             // setting back last active view
00086             $oSmarty = oxRegistry::get("oxUtilsView")->getSmarty();
00087             $oSmarty->assign('oView', $oConfig->getActiveView() );
00088         }
00089     }
00090 
00101     protected function _initializeViewObject( $sClass, $sFunction, $aParams = null, $aViewsChain = null )
00102     {
00103         $oConfig = $this->getConfig();
00104         $aActiveViewsNames = $oConfig->getActiveViewsNames();
00105         $aActiveViewsNames = array_map( "strtolower", $aActiveViewsNames );
00106 
00107         // if exists views chain, initializing these view at first
00108         if ( is_array($aViewsChain) && !empty($aViewsChain) ) {
00109 
00110             foreach ( $aViewsChain as $sParentClassName ) {
00111                 if ( $sParentClassName != $sClass && !in_array( strtolower($sParentClassName), $aActiveViewsNames ) ) {
00112                     // creating parent view object
00113                     if ( strtolower($sParentClassName) == 'oxubase' ) {
00114                         $oViewObject = oxNew( 'oxubase' );
00115                         $oConfig->setActiveView( $oViewObject );
00116                     } else {
00117                         $oViewObject = oxNew( $sParentClassName );
00118                         $oViewObject->setClassName( $sParentClassName );
00119                         $oConfig->setActiveView( $oViewObject );
00120                     }
00121                 }
00122             }
00123         }
00124 
00125         $oWidgetViewObject = parent::_initializeViewObject( $sClass, $sFunction, $aParams );
00126 
00127         //set template name for current widget
00128         if ( $aParams['oxwtemplate'] ) {
00129             $oWidgetViewObject->setTemplateName( $aParams['oxwtemplate'] );
00130         }
00131 
00132         return $oWidgetViewObject;
00133     }
00134 }