Example #1
0
 public function getGlossarTerm()
 {
     if (\Input::post('id')) {
         $Term = \SwGlossarModel::findByPk(\Input::post('id'));
     }
     if ($Term === null && \Input::post('cloud') == '') {
         return false;
     }
     if (!$this->checkLizenz()) {
         $Log = new \GlossarLogModel();
         $Log->tstamp = time();
         $Log->user = session_id();
         $GAction = 'load';
         if (\Input::post('loaded') == 1) {
             $GAction = 'close';
         }
         if (\Input::post('clicked') == 1) {
             $GAction = 'follow';
             if (\Input::post('no_ref') == 1) {
                 $GAction = 'span';
             }
         }
         if ($id = \Input::post('cloud')) {
             $GAction = 'cloud';
             $Term = new \stdClass();
             $Term->id = $id;
         }
         $Log->action = $GAction;
         $Log->term = $Term->id;
         $Log->page = $_SESSION['FE_DATA']['referer']['current'];
         $Log->language = $_SESSION['TL_LANGUAGE'];
         $Log->save();
     }
     if (\Input::post('cloud') != '') {
         return false;
     }
     $Content = \GlossarContentModel::findPublishedByPidAndTable($Term->id, 'tl_sw_glossar');
     $termObj = new \FrontendTemplate('glossar_layer');
     $termObj->setData($Term->row());
     $termObj->class = 'ce_glossar_layer';
     if (!empty($Content)) {
         if ($GLOBALS['TL_CONFIG']['jumpToGlossar']) {
             $link = \GlossarPageModel::findByPk($GLOBALS['TL_CONFIG']['jumpToGlossar']);
             $termObj->link = $this->generateFrontendUrl($link->row(), ($GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/' : '/items/') . $termObj->alias);
         }
         if ($termObj->jumpTo) {
             $link = \GlossarPageModel::findByPk($termObj->jumpTo);
             $termObj->link = $this->generateFrontendUrl($link->row(), ($GLOBALS['TL_CONFIG']['useAutoItem'] && !$GLOBALS['TL_CONFIG']['disableAlias'] ? '/' : '/items/') . $termObj->alias);
         }
     }
     echo json_encode(array('content' => $termObj->parse()));
     die;
 }