コード例 #1
0
        private void BindData()
        {
            FAQsController             FAQsController = new FAQsController();
            IEnumerable <CategoryInfo> cats           = FAQsController.ListCategoriesHierarchical(ModuleId, false);
            // treeCategories fails with int? FaqCategoryParentId
            // define a temp class that has no nullables
            // set null ints to Null.NullInt
            var lst = new List <CategoryInfoTreeNode>();

            foreach (CategoryInfo cat in cats)
            {
                lst.Add(cat.ToTreeNode());
            }

            treeCategories.Nodes.Clear();
            treeCategories.DataTextField     = "FaqCategoryName";
            treeCategories.DataFieldID       = "FaqCategoryId";
            treeCategories.DataFieldParentID = "FaqCategoryParentId";
            treeCategories.DataSource        = lst;
            treeCategories.DataBind();
            if (!IsPostBack && treeCategories.Nodes.Count > 0)
            {
                treeCategories.Nodes[0].Selected = true;
            }
        }
コード例 #2
0
        /// <summary>
        /// Populates the categories drop down.
        /// </summary>
        private void PopulateCategoriesDropDown()
        {
            FAQsController FAQsController = new FAQsController();

            foreach (CategoryInfo category in FAQsController.ListCategoriesHierarchical(ModuleId, false))
            {
                drpCategory.Items.Add(new ListItem(new string('.', category.Level * 3) + category.FaqCategoryName, category.FaqCategoryId.ToString()));
            }
        }
コード例 #3
0
        /// <summary>
        /// Populates the categories drop down.
        /// </summary>
        private void PopulateCategoriesDropDown()
        {
            FAQsController FAQsController = new FAQsController();

            foreach (CategoryInfo category in FAQsController.ListCategoriesHierarchical(ModuleId, false))
            {
                drpCategory.Items.Add(new ListItem(new string('.', category.Level * 3) + category.FaqCategoryName, category.FaqCategoryId.ToString()));
            }
        }
コード例 #4
0
        /// <summary>
        /// Handles the Click event of the cmdUpdate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
        protected void cmdUpdate_Click(System.Object sender, System.EventArgs e)
        {
            try
            {
                // We do not allow for script or markup in the question
                PortalSecurity objSecurity = new PortalSecurity();
                string         question    = objSecurity.InputFilter(txtQuestionField.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
                string         answer      = objSecurity.InputFilter(teAnswerField.Text, PortalSecurity.FilterFlag.NoScripting);

                FAQsController faqsController = new FAQsController();
                FAQsInfo       faq;

                int?newCatID = null;
                if (drpCategory.SelectedValue != "-1")
                {
                    newCatID = int.Parse(drpCategory.SelectedValue);
                }

                // Do we add of update? The Id will tell us
                if (FaqId != -1)
                {
                    faq              = faqsController.GetFAQ(FaqId);
                    faq.CategoryId   = newCatID;
                    faq.FaqHide      = chkFaqHide.Checked;
                    faq.PublishDate  = datepickerPublishDate.SelectedDate;
                    faq.ExpireDate   = datepickerExpireDate.SelectedDate;
                    faq.Question     = question;
                    faq.Answer       = answer;
                    faq.DateModified = DateTime.Now;
                    faqsController.UpdateFAQ(faq);
                }
                else
                {
                    faq = new FAQsInfo
                    {
                        ItemID        = FaqId,
                        CategoryId    = newCatID,
                        FaqHide       = chkFaqHide.Checked,
                        PublishDate   = datepickerPublishDate.SelectedDate,
                        ExpireDate    = datepickerExpireDate.SelectedDate,
                        Question      = question,
                        Answer        = answer,
                        CreatedByUser = UserId.ToString(),
                        ViewCount     = 0,
                        DateModified  = DateTime.Now,
                        ModuleID      = ModuleId,
                        CreatedDate   = DateTime.Now
                    };
                    faqsController.AddFAQ(faq);
                }
                Response.Redirect(Globals.NavigateURL(), true);
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
コード例 #5
0
 /// <summary>
 /// Handles the Click event of the cmdDelete control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
 protected void cmdDelete_Click(System.Object sender, System.EventArgs e)
 {
     try
     {
         FAQsController FAQsController = new FAQsController();
         FAQsController.DeleteFAQ(FaqId);
         Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
     }
     catch (Exception exc) //Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
コード例 #6
0
        private void EditCategory(int faqCategoryId)
        {
            FAQsController faqsController = new FAQsController();

            panelAddEdit.Visible = true;
            PopulateCategoriesDropDown(faqCategoryId);
            CategoryInfo categoryItem     = faqsController.GetCategory(faqCategoryId);
            int?         parentCategoryId = categoryItem.FaqCategoryParentId;

            drpParentCategory.SelectedValue = (parentCategoryId == null ? "-1" : parentCategoryId.ToString());
            txtCategoryName.Text            = categoryItem.FaqCategoryName;
            txtCategoryDescription.Text     = categoryItem.FaqCategoryDescription;
        }
コード例 #7
0
        protected void treeCategories_HandleDrop(object sender, RadTreeNodeDragDropEventArgs e)
        {
            FAQsController          FAQsController = new FAQsController();
            RadTreeNode             sourceNode     = e.SourceDragNode;
            RadTreeNode             destNode       = e.DestDragNode;
            RadTreeViewDropPosition dropPosition   = e.DropPosition;

            if (destNode == null || sourceNode == destNode || sourceNode.IsAncestorOf(destNode))
            {
                return;
            }

            int          sourceFaqCategoryId = Convert.ToInt32(sourceNode.Value);
            CategoryInfo sourceCategory      = FAQsController.GetCategory(sourceFaqCategoryId);

            int          destFaqCategoryId = Convert.ToInt32(destNode.Value);
            CategoryInfo destCategory      = FAQsController.GetCategory(destFaqCategoryId);

            switch (dropPosition)
            {
            case RadTreeViewDropPosition.Over:                     // child
                // Change Treeview
                sourceNode.Owner.Nodes.Remove(sourceNode);
                destNode.Nodes.Add(sourceNode);

                // Change the ParentId of Source in database
                sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryId;
                sourceCategory.ViewOrder           = 999;
                FAQsController.UpdateCategory(sourceCategory);
                break;

            case RadTreeViewDropPosition.Above:                     // sibling - above
                sourceNode.Owner.Nodes.Remove(sourceNode);
                destNode.InsertBefore(sourceNode);
                sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryParentId;
                sourceCategory.ViewOrder           = destCategory.ViewOrder - 1;
                FAQsController.UpdateCategory(sourceCategory);

                break;

            case RadTreeViewDropPosition.Below:                     // sibling - below
                sourceNode.Owner.Nodes.Remove(sourceNode);
                destNode.InsertAfter(sourceNode);
                sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryParentId;
                sourceCategory.ViewOrder           = destCategory.ViewOrder + 1;
                FAQsController.UpdateCategory(sourceCategory);
                break;
            }
            FAQsController.ReorderCategory(sourceCategory.FaqCategoryParentId, ModuleId);
            panelAddEdit.Visible = false;
        }
コード例 #8
0
        /// <summary>
        /// Populates the (Parent-)categories drop down.
        /// </summary>
        private void PopulateCategoriesDropDown(int faqCategoryId)
        {
            drpParentCategory.Items.Clear();
            drpParentCategory.Items.Add(new ListItem(Localization.GetString("SelectParentCategory.Text", this.LocalResourceFile), "-1"));
            FAQsController FAQsController = new FAQsController();

            foreach (CategoryInfo category in FAQsController.ListCategoriesHierarchical(ModuleId, false))
            {
                if (faqCategoryId != category.FaqCategoryId)
                {
                    drpParentCategory.Items.Add(new ListItem(new string('.', category.Level * 3) + category.FaqCategoryName, category.FaqCategoryId.ToString()));
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
        protected void Page_Load(System.Object sender, System.EventArgs e)
        {
            if (Page.IsPostBack == false)
            {
                cmdDelete.Attributes.Add("onClick", "javascript:return confirm(\'" + Localization.GetString("DeleteItem") + "\');");

                FAQsController FAQsController = new FAQsController();

                PopulateCategoriesDropDown();

                if (!Null.IsNull(FaqId))
                {
                    FAQsInfo FaqItem = FAQsController.GetFAQ(FaqId);

                    if (FaqItem != null)
                    {
                        if (FaqItem.CategoryId != null)
                        {
                            drpCategory.SelectedValue = FaqItem.CategoryId.ToString();
                        }

                        chkFaqHide.Checked = FaqItem.FaqHide;
                        datepickerPublishDate.SelectedDate = FaqItem.PublishDate;
                        datepickerExpireDate.SelectedDate  = FaqItem.ExpireDate;
                        teAnswerField.Text    = FaqItem.Answer;
                        txtQuestionField.Text = FaqItem.Question;
                        UserInfo user = UserController.GetUserById(PortalId, Convert.ToInt32(FaqItem.CreatedByUser));
                        ctlAudit.CreatedByUser = (user != null ? user.DisplayName : "");
                        if (FaqItem.DateModified == Null.NullDate)
                        {
                            ctlAudit.CreatedDate = FaqItem.CreatedDate.ToString();
                        }
                        else
                        {
                            ctlAudit.CreatedDate = FaqItem.DateModified.ToString();
                        }
                    }
                    else
                    {
                        Response.Redirect(Globals.NavigateURL(), true);
                    }
                }
                else
                {
                    cmdDelete.Visible = false;
                    ctlAudit.Visible  = false;
                }
            }
        }
コード例 #10
0
        private void BindData()
        {
            FAQsController             FAQsController = new FAQsController();
            IEnumerable <CategoryInfo> cats           = FAQsController.ListCategoriesHierarchical(ModuleId, false);

            treeCategories.Nodes.Clear();
            treeCategories.DataTextField     = "FaqCategoryName";
            treeCategories.DataFieldID       = "FaqCategoryId";
            treeCategories.DataFieldParentID = "FaqCategoryParentId";
            treeCategories.DataSource        = cats;
            treeCategories.DataBind();
            if (!IsPostBack && treeCategories.Nodes.Count > 0)
            {
                treeCategories.Nodes[0].Selected = true;
            }
        }
コード例 #11
0
ファイル: FAQsInfo.cs プロジェクト: EPTamminga/DNNFaq
        public string GetProperty(string strPropertyName, string strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
        {
            PropertyNotFound = false;
            FAQsController faqController;

            switch (strPropertyName.ToLower())
            {
            case "question":
                return(PropertyAccess.FormatString(Question, strFormat));

            case "answer":
                return(PropertyAccess.FormatString(Answer, strFormat));

            case "user":
                UserInfo user = UserController.GetUserById(PortalSettings.Current.PortalId, Convert.ToInt32(CreatedByUser));
                return(PropertyAccess.FormatString(user.DisplayName, strFormat));

            case "viewcount":
                return(ViewCount.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider));

            case "vieworder":
                return(ViewOrder.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider));

            case "categoryname":
                faqController = new FAQsController();
                return(PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryName, strFormat));

            case "categorydesc":
                faqController = new FAQsController();
                return(PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryDescription, strFormat));

            case "datecreated":
                return(CreatedDate.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider));

            case "datemodified":
                return(DateModified.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider));

            case "index":
                return(Index.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider));

            default:
                PropertyNotFound = true;
                return(String.Empty);
            }
        }
コード例 #12
0
        /// <summary>
        /// Handles the Click event of the cmdDelete control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
        protected void cmdDelete_Click(Object sender, EventArgs e)
        {
            FAQsController faqsController = new FAQsController();

            try
            {
                RadTreeNode node = treeCategories.SelectedNode;
                if (node != null)
                {
                    int faqCategoryId = Convert.ToInt32(node.Value);
                    faqsController.DeleteCategory(faqCategoryId);
                }
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception exc)             //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
コード例 #13
0
        /// <summary>
        /// Handles the Click event of the cmdUpdate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
        protected void cmdUpdate_Click(Object sender, EventArgs e)
        {
            FAQsController faqsController = new FAQsController();
            CategoryInfo   categoryItem   = new CategoryInfo();
            PortalSecurity objSecurity    = new PortalSecurity();

            int parentCategoryId = Convert.ToInt32(drpParentCategory.SelectedValue);

            if (parentCategoryId < 0)
            {
                parentCategoryId = 0;
            }

            // We do not allow for script or markup
            categoryItem.FaqCategoryParentId    = parentCategoryId;
            categoryItem.FaqCategoryName        = objSecurity.InputFilter(txtCategoryName.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting);
            categoryItem.FaqCategoryDescription = objSecurity.InputFilter(txtCategoryDescription.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
            categoryItem.ModuleId = ModuleId;

            try
            {
                RadTreeNode node = treeCategories.SelectedNode;
                if (node != null)
                {
                    categoryItem.FaqCategoryId = Convert.ToInt32(node.Value);
                    CategoryInfo originalCategoryItem = faqsController.GetCategory(categoryItem.FaqCategoryId);
                    categoryItem.ViewOrder = originalCategoryItem.ViewOrder;
                    faqsController.UpdateCategory(categoryItem);
                }
                else
                {
                    categoryItem.ViewOrder = 999;
                    faqsController.AddCategory(categoryItem);
                }
                faqsController.ReorderCategory(categoryItem.FaqCategoryParentId, ModuleId);
                Response.Redirect(Request.RawUrl);
            }
            catch (Exception exc)             //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }
        }
コード例 #14
0
        /// <summary>
        /// Raises the client API callback event.
        /// </summary>
        /// <param name="eventArgument">The event argument.</param>
        /// <returns></returns>
        public string RaiseClientAPICallbackEvent(string eventArgument)
        {
            try
            {
                int            FaqId   = int.Parse(eventArgument);
                FAQsController objFAQs = new FAQsController();

                IncrementViewCount(FaqId);

                FAQsInfo FaqItem = objFAQs.GetFAQ(FaqId);

                return(HtmlDecode(objFAQs.ProcessTokens(FaqItem, this.AnswerTemplate)));
            }
            catch (Exception exc)
            {
                DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
            }

            return("");
        }
コード例 #15
0
ファイル: FAQsInfo.cs プロジェクト: JosvanLeeuwen/DNN.Faq
		public string GetProperty(string strPropertyName, string strFormat, CultureInfo formatProvider, UserInfo AccessingUser, Scope AccessLevel, ref bool PropertyNotFound)
		{

			PropertyNotFound = false;
		    FAQsController faqController;
			switch (strPropertyName.ToLower())
			{
				case "question":
					return PropertyAccess.FormatString(Question, strFormat);
				case "answer":
					return PropertyAccess.FormatString(Answer, strFormat);
				case "user":
			        UserInfo user = UserController.GetUserById(PortalSettings.Current.PortalId, Convert.ToInt32(CreatedByUser));
					return PropertyAccess.FormatString(user.DisplayName, strFormat);
				case "viewcount":
					return ViewCount.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider);
				case "vieworder":
					return ViewOrder.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider);
				case "categoryname":
                    faqController = new FAQsController();
                    return PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryName, strFormat);
				case "categorydesc":
                    faqController = new FAQsController();
                    return PropertyAccess.FormatString(faqController.GetCategory(CategoryId).FaqCategoryDescription, strFormat);
				case "datecreated":
					return CreatedDate.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider);
				case "datemodified":
					return DateModified.ToString(String.IsNullOrEmpty(strFormat) ? "d" : strFormat, formatProvider);
				case "index":
					return Index.ToString(String.IsNullOrEmpty(strFormat) ? "g" : strFormat, formatProvider);
				default:
					PropertyNotFound = true;
					return String.Empty;
			}
		}
コード例 #16
0
        /// <summary>
        /// Binds the categories.
        /// </summary>
        private void BindCategories()
        {
            //Show the categories ?
            if (ShowCategories)
            {
                // Do we have unassigned categories ?
                bool noCat = false;
                foreach (FAQsInfo faq in FaqData)
                {
                    if (faq.CategoryId == null)
                    {
                        noCat = true;
                        break;
                    }
                }
                pnlShowCategories.Visible = true;

                //Build the Catagories List.
                FAQsController FAQsController = new FAQsController();
                ArrayList      categories     = new ArrayList();

                //Empty Category
                CategoryInfo emptyCategory = new CategoryInfo();
                emptyCategory.FaqCategoryId   = -1;
                emptyCategory.FaqCategoryName = Localization.GetString("EmptyCategory", LocalResourceFile);
                emptyCategory.ModuleId        = ModuleId;
                emptyCategory.Level           = 0;
                emptyCategory.ViewOrder       = 998;

                //All Categories
                CategoryInfo allCategories = new CategoryInfo();
                allCategories.FaqCategoryId   = -2;
                allCategories.FaqCategoryName = Localization.GetString("AllCategory", LocalResourceFile);
                allCategories.ModuleId        = ModuleId;
                allCategories.Level           = 0;
                allCategories.ViewOrder       = 999;

                IEnumerable <CategoryInfo> cats = FAQsController.ListCategoriesHierarchical(ModuleId, !ShowEmptyCategories);

                switch (ShowCategoryType)
                {
                case 0:
                    if (noCat)
                    {
                        categories.Add(emptyCategory);
                    }
                    foreach (CategoryInfo cat in cats)
                    {
                        categories.Add(cat);
                    }
                    listCategories.DataSource = categories;
                    listCategories.DataBind();
                    mvShowCategoryType.SetActiveView(vShowCategoryTypeList);
                    pnlShowCategoryTypeDropdown.Visible = false;
                    break;

                case 1:
                    categories.Add(allCategories);
                    if (noCat)
                    {
                        categories.Add(emptyCategory);
                    }
                    foreach (CategoryInfo cat in cats)
                    {
                        categories.Add(cat);
                    }
                    // treeCategories fails with int? FaqCategoryParentId
                    // define a temp class that has no nullables
                    // set null ints to Null.NullInt
                    ArrayList lst = new ArrayList();
                    foreach (CategoryInfo cat in categories)
                    {
                        lst.Add(cat.ToTreeNode());
                    }
                    treeCategories.DataTextField     = "FaqCategoryName";
                    treeCategories.DataFieldID       = "FaqCategoryId";
                    treeCategories.DataFieldParentID = "FaqCategoryParentId";
                    treeCategories.DataSource        = lst;
                    treeCategories.DataBind();
                    if (!IsPostBack)
                    {
                        treeCategories.Nodes[0].Selected = true;
                    }
                    mvShowCategoryType.SetActiveView(vShowCategoryTypeTree);
                    pnlShowCategoryTypeDropdown.Visible = false;
                    break;

                case 2:
                    categories.Add(allCategories);
                    if (noCat)
                    {
                        categories.Add(emptyCategory);
                    }
                    foreach (CategoryInfo cat in cats)
                    {
                        categories.Add(cat);
                    }
                    foreach (CategoryInfo cat in categories)
                    {
                        drpCategories.Items.Add(new ListItem(new string('.', cat.Level * 3) + cat.FaqCategoryName, cat.FaqCategoryId.ToString()));
                    }
                    if (!IsPostBack)
                    {
                        drpCategories.SelectedIndex = 0;
                    }
                    pnlShowCategoryTypeDropdown.Visible = true;
                    pnlShowCategories.Visible           = false;
                    pnlSortbox.Style.Add("float", "right");
                    pnlSortbox.Style.Add("text-align", "right");
                    break;
                }
            }
            else
            {
                pnlShowCategories.Visible = false;
            }
        }
コード例 #17
0
        /// <summary>
        /// Determines if the element matches the filter input.
        /// </summary>
        private bool MatchElement(FAQsInfo fData)
        {
            bool match       = false;
            bool noneChecked = true;

            FAQsController             faqsController = new FAQsController();
            IEnumerable <CategoryInfo> cats           = faqsController.ListCategories(ModuleId, true);
            string categoryName;

            switch (ShowCategoryType)
            {
            case 0:
                //Filter on the checked items
                foreach (RadListBoxItem item in listCategories.Items)
                {
                    //Get the checkbox in the Control
                    CheckBox chkCategory = (CheckBox)(item.FindControl("chkCategory"));

                    //If checked the faq module is being filtered on one or more category's
                    if (chkCategory.Checked)
                    {
                        //Set Checked Flag
                        noneChecked = false;

                        //Get the filtered category
                        string checkedCategoryName = chkCategory.Text;

                        //Get the elements that match the catagory
                        var matchedCat = (from c in cats where c.FaqCategoryId == fData.CategoryId select c).SingleOrDefault();
                        categoryName = (matchedCat != null ? matchedCat.FaqCategoryName : "");

                        if ((categoryName == checkedCategoryName) ||
                            (fData.CategoryId == null && checkedCategoryName == Localization.GetString("EmptyCategory", LocalResourceFile)))
                        {
                            match = true;
                            break;
                        }
                    }
                }
                break;

            case 1:
                if (treeCategories.SelectedNode != null)
                {
                    noneChecked = (treeCategories.SelectedNode.Text == Localization.GetString("AllCategory", LocalResourceFile));
                    var matchedCat = (from c in cats where c.FaqCategoryId == fData.CategoryId select c).SingleOrDefault();
                    categoryName = (matchedCat != null ? matchedCat.FaqCategoryName : "");
                    if (treeCategories.SelectedNode.Text == categoryName ||
                        (fData.CategoryId == null && treeCategories.SelectedNode.Text == Localization.GetString("EmptyCategory", LocalResourceFile)))
                    {
                        match = true;
                        break;
                    }
                }
                break;

            case 2:
                if (drpCategories.SelectedValue != null)
                {
                    string selectedCat = drpCategories.SelectedItem.Text;

                    // strip out possible level points
                    while (selectedCat.StartsWith("."))
                    {
                        selectedCat = selectedCat.Substring(1);
                    }
                    noneChecked = (selectedCat == Localization.GetString("AllCategory", LocalResourceFile));
                    var matchedCat = (from c in cats where c.FaqCategoryId == fData.CategoryId select c).SingleOrDefault();
                    categoryName = (matchedCat != null ? matchedCat.FaqCategoryName : "");
                    if (selectedCat == categoryName ||
                        (fData.CategoryId == null && selectedCat == Localization.GetString("EmptyCategory", LocalResourceFile)))
                    {
                        match = true;
                        break;
                    }
                }
                break;
            }

            if (noneChecked)
            {
                return(true);
            }

            return(match);
        }
コード例 #18
0
		/// <summary>
		/// Handles the Click event of the cmdUpdate control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
		protected void cmdUpdate_Click(Object sender, EventArgs e)
		{

			FAQsController faqsController = new FAQsController();
			CategoryInfo categoryItem = new CategoryInfo();
			PortalSecurity objSecurity = new PortalSecurity();

			int parentCategoryId = Convert.ToInt32(drpParentCategory.SelectedValue);
			if (parentCategoryId < 0) 
				parentCategoryId = 0;

			// We do not allow for script or markup
			categoryItem.FaqCategoryParentId = parentCategoryId;
			categoryItem.FaqCategoryName = objSecurity.InputFilter(txtCategoryName.Text, PortalSecurity.FilterFlag.NoMarkup | PortalSecurity.FilterFlag.NoScripting);
			categoryItem.FaqCategoryDescription = objSecurity.InputFilter(txtCategoryDescription.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
			categoryItem.ModuleId = ModuleId;

			try
			{
				RadTreeNode node = treeCategories.SelectedNode;
				if (node != null)
				{
					categoryItem.FaqCategoryId = Convert.ToInt32(node.Value);
					CategoryInfo originalCategoryItem = faqsController.GetCategory(categoryItem.FaqCategoryId);
					categoryItem.ViewOrder = originalCategoryItem.ViewOrder;
					faqsController.UpdateCategory(categoryItem);
				}
				else
				{
					categoryItem.ViewOrder = 999;
					faqsController.AddCategory(categoryItem);
				}
				faqsController.ReorderCategory(categoryItem.FaqCategoryParentId, ModuleId);
				Response.Redirect(Request.RawUrl);
			}
			catch (Exception exc) //Module failed to load
			{
				Exceptions.ProcessModuleLoadException(this, exc);
			}
		}
コード例 #19
0
		/// <summary>
		/// Populates the (Parent-)categories drop down.
		/// </summary>
		private void PopulateCategoriesDropDown(int faqCategoryId)
		{
			drpParentCategory.Items.Clear();
			drpParentCategory.Items.Add(new ListItem(Localization.GetString("SelectParentCategory.Text",this.LocalResourceFile), "-1"));
			FAQsController FAQsController = new FAQsController();
			foreach (CategoryInfo category in FAQsController.ListCategoriesHierarchical(ModuleId, false))
			{
				if (faqCategoryId != category.FaqCategoryId)
					drpParentCategory.Items.Add(new ListItem(new string('.',category.Level*3) + category.FaqCategoryName, category.FaqCategoryId.ToString()));
			}
		}
コード例 #20
0
		private void EditCategory(int faqCategoryId)
		{
			FAQsController faqsController = new FAQsController();
			panelAddEdit.Visible = true;
			PopulateCategoriesDropDown(faqCategoryId);
			CategoryInfo categoryItem = faqsController.GetCategory(faqCategoryId);
			int? parentCategoryId = categoryItem.FaqCategoryParentId;
			drpParentCategory.SelectedValue = (parentCategoryId == null ? "-1" : parentCategoryId.ToString());
			txtCategoryName.Text = categoryItem.FaqCategoryName;
			txtCategoryDescription.Text = categoryItem.FaqCategoryDescription;
		}
コード例 #21
0
		/// <summary>
		/// Handles the Click event of the cmdDelete control.
		/// </summary>
		/// <param name="sender">The source of the event.</param>
		/// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
		protected void cmdDelete_Click(Object sender, EventArgs e)
		{
			FAQsController faqsController = new FAQsController();
			try
			{
				RadTreeNode node = treeCategories.SelectedNode;
				if (node != null)
				{
					int faqCategoryId = Convert.ToInt32(node.Value);
					faqsController.DeleteCategory(faqCategoryId);
				}
				Response.Redirect(Request.RawUrl);
			}
			catch (Exception exc) //Module failed to load
			{
				Exceptions.ProcessModuleLoadException(this, exc);
			}
		}
コード例 #22
0
		protected void treeCategories_HandleDrop(object sender, RadTreeNodeDragDropEventArgs e)
		{
			FAQsController FAQsController = new FAQsController();
			RadTreeNode sourceNode = e.SourceDragNode;
			RadTreeNode destNode = e.DestDragNode;
			RadTreeViewDropPosition dropPosition = e.DropPosition;

			if (destNode == null || sourceNode == destNode || sourceNode.IsAncestorOf(destNode))
				return;
			
			int sourceFaqCategoryId = Convert.ToInt32(sourceNode.Value);
			CategoryInfo sourceCategory = FAQsController.GetCategory(sourceFaqCategoryId);

			int destFaqCategoryId = Convert.ToInt32(destNode.Value);
			CategoryInfo destCategory = FAQsController.GetCategory(destFaqCategoryId);

			switch (dropPosition)
			{
				case RadTreeViewDropPosition.Over: // child
					// Change Treeview
					sourceNode.Owner.Nodes.Remove(sourceNode);
					destNode.Nodes.Add(sourceNode);
						
					// Change the ParentId of Source in database
					sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryId;
					sourceCategory.ViewOrder = 999;
					FAQsController.UpdateCategory(sourceCategory);
					break;
				
				case RadTreeViewDropPosition.Above: // sibling - above
					sourceNode.Owner.Nodes.Remove(sourceNode);
					destNode.InsertBefore(sourceNode);
					sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryParentId;
					sourceCategory.ViewOrder = destCategory.ViewOrder - 1;
					FAQsController.UpdateCategory(sourceCategory);
					
					break;
				
				case RadTreeViewDropPosition.Below: // sibling - below
					sourceNode.Owner.Nodes.Remove(sourceNode);
					destNode.InsertAfter(sourceNode);
					sourceCategory.FaqCategoryParentId = destCategory.FaqCategoryParentId;
					sourceCategory.ViewOrder = destCategory.ViewOrder + 1;
					FAQsController.UpdateCategory(sourceCategory);
					break;
			}
			FAQsController.ReorderCategory(sourceCategory.FaqCategoryParentId, ModuleId);
			panelAddEdit.Visible = false;
		}
コード例 #23
0
ファイル: FAQs.ascx.cs プロジェクト: JosvanLeeuwen/DNN.Faq
		/// <summary>
		/// Raises the client API callback event.
		/// </summary>
		/// <param name="eventArgument">The event argument.</param>
		/// <returns></returns>
		public string RaiseClientAPICallbackEvent(string eventArgument)
		{
			
			try
			{
				int FaqId = int.Parse(eventArgument);
				FAQsController objFAQs = new FAQsController();
				
				IncrementViewCount(FaqId);
				
				FAQsInfo FaqItem = objFAQs.GetFAQ(FaqId);
				
				return HtmlDecode(objFAQs.ProcessTokens(FaqItem, this.AnswerTemplate));
				
			}
			catch (Exception exc)
			{
				DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
			}
			
			return "";
			
		}
コード例 #24
0
ファイル: FAQs.ascx.cs プロジェクト: JosvanLeeuwen/DNN.Faq
		/// <summary>
		/// Handles the Select event of the lstFAQs control.
		/// </summary>
		/// <param name="source">The source of the event.</param>
		/// <param name="e">The <see cref="System.Web.UI.WebControls.DataListCommandEventArgs" /> instance containing the event data.</param>
		protected void lstFAQs_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
		{
			FAQsController controller = new FAQsController();
			int itemId = System.Convert.ToInt32(e.CommandArgument);
			int index = e.Item.ItemIndex;
			int itemCount = FaqData.Count;

			switch (e.CommandName.ToLower())
			{
				case "select":
					if (!SupportsClientAPI)
					{
						try
						{
							Label lblAnswer = (Label) (lstFAQs.Items[index].FindControl("A2"));
							FAQsInfo FaqItem = controller.GetFAQ(itemId);

							if (lblAnswer.Text == "")
							{
								IncrementViewCount(FaqItem.ItemID);
								lblAnswer.Text = HtmlDecode(controller.ProcessTokens(FaqItem, this.AnswerTemplate));
							}
							else
							{
								lblAnswer.Text = "";
							}

						}
						catch (Exception exc) //Module failed to load
						{
							DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
						}
					}
					break;
				case "up":
					if (index == 0)
						controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[itemCount-1]).ItemID, ModuleId);
					else
						controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[index - 1]).ItemID, ModuleId);
					FaqData = null;
					BindData();
					break;
				case "down":
					if (index == itemCount -1)
						controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[0]).ItemID, ModuleId);
					else
						controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[index + 1]).ItemID, ModuleId);
					//Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
					FaqData = null;
					BindData();
					break;
			}
		}
コード例 #25
0
ファイル: FAQs.ascx.cs プロジェクト: JosvanLeeuwen/DNN.Faq
		/// <summary>
		/// Increments the view count.
		/// </summary>
		/// <param name="FaqId">The FAQ id.</param>
		private void IncrementViewCount(int FaqId)
		{
			FAQsController objFAQs = new FAQsController();
			objFAQs.IncrementViewCount(FaqId);
			
		}
コード例 #26
0
        /// <summary>
        /// Handles the Click event of the cmdUpdate control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
        protected void cmdUpdate_Click(System.Object sender, System.EventArgs e)
        {

            try
            {
                   // We do not allow for script or markup in the question
                PortalSecurity objSecurity = new PortalSecurity();
                string question = objSecurity.InputFilter(txtQuestionField.Text, PortalSecurity.FilterFlag.NoScripting | PortalSecurity.FilterFlag.NoMarkup);
                string answer = objSecurity.InputFilter(teAnswerField.Text, PortalSecurity.FilterFlag.NoScripting);

                FAQsController faqsController = new FAQsController();
                FAQsInfo faq;

                int? newCatID = null;
                if (drpCategory.SelectedValue != "-1")
                    newCatID = int.Parse(drpCategory.SelectedValue);

                 // Do we add of update? The Id will tell us
                if (FaqId != -1)
                {
                    faq = faqsController.GetFAQ(FaqId);
                    faq.CategoryId = newCatID;
                    faq.FaqHide = chkFaqHide.Checked;
                    faq.PublishDate = datepickerPublishDate.SelectedDate;
                    faq.ExpireDate = datepickerExpireDate.SelectedDate;
                    faq.Question = question;
                    faq.Answer = answer;
                    faq.DateModified = DateTime.Now;
                    faqsController.UpdateFAQ(faq);
                }
                else
                {
                    faq = new FAQsInfo
                              {
                                  ItemID = FaqId,
                                  CategoryId = newCatID,
                                  FaqHide = chkFaqHide.Checked,
                                  PublishDate = datepickerPublishDate.SelectedDate,
                                  ExpireDate = datepickerExpireDate.SelectedDate,
                                  Question = question,
                                  Answer = answer,
                                  CreatedByUser = UserId.ToString(),
                                  ViewCount = 0,
                                  DateModified = DateTime.Now,
                                  ModuleID = ModuleId,
                                  CreatedDate = DateTime.Now
                              };
                    faqsController.AddFAQ(faq);
                }
                Response.Redirect(Globals.NavigateURL(), true);
            }
            catch (Exception exc) //Module failed to load
            {
                Exceptions.ProcessModuleLoadException(this, exc);
            }

        }
コード例 #27
0
        /// <summary>
        /// Increments the view count.
        /// </summary>
        /// <param name="FaqId">The FAQ id.</param>
        private void IncrementViewCount(int FaqId)
        {
            FAQsController objFAQs = new FAQsController();

            objFAQs.IncrementViewCount(FaqId);
        }
コード例 #28
0
 /// <summary>
 /// Handles the Click event of the cmdDelete control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
 protected void cmdDelete_Click(System.Object sender, System.EventArgs e)
 {
     try
     {
         FAQsController FAQsController = new FAQsController();
         FAQsController.DeleteFAQ(FaqId);
         Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
     }
     catch (Exception exc) //Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }
コード例 #29
0
		private void BindData()
		{
			FAQsController FAQsController = new FAQsController();
            IEnumerable<CategoryInfo> cats = FAQsController.ListCategoriesHierarchical(ModuleId, false);

            treeCategories.Nodes.Clear();
			treeCategories.DataTextField = "FaqCategoryName";
			treeCategories.DataFieldID = "FaqCategoryId";
			treeCategories.DataFieldParentID = "FaqCategoryParentId";
			treeCategories.DataSource = cats;
			treeCategories.DataBind();
			if (!IsPostBack && treeCategories.Nodes.Count > 0)
				treeCategories.Nodes[0].Selected = true;
		}
コード例 #30
0
ファイル: FAQs.ascx.cs プロジェクト: JosvanLeeuwen/DNN.Faq
		/// <summary>
		/// Binds the categories.
		/// </summary>
		private void BindCategories()
		{
			//Show the categories ?
			if (ShowCategories)
			{
				// Do we have unassigned categories ?
				bool noCat = false;
				foreach (FAQsInfo faq in FaqData)
				{
					if (faq.CategoryId == null)
					{
						noCat = true;
						break;
					}
				}
				pnlShowCategories.Visible = true;

				//Build the Catagories List.
				FAQsController FAQsController = new FAQsController();
				ArrayList categories = new ArrayList();

				//Empty Category
				CategoryInfo emptyCategory = new CategoryInfo();
				emptyCategory.FaqCategoryId = -1;
				emptyCategory.FaqCategoryName = Localization.GetString("EmptyCategory", LocalResourceFile);

				//All Categories
				CategoryInfo allCategories = new CategoryInfo();
				allCategories.FaqCategoryId = -2;
				allCategories.FaqCategoryName = Localization.GetString("AllCategory", LocalResourceFile);

			    IEnumerable<CategoryInfo> cats = FAQsController.ListCategoriesHierarchical(ModuleId, !ShowEmptyCategories);

				switch (ShowCategoryType)
				{
					case 0:
						if (noCat)
							categories.Add(emptyCategory);
				        foreach (CategoryInfo cat in cats)
				        {
				            categories.Add(cat);
				        }
						listCategories.DataSource = categories;
						listCategories.DataBind();
						mvShowCategoryType.SetActiveView(vShowCategoryTypeList);
						pnlShowCategoryTypeDropdown.Visible = false;
						break;

					case 1:
						categories.Add(allCategories);
						if (noCat)
							categories.Add(emptyCategory);
                        foreach (CategoryInfo cat in cats)
                        {
                            categories.Add(cat);
                        }
						List<CategoryInfo> lst = new List<CategoryInfo>();
						foreach (CategoryInfo cat in categories)
						{
							lst.Add(cat);
						}
						treeCategories.DataTextField = "FaqCategoryName";
						treeCategories.DataFieldID = "FaqCategoryId";
						treeCategories.DataFieldParentID = "FaqCategoryParentId";
						treeCategories.DataSource = lst;
						treeCategories.DataBind();
						if (!IsPostBack)
							treeCategories.Nodes[0].Selected = true;
						mvShowCategoryType.SetActiveView(vShowCategoryTypeTree);
						pnlShowCategoryTypeDropdown.Visible = false;
						break;
					case 2:
						categories.Add(allCategories);
						if (noCat)
							categories.Add(emptyCategory);
                        foreach (CategoryInfo cat in cats)
                        {
                            categories.Add(cat);
                        }
						foreach (CategoryInfo cat in categories)
						{
							drpCategories.Items.Add(new ListItem(new string('.',cat.Level * 3) + cat.FaqCategoryName,cat.FaqCategoryId.ToString()));
						}
						if (!IsPostBack)
							drpCategories.SelectedIndex = 0;
						pnlShowCategoryTypeDropdown.Visible = true;
						pnlShowCategories.Visible = false;
						pnlSortbox.Style.Add("float", "right");
						pnlSortbox.Style.Add("text-align", "right");
						break;
				}
			}
			else
			{
				pnlShowCategories.Visible = false;
			}
		}
コード例 #31
0
        /// <summary>
        /// Handles the Select event of the lstFAQs control.
        /// </summary>
        /// <param name="source">The source of the event.</param>
        /// <param name="e">The <see cref="System.Web.UI.WebControls.DataListCommandEventArgs" /> instance containing the event data.</param>
        protected void lstFAQs_ItemCommand(object source, System.Web.UI.WebControls.DataListCommandEventArgs e)
        {
            FAQsController controller = new FAQsController();
            int            itemId     = System.Convert.ToInt32(e.CommandArgument);
            int            index      = e.Item.ItemIndex;
            int            itemCount  = FaqData.Count;

            switch (e.CommandName.ToLower())
            {
            case "select":
                if (!SupportsClientAPI)
                {
                    try
                    {
                        Label    lblAnswer = (Label)(lstFAQs.Items[index].FindControl("A2"));
                        FAQsInfo FaqItem   = controller.GetFAQ(itemId);

                        if (lblAnswer.Text == "")
                        {
                            IncrementViewCount(FaqItem.ItemID);
                            lblAnswer.Text = HtmlDecode(controller.ProcessTokens(FaqItem, this.AnswerTemplate));
                        }
                        else
                        {
                            lblAnswer.Text = "";
                        }
                    }
                    catch (Exception exc)     //Module failed to load
                    {
                        DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException(this, exc);
                    }
                }
                break;

            case "up":
                if (index == 0)
                {
                    controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[itemCount - 1]).ItemID, ModuleId);
                }
                else
                {
                    controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[index - 1]).ItemID, ModuleId);
                }
                FaqData = null;
                BindData();
                break;

            case "down":
                if (index == itemCount - 1)
                {
                    controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[0]).ItemID, ModuleId);
                }
                else
                {
                    controller.ReorderFAQ(itemId, ((FAQsInfo)FaqData[index + 1]).ItemID, ModuleId);
                }
                //Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
                FaqData = null;
                BindData();
                break;
            }
        }
コード例 #32
0
ファイル: FAQs.ascx.cs プロジェクト: JosvanLeeuwen/DNN.Faq
		/// <summary>
		/// Determines if the element matches the filter input.
		/// </summary>
		private bool MatchElement(FAQsInfo fData)
		{
			
			bool match = false;
			bool noneChecked = true;

            FAQsController faqsController = new FAQsController();
		    IEnumerable<CategoryInfo> cats = faqsController.ListCategories(ModuleId, true);
		    string categoryName;

			switch (ShowCategoryType)
			{
				case 0:
					//Filter on the checked items
					foreach (RadListBoxItem item in listCategories.Items)
					{

						//Get the checkbox in the Control
						CheckBox chkCategory = (CheckBox) (item.FindControl("chkCategory"));

						//If checked the faq module is being filtered on one or more category's
						if (chkCategory.Checked)
						{

							//Set Checked Flag
							noneChecked = false;

							//Get the filtered category
							string checkedCategoryName = chkCategory.Text;

							//Get the elements that match the catagory
                            var matchedCat = (from c in cats where c.FaqCategoryId == fData.CategoryId select c).SingleOrDefault();
                            categoryName = (matchedCat != null ? matchedCat.FaqCategoryName : "");

							if ((categoryName == checkedCategoryName) ||
							    (fData.CategoryId == null && checkedCategoryName == Localization.GetString("EmptyCategory", LocalResourceFile)))
							{
								match = true;
							    break;
							}
						}
					}
					break;
				case 1:
					if (treeCategories.SelectedNode != null)
					{
						noneChecked = (treeCategories.SelectedNode.Text == Localization.GetString("AllCategory", LocalResourceFile));
                        var matchedCat = (from c in cats where c.FaqCategoryId == fData.CategoryId select c).SingleOrDefault();
					    categoryName = (matchedCat != null ? matchedCat.FaqCategoryName : "");
						if (treeCategories.SelectedNode.Text == categoryName ||
								(fData.CategoryId == null && treeCategories.SelectedNode.Text == Localization.GetString("EmptyCategory", LocalResourceFile)))
						{
							match = true;
							break;
						}
					}
					break;
				case 2:
					if (drpCategories.SelectedValue != null)
					{
						string selectedCat = drpCategories.SelectedItem.Text;
						
						// strip out possible level points
						while (selectedCat.StartsWith("."))
						{
							selectedCat = selectedCat.Substring(1);
						}
						noneChecked = (selectedCat == Localization.GetString("AllCategory", LocalResourceFile));
                        var matchedCat = (from c in cats where c.FaqCategoryId == fData.CategoryId select c).SingleOrDefault();
                        categoryName = (matchedCat != null ? matchedCat.FaqCategoryName : "");
						if (selectedCat == categoryName ||
								(fData.CategoryId == null && selectedCat == Localization.GetString("EmptyCategory", LocalResourceFile)))
						{
							match = true;
							break;
						}
					}
					break;
			}
			
			if (noneChecked)
			{
				return true;
			}
			
			return match;
			
		}
コード例 #33
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs" /> instance containing the event data.</param>
        protected void Page_Load(System.Object sender, System.EventArgs e)
        {

            if (Page.IsPostBack == false)
            {

                cmdDelete.Attributes.Add("onClick", "javascript:return confirm(\'" + Localization.GetString("DeleteItem") + "\');");

                FAQsController FAQsController = new FAQsController();

                PopulateCategoriesDropDown();

                if (!Null.IsNull(FaqId))
                {

                    FAQsInfo FaqItem = FAQsController.GetFAQ(FaqId);

                    if (FaqItem != null)
                    {

                        if (FaqItem.CategoryId != null)
                        {
                            drpCategory.SelectedValue = FaqItem.CategoryId.ToString();
                        }

                        chkFaqHide.Checked = FaqItem.FaqHide;
                        datepickerPublishDate.SelectedDate = FaqItem.PublishDate;
                        datepickerExpireDate.SelectedDate = FaqItem.ExpireDate;
                        teAnswerField.Text = FaqItem.Answer;
                        txtQuestionField.Text = FaqItem.Question;
                        UserInfo user = UserController.GetUserById(PortalId, Convert.ToInt32(FaqItem.CreatedByUser));
                        ctlAudit.CreatedByUser = (user != null ? user.DisplayName : "");
                        if (FaqItem.DateModified == Null.NullDate)
                        {
                            ctlAudit.CreatedDate = FaqItem.CreatedDate.ToString();
                        }
                        else
                        {
                            ctlAudit.CreatedDate = FaqItem.DateModified.ToString();
                        }
                    }
                    else
                    {
                        Response.Redirect(Globals.NavigateURL(), true);
                    }

                }
                else
                {
                    cmdDelete.Visible = false;
                    ctlAudit.Visible = false;
                }

            }

        }