Esempio n. 1
0
 ///<summary>
 /// Load the Description in the CultureCode language from DB. You must set CourseId and CultureCode to get the Description
 ///</summary>
 public void LoadDescription()
 {
     if (TheCourse == null || TheCourse.CourseId == 0 || CultureCode == null)
         throw new Exception("Cannot load Description. Need CourseId and CultureCode");
     BaseRepository rep = new BaseRepository();
     TheDescription = rep.GetCurrentVersionText(CultureCode, TheCourse.CourseId, ETextItemType.CourseDescription);
 }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     BaseHandler bh = new BaseHandler();
     PHText t = bh.GetCurrentVersionText(CultureCode, ItemId, ItemType);
     if (t == null)
     {
         t = new PHText();
         t.CreatedByUserId = UserId;
         t.CultureCode = CultureCode;
         t.ItemId = ItemId;
         t.ItemType = ItemType;
     }
     t.Text = System.Net.WebUtility.HtmlDecode(hdnrichtext.Value);
     t.ModifiedByUserId = UserId;
     if (Case == EControlCase.Edit)
     {
         bh.SavePhTextInAllCc(t);
         Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", AttachQS));
     }
     else if (Case == EControlCase.Translate)
     {
         t.CultureCodeStatus = ECultureCodeStatus.HumanTranslated;
         bh.SavePhText(t);
         Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", AttachQS));
     }
 }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     BaseHandler bh = new BaseHandler();
     PHText t = bh.GetCurrentVersionText(CultureCode, ItemId, ItemType);
     if (t == null)
     {
         t = new PHText();
         t.CreatedByUserId = UserId;
         t.CultureCode = CultureCode;
         t.ItemId = ItemId;
         t.ItemType = ItemType;
     }
     t.Text = Regex.Replace(tbTheText.Text, "<[^>]*>", String.Empty);
     if (ddlHeadingType.SelectedIndex > 0)
     {
         t.Text = "<h" + ddlHeadingType.SelectedIndex.ToString() + ">" + t.Text + "</h" + ddlHeadingType.SelectedIndex.ToString() + ">";
     }
     t.ModifiedByUserId = UserId;
     if (Case == EControlCase.Edit)
     {
         bh.SavePhTextInAllCc(t);
         Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", AttachQS));
     }
     else if (Case == EControlCase.Translate)
     {
         t.CultureCodeStatus = ECultureCodeStatus.HumanTranslated;
         bh.SavePhText(t);
         Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", AttachQS));
     }
 }
Esempio n. 4
0
 public void CreatePhText(PHText p)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository <PHText>();
         rep.Insert(p);
     }
 }
Esempio n. 5
0
 public void DeletePhText(PHText p)
 {
     using (IDataContext db = DataContext.Instance())
     {
         var rep = db.GetRepository <PHText>();
         rep.Delete(p);
     }
 }
 public void CreatePhText(PHText p)
 {
     using (IDataContext ctx = DataContext.Instance())
     {
         var rep = ctx.GetRepository<PHText>();
         rep.Insert(p);
     }
 }
Esempio n. 7
0
        ///<summary>
        /// Load the title in the CultureCode language from DB. You must set PluggId and CultureCode to get the Title
        ///</summary>
        public void LoadTitle()
        {
            if (ThePlugg == null || ThePlugg.PluggId == 0)
            {
                throw new Exception("Cannot load title. Need PluggId");
            }
            BaseRepository rep = new BaseRepository();

            TheTitle = rep.GetCurrentVersionText(CultureCode, ThePlugg.PluggId, ETextItemType.PluggTitle);
        }
Esempio n. 8
0
        ///<summary>
        /// Load the Description in the CultureCode language from DB. You must set PluggId and CultureCode to get the Description
        ///</summary>
        public void LoadDescription()
        {
            if (ThePlugg == null || ThePlugg.PluggId == 0 || CultureCode == null)
            {
                throw new Exception("Cannot load Description. Need PluggId and CultureCode");
            }
            BaseRepository rep = new BaseRepository();

            TheTitle = rep.GetCurrentVersionText(CultureCode, ThePlugg.PluggId, ETextItemType.PluggDescription);
        }
Esempio n. 9
0
        /// <summary>
        /// Will get the latest version of text in language cultureCode for itemType/itemId
        /// If the text does not exist, it creates a PHText where TextId=0
        /// </summary>
        /// <param name="cultureCode"></param>
        /// <param name="itemId"></param>
        /// <param name="itemType"></param>
        /// <returns></returns>
        public PHText GetCurrentVersionText(string cultureCode, int itemId, ETextItemType itemType)
        {
            PHText txt = rep.GetCurrentVersionText(cultureCode, itemId, itemType);

            if (txt == null)
            {
                txt             = new PHText();
                txt.Text        = "(No text)";
                txt.CultureCode = cultureCode;
                txt.ItemId      = itemId;
                txt.ItemType    = itemType;
            }
            return(txt);
        }
Esempio n. 10
0
        public PHText GetCurrentVersionText(string cultureCode, int itemId, ETextItemType itemType)
        {
            IEnumerable <PHText> txt;
            PHText theText = null;

            using (IDataContext ctx = DataContext.Instance())
            {
                var rep = ctx.GetRepository <PHText>();
                txt = rep.Find("WHERE CultureCode = @0 AND ItemId = @1 AND ItemType = @2 AND CurrentVersion = 'True'", cultureCode, itemId, (int)itemType);
            }

            if (txt.Any())
            {
                theText = txt.First(); //Can only be at most one.
            }
            return(theText);
        }
Esempio n. 11
0
        /// <summary>
        /// Must set Text, ItemId, ItemType, CultureCode, CultureCodeStatus and CreatedByUserId or it will not save anything
        /// If text is versioned, it creates a new version
        /// If text is not versioned, it creates new text or updates text depending on TextId.
        /// </summary>
        /// <param name="t"></param>
        public void SavePhText(PHText t)
        {
            if (t.Text == null || t.ItemId == 0 || t.ItemType == ETextItemType.NotSet || t.CultureCode == null || t.CultureCodeStatus == ECultureCodeStatus.NotSet || t.CreatedByUserId == 0)
            {
                return;  //Nothing to save
            }
            if (t.ModifiedByUserId == 0)
            {
                t.ModifiedByUserId = t.CreatedByUserId;
            }
            t.ModifiedOnDate = DateTime.Now;
            t.CurrentVersion = true;
            bool isVersioned = (t.ItemType == ETextItemType.PluggComponentRichRichText || t.ItemType == ETextItemType.PluggComponentRichText || t.ItemType == ETextItemType.CoursePluggText || t.ItemType == ETextItemType.CourseRichRichText);

            if (isVersioned)
            {
                var prevText = rep.GetCurrentVersionText(t.CultureCode, t.ItemId, t.ItemType);
                if (prevText == null)
                {
                    t.Version = 1;
                }
                else
                {
                    t.Version = prevText.Version + 1;
                    prevText.CurrentVersion = false;
                    rep.UpdatePhText(prevText);
                }
                t.CreatedOnDate = DateTime.Now;
                rep.CreatePhText(t);
            }
            else
            {
                t.Version = 0;
                if (t.TextId == 0)
                {
                    t.CreatedOnDate = DateTime.Now;
                    rep.CreatePhText(t);
                }
                else
                {
                    rep.UpdatePhText(t);
                }
            }
        }
Esempio n. 12
0
        //public void CreateCourse(Course c, List<CourseItemEntity> cis)
        //{
        //    rep.CreateCourse(c);

        //    try
        //    {
        //        foreach (CourseItemEntity ci in cis)
        //        {
        //            ci.CourseId = c.CourseId;
        //            rep.CreateCourseItem(ci);
        //        }
        //    }
        //    catch (Exception)
        //    {
        //        DeleteCourse(c);
        //        throw;
        //    }

        //    //Create CoursePage
        //    DNNHelper d = new DNNHelper();
        //    string pageUrl = "C" + c.CourseId.ToString();
        //    string pageName = pageUrl + ": " + c.Title;
        //    try
        //    {
        //        TabInfo newTab = d.AddCoursePage(pageName, pageUrl);
        //        c.TabId = newTab.TabID;
        //        rep.UpdateCourse(c);
        //    }
        //    catch (Exception)
        //    {
        //        DeleteCourse(c);
        //        throw;
        //    }
        //}

        //public Course GetCourse(int CourseID)
        //{
        //    return rep.GetCourse(CourseID);
        //}

        //public void DeleteCourse(Course c)
        //{
        //    // Todo: Don't delete course if: It has comments or ratings
        //    // Todo: Soft delete of Course
        //    if (c == null)
        //    {
        //        throw new Exception("Cannot delete: Course not initialized");
        //        return;
        //    }

        //    TabController tabController = new TabController();
        //    TabInfo getTab = tabController.GetTab(c.TabId);

        //    if (getTab != null)
        //    {
        //        DNNHelper h = new DNNHelper();
        //        h.DeleteTab(getTab);
        //    }

        //    var cis = rep.GetItemsInCourse(c.CourseId);
        //    foreach (CourseItem ciDelete in cis)
        //    {
        //        rep.DeleteCourseItem(ciDelete);
        //    }

        //    rep.DeleteCourse(c);
        //}

        #endregion

        #region CourseItem

        //public IEnumerable<CourseItem> GetCourseItems(int CourseID, int ItemID)
        //{
        //    return rep.GetCourseItems(CourseID, ItemID);
        //}

        //public List<CourseItem> GetItemsInCourse(int courseId)
        //{
        //    return rep.GetItemsInCourse(courseId);
        //}

        //public IList<CourseItem> FlatToHierarchy(IEnumerable<CourseItem> list, int motherId = 0)
        //{
        //    return (from i in list
        //            where i.MotherId == motherId
        //            select new CourseItem
        //            {
        //                CourseItemId = i.CourseItemId,
        //                CourseId = i.CourseId,
        //                ItemId = i.ItemId,
        //                CIOrder = i.CIOrder,
        //                ItemType = i.ItemType,
        //                MotherId = i.MotherId,
        //                //Mother = i,
        //                label = i.label,
        //                name = i.name,
        //                children = FlatToHierarchy(list, i.CourseItemId)
        //            }).ToList();
        //}

        //public IList<CourseItem> GetCourseItemsAsTree(int courseId)
        //{
        //    List<CourseItem> source = GetItemsInCourse(courseId);
        //    return FlatToHierarchy(source);
        //}

        ////It is assumed that all CourseItems are in the same course
        //public void SaveCourseItems(IList<CourseItem> cis, int courseId, int motherId = 0)
        //{
        //    CourseItemEntity cie = new CourseItemEntity();
        //    int ciOrder = 1;
        //    foreach (CourseItem ci in cis)
        //    {
        //        DeleteCourseItem(ci); //Deletes heading as well if item is a heading

        //        if (ci.ItemType == ECourseItemType.Heading)
        //        {
        //            CourseMenuHeadings ch = new CourseMenuHeadings();
        //            ch.Title = ci.name;
        //            rep.CreateHeading(ch);
        //            cie.ItemId = ch.HeadingID;
        //        }
        //        else
        //            cie.ItemId = ci.ItemId;

        //        cie.CourseId = courseId;
        //        cie.CIOrder = ciOrder;
        //        cie.ItemType = ci.ItemType;
        //        cie.MotherId = motherId;
        //        rep.CreateCourseItem(cie);
        //        ciOrder += 1;
        //        if (ci.children != null)
        //            SaveCourseItems(ci.children, courseId, cie.CourseItemId);
        //    }
        //}

        //public void CreateCourseItem(CourseItem ci)
        //{
        //    rep.CreateCourseItem(ci);
        //}

        //public void UpdateCourseItem(CourseItem ci)
        //{
        //    rep.UpdateCourseItem(ci);
        //}

        //public void DeleteCourseItem(CourseItem ci)
        //{
        //    if (ci.ItemType == ECourseItemType.Heading)
        //        rep.DeleteHeading(new CourseMenuHeadings() {HeadingID =ci.ItemId});
        //    rep.DeleteCourseItem(ci);
        //}

        #endregion

        #region PHTextAndLatex

        /// <summary>
        /// This method will save the text in all Culture Codes
        /// It expects the text to be created in t.CultureCode
        /// It will call SavePhText(t)
        /// It then translates t into all languages and calls SavePhText on each text
        /// </summary>
        /// <param name="t"></param>
        public void SavePhTextInAllCc(PHText t)
        {
            t.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
            SavePhText(t);  //Save Text in created language
            LocaleController lc = new LocaleController();
            var    locales      = lc.GetLocales(PortalID);
            PHText translatedText;

            foreach (var locale in locales)
            {
                if (locale.Key != t.CultureCode)
                {
                    translatedText      = GetCurrentVersionText(locale.Key, t.ItemId, t.ItemType);
                    translatedText.Text = TranslateText(t.CultureCode.Substring(0, 2), locale.Key.Substring(0, 2), t.Text);
                    translatedText.CultureCodeStatus = ECultureCodeStatus.GoogleTranslated;
                    SavePhText(translatedText);
                }
            }
        }
 protected void btnSave_Click(object sender, EventArgs e)
 {
     BaseHandler bh = new BaseHandler();
     PHText t = bh.GetCurrentVersionText(CultureCode, ItemId, ItemType);
     if (t == null)
     {
         t = new PHText();
         t.CreatedByUserId = UserId;
         t.CultureCode = CultureCode;
         t.ItemId = ItemId;
         t.ItemType = ItemType;
     }
     t.Text = Regex.Replace(tbTheText.Text, "<[^>]*>", String.Empty);
     t.ModifiedByUserId = UserId;
     if (Case == EControlCase.Edit)
     {
         bh.SavePhTextInAllCc(t);
         if (ItemType == ETextItemType.PluggTitle)
         {
             string newPageName = ItemId.ToString() + ": " + t.Text;
             PluggContainer pc = new PluggContainer(CultureCode, ItemId);
             DNNHelper h = new DNNHelper();
             h.RenameTab(pc.ThePlugg.TabId, newPageName);
         }
         if (ItemType == ETextItemType.CourseTitle)
         {
             string newPageName = "C" + ItemId.ToString() + ": " + t.Text;
             CourseContainer cc = new CourseContainer(CultureCode, ItemId);
             DNNHelper h = new DNNHelper();
             h.RenameTab(cc.TheCourse.TabId, newPageName);
         }
         Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", "edit=0", AttachQS));
     }
     else if (Case == EControlCase.Translate)
     {
         t.CultureCodeStatus = ECultureCodeStatus.HumanTranslated;
         bh.SavePhText(t);
         Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", "translate=0", AttachQS));
     }
 }
Esempio n. 14
0
        protected void btnOk_Click(object sender, EventArgs e)
        {
            try
            {
                if (txtTitle.Text.Trim() == "")
                {
                    Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Err", "alert('Please enter title !')", true);
                    return;
                }
                BaseHandler bh = new BaseHandler();
                List<object> cmpData = new List<object>();
                PluggContainer pc = new PluggContainer(new Localization().CurrentCulture);
                //pc.ThePlugg.CreatedByUserId = this.UserId;
                //pc.ThePlugg.ModifiedByUserId = this.UserId;
                pc.ThePlugg.PluggId = 0;
                pc.SetTitle(txtTitle.Text);

                //pc.SetDescription(txtDescription.Text);

                PHText RichRichText = new PHText();
                RichRichText.ItemType = ETextItemType.PluggComponentRichRichText;
                cmpData.Add(RichRichText);

                Plugghest.Base2.YouTube objYouTube = new Plugghest.Base2.YouTube();
                cmpData.Add(objYouTube);

                bh.SavePlugg(pc, cmpData);

                txtTitle.Text = "";
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Success", "alert('New Plugg is created successfully')", true);
            }
            catch (Exception ex)
            {
                Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "Error", "alert('Error : " + ex.Message + "')", true);
            }
        }
Esempio n. 15
0
 /// <summary>
 /// Will get the latest version of text in language cultureCode for itemType/itemId
 /// If the text does not exist, it creates a PHText where TextId=0
 /// </summary>
 /// <param name="cultureCode"></param>
 /// <param name="itemId"></param>
 /// <param name="itemType"></param>
 /// <returns></returns>
 public PHText GetCurrentVersionText(string cultureCode, int itemId, ETextItemType itemType)
 {
     PHText txt = rep.GetCurrentVersionText(cultureCode, itemId, itemType);
     if(txt == null)
     {
         txt = new PHText();
         txt.Text = "(No text)";
         txt.CultureCode = cultureCode;
         txt.ItemId = itemId;
         txt.ItemType = itemType;
     }
     return txt;
 }
Esempio n. 16
0
        /// <summary>
        /// Must set Text, ItemId, ItemType, CultureCode, CultureCodeStatus and CreatedByUserId or it will not save anything
        /// If text is versioned, it creates a new version
        /// If text is not versioned, it creates new text or updates text depending on TextId.
        /// </summary>
        /// <param name="t"></param>
        public void SavePhText(PHText t)
        {
            if (t.Text == null || t.ItemId == 0 || t.ItemType == ETextItemType.NotSet || t.CultureCode == null || t.CultureCodeStatus == ECultureCodeStatus.NotSet || t.CreatedByUserId == 0)
                return;  //Nothing to save

            if (t.ModifiedByUserId == 0)
                t.ModifiedByUserId = t.CreatedByUserId;
            t.ModifiedOnDate = DateTime.Now;
            t.CurrentVersion = true;
            bool isVersioned = (t.ItemType == ETextItemType.PluggComponentRichRichText || t.ItemType == ETextItemType.PluggComponentRichText || t.ItemType == ETextItemType.CoursePluggText || t.ItemType == ETextItemType.CourseRichRichText);

            if (isVersioned)
            {
                var prevText = rep.GetCurrentVersionText(t.CultureCode, t.ItemId, t.ItemType);
                if (prevText == null)
                {
                    t.Version = 1;
                }
                else
                {
                    t.Version = prevText.Version + 1;
                    prevText.CurrentVersion = false;
                    rep.UpdatePhText(prevText);
                }
                t.CreatedOnDate = DateTime.Now;
                rep.CreatePhText(t);
            }
            else
            {
                t.Version = 0;
                if (t.TextId == 0)
                {
                    t.CreatedOnDate = DateTime.Now;
                    rep.CreatePhText(t);
                }
                else
                    rep.UpdatePhText(t);
            }
        }
Esempio n. 17
0
        protected void btnSaveTitle_Click(object sender, EventArgs e)
        {
            BaseHandler bh = new BaseHandler();
            PluggContainer pc = new PluggContainer(new Localization().CurrentCulture);
            pc.ThePlugg.CreatedByUserId = this.UserId;
            pc.ThePlugg.ModifiedByUserId = this.UserId;
            pc.ThePlugg.PluggId = 0;
            pc.ThePlugg.WhoCanEdit = (EWhoCanEdit)Enum.Parse(typeof(EWhoCanEdit), rdEditPlug.SelectedValue);
            pc.SetTitle(txtTitle.Text);
            pc.SetDescription(txtDescription.Text);

            List<object> cmpData = new List<object>();

            foreach (string StrCmpData in hdcmpData.Value.Split(new string[] { "$#%#$%" }, StringSplitOptions.RemoveEmptyEntries))
            {
                string[] straCmpData = StrCmpData.Split(new string[] { "$$$&$$$" }, StringSplitOptions.RemoveEmptyEntries);

                switch (straCmpData[0])
                {
                    case "RichRichText":
                        PHText RichRichText = new PHText();
                        RichRichText.Text = straCmpData[1];
                        RichRichText.ItemType = ETextItemType.PluggComponentRichRichText;
                        cmpData.Add(RichRichText);
                        break;
                    case "RichText":
                        PHText RichText = new PHText();
                        RichText.Text = straCmpData[1];
                        RichText.ItemType = ETextItemType.PluggComponentRichText;
                        cmpData.Add(RichText);
                        break;
                    case "Label":
                        PHText Label = new PHText();
                        Label.Text = straCmpData[1];
                        Label.ItemType = ETextItemType.PluggComponentLabel;
                        cmpData.Add(Label);
                        break;
                    case "Latex":
                        PHLatex Latex = new PHLatex(straCmpData[1], new Localization().CurrentCulture,ELatexItemType.PluggComponentLatex);
                        cmpData.Add(Latex);
                        break;
                    case "YouTube":
                        Plugghest.Base2.YouTube objYouTube = new Plugghest.Base2.YouTube();
                        string[] strYoutubeval = straCmpData[1].Split(new string[] { "&&&$$&&&" }, StringSplitOptions.RemoveEmptyEntries);
                        objYouTube.YouTubeAuthor = strYoutubeval[3];
                        objYouTube.YouTubeCode = strYoutubeval[2];
                        objYouTube.YouTubeComment = strYoutubeval[5];
                        objYouTube.YouTubeCreatedOn = Convert.ToDateTime(strYoutubeval[4]);
                        objYouTube.YouTubeDuration = Convert.ToInt32(strYoutubeval[1]);
                        objYouTube.YouTubeTitle = strYoutubeval[0];
                        cmpData.Add(objYouTube);
                        break;
                }

            }
            bh.SavePlugg(pc, cmpData);
        }
Esempio n. 18
0
 public void CreateSubject(Subject s, int userId)
 {
     if (s == null || s.SubjectId != 0 || s.SubjectOrder == 0)
         throw new Exception("Cannot create subject");
     IEnumerable<Subject> sameMother = rep.GetChildrenSubjects(s.MotherId);
     foreach(Subject tmpS in sameMother)
     {
         if (tmpS.SubjectOrder >= s.SubjectOrder)
         {
             tmpS.SubjectOrder++;
             rep.UpdateSubject(tmpS);
         }
     }
     rep.CreateSubject(s);
     PHText sText = new PHText(s.label, "en-US", ETextItemType.Subject);
     sText.CreatedByUserId = userId;
     sText.ItemId = s.SubjectId;
     sText.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
     SavePhTextInAllCc(sText);
 }
Esempio n. 19
0
 ///<summary>
 /// Load TheHtmlCourseText in the CultureCode language from DB. You must set CourseId and CultureCode to get TheHtmlCourseText
 ///</summary>
 public void LoadTheHtmlCourseText()
 {
     if (TheCourse == null || TheCourse.CourseId == 0 || CultureCode == null)
         throw new Exception("Cannot load TheHtmlCourseText. Need CourseId and CultureCode");
     BaseHandler bh = new BaseHandler();
     TheHtmlCourseText = bh.GetCurrentVersionText(CultureCode, TheCourse.CourseId, ETextItemType.CourseRichRichText);
 }
Esempio n. 20
0
 ///<summary>
 /// Creates a HtmlCourseText Object (a PHText). 
 /// Sets its Text to htmlText, 
 /// its CultureCode to the CultureCode of the CourseContainer,
 /// its ETextItemType to CourseRichRichText.
 /// its ItemId to TheCourse.CourseId
 /// To save it (itemId must be different from zero) use BaseHandler.SavePhText(PHText t) or SavePhTextInAllCc
 /// Note that BaseHandler.CreateCourse(CourseContainer c) will NOT create HtmlCourseText
 ///</summary>
 public void SetTheHtmlCourseText(string htmlText)
 {
     TheHtmlCourseText = new PHText(htmlText, CultureCode, ETextItemType.CourseRichRichText);
     TheHtmlCourseText.ItemId = TheCourse.CourseId;
 }
Esempio n. 21
0
 private void CreateBtnImproveHumGoogleTrans(PluggComponent comp, PHText lbl, string css, string id,string BtnText)
 {
     Button btnImpHumTras = new Button();
     btnImpHumTras.CssClass = css;
     btnImpHumTras.ID = id;
     btnImpHumTras.Text = BtnText;
     btnImpHumTras.Click += (s, e) => { ImpGoogleTrans(comp, lbl); };
     divTitle.Controls.Add(btnImpHumTras);
 }
Esempio n. 22
0
 /////<summary>
 ///// Loads all the components of a Course into TheComponents.
 ///// Note: If the actual content of the component has not yet been created, Load will create an empty object with the correct ItemType
 /////</summary>
 ///// <returns> returns nothing.</returns>
 //public void LoadComponents()
 //{
 //    BaseRepository rep = new BaseRepository();
 //    TheComponents = rep.GetAllComponentsInCourse(TheCourse.CourseId);
 //}
 //public List<CourseComponent> GetComponentList()
 //{
 //    if (TheComponents == null)
 //        LoadComponents();
 //    return TheComponents.ToList();
 //}
 public void SetRichRichText(string htmlText)
 {
     TheRichRichText = new PHText(htmlText, CultureCode, ETextItemType.CourseRichRichText);
 }
Esempio n. 23
0
 ///<summary>
 /// Create a Description Object (a PHText).
 /// Sets its Text to htmlText, 
 /// its CultureCode to the CultureCode of the PluggContainer,
 /// its ETextItemType to PluggDescription.
 /// To save it, use BaseHandler.SavePhText(PHText t)
 ///</summary>
 public void SetDescription(string htmlText)
 {
     TheDescription = new PHText(htmlText, CultureCode, ETextItemType.PluggDescription);
 }
Esempio n. 24
0
 private string CreateDiv(PHText Phtxt, string divid, string obj)
 {
     string HTMLstring = "";
     if (Phtxt == null)
         HTMLstring = "<div><div id=" + divid + " class='Main'" + obj + " ";
     else
         HTMLstring = "<div><div id=" + divid + " class='Main'=>" + obj + " " + Phtxt.Text + " ";
     divTitle.Controls.Add(new LiteralControl(HTMLstring));
     return HTMLstring;
 }
Esempio n. 25
0
 ///<summary>
 /// Load the Description in the CultureCode language from DB. You must set PluggId and CultureCode to get the Description
 ///</summary>
 public void LoadDescription()
 {
     if (ThePlugg == null || ThePlugg.PluggId == 0 || CultureCode == null)
         throw new Exception("Cannot load Description. Need PluggId and CultureCode");
     BaseHandler bh = new BaseHandler();
     TheDescription = bh.GetCurrentVersionText(CultureCode, ThePlugg.PluggId, ETextItemType.PluggDescription);
 }
Esempio n. 26
0
 ///<summary>
 /// Load the Description in the CultureCode language from DB. You must set PluggId and CultureCode to get the Description
 ///</summary>
 public void LoadDescription()
 {
     if (ThePlugg == null || ThePlugg.PluggId == 0 || CultureCode == null)
         throw new Exception("Cannot load Description. Need PluggId and CultureCode");
     BaseRepository rep = new BaseRepository();
     TheTitle = rep.GetCurrentVersionText(CultureCode, ThePlugg.PluggId, ETextItemType.PluggDescription);
 }
Esempio n. 27
0
 private void GoogleTranText(PHText txt)
 {
     BaseHandler bh = new BaseHandler();
     txt.CultureCodeStatus = ECultureCodeStatus.HumanTranslated;
     bh.SavePhText(txt);
     Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", new string[] { "edit=" + EditStr, "language=" + curlan }));
 }
Esempio n. 28
0
 /// <summary>
 /// This method will save the text in all Culture Codes
 /// It expects the text to be created in t.CultureCode
 /// It will call SavePhText(t)
 /// It then translates t into all languages and calls SavePhText on each text
 /// </summary>
 /// <param name="t"></param>
 public void SavePhTextInAllCc(PHText t)
 {
     t.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
     SavePhText(t);  //Save Text in created language
     LocaleController lc = new LocaleController();
     var locales = lc.GetLocales(PortalID);
     PHText translatedText;
     foreach (var locale in locales)
     {
         if (locale.Key != t.CultureCode)
         {
             translatedText = GetCurrentVersionText(locale.Key, t.ItemId, t.ItemType);
             translatedText.Text = TranslateText(t.CultureCode.Substring(0, 2), locale.Key.Substring(0, 2), t.Text);
             translatedText.CultureCodeStatus = ECultureCodeStatus.GoogleTranslated;
             SavePhText(translatedText);
         }
     }
 }
Esempio n. 29
0
 ///<summary>
 /// Create a Description Object (a PHText).
 /// Sets its Text to htmlText,
 /// its CultureCode to the CultureCode of the PluggContainer,
 /// its ETextItemType to PluggDescription.
 /// To save it, use BaseHandler.SavePhText(PHText t)
 ///</summary>
 public void SetDescription(string htmlText)
 {
     TheDescription = new PHText(htmlText, CultureCode, ETextItemType.PluggDescription);
 }
Esempio n. 30
0
 ///<summary>
 /// Load the title in the CultureCode language from DB. You must set CourseId and CultureCode to get the Title
 ///</summary>
 public void LoadTitle()
 {
     if (TheCourse == null || TheCourse.CourseId == 0)
         throw new Exception("Cannot load title. Need CourseId");
     BaseRepository rep = new BaseRepository();
     TheTitle = rep.GetCurrentVersionText(CultureCode, TheCourse.CourseId, ETextItemType.CourseTitle);
 }
Esempio n. 31
0
 private void CreateBtnGoogleT(PHText rrt, string CssClassGT, string IDGT)
 {
     Button btnGT = new Button();
     btnGT.CssClass = CssClassGT;
     btnGT.ID = IDGT;
     btnGT.Text = BtnGoogleTransTxtOkTxt;
     btnGT.Click += (s, e) => { GoogleTranText(rrt); };
     divTitle.Controls.Add(btnGT);
 }
Esempio n. 32
0
 public void UpdatePhText(PHText p)
 {
     using (IDataContext db = DataContext.Instance())
     {
         var rep = db.GetRepository<PHText>();
         rep.Update(p);
     }
 }
Esempio n. 33
0
 private void CreateBtnEdit(PluggComponent comp, PHText lbl, string CssClass, string ID)
 {
     Button editbtn = new Button();
     editbtn.CssClass = CssClass;
     editbtn.ID = ID;
     editbtn.Text = BtnEditTxt;
     editbtn.Click += (s, e) => { ImpGoogleTrans(comp, lbl); };
     divTitle.Controls.Add(editbtn);
 }
Esempio n. 34
0
 ///<summary>
 /// Create a Description Object (a PHText).
 /// Sets its Text to htmlText, 
 /// its CultureCode to the CultureCode of the CourseContainer,
 /// its ETextItemType to CourseDescription.
 /// its ItemId to TheCourse.CourseId
 /// To save Description if ItemId is not zero (existing Course), use BaseHandler.SavePhText(PHText t) or SavePhTextInAllCc
 /// If this is a new course, use BaseHandler.CreateCourse(CourseContainer c) which also creates the Description in all Cc
 ///</summary>
 public void SetDescription(string htmlText)
 {
     TheDescription = new PHText(htmlText, CultureCode, ETextItemType.CourseDescription);
     TheDescription.ItemId = TheCourse.CourseId;
 }
Esempio n. 35
0
        protected void btnSaveRRt_Click(object sender, EventArgs e)
        {
            var id = hdnlabel.Value;
            var itemid = Convert.ToInt32(id);

            List<PluggComponent> comps = p.GetComponentList();
            PluggComponent cToAdd = comps.Find(x => x.PluggComponentId == Convert.ToInt32(id));
            BaseHandler bh = new BaseHandler();

            var comtype = cToAdd.ComponentType;

            switch (cToAdd.ComponentType)
            {
                case EComponentType.RichRichText:
                    //PHText RichRichText = bh.GetCurrentVersionText(curlan, itemid, ETextItemType.PluggComponentRichRichText);
                    //RichRichText.Text = richrichtext.Text;

                    PHText objPHtext = new PHText(System.Net.WebUtility.HtmlDecode(richrichtext.Text), curlan, ETextItemType.PluggComponentRichRichText);
                    objPHtext.CultureCodeStatus = ECultureCodeStatus.GoogleTranslated;
                    objPHtext.ItemId = itemid;
                    objPHtext.CreatedByUserId = this.UserId;

                    if (EditStr == "2")
                        objPHtext.CultureCodeStatus = ECultureCodeStatus.HumanTranslated;

                    bh.SavePhTextInAllCc(objPHtext);
                    break;

                case EComponentType.Latex:

                    PHLatex latex = bh.GetCurrentVersionLatexText(curlan, Convert.ToInt32(id), ELatexItemType.PluggComponentLatex);
                    latex.CultureCodeStatus = ECultureCodeStatus.GoogleTranslated;
                    latex.ItemId = itemid;
                    latex.CreatedByUserId = this.UserId;
                    latex.Text = System.Net.WebUtility.HtmlDecode(richrichtext.Text);
                    //bh.SaveLatexText(latex);
                    bh.SaveLatexTextInAllCc(latex);
                    break;
            }

            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(TabId, "", new string[] { "edit=" + EditStr, "language=" + curlan }));
        }
Esempio n. 36
0
 ///<summary>
 /// Creates a Title Object (a PHText). 
 /// Sets its Text to htmlText, 
 /// its CultureCode to the CultureCode of the CourseContainer,
 /// its ETextItemType to CourseTitle,
 /// its ItemId to TheCourse.CourseId
 /// To save Title if ItemId is not zero (existing Course), use BaseHandler.SavePhText(PHText t) or SavePhTextInAllCc
 /// If this is a new course, use BaseHandler.CreateCourse(CourseContainer c) which also creates the Title in all Cc
 ///</summary>
 public void SetTitle(string htmlText)
 {
     TheTitle = new PHText(htmlText, CultureCode, ETextItemType.CourseTitle);
     TheTitle.ItemId = TheCourse.CourseId;
 }
Esempio n. 37
0
        private void ImpGoogleTrans(PluggComponent comp, PHText CulTxt)
        {
            hdnlabel.Value = Convert.ToString(comp.PluggComponentId);

            string text = CulTxt.Text;
            switch (comp.ComponentType)
            {
                case EComponentType.Label:
                    CompHide();
                    txtlabel.Text = text;
                    pnllabel.Visible = true;
                    break;

                case EComponentType.RichText:
                    CompHide();
                    richtextbox.Visible = true;
                    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "", " $(document).ready(function () {$('#editor').html('" + text.Replace("\r\n", "<br />") + "')});", true);
                    break;

                case EComponentType.RichRichText:
                    CompHide();
                    pnlRRT.Visible = true;
                    richrichtext.Text = text;
                    break;
            }
            pnlPluggCom.Visible = false;
        }
Esempio n. 38
0
 ///<summary>
 /// Load the title in the CultureCode language from DB. You must set PluggId and CultureCode to get the Title
 ///</summary>
 public void LoadTitle()
 {
     if (ThePlugg == null || ThePlugg.PluggId == 0)
         throw new Exception("Cannot load title. Need PluggId");
     BaseHandler bh = new BaseHandler();
     TheTitle = bh.GetCurrentVersionText(CultureCode, ThePlugg.PluggId, ETextItemType.PluggTitle);
 }
Esempio n. 39
0
 ///<summary>
 /// Creates a Title Object (a PHText).
 /// Sets its Text to htmlText,
 /// its CultureCode to the CultureCode of the PluggContainer,
 /// its ETextItemType to PluggTitle.
 /// To save it, use BaseHandler.SavePhText(PHText t)
 ///</summary>
 public void SetTitle(string htmlText)
 {
     TheTitle = new PHText(htmlText, CultureCode, ETextItemType.PluggTitle);
 }
Esempio n. 40
0
 ///<summary>
 /// Creates a Title Object (a PHText). 
 /// Sets its Text to htmlText, 
 /// its CultureCode to the CultureCode of the PluggContainer,
 /// its ETextItemType to PluggTitle.
 /// To save it, use BaseHandler.SavePhText(PHText t)
 ///</summary>
 public void SetTitle(string htmlText)
 {
     TheTitle = new PHText(htmlText, CultureCode, ETextItemType.PluggTitle);
 }
Esempio n. 41
0
        public void SavePlugg(PluggContainer p, List <object> cs)
        {
            if (p.ThePlugg.CreatedInCultureCode != null && p.CultureCode != p.ThePlugg.CreatedInCultureCode)
            {
                throw new Exception("Cannot use SavePlugg unless you are saving it in the creation language.");
            }

            p.ThePlugg.CreatedInCultureCode = p.CultureCode;

            try
            {
                bool isNew = p.ThePlugg.PluggId == 0;

                //Temporary - to avoid login - remove soon
                p.ThePlugg.CreatedByUserId  = 1;
                p.ThePlugg.ModifiedByUserId = 1;

                //Save Plugg entity
                p.ThePlugg.ModifiedOnDate = DateTime.Now;

                if (isNew)
                {
                    p.ThePlugg.CreatedOnDate = DateTime.Now;
                    rep.CreatePlugg(p.ThePlugg);
                }
                else
                {
                    rep.UpdatePlugg(p.ThePlugg);
                }

                //Save Title
                if (p.TheTitle == null || p.TheTitle.Text == null)
                {
                    throw new Exception("Cannot Save Plugg. TheTitle cannot be null");
                }

                if (p.TheTitle.TextId == 0)
                {
                    p.TheTitle.ItemId            = p.ThePlugg.PluggId;
                    p.TheTitle.ItemType          = ETextItemType.PluggTitle;
                    p.TheTitle.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
                    p.TheTitle.CreatedByUserId   = p.ThePlugg.CreatedByUserId;
                    p.TheTitle.ModifiedByUserId  = p.ThePlugg.ModifiedByUserId;
                }
                SavePhTextInAllCc(p.TheTitle);  //Save or Update

                if (p.TheDescription != null && p.TheDescription.Text != null)
                {
                    if (p.TheDescription.TextId == 0)
                    {
                        p.TheDescription.ItemId            = p.ThePlugg.PluggId;
                        p.TheDescription.ItemType          = ETextItemType.PluggDescription;
                        p.TheDescription.CultureCodeStatus = ECultureCodeStatus.InCreationLanguage;
                        p.TheDescription.CreatedByUserId   = p.ThePlugg.CreatedByUserId;
                        p.TheDescription.ModifiedByUserId  = p.ThePlugg.ModifiedByUserId;
                    }
                    SavePhTextInAllCc(p.TheDescription);
                }

                int            cmpOrder = 1;
                PluggComponent pc       = new PluggComponent();
                pc.PluggId = p.ThePlugg.PluggId;
                foreach (object cmp in cs)
                {
                    pc.ComponentOrder = cmpOrder;
                    switch (cmp.GetType().Name)
                    {
                    case "PHText":
                        PHText theText = (PHText)cmp;
                        switch (theText.ItemType)
                        {
                        case ETextItemType.PluggComponentRichRichText:
                            pc.ComponentType = EComponentType.RichRichText;
                            break;

                        case ETextItemType.PluggComponentRichText:
                            pc.ComponentType = EComponentType.RichText;
                            break;

                        case ETextItemType.PluggComponentLabel:
                            pc.ComponentType = EComponentType.Label;
                            break;
                        }
                        rep.CreatePluggComponent(pc);
                        theText.ItemId          = pc.PluggComponentId;
                        theText.CultureCode     = p.ThePlugg.CreatedInCultureCode;
                        theText.CreatedByUserId = p.ThePlugg.CreatedByUserId;
                        SavePhTextInAllCc(theText);
                        break;

                    case "PHLatex":
                        PHLatex theLatex = (PHLatex)cmp;
                        pc.ComponentType = EComponentType.Latex;
                        rep.CreatePluggComponent(pc);
                        theLatex.ItemId          = pc.PluggComponentId;
                        theLatex.CultureCode     = p.ThePlugg.CreatedInCultureCode;
                        theLatex.CreatedByUserId = p.ThePlugg.CreatedByUserId;
                        SaveLatexTextInAllCc(theLatex);
                        break;

                    case "YouTube":
                        pc.ComponentType = EComponentType.YouTube;
                        rep.CreatePluggComponent(pc);
                        YouTube theVideo = (YouTube)cmp;
                        theVideo.CreatedByUserId  = p.ThePlugg.CreatedByUserId;
                        theVideo.PluggComponentId = pc.PluggComponentId;
                        SaveYouTube(theVideo);
                        break;
                    }
                    cmpOrder++;
                }

                //Create PluggPage
                DNNHelper d        = new DNNHelper();
                string    pageUrl  = p.ThePlugg.PluggId.ToString();
                string    pageName = pageUrl + ": " + p.TheTitle.Text;
                TabInfo   newTab   = d.AddPluggPage(pageName, pageUrl);
                p.ThePlugg.TabId = newTab.TabID;
                rep.UpdatePlugg(p.ThePlugg);
            }
            catch (Exception)
            {
                //Todo: Update
                //DeletePlugg(p.ThePlugg);
                throw;
            }
        }