private function getJSON(&$aRequest) { if ($this->sAction === 'destroy') { foreach ($aRequest['session_key'] as $sSessionKey) { Session::getSession()->setArrayAttributeValueForKey(WidgetModule::WIDGET_SESSION_KEY, $sSessionKey, null); } return; } $sWidgetClass = WidgetModule::getClassNameByName($this->sWidgetType); $bIsPersistent = $sWidgetClass::isPersistent(); if (!$bIsPersistent) { // Close session early on readonly calls Session::close(); } if ($this->sAction == 'widgetInformation') { $aInformation = array(); $sWidgetClass::includeResources(); $aInformation['resources'] = ResourceIncluder::defaultIncluder()->getIncludes()->render(); $aInformation['methods'] = $sWidgetClass::getCustomMethods(); $aInformation['is_singleton'] = $sWidgetClass::isSingleton(); $aInformation['is_persistent'] = $bIsPersistent; return $aInformation; } if ($this->sAction == 'staticMethodCall') { $this->checkPermissions($sWidgetClass); $sMethodName = isset($aRequest['method']) ? $aRequest['method'] : Manager::usePath(); if (!method_exists($sWidgetClass, $sMethodName)) { throw new LocalizedException('wns.file.widget_json.method_does_not_exist', array('method' => $sMethodName, 'widget' => $sWidgetClass)); } return array("result" => call_user_func_array(array($sWidgetClass, $sMethodName), isset($aRequest['method_parameters']) ? $aRequest['method_parameters'] : array())); } $aInstanceArgs = array(@$aRequest['session_key']); if (isset($aRequest['instance_args'])) { $aInstanceArgs = $aRequest['instance_args']; } $aNewArgs = array_merge(array($this->sWidgetType), $aInstanceArgs); $oWidget = call_user_func_array(array('WidgetModule', 'getWidget'), $aNewArgs); if ($this->sAction === 'instanciateWidget') { $this->checkPermissions($sWidgetClass); $aInformation = array(); $aInformation['session_id'] = $oWidget->getSessionKey(); $oWidgetContents = $oWidget->doWidget(); if ($oWidgetContents instanceof Template) { $oWidgetContents = $oWidgetContents->render(); } $aInformation['content'] = $oWidgetContents; $aInformation['is_new'] = $oWidget->isNew(); $aInformation['initial_settings'] = $oWidget->allSettings(); return $aInformation; } if ($this->sAction === 'methodCall') { $this->checkPermissions($sWidgetClass); $sMethodName = isset($aRequest['method']) ? $aRequest['method'] : Manager::usePath(); if (!method_exists($oWidget, $sMethodName)) { throw new LocalizedException('wns.file.widget_json.method_does_not_exist', array('method' => $sMethodName, 'widget' => $oWidget->getName())); } return array("result" => call_user_func_array(array($oWidget, $sMethodName), isset($aRequest['method_parameters']) ? $aRequest['method_parameters'] : array())); } }
private function content(Template $oTemplate, $sWidgetName) { $sWidgetClass = WidgetModule::getClassNameByName($sWidgetName); if (is_callable(array($sWidgetClass, 'testWidget'))) { $oWidget = $sWidgetClass::testWidget(); } else { $oWidget = WidgetModule::getWidget($sWidgetName, null); } $oTemplate->replaceIdentifierMultiple('main_content', $oWidget->doWidget()); }
private function doAdmin($oTemplate) { $oAdminMenuWidget = new AdminMenuWidgetModule(); AdminMenuWidgetModule::includeResources($this->oResourceIncluder); $oTemplate->replaceIdentifierMultiple('main_content', $this->oModule->mainContent()); $mSidebarContent = $this->oModule->sidebarContent(); if ($mSidebarContent === null) { $mSidebarContent = ''; } else { if ($mSidebarContent === false) { $mSidebarContent = null; } } $oTemplate->replaceIdentifierMultiple('sidebar_content', $mSidebarContent); $oTemplate->replaceIdentifierMultiple('admin_menu', $oAdminMenuWidget->doWidget()); foreach ($this->oModule->usedWidgets() as $mWidget) { if (!is_string($mWidget)) { $mWidget = get_class($mWidget); } else { $mWidget = WidgetModule::getClassNameByName($mWidget); } call_user_func(array($mWidget, 'includeResources'), $this->oResourceIncluder); } $this->oModule->includeCustomResources($this->oResourceIncluder); }