/**
  * Główny kontroler
  * @return string
  */
 public function get()
 {
     try {
         /**
          * Quotowana tablica request
          * @var array
          */
         $aRequest = $_REQUEST;
         \Database\Factory::getInstance()->quoteAll($aRequest);
         /**
          * Inicjacja szablonu
          * @var \General\Templater
          */
         $template = new \General\Templater('index.html');
         /*
          * Rejestracja listenerów
          */
         \Listeners\Message::getInstance()->register($aRequest, $template);
         if (empty($aRequest['class'])) {
             $aRequest['class'] = 'Frontpage';
         }
         if (empty($aRequest['method'])) {
             $aRequest['method'] = 'render';
         }
         if (!isset($HTTP_RAW_POST_DATA)) {
             $HTTP_RAW_POST_DATA = file_get_contents("php://input");
         }
         $retVal = '';
         $className = '';
         switch ($aRequest['class']) {
             default:
                 $className = '\\Controller\\' . $aRequest['class'];
                 break;
         }
         $methodName = '';
         switch ($aRequest['method']) {
             default:
                 $methodName = $aRequest['method'];
                 break;
         }
         if (class_exists($className)) {
             $tObject = $className::getInstance();
             if (method_exists($tObject, $methodName)) {
                 $tObject->{$methodName}($aRequest, $template);
             }
         }
         \Listeners\LowLevelMessage::getInstance()->register($aRequest, $template);
     } catch (CustomException $e) {
         $template->add('mainContent', \General\Debug::cThrow($e->getMessage(), $e, array('send' => false, 'display' => false)));
     } catch (Exception $e) {
         $template->add('mainContent', \General\Debug::cThrow(null, $e));
     }
     $template->add('chartHead', '');
     $template->add('listeners', '');
     $template->add('menu', '');
     $template->add('mainContent', '');
     $template->add('titleSecond', '');
     $template->add('pageTitle', '{T:Product Name}');
     return (string) $template;
 }
Esempio n. 2
0
 /**
  * @return string
  */
 public function get()
 {
     \General\Environment::setContentHtml();
     \General\Session::start();
     \General\Environment::set();
     /**
      * @var \General\Templater
      */
     $template = new \General\Templater('index.html');
     try {
         \Database\Factory::getInstance()->quoteAll($this->aParams);
         /*
          * Rejestracja listenerów
          */
         \Listeners\Message::getInstance()->register($this->aParams, $template);
         if (empty($this->aParams['class'])) {
             $this->aParams['class'] = 'Overview';
         }
         if (empty($this->aParams['method'])) {
             $this->aParams['method'] = 'render';
         }
         switch ($this->aParams['class']) {
             default:
                 $className = '\\Controller\\' . $this->aParams['class'];
                 break;
         }
         switch ($this->aParams['method']) {
             default:
                 $methodName = $this->aParams['method'];
                 break;
         }
         if (class_exists($className)) {
             /** @noinspection PhpUndefinedMethodInspection */
             $tObject = $className::getInstance();
             if (method_exists($tObject, $methodName)) {
                 $tObject->{$methodName}($this->aParams, $template);
             }
         }
         \Listeners\LowLevelMessage::getInstance()->register($this->aParams, $template);
     } catch (CustomException $e) {
         $template->add('mainContent', Debug::cThrow($e->getMessage(), $e, array('send' => false, 'display' => false)));
     } catch (Exception $e) {
         $template->add('mainContent', Debug::cThrow(null, $e));
     }
     $template->add('chartHead', '');
     $template->add('listeners', '');
     $template->add('menu', '');
     $template->add('mainContent', '');
     $template->add('titleSecond', '');
     $template->add('pageTitle', '{T:Product Name}');
     $sHtml = (string) $template;
     /*
      * Remove all menu-active-* occurences
      */
     $sHtml = preg_replace('!({submenu-active-[^}]*})!', '', $sHtml);
     $sHtml = preg_replace('!({menu-active-[^}]*})!', '', $sHtml);
     /*
      * Add params
      */
     $sHtml = preg_replace_callback('!({params:[^}]*})!', array($this, 'paramsInjecter'), $sHtml);
     return $sHtml;
 }