<?php
namespace NCBS\WebsiteBundle\Controller;
use Symfony\Component\HttpFoundation\Request;
//s33: what else because constants?
// use Symfony\Bundle\FrameworkBundle\Controller\Controller as SymCon;
// class DefaultController extends SymCon // NCBSWController
// cant, because: consts
use Symfony\Component\Yaml\Yaml;
class DefaultController extends NCBSWController
{
protected $prefix = 'Default';
public function indexAction(Request $request)
{
$locale = $request->getLocale();
$this->onloadPage($request);
$bibleTranslationUrl = $this->DEFAULT_BIBLE_VERSION;
$nBibleTransID = $request->getSession()->get('current_bible_translation_id');
if($nBibleTransID != '')
{
$bibleTranslation = $this->getBibleTranslationByID($nBibleTransID);
if(!empty($bibleTranslation))
$bibleTranslationUrl = $bibleTranslation['url'];
}
else
{
$bibleTranslation = $this->getDefaultBibleTranslationByLocale($locale);
if(!empty($bibleTranslation))
$bibleTranslationUrl = $bibleTranslation['url'];
}
$nFeaturedNum = 6;
$nSeeMore = $request->query->get('mfc');
$bSeeMore = ($nSeeMore == 1);
if($bSeeMore)
$nFeaturedNum += 20;
$featureData = $this->getFeaturedContentList($locale, $nFeaturedNum, false);
if(empty($featureData))
$featureData = $this->getFeaturedContentList($locale, $nFeaturedNum, true);
$indexData = array(
'feature_data' => $featureData,
'bible_translation_url' => $bibleTranslationUrl,
'see_more' => $bSeeMore
);
$request->getSession()->set('searched_bible_story_list', array());
$request->getSession()->set('searched_topic_list', array());
return $this->renderView('index', $indexData);
}
public function aboutAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('about', array());
}
public function no_contentAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('no_content', array());
}
public function the_planAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('the_plan', array());
}
public function mobile_appAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('mobile_app', array());
}
public function biblenavtestAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('biblenavtest', array());
}
public function swedenborg_nav_widgetAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('swedenborg_nav_widget', array());
}
public function swedenborg_testAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$locale = $request->getLocale();
$nLocaleLanguageID = $this->getLanguageIDByShortCode($locale);
$nSelectedLangID = $request->query->get('l');
return $this->renderView('swedenborg_test', array(
'works' => $this->getSwedenborgWorks($request, $nLocaleLanguageID, $nSelectedLangID),
'languages' => $this->getSwedenborgWorkLanguages($request),
'selected_language_id' => $nSelectedLangID,
'search_domain' => 'w'
));
}
public function new_church_mapAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('new_church_map', array());
}
public function bible_studiesAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('bible_studies', array());
}
public function newsAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('news', array());
}
public function site_searchAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('site_search', array());
}
public function neosearchAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('neosearch', array());
}
public function donateAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('donate', array());
}
public function donation_thank_youAction()
{
return $this->renderView('donation_thank_you', array());
}
public function contactAction(Request $request)
{
return $this->renderView('contact', array());
}
public function resourcesAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('resources', array());
}
public function additional_translationsAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('additional_translations', array());
}
public function swedenborg_research_toolsAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('swedenborg_research_tools', array());
}
public function explanatory_worksAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('explanatory_works', array());
}
public function bible_commentaryAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('bible_commentary', array());
}
public function swedenborg_glossaryAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('swedenborg_glossary', array());
}
public function new_church_lifeAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('new_church_life', array());
}
public function get_involvedAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('get_involved', array());
}
public function partnersAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('partners', array());
}
public function terms_of_useAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('terms_of_use', array());
}
public function privacy_policyAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('privacy_policy', array());
}
public function storeAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('store', array());
}
public function explanation_formAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('explanation_form', array());
}
public function spiritual_topic_formAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('spiritual_topic_form', array());
}
public function bible_story_formAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('bible_story_form', array());
}
public function mailing_listAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('mailing_list', array());
}
public function daily_verseAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$sText = $this->getDailyVerse($request);
$data = array(
'daily_verse_text' => $sText
);
return $this->renderView('daily_verse', $data);
}
/* public function q_and_aAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('q_and_a', array());
} */
public function classes_and_groupsAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$aLanguage = $this->getLanguageListForClassHub();
$data = array(
'language_list' => $aLanguage
);
return $this->renderView('classes_and_groups', $data);
}
public function noteAction($status_code)
{
$noteData = array(
'status_code' => $status_code
);
return $this->renderView('note', $noteData);
}
public function work_translationAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('work_translation', array());
}
public function conceptsAllAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('all_concepts', array());
}
public function loginAction(Request $request)
{
$this->onloadPage($request);
return $this->goToLoginPage($request);
}
public function registerAction(Request $request)
{
$this->onloadPage($request);
return $this->renderView('register', array());
}
public function forgotpwdAction(Request $request)
{
$this->onloadPage($request);
return $this->renderView('forgotpwd', array());
}
public function resendactivationcodeAction(Request $request)
{
$this->onloadPage($request);
return $this->renderView('resendactivationcode', array());
}
public function changepwdAction(Request $request)
{
$this->onloadPage($request);
return $this->renderView('changepwd', array());
}
public function get_session_from_admin_siteAction($user_id, $user_level, $user_lang_id, $user_bible_trans_id, Request $request)
{
$audio_rate = @$_GET['audio_rate'];
if(empty($audio_rate))
$audio_rate = 1.0;
$this->setsessionswhenlogin($user_id, $user_level, $user_lang_id, $user_bible_trans_id, $audio_rate, $request);
return $this->renderView('blankpage', array());
}
public function reset_session_from_admin_siteAction(Request $request)
{
self::resetPortalSession($request);
return $this->renderView('blankpage', array());
}
public function myprofileAction(Request $request)
{
//$this->setCurrentUrl($request);
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
return $this->renderView('myprofile', array());
}
public function mypreferenceAction(Request $request)
{
//$this->setCurrentUrl($request);
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
return $this->renderView('mypreference', array());
}
public function bookmarkAction(Request $request)
{
//$this->setCurrentUrl($request);
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
return $this->renderView('mybookmark', array());
}
public function portal_homeAction()
{
$frameData = array(
'file_name' => 'homepage'
);
return $this->renderView('frame', $frameData);
}
public function logoutAction(Request $request)
{
$sCurrentPageUrl = $this->getCurrentUrl($request);
self::resetPortalSession($request);
$frameData = array(
'file_name' => 'sc_logout',
'current_url' => $sCurrentPageUrl
);
return $this->renderView('frame_logout', $frameData);
}
public function resetPortalSession($request)
{
$request->getSession()->set("user_id", "");
$request->getSession()->set("user_level", "");
$request->getSession()->set("current_language", "");
$request->getSession()->set("current_bible_translation_id", "");
$request->getSession()->set("user_receive_verse_of_day", "");
$request->getSession()->set("audio_rate", "");
}
public function mynoteAction(Request $request)
{
// $this->setCurrentUrl($request);
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
$args = @$_SERVER['QUERY_STRING'];
if(!empty($args))
{
$args = '?'.$args;
}
$frameData = array(
'url_param' => $args
);
return $this->renderView('mynote', $frameData);
}
public function mysubjectAction(Request $request)
{
//$this->setCurrentUrl($request);
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
$frameData = array(
);
return $this->renderView('mysubject', $frameData);
}
public function searchwordsAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$frameData = array(
'file_name' => 'searchword'
);
return $this->renderView('searchwords', $frameData);
}
public function swedenborgworkAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$frameData = array(
'file_name' => 'vexpositiontransforpubliclist'
);
return $this->renderView('frame_works_in_language', $frameData);
}
public function swedenborgglossaryAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$frameData = array();
return $this->renderView('swedenborg_glossary', $frameData);
}
public function myreadingplanAction(Request $request)
{
//$this->setCurrentUrl($request);
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
return $this->renderView('myreadingplan', array());
}
public function testAction(Request $request)
{
$this->onloadPage($request);
$indexData = array(
'user_agent' => @$_SERVER['HTTP_USER_AGENT'],
'is_mobile' => $this->isOnMobile()
);
/* $aReplace = array(
'_8100_' => "Test Book",
'_8210_' => "2",
'_8220_' => "6"
);
$indexData['range_name2'] = $this->ui_string_replace($request->getSession()->get('ui_str')["bible.chapternav.bookchapterrange"], $aReplace); */
return $this->renderView('test', $indexData);
}
public function explainchapterAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
$frameData = array(
);
return $this->renderView('explainchapter', $frameData);
}
public function loginredirectAction($user_id, $user_level, $user_lang_id, $user_bible_trans_id, $signed_up_verse_of_day, Request $request)
{
//$nUserID = $request->getSession()->get('user_id');
if($user_id != '')
{
$audio_rate = @$_GET['audio_rate'];
if(empty($audio_rate))
$audio_rate = 1.0;
$this->setsessionswhenlogin($user_id, $user_level, $user_lang_id, $user_bible_trans_id, $audio_rate, $request);
if($signed_up_verse_of_day == 1)
{
$request->getSession()->set("user_signed_up_verse_of_day", "1");
}
}
$sFromLogin = $request->getSession()->get('from_login');
if($sFromLogin != '')
{
$request->getSession()->set("from_login", "");
$sCurrentPageUrl = $this->getCurrentUrl($request);
if($sCurrentPageUrl != '')
{
$request->getSession()->set("current_page_url", "");
return $this->redirect($sCurrentPageUrl, 301);
}
}
return $this->redirect($this->get('router')->generate('homepage', array()), 301);
}
public function relatedworkpassagesAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$locale = $request->getLocale();
$nLanguageID = $this->getLanguageIDByShortCode($locale);
$frameData = array(
'language_id' => $nLanguageID
);
return $this->renderView('frame_related_passages', $frameData);
}
public function searchtermsAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$frameData = array(
);
return $this->renderView('searchterms', $frameData);
}
public function logoutredirectAction(Request $request)
{
$sCurrentPageUrl = @$_GET['cu'];
if($sCurrentPageUrl != '')
{
return $this->redirect($sCurrentPageUrl, 301);
}
else
return $this->redirect($this->get('router')->generate('homepage', array()), 301);
}
public function explainchaptersumAction($cchapterID, $translationID, Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
$frameData = array(
'cchapter_id' => $cchapterID,
'translation_id' => $translationID
);
return $this->renderView('explainchaptersum', $frameData);
}
public function crossrefAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$frameData = array(
);
return $this->renderView('frame_cross_ref', $frameData);
}
public function crossref2Action(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$frameData = array(
);
return $this->renderView('frame_cross_ref2', $frameData);
}
public function editexplanationAction(Request $request, $translationID)
{
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
$frameData = array(
'translation_id_for_update' => $translationID
);
return $this->renderView('editexplanation', $frameData);
}
public function editworkAction(Request $request, $translationID, $passageNumber)
{
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
$frameData = array(
'translation_id_to_edit' => $translationID,
'passage_num_to_edit' => $passageNumber
);
return $this->renderView('editwork', $frameData);
}
public function checkuiAction(Request $request, $languageID)
{
$locale = $request->getLocale();
$sLocaleForAlert = null;
$sUILocaleForTrans = $this->getUILocale($languageID);
if($sUILocaleForTrans != $locale)
$sLocaleForAlert = $sUILocaleForTrans;
$data = array(
'locale_for_alert' => $sLocaleForAlert
);
return $this->renderView('checkui', $data);
}
public function showvideoAction($YoutubeID, $ShowTimeInSeconds)
{
$data = array(
'youtube_id' => $YoutubeID,
'show_time_in_seconds' => $ShowTimeInSeconds
);
return $this->renderView('showvideo', $data);
}
public function pageredirectAction(Request $request)
{
$user_id = $this->getCurrUserID($request);
if($user_id != '')
{
$bReceive = $this->getVerseOfDayStatus($user_id);
$request->getSession()->set('user_receive_verse_of_day', $bReceive);
$nAudioRate = $this->getAudioRate($user_id);
$request->getSession()->set('current_audio_rate', $nAudioRate);
}
$sCurrentPageUrl = $this->getCurrentUrl($request);
if($sCurrentPageUrl != '')
{
return $this->redirect($sCurrentPageUrl, 301);
}
else
return $this->redirect($this->get('router')->generate('homepage', array()), 301);
}
// For the popup form to allow users to ask questions
public function ask_questionAction(Request $request)
{
return $this->renderView('ask_question', array());
}
public function set_sessionAction($index, Request $request)
{
if($index == 1)
{
$request->getSession()->set('user_receive_verse_of_day', true);
}
return $this->renderView('blankpage', array());
}
public function sermonhubAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$aLanguage = $this->getLanguageListForSermonHub();
$aTopic = $this->getTopicListForSermonHub();
$aAuthor = $this->getAuthorListForSermonHub();
$data = array(
'language_list' => $aLanguage,
'topic_list' => $aTopic,
'author_list' => $aAuthor
);
return $this->renderView('sermonhub', $data);
}
public function sermon_storehouseAction(Request $request)
{
//copy front end "Sermons" page to a new page as "Sermons"
// in the menu (url=sermon-storehouse).
// new page will only show type=gneral public
$this->setCurrentUrl($request);
$this->onloadPage($request);
$aLanguage = $this->getLanguageListForSermonStorehouse();
$aTopic = $this->getTopicListForSermonStorehouse();
$aAuthor = $this->getAuthorListForSermonStorehouse();
$data = array(
'language_list' => $aLanguage,
'topic_list' => $aTopic,
'author_list' => $aAuthor
);
return $this->renderView('sermon_storehouse', $data);
}
public function latin_wordsAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
return $this->renderView('latin_words', array());
}
/**
* Show logged-in menu item list on a popup
*/
public function selectloggedinmenuAction(Request $request)
{
$data = array();
return $this->renderView('selectloggedinmenu', $data);
}
public function setshowbiblelinksAction($index, Request $request)
{
$request->getSession()->set('show_bible_links', $index);
return $this->renderView('blankpage', array());
}
public function concepthubAction(Request $request)
{
$this->setCurrentUrl($request);
$this->onloadPage($request);
$locale = $request->getLocale();
$nLocaleLanguageID = $this->getLanguageIDByShortCode($locale);
$aLanguage = $this->getLanguageListForConceptHub();
$data = array(
'language_list' => $aLanguage,
'ui_language_id' => $nLocaleLanguageID
);
return $this->renderView('concepthub', $data);
}
public function unsubscribeAction(Request $request)
{
$this->onloadPage($request);
$idx = $request->query->get('msg');
if(empty($idx))
{
$sEmail = $request->query->get('em');
if(!empty($sEmail))
{
$sLink = "/dbadmin/unsubscribe.php?em=".$sEmail;
return $this->redirect($sLink, 301);
}
else
{
$idx = 2;
}
}
$data = array(
'unsubscribe_idx' => $idx
);
return $this->renderView('unsubscribe', $data);
}
public function gotowebsiteAction(Request $request)
{
$nUserID = $request->getSession()->get('user_id');
$sLink = "";
if($nUserID != '')
{
$sLink = "/";
}
else
{
$sLink = "/dbadmin/checklogin.php";
}
return $this->redirect($sLink, 301);
}
public function mygroupAction(Request $request)
{
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
$args = @$_SERVER['QUERY_STRING'];
if(!empty($args))
{
$args = '?'.$args;
}
$frameData = array(
'url_param' => $args
);
return $this->renderView('mygroup', $frameData);
}
public function popup_formAction($typeName, Request $request)
{
return $this->renderView($typeName, array());
}
public function chatbotAction(Request $request)
{
$locale = $request->getLocale();
$this->setCurrentUrl($request);
$this->onloadPage($request);
$nLanguageID = $this->getLanguageIDByShortCode($locale);
$rval = array();
$rval['text_to_speech'] = $this->getTextToSpeech($nLanguageID);
if($this->canUseSpeechToText())
{
$rval['speech_to_text'] = 1;
$rval['language_for_speech'] = $this->getLanguageForSpeech($locale);
}
// $rval['on_new_window'] = 1;
return $this->renderView('chatbot', $rval);
}
public function chatbothelpAction(Request $request)
{
return $this->renderView('chatbothelp', array());
}
public function chatbotdevAction(Request $request)
{
$this->onloadPage($request);
$this->setCurrentUrl($request);
$locale = $request->getLocale();
$nLanguageID = $this->getLanguageIDByShortCode($locale);
$rval = array();
$rval['text_to_speech'] = $this->getTextToSpeech($nLanguageID);
if($this->canUseSpeechToText())
{
$rval['speech_to_text'] = 1;
$rval['language_for_speech'] = $this->getLanguageForSpeech($locale);
}
return $this->renderView('chatbotdev', $rval);
}
public function gotoworkAction(Request $request)
{
$nTransID = @$_GET['t'];
$bTranslation = !empty($nTransID);
$nWorkID = @$_GET['w'];
$nPassageNum = @$_GET['p'];
$nSectionNum = @$_GET['s'];
$sLanguage = @$_GET['l'];
$nLanguageID = null;
$sLocale = null;
if(is_numeric($sLanguage))
{
$nLanguageID = $sLanguage;
$sSql = "select shortcode FROM language where id = " . $sLanguage;
$sLocale = $this->getSingleData($sSql);
}
else
{
$sLocale = $sLanguage;
$nLanguageID = $this->getLanguageIDByShortCode($sLocale);
}
$bValidUrl = true;
if(!$bTranslation && empty($nWorkID))
$bValidUrl = false;
if($bValidUrl && $nPassageNum == '')
$bValidUrl = false;
if(!$bValidUrl)
{
return $this->redirect("/", 301);
}
$sOrderStr = "";
$sLocaleForLink = "";
if($sLocale == 'en' || empty($sLocale))
{
}
else
{
$sLocaleForLink = "/".$sLocale;
}
if(!$bTranslation)
{
if($sLocale == 'en' || empty($sLocale))
{
$sOrderStr = "case when language_id=". $this->LANGUAGE_ID_ENGLISH . " then 1 else 2 end";
}
else
{
$sOrderStr = "case when language_id=". $nLanguageID . " then 1 else case when language_id=" . $this->LANGUAGE_ID_ENGLISH . " then 2 else 3 end end";
}
}
if($bTranslation)
{
if($nPassageNum == 'i')
{
$sSql = "select '" . $sLocaleForLink . "/exposition/translation/' || t.url || '/index' from expositiontranslation t where t.id=".$nTransID;
}
else
{
$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);
}
}
else
{
$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";
}
// echo $sSql;
$sUrl = $this->getSingleData($sSql);
if(!empty($nSectionNum) && $nSectionNum != 1)
$sUrl .= "#subsection-0-".$nSectionNum;
//echo $sUrl;
if($sUrl != '')
return $this->redirect($sUrl, 301);
else
{
$sUrl2 = $sLocaleForLink."/no-content";
return $this->redirect($sUrl2, 301);
}
}
public function gotobibleAction(Request $request)
{
$nCBookID = $request->query->get('b');
$nChapternum = $request->query->get('c');
$sVerses = $request->query->get('v');
$nLanguageID = $request->query->get('l');
$nTransID = $request->query->get('t');
$nBookID = $request->query->get('nb');
$sSql = "select shortcode FROM language where id = " . $nLanguageID;
$sLocale = $this->getSingleData($sSql);
$bFullChapter = (empty($sVerses));
$nVerseNum1 = "";
$nVerseNum2 = "";
if(!$bFullChapter)
{
$aVerse = explode("-", $sVerses);
if(count($aVerse) > 1)
{
$nVerseNum2 = $aVerse[1];
}
$nVerseNum1 = $aVerse[0];
}
$sOrderStr = "";
$sLocaleForLink = "";
if(!empty($sLocale) && $sLocale != 'en')
{
$sLocaleForLink = "/".$sLocale;
}
if(!empty($nBookID))
{
$sSql = "";
if($bFullChapter)
{
$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";
}
else
{
if(empty($nVerseNum2) || $nVerseNum1 == $nVerseNum2)
{
$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";
}
else
{
$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";
}
}
$sSql .= " and t.enabled";
}
else
{
if(empty($sLocaleForLink))
{
$sOrderStr = "case when language_id=". $this->LANGUAGE_ID_ENGLISH . " then 1 else 2 end";
}
else
{
$sSql1 = "select id from language where shortcode = '" . trim(str_replace("'", "''", $sLocale)) . "'";
$nUILanguageID = $this->getSingleData($sSql1);
$sOrderStr = "case when language_id=". $nUILanguageID . " then 1 else case when language_id=" . $this->LANGUAGE_ID_ENGLISH . " then 2 else 3 end end";
}
$sSql = "";
if($bFullChapter)
{
$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";
}
else
{
if(empty($nVerseNum2) || $nVerseNum1 == $nVerseNum2)
{
$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";
}
else
{
$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";
}
}
$sSql .= " and t.enabled";
if(!empty($nTransID))
{
$sSql .= " and t.id = " . $nTransID;
}
else
{
$sSql .= " order by " . $sOrderStr . ", languagedefault desc limit 1";
}
}
// echo $sSql."<br>";
$sLink = $this->getSingleData($sSql);
if(!empty($sLink))
return $this->redirect($sLink, 301);
else
return $this->redirect("/", 301);
}
public function gotobiblelinkAction(Request $request)
{
$nRefID = $request->query->get('linkid');
$nTLang = $request->query->get('tlang'); // Translation Language ID
$sLocale = $request->query->get('uilang');
$sOrderStr = "";
$sLocaleForLink = "";
if(!empty($sLocale) && $sLocale != 'en')
{
$sLocaleForLink = "/".$sLocale;
}
if(empty($nTLang))
{
$sOrderStr = "case when language_id=". $this->LANGUAGE_ID_ENGLISH . " then 1 else 2 end";
}
else
{
$sOrderStr = "case when language_id=". $nTLang . " then 1 else case when language_id=" . $this->LANGUAGE_ID_ENGLISH . " then 2 else 3 end end";
}
$sSql1 = "SELECT startverse_id, endverse_id FROM refbible WHERE container_id = " . $nRefID;
// echo $sSql1."<br>";
$aData = $this->getRowData($sSql1);
if(!empty($aData))
{
$sSql = "";
$startverse_id = trim($aData['startverse_id']);
$endverse_id = trim($aData['endverse_id']);
if($startverse_id == $endverse_id)
{
$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";
}
else
{
if($this->isBibleFullChapter($startverse_id, $endverse_id))
{
$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";
}
else
{
$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";
}
}
$sSql .= " and t.enabled order by " . $sOrderStr . ", languagedefault desc limit 1";
// echo $sSql."<br>";
$sLink = $this->getSingleData($sSql);
return $this->redirect($sLink, 301);
}
else
return $this->redirect("/", 301);
}
public function mynotesAction(Request $request)
{
$nUserID = $this->getCurrUserID($request);
if(empty($nUserID))
{
return $this->redirect($this->get('router')->generate('login', array()), 301);
}
$this->setCurrentUrl($request);
$this->onloadPage($request);
$data = array(
);
return $this->renderView('mynotes', $data);
}
public function search_mynoteAction(Request $request)
{
$locale = $request->getLocale();
$searchedResults = array();
$sSearchTerm = $request->query->get('searchTerm');
$nStartNum = $request->query->get('startnum');
$searchedResults = $this->getMynoteList($nStartNum, $locale, $request);
return $this->renderView('mynote_searched', array(
'searched_mynote' => $searchedResults['results'],
'total_record' => $searchedResults['total_record'],
'has_filter' => $searchedResults['has_filter'],
'has_more' => $searchedResults['has_more'],
'start_num' => $nStartNum
));
}
public function mybookmarksAction(Request $request)
{
$nUserID = $this->getCurrUserID($request);
if(empty($nUserID))
{
return $this->redirect($this->get('router')->generate('login', array()), 301);
}
$this->setCurrentUrl($request);
$this->onloadPage($request);
$aLinkType = $this->getLinkTypeList($request);
$data = array(
'linktype_list' => $aLinkType
);
return $this->renderView('mybookmarks', $data);
}
public function search_mybookmarkAction(Request $request)
{
$locale = $request->getLocale();
$searchedResults = array();
$sSearchTerm = $request->query->get('searchTerm');
$nStartNum = $request->query->get('startnum');
$searchedResults = $this->getMybookmarkList($nStartNum, $locale, $request);
return $this->renderView('mybookmark_searched', array(
'searched_mybookmark' => $searchedResults['results'],
'total_record' => $searchedResults['total_record'],
'has_filter' => $searchedResults['has_filter'],
'has_more' => $searchedResults['has_more'],
'start_num' => $nStartNum
));
}
public function chatbot_widgetAction(Request $request)
{
$locale = $request->getLocale();
$this->onloadPage($request);
$nLanguageID = $this->getLanguageIDByShortCode($locale);
$rval = array();
$rval['text_to_speech'] = $this->getTextToSpeech($nLanguageID);
if($this->canUseSpeechToText())
{
$rval['speech_to_text'] = 1;
$rval['language_for_speech'] = $this->getLanguageForSpeech($locale);
}
$rval['on_new_window'] = 1;
return $this->renderView('chatbot_widget', $rval);
}
public function chatbotdevstreamlitAction(Request $request)
{
$this->onloadPage($request);
$this->setCurrentUrl($request);
$nUserID = $this->getCurrUserID($request);
$nUserIDForChat = null;
if(empty($nUserID))
{
$nUserIDForChat = "t".$this->getRandomNum(); // temporary user ID
}
else
{
$nUserIDForChat = $this->simpleEncrypt($nUserID);
}
$bHasSessionHistory = false;
// $bHasChatHistory = false;
$nSessionID = $request->getSession()->get('current_chatbot_session');
if(empty($nSessionID))
{
$nSessionID = $this->getRandomNum();
$request->getSession()->set('current_chatbot_session', $nSessionID);
}
else
{
$bHasSessionHistory = $this->hasSessionHistory($nSessionID);
}
/* if(!empty($nUserID))
{
$bHasChatHistory = $this->hasChatHistory($nUserID);
} */
$locale = $request->getLocale();
$nLanguageID = $this->getLanguageIDByShortCode($locale);
$rval = array();
// $rval['text_to_speech'] = $this->getTextToSpeech($nLanguageID);
$rval['user_id_for_chat'] = $nUserIDForChat;
$rval['session_id'] = $nSessionID;
$rval['ui_language_id'] = $nLanguageID;
$rval['has_session_history'] = $bHasSessionHistory;
// $rval['has_chat_history'] = $bHasChatHistory;
/* if($this->canUseSpeechToText())
{
$locale = $request->getLocale();
$rval['speech_to_text'] = 1;
$rval['language_for_speech'] = $this->getLanguageForSpeech($locale);
} */
return $this->renderView('chatbotdevstreamlit', $rval);
}
public function reset_chatsAction(Request $request)
{
$nUserForChat = @$_GET['u'];
$nLanguageID = @$_GET['l'];
$nSessionID = $this->getRandomNum();
$request->getSession()->set('current_chatbot_session', $nSessionID);
$sLink = "https://newchristianchatbot.org/?u=" . $nUserForChat . "&q=&s=" . $nSessionID . "&q=&l=" . $nLanguageID;
return $this->redirect($sLink, 301);
}
public function selectchathistoryAction(Request $request)
{
$nUserIDForChat = @$_GET['u'];
$nUILangID = @$_GET['l'];
$nUserID = $this->getCurrUserID($request);
$aChat = $this->getChatHistoryList($nUserID, 20);
$data['chat_history_list'] = $aChat['chat_list'];
// $data['show_more'] = $aChat['show_more'];
$data['user_id_for_chat'] = $nUserIDForChat;
$data['ui_language_id'] = $nUILangID;
return $this->renderView('selectchathistory', $data);
}
public function set_chat_sessionAction(Request $request)
{
$nSessionID = @$_GET['s'];
$request->getSession()->set('current_chatbot_session', $nSessionID);
return $this->renderView('blankpage', array());
}
public function goto_chatbot_pageAction(Request $request)
{
$nUserForChat = @$_GET['u'];
$nLanguageID = @$_GET['l'];
$nSessionID = @$_GET['s'];
if(empty($nSessionID))
{
$nSessionID = $request->getSession()->get('current_chatbot_session');
}
else
{
$request->getSession()->set('current_chatbot_session', $nSessionID);
}
$sLink = "https://newchristianchatbot.org/?u=" . $nUserForChat . "&q=&s=" . $nSessionID . "&q=&l=" . $nLanguageID;
return $this->redirect($sLink, 301);
}
public function mychatAction(Request $request)
{
// $this->setCurrentUrl($request);
$this->onloadPage($request);
if($this->getCurrUserID($request) == '')
{
return $this->goToLoginPage($request);
}
$args = @$_SERVER['QUERY_STRING'];
if(!empty($args))
{
$args = '?'.$args;
}
$frameData = array(
'url_param' => $args
);
return $this->renderView('mychat', $frameData);
}
public function open_chatbot_sessionAction(Request $request)
{
$nSessionID = @$_GET['s'];
if(!empty($nSessionID))
{
$request->getSession()->set('current_chatbot_session', $nSessionID);
}
return $this->redirect($this->get('router')->generate('chatbot', array()), 301);
}
public function gotobibleverseAction(Request $request)
{
$nCVerseID = $request->query->get('v');
$nLanguageID = $request->query->get('l');
$nTransID = $request->query->get('t');
if(empty($nLanguageID))
{
$nLanguageID = $this->LANGUAGE_ID_ENGLISH;
}
$sSql = "select shortcode FROM language where id = " . $nLanguageID;
$sLocale = $this->getSingleData($sSql);
$sOrderStr = "";
$sLocaleForLink = "";
if(!empty($sLocale) && $sLocale != 'en')
{
$sLocaleForLink = "/".$sLocale;
}
if(empty($sLocaleForLink))
{
$sOrderStr = "case when language_id=". $this->LANGUAGE_ID_ENGLISH . " then 1 else 2 end";
}
else
{
$sSql1 = "select id from language where shortcode = '" . trim(str_replace("'", "''", $sLocale)) . "'";
$nUILanguageID = $this->getSingleData($sSql1);
$sOrderStr = "case when language_id=". $nUILanguageID . " then 1 else case when language_id=" . $this->LANGUAGE_ID_ENGLISH . " then 2 else 3 end end";
}
$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";
$sSql .= " and t.enabled";
if(!empty($nTransID))
{
$sSql .= " and t.id = " . $nTransID;
}
else
{
$sSql .= " order by " . $sOrderStr . ", languagedefault desc limit 1";
}
// echo $sSql."<br>";
$sLink = $this->getSingleData($sSql);
if(!empty($sLink))
return $this->redirect($sLink, 301);
else
return $this->redirect("/", 301);
}
public function gotoqbiblelinkAction(Request $request)
{
$nCVerseID = $request->query->get('v');
$sLink = $this->getQBibleLinkByCVerse($nCVerseID);
if(!empty($sLink))
return $this->redirect($sLink, 301);
else
return $this->redirect("/", 301);
}
} // end of class