示例#1
0
 /**
  * Translate the given key
  * @param $key
  * @return string
  */
 public function translate($key)
 {
     /** @var $translation Translation */
     $translation = $this->database->getEntityManager()->getRepository('Quantum\\DBO\\Translation')->findOneBy(array("trans" => $key, "lang" => $this->lang));
     if ($translation == null) {
         $translation = new Translation($key, $this->lang, $key);
         $this->database->getEntityManager()->persist($translation);
         $this->database->getEntityManager()->flush();
     }
     return utf8_encode($translation->getTranslated());
 }
示例#2
0
 /**
  * Handle the request. Do actions and display the page.
  */
 public function execute()
 {
     // Only for development:
     $this->internalDatabase->createStructure();
     $this->smarty->debugging = $this->settings['in_dev'];
     $this->smarty->assign('system_pageTitle', $this->getSettings()['info']['pageTitle']);
     $this->smarty->assign('system_slogan', $this->getSettings()['info']['slogan']);
     $this->smarty->assign('system_year', date('Y'));
     $this->smarty->assign('system_path', $this->settings['external_path']);
     $this->smarty->assign('system_currentUser', $this->getAccount());
     $this->smarty->assign('system_userManager', $this->getUserManager());
     $this->smarty->assign('system_currentInternalUser', $this->getUserManager()->getCurrentInternalAccount());
     $this->smarty->assign('system_date', date('d-m-Y'));
     $this->smarty->assign('system_time', date('H:i:s'));
     $this->smarty->assign('board_type', $this->getSettings()['news']['type']['version']);
     $this->smarty->assign('board_link', $this->getSettings()['news']['path']);
     $uri = $this->prepareUri();
     $path = explode('/', $uri);
     $page = $this->settings['default_page'] ?: 'Home';
     if (count($path) > 0 && $uri !== '') {
         $page = $path[0];
     }
     $pageFullName = "\\App\\Pages\\" . $page;
     if (!class_exists($pageFullName)) {
         throw new NotFoundException();
     }
     /** @var $pageObject BasePage */
     $pageObject = new $pageFullName();
     if (!$pageObject instanceof BasePage) {
         throw new NotFoundException();
     }
     $pageObject->setSmarty($this->smarty);
     $pageObject->setCore($this);
     $pageObject->setArgs($path);
     $this->doAuthorization($pageObject);
     /** Container pages allows us to create sub-pages */
     if ($pageObject instanceof ContainerPage) {
         $pageObject = $this->handleContainerPage($pageObject, $pageFullName, $path);
     }
     array_shift($path);
     $pageObject->setSmarty($this->smarty);
     $pageObject->setCore($this);
     $pageObject->setArgs($path);
     if ($pageObject instanceof Controller) {
         // The big deal begins
         $action = isset($path[0]) ? $path[0] : '';
         array_shift($path);
         $pageObject->setArgs($path);
         if (method_exists($pageObject, $action)) {
             $layout = 'index.tpl';
             $result = $pageObject->{$action}();
             if (stripos($result, ':') !== false) {
                 list($layout, $template) = explode(':', $result);
             } else {
                 $template = $result;
             }
             $this->smarty->assign('pageTemplate', $template);
             $this->smarty->display($layout);
         } else {
             $pageObject->_404();
         }
         return;
     }
     $this->renderPage($pageObject);
 }