Beispiel #1
0
        private void LoadLanguageDropdown()
        {
            ddlLanguageFilter.Items.Clear();

            var cacheKey  = "Languages";
            var languages = Cache[cacheKey] as List <Language>;

            if (languages == null)
            {
                using (var quran = new QuranContext())
                    languages = quran.Languages.OrderBy(t => t.ID).ToList();
                Cache[cacheKey] = languages;
            }

            foreach (var language in languages)
            {
                var item = new ListItem(language.Name, language.ID.ToString());
                // item.Selected = cookie == null ? translator.ShowDefault : !hideTranslations.Contains(translator.ID.ToString());
                ddlLanguageFilter.Items.Add(item);
            }

            var languageIDCookie = Request.Cookies["language"];

            if (languageIDCookie != null)
            {
                ddlLanguageFilter.SelectedValue = languageIDCookie.Value;
            }
            //lblLanguageAll.Visible = ddlLanguageFilter.SelectedValue == "0" ? false : true;
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var criteria = Request["query"];
            //if (!criteria.Contains(' '))
            //   criteria = criteria + ' ';
            var arabic = Convert.ToBoolean(Request["arabic"]);
            var translationID = arabic ? 45 : 7;
            var searchTranslationIDs = new int[] { 6, 12, 45, 50, 5 };

            using (var quran = new QuranContext())
            {
                var verse = from a in quran.Ayahs
                            where searchTranslationIDs.Contains(a.TranslatorID) && a.Content.Contains(criteria)
                            group a by new { a.SurahNo, a.AyahNo } into anAyah
                            select new
                            {
                                SurahNo = anAyah.Key.SurahNo,
                                AyahNo = anAyah.Key.AyahNo,
                                Result = (arabic ? "<big>" : "") + anAyah.FirstOrDefault().Content.Replace(criteria, "<em>" + criteria + "</em>") + (arabic ? "" : " - <small>[" + anAyah.FirstOrDefault().Translator.Name + "]</small>") + (arabic ? "</big>" : ""),
                                Other = (from b in quran.Ayahs
                                           where b.AyahNo == anAyah.Key.AyahNo
                                           && b.SurahNo == anAyah.Key.SurahNo
                                           && b.TranslatorID == translationID
                                         select (arabic ? "" : "<big>") + b.Content + (arabic ? " - <small>[" + b.Translator.Name + "]</small>" : "") + (arabic ? "" : "</big>")).FirstOrDefault()
                            };

                SearchResultGridView.DataSource = verse.Take(50).ToList();
                SearchResultGridView.DataBind();
            }
        }
Beispiel #3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var criteria = Request["query"];
            //if (!criteria.Contains(' '))
            //   criteria = criteria + ' ';
            var arabic               = Convert.ToBoolean(Request["arabic"]);
            var translationID        = arabic ? 45 : 7;
            var searchTranslationIDs = new int[] { 6, 12, 45, 50, 5 };

            using (var quran = new QuranContext())
            {
                var verse = from a in quran.Ayahs
                            where searchTranslationIDs.Contains(a.TranslatorID) && a.Content.Contains(criteria)
                            group a by new { a.SurahNo, a.AyahNo } into anAyah
                    select new
                {
                    SurahNo = anAyah.Key.SurahNo,
                    AyahNo  = anAyah.Key.AyahNo,
                    Result  = (arabic ? "<big>" : "") + anAyah.FirstOrDefault().Content.Replace(criteria, "<em>" + criteria + "</em>") + (arabic ? "" : " - <small>[" + anAyah.FirstOrDefault().Translator.Name + "]</small>") + (arabic ? "</big>" : ""),
                    Other   = (from b in quran.Ayahs
                               where b.AyahNo == anAyah.Key.AyahNo &&
                               b.SurahNo == anAyah.Key.SurahNo &&
                               b.TranslatorID == translationID
                               select(arabic ? "" : "<big>") + b.Content + (arabic ? " - <small>[" + b.Translator.Name + "]</small>" : "") + (arabic ? "" : "</big>")).FirstOrDefault()
                };

                SearchResultGridView.DataSource = verse.Take(50).ToList();
                SearchResultGridView.DataBind();
            }
        }
Beispiel #4
0
        protected void SaveBanglaMeanings_Clicked(object sender, EventArgs e)
        {
            var surah = int.Parse(Request["surah"] ?? "1");
            var ayah  = int.Parse(Request["ayah"] ?? "1");
            var word  = int.Parse(Request["word"] ?? "1");

            using (QuranContext quran = new QuranContext())
            {
                var meaning = (from m in quran.Meanings
                               where m.SurahNo == surah && m.VerseNo == ayah && m.WordNo == word
                               select m).First();

                var root = (from r in quran.Roots where r.ID == meaning.RootID select r).First();
                root.BanglaMeanings = BanglaMeanings.Text.Trim();
                quran.SaveChanges();
            }
        }
Beispiel #5
0
        private int GetAyahCount(int surahNo)
        {
            var cacheKey  = "AyahCount." + surahNo;
            var ayahCount = Cache[cacheKey];

            if (ayahCount == null)
            {
                using (var quran = new QuranContext())
                    ayahCount = (from a in quran.Ayahs where a.SurahNo == surahNo orderby a.AyahNo descending select a).FirstOrDefault().AyahNo;
                Cache[cacheKey] = ayahCount;
                return((int)ayahCount);
            }
            else
            {
                return((int)ayahCount);
            }
        }
Beispiel #6
0
        protected void Save_Clicked(object sender, EventArgs e)
        {
            var heading       = Heading.Text;
            var myTranslation = HttpUtility.HtmlDecode(MyTranslation.Text);
            var footnote      = HttpUtility.HtmlDecode(Footnote.Text);
            var newPara       = NewPara.Checked;

            var surah = int.Parse(Request["surah"] ?? "1");
            var ayah  = int.Parse(Request["ayah"] ?? "1");

            using (var quran = new QuranContext())
            {
                var existingTranslation = quran.MyTranslations.FirstOrDefault(t => t.SurahNo == surah && t.AyahNo == ayah);
                if (existingTranslation == null)
                {
                    var newTranslation = new MyTranslation
                    {
                        AyahNo           = ayah,
                        SurahNo          = surah,
                        Heading          = heading,
                        Translation      = myTranslation,
                        Footnote         = footnote,
                        NewParaAfterThis = newPara,
                        CreatedDate      = DateTime.Now,
                        LastUpdateDate   = DateTime.Now
                    };

                    quran.MyTranslations.Add(newTranslation);
                    quran.SaveChanges();
                }
                else
                {
                    existingTranslation.NewParaAfterThis = newPara;
                    existingTranslation.SurahNo          = surah;
                    existingTranslation.AyahNo           = ayah;
                    existingTranslation.Heading          = heading;
                    existingTranslation.Translation      = myTranslation;
                    existingTranslation.Footnote         = footnote;
                    existingTranslation.LastUpdateDate   = DateTime.Now;

                    quran.SaveChanges();
                }
            }
        }
Beispiel #7
0
        private List <Ayah> GetTranslations(int surah, int ayah)
        {
            var cacheKey = "Translations." + surah + "." + ayah;
            var cached   = Cache[cacheKey] as List <Ayah>;

            if (cached != null)
            {
                return(cached);
            }
            else
            {
                using (var quran = new QuranContext())
                {
                    var translations = (from a in quran.Ayahs.Include("Translator")
                                        where a.SurahNo == surah && a.AyahNo == ayah
                                        orderby a.Translator.Order
                                        select a).ToList();
                    Cache[cacheKey] = translations;
                    return(translations);
                }
            }
        }
Beispiel #8
0
        private List <V_Surah> GetSurahNames(int languageId)
        {
            var cacheKey   = "SurahNames." + languageId;
            var surahNames = Cache[cacheKey] as List <V_Surah>;

            if (surahNames == null)
            {
                using (var quran = new QuranContext())
                {
                    surahNames = (from a in quran.V_Surahs
                                  where a.LanguageID == languageId
                                  orderby a.ID
                                  select a).ToList();
                }
                Cache[cacheKey] = surahNames;
                return(surahNames);
            }
            else
            {
                return(surahNames);
            }
        }
Beispiel #9
0
 public ChapterController(QuranContext quranContext, IMapper mapper)
 {
     this.quranContext = quranContext;
     this.mapper       = mapper;
 }
        protected void SaveBanglaMeanings_Clicked(object sender, EventArgs e)
        {
            var surah = int.Parse(Request["surah"] ?? "1");
            var ayah = int.Parse(Request["ayah"] ?? "1");
            var word = int.Parse(Request["word"] ?? "1");

            using (QuranContext quran = new QuranContext())
            {
                var meaning = (from m in quran.Meanings
                               where m.SurahNo == surah && m.VerseNo == ayah && m.WordNo == word
                               select m).First();

                var root = (from r in quran.Roots where r.ID == meaning.RootID select r).First();
                root.BanglaMeanings = BanglaMeanings.Text.Trim();
                quran.SaveChanges();
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            var surah = int.Parse(Request["surah"] ?? "1");
            var ayah = int.Parse(Request["ayah"] ?? "1");
            var word = int.Parse(Request["word"] ?? "1");

            using (QuranContext quran = new QuranContext())
            {
                var meaning = (from m in quran.Meanings
                               where m.SurahNo == surah && m.VerseNo == ayah && m.WordNo == word
                               select new
                               {
                                   Meaning = m,
                                   ArabicWord = m.ArabicWord,
                                   GrammarForm = m.GrammarForm,
                                   Root = m.Root,
                                   OtherMeaningsOfSameArabic = from om in quran.Meanings
                                                               where om.ArabicWordID == m.ArabicWordID
                                                               select om,
                                   OtherMeaningsOfSameRoot = from or in quran.Meanings
                                                             where or.RootID == m.RootID
                                                             group or by or.EnglishMeaning into groupedMeaning
                                                             orderby groupedMeaning.Count() descending
                                                             select new
                                                             {
                                                                 EnglishMeaning = groupedMeaning.Key,
                                                                 Usage = groupedMeaning.Count(),
                                                                 AllMeanings = from am in quran.Meanings
                                                                               where am.RootID == m.RootID && am.EnglishMeaning == groupedMeaning.Key
                                                                               select am
                                                             }
                               }).First();

                RootArabic.Text = meaning.Root.RootArabic.Replace(" ", "");
                RootEnglish.Text = meaning.Root.RootEnglish;
                RootMeanings.Text = meaning.Root.Meanings;
                if (!Page.IsPostBack)
                    BanglaMeanings.Text = meaning.Root.BanglaMeanings;

                TheWord.Text = meaning.ArabicWord.Arabic;
                OtherMeaningsOfArabic.DataSource = meaning.OtherMeaningsOfSameArabic;
                OtherMeaningsOfArabic.DataBind();

                OtherMeaningsOfRoot.DataSource = meaning.OtherMeaningsOfSameRoot;
                OtherMeaningsOfRoot.DataBind();

                var arabicWordsFromRoot = from arabicWords in quran.ArabicWords
                                          where arabicWords.RootID == meaning.Root.ID
                                          select arabicWords;

                var meaningFromRoot = (from rootMeaning in quran.Meanings
                                       where rootMeaning.RootID == meaning.Root.ID
                                       group rootMeaning by new { rootMeaning.GrammarForm.Grammar, rootMeaning.ArabicWordID, rootMeaning.ArabicWord.Arabic, rootMeaning.EnglishMeaning } into groupedMeaning
                                       orderby groupedMeaning.Key.Grammar ascending, groupedMeaning.Count() descending
                                       select new
                                       {
                                           Arabic = groupedMeaning.Key.Arabic,
                                           EnglishMeaning = groupedMeaning.Key.EnglishMeaning,
                                           Grammar = groupedMeaning.Key.Grammar,
                                           Usage = groupedMeaning.Count(),
                                           SameArabicWord = (groupedMeaning.Key.Arabic == meaning.ArabicWord.Arabic),
                                           Verses = from v in quran.Meanings
                                                    where v.ArabicWordID == groupedMeaning.Key.ArabicWordID
                                                    && v.EnglishMeaning == groupedMeaning.Key.EnglishMeaning
                                                    select v
                                       }).ToList();
                MeaningList.DataSource = meaningFromRoot;
                MeaningList.DataBind();

                TotalRootUsage.Text = meaningFromRoot.Sum(m => m.Usage).ToString();

                DictionaryLink.NavigateUrl = string.Format(DictionaryLink.NavigateUrl, meaning.Root.RootArabic.Replace(" ", ""));
            }
        }
Beispiel #12
0
        private void ShowMyTranslation(int surah, int ayah)
        {
            var showBangla = Request.Cookies["b"] != null && Request.Cookies["b"].Value == "1";

            BanglaInProgress.Visible = showBangla;

            if (!showBangla)
                return;

            using (var quran = new QuranContext())
            {
                var existingTranslation = quran.MyTranslations.FirstOrDefault(t => t.SurahNo == surah && t.AyahNo == ayah);
                if (existingTranslation != null)
                {
                    NewPara.Checked = existingTranslation.NewParaAfterThis;
                    Heading.Text = existingTranslation.Heading;
                    MyTranslation.Text = existingTranslation.Translation;
                    Footnote.Text = existingTranslation.Footnote;

                    //lblMyTranslation.Text = existingTranslation.Translation;
                    var text = existingTranslation.Translation;
                    text = new Regex(@"\*+").Replace(text, (match) =>
                    {
                        // Each * is footnote number
                        int footnoteIndex = match.Value.Length;
                        //var footnoteId = "Footnote_" + existingTranslation.SurahNo + "_" + existingTranslation.AyahNo + "_" + footnoteIndex;
                        return "<sup>" + (char)('a' + (char)(footnoteIndex - 1)) + "</sup>";
                    });
                    lblMyTranslation.Text = text;

                    //lblFootnote.Text = existingTranslation.Footnote;
                    var matches = new Regex(@"(\*+)([^\*]*)").Matches(existingTranslation.Footnote);
                    var footnoteHtml = "";
                    foreach (Match match in matches)
                    {
                        var footnoteCounter = match.Groups[1].Value.Length;
                        var footnoteText = match.Groups[2].Value;

                        footnoteHtml += "<p class=\"footnote\"><sup>"
                            + (char)('a' + (char)(footnoteCounter - 1)) + "</sup> "
                            + footnoteText + "</p>";
                    }
                    lblFootnote.Text = footnoteHtml;
                }
                else
                {
                    NewPara.Checked = false;
                    Heading.Text = string.Empty;
                    MyTranslation.Text = string.Empty;
                    Footnote.Text = string.Empty;

                    lblMyTranslation.Text = string.Empty;
                    lblFootnote.Text = string.Empty;
                }
            }
            //var banglaCookie = Response.Cookies.AllKeys.Contains("bangla") ? Response.Cookies["bangla"] : Request.Cookies.Get("bangla");
            if (showBangla)
            {
                pnlMyTranslationView.Visible = true;
                //ToggleBangla.Text = "Hide";
            }
            else
            {
                //ToggleBangla.Text = "Show";
                pnlMyTranslationView.Visible = false;
            }
        }
Beispiel #13
0
        private void LoadPageContent(int surah, int ayah)
        {
            var translations = GetTranslations(surah, ayah).AsQueryable();

            var cookie = Request.Cookies["hide"];
            var cookieValue = cookie == null ? string.Empty : cookie.Value;
            var hiddenTranslations = cookieValue.Split(',');

            if (cookie == null)
                translations = translations
                    .Where(t => t.Translator.ShowDefault)
                    .OrderBy(t => t.Translator.Order);
            else
                translations = translations.Where(t => !hiddenTranslations.Contains(t.TranslatorID.ToString())).OrderBy(t => t.Translator.Order);

            var languageId = int.Parse(ddlLanguageFilter.SelectedValue);
            foreach (var translation in translations)
            {
                var control = new LiteralControl(string.Format("<div class=\"translator\">{0}</div><p class=\"content\">{1}</p>",
                    translation.Translator.Name, translation.Content));

                if (translation.Translator.Type == 0)
                    pnlOriginal.Controls.Add(control);
                else if (translation.Translator.Type == 1)
                {
                    if (languageId == 0 || translation.Translator.LanguageID == languageId)
                    {
                        pnlAccepted.Controls.Add(control);
                        pnlAccepted.Visible = true;
                    }
                    else
                    {
                        pnlGenAcceptedAll.Controls.Add(control);
                        pnlGenAcceptedAll.Visible = true;
                    }
                }
                else if (translation.Translator.Type == 2)
                {
                    if (languageId == 0 || translation.Translator.LanguageID == languageId)
                    {
                        pnlControversal.Controls.Add(control);
                        pnlControversal.Visible = true;
                    }
                    else
                    {
                        pnlControversalAll.Controls.Add(control);
                        pnlControversalAll.Visible = true;
                    }
                }

                else if (translation.Translator.Type == 3)
                {
                    if (languageId == 0 || translation.Translator.LanguageID == languageId)
                    {
                        pnlNonMuslim.Controls.Add(control);
                        pnlNonMuslim.Visible = true;
                    }
                    else
                    {
                        pnlNonMuslimAll.Controls.Add(control);
                        pnlNonMuslimAll.Visible = true;
                    }
                }
                else if (translation.Translator.Type == 4)
                {
                    pnlTransliteration.Controls.Add(control);
                }
            }

            //Render related topics
            var selectedVerse = surah.ToString() + ":" + ayah.ToString();

            var cacheKey = "TopicMap." + surah + "." + ayah;
            var topics = Cache[cacheKey] as List<TopicAyahsMap>;
            if (topics == null)
            {
                using (var quran = new QuranContext())
                {
                    topics = (from t in quran.TopicAyahsMaps
                              where t.Ayahs.Contains("\"" + selectedVerse + "\"")
                              select t).ToList();
                }
                Cache[cacheKey] = topics;
            }

            var topicName = string.Empty;
            foreach (var topic in topics)
            {
                topicName += string.Format("<a class=\"topic\" href='#' onclick='topicDetails({1}); return false;'>{0}</a>", topic.Topic.Trim(), topic.ID.ToString()) + ", ";
            }

            topicName = !string.IsNullOrEmpty(topicName) ? topicName.Substring(0, topicName.LastIndexOf(',')) : "No relevant topic found";
            pnlRelevantVerses.Controls.Add(new LiteralControl(topicName));

            RefreshNavigationState();
        }
Beispiel #14
0
        private void LoadLanguageDropdown()
        {
            ddlLanguageFilter.Items.Clear();

            var cacheKey = "Languages";
            var languages = Cache[cacheKey] as List<Language>;
            if (languages == null)
            {
                using (var quran = new QuranContext())
                    languages = quran.Languages.OrderBy(t => t.ID).ToList();
                Cache[cacheKey] = languages;
            }

            foreach (var language in languages)
            {
                var item = new ListItem(language.Name, language.ID.ToString());
                // item.Selected = cookie == null ? translator.ShowDefault : !hideTranslations.Contains(translator.ID.ToString());
                ddlLanguageFilter.Items.Add(item);
            }

            var languageIDCookie = Request.Cookies["language"];
            if (languageIDCookie != null)
                ddlLanguageFilter.SelectedValue = languageIDCookie.Value;
            //lblLanguageAll.Visible = ddlLanguageFilter.SelectedValue == "0" ? false : true;
        }
Beispiel #15
0
 private List<Ayah> GetTranslations(int surah, int ayah)
 {
     var cacheKey = "Translations." + surah + "." + ayah;
     var cached = Cache[cacheKey] as List<Ayah>;
     if (cached != null)
         return cached;
     else
     {
         using (var quran = new QuranContext())
         {
             var translations = (from a in quran.Ayahs.Include("Translator")
                                 where a.SurahNo == surah && a.AyahNo == ayah
                                 orderby a.Translator.Order
                                 select a).ToList();
             Cache[cacheKey] = translations;
             return translations;
         }
     }
 }
Beispiel #16
0
 private List<V_Surah> GetSurahNames(int languageId)
 {
     var cacheKey = "SurahNames." + languageId;
     var surahNames = Cache[cacheKey] as List<V_Surah>;
     if (surahNames == null)
     {
         using (var quran = new QuranContext())
         {
             surahNames = (from a in quran.V_Surahs
                           where a.LanguageID == languageId
                           orderby a.ID
                           select a).ToList();
         }
         Cache[cacheKey] = surahNames;
         return surahNames;
     }
     else
     {
         return surahNames;
     }
 }
Beispiel #17
0
 private int GetAyahCount(int surahNo)
 {
     var cacheKey = "AyahCount." + surahNo;
     var ayahCount = Cache[cacheKey];
     if (ayahCount == null)
     {
         using (var quran = new QuranContext())
             ayahCount = (from a in quran.Ayahs where a.SurahNo == surahNo orderby a.AyahNo descending select a).FirstOrDefault().AyahNo;
         Cache[cacheKey] = ayahCount;
         return (int)ayahCount;
     }
     else
     {
         return (int)ayahCount;
     }
 }
Beispiel #18
0
        protected void Save_Clicked(object sender, EventArgs e)
        {
            var heading = Heading.Text;
            var myTranslation = HttpUtility.HtmlDecode(MyTranslation.Text);
            var footnote = HttpUtility.HtmlDecode(Footnote.Text);
            var newPara = NewPara.Checked;

            var surah = int.Parse(Request["surah"] ?? "1");
            var ayah = int.Parse(Request["ayah"] ?? "1");

            using (var quran = new QuranContext())
            {
                var existingTranslation = quran.MyTranslations.FirstOrDefault(t => t.SurahNo == surah && t.AyahNo == ayah);
                if (existingTranslation == null)
                {
                    var newTranslation = new MyTranslation
                    {
                        AyahNo = ayah,
                        SurahNo = surah,
                        Heading = heading,
                        Translation = myTranslation,
                        Footnote = footnote,
                        NewParaAfterThis = newPara,
                        CreatedDate = DateTime.Now,
                        LastUpdateDate = DateTime.Now
                    };

                    quran.MyTranslations.Add(newTranslation);
                    quran.SaveChanges();
                }
                else
                {
                    existingTranslation.NewParaAfterThis = newPara;
                    existingTranslation.SurahNo = surah;
                    existingTranslation.AyahNo = ayah;
                    existingTranslation.Heading = heading;
                    existingTranslation.Translation = myTranslation;
                    existingTranslation.Footnote = footnote;
                    existingTranslation.LastUpdateDate = DateTime.Now;

                    quran.SaveChanges();
                }
            }
        }
 public VerseController(QuranContext quranContext, IMapper mapper)
 {
     this.quranContext = quranContext;
     this.mapper       = mapper;
 }
Beispiel #20
0
        private void LoadPageContent(int surah, int ayah)
        {
            var translations = GetTranslations(surah, ayah).AsQueryable();

            var cookie             = Request.Cookies["hide"];
            var cookieValue        = cookie == null ? string.Empty : cookie.Value;
            var hiddenTranslations = cookieValue.Split(',');

            if (cookie == null)
            {
                translations = translations
                               .Where(t => t.Translator.ShowDefault)
                               .OrderBy(t => t.Translator.Order);
            }
            else
            {
                translations = translations.Where(t => !hiddenTranslations.Contains(t.TranslatorID.ToString())).OrderBy(t => t.Translator.Order);
            }

            var languageId = int.Parse(ddlLanguageFilter.SelectedValue);

            foreach (var translation in translations)
            {
                var control = new LiteralControl(string.Format("<div class=\"translator\">{0}</div><p class=\"content\">{1}</p>",
                                                               translation.Translator.Name, translation.Content));

                if (translation.Translator.Type == 0)
                {
                    pnlOriginal.Controls.Add(control);
                }
                else if (translation.Translator.Type == 1)
                {
                    if (languageId == 0 || translation.Translator.LanguageID == languageId)
                    {
                        pnlAccepted.Controls.Add(control);
                        pnlAccepted.Visible = true;
                    }
                    else
                    {
                        pnlGenAcceptedAll.Controls.Add(control);
                        pnlGenAcceptedAll.Visible = true;
                    }
                }
                else if (translation.Translator.Type == 2)
                {
                    if (languageId == 0 || translation.Translator.LanguageID == languageId)
                    {
                        pnlControversal.Controls.Add(control);
                        pnlControversal.Visible = true;
                    }
                    else
                    {
                        pnlControversalAll.Controls.Add(control);
                        pnlControversalAll.Visible = true;
                    }
                }

                else if (translation.Translator.Type == 3)
                {
                    if (languageId == 0 || translation.Translator.LanguageID == languageId)
                    {
                        pnlNonMuslim.Controls.Add(control);
                        pnlNonMuslim.Visible = true;
                    }
                    else
                    {
                        pnlNonMuslimAll.Controls.Add(control);
                        pnlNonMuslimAll.Visible = true;
                    }
                }
                else if (translation.Translator.Type == 4)
                {
                    pnlTransliteration.Controls.Add(control);
                }
            }

            //Render related topics
            var selectedVerse = surah.ToString() + ":" + ayah.ToString();

            var cacheKey = "TopicMap." + surah + "." + ayah;
            var topics   = Cache[cacheKey] as List <TopicAyahsMap>;

            if (topics == null)
            {
                using (var quran = new QuranContext())
                {
                    topics = (from t in quran.TopicAyahsMaps
                              where t.Ayahs.Contains("\"" + selectedVerse + "\"")
                              select t).ToList();
                }
                Cache[cacheKey] = topics;
            }

            var topicName = string.Empty;

            foreach (var topic in topics)
            {
                topicName += string.Format("<a class=\"topic\" href='#' onclick='topicDetails({1}); return false;'>{0}</a>", topic.Topic.Trim(), topic.ID.ToString()) + ", ";
            }

            topicName = !string.IsNullOrEmpty(topicName) ? topicName.Substring(0, topicName.LastIndexOf(',')) : "No relevant topic found";
            pnlRelevantVerses.Controls.Add(new LiteralControl(topicName));

            RefreshNavigationState();
        }
Beispiel #21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            var surah = int.Parse(Request["surah"] ?? "1");
            var ayah  = int.Parse(Request["ayah"] ?? "1");
            var word  = int.Parse(Request["word"] ?? "1");

            using (QuranContext quran = new QuranContext())
            {
                var meaning = (from m in quran.Meanings
                               where m.SurahNo == surah && m.VerseNo == ayah && m.WordNo == word
                               select new
                {
                    Meaning = m,
                    ArabicWord = m.ArabicWord,
                    GrammarForm = m.GrammarForm,
                    Root = m.Root,
                    OtherMeaningsOfSameArabic = from om in quran.Meanings
                                                where om.ArabicWordID == m.ArabicWordID
                                                select om,
                    OtherMeaningsOfSameRoot = from or in quran.Meanings
                                              where or.RootID == m.RootID
                                              group or by or.EnglishMeaning into groupedMeaning
                                              orderby groupedMeaning.Count() descending
                                              select new
                    {
                        EnglishMeaning = groupedMeaning.Key,
                        Usage = groupedMeaning.Count(),
                        AllMeanings = from am in quran.Meanings
                                      where am.RootID == m.RootID && am.EnglishMeaning == groupedMeaning.Key
                                      select am
                    }
                }).First();

                RootArabic.Text   = meaning.Root.RootArabic.Replace(" ", "");
                RootEnglish.Text  = meaning.Root.RootEnglish;
                RootMeanings.Text = meaning.Root.Meanings;
                if (!Page.IsPostBack)
                {
                    BanglaMeanings.Text = meaning.Root.BanglaMeanings;
                }

                TheWord.Text = meaning.ArabicWord.Arabic;
                OtherMeaningsOfArabic.DataSource = meaning.OtherMeaningsOfSameArabic;
                OtherMeaningsOfArabic.DataBind();

                OtherMeaningsOfRoot.DataSource = meaning.OtherMeaningsOfSameRoot;
                OtherMeaningsOfRoot.DataBind();


                var arabicWordsFromRoot = from arabicWords in quran.ArabicWords
                                          where arabicWords.RootID == meaning.Root.ID
                                          select arabicWords;

                var meaningFromRoot = (from rootMeaning in quran.Meanings
                                       where rootMeaning.RootID == meaning.Root.ID
                                       group rootMeaning by new { rootMeaning.GrammarForm.Grammar, rootMeaning.ArabicWordID, rootMeaning.ArabicWord.Arabic, rootMeaning.EnglishMeaning } into groupedMeaning
                                       orderby groupedMeaning.Key.Grammar ascending, groupedMeaning.Count() descending
                                       select new
                {
                    Arabic = groupedMeaning.Key.Arabic,
                    EnglishMeaning = groupedMeaning.Key.EnglishMeaning,
                    Grammar = groupedMeaning.Key.Grammar,
                    Usage = groupedMeaning.Count(),
                    SameArabicWord = (groupedMeaning.Key.Arabic == meaning.ArabicWord.Arabic),
                    Verses = from v in quran.Meanings
                             where v.ArabicWordID == groupedMeaning.Key.ArabicWordID &&
                             v.EnglishMeaning == groupedMeaning.Key.EnglishMeaning
                             select v
                }).ToList();
                MeaningList.DataSource = meaningFromRoot;
                MeaningList.DataBind();

                TotalRootUsage.Text = meaningFromRoot.Sum(m => m.Usage).ToString();

                DictionaryLink.NavigateUrl = string.Format(DictionaryLink.NavigateUrl, meaning.Root.RootArabic.Replace(" ", ""));
            }
        }
Beispiel #22
0
        private void ShowMyTranslation(int surah, int ayah)
        {
            var showBangla = Request.Cookies["b"] != null && Request.Cookies["b"].Value == "1";

            BanglaInProgress.Visible = showBangla;

            if (!showBangla)
            {
                return;
            }

            using (var quran = new QuranContext())
            {
                var existingTranslation = quran.MyTranslations.FirstOrDefault(t => t.SurahNo == surah && t.AyahNo == ayah);
                if (existingTranslation != null)
                {
                    NewPara.Checked    = existingTranslation.NewParaAfterThis;
                    Heading.Text       = existingTranslation.Heading;
                    MyTranslation.Text = existingTranslation.Translation;
                    Footnote.Text      = existingTranslation.Footnote;

                    //lblMyTranslation.Text = existingTranslation.Translation;
                    var text = existingTranslation.Translation;
                    text = new Regex(@"\*+").Replace(text, (match) =>
                    {
                        // Each * is footnote number
                        int footnoteIndex = match.Value.Length;
                        //var footnoteId = "Footnote_" + existingTranslation.SurahNo + "_" + existingTranslation.AyahNo + "_" + footnoteIndex;
                        return("<sup>" + (char)('a' + (char)(footnoteIndex - 1)) + "</sup>");
                    });
                    lblMyTranslation.Text = text;

                    //lblFootnote.Text = existingTranslation.Footnote;
                    var matches      = new Regex(@"(\*+)([^\*]*)").Matches(existingTranslation.Footnote);
                    var footnoteHtml = "";
                    foreach (Match match in matches)
                    {
                        var footnoteCounter = match.Groups[1].Value.Length;
                        var footnoteText    = match.Groups[2].Value;

                        footnoteHtml += "<p class=\"footnote\"><sup>"
                                        + (char)('a' + (char)(footnoteCounter - 1)) + "</sup> "
                                        + footnoteText + "</p>";
                    }
                    lblFootnote.Text = footnoteHtml;
                }
                else
                {
                    NewPara.Checked    = false;
                    Heading.Text       = string.Empty;
                    MyTranslation.Text = string.Empty;
                    Footnote.Text      = string.Empty;

                    lblMyTranslation.Text = string.Empty;
                    lblFootnote.Text      = string.Empty;
                }
            }
            //var banglaCookie = Response.Cookies.AllKeys.Contains("bangla") ? Response.Cookies["bangla"] : Request.Cookies.Get("bangla");
            if (showBangla)
            {
                pnlMyTranslationView.Visible = true;
                //ToggleBangla.Text = "Hide";
            }
            else
            {
                //ToggleBangla.Text = "Show";
                pnlMyTranslationView.Visible = false;
            }
        }