oxwidgetcontrol.php

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