Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                string coursePageName = ((DotNetNuke.Framework.CDefault)this.Page).Title;
                coursePageName = coursePageName.Replace("C", "");
                CourseId = Convert.ToInt32(coursePageName);
                CultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
                BaseHandler bh = new BaseHandler();
                cc = new CourseContainer(CultureCode, CourseId);
                if (cc.TheCourse.IsDeleted)
                    Response.Redirect(DotNetNuke.Common.Globals.NavigateURL(Convert.ToInt32(Localization.GetString("TabCourseDeleted.Text", LocalResourceFile))));
                InCreationLanguage = (cc.TheCourse.CreatedInCultureCode == CultureCode);
                IsAuthorized = ((this.UserId != -1 && cc.TheCourse.WhoCanEdit == EWhoCanEdit.Anyone) || cc.TheCourse.CreatedByUserId == this.UserId || (UserInfo.IsInRole("Administator")));
                Edit = !string.IsNullOrEmpty(Page.Request.QueryString["edit"]) ? Convert.ToInt16(Page.Request.QueryString["edit"]) : -1;
                Translate = !string.IsNullOrEmpty(Page.Request.QueryString["translate"]) ? Convert.ToInt16(Page.Request.QueryString["translate"]) : -1;
                DisplayInfo = !string.IsNullOrEmpty(Page.Request.QueryString["info"]) ? Convert.ToInt16(Page.Request.QueryString["info"]) : -1;
                bool editOrTranslateMode = (Edit > -1 || Translate > -1) && UserId > -1;

                #region hide/display controls
                hlDisplayInfo.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "info=0");
                if (DisplayInfo == 0)
                {
                    pnlDisplayInfo.Visible = false;
                    pnlHideDisplayInfo.Visible = true;
                    hlHideDisplayInfo.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "");
                }

                if (!InCreationLanguage && UserId > -1 && Translate == -1)
                {
                    pnlToCreationLanguage.Visible = true;
                    hlToCreationLanguage.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "language=" + cc.TheCourse.CreatedInCultureCode);
                    pnlTranslatePlugg.Visible = true;
                    hlTranslatePlugg.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "translate=0");
                }

                if (InCreationLanguage && UserId > -1 && Edit == -1)
                {
                    pnlEditPlugg.Visible = true;
                    hlEditPlugg.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "edit=0");
                }

                if (!InCreationLanguage && UserId > -1 && Translate > -1)
                {
                    pnlExitTranslateMode.Visible = true;
                    hlExitTranslateMode.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "");
                }

                if (InCreationLanguage && UserId > -1 && Edit > -1)
                {
                    pnlExitEditMode.Visible = true;
                    hlExitEditMode.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(TabId, "", "");
                }

                if (Edit == 0)
                {
                    plEditPluggs.Visible = true;
                    hlEditPluggs.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(133, "", "c=" + CourseId); //"/PAndC/Edit-CP/c/" + CourseId;
                }

                cc.LoadPluggs();
                if (cc.ThePluggs.Count == 0)
                {
                    lblNoPluggs.Visible = true;
                    lnkBeginCourse.Enabled = false;
                }
                else
                {
                    PluggContainer pc = new PluggContainer(CultureCode, cc.ThePluggs[0].PluggId);
                    lnkBeginCourse.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(pc.ThePlugg.TabId, "", "cp=" + cc.ThePluggs[0].CoursePluggId);
                }
                #endregion

                phComponents.Controls.Clear();
                int controlOrder = 1;

                if (DisplayInfo == 0)
                {
                    DisplayCourseInfo ucDCI = (DisplayCourseInfo)this.LoadControl("/DesktopModules/DisplayCourse/DisplayCourseInfo.ascx");
                    if (ucDCI != null)
                    {
                        ucDCI.LocalResourceFile = "/DesktopModules/DisplayCourse/App_LocalResources/DisplayCourseInfo.ascx";
                        phComponents.Controls.Add(ucDCI);
                    }
                }

                if (editOrTranslateMode)
                {
                    string ComponentHead = "<hr /><h3>" + Localization.GetString("Subject", LocalResourceFile) + "</h3>";
                    phComponents.Controls.Add(new LiteralControl(ComponentHead));
                }
                LoadSubject(controlOrder);
                controlOrder++;

                if (editOrTranslateMode)
                {
                    string ComponentHead = "<hr /><h3>" + Localization.GetString("Title", LocalResourceFile) + "</h3>";
                    phComponents.Controls.Add(new LiteralControl(ComponentHead));
                    EditTitleAndDescription(controlOrder, ETextItemType.CourseTitle);
                    controlOrder++;

                    ComponentHead = "<hr /><h3>" + Localization.GetString("Description", LocalResourceFile) + "</h3>";
                    phComponents.Controls.Add(new LiteralControl(ComponentHead));
                    EditTitleAndDescription(controlOrder, ETextItemType.CourseDescription );
                    controlOrder++;
                }

                if (editOrTranslateMode)
                {
                    string ComponentHead = "<hr /><h3>" + Localization.GetString("Content", LocalResourceFile) + "</h3>";
                    phComponents.Controls.Add(new LiteralControl(ComponentHead));
                }

                LoadRichRich(controlOrder);

            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
Beispiel #2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!IsPostBack)
                {
                    BaseHandler bh = new BaseHandler();
                    CultureCode = (Page as DotNetNuke.Framework.PageBase).PageCulture.Name;
                    PluggId = Convert.ToInt32(((DotNetNuke.Framework.CDefault)this.Page).Title);

                    string coursePluggIdStr = Page.Request.QueryString["cp"];
                    if (coursePluggIdStr == null)    //This is a Plugg outside a course: no menu
                        return;

                    bool isNum = int.TryParse(coursePluggIdStr, out CoursePluggId);
                    if (!isNum)
                        return;

                    currentCPE = bh.GetCPEntity(CoursePluggId);
                    if (currentCPE == null)
                        return;
                    CourseId = currentCPE.CourseId;
                    cc = new CourseContainer(CultureCode, CourseId);
                    if (cc == null)
                        return;
                    pnlTitle.Visible = true;
                    hlBackToCourse.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(cc.TheCourse.TabId, "", "");
                    cc.LoadPluggs();
                    CoursePlugg currentCP = bh.FindCoursePlugg(CultureCode, CourseId, CoursePluggId);
                    CoursePlugg nextCP = bh.NextCoursePlugg(currentCP);
                    if (nextCP != null)
                    {
                        PluggContainer p = new PluggContainer(CultureCode, nextCP.PluggId);
                        lnkNextPlugg.NavigateUrl = DotNetNuke.Common.Globals.NavigateURL(p.ThePlugg.TabId, "", "cp=" + nextCP.CoursePluggId );
                    }
                    else
                    {
                        lnkNextPlugg.Enabled = false;
                    }

                    PopulateTreeNodes((List<CoursePlugg>)cc.ThePluggs, TreeViewMain.Nodes);
                }

            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }