src/NCBS/WebsiteBundle/Controller/DefaultController.php line 596

Open in your IDE?
  1. <?php
  2. namespace NCBS\WebsiteBundle\Controller;
  3. use Symfony\Component\HttpFoundation\Request;
  4. //s33: what else because constants?
  5. // use Symfony\Bundle\FrameworkBundle\Controller\Controller as SymCon;
  6. // class DefaultController extends SymCon // NCBSWController
  7. // cant, because:  consts 
  8. use Symfony\Component\Yaml\Yaml;
  9. class DefaultController extends NCBSWController
  10. {
  11.     protected $prefix 'Default';
  12.     
  13.     public function indexAction(Request $request)
  14.     {    
  15.         $locale $request->getLocale();
  16.         $this->onloadPage($request);
  17.         $bibleTranslationUrl $this->DEFAULT_BIBLE_VERSION;
  18.         $nBibleTransID $request->getSession()->get('current_bible_translation_id');
  19.         if($nBibleTransID != '')
  20.         {   
  21.                $bibleTranslation $this->getBibleTranslationByID($nBibleTransID);
  22.                if(!empty($bibleTranslation))
  23.                    $bibleTranslationUrl $bibleTranslation['url'];
  24.         } 
  25.         else
  26.         {
  27.             $bibleTranslation $this->getDefaultBibleTranslationByLocale($locale);
  28.             if(!empty($bibleTranslation))
  29.                    $bibleTranslationUrl $bibleTranslation['url'];
  30.         } 
  31.         
  32.         $nFeaturedNum 6;
  33.         $nSeeMore $request->query->get('mfc');
  34.         $bSeeMore = ($nSeeMore == 1);
  35.         if($bSeeMore)
  36.             $nFeaturedNum += 20;
  37.         
  38.         $featureData $this->getFeaturedContentList($locale$nFeaturedNumfalse); 
  39.         if(empty($featureData))
  40.             $featureData $this->getFeaturedContentList($locale$nFeaturedNumtrue);
  41.     
  42.         $indexData = array(
  43.             'feature_data' => $featureData,           
  44.             'bible_translation_url' => $bibleTranslationUrl,
  45.             'see_more' => $bSeeMore   
  46.         );
  47.         
  48.         $request->getSession()->set('searched_bible_story_list', array());
  49.         $request->getSession()->set('searched_topic_list', array());
  50.         
  51.         return $this->renderView('index'$indexData);
  52.     }
  53.     public function aboutAction(Request $request)
  54.     {
  55.         $this->setCurrentUrl($request); 
  56.         $this->onloadPage($request);
  57.         return $this->renderView('about', array());
  58.     }
  59.     public function no_contentAction(Request $request)
  60.     {
  61.         $this->setCurrentUrl($request); 
  62.         $this->onloadPage($request);
  63.         return $this->renderView('no_content', array());
  64.     }
  65.     public function the_planAction(Request $request)
  66.     {
  67.         $this->setCurrentUrl($request); 
  68.         $this->onloadPage($request);
  69.         return $this->renderView('the_plan', array());
  70.     }
  71.     public function mobile_appAction(Request $request)
  72.     {
  73.         $this->setCurrentUrl($request); 
  74.         $this->onloadPage($request);
  75.         return $this->renderView('mobile_app', array());
  76.     }
  77.     public function biblenavtestAction(Request $request)
  78.     {
  79.         $this->setCurrentUrl($request); 
  80.         $this->onloadPage($request);
  81.         return $this->renderView('biblenavtest', array());
  82.     }
  83.     public function swedenborg_nav_widgetAction(Request $request)
  84.     {
  85.         $this->setCurrentUrl($request); 
  86.         $this->onloadPage($request);
  87.         return $this->renderView('swedenborg_nav_widget', array());
  88.     }
  89.     public function swedenborg_testAction(Request $request)
  90.     {
  91.         $this->setCurrentUrl($request); 
  92.         $this->onloadPage($request);
  93.         $locale $request->getLocale();
  94.         $nLocaleLanguageID $this->getLanguageIDByShortCode($locale);
  95.         
  96.         $nSelectedLangID $request->query->get('l');
  97.         
  98.         return $this->renderView('swedenborg_test', array(          
  99.             'works' => $this->getSwedenborgWorks($request$nLocaleLanguageID$nSelectedLangID),
  100.             'languages' => $this->getSwedenborgWorkLanguages($request),
  101.             'selected_language_id' => $nSelectedLangID,
  102.             'search_domain' => 'w'
  103.         ));
  104.     }
  105.     public function new_church_mapAction(Request $request)
  106.     {
  107.         $this->setCurrentUrl($request); 
  108.         $this->onloadPage($request);
  109.         return $this->renderView('new_church_map', array());
  110.     }
  111.     public function bible_studiesAction(Request $request)
  112.     {
  113.         $this->setCurrentUrl($request); 
  114.         $this->onloadPage($request);
  115.         return $this->renderView('bible_studies', array());
  116.     }
  117.     public function newsAction(Request $request)
  118.     {
  119.         $this->setCurrentUrl($request); 
  120.         $this->onloadPage($request);
  121.         return $this->renderView('news', array());
  122.     }
  123.     public function site_searchAction(Request $request)
  124.     {
  125.         $this->setCurrentUrl($request); 
  126.         $this->onloadPage($request);
  127.         return $this->renderView('site_search', array());
  128.     }    
  129.     public function neosearchAction(Request $request)
  130.     {
  131.         $this->setCurrentUrl($request); 
  132.         $this->onloadPage($request);
  133.         return $this->renderView('neosearch', array());
  134.     }
  135.     public function donateAction(Request $request)
  136.     {
  137.         $this->setCurrentUrl($request); 
  138.         $this->onloadPage($request);
  139.         return $this->renderView('donate', array());
  140.     }
  141.     public function donation_thank_youAction()
  142.     {
  143.         return $this->renderView('donation_thank_you', array());
  144.     }    
  145.     public function contactAction(Request $request)
  146.     {
  147.         return $this->renderView('contact', array());
  148.     }
  149.     public function resourcesAction(Request $request)
  150.     {
  151.         $this->setCurrentUrl($request); 
  152.         $this->onloadPage($request);
  153.         return $this->renderView('resources', array());
  154.     }
  155.     public function additional_translationsAction(Request $request)
  156.     {
  157.         $this->setCurrentUrl($request); 
  158.         $this->onloadPage($request);
  159.         return $this->renderView('additional_translations', array());
  160.     }
  161.     public function swedenborg_research_toolsAction(Request $request)
  162.     {
  163.         $this->setCurrentUrl($request); 
  164.         $this->onloadPage($request);
  165.         return $this->renderView('swedenborg_research_tools', array());
  166.     }
  167.     public function explanatory_worksAction(Request $request)
  168.     {
  169.         $this->setCurrentUrl($request); 
  170.         $this->onloadPage($request);
  171.         return $this->renderView('explanatory_works', array());
  172.     }
  173.     public function bible_commentaryAction(Request $request)
  174.     {
  175.         $this->setCurrentUrl($request); 
  176.         $this->onloadPage($request);
  177.         return $this->renderView('bible_commentary', array());
  178.     }
  179.     public function swedenborg_glossaryAction(Request $request)
  180.     {
  181.         $this->setCurrentUrl($request); 
  182.         $this->onloadPage($request);
  183.         return $this->renderView('swedenborg_glossary', array());
  184.     }
  185.     public function new_church_lifeAction(Request $request)
  186.     {
  187.         $this->setCurrentUrl($request); 
  188.         $this->onloadPage($request);
  189.         return $this->renderView('new_church_life', array());
  190.     }    
  191.     public function get_involvedAction(Request $request)
  192.     {
  193.         $this->setCurrentUrl($request); 
  194.         $this->onloadPage($request);
  195.         return $this->renderView('get_involved', array());
  196.     }    
  197.     public function partnersAction(Request $request)
  198.     {
  199.         $this->setCurrentUrl($request); 
  200.         $this->onloadPage($request);
  201.         return $this->renderView('partners', array());
  202.     }
  203.     public function terms_of_useAction(Request $request)
  204.     {
  205.         $this->setCurrentUrl($request); 
  206.         $this->onloadPage($request);
  207.         return $this->renderView('terms_of_use', array());
  208.     }
  209.     public function privacy_policyAction(Request $request)
  210.     {
  211.         $this->setCurrentUrl($request); 
  212.         $this->onloadPage($request);
  213.         return $this->renderView('privacy_policy', array());
  214.     }
  215.     public function storeAction(Request $request)
  216.     {
  217.         $this->setCurrentUrl($request); 
  218.         $this->onloadPage($request);
  219.         return $this->renderView('store', array());
  220.     }         
  221.     public function explanation_formAction(Request $request)
  222.     {
  223.         $this->setCurrentUrl($request); 
  224.         $this->onloadPage($request);
  225.         return $this->renderView('explanation_form', array());
  226.     } 
  227.     public function spiritual_topic_formAction(Request $request)
  228.     {
  229.         $this->setCurrentUrl($request); 
  230.         $this->onloadPage($request);
  231.         return $this->renderView('spiritual_topic_form', array());
  232.     }
  233.     public function bible_story_formAction(Request $request)
  234.     {
  235.         $this->setCurrentUrl($request); 
  236.         $this->onloadPage($request);
  237.         return $this->renderView('bible_story_form', array());
  238.     }
  239.     public function mailing_listAction(Request $request)
  240.     {
  241.         $this->setCurrentUrl($request); 
  242.         $this->onloadPage($request);
  243.         return $this->renderView('mailing_list', array());
  244.     }
  245.     public function daily_verseAction(Request $request)
  246.     {
  247.         $this->setCurrentUrl($request); 
  248.         $this->onloadPage($request);
  249.         $sText $this->getDailyVerse($request);   
  250.         $data = array(
  251.                'daily_verse_text' => $sText            
  252.         );
  253.         return $this->renderView('daily_verse'$data);
  254.     }
  255. /*    public function q_and_aAction(Request $request)
  256.     {
  257.         $this->setCurrentUrl($request); 
  258.         $this->onloadPage($request);
  259.         return $this->renderView('q_and_a', array());
  260.     } */
  261.     public function classes_and_groupsAction(Request $request)
  262.     {
  263.         $this->setCurrentUrl($request); 
  264.         $this->onloadPage($request);
  265.         $aLanguage $this->getLanguageListForClassHub();   
  266.         $data = array(
  267.                'language_list' => $aLanguage            
  268.         );
  269.         return $this->renderView('classes_and_groups'$data);
  270.     }
  271.     public function noteAction($status_code)
  272.     {        
  273.         $noteData = array(
  274.             'status_code' => $status_code        
  275.         );
  276.         return $this->renderView('note'$noteData);
  277.     }   
  278.     
  279.     public function work_translationAction(Request $request)
  280.     {      
  281.         $this->setCurrentUrl($request); 
  282.         $this->onloadPage($request);
  283.         return $this->renderView('work_translation', array());
  284.     }  
  285.     
  286.     public function conceptsAllAction(Request $request)
  287.     {      
  288.         $this->setCurrentUrl($request); 
  289.         $this->onloadPage($request);
  290.         return $this->renderView('all_concepts', array());
  291.     } 
  292.     
  293.     public function loginAction(Request $request)
  294.     {          
  295.         $this->onloadPage($request);
  296.           return $this->goToLoginPage($request);
  297.     } 
  298.     
  299.     public function registerAction(Request $request)
  300.     {
  301.         $this->onloadPage($request);
  302.         return $this->renderView('register', array());
  303.     }
  304.     
  305.     public function forgotpwdAction(Request $request)
  306.     {
  307.         $this->onloadPage($request);
  308.         return $this->renderView('forgotpwd', array());
  309.     }
  310.     
  311.     public function resendactivationcodeAction(Request $request)
  312.     {
  313.         $this->onloadPage($request);
  314.         return $this->renderView('resendactivationcode', array());
  315.     }
  316.     
  317.     public function changepwdAction(Request $request)
  318.     {
  319.         $this->onloadPage($request);
  320.         return $this->renderView('changepwd', array());
  321.     }
  322.     
  323.     public function get_session_from_admin_siteAction($user_id$user_level$user_lang_id$user_bible_trans_idRequest $request)
  324.     {      
  325.         $audio_rate = @$_GET['audio_rate'];
  326.         if(empty($audio_rate))
  327.             $audio_rate 1.0;
  328.         
  329.         $this->setsessionswhenlogin($user_id$user_level$user_lang_id$user_bible_trans_id$audio_rate$request);
  330.         return $this->renderView('blankpage', array());       
  331.     } 
  332.     
  333.     public function reset_session_from_admin_siteAction(Request $request)
  334.     {      
  335.         self::resetPortalSession($request);
  336.         return $this->renderView('blankpage', array());       
  337.     } 
  338.     
  339.     public function myprofileAction(Request $request)
  340.     {     
  341.         //$this->setCurrentUrl($request); 
  342.         $this->onloadPage($request);
  343.         if($this->getCurrUserID($request) == '')
  344.         {
  345.             return $this->goToLoginPage($request);
  346.         } 
  347.         return $this->renderView('myprofile', array());       
  348.     } 
  349.     
  350.     public function mypreferenceAction(Request $request)
  351.     {     
  352.         //$this->setCurrentUrl($request); 
  353.         $this->onloadPage($request);        
  354.           if($this->getCurrUserID($request) == '')
  355.         {
  356.             return $this->goToLoginPage($request);
  357.         }        
  358.         return $this->renderView('mypreference', array());       
  359.     } 
  360.     
  361.     public function bookmarkAction(Request $request)
  362.     {             
  363.         //$this->setCurrentUrl($request); 
  364.         $this->onloadPage($request);
  365.         if($this->getCurrUserID($request) == '')
  366.         {
  367.             return $this->goToLoginPage($request);
  368.         } 
  369.         return $this->renderView('mybookmark', array());
  370.     }
  371.     
  372.     public function portal_homeAction()
  373.     {     
  374.         $frameData = array(
  375.             'file_name' => 'homepage'        
  376.         );
  377.         return $this->renderView('frame'$frameData);
  378.     }
  379.     
  380.     public function logoutAction(Request $request)
  381.     {   
  382.         $sCurrentPageUrl $this->getCurrentUrl($request);     
  383.         self::resetPortalSession($request);         
  384.         $frameData = array(
  385.             'file_name' => 'sc_logout'
  386.             'current_url' => $sCurrentPageUrl      
  387.         );
  388.         return $this->renderView('frame_logout'$frameData);
  389.     }
  390.             
  391.     public function resetPortalSession($request)
  392.     {     
  393.         $request->getSession()->set("user_id""");  
  394.         $request->getSession()->set("user_level"""); 
  395.         $request->getSession()->set("current_language""");
  396.         $request->getSession()->set("current_bible_translation_id""");
  397.         $request->getSession()->set("user_receive_verse_of_day""");
  398.         $request->getSession()->set("audio_rate""");    
  399.     }
  400.     
  401.     public function mynoteAction(Request $request)
  402.     {                    
  403.     //    $this->setCurrentUrl($request); 
  404.         $this->onloadPage($request);
  405.         if($this->getCurrUserID($request) == '')
  406.         {
  407.             return $this->goToLoginPage($request);
  408.         } 
  409.         
  410.         $args = @$_SERVER['QUERY_STRING'];
  411.         if(!empty($args)) 
  412.         {                
  413.             $args '?'.$args;                   
  414.         } 
  415.         $frameData = array(
  416.             'url_param' => $args      
  417.         );
  418.         
  419.         return $this->renderView('mynote'$frameData);
  420.     }
  421.     
  422.     public function mysubjectAction(Request $request)
  423.     {                    
  424.         //$this->setCurrentUrl($request); 
  425.         $this->onloadPage($request);
  426.         if($this->getCurrUserID($request) == '')
  427.         {
  428.             return $this->goToLoginPage($request);
  429.         } 
  430.              
  431.         $frameData = array(                
  432.         );
  433.         
  434.         return $this->renderView('mysubject'$frameData);
  435.     }
  436.     
  437.     public function searchwordsAction(Request $request)
  438.     {     
  439.         $this->setCurrentUrl($request); 
  440.         $this->onloadPage($request);
  441.         $frameData = array(
  442.             'file_name' => 'searchword'        
  443.         );
  444.         return $this->renderView('searchwords'$frameData);
  445.     }
  446.     
  447.     public function swedenborgworkAction(Request $request)
  448.     {     
  449.         $this->setCurrentUrl($request); 
  450.         $this->onloadPage($request);
  451.         $frameData = array(
  452.             'file_name' => 'vexpositiontransforpubliclist'        
  453.         );
  454.         return $this->renderView('frame_works_in_language'$frameData);
  455.     }
  456.     
  457.     public function swedenborgglossaryAction(Request $request)
  458.     {     
  459.         $this->setCurrentUrl($request); 
  460.         $this->onloadPage($request);
  461.         $frameData = array();
  462.         return $this->renderView('swedenborg_glossary'$frameData);
  463.     } 
  464.     
  465.     public function myreadingplanAction(Request $request)
  466.     {     
  467.         //$this->setCurrentUrl($request); 
  468.         $this->onloadPage($request);
  469.         if($this->getCurrUserID($request) == '')
  470.         {
  471.             return $this->goToLoginPage($request);
  472.         } 
  473.         return $this->renderView('myreadingplan', array());       
  474.     }    
  475.     
  476.     public function testAction(Request $request)
  477.     {   
  478.         $this->onloadPage($request);    
  479.         $indexData = array(
  480.             'user_agent' => @$_SERVER['HTTP_USER_AGENT'],
  481.             'is_mobile' => $this->isOnMobile()
  482.         );
  483.                             
  484. /*        $aReplace = array(
  485.                 '_8100_' => "Test Book",
  486.                 '_8210_' => "2",
  487.                 '_8220_' => "6"
  488.             );    
  489.         
  490.         $indexData['range_name2'] = $this->ui_string_replace($request->getSession()->get('ui_str')["bible.chapternav.bookchapterrange"], $aReplace);  */
  491.             
  492.         return $this->renderView('test'$indexData);
  493.     }
  494.     
  495.     public function explainchapterAction(Request $request)
  496.     {                    
  497.         $this->setCurrentUrl($request); 
  498.         $this->onloadPage($request);
  499.         if($this->getCurrUserID($request) == '')
  500.         {
  501.             return $this->goToLoginPage($request);
  502.         } 
  503.              
  504.         $frameData = array(                
  505.         );
  506.         
  507.         return $this->renderView('explainchapter'$frameData);
  508.     }
  509.     
  510.     public function loginredirectAction($user_id$user_level$user_lang_id$user_bible_trans_id$signed_up_verse_of_dayRequest $request)
  511.     {            
  512.         //$nUserID = $request->getSession()->get('user_id'); 
  513.         if($user_id != '')
  514.         {
  515.             $audio_rate = @$_GET['audio_rate'];
  516.             if(empty($audio_rate))
  517.                 $audio_rate 1.0;
  518.             
  519.             $this->setsessionswhenlogin($user_id$user_level$user_lang_id$user_bible_trans_id$audio_rate$request);
  520.             
  521.             if($signed_up_verse_of_day == 1)
  522.             {
  523.                 $request->getSession()->set("user_signed_up_verse_of_day""1");
  524.             }            
  525.         }
  526.                 
  527.         $sFromLogin $request->getSession()->get('from_login');
  528.            if($sFromLogin != '')
  529.            {
  530.                $request->getSession()->set("from_login""");
  531.             $sCurrentPageUrl $this->getCurrentUrl($request);     
  532.                                      
  533.             if($sCurrentPageUrl != '')
  534.             {            
  535.                 $request->getSession()->set("current_page_url""");
  536.                 return $this->redirect($sCurrentPageUrl301); 
  537.             }
  538.         }
  539.         
  540.         return $this->redirect($this->get('router')->generate('homepage', array()), 301); 
  541.     }
  542.     
  543.     public function relatedworkpassagesAction(Request $request)
  544.     {     
  545.         $this->setCurrentUrl($request); 
  546.         $this->onloadPage($request);
  547.         $locale $request->getLocale();
  548.         $nLanguageID $this->getLanguageIDByShortCode($locale); 
  549.         $frameData = array(
  550.             'language_id' => $nLanguageID        
  551.         );
  552.         return $this->renderView('frame_related_passages'$frameData);
  553.     }
  554.     
  555.     public function searchtermsAction(Request $request)
  556.     {     
  557.         $this->setCurrentUrl($request); 
  558.         $this->onloadPage($request);
  559.         $frameData = array(                 
  560.         );
  561.         return $this->renderView('searchterms'$frameData);
  562.     }
  563.     
  564.     public function logoutredirectAction(Request $request)
  565.     {                     
  566.         $sCurrentPageUrl = @$_GET['cu'];             
  567.         if($sCurrentPageUrl != '')
  568.         {                    
  569.             return $this->redirect($sCurrentPageUrl301); 
  570.         }        
  571.         else
  572.             return $this->redirect($this->get('router')->generate('homepage', array()), 301); 
  573.     }
  574.     
  575.     public function explainchaptersumAction($cchapterID$translationIDRequest $request)
  576.     {                    
  577.         $this->setCurrentUrl($request); 
  578.         $this->onloadPage($request);
  579.         if($this->getCurrUserID($request) == '')
  580.         {
  581.             return $this->goToLoginPage($request);
  582.         } 
  583.              
  584.         $frameData = array(    
  585.             'cchapter_id' => $cchapterID,
  586.             'translation_id' => $translationID           
  587.         );
  588.         
  589.         return $this->renderView('explainchaptersum'$frameData);
  590.     }
  591.     
  592.     public function crossrefAction(Request $request)
  593.     {     
  594.         $this->setCurrentUrl($request); 
  595.         $this->onloadPage($request);
  596.         $frameData = array(
  597.                  
  598.         );
  599.         return $this->renderView('frame_cross_ref'$frameData);
  600.     }
  601.     
  602.     public function crossref2Action(Request $request)
  603.     {     
  604.         $this->setCurrentUrl($request); 
  605.         $this->onloadPage($request);
  606.         $frameData = array(
  607.                  
  608.         );
  609.         return $this->renderView('frame_cross_ref2'$frameData);
  610.     }
  611.     
  612.     public function editexplanationAction(Request $request$translationID)
  613.     {       
  614.         $this->onloadPage($request);
  615.         if($this->getCurrUserID($request) == '')
  616.         {
  617.             return $this->goToLoginPage($request);
  618.         } 
  619.              
  620.         $frameData = array(  
  621.             'translation_id_for_update' => $translationID              
  622.         );
  623.         
  624.         return $this->renderView('editexplanation'$frameData);
  625.     }
  626.     
  627.     public function editworkAction(Request $request$translationID$passageNumber)
  628.     {       
  629.         $this->onloadPage($request);
  630.         if($this->getCurrUserID($request) == '')
  631.         {
  632.             return $this->goToLoginPage($request);
  633.         } 
  634.              
  635.         $frameData = array(  
  636.             'translation_id_to_edit' => $translationID,
  637.             'passage_num_to_edit' => $passageNumber              
  638.         );
  639.         
  640.         return $this->renderView('editwork'$frameData);
  641.     }
  642.     
  643.     public function checkuiAction(Request $request$languageID)
  644.     {     
  645.         $locale $request->getLocale();       
  646.         $sLocaleForAlert null;   
  647.         $sUILocaleForTrans $this->getUILocale($languageID);
  648.         if($sUILocaleForTrans != $locale)
  649.             $sLocaleForAlert $sUILocaleForTrans;
  650.         
  651.         $data = array(  
  652.             'locale_for_alert' => $sLocaleForAlert                         
  653.         );
  654.         
  655.         return $this->renderView('checkui'$data);
  656.     }
  657.     
  658.     public function showvideoAction($YoutubeID$ShowTimeInSeconds)
  659.     {        
  660.         $data = array(  
  661.             'youtube_id' => $YoutubeID,
  662.             'show_time_in_seconds' => $ShowTimeInSeconds                        
  663.         );
  664.         return $this->renderView('showvideo'$data);
  665.     }
  666.     
  667.     public function pageredirectAction(Request $request)
  668.     {                     
  669.         $user_id $this->getCurrUserID($request);
  670.         if($user_id != '')
  671.         {
  672.             $bReceive $this->getVerseOfDayStatus($user_id);
  673.             $request->getSession()->set('user_receive_verse_of_day'$bReceive);
  674.             
  675.             $nAudioRate $this->getAudioRate($user_id);
  676.             $request->getSession()->set('current_audio_rate'$nAudioRate);
  677.         }
  678.         
  679.         $sCurrentPageUrl $this->getCurrentUrl($request);        
  680.         if($sCurrentPageUrl != '')
  681.         {                    
  682.             return $this->redirect($sCurrentPageUrl301); 
  683.         }        
  684.         else
  685.             return $this->redirect($this->get('router')->generate('homepage', array()), 301); 
  686.     }
  687.     
  688.     // For the popup form to allow users to ask questions
  689.     public function ask_questionAction(Request $request)
  690.     {        
  691.         return $this->renderView('ask_question', array());
  692.     }
  693.            
  694.     public function set_sessionAction($indexRequest $request)
  695.     {         
  696.         if($index == 1)
  697.         {
  698.             $request->getSession()->set('user_receive_verse_of_day'true);
  699.         }     
  700.         return $this->renderView('blankpage', array());       
  701.     }
  702.     
  703.     public function sermonhubAction(Request $request)
  704.     {
  705.         $this->setCurrentUrl($request); 
  706.         $this->onloadPage($request);
  707.         $aLanguage $this->getLanguageListForSermonHub(); 
  708.         $aTopic $this->getTopicListForSermonHub();
  709.         $aAuthor $this->getAuthorListForSermonHub();  
  710.         $data = array(
  711.                'language_list' => $aLanguage,
  712.                'topic_list' => $aTopic,
  713.                'author_list' => $aAuthor            
  714.         );
  715.         return $this->renderView('sermonhub'$data);
  716.     }
  717.     
  718.     public function sermon_storehouseAction(Request $request)
  719.     {
  720.         //copy front end "Sermons" page to a new page as "Sermons"
  721.         // in the menu (url=sermon-storehouse).
  722.         // new page will only show type=gneral public
  723.         $this->setCurrentUrl($request); 
  724.         $this->onloadPage($request);
  725.         $aLanguage $this->getLanguageListForSermonStorehouse(); 
  726.         $aTopic $this->getTopicListForSermonStorehouse();
  727.         $aAuthor $this->getAuthorListForSermonStorehouse();  
  728.         $data = array(
  729.                'language_list' => $aLanguage,
  730.                'topic_list' => $aTopic,
  731.                'author_list' => $aAuthor            
  732.         );
  733.         return $this->renderView('sermon_storehouse'$data);
  734.     }
  735.     
  736.     public function latin_wordsAction(Request $request)
  737.     {
  738.         $this->setCurrentUrl($request); 
  739.         $this->onloadPage($request);
  740.         return $this->renderView('latin_words', array());
  741.     }
  742.     
  743.     /**
  744.      * Show logged-in menu item list on a popup
  745.      */
  746.     public function selectloggedinmenuAction(Request $request)
  747.     {    
  748.       $data = array();         
  749.       return $this->renderView('selectloggedinmenu'$data);
  750.     }
  751.     
  752.     public function setshowbiblelinksAction($indexRequest $request)
  753.     {    
  754.         $request->getSession()->set('show_bible_links'$index);
  755.         return $this->renderView('blankpage', array());       
  756.     }
  757.     
  758.     public function concepthubAction(Request $request)
  759.     {
  760.         $this->setCurrentUrl($request); 
  761.         $this->onloadPage($request);
  762.         $locale $request->getLocale();
  763.         $nLocaleLanguageID $this->getLanguageIDByShortCode($locale);
  764.         $aLanguage $this->getLanguageListForConceptHub();         
  765.         $data = array(
  766.                'language_list' => $aLanguage,
  767.                'ui_language_id' => $nLocaleLanguageID      
  768.         );
  769.         return $this->renderView('concepthub'$data);
  770.     }
  771.     
  772.     public function unsubscribeAction(Request $request)
  773.     {         
  774.         $this->onloadPage($request);
  775.         $idx $request->query->get('msg');  
  776.         if(empty($idx))
  777.         {
  778.             $sEmail $request->query->get('em');
  779.             if(!empty($sEmail))
  780.             {                
  781.                 $sLink "/dbadmin/unsubscribe.php?em=".$sEmail;
  782.                 return $this->redirect($sLink301);
  783.             }
  784.             else
  785.             {                
  786.                 $idx 2;
  787.             }
  788.         }        
  789.         
  790.         $data = array(
  791.                'unsubscribe_idx' => $idx     
  792.         );
  793.         
  794.         return $this->renderView('unsubscribe'$data);
  795.     }
  796.     
  797.     public function gotowebsiteAction(Request $request)
  798.     {         
  799.         $nUserID $request->getSession()->get('user_id'); 
  800.         $sLink "";
  801.         if($nUserID != '')
  802.         {                            
  803.             $sLink "/";                        
  804.         }
  805.         else
  806.         {
  807.             $sLink "/dbadmin/checklogin.php";
  808.         }    
  809.         
  810.         return $this->redirect($sLink301);        
  811.     }
  812.     
  813.     public function mygroupAction(Request $request)
  814.     {                         
  815.         $this->onloadPage($request);
  816.         if($this->getCurrUserID($request) == '')
  817.         {
  818.             return $this->goToLoginPage($request);
  819.         } 
  820.         
  821.         $args = @$_SERVER['QUERY_STRING'];
  822.         if(!empty($args)) 
  823.         {                
  824.             $args '?'.$args;                   
  825.         } 
  826.         $frameData = array(
  827.             'url_param' => $args      
  828.         );
  829.         
  830.         return $this->renderView('mygroup'$frameData);
  831.     }
  832.     
  833.     public function popup_formAction($typeNameRequest $request)
  834.     {              
  835.         return $this->renderView($typeName, array());
  836.     }   
  837.     
  838.     public function chatbotAction(Request $request)
  839.     {                      
  840.         $locale $request->getLocale();
  841.         $this->setCurrentUrl($request);
  842.         $this->onloadPage($request);
  843.         $nLanguageID $this->getLanguageIDByShortCode($locale);
  844.         $rval = array();
  845.         $rval['text_to_speech'] = $this->getTextToSpeech($nLanguageID);
  846.         if($this->canUseSpeechToText())
  847.         {
  848.             $rval['speech_to_text'] = 1;
  849.             $rval['language_for_speech'] = $this->getLanguageForSpeech($locale);
  850.         }    
  851.         
  852.         // $rval['on_new_window'] = 1;
  853.                 
  854.         return $this->renderView('chatbot'$rval);        
  855.     } 
  856.     
  857.     public function chatbothelpAction(Request $request)
  858.     {         
  859.         return $this->renderView('chatbothelp', array());
  860.     } 
  861.     
  862.     public function chatbotdevAction(Request $request)
  863.     {                  
  864.         $this->onloadPage($request);
  865.         $this->setCurrentUrl($request);
  866.         $locale $request->getLocale();
  867.         $nLanguageID $this->getLanguageIDByShortCode($locale);
  868.         $rval = array();
  869.         $rval['text_to_speech'] = $this->getTextToSpeech($nLanguageID);        
  870.         if($this->canUseSpeechToText())
  871.         {            
  872.             $rval['speech_to_text'] = 1;
  873.             $rval['language_for_speech'] = $this->getLanguageForSpeech($locale);
  874.         }    
  875.             
  876.         return $this->renderView('chatbotdev'$rval);
  877.     }  
  878.     
  879.     public function gotoworkAction(Request $request)
  880.     {
  881.         $nTransID = @$_GET['t'];
  882.         $bTranslation = !empty($nTransID);
  883.         $nWorkID = @$_GET['w'];
  884.         $nPassageNum = @$_GET['p'];
  885.         $nSectionNum = @$_GET['s'];
  886.         $sLanguage = @$_GET['l'];
  887.         $nLanguageID null;
  888.         $sLocale null;
  889.         if(is_numeric($sLanguage))
  890.         {
  891.             $nLanguageID $sLanguage;
  892.             $sSql "select shortcode FROM language where id = " $sLanguage;
  893.             $sLocale $this->getSingleData($sSql);
  894.         }
  895.         else
  896.         {
  897.             $sLocale $sLanguage;
  898.             $nLanguageID $this->getLanguageIDByShortCode($sLocale);
  899.         }
  900.         
  901.         $bValidUrl true;
  902.         if(!$bTranslation && empty($nWorkID)) 
  903.             $bValidUrl false;
  904.             
  905.         if($bValidUrl && $nPassageNum == '')
  906.             $bValidUrl false;
  907.             
  908.         if(!$bValidUrl)
  909.         {
  910.             return $this->redirect("/"301);
  911.         }    
  912.     
  913.         $sOrderStr "";
  914.         $sLocaleForLink "";
  915.         if($sLocale == 'en' || empty($sLocale))
  916.         {        
  917.             
  918.         }
  919.         else
  920.         {
  921.             $sLocaleForLink "/".$sLocale;        
  922.         }    
  923.         
  924.         if(!$bTranslation)
  925.         {
  926.             if($sLocale == 'en' || empty($sLocale))
  927.             {        
  928.                 $sOrderStr "case when language_id="$this->LANGUAGE_ID_ENGLISH " then 1 else 2 end";
  929.             }
  930.             else
  931.             {    
  932.                 $sOrderStr "case when language_id="$nLanguageID " then 1 else case when language_id=" $this->LANGUAGE_ID_ENGLISH " then 2 else 3 end end";
  933.             }
  934.         }
  935.                 
  936.         if($bTranslation)
  937.         {
  938.             if($nPassageNum == 'i')
  939.             {
  940.                 $sSql "select '" $sLocaleForLink "/exposition/translation/' || t.url || '/index' from expositiontranslation t where t.id=".$nTransID;
  941.             }
  942.             else
  943.             {
  944.                 $sSql "select '" $sLocaleForLink "/exposition/translation/' || t.url || '/' || d.url || '/' || p.ordering from expositiontranslation t, expositionwork w, expositionpassage p, expositiondivision d where t.id=".$nTransID." and t.ispublic and t.work_id = w.id and w.ispublic and type_id = " $this->TRANSLATION_TYPE_ID_TEXT " and d.work_id = w.id and p.division_id = d.id and p.swedenborgsection = " $this->dbstr($nPassageNum);
  945.             }
  946.         }
  947.         else
  948.         {
  949.             $sSql "select '" $sLocaleForLink "/exposition/translation/' || t.url || '/' || d.url || '/' || p.ordering from expositiontranslation t, expositionwork w, expositionpassage p, expositiondivision d where t.work_id=".$nWorkID." and t.ispublic and t.work_id = w.id and w.ispublic and type_id = " $this->TRANSLATION_TYPE_ID_TEXT " and d.work_id = w.id and p.division_id = d.id and p.swedenborgsection = " $this->dbstr($nPassageNum) . " order by " $sOrderStr ", islanguagedefault desc limit 1";
  950.         }    
  951.     //    echo $sSql;
  952.         $sUrl $this->getSingleData($sSql);
  953.     
  954.         if(!empty($nSectionNum) && $nSectionNum != 1)
  955.             $sUrl .= "#subsection-0-".$nSectionNum;
  956.                     
  957.     //echo $sUrl;    
  958.         if($sUrl != '')
  959.             return $this->redirect($sUrl301);
  960.         else
  961.         {
  962.             $sUrl2 $sLocaleForLink."/no-content";
  963.             return $this->redirect($sUrl2301);
  964.         }        
  965.     }
  966.     
  967.     public function gotobibleAction(Request $request)
  968.     {                 
  969.         $nCBookID $request->query->get('b'); 
  970.         $nChapternum $request->query->get('c');
  971.         $sVerses $request->query->get('v');
  972.         $nLanguageID $request->query->get('l');
  973.         $nTransID $request->query->get('t');
  974.         $nBookID $request->query->get('nb');        
  975.         $sSql "select shortcode FROM language where id = " $nLanguageID;
  976.         $sLocale $this->getSingleData($sSql);
  977.         $bFullChapter = (empty($sVerses));
  978.         $nVerseNum1 "";
  979.         $nVerseNum2 "";
  980.         if(!$bFullChapter)
  981.         {
  982.             $aVerse explode("-"$sVerses);
  983.             if(count($aVerse) > 1)
  984.             {
  985.                 $nVerseNum2 $aVerse[1];
  986.             }
  987.             
  988.             $nVerseNum1 $aVerse[0];    
  989.         }
  990.                         
  991.         $sOrderStr "";
  992.         $sLocaleForLink "";
  993.         if(!empty($sLocale) && $sLocale != 'en')        
  994.         {
  995.             $sLocaleForLink "/".$sLocale;        
  996.         }
  997.         
  998.         if(!empty($nBookID))
  999.         {
  1000.             $sSql "";
  1001.             if($bFullChapter)
  1002.                {
  1003.                    $sSql .= "select '" $sLocaleForLink "/bible/' || t.url || '/' || cb.url || '/' || cc1.ordering FROM canonicalbibleverse cv1, canonicalbiblechapter cc1, biblebook b, bibletranslation t, canonicalbiblebook cb where b.id = " $nBookID " and cc1.ordering = " $nChapternum " and cc1.book_id = cb.id and cv1.chapter_id = cc1.id and b.canonicalization_id = cc1.book_id and b.translation_id = t.id";
  1004.                }
  1005.                else
  1006.                {        
  1007.                 if(empty($nVerseNum2) || $nVerseNum1 == $nVerseNum2)
  1008.                 {            
  1009.                        $sSql .= "select '" $sLocaleForLink "/bible/' || t.url || '/' || cb.url || '/' || cc1.ordering || '/' || cv1.ordering FROM canonicalbibleverse cv1, canonicalbiblechapter cc1, biblebook b, bibletranslation t, canonicalbiblebook cb where b.id = " $nBookID " and cc1.ordering = " $nChapternum " and cv1.ordering = " $nVerseNum1 " and cc1.book_id = cb.id and cv1.chapter_id = cc1.id and b.canonicalization_id = cc1.book_id and b.translation_id = t.id";
  1010.                }
  1011.                else
  1012.                {
  1013.                        $sSql .= "select '" $sLocaleForLink "/bible/' || t.url || '/' || cb.url || '/' || cc1.ordering || '/' || cv1.ordering || '-' || cv2.ordering FROM canonicalbibleverse cv1, canonicalbiblechapter cc1, canonicalbibleverse cv2, canonicalbiblechapter cc2, biblebook b, bibletranslation t, canonicalbiblebook cb where b.id = " $nBookID " and cc1.ordering = " $nChapternum " and cv1.ordering = " $nVerseNum1 " and cv2.ordering = " $nVerseNum2 " and cc2.id = cc1.id and cv1.chapter_id = cc1.id and cv2.chapter_id = cc2.id and cc1.book_id = cb.id and b.canonicalization_id = cc1.book_id and b.translation_id = t.id";               
  1014.                }
  1015.            }
  1016.            
  1017.            $sSql .= " and t.enabled";
  1018.         }
  1019.         else
  1020.         {
  1021.             if(empty($sLocaleForLink))
  1022.             {        
  1023.                 $sOrderStr "case when language_id="$this->LANGUAGE_ID_ENGLISH " then 1 else 2 end";
  1024.             }
  1025.             else
  1026.             {
  1027.                 $sSql1 "select id from language where shortcode = '" trim(str_replace("'""''"$sLocale)) . "'";
  1028.                 $nUILanguageID $this->getSingleData($sSql1);
  1029.             
  1030.                 $sOrderStr "case when language_id="$nUILanguageID " then 1 else case when language_id=" $this->LANGUAGE_ID_ENGLISH " then 2 else 3 end end";
  1031.             }    
  1032.             
  1033.             $sSql "";
  1034.             if($bFullChapter)
  1035.                {
  1036.                    $sSql .= "select '" $sLocaleForLink "/bible/' || t.url || '/' || cb.url || '/' || cc1.ordering FROM canonicalbibleverse cv1, canonicalbiblechapter cc1, biblebook b, bibletranslation t, canonicalbiblebook cb where cb.id = " $nCBookID " and cc1.ordering = " $nChapternum " and cc1.book_id = cb.id and cv1.chapter_id = cc1.id and b.canonicalization_id = cc1.book_id and b.translation_id = t.id";
  1037.                }
  1038.                else
  1039.                {        
  1040.                 if(empty($nVerseNum2) || $nVerseNum1 == $nVerseNum2)
  1041.                 {            
  1042.                        $sSql .= "select '" $sLocaleForLink "/bible/' || t.url || '/' || cb.url || '/' || cc1.ordering || '/' || cv1.ordering FROM canonicalbibleverse cv1, canonicalbiblechapter cc1, biblebook b, bibletranslation t, canonicalbiblebook cb where cb.id = " $nCBookID " and cc1.ordering = " $nChapternum " and cv1.ordering = " $nVerseNum1 " and cc1.book_id = cb.id and cv1.chapter_id = cc1.id and b.canonicalization_id = cc1.book_id and b.translation_id = t.id";
  1043.                }
  1044.                else
  1045.                {
  1046.                        $sSql .= "select '" $sLocaleForLink "/bible/' || t.url || '/' || cb.url || '/' || cc1.ordering || '/' || cv1.ordering || '-' || cv2.ordering FROM canonicalbibleverse cv1, canonicalbiblechapter cc1, canonicalbibleverse cv2, canonicalbiblechapter cc2, biblebook b, bibletranslation t, canonicalbiblebook cb where cb.id = " $nCBookID " and cc1.ordering = " $nChapternum " and cv1.ordering = " $nVerseNum1 " and cv2.ordering = " $nVerseNum2 " and cc2.id = cc1.id and cv1.chapter_id = cc1.id and cv2.chapter_id = cc2.id and cc1.book_id = cb.id and b.canonicalization_id = cc1.book_id and b.translation_id = t.id";               
  1047.                }
  1048.            }
  1049.            
  1050.             $sSql .= " and t.enabled";
  1051.             if(!empty($nTransID))
  1052.             {
  1053.                 $sSql .= " and t.id = " $nTransID;
  1054.             }            
  1055.             else
  1056.             {
  1057.                $sSql .= " order by " $sOrderStr ", languagedefault desc limit 1";
  1058.             }
  1059.        } 
  1060.  
  1061.    // echo $sSql."<br>";   
  1062.        $sLink $this->getSingleData($sSql);
  1063.        if(!empty($sLink))
  1064.                return $this->redirect($sLink301);            
  1065.        else
  1066.             return $this->redirect("/"301);            
  1067.     }
  1068.     
  1069.     public function gotobiblelinkAction(Request $request)
  1070.     {                 
  1071.         $nRefID $request->query->get('linkid'); 
  1072.         $nTLang $request->query->get('tlang'); // Translation Language ID
  1073.         $sLocale $request->query->get('uilang');
  1074.         
  1075.         $sOrderStr "";
  1076.         $sLocaleForLink "";
  1077.         if(!empty($sLocale) && $sLocale != 'en')        
  1078.         {
  1079.             $sLocaleForLink "/".$sLocale;            
  1080.         }    
  1081.         
  1082.         if(empty($nTLang))
  1083.         {        
  1084.             $sOrderStr "case when language_id="$this->LANGUAGE_ID_ENGLISH " then 1 else 2 end";
  1085.         }
  1086.         else
  1087.         {
  1088.             $sOrderStr "case when language_id="$nTLang " then 1 else case when language_id=" $this->LANGUAGE_ID_ENGLISH " then 2 else 3 end end";
  1089.         }
  1090.                     
  1091.         $sSql1 "SELECT startverse_id, endverse_id FROM refbible WHERE container_id = " $nRefID;            
  1092.     //    echo $sSql1."<br>";
  1093.         $aData $this->getRowData($sSql1);        
  1094.         if(!empty($aData))
  1095.         {        
  1096.             $sSql "";
  1097.             $startverse_id trim($aData['startverse_id']); 
  1098.             $endverse_id trim($aData['endverse_id']); 
  1099.             if($startverse_id == $endverse_id)
  1100.             {            
  1101.                    $sSql .= "select '" $sLocaleForLink "/bible/' || t.url || '/' || cb.url || '/' || cc1.ordering || '/' || cv1.ordering FROM canonicalbibleverse cv1, canonicalbiblechapter cc1, biblebook b, bibletranslation t, canonicalbiblebook cb where cv1.id = " $startverse_id " and cv1.chapter_id = cc1.id and cc1.book_id = cb.id and b.canonicalization_id = cc1.book_id and b.translation_id = t.id";
  1102.            }
  1103.            else
  1104.            {      
  1105.                    if($this->isBibleFullChapter($startverse_id$endverse_id))
  1106.                    {
  1107.                        $sSql .= "select '" $sLocaleForLink "/bible/' || t.url || '/' || cb.url || '/' || cc1.ordering FROM canonicalbibleverse cv1, canonicalbiblechapter cc1, biblebook b, bibletranslation t, canonicalbiblebook cb where cv1.id = " $startverse_id " and cv1.chapter_id = cc1.id and cc1.book_id = cb.id and b.canonicalization_id = cc1.book_id and b.translation_id = t.id";
  1108.                    }
  1109.                    else
  1110.                    {      
  1111.                        $sSql .= "select '" $sLocaleForLink "/bible/' || t.url || '/' || cb.url || '/' || cc1.ordering || '/' || cv1.ordering || '-' || cv2.ordering FROM canonicalbibleverse cv1, canonicalbiblechapter cc1, canonicalbibleverse cv2, canonicalbiblechapter cc2, biblebook b, bibletranslation t, canonicalbiblebook cb where cv1.id = " $startverse_id " and cv2.id = " $endverse_id " and cc2 = cc1 and cv1.chapter_id = cc1.id and cv2.chapter_id = cc2.id and cc1.book_id = cb.id and b.canonicalization_id = cc1.book_id and b.translation_id = t.id";
  1112.                    }    
  1113.            }
  1114.            
  1115.            $sSql .= " and t.enabled order by " $sOrderStr ", languagedefault desc limit 1";
  1116.        // echo $sSql."<br>";   
  1117.            $sLink $this->getSingleData($sSql);
  1118.            return $this->redirect($sLink301);
  1119.         }    
  1120.         else
  1121.             return $this->redirect("/"301);        
  1122.     }
  1123.     
  1124.     public function mynotesAction(Request $request)
  1125.     {
  1126.         $nUserID $this->getCurrUserID($request);
  1127.         if(empty($nUserID))
  1128.         {            
  1129.             return $this->redirect($this->get('router')->generate('login', array()), 301);
  1130.         }
  1131.         
  1132.         $this->setCurrentUrl($request); 
  1133.         $this->onloadPage($request);          
  1134.         $data = array(                      
  1135.         );
  1136.         return $this->renderView('mynotes'$data);
  1137.     }
  1138.     
  1139.     public function search_mynoteAction(Request $request)
  1140.     {           
  1141.         $locale $request->getLocale();
  1142.         $searchedResults = array();
  1143.         $sSearchTerm $request->query->get('searchTerm');  
  1144.         $nStartNum $request->query->get('startnum'); 
  1145.         $searchedResults $this->getMynoteList($nStartNum$locale$request);            
  1146.                          
  1147.         return $this->renderView('mynote_searched', array(     
  1148.             'searched_mynote' => $searchedResults['results'],
  1149.             'total_record' => $searchedResults['total_record'],
  1150.             'has_filter' => $searchedResults['has_filter'],
  1151.             'has_more' => $searchedResults['has_more'],
  1152.             'start_num' => $nStartNum           
  1153.         ));
  1154.     }
  1155.     
  1156.     public function mybookmarksAction(Request $request)
  1157.     {
  1158.         $nUserID $this->getCurrUserID($request);
  1159.         if(empty($nUserID))
  1160.         {            
  1161.             return $this->redirect($this->get('router')->generate('login', array()), 301);
  1162.         }
  1163.         $this->setCurrentUrl($request); 
  1164.         $this->onloadPage($request);          
  1165.         $aLinkType $this->getLinkTypeList($request);   
  1166.         $data = array(
  1167.                'linktype_list' => $aLinkType            
  1168.         );
  1169.         return $this->renderView('mybookmarks'$data);
  1170.     }
  1171.     
  1172.     public function search_mybookmarkAction(Request $request)
  1173.     {      
  1174.         $locale $request->getLocale();
  1175.         $searchedResults = array();
  1176.         $sSearchTerm $request->query->get('searchTerm');  
  1177.         $nStartNum $request->query->get('startnum'); 
  1178.         $searchedResults $this->getMybookmarkList($nStartNum$locale$request);            
  1179.                          
  1180.         return $this->renderView('mybookmark_searched', array(     
  1181.             'searched_mybookmark' => $searchedResults['results'],
  1182.             'total_record' => $searchedResults['total_record'],
  1183.             'has_filter' => $searchedResults['has_filter'],
  1184.             'has_more' => $searchedResults['has_more'],
  1185.             'start_num' => $nStartNum           
  1186.         ));
  1187.     }
  1188.     
  1189.     public function chatbot_widgetAction(Request $request)
  1190.     {                      
  1191.         $locale $request->getLocale();
  1192.         $this->onloadPage($request);
  1193.         $nLanguageID $this->getLanguageIDByShortCode($locale);
  1194.         $rval = array();
  1195.         $rval['text_to_speech'] = $this->getTextToSpeech($nLanguageID);
  1196.         if($this->canUseSpeechToText())
  1197.         {
  1198.             $rval['speech_to_text'] = 1;
  1199.             $rval['language_for_speech'] = $this->getLanguageForSpeech($locale);
  1200.         }    
  1201.         
  1202.         $rval['on_new_window'] = 1;
  1203.                 
  1204.         return $this->renderView('chatbot_widget'$rval);        
  1205.     }
  1206.     
  1207.     public function chatbotdevstreamlitAction(Request $request)
  1208.     {                  
  1209.         $this->onloadPage($request);
  1210.         $this->setCurrentUrl($request);    
  1211.         
  1212.         $nUserID $this->getCurrUserID($request);
  1213.         $nUserIDForChat null;
  1214.         if(empty($nUserID))
  1215.         {
  1216.             $nUserIDForChat "t".$this->getRandomNum(); // temporary user ID
  1217.         }
  1218.         else
  1219.         {
  1220.             $nUserIDForChat $this->simpleEncrypt($nUserID);
  1221.         }
  1222.         $bHasSessionHistory false;
  1223.     //    $bHasChatHistory = false;
  1224.         $nSessionID $request->getSession()->get('current_chatbot_session');
  1225.         if(empty($nSessionID))
  1226.         {
  1227.             $nSessionID $this->getRandomNum();
  1228.             $request->getSession()->set('current_chatbot_session'$nSessionID);
  1229.         }
  1230.         else
  1231.         {
  1232.             $bHasSessionHistory $this->hasSessionHistory($nSessionID);            
  1233.         }
  1234.         
  1235.    /*     if(!empty($nUserID))
  1236.         {
  1237.             $bHasChatHistory = $this->hasChatHistory($nUserID);
  1238.         } */
  1239.                 
  1240.         $locale $request->getLocale();
  1241.         $nLanguageID $this->getLanguageIDByShortCode($locale);
  1242.         $rval = array();
  1243.     //    $rval['text_to_speech'] = $this->getTextToSpeech($nLanguageID);
  1244.         $rval['user_id_for_chat'] = $nUserIDForChat;
  1245.         $rval['session_id'] = $nSessionID;
  1246.         $rval['ui_language_id'] = $nLanguageID;
  1247.         $rval['has_session_history'] = $bHasSessionHistory;
  1248.     //    $rval['has_chat_history'] = $bHasChatHistory;
  1249.     /*    if($this->canUseSpeechToText())
  1250.         {
  1251.             $locale = $request->getLocale();
  1252.             $rval['speech_to_text'] = 1;
  1253.             $rval['language_for_speech'] = $this->getLanguageForSpeech($locale);
  1254.         }    */
  1255.             
  1256.         return $this->renderView('chatbotdevstreamlit'$rval);
  1257.     }
  1258.     
  1259.     public function reset_chatsAction(Request $request)
  1260.     {  
  1261.         $nUserForChat = @$_GET['u'];
  1262.         $nLanguageID = @$_GET['l'];
  1263.         $nSessionID $this->getRandomNum();
  1264.         $request->getSession()->set('current_chatbot_session'$nSessionID);
  1265.         $sLink "https://newchristianchatbot.org/?u=" $nUserForChat "&q=&s=" $nSessionID "&q=&l=" $nLanguageID;
  1266.         return $this->redirect($sLink301);       
  1267.     }
  1268.     
  1269.     public function selectchathistoryAction(Request $request)
  1270.     {
  1271.         $nUserIDForChat = @$_GET['u'];
  1272.         $nUILangID = @$_GET['l'];
  1273.         $nUserID $this->getCurrUserID($request); 
  1274.         $aChat $this->getChatHistoryList($nUserID20);
  1275.           $data['chat_history_list'] = $aChat['chat_list'];
  1276.      //     $data['show_more'] = $aChat['show_more'];
  1277.           $data['user_id_for_chat'] = $nUserIDForChat;
  1278.           $data['ui_language_id'] = $nUILangID;
  1279.           return $this->renderView('selectchathistory'$data);
  1280.     }
  1281.     
  1282.     public function set_chat_sessionAction(Request $request)
  1283.     {            
  1284.         $nSessionID = @$_GET['s'];
  1285.           $request->getSession()->set('current_chatbot_session'$nSessionID);
  1286.           return $this->renderView('blankpage', array());
  1287.     }
  1288.     
  1289.     public function goto_chatbot_pageAction(Request $request)
  1290.     {            
  1291.         $nUserForChat = @$_GET['u'];
  1292.         $nLanguageID = @$_GET['l'];
  1293.         $nSessionID = @$_GET['s'];
  1294.         if(empty($nSessionID))
  1295.         {
  1296.             $nSessionID $request->getSession()->get('current_chatbot_session');
  1297.         }
  1298.         else
  1299.         {
  1300.             $request->getSession()->set('current_chatbot_session'$nSessionID);
  1301.         }    
  1302.           $sLink "https://newchristianchatbot.org/?u=" $nUserForChat "&q=&s=" $nSessionID "&q=&l=" $nLanguageID;
  1303.         return $this->redirect($sLink301);
  1304.     }
  1305.     
  1306.     public function mychatAction(Request $request)
  1307.     {                    
  1308.     //    $this->setCurrentUrl($request); 
  1309.         $this->onloadPage($request);
  1310.         if($this->getCurrUserID($request) == '')
  1311.         {
  1312.             return $this->goToLoginPage($request);
  1313.         } 
  1314.         $args = @$_SERVER['QUERY_STRING'];
  1315.         if(!empty($args)) 
  1316.         {                
  1317.             $args '?'.$args;                   
  1318.         } 
  1319.         $frameData = array(
  1320.             'url_param' => $args      
  1321.         );
  1322.         
  1323.         return $this->renderView('mychat'$frameData);
  1324.     }
  1325.     
  1326.     public function open_chatbot_sessionAction(Request $request)
  1327.     {   
  1328.         $nSessionID = @$_GET['s'];
  1329.         if(!empty($nSessionID))        
  1330.         {
  1331.             $request->getSession()->set('current_chatbot_session'$nSessionID);
  1332.         }    
  1333.           
  1334.         return $this->redirect($this->get('router')->generate('chatbot', array()), 301);
  1335.     }
  1336.     
  1337.     public function gotobibleverseAction(Request $request)
  1338.     {                 
  1339.         $nCVerseID $request->query->get('v');                
  1340.         $nLanguageID $request->query->get('l');
  1341.         $nTransID $request->query->get('t'); 
  1342.         if(empty($nLanguageID))
  1343.         {
  1344.             $nLanguageID $this->LANGUAGE_ID_ENGLISH;
  1345.         }              
  1346.         $sSql "select shortcode FROM language where id = " $nLanguageID;
  1347.         $sLocale $this->getSingleData($sSql);
  1348.                                 
  1349.         $sOrderStr "";
  1350.         $sLocaleForLink "";
  1351.         if(!empty($sLocale) && $sLocale != 'en')        
  1352.         {
  1353.             $sLocaleForLink "/".$sLocale;        
  1354.         }
  1355.         
  1356.         if(empty($sLocaleForLink))
  1357.         {        
  1358.             $sOrderStr "case when language_id="$this->LANGUAGE_ID_ENGLISH " then 1 else 2 end";
  1359.         }
  1360.         else
  1361.         {
  1362.             $sSql1 "select id from language where shortcode = '" trim(str_replace("'""''"$sLocale)) . "'";
  1363.             $nUILanguageID $this->getSingleData($sSql1);
  1364.         
  1365.             $sOrderStr "case when language_id="$nUILanguageID " then 1 else case when language_id=" $this->LANGUAGE_ID_ENGLISH " then 2 else 3 end end";
  1366.         }
  1367.                     
  1368.         $sSql "select '" $sLocaleForLink "/bible/' || t.url || '/' || cb.url || '/' || cc.ordering || '/' || cv.ordering FROM canonicalbibleverse cv, canonicalbiblechapter cc, biblebook b, bibletranslation t, canonicalbiblebook cb where cv.id = " $nCVerseID " and cv.chapter_id = cc.id and cc.book_id = cb.id and b.canonicalization_id = cc.book_id and b.translation_id = t.id";
  1369.             
  1370.         $sSql .= " and t.enabled";
  1371.         if(!empty($nTransID))
  1372.         {
  1373.             $sSql .= " and t.id = " $nTransID;
  1374.         }            
  1375.         else
  1376.         {
  1377.            $sSql .= " order by " $sOrderStr ", languagedefault desc limit 1";
  1378.         }
  1379.         
  1380.    // echo $sSql."<br>";   
  1381.        $sLink $this->getSingleData($sSql);
  1382.        if(!empty($sLink))
  1383.                return $this->redirect($sLink301);            
  1384.        else
  1385.             return $this->redirect("/"301);            
  1386.     }
  1387.     
  1388.     public function gotoqbiblelinkAction(Request $request)
  1389.     {                 
  1390.         $nCVerseID $request->query->get('v');                
  1391.         $sLink $this->getQBibleLinkByCVerse($nCVerseID);
  1392.         if(!empty($sLink))
  1393.                return $this->redirect($sLink301);            
  1394.         else
  1395.             return $this->redirect("/"301);            
  1396.     }
  1397. // end of class