Example #1
0
 public function ___construct($forceSetup = false)
 {
     $this->container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     $this->mBuilt = false;
     // Parameters must be extracted before starting any dispatcher or validator
     //
     $this->parameters = $this->arrayMergeClobber($this->arrayMergeClobber($_GET, $_POST), $_FILES);
     $this->mDisp = new \Innomatic\Wui\Dispatch\WuiDispatcher('wui');
     $this->mForceSetup = $forceSetup;
     if ($this->container->getState() != \Innomatic\Core\InnomaticContainer::STATE_SETUP or $this->mForceSetup and $this->container->getState() == \Innomatic\Core\InnomaticContainer::STATE_SETUP) {
         $rootDA = $this->container->getDataAccess();
         if (is_object($rootDA)) {
             $this->mrRootDb = $rootDA;
         }
     }
     // AJAX
     $ajax_request_uri = $_SERVER['REQUEST_URI'];
     if (strpos($ajax_request_uri, '?')) {
         $ajax_request_uri = substr($ajax_request_uri, 0, strpos($ajax_request_uri, '?'));
     }
     $this->xajax = \Innomatic\Ajax\Xajax::instance('Xajax', $ajax_request_uri);
 }
 public function doGet(WebAppRequest $req, WebAppResponse $res)
 {
     // Start Innomatic and Tenant
     $innomatic = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     $innomatic->setInterface(\Innomatic\Core\InnomaticContainer::INTERFACE_EXTERNAL);
     $root = \Innomatic\Core\RootContainer::instance('\\Innomatic\\Core\\RootContainer');
     $innomatic_home = $root->getHome() . 'innomatic/';
     $innomatic->bootstrap($innomatic_home, $innomatic_home . 'core/conf/innomatic.ini');
     $innomatic->startDomain(\Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getName());
     $request_uri = \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getProcessor()->getRequest()->getUrlPath(true) . '/_xajax/call.xajax';
     $xajax = Xajax::instance('Xajax', $request_uri);
     // Set debug mode
     if ($innomatic->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) {
         $xajax->debugOn();
     }
     $xajax->setLogFile($innomatic->getHome() . 'core/log/ajax.log');
     $cfg = XajaxConfig::getInstance(\Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp(), \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getHome() . 'core/conf/ajax.xml');
     if (isset($cfg->functions)) {
         foreach ($cfg->functions as $name => $functionData) {
             $xajax->registerExternalFunction(array($name, $functionData['classname'], $functionData['method']), $functionData['classfile']);
         }
     }
     $xajax->processRequests();
 }
Example #3
0
 public function setPredefinedTags($block)
 {
     // Base tags
     $block->set('receiver', $this->context->getRequest()->getUrlPath(true));
     $block->set('baseurl', $this->context->getRequest()->getUrlPath(false) . '/');
     $block->set('module', $this->getModule());
     $block->set('page', $this);
     // Internal page name
     $block->set('page_name', $this->getName());
     // Set page parameters as tags
     $pageParams = $this->getParameters();
     foreach ($pageParams as $paramName => $paramValue) {
         $block->set('page_' . $paramName, $paramValue);
     }
     // Ajax support
     $xajax = \Innomatic\Ajax\Xajax::instance('\\Innomatic\\Ajax\\Xajax', $this->context->getRequest()->getUrlPath(false) . '/ajax/');
     $xajax->ajaxLoader = false;
     $xajax->setLogFile($this->context->getHome() . 'core/log/ajax.log');
     // Set debug mode
     if (\Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer')->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) {
         $xajax->debugOn();
     }
     // Register Ajax calls parsing the ajax.xml configuration file
     if (file_exists(\Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getHome() . 'core/conf/ajax.xml')) {
         $cfg = \Innomatic\Ajax\XajaxConfig::getInstance(\Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp(), \Innomatic\Webapp\WebAppContainer::instance('\\Innomatic\\Webapp\\WebAppContainer')->getCurrentWebApp()->getHome() . 'core/conf/ajax.xml');
         if (isset($cfg->functions)) {
             foreach ($cfg->functions as $name => $functionData) {
                 $xajax->registerExternalFunction(array($name, $functionData['classname'], $functionData['method']), $functionData['classfile']);
             }
         }
     }
     // Build the base javascript for ajax
     $xajax_js = $xajax->getJavascript($this->context->getRequest()->getUrlPath(false) . '/' . 'shared/javascript', 'xajax.js');
     // Setup calls.
     if ($this->context->countRegisteredAjaxSetupCalls() > 0) {
         $setup_calls = $this->context->getRegisteredAjaxSetupCalls();
         $xajax_js .= '<script type="text/javascript">' . "\n";
         foreach ($setup_calls as $call) {
             $xajax_js .= $call . ";\n";
         }
         $xajax_js .= '</script>' . "\n";
     }
     $block->set('xajax_js', $xajax_js);
     return $this;
 }
Example #4
0
 protected function generateSourceEnd()
 {
     $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     // Add titlebar
     $this->mLayout = str_replace('{[wui-titlebar-title]}', isset($GLOBALS['wui']['titlebar-title']) ? $GLOBALS['wui']['titlebar-title'] : '', $this->mLayout);
     // Extract toolbars
     $string = '';
     preg_match_all("/<!\\[WUITOOLBAR\\[(.*?)\\]\\]>/s", $this->mLayout, $string);
     $toolbars = implode($string[0]);
     $toolbars = str_replace('<![WUITOOLBAR[', '', $toolbars);
     $toolbars = str_replace(']]>', '', $toolbars);
     // Strip toolbars template
     $this->mLayout = preg_replace("/<!\\[WUITOOLBAR\\[(.*?)\\]\\]>/s", '', $this->mLayout);
     // Add toolbars
     $this->mLayout = str_replace('{[wui-toolbars]}', $toolbars, $this->mLayout);
     $block = '';
     $block .= "</td></tr>\n</table>\n";
     if (isset($GLOBALS['gEnv']['runtime']['wui_menu']['footer'])) {
         $block .= $GLOBALS['gEnv']['runtime']['wui_menu']['footer'];
     }
     $block .= "</td></tr></table>\n";
     // Ajax support.
     if (\Innomatic\Wui\Wui::instance('\\Innomatic\\Wui\\Wui')->countRegisteredAjaxCalls() > 0) {
         $xajax = \Innomatic\Ajax\Xajax::instance('Xajax');
         // Show the ajax loader?
         $xajax->ajaxLoader = $this->mArgs['ajaxloader'] == 'true' ? true : false;
         // Set debug mode
         if ($container->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) {
             $xajax->debugOn();
         }
         $block .= $xajax->getJavascript($container->getBaseUrl() . '/shared', 'xajax.js');
         // Setup calls.
         if (\Innomatic\Wui\Wui::instance('\\Innomatic\\Wui\\Wui')->countRegisteredAjaxSetupCalls() > 0) {
             $setup_calls = \Innomatic\Wui\Wui::instance('\\Innomatic\\Wui\\Wui')->getRegisteredAjaxSetupCalls();
             $block .= '<script type="text/javascript">' . "\n";
             foreach ($setup_calls as $call) {
                 $block .= $call . ";\n";
             }
             $block .= '</script>' . "\n";
         }
     }
     $block .= "<script type=\"text/javascript\">\n";
     $block .= "\n        \$( document ).ready(function() {\n            resizeSubTopMenu()\n        });\n        \$( window ).resize(function() {\n          resizeSubTopMenu()\n        });\n\n        function resizeSubTopMenu(){\n            heigthThead = \$('#sub-top-menu').height()-35;\n            \$('#page-tbody tr td:first').css({ 'padding-top': heigthThead+'px'});\n        }";
     $block .= "</script>\n";
     $block .= "</body>\n</html>\n";
     return $block;
 }
 public function __construct($mode, $application)
 {
     $container = \Innomatic\Core\InnomaticContainer::instance('\\Innomatic\\Core\\InnomaticContainer');
     // Builds the application home path
     $home = $container->getHome();
     switch ($mode) {
         case \Innomatic\Core\InnomaticContainer::MODE_ROOT:
             $home .= 'root/';
             break;
         case \Innomatic\Core\InnomaticContainer::MODE_DOMAIN:
             $home .= 'domain/';
             break;
     }
     $home .= $application . '-panel/';
     // Checks if the application exists and is valid
     if (file_exists($home)) {
         $this->mode = $mode;
         $this->applicationHome = $home;
         $this->application = $application;
     } else {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::INVALID_APPLICATION);
     }
     // TODO Verificare, dopo questa impostazione, quanto ancora sia utile di WuiDispatcher
     $view = null;
     $action = null;
     // View initialization
     $viewDispatcher = new \Innomatic\Wui\Dispatch\WuiDispatcher('view');
     $viewEvent = $viewDispatcher->getEventName();
     if (!strlen($viewEvent)) {
         $viewEvent = 'default';
     }
     $viewClassName = ucfirst($this->application) . 'PanelViews';
     // Checks if view file and definition exist
     // @todo update to new namespaces model
     if (!(include_once $this->applicationHome . $viewClassName . '.php')) {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::MISSING_VIEWS_FILE);
     }
     if (!class_exists($viewClassName, true)) {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::MISSING_VIEWS_CLASS);
     }
     // Instantiate views class
     $this->view = new $viewClassName($this);
     $this->_view = $this->view;
     $this->view->beginHelper();
     // Action initialization
     $actionClassName = ucfirst($this->application) . 'PanelActions';
     // Checks if class file and definition exist
     if (!(include_once $this->applicationHome . $actionClassName . '.php')) {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::MISSING_ACTIONS_FILE);
     }
     if (!class_exists($actionClassName, true)) {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::MISSING_ACTIONS_CLASS);
     }
     // AJAX
     $ajax_request_uri = $_SERVER['REQUEST_URI'];
     if (strpos($ajax_request_uri, '?')) {
         $ajax_request_uri = substr($ajax_request_uri, 0, strpos($ajax_request_uri, '?'));
     }
     $this->ajax = \Innomatic\Ajax\Xajax::instance('Xajax', $ajax_request_uri);
     // Set debug mode
     if ($container->getState() == \Innomatic\Core\InnomaticContainer::STATE_DEBUG) {
         $this->ajax->debugOn();
     }
     $this->ajax->setLogFile($container->getHome() . 'core/log/ajax.log');
     // Register action ajax calls
     $this->registerClassAjaxCalls($actionClassName, $this->applicationHome . $actionClassName . '.php');
     // Register WUI widgets ajax calls
     $wui = \Innomatic\Wui\Wui::instance('\\Innomatic\\Wui\\Wui');
     $wui->loadAllWidgets();
     foreach ($wui->mLoadedWidgets as $widget) {
         $this->registerClassAjaxCalls('\\Shared\\Wui\\Wui' . ucfirst($widget), $container->getHome() . 'core/classes/shared/wui/Wui' . ucfirst($widget) . '.php', 'Wui' . ucfirst($widget));
     }
     // Process ajax requests, if any (if so, then it exits)
     $this->ajax->processRequests();
     // Action execution, if set
     $actionDispatcher = new \Innomatic\Wui\Dispatch\WuiDispatcher('action');
     $actionEvent = $actionDispatcher->getEventName();
     if (strlen($actionEvent)) {
         $this->action = new $actionClassName($this);
         $this->_action = $this->action;
         $this->action->addObserver($this);
         if (is_object($this->view)) {
             $this->action->addObserver($this->view);
         }
         $this->action->beginHelper();
         // Executes the action
         $actionResult = $this->action->execute($actionEvent, $actionDispatcher->getEventData());
         $this->action->endHelper();
     }
     // Displays the view result
     if (is_object($this->view)) {
         $this->view->execute($viewEvent, $viewDispatcher->getEventData());
         $this->view->endHelper();
         $this->view->display();
     } else {
         throw new \Innomatic\Wui\WuiException(\Innomatic\Wui\WuiException::NO_VIEW_DEFINED);
     }
 }