/**
  * Gets the search results.
  * 
  * @return  mixed  Parsed content.
  */
 public function getSearchResults()
 {
     global $_ARRAYLANG;
     $this->template->addBlockfile('ADMIN_CONTENT', 'search', 'Default.html');
     if (!empty($this->term)) {
         $pages = $this->getSearchedPages();
         $countPages = $this->countSearchedPages();
         usort($pages, array($this, 'sortPages'));
         if ($countPages > 0) {
             $parameter = '&cmd=Search' . (empty($this->term) ? '' : '&term=' . contrexx_raw2encodedUrl($this->term));
             $paging = \Paging::get($parameter, '', $countPages, 0, true, null, 'pos');
             $this->template->setVariable(array('TXT_SEARCH_RESULTS_COMMENT' => sprintf($_ARRAYLANG['TXT_SEARCH_RESULTS_COMMENT'], $this->term, $countPages), 'TXT_SEARCH_TITLE' => $_ARRAYLANG['TXT_NAVIGATION_TITLE'], 'TXT_SEARCH_CONTENT_TITLE' => $_ARRAYLANG['TXT_PAGETITLE'], 'TXT_SEARCH_SLUG' => $_ARRAYLANG['TXT_CORE_CM_SLUG'], 'TXT_SEARCH_LANG' => $_ARRAYLANG['TXT_LANGUAGE'], 'SEARCH_PAGING' => $paging));
             foreach ($pages as $page) {
                 // used for alias pages, because they have no language
                 if ($page->getLang() == "") {
                     $languages = "";
                     foreach (\FWLanguage::getIdArray('frontend') as $langId) {
                         $languages[] = \FWLanguage::getLanguageCodeById($langId);
                     }
                 } else {
                     $languages = array(\FWLanguage::getLanguageCodeById($page->getLang()));
                 }
                 $aliasLanguages = implode(', ', $languages);
                 $originalPage = $page;
                 $link = 'index.php?cmd=ContentManager&page=' . $page->getId();
                 if ($page->getType() == \Cx\Core\ContentManager\Model\Entity\Page::TYPE_ALIAS) {
                     $pageRepo = \Env::get('em')->getRepository('Cx\\Core\\ContentManager\\Model\\Entity\\Page');
                     if ($originalPage->isTargetInternal()) {
                         // is internal target, get target page
                         $originalPage = $pageRepo->getTargetPage($page);
                     } else {
                         // is an external target, set the link to the external targets url
                         $originalPage = new \Cx\Core\ContentManager\Model\Entity\Page();
                         $originalPage->setTitle($page->getTarget());
                         $link = $page->getTarget();
                     }
                 }
                 $this->template->setVariable(array('SEARCH_RESULT_BACKEND_LINK' => $link, 'SEARCH_RESULT_TITLE' => $originalPage->getTitle(), 'SEARCH_RESULT_CONTENT_TITLE' => $originalPage->getContentTitle(), 'SEARCH_RESULT_SLUG' => substr($page->getPath(), 1), 'SEARCH_RESULT_LANG' => $aliasLanguages, 'SEARCH_RESULT_FRONTEND_LINK' => \Cx\Core\Routing\Url::fromPage($page)));
                 $this->template->parse('search_result_row');
             }
         } else {
             $this->template->setVariable(array('TXT_SEARCH_NO_RESULTS' => sprintf($_ARRAYLANG['TXT_SEARCH_NO_RESULTS'], $this->term)));
         }
     } else {
         $this->template->setVariable(array('TXT_SEARCH_NO_TERM' => $_ARRAYLANG['TXT_SEARCH_NO_TERM']));
     }
 }