src/NCBS/WebsiteBundle/Controller/ExpositionController.php line 504

Open in your IDE?
  1. <?php
  2. namespace NCBS\WebsiteBundle\Controller;
  3. use Doctrine\ORM\EntityManager;
  4. use Doctrine\ORM\Query\ResultSetMapping;
  5. use NCBS\WebsiteBundle\Controller\SearchController;
  6. use NCBS\WebsiteBundle\Entity\Exposition;
  7. use NCBS\WebsiteBundle\Tools\DataAssembly;
  8. use NCBS\WebsiteBundle\Tools\PostgresSearch;
  9. use Symfony\Component\HttpFoundation\Response;
  10. use Symfony\Component\HttpFoundation\Request;
  11. class ExpositionController extends NCBSWController
  12. {
  13.   
  14.     protected $prefix 'Exposition';
  15.     // Overriding this to automatically pass list of Swedenborg works to every template
  16.     // (easier to program than trying to figure out which ones need it and which don't)
  17.     public function renderView($view, array $parameters = array(), Response $response null)
  18.     {    
  19.         return parent::renderView($view$parameters$response);
  20.     }
  21.     // Given a Work or Translation, checks whether it would be better to view as some other entity type
  22.     // (currently can redirect only to concepts)
  23.     // Returns null if no redirect is necessary or a null argument is provided, or false if an unknown argument type is supplied
  24.     // Otherwise, returns url to redirect to
  25.     protected function checkRedirect($target)
  26.     {
  27.    /*     if($target === null) {
  28.             return null;
  29.         } elseif($target instanceof Exposition\Translation) {
  30.             $targetTranslation = $target;
  31.         } elseif($target instanceof Exposition\Work) {
  32.             $targetTranslation = $target->selectTranslation();
  33.         } else {
  34.             return null;
  35.         }
  36.         
  37.         if($targetTranslation == null)
  38.             return null;
  39.             
  40.         $sConceptUrl = $this->checkConcept($targetTranslation->getId());    
  41.         if(!empty($sConceptUrl))
  42.         {
  43.             $url = $this->get('router')->generate('concept', array(
  44.                     'conceptUrl' => $sConceptUrl
  45.                 ));
  46.                 
  47.             $args = @$_SERVER['QUERY_STRING'];
  48.             if(!empty($args)) 
  49.             {                
  50.                 $url .= '?'.$args;                   
  51.             } 
  52.             
  53.             return $url;
  54.         }    */
  55.                     
  56.         return null;
  57.     }
  58.     protected function selectSelectorList($work$languageName 'English'$currentTranslation null)
  59.     {
  60.         if($work === null) {
  61.             return null;
  62.         }
  63.         if($work->getSwedenborgType() !== null) {
  64.             return $this->buildSwedenborgSelectorList($languageName$currentTranslation);
  65.         }
  66.         $list = array();
  67.         foreach($work->getCategories() as $category) {
  68.             if($category->getIndexPage() !== null) {
  69.                 $catName $category->getName();
  70.                 $list[$catName] = array();
  71.                 foreach($category->getWorks() as $w) {
  72.                     $t $w->selectTranslation($languageName);
  73.                     if($t != null)
  74.                         $list[$catName][$t->getTranslatedTitle()] = ($work == $w) ? null $t;
  75.                 }
  76.                 ksort($list[$catName]);
  77.             }
  78.         }
  79.         if(empty($list)) {
  80.             return null;
  81.         } else {
  82.             return $list;
  83.         }
  84.     }
  85.     protected function buildSwedenborgSelectorList($languageName 'English'$currentTranslation null)
  86.     {
  87.         $allWorks $this->expositionData('Work')->findByIsPublic(true);
  88.         $swedenborgBooks = array(
  89. //            'Published Theological Works' => array(),
  90. //            'Posthumous Theological Works' => array(),
  91. //            'Pre-Revelatory Works' => array()
  92.         );
  93.         foreach($allWorks as $work) {
  94.             if($work->getSwedenborgType() !== null) {
  95.                 if($currentTranslation !== null && $currentTranslation->getWork() == $work) {
  96.                     $translation $currentTranslation;
  97.                 } else {
  98.                     $translation $work->selectTranslation($languageName);
  99.                 }
  100.                 if($translation !== null) {
  101.                     $title $translation->getTranslatedTitle();
  102.                     $swedenborgBooks[$title] = $translation;
  103. /*
  104.                     if($work->getSwedenborgType() == 'published revelatory') {
  105.                         $swedenborgBooks['Published Theological Works'][$title] = $translation;
  106.                     } elseif($work->getSwedenborgType() == 'posthumous revelatory') {
  107.                         $swedenborgBooks['Posthumous Theological Works'][$title] = $translation;
  108.                     } else { // 'published pre-revelatory' or 'posthumous pre-revelatory'
  109.                         $swedenborgBooks['Pre-Revelatory Works'][$title] = $translation;
  110.                     }
  111. */
  112.                 }
  113.             }
  114.         }
  115.         ksort($swedenborgBooks);
  116. //        ksort($swedenborgBooks['Published Theological Works']);
  117. //        ksort($swedenborgBooks['Posthumous Theological Works']);
  118. //        ksort($swedenborgBooks['Pre-Revelatory Works']);
  119.         return array("Swedenborg's Theological Works" => $swedenborgBooks);
  120.     }
  121.     public function swedenborgIndexAction(Request $request)
  122.     {
  123.     /*    
  124.         $locale = $request->getLocale();
  125.         $nLanguageID = $this->getLanguageIDByShortCode($locale);
  126.         return $this->renderView('index/swedenborg', array(          
  127.             'selector_data' => $this->getCategorizedSwedenborgWorks($request, $nLanguageID),
  128.             'illustration' => $this->getRepository('Media\Image')->findOneByFile('quill-pen.jpg'),
  129.             'index_path' => 'swedenborg'
  130.         )); */
  131.         
  132.         $this->setCurrentUrl($request); 
  133.         $this->onloadPage($request);
  134.         $locale $request->getLocale();
  135.         $nLocaleLanguageID $this->getLanguageIDByShortCode($locale);
  136.         
  137.         $nSelectedLangID $request->query->get('l');
  138.         
  139.         return $this->renderView('index/swedenborg', array(          
  140.             'works' => $this->getSwedenborgWorks($request$nLocaleLanguageID$nSelectedLangID),
  141.             'works2' => $this->getSwedenborgWorks2($request$nLocaleLanguageID$nSelectedLangID),
  142.             'languages' => $this->getSwedenborgWorkLanguages($request),
  143.             'selected_language_id' => $nSelectedLangID,
  144.             'search_domain' => 'w'
  145.         ));
  146.     }
  147.     public function conceptsIndexAction(Request $request)
  148.     {        
  149.         $this->setCurrentUrl($request); 
  150.         $this->onloadPage($request);
  151.         return $this->renderView('index/concepts', array('index_path' => 'concepts''selector_data' => array('Bible Words Explained' => $conceptSelection)));
  152.     }
  153.         
  154.     public function considerIndexAction(Request $request)
  155.     {                       
  156.         $this->setCurrentUrl($request); 
  157.         $this->onloadPage($request);
  158.         $locale $request->getLocale();
  159.         $aPathway $this->getTopPathList($locale);
  160.         return $this->renderView('index/spiritual_topics', array(     
  161.             'pathway_list' => $aPathway            
  162.         ));
  163.     }
  164.     public function educationalMaterialsIndexAction(Request $request)
  165.     {
  166.         $this->setCurrentUrl($request); 
  167.         $this->onloadPage($request);
  168.         $categoryUrls = array('vineyard-collection-concept-articles');
  169.         $selectorData = array();
  170.         foreach($categoryUrls as $url) {
  171.             $category $this->expositionData('Category')->findOneByUrl($url);
  172.             $selectorData[$category->getName()] = $this->singleCategorySelectorData($category);
  173.         }
  174.         return $this->renderView('index/educational_materials', array(
  175.             'index_path' => 'educational_materials',
  176.             'selector_data' => $selectorData,
  177.             'illustration' => $this->getRepository('Media\Image')->findOneByFile('nc-vineyard.jpg')
  178.         ));
  179.     }
  180.     function singleCategorySelectorData($category)
  181.     {
  182.         if($category === null) {
  183.             return array();
  184.         }
  185.         $categoryData = array();
  186.         foreach($category->getWorks() as $work) {
  187.             $translation $work->selectTranslation();
  188.             $categoryData[$translation->getTranslatedTitle()] = $translation;
  189.         }
  190.         foreach($category->getTranslations() as $translation) {
  191.             $categoryData[$translation->getTranslatedTitle()] = $translation;
  192.         }
  193.         ksort($categoryData);
  194.         return $categoryData;
  195.     }
  196.     public function categoryAction($categoryUrlRequest $request)
  197.     {
  198.         $category $this->expositionData('Category')->findOneByUrl($categoryUrl);
  199.         $response null;
  200.         if($category === null) {
  201.             $response = new Response();
  202.             $response->setStatusCode(404);
  203.             return $this->renderView('no_work_content', array(), $response);
  204.         }
  205.         $this->setCurrentUrl($request); 
  206.         $this->onloadPage($request);
  207.         return $this->renderView('category', array('category' => $category), $response);
  208.     }
  209.     // Note: If $passageSeparator is null (e.g. due to being unspecified) then the template file will use <p></p> tags to separate passages
  210.     public function excerptAction($excerptIdRequest $request$translationUrl null$textUnitSeparator "\n"$passageSeparator null$userSelected false)
  211.     {
  212.         $excerpt $this->expositionData('Excerpt')->findOneById($excerptId);
  213.         if($excerpt === null) {
  214.             $response = new Response();
  215.             $response->setStatusCode(404);
  216.             return $this->renderView('no_work_content', array(), $response);
  217.         }
  218.         
  219.         if($translationUrl === null) {
  220.             $translation $excerpt->getStartArea()->getTranslation();
  221.         } else {
  222.             $translation $this->expositionData('Translation')->findOneBy(array('url' => $translationUrl'isPublic' => true));
  223.         }
  224.         if($userSelected) {
  225.             $request->getSession()->set('current_language'$translation->getLanguage()->getBibliographicCode());
  226.         }
  227.         $translationId $translation->getId();
  228.         $excerptPassages = array();
  229.         $startTextArea $excerpt->getStartArea();
  230.         $endTextArea $excerpt->getEndArea();
  231.         if($startTextArea->getId() === $endTextArea->getId()) {
  232.             // Entire excerpt is in a single text unit
  233.             if($excerpt->getStartChar() > $excerpt->getEndChar()) {
  234.                 // Error! Invalid Excerpt: Start character comes after end character
  235.             }
  236.             $excerptPassages[] = substr($startTextArea->getText(), $excerpt->getStartChar(), 1+$excerpt->getEndChar()-$excerpt->getStartChar());
  237.         } else {
  238.             $startTextUnit $startTextArea->getPlacement();
  239.             $startPassage $startTextUnit->getPassage();
  240.             $endTextUnit $endTextArea->getPlacement();
  241.             $endPassage $endTextUnit->getPassage();
  242.             if($startPassage->getId() == $endPassage->getId()) {
  243.                 // Entire excerpt is in a single passage
  244.                 $startTextOrdering $startTextUnit->getOrdering();
  245.                 $endTextOrdering $endTextArea->getOrdering();
  246.                 if($startTextOrdering $endTextOrdering) {
  247.                     // Error! Invalid Excerpt: Start text unit comes after end text unit
  248.                 }
  249.                 $text substr($startTextArea->getText(), $excerpt->getStartChar());
  250.                 foreach($startPassage->getTextUnits() as $textUnit) {
  251.                     if($textUnit->getOrdering() > $startTextOrdering && $textUnit->getOrdering() < $endTextOrdering) {
  252.                         $text .= $textUnitSeparator.$textUnit->findTranslatedVersion($translationId)->getText();
  253.                     }
  254.                 }
  255.                 $text .= $textUnitSeparator.substr($endTextArea->getText(), 0$excerpt->getEndChar() + 1);
  256.                 $excerptPassages[] = $text;
  257.             } else {
  258.                 $startText substr($startTextArea->getText(), $excerpt->getStartChar());
  259.                 foreach($startPassage->getTextUnits() as $textUnit) {
  260.                     if($textUnit->getOrdering() > $startTextUnit->getOrdering()) {
  261.                         $startText .= $textUnitSeparator.$textUnit->findTranslatedVersion($translationId)->getText();
  262.                     }
  263.                 }
  264.                 $excerptPassages[] = $startText;
  265.                 // Add text for intermediate passages
  266.                 for($currentPassage $startPassage->findNextPassage(); $currentPassage != null && $currentPassage->getId() != $endPassage->getId(); $currentPassage $currentPassage->findNextPassage()) {
  267.                     $excerptPassages[] = $currentPassage->textInTranslation($translationId);
  268.                 }
  269.                 if($currentPassage == null) {
  270.                     // Error! Invalid Excerpt: End passage can't be reached by moving forward from start passage
  271.                 }
  272.                 // Build text for end of passage
  273.                 $endText "";
  274.                 foreach($endPassage->getTextUnits() as $textUnit) {
  275.                     if($textUnit->getOrdering() < $endTextUnit->getOrdering()) {
  276.                         $endText .= $textUnit->findTranslatedVersion($translationId)->getText().$textUnitSeparator;
  277.                     }
  278.                 }
  279.                 $endText .= substr($endTextArea->getText(), 0$excerpt->getEndChar() + 1);
  280.                 $excerptPassages[] = $endText;
  281.             }
  282.         }
  283.         $excerptData = array(
  284.             'excerpt' => $excerpt,
  285.             'excerpt_passages' => $excerptPassages,
  286.             'passage_separator' => $passageSeparator,
  287.             'nav_mode' => 'translation'
  288.         );
  289.         if($translation->getWork()->getSwedenborgType() !== null) {
  290.             $excerptData['selector_data'] = $this->buildSwedenborgSelectorList($translation->getLanguage()->getName(), $translation);
  291.         }
  292.         $this->setCurrentUrl($request); 
  293.         $this->onloadPage($request);
  294.         return $this->renderView('excerpt'$excerptData);
  295.     } // end function excerptAction
  296.     public function workIndexAction($workUrlRequest $request)
  297.     {
  298.         $this->onloadPage($request);
  299.         $work $this->expositionData('Work')->findOneBy(array('url' => $workUrl'isPublic' => true));
  300.         
  301.         $translation = ($work === null) ? null $work->selectTranslation();
  302.         if($translation === null) {
  303.             $response = new Response();
  304.             $response->setStatusCode(404);
  305.             return $this->renderView('no_work_content', array(), $response);
  306.         }
  307.         else 
  308.         {      
  309.             $this->setCurrentUrl($request);            
  310.             $translationUrl $translation->getUrl(); 
  311.             return $this->redirect($this->get('router')->generate('exposition_translation_index', array(
  312.                     'translationUrl' => $translationUrl
  313.                 )), 301);            
  314.         }
  315.     }
  316.    
  317.     public function workPassageAction($workUrlRequest $request$passageId null)
  318.     {
  319.         $this->onloadPage($request);
  320.         $work $this->expositionData('Work')->findOneBy(array('url' => $workUrl'isPublic' => true));
  321.         if($work === null) {
  322.             $response = new Response();
  323.             $response->setStatusCode(404);
  324.             return $this->renderView('no_work_content', array(), $response);
  325.         }
  326.         
  327.         $redir $this->checkRedirect($work);
  328.         if($redir !== null) {
  329.             return $this->redirect($redir301);
  330.         }
  331.                      
  332.          $locale $request->getLocale();
  333.          $aTranslation $this->getTranslationInfo($workUrl,$locale,$passageId);         
  334.         if(empty($aTranslation)) {
  335.             $response = new Response();
  336.             $response->setStatusCode(404);
  337.             return $this->renderView('no_work_content', array(), $response);
  338.         }
  339.         else 
  340.         {       
  341.             $this->setCurrentUrl($request);             
  342.             $translationUrl $aTranslation['translation_url'];
  343.             $divisionUrl $aTranslation['division_url'];
  344.             $passageNum $aTranslation['passage_order'];
  345.             return $this->redirect($this->get('router')->generate('exposition_translation_division_passage', array(
  346.                     'translationUrl' => $translationUrl,
  347.                     'divisionUrls' => $divisionUrl,
  348.                     'passageNumber' => $passageNum
  349.                 )), 301);        
  350.         }    
  351.     }
  352.     public function workDivisionPassageAction($workUrl$divisionUrlsRequest $request$passageNumber null)
  353.     {
  354.         $this->onloadPage($request);
  355.         $work $this->expositionData('Work')->findOneBy(array('url' => $workUrl'isPublic' => true));
  356.         $redir $this->checkRedirect($work);
  357.         if($redir !== null) {
  358.             return $this->redirect($redir301);
  359.         }
  360.         // 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
  361.  /*       if($work !== null && $work->getUrl() === 'arcana-coelestia' && $divisionUrls === 'contents' && $passageNumber !== null && substr($passageNumber, -1) === '0') {
  362.             $passage = $this->expositionData('Passage')->findSwedenborgSection($work, substr($passageNumber, 0, -1));
  363.             return $this->passageCanonicalRedirect($passage);
  364.         } */
  365.         $passage $this->findPassageByWorkAndDivisions($work$divisionUrls$passageNumber);        
  366.         $translation = ($work === null) ? null $work->selectTranslation();
  367.         if($translation === null) {
  368.             $response = new Response();
  369.             $response->setStatusCode(404);
  370.             return $this->renderView('no_work_content', array(), $response);
  371.         }
  372.         else 
  373.         {      
  374.             $this->setCurrentUrl($request);            
  375.             $translationUrl $translation->getUrl(); 
  376.             if($passageNumber != null)
  377.             {
  378.                 return $this->redirect($this->get('router')->generate('exposition_translation_division_passage', array(
  379.                     'translationUrl' => $translationUrl,
  380.                     'divisionUrls' => $divisionUrls,
  381.                     'passageNumber' => $passageNumber
  382.                 )), 301);
  383.                 //return $this->redirect('/exposition/translation/'.$translationUrl.'/'.$divisionUrls.'/'.$passageNumber);
  384.             }
  385.             else
  386.             {
  387.                 return $this->redirect($this->get('router')->generate('exposition_translation_division', array(
  388.                     'translationUrl' => $translationUrl,
  389.                     'divisionUrls' => $divisionUrls
  390.                 )), 301);
  391.                 //return $this->redirect('/exposition/translation/'.$translationUrl.'/'.$divisionUrls);
  392.             }    
  393.         }                
  394.     }
  395.     protected function workPassageView($passage$work null$request)
  396.     {
  397.         $this->onloadPage($request);
  398.         if($work === null && $passage !== null) {
  399.             $work $passage->findWork();
  400.         }
  401.         // 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
  402.         $translation = ($work === null) ? null $work->selectTranslation();
  403.         
  404.         $sUrlCompareTo $request->query->get('compareTo');
  405.         $aCompare explode(";;"$sUrlCompareTo);
  406.         $nCompareLen count($aCompare);
  407.         $compareTo null;
  408.         $compareTo2 null;        
  409.         if($nCompareLen && $aCompare[0] != '')
  410.             $compareTo $this->expositionData('Translation')->findOneByUrl($aCompare[0]);        
  411.         
  412.         if($nCompareLen == && $aCompare[1] != '')            
  413.             $compareTo2 $this->expositionData('Translation')->findOneByUrl($aCompare[1]);
  414.                
  415.         $data = array(
  416.             'work' => $work,
  417.             'passage' => $passage,
  418.             'translation' => $translation,
  419.             'compare_to' => $compareTo,
  420.             'compare_to2' => $compareTo2,
  421.             'nav_mode' => 'work',
  422.             'text_style_override' => $this->getTextStyleOverride($translation->getLanguage()->getId())
  423.         );
  424.    /*     $selectorData = $this->selectSelectorList($work);
  425.         if($selectorData !== null) {
  426.             $data['selector_data'] = $selectorData;
  427.         } */
  428.         $this->setCurrentUrl($request);         
  429.         return $this->createPassageView($data'work'$work$request);
  430.     }
  431.     public function workDivisionAction($workUrl$divisionUrls)
  432.     {
  433.         $this->onloadPage($request);
  434.         $work $this->expositionData('Work')->findOneBy(array('url' => $workUrl'isPublic' => true));
  435.         $translation = ($work === null) ? null $work->selectTranslation();
  436.         if($translation === null) {
  437.             $response = new Response();
  438.             $response->setStatusCode(404);
  439.             return $this->renderView('no_work_content', array(), $response);
  440.         }
  441.         else 
  442.         {      
  443.             $this->setCurrentUrl($request);             
  444.             $translationUrl $translation->getUrl(); 
  445.             return $this->redirect($this->get('router')->generate('exposition_translation_division', array(
  446.                     'translationUrl' => $translationUrl,
  447.                     'divisionUrls' => $divisionUrls
  448.                 )), 301);
  449.             //return $this->redirect('/exposition/translation/'.$translationUrl.'/'.$divisionUrls);
  450.         
  451.     }
  452.     public function collectionIndexAction($collectionUrlRequest $request)
  453.     {
  454.         $this->onloadPage($request);
  455.         $collection $this->expositionData('Collection')->findOneByUrl($collectionUrl);
  456.         $response null;
  457.         if($collection === null) {
  458.             $response = new Response();
  459.             $response->setStatusCode(404);
  460.             return $this->renderView('no_work_content', array(), $response);
  461.         }
  462.         $this->setCurrentUrl($request);         
  463.         return $this->renderView('collection_index', array('collection' => $collection), $response);
  464.     }
  465.     public function translationIndexAction($translationUrlRequest $request$userSelected true)
  466.     {
  467.         $this->onloadPage($request);
  468.         $translation $this->expositionData('Translation')->findOneBy(array('url' => $translationUrl'isPublic' => true));
  469.         $response null;
  470.         if($translation === null) {
  471.             $response = new Response();
  472.             $response->setStatusCode(404);
  473.             return $this->renderView('no_work_content', array(), $response);
  474.         }
  475.             
  476.         if($userSelected && $translation !== null) {
  477.             $request->getSession()->set('current_language'$translation->getLanguage()->getBibliographicCode());
  478.         }
  479.         $data = array('translation' => $translation'nav_mode' => 'translation');
  480.         
  481.         $type_id $translation->getTypeId();
  482.         
  483.         if($type_id == $this->TRANSLATION_TYPE_ID_FILE
  484.         {
  485.             $file $translation->getFile();
  486.             if($file !== null) {
  487.                 $data['file'] = $file;
  488.             }
  489.         }
  490.         if($type_id == $this->TRANSLATION_TYPE_ID_LINK// link
  491.         {
  492.             $doc_link $translation->getDocLink();
  493.             if($doc_link !== null) {
  494.                 $data['doc_link'] = $doc_link;
  495.             }
  496.         }
  497.         
  498.         $data['type_id'] = $type_id;
  499.         
  500.         $nTransID $translation->getId();
  501.         $data['biblio'] = $this->getBiblio($nTransID$translation->getIsOriginal());
  502.         $data['work_biblio_orig'] = null;
  503.         if(!$translation->getIsOriginal())
  504.             $data['work_biblio_orig'] = $this->getBiblioOriginal($nTransID);
  505.             
  506.         $data['translation_index'] = '1';    
  507.         
  508.         $this->setCurrentUrl($request);         
  509.         return $this->renderView('translation_index'$data$response);
  510.     }
  511.     
  512.     public function translationPassageAction($translationUrlRequest $request$passageId null$userSelected true$inFrame false)
  513.     {
  514.         $this->onloadPage($request);
  515.         $translation $this->expositionData('Translation')->findOneBy(array('url' => $translationUrl'isPublic' => true));
  516.          if($translation == null) {
  517.             $response = new Response();
  518.             $response->setStatusCode(404);
  519.             return $this->renderView('no_work_content', array(), $response);
  520.         }
  521.         
  522.         if($userSelected && $translation !== null) {
  523.             $request->getSession()->set('current_language'$translation->getLanguage()->getBibliographicCode());
  524.         }
  525.         $redir $this->checkRedirect($translation);
  526.         if($redir !== null) {
  527.             return $this->redirect($redir301);
  528.         }
  529.         $passage = ($passageId !== null)
  530.             ? $this->expositionData('Passage')->findOneById($passageId)
  531.             : (($translation !== null) ? $translation->getWork()->findFirstNonEmptyPassage($translation) : null);
  532.  /*       if($passage !== null && $passage->findWork() === $translation->getWork()) {
  533.             return $this->passageCanonicalRedirect($passage, $translation);
  534.         } */
  535.         
  536.         if(!$inFrame)
  537.             $this->setCurrentUrl($request); 
  538.                         
  539.         return $this->translationPassageView($passage$translation$request$inFrame);
  540.     }
  541.     public function translationDivisionPassageAction($translationUrl$divisionUrlsRequest $request$passageNumber null$userSelected true$inFrame false)
  542.     {
  543.         $this->onloadPage($request);
  544.         $response null;
  545.         if(strlen($passageNumber) > 8) {
  546.             $response = new Response();
  547.             $response->setStatusCode(404);
  548.             return $this->renderView('no_work_content', array(), $response);
  549.         }
  550.         
  551.         if(!$this->IsSwedenborgWork($translationUrl))
  552.         {
  553.             return $this->redirect($this->get('router')->generate('exposition_translation', array(
  554.                     'translationUrl' => $translationUrl
  555.                 )), 301);
  556.         }
  557.     
  558.         $translation $this->expositionData('Translation')->findOneBy(array('url' => $translationUrl'isPublic' => true));
  559.         if($translation == null) {
  560.             $response = new Response();
  561.             $response->setStatusCode(404);
  562.             return $this->renderView('no_work_content', array(), $response);
  563.         }
  564.         
  565.         if($userSelected && $translation !== null) {
  566.             $request->getSession()->set('current_language'$translation->getLanguage()->getBibliographicCode());
  567.         }
  568.         $redir $this->checkRedirect($translation);
  569.         if($redir !== null) {
  570.             return $this->redirect($redir301);
  571.         }
  572.         $work = ($translation === null) ? null $translation->getWork();
  573.         
  574.         if(!$work->getIsPublic()) {
  575.             $response = new Response();
  576.             $response->setStatusCode(404);
  577.             return $this->renderView('no_work_content', array(), $response);
  578.         }
  579.         // 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
  580.         if($work !== null && $work->getUrl() === 'arcana-coelestia' && $divisionUrls === 'contents' && $passageNumber !== null && substr($passageNumber, -1) === '0') {
  581.             $passage $this->expositionData('Passage')->findSwedenborgSection($worksubstr($passageNumber0, -1));
  582.             return $this->passageCanonicalRedirect($passage$translation);
  583.         }
  584.         $passage $this->findPassageByWorkAndDivisions($work$divisionUrls$passageNumber);
  585.         
  586.         if(!$inFrame)
  587.             $this->setCurrentUrl($request); 
  588.             
  589.         return $this->translationPassageView($passage$translation$request$inFrame);
  590.     }
  591.     protected function translationPassageView($passage$translation$request$inFrame false)
  592.     {    
  593.         $this->checkIfOnMobile($request);        
  594.         $locale $request->getLocale();
  595.         $nTranslationID $translation->getId();
  596.         $sUrlCompareTo $request->query->get('compareTo');
  597.         $aCompare explode(";;"$sUrlCompareTo);
  598.         $nCompareLen count($aCompare);
  599.         $compareTo null;
  600.         $compareTo2 null;    
  601.         $text_to_speech2 null;
  602.         $text_to_speech3 null;
  603.         $text_style_override_compare_to null;   
  604.         $text_style_override_compare_to2 null
  605.         $translation_shortname2 null;
  606.         $translation_shortname3 null;
  607.         if($nCompareLen && $aCompare[0] != '')
  608.         {
  609.             $compareTo $this->expositionData('Translation')->findOneBy(array('url' => $aCompare[0], 'isPublic' => true));   
  610.             if($compareTo != null)    
  611.             {
  612.                 $nLanguageID2 $compareTo->getLanguage()->getId();
  613.                 $text_style_override_compare_to $this->getTextStyleOverride($nLanguageID2);
  614.                 $text_to_speech2 $this->getTextToSpeech($nLanguageID2);
  615.                 
  616.                 $translation_shortname2 $this->getWorkTranslationShortName($compareTo->getId());                
  617.             }    
  618.         }         
  619.         
  620.         if($nCompareLen == && $aCompare[1] != ''
  621.         {           
  622.             $compareTo2 $this->expositionData('Translation')->findOneBy(array('url' => $aCompare[1], 'isPublic' => true)); 
  623.             if($compareTo2 != null)    
  624.             {
  625.                 $nLanguageID3 $compareTo2->getLanguage()->getId();
  626.                 $text_style_override_compare_to2 $this->getTextStyleOverride($nLanguageID3);
  627.                 $text_to_speech3 $this->getTextToSpeech($nLanguageID3);
  628.                 $translation_shortname3 $this->getWorkTranslationShortName($compareTo2->getId());
  629.             }    
  630.         }    
  631.         
  632.         $bSwedenborg $this->isSwedenborg($nTranslationID);
  633.         $chapterExplanations null;
  634.         $chapterExplanationsForCombo null;
  635.         $prev_chapter_explanation = array();
  636.         $next_chapter_explanation = array();
  637.         $explained_cbook_id null;
  638.         if(!$bSwedenborg)
  639.         {    
  640.             $chapterExplanations $this->getChapterExplanationsForNav($translation);       
  641.             $chapterExplanationsForCombo $this->getChapterExplanationsForTextForCombo($translation); 
  642.             
  643.             if(!empty($chapterExplanations))
  644.             {
  645.                 $bHasPass false;
  646.                 foreach($chapterExplanations as $ce)
  647.                 {
  648.                     if($ce['translation_id'] == $nTranslationID)
  649.                         $bHasPass true;
  650.                     else
  651.                     {    
  652.                         if(!$bHasPass)
  653.                         {
  654.                             $prev_chapter_explanation['url'] = $ce['translation_url'];
  655.                             $prev_chapter_explanation['title'] = $ce['explanationtitle'];
  656.                         }    
  657.                         else
  658.                         {
  659.                             $next_chapter_explanation['url'] = $ce['translation_url'];
  660.                             $next_chapter_explanation['title'] = $ce['explanationtitle'];
  661.                             break;
  662.                         }        
  663.                     }                            
  664.                 }
  665.                 
  666.                 $explained_cbook_id $chapterExplanations[0]['book_id'];
  667.             }
  668.         }
  669.         $ref_column_spec '';
  670.         if($bSwedenborg)
  671.             $ref_column_spec $this->MULTI_URL_INDICATOR_SWEDENBORG_WORK;    
  672.         else
  673.             $ref_column_spec $this->MULTI_URL_INDICATOR_EXPLANATION;    
  674.         
  675.         $ref_column_spec .= '_' $translation->getUrl();
  676.         if($passage != null && $bSwedenborg)
  677.             $ref_column_spec .= '_' $passage->getSwedenborgSection();
  678.             
  679.         $nPassageID null;    
  680.         if($passage != null)
  681.             $nPassageID $passage->getId();
  682.             
  683.         $nLanguageID $translation->getLanguage()->getId();      
  684.         $data = array(
  685.             'translation' => $translation,
  686.             'passage' => $passage,
  687.             'compare_to' => $compareTo,
  688.             'compare_to2' => $compareTo2,
  689.             'nav_mode' => 'translation',            
  690.           //  'chapter_explanations' => $chapterExplanations,
  691.             'chapter_explanations_for_combo' => $chapterExplanationsForCombo,
  692.             'prev_chapter_explanation' => $prev_chapter_explanation,
  693.             'next_chapter_explanation' => $next_chapter_explanation,
  694.             'explained_cbook_id' => $explained_cbook_id,
  695.             'ref_column_spec' => $ref_column_spec,
  696.             'text_style_override' => $this->getTextStyleOverride($nLanguageID),
  697.             'text_style_override_compare_to' => $text_style_override_compare_to,
  698.             'text_style_override_compare_to2' => $text_style_override_compare_to2,
  699.             'text_to_speech1' => $this->getTextToSpeech($nLanguageID),
  700.             'text_to_speech2' => $text_to_speech2,
  701.             'text_to_speech3' => $text_to_speech3,            
  702.             'translation_shortname2' => $translation_shortname2,
  703.             'translation_shortname3' => $translation_shortname3            
  704.         );
  705.         
  706.         $data['is_ipad'] = $this->isIPad();
  707.         
  708.         if($translation !== null) {
  709.        /*     $selectorData = $this->selectSelectorList($translation->getWork(), $translation->getLanguage()->getName(), $translation);
  710.             if($selectorData !== null) {
  711.                 $data['selector_data'] = $selectorData;
  712.             } */
  713.             $work $translation->getWork();
  714.             
  715.             $bSwedenborgWork = ($work->getSwedenborgType() !== null);
  716.             $data['is_swedenborg'] = $bSwedenborgWork;
  717.             if($bSwedenborgWork)
  718.             {
  719.                 $data['linktype_id'] = $this->LINK_TYPE_ID_SWEDENBORG;
  720.             }
  721.             else
  722.             {
  723.                 $data['linktype_id'] = $this->LINK_TYPE_ID_OTHER;
  724.             }
  725.             if($bSwedenborgWork && $nLanguageID == $request->getSession()->get('work_search_language_id'))
  726.             {
  727.                 $data['work_searchterm'] = $request->getSession()->get('work_searchterm');
  728.                 $data['work_search_phrase'] = $request->getSession()->get('work_search_phrase');
  729.                 if($nLanguageID == $this->LANGUAGE_ID_LATIN)
  730.                 {
  731.                     $data['work_search_internal_amb'] = $request->getSession()->get('work_search_internal_amb');                    
  732.                     $data['work_search_external_amb'] = $request->getSession()->get('work_search_external_amb');
  733.                     $data['work_search_int_ext_amb'] = $request->getSession()->get('work_search_int_ext_amb');
  734.                 }
  735.                 else
  736.                 {
  737.                     $data['work_search_internal_amb'] = null;
  738.                     $data['work_search_external_amb'] = null;
  739.                     $data['work_search_int_ext_amb'] = null;
  740.                 }
  741.             }
  742.             else
  743.             {
  744.                 $data['work_searchterm'] = null;
  745.                 $data['work_search_phrase'] = null;
  746.                 $data['work_search_internal_amb'] = null;
  747.                 $data['work_search_external_amb'] = null;
  748.                 $data['work_search_int_ext_amb'] = null;
  749.             }
  750.             
  751.             $bConsider false;
  752.             $bBibleStudy false;
  753.             $bConcept false;
  754.             $bQA false;
  755.             if(!$bSwedenborgWork)
  756.             {
  757.                 foreach($work->getCategories() as $category) {
  758.                     if($category->getId() == $this->CATEGORY_ID_SPIRITUAL_TOPIC) {
  759.                         $bConsider true;
  760.                     }
  761.                     elseif($category->getId() == $this->CATEGORY_ID_BIBLE_STUDY) {
  762.                         $bBibleStudy true;
  763.                     }
  764.                     elseif($category->getId() == $this->CATEGORY_ID_CONCEPT) {
  765.                         $bConcept true;
  766.                         $data['category_concept'] = 1;
  767.                     }
  768.                     elseif($category->getId() == $this->CATEGORY_ID_QA) {
  769.                         $bQA true;
  770.                     }
  771.                 }
  772.             }
  773.             
  774.             $nLanguageID $translation->getLanguage()->getId();
  775.             if($bQA)
  776.             {                
  777.                 $data['prev_next'] = $this->getPrevNextLink($translation->getId(), $this->CATEGORY_ID_QA$request);
  778.             }
  779.             else
  780.             {
  781.                 if($bConsider)
  782.                 {                
  783.                     $aAllTopic = array();
  784.                     $sTranslationUrl $translation->getUrl();
  785.                     $aSearchedTopic $request->getSession()->get('searched_topic_list');
  786.                     if(!empty($aSearchedTopic))
  787.                     {                
  788.                         foreach($aSearchedTopic as $s)
  789.                         {                
  790.                             if($s['translation_url'] == $sTranslationUrl)
  791.                             {
  792.                                 $aAllTopic $aSearchedTopic;
  793.                                 break;
  794.                             }
  795.                         }
  796.                     }
  797.                     
  798.                     if(empty($aAllTopic))
  799.                     {                    
  800.                         $aAllTopic $this->getCategoryList($nLanguageID$this->CATEGORY_ID_SPIRITUAL_TOPIC$locale);
  801.                     }                
  802.                 
  803.                     $data['consider_data'] = $aAllTopic;
  804.                     $data['prev_next'] = $this->getPrevNextLinkFromList($translation->getId(), $data['consider_data']);                    
  805.                 }
  806.                 
  807.                 if($bBibleStudy)
  808.                 {
  809.                     $data['biblestudy_data'] = $this->getCategoryList($nLanguageID$this->CATEGORY_ID_BIBLE_STUDY$locale);
  810.                     $data['prev_next'] = $this->getPrevNextLinkFromList($translation->getId(), $data['biblestudy_data']);                    
  811.                 }
  812.                 
  813.                 if($bConcept)
  814.                 {                
  815.                     $data['concept_prev_next'] = $this->getNextPrevConceptUrl($translation->getId(), $nLanguageID$locale);
  816.                 }
  817.             }
  818.                         
  819.             if(!$bSwedenborgWork)                
  820.                 $data['authors'] = $this->getAuthorInfo($request$translation->getId());
  821.             else
  822.                 $data['IsSwedenborgWork'] = 1;    
  823.                 
  824.             $type_id $translation->getTypeId();
  825.         
  826.             if($type_id == $this->TRANSLATION_TYPE_ID_FILE
  827.             {
  828.                 $file $translation->getFile();
  829.                 if($file !== null) {
  830.                     $data['file'] = $file;
  831.                 }
  832.             }
  833.             if($type_id == $this->TRANSLATION_TYPE_ID_LINK
  834.             {
  835.                 $doc_link $translation->getDocLink();
  836.                 if($doc_link !== null) {
  837.                     $data['doc_link'] = $doc_link;
  838.                 }
  839.             }
  840.             
  841.             $data['type_id'] = $type_id;
  842.             
  843.             $data['in_frame'] = $inFrame;
  844.             
  845.             if($passage != null)
  846.             {            
  847.                 $nTranslationID $translation->getId();
  848.                 
  849.                 if(!$bSwedenborgWork)
  850.                     $data['passage_ref'] = $this->getWorkPassageRefs($nPassageID,$nTranslationID$request);
  851.                 
  852.                 if($bSwedenborgWork)
  853.                     $data['related_bible_ref'] = $this->getRelatedBibleRefForWork($nPassageID,$nTranslationID$request);
  854.                 $data['passage_footnote'] = $this->getPassageFootnotes($nPassageID,$nTranslationID);
  855.                 $data['passage_multilink'] = $this->getWorkPassageMultiLink($nPassageID,$nTranslationID$request);
  856.                 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))
  857.                 {                
  858.                     $data['passage_scanimage'] = $this->getWorkPassageScanImageFileName($nPassageID);
  859.                     $data['define_latin_icon'] = 1;
  860.                 }
  861.                 
  862.            //     $data['work_references'] = $this->getWorkRefForWork($nPassageID, $nLanguageID);
  863.            //     $data['explanation_references'] = $this->getExplanationRefForWork($nPassageID, $nLanguageID);
  864.            //     $data['gced_ref'] = $this->getGCEDRefForWork($nPassageID);
  865.            //     $data['otle_ref'] = $this->getOTLERefForWork($nPassageID);
  866.            //     $data['related_passages'] = $this->getRelatedPassages($nPassageID, $nLanguageID);
  867.                 
  868.                 $request->getSession()->set('current_explanation_cchapter_id''');                
  869.                 $nExplainChapterID $this->getExplainChapterID($nTranslationID$this->getCurrUserID($request)); 
  870.                   if(!empty($nExplainChapterID))
  871.                   {                  
  872.                       $data['cchapter_id'] = $nExplainChapterID;
  873.                     $request->getSession()->set('current_explanation_cchapter_id'$nExplainChapterID); 
  874.                       $request->getSession()->set('current_explanation_translation_id'$nTranslationID);
  875.                   }
  876.                                     
  877.                   if(!$bSwedenborgWork)
  878.                   {
  879.                       if ($this->canEditExplanation($request))                  
  880.                           $data['explanation_translation_id_to_edit'] = $nTranslationID;
  881.                   }    
  882.                   else if ($this->canEditWork($request))
  883.                   {
  884.                       $data['work_translation_id_to_edit'] = $nTranslationID;    
  885.                       $data['work_passage_num_to_edit'] = $passage->getSwedenborgSection();        
  886.                       //$data['has_slider_item_for_work'] = $this->hasSliderItemForWork($nPassageID, $nTranslationID, $request, $nLanguageID);
  887.         
  888.                     $data['slider_url'] = $this->get('router')->generate('exposition_slider', array(
  889.                             'translationId' => $nTranslationID,
  890.                             'passageId' => $nPassageID
  891.                         ));
  892.                   }    
  893.                   
  894.                   if($bSwedenborgWork)
  895.                   {                              
  896.                       $data['has_slider_item_for_work'] = $this->hasSliderItemForWork($nPassageID$nTranslationID$request$nLanguageID);
  897.         
  898.                     $data['slider_url'] = $this->get('router')->generate('exposition_slider', array(
  899.                             'translationId' => $nTranslationID,
  900.                             'passageId' => $nPassageID
  901.                         ));
  902.                     
  903.                     if($passage->emptyInTranslation($translation))
  904.                     {    
  905.                         $data['last_passage_num'] = $this->getLastAvailablePassageNum($nTranslationID);
  906.                     }   
  907.                   }    
  908.                   
  909.                   // check table of contents
  910.                   $aTOC $this->getWorkTranslationTOC($nTranslationIDtrue); 
  911.                   if(!empty($aTOC))
  912.                   {                  
  913.                       $data['has_work_toc'] = true;
  914.                   }              
  915.             }
  916.             $data['text_to_speech'] = $this->getTextToSpeech($translation->getLanguage()->getId());    
  917.             
  918.             if($bSwedenborgWork)   
  919.             {     
  920.                 $data['biblio_info'] = $this->getBiblioForTranslation($translation->getId());
  921.             //    $data['swedenborg_works'] = $this->getCategorizedSwedenborgWorksForTranslation($request, $translation->getId(), $translation->getLanguage()->getId());
  922.             }
  923.             else
  924.             {
  925.                 // check concept image
  926.                 if($compareTo == null)
  927.                 {
  928.                     $conceptUrl $this->getConceptUrl($translation->getWork()->getId());                    
  929.                     if(!empty($conceptUrl))
  930.                     {
  931.                         $concept $this->getRepository('Concepts\Concept')->findOneByUrl($conceptUrl);
  932.                         $illustrations $concept->getIllustrations();
  933.                         $data['image'] = ($illustrations->isEmpty()) ? null $illustrations[0]->getImage();
  934.                     }
  935.                 }
  936.             }    
  937.         } else {
  938.             $work null;
  939.         }
  940.         return $this->createPassageView($data'translation'$work$request);
  941.     }
  942.     public function translationDivisionAction($translationUrl$divisionUrls$userSelected trueRequest $request)
  943.     {
  944.         $this->onloadPage($request);
  945.         $translation $this->expositionData('Translation')->findOneBy(array('url' => $translationUrl'isPublic' => true));
  946.         if($userSelected) {
  947.             $request->getSession()->set('current_language'$translation->getLanguage()->getBibliographicCode());
  948.         }
  949.         $redir $this->checkRedirect($translation);
  950.         if($redir !== null) {
  951.             return $this->redirect($redir301);
  952.         }
  953.         $work = ($translation === null) ? null $translation->getWork();
  954.         $division $this->findDivisionByWorkAndUrls($work$divisionUrls);
  955.         $data = array('translation' => $translation'division' => $division'nav_mode' => 'translation');
  956.   /*      $selectorData = $this->selectSelectorList($translation->getWork(), $translation->getLanguage()->getName(), $translation);
  957.         if($selectorData !== null) {
  958.             $data['selector_data'] = $selectorData;
  959.         } */
  960.         $response null;
  961.         if($division === null) {
  962.             $response = new Response();
  963.             $response->setStatusCode(404);
  964.             return $this->renderView('no_work_content', array(), $response);
  965.         }
  966.         $this->setCurrentUrl($request);         
  967.         return $this->renderView('translation_division'$data$response);
  968.     }
  969.     // Final tasks to be performed when rendering a passage, whether accessed via work or via translation
  970.     protected function createPassageView($data$mode$work$request)
  971.     {
  972.         $locale $request->getLocale();
  973.         $response null;
  974.         if($work === null || $data['translation'] === null || $data['passage'] === null || $data['passage']->findWork() !== $work) {
  975.             $response = new Response();
  976.             $response->setStatusCode(404);
  977.             return $this->renderView('no_work_content', array(), $response);
  978.         }
  979.         
  980.         $nPassageID $data['passage']->getId();
  981.         $nTranslationID $data['translation']->getId();
  982.         $nLanguageID $data['translation']->getLanguage()->getId();
  983.         $data['translation_shortname'] = $this->getWorkTranslationShortName($nTranslationID);
  984.         
  985.         $nBibleBookIDForSummary $this->getBibleBookIDForSummary($nTranslationID);
  986.         $bBibleBookSummary = ($nBibleBookIDForSummary != '');
  987.         if($bBibleBookSummary)
  988.             $data['is_book_summary'] = '1';
  989.         
  990.         if($work !== null) {              
  991.                $nLevelID '';
  992.                $aStory $this->getStoryInfo($nTranslationID);
  993.             if(!empty($aStory))
  994.             {                   
  995.                 $nStoryID $aStory['story_id'];
  996.                 $nLevelID $aStory['level_id'];               
  997.                 if($nLevelID == $this->STORY_LEVEL_ID_BIBLE)
  998.                 {  
  999.                     $aAllStory = array();
  1000.             /*        $aSearchedStory = $request->getSession()->get('searched_bible_story_list');
  1001.                     if(!empty($aSearchedStory))
  1002.                     {
  1003.                         $sTranslationUrl = $data['translation']->getUrl();
  1004.                         foreach($aSearchedStory as $s)
  1005.                         {                
  1006.                             if($s['commentary_url'] == $sTranslationUrl)
  1007.                             {
  1008.                                 $aAllStory = $aSearchedStory;
  1009.                                 break;
  1010.                             }
  1011.                         }
  1012.                     }
  1013.                     
  1014.                     if(empty($aAllStory))
  1015.                     {
  1016.                         $aAllStory = $this->getExplainedStoryList($locale);
  1017.                     }
  1018.             //        print_r($aAllStory); */
  1019.                     $data['all_stories'] = $aAllStory;
  1020.                     
  1021.                     $data['story_explanations'] = $this->getWorkListForStory($locale$nStoryID);
  1022.                     $data['commentary_type'] = 'storyexplanation';                                            
  1023.                 }
  1024.                 elseif($nLevelID == $this->STORY_LEVEL_ID_CHAPTER)
  1025.                     $data['is_chapter_explanation'] = '1';
  1026.                 elseif($nLevelID == $this->STORY_LEVEL_ID_VERSE)
  1027.                     $data['is_verse_explanation'] = '1';    
  1028.                                
  1029.                 $data['story_id'] = $nStoryID;
  1030.             }  
  1031.             // We can override the 'storyexplanation' commentary type because some "story" explanations are really verse explanations.
  1032.             // 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.
  1033.             // 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.
  1034.             if($this->getConceptID($data['translation']->getId()) !== null) {
  1035.                 $data['commentary_type'] = 'conceptexplanation';
  1036.             } else {
  1037.                 $containingCategories $work->getCategories()->toArray();
  1038.                 if($data['translation'] !== null) {
  1039.                     $containingCategories array_merge($containingCategories$data['translation']->getCategories()->toArray());
  1040.                 }
  1041.                 $categoryUrlToCommentaryTypeMap = array(
  1042.                     'doctrinal-topic-explanations' => 'doctrinaltopic',
  1043.                     'verse-explanations' => 'verseexplanation',
  1044.                     // 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
  1045.                     'story-explanations' => 'storyexplanation'
  1046.                 );
  1047.                 // If the content doesn't belong to the Category for any major commentary type, then $data['commentary_type'] can just remain unset.
  1048.                 foreach($containingCategories as $cat) {
  1049.                     if(array_key_exists($cat->getUrl(), $categoryUrlToCommentaryTypeMap)) {
  1050.                         $data['commentary_type'] = $categoryUrlToCommentaryTypeMap[$cat->getUrl()];
  1051.                         // At the time of coding this, there shouldn't be anything which belongs to more than one major commentary type.
  1052.                         break;
  1053.                     }
  1054.                 }
  1055.             }
  1056.         }
  1057.                 
  1058.         if($work->getSwedenborgType() !== null)
  1059.         {              
  1060.             $data['previous_passage'] = $this->getPreviousPassageWithContent($data['passage'], $data['translation']);
  1061.             $data['next_passage'] = $this->getNextPassageWithContent($data['passage'], $data['translation']); 
  1062.             
  1063.             // Get meta description
  1064.             $nTextLength 140;            
  1065.             $sPassageText $this->getWorkPassageContents($nPassageID,$nTranslationID); 
  1066.             $sMetaDesc $this->fixWorkText($sPassageText);
  1067.               $sMetaDesc $this->getTextWithinLength($sMetaDesc$nTextLength"...");          
  1068.               $data['work_meta_desc'] = $sMetaDesc;
  1069.         } 
  1070.         else
  1071.         {
  1072.             // Get meta description
  1073.             $nTextLength 140;
  1074.             $sPassageText '';
  1075.             if($nLevelID == $this->STORY_LEVEL_ID_CHAPTER)
  1076.             {            
  1077.                 $sPassageText $this->getWorkPassageContents($nPassageID,$nTranslationID);
  1078.             }
  1079.             else
  1080.             {
  1081.                 $sPassageText $this->getWorkTranslationDesc($nTranslationID); 
  1082.                 if(empty($sPassageText))
  1083.                 {
  1084.                     $sPassageText $this->getWorkPassageContents($nPassageID,$nTranslationID); 
  1085.                 }
  1086.             }
  1087.             $sMetaDesc $this->fixWorkText($sPassageText);
  1088.               $sMetaDesc $this->getTextWithinLength($sMetaDesc$nTextLength"...");          
  1089.               $data['work_meta_desc'] = $sMetaDesc;
  1090.         }      
  1091.         
  1092.         $data['work'] = $work;
  1093.                      
  1094.         return $this->renderView($mode.'_passage'$data$response);
  1095.     }
  1096.     protected function findDivisionByWorkAndUrls($work$divisionUrls)
  1097.     {
  1098.         if($work === null) {
  1099.             return null;
  1100.         }
  1101.         $divisionUrlList explode('/'$divisionUrls);
  1102.         $divisionData $this->expositionData('Division');
  1103.         $division $divisionData->findOneBy(array(
  1104.             'work' => $work->getId(), 'url' => array_shift($divisionUrlList)));
  1105.         foreach($divisionUrlList as $url) {
  1106.             if($division === null) {
  1107.                 return null;
  1108.             }
  1109.             $division $divisionData->findOneBy(array('superdivision' => $division->getId(), 'url' => $url));
  1110.         }
  1111.         return $division;
  1112.     }
  1113.     protected function findPassageByWorkAndDivisions($work$divisionUrls$passageNumber null)
  1114.     {
  1115.         $division $this->findDivisionByWorkAndUrls($work$divisionUrls);
  1116.         if($division === null) {
  1117.             return null;
  1118.         }
  1119.         return ($passageNumber === null)
  1120.             ? $division->findFirstPassage()
  1121.             : $this->expositionData('Passage')->findOneBy(array(
  1122.                 'division' => $division->getId(),
  1123.                 'ordering' => $passageNumber
  1124.             ));
  1125.     }
  1126.     public function conceptAction($conceptUrlRequest $request$languageCode ''$asOverlay false)
  1127.     {
  1128.       // $memcache = $this->get('cache');  // it's actually apccache, but behaves the same way
  1129.       // $apccache = $this->get('cache');    
  1130.       
  1131.           // The client requested to use translation url instead of concept url (3/16/2020)
  1132.           
  1133.           $this->onloadPage($request);          
  1134.         if(!$asOverlay)
  1135.         {
  1136.             $sTranslationUrl $this->getConceptTranslationUrl($conceptUrl$languageCode);
  1137.             if(!empty($sTranslationUrl))
  1138.             {
  1139.                 return $this->redirect($this->get('router')->generate('exposition_translation', array(
  1140.                         'translationUrl' => $sTranslationUrl
  1141.                     )), 301);
  1142.             }        
  1143.         }
  1144.       
  1145.           $locale $request->getLocale();
  1146.         $displayInfo = array('nav_mode' => 'translation''commentary_type' => 'conceptexplanation');
  1147.         $concept $this->getRepository('Concepts\Concept')->findOneByUrl($conceptUrl);
  1148.         
  1149.         if(!empty($languageCode))
  1150.         {
  1151.             $language $this->getLanguageByBibliographicCode($languageCode);
  1152.             $nLanguageID $language['id'];
  1153.         }
  1154.         else
  1155.         {
  1156.             $nLanguageID $this->getLanguageIDByShortCode($locale);            
  1157.         }
  1158.         
  1159.         $sTranslationUrl $this->getConceptTranslationUrl($conceptUrl$languageCode);
  1160.                  
  1161.         if(!empty($sTranslationUrl)) 
  1162.         {     
  1163.             $translation =  $this->expositionData('Translation')->findOneByUrl($sTranslationUrl); 
  1164.             $displayInfo['translation'] = $translation;               
  1165.             $displayInfo['title'] = $translation->getNameOrTitle();
  1166.             $illustrations $concept->getIllustrations();
  1167.             $displayInfo['image'] = ($illustrations->isEmpty()) ? null $illustrations[0]->getImage();
  1168.             
  1169.             $displayInfo['passage'] = $translation->getWork()->findFirstPassage();
  1170.             $displayInfo['text_style_override'] = $this->getTextStyleOverride($translation->getLanguage()->getId());
  1171.             
  1172.             $displayInfo['passage_ref'] = $this->getWorkPassageRefs($displayInfo['passage']->getId(),$translation->getId(), $request); 
  1173.             $displayInfo['ref_column_spec'] = $this->getExplanationUrl($translation->getId());
  1174.             $displayInfo['passage_footnote'] = $this->getPassageFootnotes($displayInfo['passage']->getId(),$translation->getId());
  1175.             $displayInfo['passage_multilink'] = $this->getWorkPassageMultiLink($displayInfo['passage']->getId(),$translation->getId(), $request);
  1176.         } elseif($concept !== null) {
  1177.             // 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
  1178.         } else {
  1179.             $displayInfo['translation'] = null;
  1180.             $displayInfo['passage'] = null;
  1181.         }
  1182.         $response null;
  1183.         if(empty($sTranslationUrl) || $displayInfo['translation'] === null) {
  1184.             $response = new Response();
  1185.             $response->setStatusCode(404);
  1186.             return $this->renderView('no_work_content', array(), $response);
  1187.         }
  1188.     
  1189.         $templateName $asOverlay 'overlay/passage' 'translation_passage';
  1190.         
  1191.         if(!$asOverlay)
  1192.         {
  1193.             $this->setCurrentUrl($request);
  1194.             $displayInfo['concept_prev_next'] = $this->getNextPrevConcept($concept->getId());
  1195.         }     
  1196.                         
  1197.         return $this->renderView($templateName$displayInfo$response);
  1198.     }
  1199.     protected function passageCanonicalRedirect($passage$translation$code 301)
  1200.     {    
  1201.           $redirectUrl $this->get('router')->generate('exposition_translation_division_passage', array(
  1202.                     'translationUrl' => $translation->getUrl(),
  1203.                     'divisionUrls' => $passage->getDivision()->getUrl(),
  1204.                     'passageNumber' => $passage->getOrdering()
  1205.                 )); 
  1206.               
  1207.         $args = @$_SERVER['QUERY_STRING'];
  1208.         if(!empty($args)) 
  1209.         {                
  1210.             $redirectUrl .= '?'.$args;                   
  1211.         }
  1212.         return $this->redirect($redirectUrl$code);
  1213.     }
  1214.     public function swedenborgGotoAction(Request $request)
  1215.     {
  1216.         $this->onloadPage($request);
  1217.         $statusCode 200;
  1218.         $query $request->query;
  1219.         if(!$query->has('translation') && !$query->has('work')) {
  1220.             // If we aren't told what book to show, then we'll redirect to the list of all Swedenborg books
  1221.             return $this->redirect($this->get('router')->generate('swedenborg'));
  1222.         }
  1223.         
  1224.         $translation $this->expositionData('Translation')->findOneByUrl($query->get('translation'));
  1225.         if($translation !== null) {
  1226.             $request->getSession()->set('current_language'$translation->getLanguage()->getBibliographicCode());
  1227.             $work $translation->getWork();
  1228.             $params = array('translation' => $translation'nav_mode' => 'translation');
  1229.      /*       if($work->getSwedenborgType() !== null) {
  1230.                 $params['selector_data'] = $this->buildSwedenborgSelectorList($translation->getLanguage()->getName(), $translation); 
  1231.             }*/
  1232.         } else {
  1233.             $work $this->expositionData('Work')->findOneByUrl($query->get('work'));
  1234.             $params = array('work' => $work'nav_mode' => 'work');
  1235.             $translation $work->selectTranslation();
  1236.     /*        if($work->getSwedenborgType() !== null) {
  1237.                 $params['selector_data'] = $this->buildSwedenborgSelectorList();
  1238.             } */
  1239.         }
  1240.         if($query->has('section')) {
  1241.             $targetSectionNumber $query->get('section');
  1242.             $targetSection $this->expositionData('Passage')->findSwedenborgSection($work$targetSectionNumber);
  1243.             
  1244.             $inframe $query->get('inframe');
  1245.             if($inframe == 1)
  1246.             {
  1247.                 return $this->redirect($this->get('router')->generate('exposition_frame_passage', array(
  1248.                         'translationUrl' => $translation->getUrl(),
  1249.                         'divisionUrls' => $targetSection->getDivision()->getUrl(),
  1250.                         'passageNumber' => $targetSection->getOrdering()
  1251.                     )), 301);                
  1252.             } 
  1253.         } else {
  1254.             $targetSection $work->findFirstPassage();
  1255.         }
  1256.         if($targetSection !== null) {
  1257.             return $this->passageCanonicalRedirect($targetSection$translation);
  1258.         } else {
  1259.             $fromSection $query->get('fromSection');
  1260.             if($fromSection !== null) {
  1261.                 $params['passage'] = $this->expositionData('Passage')->findSwedenborgSection($work$fromSection);
  1262.                 $template $params['nav_mode'].'_passage';
  1263.             } else {
  1264.                 $template $params['nav_mode'].'_index';
  1265.             }
  1266.             $title = ($translation !== null) ? $translation->getTranslatedTitle() : $work->selectTranslation()->getTranslatedTitle();
  1267.             // "%title% does not contain a section numbered _2000_"
  1268.      /*       $params['error_message'] = $this->get('translator')->trans($request->getSession()->get('ui_str')["exposition.passage.outofrange"], array(
  1269.                 '_1000_' => $title,
  1270.                 '_2000_' => $targetSectionNumber
  1271.             )); // $title." does not contain a section numbered ".$targetSectionNumber;
  1272.             */
  1273.             
  1274.             $aReplace = array(
  1275.                 '_1000_' => $title,
  1276.                 '_2000_' => $targetSectionNumber
  1277.             );
  1278.             $params['error_message'] = $this->ui_string_replace($request->getSession()->get('ui_str')["bible.chapternav.bookchapterrange"], $aReplace);
  1279.             
  1280.             $statusCode 404;
  1281.         }
  1282.         
  1283.         $sUrlCompareTo $request->query->get('compareTo');
  1284.         $aCompare explode(";;"$sUrlCompareTo);
  1285.         $nCompareLen count($aCompare);
  1286.         $compareTo null;
  1287.         $compareTo2 null;        
  1288.         if($nCompareLen && $aCompare[0] != '')
  1289.             $compareTo $this->expositionData('Translation')->findOneByUrl($aCompare[0]);        
  1290.         
  1291.         if($nCompareLen == && $aCompare[1] != '')            
  1292.             $compareTo2 $this->expositionData('Translation')->findOneByUrl($aCompare[1]);
  1293.             
  1294.         $params['compare_to'] = $compareTo;
  1295.         $params['compare_to2'] = $compareTo2;
  1296.         $response null;
  1297.         if($statusCode !== 200) {
  1298.             $response = new Response();
  1299.             $response->setStatusCode($statusCode);
  1300.         }
  1301.         $this->setCurrentUrl($request);         
  1302.         return $this->renderView($template$params$response);
  1303.     }
  1304.     public function quickviewTranslationPassageAction($passageId$translationIdRequest $request)
  1305.     {
  1306.         $translation $this->expositionData('Translation')->findOneById($translationId);
  1307.         $nTranslationID $translation->getId();
  1308.         $work $translation->getWork();
  1309.         $nLanguageID $translation->getLanguage()->getId();
  1310.   /*      $sUrlCompareTo = $request->query->get('compareTo');
  1311.         $aCompare = explode(";;", $sUrlCompareTo);
  1312.         $nCompareLen = count($aCompare);
  1313.         $compareTo = null;
  1314.         $compareTo2 = null;        
  1315.         if($nCompareLen > 0 && $aCompare[0] != '')        
  1316.             $compareTo = $this->expositionData('Translation')->findOneByUrl($aCompare[0]);        
  1317.         
  1318.         if($nCompareLen == 2 && $aCompare[1] != '')             
  1319.             $compareTo2 = $this->expositionData('Translation')->findOneByUrl($aCompare[1]);
  1320.       */  
  1321.         $passage $this->expositionData('Passage')->findOneById($passageId);    
  1322.         $quickviewData = array(
  1323.             'translation' => $translation,
  1324.        //     'compare_to' => $compareTo,
  1325.        //     'compare_to2' => $compareTo2,
  1326.             'passage' => $passage,
  1327.             'text_style_override' => $this->getTextStyleOverride($nLanguageID)
  1328.         );
  1329.         
  1330.         if($passage != null && $translation != null)
  1331.         {           
  1332.             $quickviewData['passage_footnote'] = $this->getPassageFootnotes($passage->getId(),$nTranslationID);
  1333.             $quickviewData['passage_multilink'] = $this->getWorkPassageMultiLink($passage->getId(),$nTranslationID$request);
  1334.             $quickviewData['previous_passage'] = $this->getPreviousPassageWithContent($passage,$translation);     
  1335.             $quickviewData['next_passage'] = $this->getNextPassageWithContent($passage,$translation);     
  1336.             
  1337.             $nWorkID $work->getId();
  1338.             
  1339.             if($nLanguageID != $this->LANGUAGE_ID_LATIN)
  1340.             {
  1341.                 $request->getSession()->set('last_quickview_language_id'$nLanguageID); 
  1342.             }
  1343.             
  1344.             $sLanguages "";
  1345.             $nLastLangID $request->getSession()->get('last_quickview_language_id');
  1346.             if($nLanguageID == $this->LANGUAGE_ID_LATIN)
  1347.             {          
  1348.                 if(empty($nLastLangID))
  1349.                     $sLanguages $nLanguageID;
  1350.                 else
  1351.                     $sLanguages $nLanguageID "," $request->getSession()->get('last_quickview_language_id');     
  1352.             }          
  1353.             else
  1354.                 $sLanguages $nLanguageID ", " $this->LANGUAGE_ID_LATIN;
  1355.                 
  1356.             $quickviewData['translations_by_language'] = $this->getWorkTranslationsByLanguage($nWorkID$sLanguages);  
  1357.             
  1358.             $quickviewData['shortname'] = $this->getWorkTranslationShortName($nTranslationID);  
  1359.             $quickviewData['translation_id'] = $nTranslationID;
  1360.             $quickviewData['passage_id'] = $passage->getId(); 
  1361.             
  1362.             $bSwedenborgWork = ($work->getSwedenborgType() !== null);
  1363.             if(!$bSwedenborgWork)                
  1364.                 $quickviewData['authors'] = $this->getAuthorInfo($request$translation->getId());
  1365.             else
  1366.                 $quickviewData['IsSwedenborgWork'] = 1;      
  1367.         }
  1368.         
  1369.         return $this->renderView('quickview/passage'$quickviewData);
  1370.     }
  1371.     public function quickviewSwedenborgTranslationGotoAction(Request $request)
  1372.     {
  1373.         $query $request->query;
  1374.         if(!$query->has('translation')) {
  1375.             // We haven't been told what book to show; maybe someone tried to access this directly rather than via AJAX from the search page?
  1376.             // We'll redirect to the search page
  1377.             return $this->redirect($this->get('router')->generate('advanced_search'));
  1378.         }
  1379.         $translation $this->expositionData('Translation')->findOneByUrl($query->get('translation'));
  1380.         if($query->has('section')) {
  1381.             $targetSection $this->expositionData('Passage')->findSwedenborgSection($translation->getWork(), $query->get('section'));
  1382.         } else {
  1383.             $targetSection $translation->getWork()->findFirstPassage();
  1384.         }
  1385.         return $this->quickviewTranslationPassageAction($targetSection->getId(), $translation->getId(), $request);
  1386.     }
  1387.     public function expositionSearchPostAction(Request $request)
  1388.     {
  1389.         // $query = $this->getRequest()->query;
  1390.         // $searchTerm = $query['searchTerm'];
  1391.         $params $request->request->all();
  1392.         if ( array_key_exists'searchTerm'$params ) ) {
  1393.             $searchTerm $params['searchTerm'];
  1394.         } else {
  1395.             $searchTerm '';
  1396.         }
  1397.         return $this->expositionSearchAction($searchTerm);
  1398.     }
  1399.     public function expositionSearchAction($searchTerm$start=1) {
  1400.         // $templateName = 'explanation_search';
  1401.         // return $this->sharedSearchAction( $searchTerm, 'is', $templateName, $start );
  1402.         return $this->renderView('search/exposition_search', array('searchTerm' => $searchTerm'content_class' => 'explanation''start' => $start));
  1403.     }
  1404.     public function expositionSearchResultsAction($searchTerm$pageNum 1)
  1405.     {
  1406.         return $this->renderView('search/search_results'$this->expositionSearchResults($searchTermfalse'locale'$pageNum));
  1407.     }
  1408.     public function swedenborgSearchPostAction(Request $request)
  1409.     {
  1410.         // $query = $this->getRequest()->query;
  1411.         // $searchTerm = $query['searchTerm'];
  1412.         $params $request->request->all();
  1413.         if ( array_key_exists'searchTerm'$params ) ) {
  1414.             $searchTerm $params['searchTerm'];
  1415.         } else {
  1416.             $searchTerm '';
  1417.         }
  1418.         return $this->swedenborgSearchAction($searchTerm);
  1419.     }
  1420.     public function swedenborgSearchAction($searchTerm$start=1)
  1421.     {
  1422.         // $templateName = 'swedenborg_search';
  1423.         // return $this->sharedSearchAction( $searchTerm, 'is not', $templateName, $start );
  1424.         return $this->renderView('search/exposition_search', array('searchTerm' => $searchTerm'content_class' => 'swedenborg''start' => $start));
  1425.     }
  1426.     public function swedenborgSearchResultsAction($searchTerm$pageNum 1)
  1427.     {
  1428.         // $templateName = 'swedenborg_search';
  1429.         // return $this->sharedSearchAction( $searchTerm, 'is not', $templateName, $start );
  1430.         return $this->renderView('search/search_results'$this->expositionSearchResults($searchTermtrue'locale'$pageNum));
  1431.     }
  1432.     public function expositionSearchResults(Request $request$searchTerm$isSwedenborg$forceLanguage null$start 1)
  1433.     {
  1434.         $search = new PostgresSearch();
  1435.         $em $this->getDoctrine()->getManager();
  1436.         $search->setManager($em);
  1437.         return $search->getExpositionSearchResults($request$searchTerm$isSwedenborg, array('language' => $forceLanguage'page' => $start));
  1438.     }         
  1439.             
  1440.     public function topicalPathIndexAction(Request $request)
  1441.     {
  1442.         $this->onloadPage($request);
  1443.         $locale $request->getLocale();
  1444.         $topicData $this->getTopPathList($locale);
  1445.         $data = array(
  1446.             'topic_data' => $topicData        
  1447.         );
  1448.         $this->setCurrentUrl($request);         
  1449.         return $this->renderView('index/topical_paths'$data);
  1450.     }
  1451.     
  1452.     public function topPathAction($TopPathUrlRequest $request)
  1453.     {
  1454.         $this->onloadPage($request);
  1455.         $locale $request->getLocale();
  1456.         $topPath $this->getTopPathInfo($TopPathUrl,$locale);
  1457.         $subPathList $this->getSubPathList($TopPathUrl,$locale);
  1458.         $data = array(
  1459.             'sub_path_list' => $subPathList,
  1460.             'top_path' => $topPath,
  1461.             'top_path_url' => $TopPathUrl       
  1462.         );
  1463.         $this->setCurrentUrl($request);         
  1464.         return $this->renderView('top_path'$data);
  1465.     }
  1466.     
  1467.     public function subPathAction($TopPathUrl$SubPathUrlRequest $request)
  1468.     {
  1469.         $this->onloadPage($request);
  1470.         $locale $request->getLocale();
  1471.         $bibleTranslationUrl $this->DEFAULT_BIBLE_VERSION;
  1472.         $nBibleTransID $request->getSession()->get('current_bible_translation_id');
  1473.         if($nBibleTransID != '')
  1474.         {   
  1475.                $bibleTranslation $this->getBibleTranslationByID($nBibleTransID);
  1476.                $bibleTranslationUrl $bibleTranslation['url'];
  1477.         }
  1478.         $topPath $this->getTopPathInfo($TopPathUrl,$locale);
  1479.         $subPath $this->getSubPathInfo($SubPathUrl,$locale);
  1480.         $explanationList $this->getExplanationListForTopAndSubPath($TopPathUrl$SubPathUrl,$locale);
  1481.         $data = array(
  1482.             'explanation_list' => $explanationList,
  1483.             'top_path' => $topPath,
  1484.             'sub_path' => $subPath,
  1485.             'sub_path_url' => $SubPathUrl,
  1486.             'top_path_url' => $TopPathUrl,
  1487.             'bible_translation_url' => $bibleTranslationUrl       
  1488.         );
  1489.         $this->setCurrentUrl($request);         
  1490.         return $this->renderView('sub_path'$data);
  1491.     }
  1492.     
  1493.     public function topicIndexAction(Request $request)
  1494.     {
  1495.         $locale $request->getLocale();
  1496.         $topicData $this->getTopicList($locale);
  1497.         $data = array(
  1498.             'topic_data' => $topicData        
  1499.         );
  1500.       
  1501.            $this->setCurrentUrl($request); 
  1502.            $this->onloadPage($request);
  1503.         return $this->renderView('index/topics'$data);
  1504.     }
  1505.     
  1506.     public function topicAction($TopicUrl,Request $request)
  1507.     {        
  1508.         $this->onloadPage($request);
  1509.         $locale $request->getLocale(); 
  1510.         $bibleTranslationUrl $this->DEFAULT_BIBLE_VERSION;
  1511.         $nBibleTransID $request->getSession()->get('current_bible_translation_id');
  1512.         if($nBibleTransID != '')
  1513.         {   
  1514.                $bibleTranslation $this->getBibleTranslationByID($nBibleTransID);
  1515.                $bibleTranslationUrl $bibleTranslation['url'];
  1516.         }   
  1517.         $topic $this->getSubPathInfo($TopicUrl,$locale);
  1518.         $explanationList $this->getExplanationListForTopic($TopicUrl,$locale);
  1519.         $data = array(
  1520.             'explanation_list' => $explanationList,            
  1521.             'topic' => $topic,
  1522.             'topic_url' => $TopicUrl,
  1523.             'bible_translation_url' => $bibleTranslationUrl        
  1524.         );
  1525.         $this->setCurrentUrl($request);         
  1526.         return $this->renderView('topic'$data);
  1527.     }
  1528.     
  1529.     public function viewscanimagesAction($PassageIDRequest $request)
  1530.     {             
  1531.         $this->onloadPage($request);
  1532.         $aImage = array(
  1533.             'scanimage' => $this->getWorkPassageScanImageFileName($PassageID),
  1534.             'translation_info' => $this->getCurrentPassageForLatin($PassageID),
  1535.             'next_passage' => $this->getNextPassageWithScan($PassageID),
  1536.             'previous_passage' => $this->getPreviousPassageWithScan($PassageID)       
  1537.         );
  1538.         return $this->renderView('view_scanimages'$aImage);
  1539.     }
  1540.     
  1541.     public function popoverconceptAction($explanationID$conceptIDRequest $request)
  1542.     {         
  1543.           $locale $request->getLocale();        
  1544.         $sPopupText $this->getBibleWordPopupText($explanationID$conceptID);
  1545.         $aConceptInfo $this->getBibleWordPopupConceptInfo($explanationID$conceptID);
  1546.         $data = array(
  1547.             'popup_text' => $sPopupText,
  1548.             'title' => $aConceptInfo['title'],
  1549.             'concept_url' => $aConceptInfo['concept_url']
  1550.         );
  1551.          
  1552.         return $this->renderView('word_popup'$data);
  1553.     }
  1554.     
  1555.     /**
  1556.      * Show chapter summary list on a popup for multi page
  1557.      */
  1558.     public function selectchaptersummaryAction($explanationID$bibleBookIDRequest $request)
  1559.     {             
  1560.       $data['chapter_summary_list'] = $this->getChapterSummaryList($explanationID$bibleBookID);
  1561.                        
  1562.       return $this->renderView('selectchaptersummary'$data);
  1563.     }
  1564.     
  1565.     /**
  1566.      * Show chapter summary list on a popup for single chapter summary page
  1567.      */
  1568.     public function selectchaptersummarysinglepageAction($explanationID$cBibleBookIDRequest $request)
  1569.     {             
  1570.       $data['chapter_summary_list'] = $this->getChapterSummaryListForSinglePage($explanationID$cBibleBookID);
  1571.                        
  1572.       return $this->renderView('selectchaptersummarysinglepage'$data);
  1573.     }
  1574.     
  1575.     public function featured_spiritual_topicsAction(Request $request)
  1576.     {                       
  1577.     //    $this->setCurrentUrl($request); 
  1578.         $this->onloadPage($request);
  1579.         $locale $request->getLocale();
  1580.         $featuredList $this->getFeaturedListByCategory($this->CATEGORY_ID_SPIRITUAL_TOPIC$locale9);
  1581.         if(empty($featuredList))
  1582.             $featuredList $this->getFeaturedListByCategory($this->CATEGORY_ID_SPIRITUAL_TOPIC$locale9true);
  1583.         $request->getSession()->set('searched_topic_list', array());
  1584.         return $this->renderView('index/spiritual_topics_featured', array(     
  1585.             'featured_topic' => $featuredList            
  1586.         ));
  1587.     }
  1588.     
  1589.     public function searched_spiritual_topicsAction(Request $request)
  1590.     {                       
  1591.     //    $this->setCurrentUrl($request); 
  1592.         $this->onloadPage($request);
  1593.         $locale $request->getLocale();
  1594.         $sSearchTerm $request->query->get('searchTerm');
  1595.         $searchedResults null;   
  1596.         if($sSearchTerm != '')
  1597.         {
  1598.             $searchedResults $this->getSearchedListByCategory($this->CATEGORY_ID_SPIRITUAL_TOPIC$locale$request);
  1599.         }        
  1600.         else
  1601.         {
  1602.             $nPathwayID $request->query->get('pathwayid');
  1603.             if(!empty($nPathwayID))
  1604.             {
  1605.                 $searchedResults $this->getSearchedListByCategoryAndPathway($locale$request$this->CATEGORY_ID_SPIRITUAL_TOPIC$nPathwayID);
  1606.             }
  1607.             else
  1608.             {
  1609.                 $nAll $request->query->get('all');
  1610.                 if($nAll == '1')
  1611.                 {
  1612.                     $searchedResults $this->getAllListByCategory($this->CATEGORY_ID_SPIRITUAL_TOPIC$locale$request);
  1613.                 }
  1614.             }
  1615.         }
  1616.         return $this->renderView('index/spiritual_topics_searched', array(     
  1617.             'searched_topic' => $searchedResults            
  1618.         ));
  1619.     }
  1620.     
  1621.     public function getSearchedListByCategory($vCategoryId$locale$request)
  1622.     {
  1623.         $search = new PostgresSearch();
  1624.         $em $this->getDoctrine()->getManager();
  1625.         $search->setManager($em);
  1626.         return $search->getCategorySearchResults($vCategoryId$locale$request);
  1627.     }
  1628.     
  1629.     public function getSearchedOTLEVideos($locale$request)
  1630.     {
  1631.         $search = new PostgresSearch();
  1632.         $em $this->getDoctrine()->getManager();
  1633.         $search->setManager($em);
  1634.         return $search->getOTLESearchResults($locale$request);
  1635.     }
  1636.     
  1637.     public function expositionSliderAction($translationIdRequest $request$passageId$userSelected true$inFrame false)
  1638.     {
  1639.   /*      $translation = $this->expositionData('Translation')->findOneBy(array('id' => $translationId, 'isPublic' => true));
  1640.          if($translation == null) {
  1641.             $response = new Response();
  1642.             $response->setStatusCode(404);
  1643.             return $this->renderView('no_work_content', array(), $response);
  1644.         }
  1645.         
  1646.         $passage = ($passageId !== null)
  1647.             ? $this->expositionData('Passage')->findOneById($passageId)
  1648.             : (($translation !== null) ? $translation->getWork()->findFirstNonEmptyPassage($translation) : null); */
  1649.             
  1650.         $aTranslation $this->getTranslationData($translationId);    
  1651.         $aPassage $this->getPassageData($passageId);  
  1652.              
  1653.         $this->checkIfOnMobile($request);
  1654.     //    $locale = $request->getLocale();
  1655.              
  1656.         $ref_column_spec '';
  1657.      //   $work = $translation->getWork();
  1658.         $bSwedenborgWork = ($aTranslation['swedenborgtype'] != null);
  1659.         if($bSwedenborgWork)
  1660.             $ref_column_spec $this->MULTI_URL_INDICATOR_SWEDENBORG_WORK;    
  1661.         else
  1662.             $ref_column_spec $this->MULTI_URL_INDICATOR_EXPLANATION;    
  1663.         
  1664.         $ref_column_spec .= '_' $aTranslation['url'];
  1665.         if($bSwedenborgWork)
  1666.             $ref_column_spec .= '_' $aPassage['swedenborgsection'];
  1667.                     
  1668.         $nLanguageID $aTranslation['language_id'];      
  1669.         $data = array(
  1670.            // 'translation' => $translation,
  1671.            // 'passage' => $passage,  
  1672.             'ref_column_spec' => $ref_column_spec,  
  1673.             'passage_order' => $aPassage['ordering'],  
  1674.             'passage_id' => $passageId,                     
  1675.         );
  1676.      //   $data['passage_ref'] = $this->getWorkPassageRefs($passageId,$translationId, $request);
  1677.         
  1678.     //    if($bSwedenborgWork)
  1679.     //        $data['related_bible_ref'] = $this->getRelatedBibleRefForWork($passageId,$translationId, $request);
  1680.     //    $data['passage_footnote'] = $this->getPassageFootnotes($passageId,$translationId);
  1681.     //    $data['passage_multilink'] = $this->getWorkPassageMultiLink($passageId,$translationId, $request);
  1682.                     
  1683.         $data['work_references'] = $this->getWorkRefForWork($passageId$translationId$nLanguageID);
  1684.       
  1685.         $data['explanation_references'] = $this->getExplanationRefForWork($passageId$nLanguageID);
  1686.         $data['gced_ref'] = $this->getGCEDRefForWork($passageId);
  1687.         $data['otle_ref'] = $this->getOTLERefForWork($passageId);
  1688.         $data['related_passages'] = $this->getRelatedPassages($passageId$nLanguageID);                                        
  1689.           // get table of contents
  1690.           $aTOC $this->getWorkTranslationTOC($translationId); 
  1691.           if(!empty($aTOC))
  1692.           {                  
  1693.               $data['work_toc'] = $aTOC;
  1694.           }
  1695.                    
  1696.         return $this->renderView('refsidrw'$data);
  1697.     }
  1698.     public function selecttopicAction(Request $request)
  1699.     {       
  1700.       $locale $request->getLocale();  
  1701.       $sSearchText $request->query->get('st');
  1702.                        
  1703.       $data['consider_data'] = $this->getConsiderList($locale$sSearchText); 
  1704.                     
  1705.       return $this->renderView('selecttopic'$data);
  1706.     } 
  1707.     
  1708.     public function otlevideosAction(Request $request)
  1709.     {            
  1710.         $this->onloadPage($request);
  1711.         $locale $request->getLocale();
  1712.         $aBrand $this->getBrandList();
  1713.         $aShowTopic $this->getShowTopicList();
  1714.         $aShowType $this->getShowTypeList();   
  1715.         $data = array(
  1716.               'brand_list' => $aBrand,
  1717.               'topic_list' => $aShowTopic,
  1718.                'type_list' => $aShowType            
  1719.         );
  1720.         $this->setCurrentUrl($request);         
  1721.         return $this->renderView('otle_videos'$data);
  1722.     }
  1723.     
  1724.     public function searched_otle_videosAction(Request $request)
  1725.     {            
  1726.         $locale $request->getLocale();
  1727.         $searchedResults = array();
  1728.         $sSearchTerm $request->query->get('searchTerm');
  1729.         $nBrandID $request->query->get('brandid');
  1730.         if($sSearchTerm != '')
  1731.         {
  1732.             $searchedResults $this->getSearchedOTLEVideos($locale$request);
  1733.         }        
  1734.         else
  1735.         {
  1736.             $nStartNum $request->query->get('startnum');            
  1737.             $searchedResults $this->getOTLEVideos($nStartNum$request);            
  1738.         }            
  1739.         
  1740.         return $this->renderView('otle_videos_searched', array(     
  1741.             'searched_video' => $searchedResults['results'],
  1742.             'total_record' => $searchedResults['total_record'],
  1743.             'has_more' => $searchedResults['has_more'],
  1744.             'start_num' => $searchedResults['start_num']            
  1745.         ));
  1746.     }
  1747.     
  1748.     public function otlevideopageAction($showIDRequest $request)
  1749.     {            
  1750.         //$locale = $request->getLocale();        
  1751.         $aShow $this->getShowInfo($showID);
  1752.         $aShowRef $this->getShowRefs($showID$request);    
  1753.         
  1754.         $nTextLength 150;
  1755.         $sDesc $aShow['description'];
  1756.         $sMetaDesc $this->fixWorkText($sDesc);
  1757.           $sMetaDesc $this->getTextWithinLength($sMetaDesc$nTextLength"...");          
  1758.               
  1759.         return $this->renderView('otle_video_page', array(  
  1760.             'show_id' => $showID,   
  1761.             'show_info' => $aShow,
  1762.             'show_ref' => $aShowRef,
  1763.             'meta_desc' => $sMetaDesc           
  1764.         ));
  1765.     }
  1766.     
  1767.     public function audiohubAction(Request $request)
  1768.     {            
  1769.         $this->onloadPage($request);
  1770.         $locale $request->getLocale();        
  1771.         $aLanguage $this->getLanguageListForAudioHub(); 
  1772.         $aCategory $this->getCategoryListForAudioHub();   
  1773.         $data = array(
  1774.                'language_list' => $aLanguage,
  1775.                'category_list' => $aCategory            
  1776.         );
  1777.         $this->setCurrentUrl($request);        
  1778.         return $this->renderView('audiohub'$data);
  1779.     }
  1780.     
  1781.     public function search_audioAction(Request $request)
  1782.     {            
  1783.         $locale $request->getLocale();
  1784.         $searchedResults = array();
  1785.         $sSearchTerm $request->query->get('searchTerm');  
  1786.         $nStartNum $request->query->get('startnum');      
  1787.         if($sSearchTerm != '')
  1788.         {
  1789.             $searchedResults $this->getSearchedAudio($locale$request);
  1790.         }    
  1791.         else
  1792.         {
  1793.             $nFormatID $this->PRIMARY_FORMAT_ID_AUDIO;
  1794.             $searchedResults $this->getExplanationList($nStartNum$locale$request$nFormatID);            
  1795.         }            
  1796.         
  1797.         return $this->renderView('audio_searched', array(     
  1798.             'searched_audio' => $searchedResults,
  1799.             'start_num' => $nStartNum           
  1800.         ));
  1801.     }
  1802.         
  1803.     public function getSearchedAudio($locale$request)
  1804.     {        
  1805.         $search = new PostgresSearch();
  1806.         $em $this->getDoctrine()->getManager();
  1807.         $search->setManager($em);
  1808.         $sCategoryId 'any';
  1809.         return $search->getCategorySearchResults($sCategoryId$locale$request);
  1810.     } 
  1811.     
  1812.     public function qahubAction(Request $request)
  1813.     {            
  1814.         $locale $request->getLocale(); 
  1815.         $data = array(                         
  1816.         );
  1817.         $this->setCurrentUrl($request); 
  1818.         $this->onloadPage($request);
  1819.         return $this->renderView('qahub'$data);
  1820.     }
  1821.     
  1822.     public function search_qaAction(Request $request)
  1823.     {            
  1824.         $locale $request->getLocale();
  1825.         $searchedResults = array();
  1826.         $sSearchTerm $request->query->get('searchTerm');  
  1827.         $nStartNum $request->query->get('startnum');      
  1828.         if($sSearchTerm != '')
  1829.         {
  1830.             $searchedResults $this->getSearchedQA($locale$request);
  1831.         }    
  1832.         else
  1833.         {            
  1834.             $searchedResults $this->getExplanationList($nStartNum$locale$request);
  1835.         }            
  1836.         
  1837.         return $this->renderView('qa_searched', array(     
  1838.             'searched_qa' => $searchedResults,
  1839.             'start_num' => $nStartNum           
  1840.         ));
  1841.     }
  1842.         
  1843.     public function getSearchedQA($locale$request)
  1844.     {        
  1845.         $search = new PostgresSearch();
  1846.         $em $this->getDoctrine()->getManager();
  1847.         $search->setManager($em);
  1848.         $sCategoryId 47;
  1849.         return $search->getCategorySearchResults($sCategoryId$locale$request);
  1850.     } 
  1851.     
  1852.     public function search_classAction(Request $request)
  1853.     {            
  1854.         $locale $request->getLocale();
  1855.         $searchedResults = array();
  1856.         $sSearchTerm $request->query->get('searchTerm');  
  1857.         $nStartNum $request->query->get('startnum');      
  1858.         if($sSearchTerm != '')
  1859.         {
  1860.             $searchedResults $this->getSearchedClass($locale$request);
  1861.         }    
  1862.         else
  1863.         {            
  1864.             $searchedResults $this->getClassList($nStartNum$request);            
  1865.         }            
  1866.         
  1867.         return $this->renderView('class_searched', array(     
  1868.             'searched_class' => $searchedResults['results'],
  1869.             'total_record' => $searchedResults['total_record'],
  1870.             'has_filter' => $searchedResults['has_filter'],
  1871.             'has_more' => $searchedResults['has_more'],
  1872.             'start_num' => $nStartNum           
  1873.         ));
  1874.     }
  1875.     
  1876.     public function getSearchedClass($locale$request)
  1877.     {
  1878.         $search = new PostgresSearch();
  1879.         $em $this->getDoctrine()->getManager();
  1880.         $search->setManager($em);
  1881.         return $search->getClassSearchResults($locale$request);
  1882.     }
  1883.     
  1884.     public function coursepageAction($courseIDRequest $request)
  1885.     {        
  1886.         $aCourse $this->getCourseInfo($courseID);         
  1887.         if(empty($aCourse))
  1888.         {
  1889.             $response = new Response();
  1890.             $response->setStatusCode(404);
  1891.             return $this->renderView('no_work_content', array(), $response);
  1892.         }
  1893.         $aLeader $this->getLeadersForCourse($courseID);
  1894.         $aAudience $this->getAudienceForCourse($courseID);    
  1895.         
  1896.         $nTextLength 150;
  1897.         $sDesc $aCourse['full_description'];
  1898.         $sMetaDesc $this->fixWorkText($sDesc);
  1899.           $sMetaDesc $this->getTextWithinLength($sMetaDesc$nTextLength"..."); 
  1900.                               
  1901.         return $this->renderView('course_page', array(     
  1902.             'course_info' => $aCourse,
  1903.             'leader_list' => $aLeader,
  1904.             'audience_list' => $aAudience,
  1905.             'meta_desc' => $sMetaDesc          
  1906.         ));
  1907.     }
  1908.     
  1909.     public function search_sermonAction(Request $request)
  1910.     {            
  1911.         $locale $request->getLocale();
  1912.         $searchedResults = array();
  1913.         $sSearchTerm $request->query->get('searchTerm');  
  1914.         $nStartNum $request->query->get('startnum'); 
  1915.         $nStorehouse $request->query->get('storehouse');     
  1916.         if($sSearchTerm != '')
  1917.         {
  1918.             $searchedResults $this->getSearchedSermon($locale$request);
  1919.         }    
  1920.         else
  1921.         {            
  1922.             $searchedResults $this->getSermonList($nStartNum$request);            
  1923.         }            
  1924.         
  1925.         return $this->renderView('sermon_searched', array(     
  1926.             'searched_sermon' => $searchedResults['results'],
  1927.             'total_record' => $searchedResults['total_record'],
  1928.             'has_more' => $searchedResults['has_more'],
  1929.             'has_filter' => $searchedResults['has_filter'],
  1930.             'start_num' => $nStartNum,
  1931.             'is_storehouse' => $nStorehouse          
  1932.         ));
  1933.     }
  1934.     
  1935.     public function getSearchedSermon($locale$request)
  1936.     {
  1937.         $search = new PostgresSearch();
  1938.         $em $this->getDoctrine()->getManager();
  1939.         $search->setManager($em);
  1940.         return $search->getSermonSearchResults($locale$request);
  1941.     }
  1942.     
  1943.     public function sermonpageAction($sermonIDRequest $request)
  1944.     {        
  1945.         if(!$this->userCanSeeAllSermons($request))
  1946.         {
  1947.             $nTypeID $this->getSermonTypeID($sermonID);
  1948.             if($nTypeID != $this->LNCSERMON_TYPE_ID_PUBLIC)
  1949.             {
  1950.                 $bCanView false;
  1951.                 if($this->userCanSeeLNCSermons($request) && $nTypeID == $this->LNCSERMON_TYPE_ID_LNC_MEMBER)
  1952.                 {
  1953.                     $bCanView true;
  1954.                 }
  1955.                 
  1956.                 if(!$bCanView)
  1957.                 {
  1958.                     return $this->redirect($this->get('router')->generate('sermons', array()), 301);
  1959.                 }
  1960.             }        
  1961.         }
  1962.     
  1963.         $aSermon $this->getSermonInfo($sermonID);
  1964.         $aAuthor $this->getAuthorsForSermon($sermonID);
  1965.         $aTopic $this->getTopicsForSermon($sermonID);
  1966.         $aSermonRef $this->getSermonRefs($sermonID$request);
  1967.         
  1968.         $nTextLength 150;
  1969.         $sDesc $aSermon['searchsummary'];
  1970.         $sMetaDesc $this->fixWorkText($sDesc);
  1971.           $sMetaDesc $this->getTextWithinLength($sMetaDesc$nTextLength"...");
  1972.        
  1973.         return $this->renderView('sermon_page', array(   
  1974.             'sermon_id' => $sermonID,  
  1975.             'sermon_info' => $aSermon,
  1976.             'author_list' => $aAuthor,
  1977.             'topic_list' => $aTopic,
  1978.             'sermon_ref' => $aSermonRef,
  1979.             'meta_desc' => $sMetaDesc        
  1980.         ));
  1981.     }
  1982.     
  1983.     public function sermonstorehousepageAction($sermonIDRequest $request)
  1984.     {   
  1985.         $nTypeID $this->getSermonTypeID($sermonID);
  1986.         if($nTypeID != $this->LNCSERMON_TYPE_ID_PUBLIC)
  1987.         {            
  1988.             return $this->redirect($this->get('router')->generate('sermon_storehouse', array()), 301);
  1989.         }   
  1990.     
  1991.         $aSermon $this->getSermonInfo($sermonID);
  1992.         $aAuthor $this->getAuthorsForSermon($sermonID);
  1993.         $aTopic $this->getTopicsForSermon($sermonID);
  1994.         $aSermonRef $this->getSermonRefs($sermonID$request);
  1995.         
  1996.         $nTextLength 150;
  1997.         $sDesc $aSermon['searchsummary'];
  1998.         $sMetaDesc $this->fixWorkText($sDesc);
  1999.           $sMetaDesc $this->getTextWithinLength($sMetaDesc$nTextLength"...");
  2000.        
  2001.         return $this->renderView('sermon_storehouse_page', array(   
  2002.             'sermon_id' => $sermonID,  
  2003.             'sermon_info' => $aSermon,
  2004.             'author_list' => $aAuthor,
  2005.             'topic_list' => $aTopic,
  2006.             'sermon_ref' => $aSermonRef,
  2007.             'meta_desc' => $sMetaDesc        
  2008.         ));
  2009.     }
  2010.     
  2011.     /**
  2012.      * Show chapter list on a popup
  2013.      */
  2014.     public function selectworkcompareAction($workID$translationUrl$translationUrl2$divisionUrl$passageNumberRequest $request)
  2015.     {         
  2016.       $data['translation_url'] = $translationUrl;
  2017.       $data['translation_url2'] = $translationUrl2
  2018.       $data['division_url'] = $divisionUrl
  2019.       $data['passage_number'] = $passageNumber;      
  2020.       $data['work_id'] = $workID;   
  2021.                    
  2022.       $data['translations_by_language'] = $this->getWorkTranslationsByLanguage($workID);    
  2023.                                    
  2024.       return $this->renderView('selectworkcompare'$data);
  2025.     }
  2026.     
  2027.     /**
  2028.      * Show translation list on a popup
  2029.      */
  2030.     public function selectworktranslationAction($workID$translationUrl$passageNumber$passageOrderRequest $request)
  2031.     {    
  2032.           $data['translation_url'] = $translationUrl;          
  2033.           $data['passage_number'] = $passageNumber;  
  2034.           $data['passage_order'] = $passageOrder;    
  2035.           $data['work_id'] = $workID;   
  2036.                        
  2037.           $data['translations_by_language'] = $this->getWorkTranslationsByLanguageAllType($workID);
  2038.                    
  2039.           return $this->renderView('selectworktranslation'$data);
  2040.     }
  2041.     
  2042.     /**
  2043.      * Show translation list on a popup
  2044.      */
  2045.     public function selectworkpassageAction($workID$translationUrlRequest $request)
  2046.     {    
  2047.           $data['translation_url'] = $translationUrl;                       
  2048.           $data['passage_list'] = $this->getWorkPassages($workID);
  2049.           $data['work_id'] = $workID;
  2050.                    
  2051.           return $this->renderView('selectpassage'$data);
  2052.     }
  2053.     
  2054.     /**
  2055.      * Show work list on a popup
  2056.      */
  2057.     public function selectworkAction($workID$translationID$languageIDRequest $request)
  2058.     {    
  2059.           $data['translation_id'] = $translationID;          
  2060.           $data['language_id'] = $languageID;      
  2061.           $data['work_id'] = $workID;   
  2062.                        
  2063.           $data['swedenborg_works'] = $this->getCategorizedSwedenborgWorksForTranslation($request$translationID$languageID);
  2064.                    
  2065.           return $this->renderView('selectwork'$data);
  2066.     }
  2067.     
  2068.     /**
  2069.      * Show translation list on a popup
  2070.      */
  2071.     public function selectsearchtranslationAction($workID$translationID$passageIDRequest $request)
  2072.     {    
  2073.           $data['translation_id'] = $translationID;          
  2074.           $data['passage_id'] = $passageID;      
  2075.           $data['work_id'] = $workID;   
  2076.            
  2077.           $nLanguageID $this->getLanguageIDByTranslation($translationID); 
  2078.           if($nLanguageID != $this->LANGUAGE_ID_LATIN)          
  2079.             $request->getSession()->set('last_quickview_language_id'$nLanguageID); 
  2080.                   
  2081.           $sLanguages "";
  2082.           if($nLanguageID == $this->LANGUAGE_ID_LATIN)            
  2083.             $sLanguages $nLanguageID ", " $request->getSession()->get('last_quickview_language_id');           
  2084.           else
  2085.             $sLanguages $nLanguageID ", " $this->LANGUAGE_ID_LATIN;
  2086.                                  
  2087.           $data['translations_by_language'] = $this->getWorkTranslationsByLanguage($workID$sLanguages);
  2088.                    
  2089.           return $this->renderView('selectsearchtranslation'$data);
  2090.     }
  2091.     
  2092.     /**
  2093.      * Show translation list on a popup
  2094.      */
  2095.     public function selectstorytranslationforworkAction($workID$storyID$translationIDRequest $request)
  2096.     {    
  2097.       $locale $request->getLocale();
  2098.       $data['work_id'] = $workID;  
  2099.       $data['translation_id'] = $translationID;       
  2100.       $data['story_id'] = $storyID;   
  2101.                            
  2102.       $data['story_explanations'] = $this->getWorkListForStory($locale$storyID);
  2103.                
  2104.       return $this->renderView('selectstorytranslationforwork'$data);
  2105.     }
  2106.     
  2107.     public function search_conceptAction(Request $request)
  2108.     {            
  2109.         $locale $request->getLocale();
  2110.         $searchedResults = array();
  2111.         $sSearchTerm $request->query->get('searchTerm');  
  2112.         $nStartNum $request->query->get('startnum');      
  2113.         if($sSearchTerm != '')
  2114.         {
  2115.             //$searchedResults = $this->getSearchedConcept($locale, $request);
  2116.             $searchedResults $this->getSearchedListByCategory($this->CATEGORY_ID_CONCEPT$locale$request);
  2117.         }    
  2118.         else
  2119.         {            
  2120.             //$searchedResults = $this->getConceptList($nStartNum, $request);
  2121.             $searchedResults $this->getAllListByCategory($this->CATEGORY_ID_CONCEPT$locale$request);            
  2122.         }            
  2123.         
  2124.         return $this->renderView('concept_searched', array(     
  2125.             'searched_results' => $searchedResults           
  2126.         ));
  2127.     }    
  2128.     
  2129.     public function featured_conceptsAction(Request $request)
  2130.     {                   
  2131.         $this->onloadPage($request);
  2132.         $locale $request->getLocale();
  2133.         $featuredList $this->getFeaturedListByCategory($this->CATEGORY_ID_CONCEPT$locale9false);
  2134.         if(empty($featuredList))
  2135.             $featuredList $this->getFeaturedListByCategory($this->CATEGORY_ID_CONCEPT$locale9true);
  2136.         return $this->renderView('concepts_featured', array(     
  2137.             'featured_records' => $featuredList            
  2138.         ));
  2139.     }    
  2140.     
  2141.     /**
  2142.      * Show translation list on a popup
  2143.      */
  2144.     public function selectbiblebooksummaryAction($translationID$BibleBookIDForSummaryRequest $request)
  2145.     {           
  2146.       $data['translation_id'] = $translationID;                               
  2147.       $data['book_summaries'] = $this->getBibleBookSummaryList($BibleBookIDForSummary);
  2148.                
  2149.       return $this->renderView('selectbiblebooksummary'$data);
  2150.     }
  2151.     
  2152.     /**
  2153.      * Show translation list on a popup
  2154.      */
  2155.     public function selectbiblechaptersummarytranslationAction($translationIDRequest $request)
  2156.     {           
  2157.       $data['translation_id'] = $translationID;                               
  2158.       $data['chapter_summary_translations'] = $this->getChapterExplanationsForPopup($translationID);
  2159.                
  2160.       return $this->renderView('selectbiblechaptersummarytranslation'$data);
  2161.     }
  2162.     
  2163.     public function selectbiblestudyAction(Request $request)
  2164.     {       
  2165.       $locale $request->getLocale();  
  2166.       //$sSearchText = $request->query->get('st');
  2167.                        
  2168.       $data['biblestudy_data'] = $this->getBibleStudyList($locale); 
  2169.                     
  2170.       return $this->renderView('selectbiblestudy'$data);
  2171.     } 
  2172.     
  2173.     /**
  2174.      * Show translation list on a popup
  2175.      */
  2176.     public function selectbibleversesummaryAction($workID$chapterID$languageIDRequest $request)
  2177.     {                  
  2178.           $data['work_id'] = $workID;     
  2179.           $data['verse_explanations'] = $this->getVerseExplanations($chapterID$languageID$request);
  2180.                    
  2181.           return $this->renderView('selectbibleversesummary'$data);
  2182.     }
  2183.     
  2184.     /**
  2185.      * Show work list on a popup for search
  2186.      */
  2187.     public function selectworksforsearchAction(Request $request)
  2188.     {    
  2189.           $nLanguageID $request->query->get('lang');    
  2190.                        
  2191.           $data['swedenborg_works'] = $this->getCategorizedSwedenborgWorksForTranslation($requestnull$nLanguageID);
  2192.                    
  2193.           return $this->renderView('selectworksforsearch'$data);
  2194.     }
  2195.     
  2196.     /**
  2197.      * Show work translation list on a popup for search
  2198.      */
  2199.     public function selectworktranslationsforsearchAction(Request $request)
  2200.     {    
  2201.           $nLanguageID $request->query->get('lang'); 
  2202.           $sSelectedWorkIDs $request->query->get('selectedworkids');  
  2203.           $sWorkType $request->query->get('worktype'); 
  2204.                        
  2205.           $data['work_translations'] = $this->getSWWorkTranslations($sSelectedWorkIDs$nLanguageID$sWorkType);
  2206.                    
  2207.           return $this->renderView('selectworktranslationsforsearch'$data);
  2208.     }
  2209.     
  2210.     /**
  2211.      * Show work translation list on a popup for reading plan step
  2212.      */
  2213.     public function selectworktranslationforreadingplanAction(Request $request)
  2214.     {    
  2215.           $nWorkID $request->query->get('wid'); 
  2216.           $sTranslationUrl $request->query->get('turl');
  2217.           $sReadingPlanUrl $request->query->get('rpurl'); 
  2218.           $nStepOrder $request->query->get('step'); 
  2219.           $nSW $request->query->get('sw');  
  2220.           
  2221.           $data['work_id'] = $nWorkID;
  2222.           $data['translation_url'] = $sTranslationUrl;          
  2223.           $data['readingplan_url'] = $sReadingPlanUrl;  
  2224.           $data['step_order'] = $nStepOrder
  2225.                                  
  2226.           $data['translations_by_language'] = $this->getWorkTranslationsByLanguageAllType($nWorkID);
  2227.                    
  2228.           return $this->renderView('selectworktranslationforreadingplan'$data);
  2229.     }
  2230.     
  2231.     /**
  2232.      * Show work translation list on a popup for reading plan step
  2233.      */
  2234.     public function selectexplanationtranslationforreadingplanAction(Request $request)
  2235.     {    
  2236.           $nWorkID $request->query->get('wid'); 
  2237.           $sTranslationUrl $request->query->get('turl');
  2238.           $sReadingPlanUrl $request->query->get('rpurl'); 
  2239.           $nStepOrder $request->query->get('step');   
  2240.           
  2241.           $data['work_id'] = $nWorkID;
  2242.           $data['translation_url'] = $sTranslationUrl;          
  2243.           $data['readingplan_url'] = $sReadingPlanUrl;  
  2244.           $data['step_order'] = $nStepOrder
  2245.                                  
  2246.           $data['translations_by_language'] = $this->getWorkTranslationsByLanguageAllType($nWorkID);
  2247.                    
  2248.           return $this->renderView('selectexplanationtranslationforreadingplan'$data);
  2249.     }
  2250.     
  2251.     /**
  2252.      * Show work list on a popup
  2253.      */
  2254.     public function selectbiblechaptersummaryworkAction($translationIDRequest $request)
  2255.     {           
  2256.       $aTrans $this->getWorkTranslationData($translationID);        
  2257.       $nWorkID $aTrans['work_id'];
  2258.       $data['translation_id'] = $translationID;     
  2259.       $data['work_id'] = $nWorkID;                              
  2260.       $data['chapter_summary_works'] = $this->getChapterExplanationWorksForPopup($translationID);
  2261.                
  2262.       return $this->renderView('selectbiblechaptersummarywork'$data);
  2263.     }
  2264.     
  2265.     public function fullviewTranslationPassageAction($passageId$translationIdRequest $request)
  2266.     {        
  2267.            $sSql "select url FROM expositiontranslation where id = " $translationId;
  2268.            
  2269.  //   echo $sSql."<br>";   
  2270.        $sUrl $this->getSingleData($sSql);
  2271.        
  2272.        $sLink $this->get('router')->generate('exposition_translation_passage', array(
  2273.                         'translationUrl' => $sUrl,
  2274.                         'passageId' => $passageId                      
  2275.                     ));
  2276.             
  2277.        if(!empty($sLink))
  2278.                return $this->redirect($sLink301);            
  2279.        else
  2280.             return $this->redirect("/"301);
  2281.     }
  2282.     
  2283.     public function projecthubAction(Request $request)
  2284.     {            
  2285.         $locale $request->getLocale(); 
  2286.         $data = array(                         
  2287.         );
  2288.         $this->setCurrentUrl($request); 
  2289.         $this->onloadPage($request);
  2290.         return $this->renderView('projecthub'$data);
  2291.     }
  2292.     
  2293.     public function search_projectAction(Request $request)
  2294.     {            
  2295.         $locale $request->getLocale();
  2296.         $searchedResults = array();
  2297.         $sSearchTerm $request->query->get('searchTerm');  
  2298.         $nStartNum $request->query->get('startnum');      
  2299.         if($sSearchTerm != '')
  2300.         {
  2301.             $searchedResults $this->getSearchedProject($locale$request);
  2302.         }    
  2303.         else
  2304.         {            
  2305.             $searchedResults $this->getExplanationList($nStartNum$locale$request);
  2306.         }            
  2307.         
  2308.         return $this->renderView('project_searched', array(     
  2309.             'searched_project' => $searchedResults,
  2310.             'start_num' => $nStartNum           
  2311.         ));
  2312.     }
  2313.         
  2314.     public function getSearchedProject($locale$request)
  2315.     {        
  2316.         $search = new PostgresSearch();
  2317.         $em $this->getDoctrine()->getManager();
  2318.         $search->setManager($em);
  2319.         $sCategoryId 52;
  2320.         return $search->getCategorySearchResults($sCategoryId$locale$request);
  2321.     }
  2322.     
  2323.     public function featured_projectsAction(Request $request)
  2324.     {                   
  2325.         $this->onloadPage($request);
  2326.         $locale $request->getLocale();
  2327.         $featuredList $this->getFeaturedListByCategory($this->CATEGORY_ID_PROJECT$locale9false);
  2328.         if(empty($featuredList))
  2329.             $featuredList $this->getFeaturedListByCategory($this->CATEGORY_ID_PROJECT$locale9true);
  2330.         return $this->renderView('projects_featured', array(     
  2331.             'featured_records' => $featuredList            
  2332.         ));
  2333.     } 
  2334. }