<?php
namespace NCBS\WebsiteBundle\Controller;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Query\ResultSetMapping;
use NCBS\WebsiteBundle\Controller\SearchController;
use NCBS\WebsiteBundle\Entity\Exposition;
use NCBS\WebsiteBundle\Tools\DataAssembly;
use NCBS\WebsiteBundle\Tools\PostgresSearch;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
class ExpositionController extends NCBSWController
{
protected $prefix = 'Exposition';
// Overriding this to automatically pass list of Swedenborg works to every template
// (easier to program than trying to figure out which ones need it and which don't)
public function renderView($view, array $parameters = array(), Response $response = null)
{
return parent::renderView($view, $parameters, $response);
}
// Given a Work or Translation, checks whether it would be better to view as some other entity type
// (currently can redirect only to concepts)
// Returns null if no redirect is necessary or a null argument is provided, or false if an unknown argument type is supplied
// Otherwise, returns url to redirect to
protected function checkRedirect($target)
{
/* if($target === null) {
return null;
} elseif($target instanceof Exposition\Translation) {
$targetTranslation = $target;
} elseif($target instanceof Exposition\Work) {
$targetTranslation = $target->selectTranslation();
} else {
return null;
}
if($targetTranslation == null)
return null;
$sConceptUrl = $this->checkConcept($targetTranslation->getId());
if(!empty($sConceptUrl))
{
$url = $this->get('router')->generate('concept', array(
'conceptUrl' => $sConceptUrl
));
$args = @$_SERVER['QUERY_STRING'];
if(!empty($args))
{
$url .= '?'.$args;
}
return $url;
} */
return null;
}
protected function selectSelectorList($work, $languageName = 'English', $currentTranslation = null)
{
if($work === null) {
return null;
}
if($work->getSwedenborgType() !== null) {
return $this->buildSwedenborgSelectorList($languageName, $currentTranslation);
}
$list = array();
foreach($work->getCategories() as $category) {
if($category->getIndexPage() !== null) {
$catName = $category->getName();
$list[$catName] = array();
foreach($category->getWorks() as $w) {
$t = $w->selectTranslation($languageName);
if($t != null)
$list[$catName][$t->getTranslatedTitle()] = ($work == $w) ? null : $t;
}
ksort($list[$catName]);
}
}
if(empty($list)) {
return null;
} else {
return $list;
}
}
protected function buildSwedenborgSelectorList($languageName = 'English', $currentTranslation = null)
{
$allWorks = $this->expositionData('Work')->findByIsPublic(true);
$swedenborgBooks = array(
// 'Published Theological Works' => array(),
// 'Posthumous Theological Works' => array(),
// 'Pre-Revelatory Works' => array()
);
foreach($allWorks as $work) {
if($work->getSwedenborgType() !== null) {
if($currentTranslation !== null && $currentTranslation->getWork() == $work) {
$translation = $currentTranslation;
} else {
$translation = $work->selectTranslation($languageName);
}
if($translation !== null) {
$title = $translation->getTranslatedTitle();
$swedenborgBooks[$title] = $translation;
/*
if($work->getSwedenborgType() == 'published revelatory') {
$swedenborgBooks['Published Theological Works'][$title] = $translation;
} elseif($work->getSwedenborgType() == 'posthumous revelatory') {
$swedenborgBooks['Posthumous Theological Works'][$title] = $translation;
} else { // 'published pre-revelatory' or 'posthumous pre-revelatory'
$swedenborgBooks['Pre-Revelatory Works'][$title] = $translation;
}
*/
}
}
}
ksort($swedenborgBooks);
// ksort($swedenborgBooks['Published Theological Works']);
// ksort($swedenborgBooks['Posthumous Theological Works']);
// ksort($swedenborgBooks['Pre-Revelatory Works']);
return array("Swedenborg's Theological Works" => $swedenborgBooks);
}
public function swedenborgIndexAction(Request $request)
{
/*
$locale = $request->getLocale();
$nLanguageID = $this->getLanguageIDByShortCode($locale);
return $this->renderView('index/swedenborg', array(
'selector_data' => $this->getCategorizedSwedenborgWorks($request, $nLanguageID),
'illustration' => $this->getRepository('Media\Image')->findOneByFile('quill-pen.jpg'),
'index_path' => 'swedenborg'
)); */
$this->setCurrentUrl($request);
$this->onloadPage($request);
$locale = $request->getLocale();
$nLocaleLanguageID = $this->getLanguageIDByShortCode($locale);
$nSelectedLangID = $request->query->get('l');
return $this->renderView('index/swedenborg', array(
'works' => $this->getSwedenborgWorks($request, $nLocaleLanguageID, $nSelectedLangID),
'works2' => $this->getSwedenborgWorks2($request, $nLocaleLanguageID, $nSelectedLangID),
'languages' => $this->getSwedenborgWorkLanguages($request),
'selected_language_id' => $nSelectedLangID,
'search_domain' => 'w'
));
}
public function conceptsIndexAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('index/concepts', array('index_path' => 'concepts', 'selector_data' => array('Bible Words Explained' => $conceptSelection)));
}
public function considerIndexAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$locale = $request->getLocale();
$aPathway = $this->getTopPathList($locale);
return $this->renderView('index/spiritual_topics', array(
'pathway_list' => $aPathway
));
}
public function educationalMaterialsIndexAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$categoryUrls = array('vineyard-collection-concept-articles');
$selectorData = array();
foreach($categoryUrls as $url) {
$category = $this->expositionData('Category')->findOneByUrl($url);
$selectorData[$category->getName()] = $this->singleCategorySelectorData($category);
}
return $this->renderView('index/educational_materials', array(
'index_path' => 'educational_materials',
'selector_data' => $selectorData,
'illustration' => $this->getRepository('Media\Image')->findOneByFile('nc-vineyard.jpg')
));
}
function singleCategorySelectorData($category)
{
if($category === null) {
return array();
}
$categoryData = array();
foreach($category->getWorks() as $work) {
$translation = $work->selectTranslation();
$categoryData[$translation->getTranslatedTitle()] = $translation;
}
foreach($category->getTranslations() as $translation) {
$categoryData[$translation->getTranslatedTitle()] = $translation;
}
ksort($categoryData);
return $categoryData;
}
public function categoryAction($categoryUrl, Request $request)
{
$category = $this->expositionData('Category')->findOneByUrl($categoryUrl);
$response = null;
if($category === null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('category', array('category' => $category), $response);
}
// Note: If $passageSeparator is null (e.g. due to being unspecified) then the template file will use <p></p> tags to separate passages
public function excerptAction($excerptId, Request $request, $translationUrl = null, $textUnitSeparator = "\n", $passageSeparator = null, $userSelected = false)
{
$excerpt = $this->expositionData('Excerpt')->findOneById($excerptId);
if($excerpt === null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
if($translationUrl === null) {
$translation = $excerpt->getStartArea()->getTranslation();
} else {
$translation = $this->expositionData('Translation')->findOneBy(array('url' => $translationUrl, 'isPublic' => true));
}
if($userSelected) {
$request->getSession()->set('current_language', $translation->getLanguage()->getBibliographicCode());
}
$translationId = $translation->getId();
$excerptPassages = array();
$startTextArea = $excerpt->getStartArea();
$endTextArea = $excerpt->getEndArea();
if($startTextArea->getId() === $endTextArea->getId()) {
// Entire excerpt is in a single text unit
if($excerpt->getStartChar() > $excerpt->getEndChar()) {
// Error! Invalid Excerpt: Start character comes after end character
}
$excerptPassages[] = substr($startTextArea->getText(), $excerpt->getStartChar(), 1+$excerpt->getEndChar()-$excerpt->getStartChar());
} else {
$startTextUnit = $startTextArea->getPlacement();
$startPassage = $startTextUnit->getPassage();
$endTextUnit = $endTextArea->getPlacement();
$endPassage = $endTextUnit->getPassage();
if($startPassage->getId() == $endPassage->getId()) {
// Entire excerpt is in a single passage
$startTextOrdering = $startTextUnit->getOrdering();
$endTextOrdering = $endTextArea->getOrdering();
if($startTextOrdering > $endTextOrdering) {
// Error! Invalid Excerpt: Start text unit comes after end text unit
}
$text = substr($startTextArea->getText(), $excerpt->getStartChar());
foreach($startPassage->getTextUnits() as $textUnit) {
if($textUnit->getOrdering() > $startTextOrdering && $textUnit->getOrdering() < $endTextOrdering) {
$text .= $textUnitSeparator.$textUnit->findTranslatedVersion($translationId)->getText();
}
}
$text .= $textUnitSeparator.substr($endTextArea->getText(), 0, $excerpt->getEndChar() + 1);
$excerptPassages[] = $text;
} else {
$startText = substr($startTextArea->getText(), $excerpt->getStartChar());
foreach($startPassage->getTextUnits() as $textUnit) {
if($textUnit->getOrdering() > $startTextUnit->getOrdering()) {
$startText .= $textUnitSeparator.$textUnit->findTranslatedVersion($translationId)->getText();
}
}
$excerptPassages[] = $startText;
// Add text for intermediate passages
for($currentPassage = $startPassage->findNextPassage(); $currentPassage != null && $currentPassage->getId() != $endPassage->getId(); $currentPassage = $currentPassage->findNextPassage()) {
$excerptPassages[] = $currentPassage->textInTranslation($translationId);
}
if($currentPassage == null) {
// Error! Invalid Excerpt: End passage can't be reached by moving forward from start passage
}
// Build text for end of passage
$endText = "";
foreach($endPassage->getTextUnits() as $textUnit) {
if($textUnit->getOrdering() < $endTextUnit->getOrdering()) {
$endText .= $textUnit->findTranslatedVersion($translationId)->getText().$textUnitSeparator;
}
}
$endText .= substr($endTextArea->getText(), 0, $excerpt->getEndChar() + 1);
$excerptPassages[] = $endText;
}
}
$excerptData = array(
'excerpt' => $excerpt,
'excerpt_passages' => $excerptPassages,
'passage_separator' => $passageSeparator,
'nav_mode' => 'translation'
);
if($translation->getWork()->getSwedenborgType() !== null) {
$excerptData['selector_data'] = $this->buildSwedenborgSelectorList($translation->getLanguage()->getName(), $translation);
}
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('excerpt', $excerptData);
} // end function excerptAction
public function workIndexAction($workUrl, Request $request)
{
$this->onloadPage($request);
$work = $this->expositionData('Work')->findOneBy(array('url' => $workUrl, 'isPublic' => true));
$translation = ($work === null) ? null : $work->selectTranslation();
if($translation === null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
else
{
$this->setCurrentUrl($request);
$translationUrl = $translation->getUrl();
return $this->redirect($this->get('router')->generate('exposition_translation_index', array(
'translationUrl' => $translationUrl
)), 301);
}
}
public function workPassageAction($workUrl, Request $request, $passageId = null)
{
$this->onloadPage($request);
$work = $this->expositionData('Work')->findOneBy(array('url' => $workUrl, 'isPublic' => true));
if($work === null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
$redir = $this->checkRedirect($work);
if($redir !== null) {
return $this->redirect($redir, 301);
}
$locale = $request->getLocale();
$aTranslation = $this->getTranslationInfo($workUrl,$locale,$passageId);
if(empty($aTranslation)) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
else
{
$this->setCurrentUrl($request);
$translationUrl = $aTranslation['translation_url'];
$divisionUrl = $aTranslation['division_url'];
$passageNum = $aTranslation['passage_order'];
return $this->redirect($this->get('router')->generate('exposition_translation_division_passage', array(
'translationUrl' => $translationUrl,
'divisionUrls' => $divisionUrl,
'passageNumber' => $passageNum
)), 301);
}
}
public function workDivisionPassageAction($workUrl, $divisionUrls, Request $request, $passageNumber = null)
{
$this->onloadPage($request);
$work = $this->expositionData('Work')->findOneBy(array('url' => $workUrl, 'isPublic' => true));
$redir = $this->checkRedirect($work);
if($redir !== null) {
return $this->redirect($redir, 301);
}
// Google seems to still be indexing results from /contents/<ordering> in Arcana Coelestia, so we'll redirect those to the URLs that are used for it now
/* if($work !== null && $work->getUrl() === 'arcana-coelestia' && $divisionUrls === 'contents' && $passageNumber !== null && substr($passageNumber, -1) === '0') {
$passage = $this->expositionData('Passage')->findSwedenborgSection($work, substr($passageNumber, 0, -1));
return $this->passageCanonicalRedirect($passage);
} */
$passage = $this->findPassageByWorkAndDivisions($work, $divisionUrls, $passageNumber);
$translation = ($work === null) ? null : $work->selectTranslation();
if($translation === null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
else
{
$this->setCurrentUrl($request);
$translationUrl = $translation->getUrl();
if($passageNumber != null)
{
return $this->redirect($this->get('router')->generate('exposition_translation_division_passage', array(
'translationUrl' => $translationUrl,
'divisionUrls' => $divisionUrls,
'passageNumber' => $passageNumber
)), 301);
//return $this->redirect('/exposition/translation/'.$translationUrl.'/'.$divisionUrls.'/'.$passageNumber);
}
else
{
return $this->redirect($this->get('router')->generate('exposition_translation_division', array(
'translationUrl' => $translationUrl,
'divisionUrls' => $divisionUrls
)), 301);
//return $this->redirect('/exposition/translation/'.$translationUrl.'/'.$divisionUrls);
}
}
}
protected function workPassageView($passage, $work = null, $request)
{
$this->onloadPage($request);
if($work === null && $passage !== null) {
$work = $passage->findWork();
}
// Once we have user preferences implemented, we should use the user's preferred translation (or the default for the user's preferred language) instead of the original, where applicable
$translation = ($work === null) ? null : $work->selectTranslation();
$sUrlCompareTo = $request->query->get('compareTo');
$aCompare = explode(";;", $sUrlCompareTo);
$nCompareLen = count($aCompare);
$compareTo = null;
$compareTo2 = null;
if($nCompareLen > 0 && $aCompare[0] != '')
$compareTo = $this->expositionData('Translation')->findOneByUrl($aCompare[0]);
if($nCompareLen == 2 && $aCompare[1] != '')
$compareTo2 = $this->expositionData('Translation')->findOneByUrl($aCompare[1]);
$data = array(
'work' => $work,
'passage' => $passage,
'translation' => $translation,
'compare_to' => $compareTo,
'compare_to2' => $compareTo2,
'nav_mode' => 'work',
'text_style_override' => $this->getTextStyleOverride($translation->getLanguage()->getId())
);
/* $selectorData = $this->selectSelectorList($work);
if($selectorData !== null) {
$data['selector_data'] = $selectorData;
} */
$this->setCurrentUrl($request);
return $this->createPassageView($data, 'work', $work, $request);
}
public function workDivisionAction($workUrl, $divisionUrls)
{
$this->onloadPage($request);
$work = $this->expositionData('Work')->findOneBy(array('url' => $workUrl, 'isPublic' => true));
$translation = ($work === null) ? null : $work->selectTranslation();
if($translation === null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
else
{
$this->setCurrentUrl($request);
$translationUrl = $translation->getUrl();
return $this->redirect($this->get('router')->generate('exposition_translation_division', array(
'translationUrl' => $translationUrl,
'divisionUrls' => $divisionUrls
)), 301);
//return $this->redirect('/exposition/translation/'.$translationUrl.'/'.$divisionUrls);
}
}
public function collectionIndexAction($collectionUrl, Request $request)
{
$this->onloadPage($request);
$collection = $this->expositionData('Collection')->findOneByUrl($collectionUrl);
$response = null;
if($collection === null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
$this->setCurrentUrl($request);
return $this->renderView('collection_index', array('collection' => $collection), $response);
}
public function translationIndexAction($translationUrl, Request $request, $userSelected = true)
{
$this->onloadPage($request);
$translation = $this->expositionData('Translation')->findOneBy(array('url' => $translationUrl, 'isPublic' => true));
$response = null;
if($translation === null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
if($userSelected && $translation !== null) {
$request->getSession()->set('current_language', $translation->getLanguage()->getBibliographicCode());
}
$data = array('translation' => $translation, 'nav_mode' => 'translation');
$type_id = $translation->getTypeId();
if($type_id == $this->TRANSLATION_TYPE_ID_FILE)
{
$file = $translation->getFile();
if($file !== null) {
$data['file'] = $file;
}
}
if($type_id == $this->TRANSLATION_TYPE_ID_LINK) // link
{
$doc_link = $translation->getDocLink();
if($doc_link !== null) {
$data['doc_link'] = $doc_link;
}
}
$data['type_id'] = $type_id;
$nTransID = $translation->getId();
$data['biblio'] = $this->getBiblio($nTransID, $translation->getIsOriginal());
$data['work_biblio_orig'] = null;
if(!$translation->getIsOriginal())
$data['work_biblio_orig'] = $this->getBiblioOriginal($nTransID);
$data['translation_index'] = '1';
$this->setCurrentUrl($request);
return $this->renderView('translation_index', $data, $response);
}
public function translationPassageAction($translationUrl, Request $request, $passageId = null, $userSelected = true, $inFrame = false)
{
$this->onloadPage($request);
$translation = $this->expositionData('Translation')->findOneBy(array('url' => $translationUrl, 'isPublic' => true));
if($translation == null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
if($userSelected && $translation !== null) {
$request->getSession()->set('current_language', $translation->getLanguage()->getBibliographicCode());
}
$redir = $this->checkRedirect($translation);
if($redir !== null) {
return $this->redirect($redir, 301);
}
$passage = ($passageId !== null)
? $this->expositionData('Passage')->findOneById($passageId)
: (($translation !== null) ? $translation->getWork()->findFirstNonEmptyPassage($translation) : null);
/* if($passage !== null && $passage->findWork() === $translation->getWork()) {
return $this->passageCanonicalRedirect($passage, $translation);
} */
if(!$inFrame)
$this->setCurrentUrl($request);
return $this->translationPassageView($passage, $translation, $request, $inFrame);
}
public function translationDivisionPassageAction($translationUrl, $divisionUrls, Request $request, $passageNumber = null, $userSelected = true, $inFrame = false)
{
$this->onloadPage($request);
$response = null;
if(strlen($passageNumber) > 8) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
if(!$this->IsSwedenborgWork($translationUrl))
{
return $this->redirect($this->get('router')->generate('exposition_translation', array(
'translationUrl' => $translationUrl
)), 301);
}
$translation = $this->expositionData('Translation')->findOneBy(array('url' => $translationUrl, 'isPublic' => true));
if($translation == null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
if($userSelected && $translation !== null) {
$request->getSession()->set('current_language', $translation->getLanguage()->getBibliographicCode());
}
$redir = $this->checkRedirect($translation);
if($redir !== null) {
return $this->redirect($redir, 301);
}
$work = ($translation === null) ? null : $translation->getWork();
if(!$work->getIsPublic()) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
// Google seems to still be indexing results from /contents/<ordering> in Arcana Coelestia, so we'll redirect those to the URLs that are used for it now
if($work !== null && $work->getUrl() === 'arcana-coelestia' && $divisionUrls === 'contents' && $passageNumber !== null && substr($passageNumber, -1) === '0') {
$passage = $this->expositionData('Passage')->findSwedenborgSection($work, substr($passageNumber, 0, -1));
return $this->passageCanonicalRedirect($passage, $translation);
}
$passage = $this->findPassageByWorkAndDivisions($work, $divisionUrls, $passageNumber);
if(!$inFrame)
$this->setCurrentUrl($request);
return $this->translationPassageView($passage, $translation, $request, $inFrame);
}
protected function translationPassageView($passage, $translation, $request, $inFrame = false)
{
$this->checkIfOnMobile($request);
$locale = $request->getLocale();
$nTranslationID = $translation->getId();
$sUrlCompareTo = $request->query->get('compareTo');
$aCompare = explode(";;", $sUrlCompareTo);
$nCompareLen = count($aCompare);
$compareTo = null;
$compareTo2 = null;
$text_to_speech2 = null;
$text_to_speech3 = null;
$text_style_override_compare_to = null;
$text_style_override_compare_to2 = null;
$translation_shortname2 = null;
$translation_shortname3 = null;
if($nCompareLen > 0 && $aCompare[0] != '')
{
$compareTo = $this->expositionData('Translation')->findOneBy(array('url' => $aCompare[0], 'isPublic' => true));
if($compareTo != null)
{
$nLanguageID2 = $compareTo->getLanguage()->getId();
$text_style_override_compare_to = $this->getTextStyleOverride($nLanguageID2);
$text_to_speech2 = $this->getTextToSpeech($nLanguageID2);
$translation_shortname2 = $this->getWorkTranslationShortName($compareTo->getId());
}
}
if($nCompareLen == 2 && $aCompare[1] != '')
{
$compareTo2 = $this->expositionData('Translation')->findOneBy(array('url' => $aCompare[1], 'isPublic' => true));
if($compareTo2 != null)
{
$nLanguageID3 = $compareTo2->getLanguage()->getId();
$text_style_override_compare_to2 = $this->getTextStyleOverride($nLanguageID3);
$text_to_speech3 = $this->getTextToSpeech($nLanguageID3);
$translation_shortname3 = $this->getWorkTranslationShortName($compareTo2->getId());
}
}
$bSwedenborg = $this->isSwedenborg($nTranslationID);
$chapterExplanations = null;
$chapterExplanationsForCombo = null;
$prev_chapter_explanation = array();
$next_chapter_explanation = array();
$explained_cbook_id = null;
if(!$bSwedenborg)
{
$chapterExplanations = $this->getChapterExplanationsForNav($translation);
$chapterExplanationsForCombo = $this->getChapterExplanationsForTextForCombo($translation);
if(!empty($chapterExplanations))
{
$bHasPass = false;
foreach($chapterExplanations as $ce)
{
if($ce['translation_id'] == $nTranslationID)
$bHasPass = true;
else
{
if(!$bHasPass)
{
$prev_chapter_explanation['url'] = $ce['translation_url'];
$prev_chapter_explanation['title'] = $ce['explanationtitle'];
}
else
{
$next_chapter_explanation['url'] = $ce['translation_url'];
$next_chapter_explanation['title'] = $ce['explanationtitle'];
break;
}
}
}
$explained_cbook_id = $chapterExplanations[0]['book_id'];
}
}
$ref_column_spec = '';
if($bSwedenborg)
$ref_column_spec = $this->MULTI_URL_INDICATOR_SWEDENBORG_WORK;
else
$ref_column_spec = $this->MULTI_URL_INDICATOR_EXPLANATION;
$ref_column_spec .= '_' . $translation->getUrl();
if($passage != null && $bSwedenborg)
$ref_column_spec .= '_' . $passage->getSwedenborgSection();
$nPassageID = null;
if($passage != null)
$nPassageID = $passage->getId();
$nLanguageID = $translation->getLanguage()->getId();
$data = array(
'translation' => $translation,
'passage' => $passage,
'compare_to' => $compareTo,
'compare_to2' => $compareTo2,
'nav_mode' => 'translation',
// 'chapter_explanations' => $chapterExplanations,
'chapter_explanations_for_combo' => $chapterExplanationsForCombo,
'prev_chapter_explanation' => $prev_chapter_explanation,
'next_chapter_explanation' => $next_chapter_explanation,
'explained_cbook_id' => $explained_cbook_id,
'ref_column_spec' => $ref_column_spec,
'text_style_override' => $this->getTextStyleOverride($nLanguageID),
'text_style_override_compare_to' => $text_style_override_compare_to,
'text_style_override_compare_to2' => $text_style_override_compare_to2,
'text_to_speech1' => $this->getTextToSpeech($nLanguageID),
'text_to_speech2' => $text_to_speech2,
'text_to_speech3' => $text_to_speech3,
'translation_shortname2' => $translation_shortname2,
'translation_shortname3' => $translation_shortname3
);
$data['is_ipad'] = $this->isIPad();
if($translation !== null) {
/* $selectorData = $this->selectSelectorList($translation->getWork(), $translation->getLanguage()->getName(), $translation);
if($selectorData !== null) {
$data['selector_data'] = $selectorData;
} */
$work = $translation->getWork();
$bSwedenborgWork = ($work->getSwedenborgType() !== null);
$data['is_swedenborg'] = $bSwedenborgWork;
if($bSwedenborgWork)
{
$data['linktype_id'] = $this->LINK_TYPE_ID_SWEDENBORG;
}
else
{
$data['linktype_id'] = $this->LINK_TYPE_ID_OTHER;
}
if($bSwedenborgWork && $nLanguageID == $request->getSession()->get('work_search_language_id'))
{
$data['work_searchterm'] = $request->getSession()->get('work_searchterm');
$data['work_search_phrase'] = $request->getSession()->get('work_search_phrase');
if($nLanguageID == $this->LANGUAGE_ID_LATIN)
{
$data['work_search_internal_amb'] = $request->getSession()->get('work_search_internal_amb');
$data['work_search_external_amb'] = $request->getSession()->get('work_search_external_amb');
$data['work_search_int_ext_amb'] = $request->getSession()->get('work_search_int_ext_amb');
}
else
{
$data['work_search_internal_amb'] = null;
$data['work_search_external_amb'] = null;
$data['work_search_int_ext_amb'] = null;
}
}
else
{
$data['work_searchterm'] = null;
$data['work_search_phrase'] = null;
$data['work_search_internal_amb'] = null;
$data['work_search_external_amb'] = null;
$data['work_search_int_ext_amb'] = null;
}
$bConsider = false;
$bBibleStudy = false;
$bConcept = false;
$bQA = false;
if(!$bSwedenborgWork)
{
foreach($work->getCategories() as $category) {
if($category->getId() == $this->CATEGORY_ID_SPIRITUAL_TOPIC) {
$bConsider = true;
}
elseif($category->getId() == $this->CATEGORY_ID_BIBLE_STUDY) {
$bBibleStudy = true;
}
elseif($category->getId() == $this->CATEGORY_ID_CONCEPT) {
$bConcept = true;
$data['category_concept'] = 1;
}
elseif($category->getId() == $this->CATEGORY_ID_QA) {
$bQA = true;
}
}
}
$nLanguageID = $translation->getLanguage()->getId();
if($bQA)
{
$data['prev_next'] = $this->getPrevNextLink($translation->getId(), $this->CATEGORY_ID_QA, $request);
}
else
{
if($bConsider)
{
$aAllTopic = array();
$sTranslationUrl = $translation->getUrl();
$aSearchedTopic = $request->getSession()->get('searched_topic_list');
if(!empty($aSearchedTopic))
{
foreach($aSearchedTopic as $s)
{
if($s['translation_url'] == $sTranslationUrl)
{
$aAllTopic = $aSearchedTopic;
break;
}
}
}
if(empty($aAllTopic))
{
$aAllTopic = $this->getCategoryList($nLanguageID, $this->CATEGORY_ID_SPIRITUAL_TOPIC, $locale);
}
$data['consider_data'] = $aAllTopic;
$data['prev_next'] = $this->getPrevNextLinkFromList($translation->getId(), $data['consider_data']);
}
if($bBibleStudy)
{
$data['biblestudy_data'] = $this->getCategoryList($nLanguageID, $this->CATEGORY_ID_BIBLE_STUDY, $locale);
$data['prev_next'] = $this->getPrevNextLinkFromList($translation->getId(), $data['biblestudy_data']);
}
if($bConcept)
{
$data['concept_prev_next'] = $this->getNextPrevConceptUrl($translation->getId(), $nLanguageID, $locale);
}
}
if(!$bSwedenborgWork)
$data['authors'] = $this->getAuthorInfo($request, $translation->getId());
else
$data['IsSwedenborgWork'] = 1;
$type_id = $translation->getTypeId();
if($type_id == $this->TRANSLATION_TYPE_ID_FILE)
{
$file = $translation->getFile();
if($file !== null) {
$data['file'] = $file;
}
}
if($type_id == $this->TRANSLATION_TYPE_ID_LINK)
{
$doc_link = $translation->getDocLink();
if($doc_link !== null) {
$data['doc_link'] = $doc_link;
}
}
$data['type_id'] = $type_id;
$data['in_frame'] = $inFrame;
if($passage != null)
{
$nTranslationID = $translation->getId();
if(!$bSwedenborgWork)
$data['passage_ref'] = $this->getWorkPassageRefs($nPassageID,$nTranslationID, $request);
if($bSwedenborgWork)
$data['related_bible_ref'] = $this->getRelatedBibleRefForWork($nPassageID,$nTranslationID, $request);
$data['passage_footnote'] = $this->getPassageFootnotes($nPassageID,$nTranslationID);
$data['passage_multilink'] = $this->getWorkPassageMultiLink($nPassageID,$nTranslationID, $request);
if($translation->getLanguage()->getId() == $this->LANGUAGE_ID_LATIN || ($compareTo != null && $compareTo->getLanguage()->getId() == $this->LANGUAGE_ID_LATIN) || ($compareTo2 != null && $compareTo2->getLanguage()->getId() == $this->LANGUAGE_ID_LATIN))
{
$data['passage_scanimage'] = $this->getWorkPassageScanImageFileName($nPassageID);
$data['define_latin_icon'] = 1;
}
// $data['work_references'] = $this->getWorkRefForWork($nPassageID, $nLanguageID);
// $data['explanation_references'] = $this->getExplanationRefForWork($nPassageID, $nLanguageID);
// $data['gced_ref'] = $this->getGCEDRefForWork($nPassageID);
// $data['otle_ref'] = $this->getOTLERefForWork($nPassageID);
// $data['related_passages'] = $this->getRelatedPassages($nPassageID, $nLanguageID);
$request->getSession()->set('current_explanation_cchapter_id', '');
$nExplainChapterID = $this->getExplainChapterID($nTranslationID, $this->getCurrUserID($request));
if(!empty($nExplainChapterID))
{
$data['cchapter_id'] = $nExplainChapterID;
$request->getSession()->set('current_explanation_cchapter_id', $nExplainChapterID);
$request->getSession()->set('current_explanation_translation_id', $nTranslationID);
}
if(!$bSwedenborgWork)
{
if ($this->canEditExplanation($request))
$data['explanation_translation_id_to_edit'] = $nTranslationID;
}
else if ($this->canEditWork($request))
{
$data['work_translation_id_to_edit'] = $nTranslationID;
$data['work_passage_num_to_edit'] = $passage->getSwedenborgSection();
//$data['has_slider_item_for_work'] = $this->hasSliderItemForWork($nPassageID, $nTranslationID, $request, $nLanguageID);
$data['slider_url'] = $this->get('router')->generate('exposition_slider', array(
'translationId' => $nTranslationID,
'passageId' => $nPassageID
));
}
if($bSwedenborgWork)
{
$data['has_slider_item_for_work'] = $this->hasSliderItemForWork($nPassageID, $nTranslationID, $request, $nLanguageID);
$data['slider_url'] = $this->get('router')->generate('exposition_slider', array(
'translationId' => $nTranslationID,
'passageId' => $nPassageID
));
if($passage->emptyInTranslation($translation))
{
$data['last_passage_num'] = $this->getLastAvailablePassageNum($nTranslationID);
}
}
// check table of contents
$aTOC = $this->getWorkTranslationTOC($nTranslationID, true);
if(!empty($aTOC))
{
$data['has_work_toc'] = true;
}
}
$data['text_to_speech'] = $this->getTextToSpeech($translation->getLanguage()->getId());
if($bSwedenborgWork)
{
$data['biblio_info'] = $this->getBiblioForTranslation($translation->getId());
// $data['swedenborg_works'] = $this->getCategorizedSwedenborgWorksForTranslation($request, $translation->getId(), $translation->getLanguage()->getId());
}
else
{
// check concept image
if($compareTo == null)
{
$conceptUrl = $this->getConceptUrl($translation->getWork()->getId());
if(!empty($conceptUrl))
{
$concept = $this->getRepository('Concepts\Concept')->findOneByUrl($conceptUrl);
$illustrations = $concept->getIllustrations();
$data['image'] = ($illustrations->isEmpty()) ? null : $illustrations[0]->getImage();
}
}
}
} else {
$work = null;
}
return $this->createPassageView($data, 'translation', $work, $request);
}
public function translationDivisionAction($translationUrl, $divisionUrls, $userSelected = true, Request $request)
{
$this->onloadPage($request);
$translation = $this->expositionData('Translation')->findOneBy(array('url' => $translationUrl, 'isPublic' => true));
if($userSelected) {
$request->getSession()->set('current_language', $translation->getLanguage()->getBibliographicCode());
}
$redir = $this->checkRedirect($translation);
if($redir !== null) {
return $this->redirect($redir, 301);
}
$work = ($translation === null) ? null : $translation->getWork();
$division = $this->findDivisionByWorkAndUrls($work, $divisionUrls);
$data = array('translation' => $translation, 'division' => $division, 'nav_mode' => 'translation');
/* $selectorData = $this->selectSelectorList($translation->getWork(), $translation->getLanguage()->getName(), $translation);
if($selectorData !== null) {
$data['selector_data'] = $selectorData;
} */
$response = null;
if($division === null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
$this->setCurrentUrl($request);
return $this->renderView('translation_division', $data, $response);
}
// Final tasks to be performed when rendering a passage, whether accessed via work or via translation
protected function createPassageView($data, $mode, $work, $request)
{
$locale = $request->getLocale();
$response = null;
if($work === null || $data['translation'] === null || $data['passage'] === null || $data['passage']->findWork() !== $work) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
$nPassageID = $data['passage']->getId();
$nTranslationID = $data['translation']->getId();
$nLanguageID = $data['translation']->getLanguage()->getId();
$data['translation_shortname'] = $this->getWorkTranslationShortName($nTranslationID);
$nBibleBookIDForSummary = $this->getBibleBookIDForSummary($nTranslationID);
$bBibleBookSummary = ($nBibleBookIDForSummary != '');
if($bBibleBookSummary)
$data['is_book_summary'] = '1';
if($work !== null) {
$nLevelID = '';
$aStory = $this->getStoryInfo($nTranslationID);
if(!empty($aStory))
{
$nStoryID = $aStory['story_id'];
$nLevelID = $aStory['level_id'];
if($nLevelID == $this->STORY_LEVEL_ID_BIBLE)
{
$aAllStory = array();
/* $aSearchedStory = $request->getSession()->get('searched_bible_story_list');
if(!empty($aSearchedStory))
{
$sTranslationUrl = $data['translation']->getUrl();
foreach($aSearchedStory as $s)
{
if($s['commentary_url'] == $sTranslationUrl)
{
$aAllStory = $aSearchedStory;
break;
}
}
}
if(empty($aAllStory))
{
$aAllStory = $this->getExplainedStoryList($locale);
}
// print_r($aAllStory); */
$data['all_stories'] = $aAllStory;
$data['story_explanations'] = $this->getWorkListForStory($locale, $nStoryID);
$data['commentary_type'] = 'storyexplanation';
}
elseif($nLevelID == $this->STORY_LEVEL_ID_CHAPTER)
$data['is_chapter_explanation'] = '1';
elseif($nLevelID == $this->STORY_LEVEL_ID_VERSE)
$data['is_verse_explanation'] = '1';
$data['story_id'] = $nStoryID;
}
// We can override the 'storyexplanation' commentary type because some "story" explanations are really verse explanations.
// There shouldn't be any similar situation with concept explanations, so if we have an associated concept, then we'll skip the category check below.
// The reason for not using just the category check and nothing else is in case a work or translation doesn't get put in the appropriate category.
if($this->getConceptID($data['translation']->getId()) !== null) {
$data['commentary_type'] = 'conceptexplanation';
} else {
$containingCategories = $work->getCategories()->toArray();
if($data['translation'] !== null) {
$containingCategories = array_merge($containingCategories, $data['translation']->getCategories()->toArray());
}
$categoryUrlToCommentaryTypeMap = array(
'doctrinal-topic-explanations' => 'doctrinaltopic',
'verse-explanations' => 'verseexplanation',
// The story-explanation category doesn't exist at the time of writing this as far as I know, but if it gets added later then we'll want this
'story-explanations' => 'storyexplanation'
);
// If the content doesn't belong to the Category for any major commentary type, then $data['commentary_type'] can just remain unset.
foreach($containingCategories as $cat) {
if(array_key_exists($cat->getUrl(), $categoryUrlToCommentaryTypeMap)) {
$data['commentary_type'] = $categoryUrlToCommentaryTypeMap[$cat->getUrl()];
// At the time of coding this, there shouldn't be anything which belongs to more than one major commentary type.
break;
}
}
}
}
if($work->getSwedenborgType() !== null)
{
$data['previous_passage'] = $this->getPreviousPassageWithContent($data['passage'], $data['translation']);
$data['next_passage'] = $this->getNextPassageWithContent($data['passage'], $data['translation']);
// Get meta description
$nTextLength = 140;
$sPassageText = $this->getWorkPassageContents($nPassageID,$nTranslationID);
$sMetaDesc = $this->fixWorkText($sPassageText);
$sMetaDesc = $this->getTextWithinLength($sMetaDesc, $nTextLength, "...");
$data['work_meta_desc'] = $sMetaDesc;
}
else
{
// Get meta description
$nTextLength = 140;
$sPassageText = '';
if($nLevelID == $this->STORY_LEVEL_ID_CHAPTER)
{
$sPassageText = $this->getWorkPassageContents($nPassageID,$nTranslationID);
}
else
{
$sPassageText = $this->getWorkTranslationDesc($nTranslationID);
if(empty($sPassageText))
{
$sPassageText = $this->getWorkPassageContents($nPassageID,$nTranslationID);
}
}
$sMetaDesc = $this->fixWorkText($sPassageText);
$sMetaDesc = $this->getTextWithinLength($sMetaDesc, $nTextLength, "...");
$data['work_meta_desc'] = $sMetaDesc;
}
$data['work'] = $work;
return $this->renderView($mode.'_passage', $data, $response);
}
protected function findDivisionByWorkAndUrls($work, $divisionUrls)
{
if($work === null) {
return null;
}
$divisionUrlList = explode('/', $divisionUrls);
$divisionData = $this->expositionData('Division');
$division = $divisionData->findOneBy(array(
'work' => $work->getId(), 'url' => array_shift($divisionUrlList)));
foreach($divisionUrlList as $url) {
if($division === null) {
return null;
}
$division = $divisionData->findOneBy(array('superdivision' => $division->getId(), 'url' => $url));
}
return $division;
}
protected function findPassageByWorkAndDivisions($work, $divisionUrls, $passageNumber = null)
{
$division = $this->findDivisionByWorkAndUrls($work, $divisionUrls);
if($division === null) {
return null;
}
return ($passageNumber === null)
? $division->findFirstPassage()
: $this->expositionData('Passage')->findOneBy(array(
'division' => $division->getId(),
'ordering' => $passageNumber
));
}
public function conceptAction($conceptUrl, Request $request, $languageCode = '', $asOverlay = false)
{
// $memcache = $this->get('cache'); // it's actually apccache, but behaves the same way
// $apccache = $this->get('cache');
// The client requested to use translation url instead of concept url (3/16/2020)
$this->onloadPage($request);
if(!$asOverlay)
{
$sTranslationUrl = $this->getConceptTranslationUrl($conceptUrl, $languageCode);
if(!empty($sTranslationUrl))
{
return $this->redirect($this->get('router')->generate('exposition_translation', array(
'translationUrl' => $sTranslationUrl
)), 301);
}
}
$locale = $request->getLocale();
$displayInfo = array('nav_mode' => 'translation', 'commentary_type' => 'conceptexplanation');
$concept = $this->getRepository('Concepts\Concept')->findOneByUrl($conceptUrl);
if(!empty($languageCode))
{
$language = $this->getLanguageByBibliographicCode($languageCode);
$nLanguageID = $language['id'];
}
else
{
$nLanguageID = $this->getLanguageIDByShortCode($locale);
}
$sTranslationUrl = $this->getConceptTranslationUrl($conceptUrl, $languageCode);
if(!empty($sTranslationUrl))
{
$translation = $this->expositionData('Translation')->findOneByUrl($sTranslationUrl);
$displayInfo['translation'] = $translation;
$displayInfo['title'] = $translation->getNameOrTitle();
$illustrations = $concept->getIllustrations();
$displayInfo['image'] = ($illustrations->isEmpty()) ? null : $illustrations[0]->getImage();
$displayInfo['passage'] = $translation->getWork()->findFirstPassage();
$displayInfo['text_style_override'] = $this->getTextStyleOverride($translation->getLanguage()->getId());
$displayInfo['passage_ref'] = $this->getWorkPassageRefs($displayInfo['passage']->getId(),$translation->getId(), $request);
$displayInfo['ref_column_spec'] = $this->getExplanationUrl($translation->getId());
$displayInfo['passage_footnote'] = $this->getPassageFootnotes($displayInfo['passage']->getId(),$translation->getId());
$displayInfo['passage_multilink'] = $this->getWorkPassageMultiLink($displayInfo['passage']->getId(),$translation->getId(), $request);
} elseif($concept !== null) {
// If the concept exists but not in this language, then we probably want a 404 with a list of languages that do have this concept
} else {
$displayInfo['translation'] = null;
$displayInfo['passage'] = null;
}
$response = null;
if(empty($sTranslationUrl) || $displayInfo['translation'] === null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
$templateName = $asOverlay ? 'overlay/passage' : 'translation_passage';
if(!$asOverlay)
{
$this->setCurrentUrl($request);
$displayInfo['concept_prev_next'] = $this->getNextPrevConcept($concept->getId());
}
return $this->renderView($templateName, $displayInfo, $response);
}
protected function passageCanonicalRedirect($passage, $translation, $code = 301)
{
$redirectUrl = $this->get('router')->generate('exposition_translation_division_passage', array(
'translationUrl' => $translation->getUrl(),
'divisionUrls' => $passage->getDivision()->getUrl(),
'passageNumber' => $passage->getOrdering()
));
$args = @$_SERVER['QUERY_STRING'];
if(!empty($args))
{
$redirectUrl .= '?'.$args;
}
return $this->redirect($redirectUrl, $code);
}
public function swedenborgGotoAction(Request $request)
{
$this->onloadPage($request);
$statusCode = 200;
$query = $request->query;
if(!$query->has('translation') && !$query->has('work')) {
// If we aren't told what book to show, then we'll redirect to the list of all Swedenborg books
return $this->redirect($this->get('router')->generate('swedenborg'));
}
$translation = $this->expositionData('Translation')->findOneByUrl($query->get('translation'));
if($translation !== null) {
$request->getSession()->set('current_language', $translation->getLanguage()->getBibliographicCode());
$work = $translation->getWork();
$params = array('translation' => $translation, 'nav_mode' => 'translation');
/* if($work->getSwedenborgType() !== null) {
$params['selector_data'] = $this->buildSwedenborgSelectorList($translation->getLanguage()->getName(), $translation);
}*/
} else {
$work = $this->expositionData('Work')->findOneByUrl($query->get('work'));
$params = array('work' => $work, 'nav_mode' => 'work');
$translation = $work->selectTranslation();
/* if($work->getSwedenborgType() !== null) {
$params['selector_data'] = $this->buildSwedenborgSelectorList();
} */
}
if($query->has('section')) {
$targetSectionNumber = $query->get('section');
$targetSection = $this->expositionData('Passage')->findSwedenborgSection($work, $targetSectionNumber);
$inframe = $query->get('inframe');
if($inframe == 1)
{
return $this->redirect($this->get('router')->generate('exposition_frame_passage', array(
'translationUrl' => $translation->getUrl(),
'divisionUrls' => $targetSection->getDivision()->getUrl(),
'passageNumber' => $targetSection->getOrdering()
)), 301);
}
} else {
$targetSection = $work->findFirstPassage();
}
if($targetSection !== null) {
return $this->passageCanonicalRedirect($targetSection, $translation);
} else {
$fromSection = $query->get('fromSection');
if($fromSection !== null) {
$params['passage'] = $this->expositionData('Passage')->findSwedenborgSection($work, $fromSection);
$template = $params['nav_mode'].'_passage';
} else {
$template = $params['nav_mode'].'_index';
}
$title = ($translation !== null) ? $translation->getTranslatedTitle() : $work->selectTranslation()->getTranslatedTitle();
// "%title% does not contain a section numbered _2000_"
/* $params['error_message'] = $this->get('translator')->trans($request->getSession()->get('ui_str')["exposition.passage.outofrange"], array(
'_1000_' => $title,
'_2000_' => $targetSectionNumber
)); // $title." does not contain a section numbered ".$targetSectionNumber;
*/
$aReplace = array(
'_1000_' => $title,
'_2000_' => $targetSectionNumber
);
$params['error_message'] = $this->ui_string_replace($request->getSession()->get('ui_str')["bible.chapternav.bookchapterrange"], $aReplace);
$statusCode = 404;
}
$sUrlCompareTo = $request->query->get('compareTo');
$aCompare = explode(";;", $sUrlCompareTo);
$nCompareLen = count($aCompare);
$compareTo = null;
$compareTo2 = null;
if($nCompareLen > 0 && $aCompare[0] != '')
$compareTo = $this->expositionData('Translation')->findOneByUrl($aCompare[0]);
if($nCompareLen == 2 && $aCompare[1] != '')
$compareTo2 = $this->expositionData('Translation')->findOneByUrl($aCompare[1]);
$params['compare_to'] = $compareTo;
$params['compare_to2'] = $compareTo2;
$response = null;
if($statusCode !== 200) {
$response = new Response();
$response->setStatusCode($statusCode);
}
$this->setCurrentUrl($request);
return $this->renderView($template, $params, $response);
}
public function quickviewTranslationPassageAction($passageId, $translationId, Request $request)
{
$translation = $this->expositionData('Translation')->findOneById($translationId);
$nTranslationID = $translation->getId();
$work = $translation->getWork();
$nLanguageID = $translation->getLanguage()->getId();
/* $sUrlCompareTo = $request->query->get('compareTo');
$aCompare = explode(";;", $sUrlCompareTo);
$nCompareLen = count($aCompare);
$compareTo = null;
$compareTo2 = null;
if($nCompareLen > 0 && $aCompare[0] != '')
$compareTo = $this->expositionData('Translation')->findOneByUrl($aCompare[0]);
if($nCompareLen == 2 && $aCompare[1] != '')
$compareTo2 = $this->expositionData('Translation')->findOneByUrl($aCompare[1]);
*/
$passage = $this->expositionData('Passage')->findOneById($passageId);
$quickviewData = array(
'translation' => $translation,
// 'compare_to' => $compareTo,
// 'compare_to2' => $compareTo2,
'passage' => $passage,
'text_style_override' => $this->getTextStyleOverride($nLanguageID)
);
if($passage != null && $translation != null)
{
$quickviewData['passage_footnote'] = $this->getPassageFootnotes($passage->getId(),$nTranslationID);
$quickviewData['passage_multilink'] = $this->getWorkPassageMultiLink($passage->getId(),$nTranslationID, $request);
$quickviewData['previous_passage'] = $this->getPreviousPassageWithContent($passage,$translation);
$quickviewData['next_passage'] = $this->getNextPassageWithContent($passage,$translation);
$nWorkID = $work->getId();
if($nLanguageID != $this->LANGUAGE_ID_LATIN)
{
$request->getSession()->set('last_quickview_language_id', $nLanguageID);
}
$sLanguages = "";
$nLastLangID = $request->getSession()->get('last_quickview_language_id');
if($nLanguageID == $this->LANGUAGE_ID_LATIN)
{
if(empty($nLastLangID))
$sLanguages = $nLanguageID;
else
$sLanguages = $nLanguageID . "," . $request->getSession()->get('last_quickview_language_id');
}
else
$sLanguages = $nLanguageID . ", " . $this->LANGUAGE_ID_LATIN;
$quickviewData['translations_by_language'] = $this->getWorkTranslationsByLanguage($nWorkID, $sLanguages);
$quickviewData['shortname'] = $this->getWorkTranslationShortName($nTranslationID);
$quickviewData['translation_id'] = $nTranslationID;
$quickviewData['passage_id'] = $passage->getId();
$bSwedenborgWork = ($work->getSwedenborgType() !== null);
if(!$bSwedenborgWork)
$quickviewData['authors'] = $this->getAuthorInfo($request, $translation->getId());
else
$quickviewData['IsSwedenborgWork'] = 1;
}
return $this->renderView('quickview/passage', $quickviewData);
}
public function quickviewSwedenborgTranslationGotoAction(Request $request)
{
$query = $request->query;
if(!$query->has('translation')) {
// We haven't been told what book to show; maybe someone tried to access this directly rather than via AJAX from the search page?
// We'll redirect to the search page
return $this->redirect($this->get('router')->generate('advanced_search'));
}
$translation = $this->expositionData('Translation')->findOneByUrl($query->get('translation'));
if($query->has('section')) {
$targetSection = $this->expositionData('Passage')->findSwedenborgSection($translation->getWork(), $query->get('section'));
} else {
$targetSection = $translation->getWork()->findFirstPassage();
}
return $this->quickviewTranslationPassageAction($targetSection->getId(), $translation->getId(), $request);
}
public function expositionSearchPostAction(Request $request)
{
// $query = $this->getRequest()->query;
// $searchTerm = $query['searchTerm'];
$params = $request->request->all();
if ( array_key_exists( 'searchTerm', $params ) ) {
$searchTerm = $params['searchTerm'];
} else {
$searchTerm = '';
}
return $this->expositionSearchAction($searchTerm);
}
public function expositionSearchAction($searchTerm, $start=1) {
// $templateName = 'explanation_search';
// return $this->sharedSearchAction( $searchTerm, 'is', $templateName, $start );
return $this->renderView('search/exposition_search', array('searchTerm' => $searchTerm, 'content_class' => 'explanation', 'start' => $start));
}
public function expositionSearchResultsAction($searchTerm, $pageNum = 1)
{
return $this->renderView('search/search_results', $this->expositionSearchResults($searchTerm, false, 'locale', $pageNum));
}
public function swedenborgSearchPostAction(Request $request)
{
// $query = $this->getRequest()->query;
// $searchTerm = $query['searchTerm'];
$params = $request->request->all();
if ( array_key_exists( 'searchTerm', $params ) ) {
$searchTerm = $params['searchTerm'];
} else {
$searchTerm = '';
}
return $this->swedenborgSearchAction($searchTerm);
}
public function swedenborgSearchAction($searchTerm, $start=1)
{
// $templateName = 'swedenborg_search';
// return $this->sharedSearchAction( $searchTerm, 'is not', $templateName, $start );
return $this->renderView('search/exposition_search', array('searchTerm' => $searchTerm, 'content_class' => 'swedenborg', 'start' => $start));
}
public function swedenborgSearchResultsAction($searchTerm, $pageNum = 1)
{
// $templateName = 'swedenborg_search';
// return $this->sharedSearchAction( $searchTerm, 'is not', $templateName, $start );
return $this->renderView('search/search_results', $this->expositionSearchResults($searchTerm, true, 'locale', $pageNum));
}
public function expositionSearchResults(Request $request, $searchTerm, $isSwedenborg, $forceLanguage = null, $start = 1)
{
$search = new PostgresSearch();
$em = $this->getDoctrine()->getManager();
$search->setManager($em);
return $search->getExpositionSearchResults($request, $searchTerm, $isSwedenborg, array('language' => $forceLanguage, 'page' => $start));
}
public function topicalPathIndexAction(Request $request)
{
$this->onloadPage($request);
$locale = $request->getLocale();
$topicData = $this->getTopPathList($locale);
$data = array(
'topic_data' => $topicData
);
$this->setCurrentUrl($request);
return $this->renderView('index/topical_paths', $data);
}
public function topPathAction($TopPathUrl, Request $request)
{
$this->onloadPage($request);
$locale = $request->getLocale();
$topPath = $this->getTopPathInfo($TopPathUrl,$locale);
$subPathList = $this->getSubPathList($TopPathUrl,$locale);
$data = array(
'sub_path_list' => $subPathList,
'top_path' => $topPath,
'top_path_url' => $TopPathUrl
);
$this->setCurrentUrl($request);
return $this->renderView('top_path', $data);
}
public function subPathAction($TopPathUrl, $SubPathUrl, Request $request)
{
$this->onloadPage($request);
$locale = $request->getLocale();
$bibleTranslationUrl = $this->DEFAULT_BIBLE_VERSION;
$nBibleTransID = $request->getSession()->get('current_bible_translation_id');
if($nBibleTransID != '')
{
$bibleTranslation = $this->getBibleTranslationByID($nBibleTransID);
$bibleTranslationUrl = $bibleTranslation['url'];
}
$topPath = $this->getTopPathInfo($TopPathUrl,$locale);
$subPath = $this->getSubPathInfo($SubPathUrl,$locale);
$explanationList = $this->getExplanationListForTopAndSubPath($TopPathUrl, $SubPathUrl,$locale);
$data = array(
'explanation_list' => $explanationList,
'top_path' => $topPath,
'sub_path' => $subPath,
'sub_path_url' => $SubPathUrl,
'top_path_url' => $TopPathUrl,
'bible_translation_url' => $bibleTranslationUrl
);
$this->setCurrentUrl($request);
return $this->renderView('sub_path', $data);
}
public function topicIndexAction(Request $request)
{
$locale = $request->getLocale();
$topicData = $this->getTopicList($locale);
$data = array(
'topic_data' => $topicData
);
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('index/topics', $data);
}
public function topicAction($TopicUrl,Request $request)
{
$this->onloadPage($request);
$locale = $request->getLocale();
$bibleTranslationUrl = $this->DEFAULT_BIBLE_VERSION;
$nBibleTransID = $request->getSession()->get('current_bible_translation_id');
if($nBibleTransID != '')
{
$bibleTranslation = $this->getBibleTranslationByID($nBibleTransID);
$bibleTranslationUrl = $bibleTranslation['url'];
}
$topic = $this->getSubPathInfo($TopicUrl,$locale);
$explanationList = $this->getExplanationListForTopic($TopicUrl,$locale);
$data = array(
'explanation_list' => $explanationList,
'topic' => $topic,
'topic_url' => $TopicUrl,
'bible_translation_url' => $bibleTranslationUrl
);
$this->setCurrentUrl($request);
return $this->renderView('topic', $data);
}
public function viewscanimagesAction($PassageID, Request $request)
{
$this->onloadPage($request);
$aImage = array(
'scanimage' => $this->getWorkPassageScanImageFileName($PassageID),
'translation_info' => $this->getCurrentPassageForLatin($PassageID),
'next_passage' => $this->getNextPassageWithScan($PassageID),
'previous_passage' => $this->getPreviousPassageWithScan($PassageID)
);
return $this->renderView('view_scanimages', $aImage);
}
public function popoverconceptAction($explanationID, $conceptID, Request $request)
{
$locale = $request->getLocale();
$sPopupText = $this->getBibleWordPopupText($explanationID, $conceptID);
$aConceptInfo = $this->getBibleWordPopupConceptInfo($explanationID, $conceptID);
$data = array(
'popup_text' => $sPopupText,
'title' => $aConceptInfo['title'],
'concept_url' => $aConceptInfo['concept_url']
);
return $this->renderView('word_popup', $data);
}
/**
* Show chapter summary list on a popup for multi page
*/
public function selectchaptersummaryAction($explanationID, $bibleBookID, Request $request)
{
$data['chapter_summary_list'] = $this->getChapterSummaryList($explanationID, $bibleBookID);
return $this->renderView('selectchaptersummary', $data);
}
/**
* Show chapter summary list on a popup for single chapter summary page
*/
public function selectchaptersummarysinglepageAction($explanationID, $cBibleBookID, Request $request)
{
$data['chapter_summary_list'] = $this->getChapterSummaryListForSinglePage($explanationID, $cBibleBookID);
return $this->renderView('selectchaptersummarysinglepage', $data);
}
public function featured_spiritual_topicsAction(Request $request)
{
// $this->setCurrentUrl($request);
$this->onloadPage($request);
$locale = $request->getLocale();
$featuredList = $this->getFeaturedListByCategory($this->CATEGORY_ID_SPIRITUAL_TOPIC, $locale, 9);
if(empty($featuredList))
$featuredList = $this->getFeaturedListByCategory($this->CATEGORY_ID_SPIRITUAL_TOPIC, $locale, 9, true);
$request->getSession()->set('searched_topic_list', array());
return $this->renderView('index/spiritual_topics_featured', array(
'featured_topic' => $featuredList
));
}
public function searched_spiritual_topicsAction(Request $request)
{
// $this->setCurrentUrl($request);
$this->onloadPage($request);
$locale = $request->getLocale();
$sSearchTerm = $request->query->get('searchTerm');
$searchedResults = null;
if($sSearchTerm != '')
{
$searchedResults = $this->getSearchedListByCategory($this->CATEGORY_ID_SPIRITUAL_TOPIC, $locale, $request);
}
else
{
$nPathwayID = $request->query->get('pathwayid');
if(!empty($nPathwayID))
{
$searchedResults = $this->getSearchedListByCategoryAndPathway($locale, $request, $this->CATEGORY_ID_SPIRITUAL_TOPIC, $nPathwayID);
}
else
{
$nAll = $request->query->get('all');
if($nAll == '1')
{
$searchedResults = $this->getAllListByCategory($this->CATEGORY_ID_SPIRITUAL_TOPIC, $locale, $request);
}
}
}
return $this->renderView('index/spiritual_topics_searched', array(
'searched_topic' => $searchedResults
));
}
public function getSearchedListByCategory($vCategoryId, $locale, $request)
{
$search = new PostgresSearch();
$em = $this->getDoctrine()->getManager();
$search->setManager($em);
return $search->getCategorySearchResults($vCategoryId, $locale, $request);
}
public function getSearchedOTLEVideos($locale, $request)
{
$search = new PostgresSearch();
$em = $this->getDoctrine()->getManager();
$search->setManager($em);
return $search->getOTLESearchResults($locale, $request);
}
public function expositionSliderAction($translationId, Request $request, $passageId, $userSelected = true, $inFrame = false)
{
/* $translation = $this->expositionData('Translation')->findOneBy(array('id' => $translationId, 'isPublic' => true));
if($translation == null) {
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
$passage = ($passageId !== null)
? $this->expositionData('Passage')->findOneById($passageId)
: (($translation !== null) ? $translation->getWork()->findFirstNonEmptyPassage($translation) : null); */
$aTranslation = $this->getTranslationData($translationId);
$aPassage = $this->getPassageData($passageId);
$this->checkIfOnMobile($request);
// $locale = $request->getLocale();
$ref_column_spec = '';
// $work = $translation->getWork();
$bSwedenborgWork = ($aTranslation['swedenborgtype'] != null);
if($bSwedenborgWork)
$ref_column_spec = $this->MULTI_URL_INDICATOR_SWEDENBORG_WORK;
else
$ref_column_spec = $this->MULTI_URL_INDICATOR_EXPLANATION;
$ref_column_spec .= '_' . $aTranslation['url'];
if($bSwedenborgWork)
$ref_column_spec .= '_' . $aPassage['swedenborgsection'];
$nLanguageID = $aTranslation['language_id'];
$data = array(
// 'translation' => $translation,
// 'passage' => $passage,
'ref_column_spec' => $ref_column_spec,
'passage_order' => $aPassage['ordering'],
'passage_id' => $passageId,
);
// $data['passage_ref'] = $this->getWorkPassageRefs($passageId,$translationId, $request);
// if($bSwedenborgWork)
// $data['related_bible_ref'] = $this->getRelatedBibleRefForWork($passageId,$translationId, $request);
// $data['passage_footnote'] = $this->getPassageFootnotes($passageId,$translationId);
// $data['passage_multilink'] = $this->getWorkPassageMultiLink($passageId,$translationId, $request);
$data['work_references'] = $this->getWorkRefForWork($passageId, $translationId, $nLanguageID);
$data['explanation_references'] = $this->getExplanationRefForWork($passageId, $nLanguageID);
$data['gced_ref'] = $this->getGCEDRefForWork($passageId);
$data['otle_ref'] = $this->getOTLERefForWork($passageId);
$data['related_passages'] = $this->getRelatedPassages($passageId, $nLanguageID);
// get table of contents
$aTOC = $this->getWorkTranslationTOC($translationId);
if(!empty($aTOC))
{
$data['work_toc'] = $aTOC;
}
return $this->renderView('refsidrw', $data);
}
public function selecttopicAction(Request $request)
{
$locale = $request->getLocale();
$sSearchText = $request->query->get('st');
$data['consider_data'] = $this->getConsiderList($locale, $sSearchText);
return $this->renderView('selecttopic', $data);
}
public function otlevideosAction(Request $request)
{
$this->onloadPage($request);
$locale = $request->getLocale();
$aBrand = $this->getBrandList();
$aShowTopic = $this->getShowTopicList();
$aShowType = $this->getShowTypeList();
$data = array(
'brand_list' => $aBrand,
'topic_list' => $aShowTopic,
'type_list' => $aShowType
);
$this->setCurrentUrl($request);
return $this->renderView('otle_videos', $data);
}
public function searched_otle_videosAction(Request $request)
{
$locale = $request->getLocale();
$searchedResults = array();
$sSearchTerm = $request->query->get('searchTerm');
$nBrandID = $request->query->get('brandid');
if($sSearchTerm != '')
{
$searchedResults = $this->getSearchedOTLEVideos($locale, $request);
}
else
{
$nStartNum = $request->query->get('startnum');
$searchedResults = $this->getOTLEVideos($nStartNum, $request);
}
return $this->renderView('otle_videos_searched', array(
'searched_video' => $searchedResults['results'],
'total_record' => $searchedResults['total_record'],
'has_more' => $searchedResults['has_more'],
'start_num' => $searchedResults['start_num']
));
}
public function otlevideopageAction($showID, Request $request)
{
//$locale = $request->getLocale();
$aShow = $this->getShowInfo($showID);
$aShowRef = $this->getShowRefs($showID, $request);
$nTextLength = 150;
$sDesc = $aShow['description'];
$sMetaDesc = $this->fixWorkText($sDesc);
$sMetaDesc = $this->getTextWithinLength($sMetaDesc, $nTextLength, "...");
return $this->renderView('otle_video_page', array(
'show_id' => $showID,
'show_info' => $aShow,
'show_ref' => $aShowRef,
'meta_desc' => $sMetaDesc
));
}
public function audiohubAction(Request $request)
{
$this->onloadPage($request);
$locale = $request->getLocale();
$aLanguage = $this->getLanguageListForAudioHub();
$aCategory = $this->getCategoryListForAudioHub();
$data = array(
'language_list' => $aLanguage,
'category_list' => $aCategory
);
$this->setCurrentUrl($request);
return $this->renderView('audiohub', $data);
}
public function search_audioAction(Request $request)
{
$locale = $request->getLocale();
$searchedResults = array();
$sSearchTerm = $request->query->get('searchTerm');
$nStartNum = $request->query->get('startnum');
if($sSearchTerm != '')
{
$searchedResults = $this->getSearchedAudio($locale, $request);
}
else
{
$nFormatID = $this->PRIMARY_FORMAT_ID_AUDIO;
$searchedResults = $this->getExplanationList($nStartNum, $locale, $request, $nFormatID);
}
return $this->renderView('audio_searched', array(
'searched_audio' => $searchedResults,
'start_num' => $nStartNum
));
}
public function getSearchedAudio($locale, $request)
{
$search = new PostgresSearch();
$em = $this->getDoctrine()->getManager();
$search->setManager($em);
$sCategoryId = 'any';
return $search->getCategorySearchResults($sCategoryId, $locale, $request);
}
public function qahubAction(Request $request)
{
$locale = $request->getLocale();
$data = array(
);
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('qahub', $data);
}
public function search_qaAction(Request $request)
{
$locale = $request->getLocale();
$searchedResults = array();
$sSearchTerm = $request->query->get('searchTerm');
$nStartNum = $request->query->get('startnum');
if($sSearchTerm != '')
{
$searchedResults = $this->getSearchedQA($locale, $request);
}
else
{
$searchedResults = $this->getExplanationList($nStartNum, $locale, $request);
}
return $this->renderView('qa_searched', array(
'searched_qa' => $searchedResults,
'start_num' => $nStartNum
));
}
public function getSearchedQA($locale, $request)
{
$search = new PostgresSearch();
$em = $this->getDoctrine()->getManager();
$search->setManager($em);
$sCategoryId = 47;
return $search->getCategorySearchResults($sCategoryId, $locale, $request);
}
public function search_classAction(Request $request)
{
$locale = $request->getLocale();
$searchedResults = array();
$sSearchTerm = $request->query->get('searchTerm');
$nStartNum = $request->query->get('startnum');
if($sSearchTerm != '')
{
$searchedResults = $this->getSearchedClass($locale, $request);
}
else
{
$searchedResults = $this->getClassList($nStartNum, $request);
}
return $this->renderView('class_searched', array(
'searched_class' => $searchedResults['results'],
'total_record' => $searchedResults['total_record'],
'has_filter' => $searchedResults['has_filter'],
'has_more' => $searchedResults['has_more'],
'start_num' => $nStartNum
));
}
public function getSearchedClass($locale, $request)
{
$search = new PostgresSearch();
$em = $this->getDoctrine()->getManager();
$search->setManager($em);
return $search->getClassSearchResults($locale, $request);
}
public function coursepageAction($courseID, Request $request)
{
$aCourse = $this->getCourseInfo($courseID);
if(empty($aCourse))
{
$response = new Response();
$response->setStatusCode(404);
return $this->renderView('no_work_content', array(), $response);
}
$aLeader = $this->getLeadersForCourse($courseID);
$aAudience = $this->getAudienceForCourse($courseID);
$nTextLength = 150;
$sDesc = $aCourse['full_description'];
$sMetaDesc = $this->fixWorkText($sDesc);
$sMetaDesc = $this->getTextWithinLength($sMetaDesc, $nTextLength, "...");
return $this->renderView('course_page', array(
'course_info' => $aCourse,
'leader_list' => $aLeader,
'audience_list' => $aAudience,
'meta_desc' => $sMetaDesc
));
}
public function search_sermonAction(Request $request)
{
$locale = $request->getLocale();
$searchedResults = array();
$sSearchTerm = $request->query->get('searchTerm');
$nStartNum = $request->query->get('startnum');
$nStorehouse = $request->query->get('storehouse');
if($sSearchTerm != '')
{
$searchedResults = $this->getSearchedSermon($locale, $request);
}
else
{
$searchedResults = $this->getSermonList($nStartNum, $request);
}
return $this->renderView('sermon_searched', array(
'searched_sermon' => $searchedResults['results'],
'total_record' => $searchedResults['total_record'],
'has_more' => $searchedResults['has_more'],
'has_filter' => $searchedResults['has_filter'],
'start_num' => $nStartNum,
'is_storehouse' => $nStorehouse
));
}
public function getSearchedSermon($locale, $request)
{
$search = new PostgresSearch();
$em = $this->getDoctrine()->getManager();
$search->setManager($em);
return $search->getSermonSearchResults($locale, $request);
}
public function sermonpageAction($sermonID, Request $request)
{
if(!$this->userCanSeeAllSermons($request))
{
$nTypeID = $this->getSermonTypeID($sermonID);
if($nTypeID != $this->LNCSERMON_TYPE_ID_PUBLIC)
{
$bCanView = false;
if($this->userCanSeeLNCSermons($request) && $nTypeID == $this->LNCSERMON_TYPE_ID_LNC_MEMBER)
{
$bCanView = true;
}
if(!$bCanView)
{
return $this->redirect($this->get('router')->generate('sermons', array()), 301);
}
}
}
$aSermon = $this->getSermonInfo($sermonID);
$aAuthor = $this->getAuthorsForSermon($sermonID);
$aTopic = $this->getTopicsForSermon($sermonID);
$aSermonRef = $this->getSermonRefs($sermonID, $request);
$nTextLength = 150;
$sDesc = $aSermon['searchsummary'];
$sMetaDesc = $this->fixWorkText($sDesc);
$sMetaDesc = $this->getTextWithinLength($sMetaDesc, $nTextLength, "...");
return $this->renderView('sermon_page', array(
'sermon_id' => $sermonID,
'sermon_info' => $aSermon,
'author_list' => $aAuthor,
'topic_list' => $aTopic,
'sermon_ref' => $aSermonRef,
'meta_desc' => $sMetaDesc
));
}
public function sermonstorehousepageAction($sermonID, Request $request)
{
$nTypeID = $this->getSermonTypeID($sermonID);
if($nTypeID != $this->LNCSERMON_TYPE_ID_PUBLIC)
{
return $this->redirect($this->get('router')->generate('sermon_storehouse', array()), 301);
}
$aSermon = $this->getSermonInfo($sermonID);
$aAuthor = $this->getAuthorsForSermon($sermonID);
$aTopic = $this->getTopicsForSermon($sermonID);
$aSermonRef = $this->getSermonRefs($sermonID, $request);
$nTextLength = 150;
$sDesc = $aSermon['searchsummary'];
$sMetaDesc = $this->fixWorkText($sDesc);
$sMetaDesc = $this->getTextWithinLength($sMetaDesc, $nTextLength, "...");
return $this->renderView('sermon_storehouse_page', array(
'sermon_id' => $sermonID,
'sermon_info' => $aSermon,
'author_list' => $aAuthor,
'topic_list' => $aTopic,
'sermon_ref' => $aSermonRef,
'meta_desc' => $sMetaDesc
));
}
/**
* Show chapter list on a popup
*/
public function selectworkcompareAction($workID, $translationUrl, $translationUrl2, $divisionUrl, $passageNumber, Request $request)
{
$data['translation_url'] = $translationUrl;
$data['translation_url2'] = $translationUrl2;
$data['division_url'] = $divisionUrl;
$data['passage_number'] = $passageNumber;
$data['work_id'] = $workID;
$data['translations_by_language'] = $this->getWorkTranslationsByLanguage($workID);
return $this->renderView('selectworkcompare', $data);
}
/**
* Show translation list on a popup
*/
public function selectworktranslationAction($workID, $translationUrl, $passageNumber, $passageOrder, Request $request)
{
$data['translation_url'] = $translationUrl;
$data['passage_number'] = $passageNumber;
$data['passage_order'] = $passageOrder;
$data['work_id'] = $workID;
$data['translations_by_language'] = $this->getWorkTranslationsByLanguageAllType($workID);
return $this->renderView('selectworktranslation', $data);
}
/**
* Show translation list on a popup
*/
public function selectworkpassageAction($workID, $translationUrl, Request $request)
{
$data['translation_url'] = $translationUrl;
$data['passage_list'] = $this->getWorkPassages($workID);
$data['work_id'] = $workID;
return $this->renderView('selectpassage', $data);
}
/**
* Show work list on a popup
*/
public function selectworkAction($workID, $translationID, $languageID, Request $request)
{
$data['translation_id'] = $translationID;
$data['language_id'] = $languageID;
$data['work_id'] = $workID;
$data['swedenborg_works'] = $this->getCategorizedSwedenborgWorksForTranslation($request, $translationID, $languageID);
return $this->renderView('selectwork', $data);
}
/**
* Show translation list on a popup
*/
public function selectsearchtranslationAction($workID, $translationID, $passageID, Request $request)
{
$data['translation_id'] = $translationID;
$data['passage_id'] = $passageID;
$data['work_id'] = $workID;
$nLanguageID = $this->getLanguageIDByTranslation($translationID);
if($nLanguageID != $this->LANGUAGE_ID_LATIN)
$request->getSession()->set('last_quickview_language_id', $nLanguageID);
$sLanguages = "";
if($nLanguageID == $this->LANGUAGE_ID_LATIN)
$sLanguages = $nLanguageID . ", " . $request->getSession()->get('last_quickview_language_id');
else
$sLanguages = $nLanguageID . ", " . $this->LANGUAGE_ID_LATIN;
$data['translations_by_language'] = $this->getWorkTranslationsByLanguage($workID, $sLanguages);
return $this->renderView('selectsearchtranslation', $data);
}
/**
* Show translation list on a popup
*/
public function selectstorytranslationforworkAction($workID, $storyID, $translationID, Request $request)
{
$locale = $request->getLocale();
$data['work_id'] = $workID;
$data['translation_id'] = $translationID;
$data['story_id'] = $storyID;
$data['story_explanations'] = $this->getWorkListForStory($locale, $storyID);
return $this->renderView('selectstorytranslationforwork', $data);
}
public function search_conceptAction(Request $request)
{
$locale = $request->getLocale();
$searchedResults = array();
$sSearchTerm = $request->query->get('searchTerm');
$nStartNum = $request->query->get('startnum');
if($sSearchTerm != '')
{
//$searchedResults = $this->getSearchedConcept($locale, $request);
$searchedResults = $this->getSearchedListByCategory($this->CATEGORY_ID_CONCEPT, $locale, $request);
}
else
{
//$searchedResults = $this->getConceptList($nStartNum, $request);
$searchedResults = $this->getAllListByCategory($this->CATEGORY_ID_CONCEPT, $locale, $request);
}
return $this->renderView('concept_searched', array(
'searched_results' => $searchedResults
));
}
public function featured_conceptsAction(Request $request)
{
$this->onloadPage($request);
$locale = $request->getLocale();
$featuredList = $this->getFeaturedListByCategory($this->CATEGORY_ID_CONCEPT, $locale, 9, false);
if(empty($featuredList))
$featuredList = $this->getFeaturedListByCategory($this->CATEGORY_ID_CONCEPT, $locale, 9, true);
return $this->renderView('concepts_featured', array(
'featured_records' => $featuredList
));
}
/**
* Show translation list on a popup
*/
public function selectbiblebooksummaryAction($translationID, $BibleBookIDForSummary, Request $request)
{
$data['translation_id'] = $translationID;
$data['book_summaries'] = $this->getBibleBookSummaryList($BibleBookIDForSummary);
return $this->renderView('selectbiblebooksummary', $data);
}
/**
* Show translation list on a popup
*/
public function selectbiblechaptersummarytranslationAction($translationID, Request $request)
{
$data['translation_id'] = $translationID;
$data['chapter_summary_translations'] = $this->getChapterExplanationsForPopup($translationID);
return $this->renderView('selectbiblechaptersummarytranslation', $data);
}
public function selectbiblestudyAction(Request $request)
{
$locale = $request->getLocale();
//$sSearchText = $request->query->get('st');
$data['biblestudy_data'] = $this->getBibleStudyList($locale);
return $this->renderView('selectbiblestudy', $data);
}
/**
* Show translation list on a popup
*/
public function selectbibleversesummaryAction($workID, $chapterID, $languageID, Request $request)
{
$data['work_id'] = $workID;
$data['verse_explanations'] = $this->getVerseExplanations($chapterID, $languageID, $request);
return $this->renderView('selectbibleversesummary', $data);
}
/**
* Show work list on a popup for search
*/
public function selectworksforsearchAction(Request $request)
{
$nLanguageID = $request->query->get('lang');
$data['swedenborg_works'] = $this->getCategorizedSwedenborgWorksForTranslation($request, null, $nLanguageID);
return $this->renderView('selectworksforsearch', $data);
}
/**
* Show work translation list on a popup for search
*/
public function selectworktranslationsforsearchAction(Request $request)
{
$nLanguageID = $request->query->get('lang');
$sSelectedWorkIDs = $request->query->get('selectedworkids');
$sWorkType = $request->query->get('worktype');
$data['work_translations'] = $this->getSWWorkTranslations($sSelectedWorkIDs, $nLanguageID, $sWorkType);
return $this->renderView('selectworktranslationsforsearch', $data);
}
/**
* Show work translation list on a popup for reading plan step
*/
public function selectworktranslationforreadingplanAction(Request $request)
{
$nWorkID = $request->query->get('wid');
$sTranslationUrl = $request->query->get('turl');
$sReadingPlanUrl = $request->query->get('rpurl');
$nStepOrder = $request->query->get('step');
$nSW = $request->query->get('sw');
$data['work_id'] = $nWorkID;
$data['translation_url'] = $sTranslationUrl;
$data['readingplan_url'] = $sReadingPlanUrl;
$data['step_order'] = $nStepOrder;
$data['translations_by_language'] = $this->getWorkTranslationsByLanguageAllType($nWorkID);
return $this->renderView('selectworktranslationforreadingplan', $data);
}
/**
* Show work translation list on a popup for reading plan step
*/
public function selectexplanationtranslationforreadingplanAction(Request $request)
{
$nWorkID = $request->query->get('wid');
$sTranslationUrl = $request->query->get('turl');
$sReadingPlanUrl = $request->query->get('rpurl');
$nStepOrder = $request->query->get('step');
$data['work_id'] = $nWorkID;
$data['translation_url'] = $sTranslationUrl;
$data['readingplan_url'] = $sReadingPlanUrl;
$data['step_order'] = $nStepOrder;
$data['translations_by_language'] = $this->getWorkTranslationsByLanguageAllType($nWorkID);
return $this->renderView('selectexplanationtranslationforreadingplan', $data);
}
/**
* Show work list on a popup
*/
public function selectbiblechaptersummaryworkAction($translationID, Request $request)
{
$aTrans = $this->getWorkTranslationData($translationID);
$nWorkID = $aTrans['work_id'];
$data['translation_id'] = $translationID;
$data['work_id'] = $nWorkID;
$data['chapter_summary_works'] = $this->getChapterExplanationWorksForPopup($translationID);
return $this->renderView('selectbiblechaptersummarywork', $data);
}
public function fullviewTranslationPassageAction($passageId, $translationId, Request $request)
{
$sSql = "select url FROM expositiontranslation where id = " . $translationId;
// echo $sSql."<br>";
$sUrl = $this->getSingleData($sSql);
$sLink = $this->get('router')->generate('exposition_translation_passage', array(
'translationUrl' => $sUrl,
'passageId' => $passageId
));
if(!empty($sLink))
return $this->redirect($sLink, 301);
else
return $this->redirect("/", 301);
}
public function projecthubAction(Request $request)
{
$locale = $request->getLocale();
$data = array(
);
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('projecthub', $data);
}
public function search_projectAction(Request $request)
{
$locale = $request->getLocale();
$searchedResults = array();
$sSearchTerm = $request->query->get('searchTerm');
$nStartNum = $request->query->get('startnum');
if($sSearchTerm != '')
{
$searchedResults = $this->getSearchedProject($locale, $request);
}
else
{
$searchedResults = $this->getExplanationList($nStartNum, $locale, $request);
}
return $this->renderView('project_searched', array(
'searched_project' => $searchedResults,
'start_num' => $nStartNum
));
}
public function getSearchedProject($locale, $request)
{
$search = new PostgresSearch();
$em = $this->getDoctrine()->getManager();
$search->setManager($em);
$sCategoryId = 52;
return $search->getCategorySearchResults($sCategoryId, $locale, $request);
}
public function featured_projectsAction(Request $request)
{
$this->onloadPage($request);
$locale = $request->getLocale();
$featuredList = $this->getFeaturedListByCategory($this->CATEGORY_ID_PROJECT, $locale, 9, false);
if(empty($featuredList))
$featuredList = $this->getFeaturedListByCategory($this->CATEGORY_ID_PROJECT, $locale, 9, true);
return $this->renderView('projects_featured', array(
'featured_records' => $featuredList
));
}
}