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

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