コード例 #1
0
ファイル: edittaxonomy.ascx.cs プロジェクト: jaytem/minGit
    protected void Page_Load(object sender, System.EventArgs e)
    {
        m_refMsg = m_refApi.EkMsgRef;
        AppImgPath = m_refApi.AppImgPath;
        m_strPageAction = Request.QueryString["action"];
        object refAPI = m_refApi as object;
        Utilities.SetLanguage(m_refApi);
        TaxonomyLanguage = m_refApi.ContentLanguage;
        if (TaxonomyLanguage == -1)
        {
            TaxonomyLanguage = m_refApi.DefaultContentLanguage;
        }
        if (Request.QueryString["taxonomyid"] != null)
        {
            TaxonomyId = Convert.ToInt64(Request.QueryString["taxonomyid"]);
            hdnTaxonomyId.Value = TaxonomyId.ToString();
        }
        if (Request.QueryString["parentid"] != null)
        {
            TaxonomyParentId = Convert.ToInt64(Request.QueryString["parentid"]);
        }
        m_refContent = m_refApi.EkContentRef;
        if (Request.QueryString["reorder"] != null)
        {
            m_strReorderAction = Convert.ToString(Request.QueryString["reorder"]);
        }
        chkApplyDisplayAllLanguages.Text = m_refMsg.GetMessage("lbl apply display taxonomy languages");
        chkConfigContent.Text = chkConfigContent.ToolTip = m_refMsg.GetMessage("content text");
        chkConfigUser.Text = chkConfigUser.ToolTip = m_refMsg.GetMessage("generic user");
        chkConfigGroup.Text = chkConfigGroup.ToolTip = m_refMsg.GetMessage("lbl group");
        if (Page.IsPostBack)
        {
            if (m_strPageAction == "edit")
            {
                taxonomy_data.TaxonomyLanguage = TaxonomyLanguage;
                taxonomy_data.TaxonomyParentId = TaxonomyParentId;
                taxonomy_data.TaxonomyId = TaxonomyId;
                taxonomy_data.TaxonomyDescription = Request.Form[taxonomydescription.UniqueID];
                taxonomy_data.TaxonomyName = Request.Form[taxonomytitle.UniqueID];
                taxonomy_data.TaxonomyImage = Request.Form[taxonomy_image.UniqueID];
                taxonomy_data.CategoryUrl = Request.Form[categoryLink.UniqueID];
                if (tr_enableDisable.Visible == true)
                {
                    if (!string.IsNullOrEmpty(Request.Form[chkEnableDisable.UniqueID]))
                    {
                        taxonomy_data.Visible = true;
                    }
                    else
                    {
                        taxonomy_data.Visible = false;
                    }
                }
                else
                {
                    taxonomy_data.Visible = Convert.ToBoolean(Request.Form[visibility.UniqueID]);
                }
                if (Request.Form[inherittemplate.UniqueID] != null)
                {
                    taxonomy_data.TemplateInherited = true;
                }
                if (Request.Form[taxonomytemplate.UniqueID] != null)
                {
                    taxonomy_data.TemplateId = Convert.ToInt64(Request.Form[taxonomytemplate.UniqueID]);
                }
                else
                {
                    taxonomy_data.TemplateId = 0;
                }

                try
                {
                    m_refContent.UpdateTaxonomy(taxonomy_data);
                }
                catch (Exception ex)
                {
                    Utilities.ShowError(ex.Message);
                }
                if ((!(Request.Form[chkApplyDisplayAllLanguages.UniqueID] == null)) && (Request.Form[chkApplyDisplayAllLanguages.UniqueID].ToString().ToLower() == "on"))
                {
                    m_refContent.UpdateTaxonomyVisible(TaxonomyId, -1, taxonomy_data.Visible);
                }
                m_refContent.UpdateTaxonomySynchronization(TaxonomyId, GetCheckBoxValue(chkTaxSynch));
                //else
                //{
                //    m_refContent.UpdateTaxonomyVisible(TaxonomyId, TaxonomyLanguage, taxonomy_data.Visible);
                //}
                if (TaxonomyParentId == 0)
                {
                    string strConfig = string.Empty;
                    if (!string.IsNullOrEmpty(Request.Form[chkConfigContent.UniqueID]))
                    {
                        strConfig = "0";
                    }
                    if (!string.IsNullOrEmpty(Request.Form[chkConfigUser.UniqueID]))
                    {
                        if (string.IsNullOrEmpty(strConfig))
                        {
                            strConfig = "1";
                        }
                        else
                        {
                            strConfig = strConfig + ",1";
                        }
                    }
                    if (!string.IsNullOrEmpty(Request.Form[chkConfigGroup.UniqueID]))
                    {
                        if (string.IsNullOrEmpty(strConfig))
                        {
                            strConfig = "2";
                        }
                        else
                        {
                            strConfig = strConfig + ",2";
                        }
                    }
                    if (!(string.IsNullOrEmpty(strConfig)))
                    {
                        m_refContent.UpdateTaxonomyConfig(TaxonomyId, strConfig);
                    }
                }
                UpdateCustomProperties();

                if (Request.QueryString["iframe"] == "true")
                {
                    Response.Write("<script type=\"text/javascript\">parent.CloseChildPage();</script>");
                }
                else
                {
                    if ((Request.QueryString["backaction"] != null) && Convert.ToString(Request.QueryString["backaction"]).ToLower() == "viewtree")
                    {
                        Response.Redirect((string)("taxonomy.aspx?action=viewtree&taxonomyid=" + TaxonomyId + "&LangType=" + TaxonomyLanguage), true);
                    }
                    else
                    {
                        Response.Redirect("taxonomy.aspx?action=view&view=item&taxonomyid=" + TaxonomyId + "&rf=1", true);
                    }
                }
            }
            else
            {
                if (Request.Form[LinkOrder.UniqueID] != "")
                {
                    taxonomy_request = new TaxonomyRequest();
                    taxonomy_request.TaxonomyId = TaxonomyId;
                    taxonomy_request.TaxonomyLanguage = TaxonomyLanguage;
                    taxonomy_request.TaxonomyIdList = Request.Form[LinkOrder.UniqueID];
                    if (!string.IsNullOrEmpty(Request.Form[chkOrderAllLang.UniqueID]))
                    {
                        if (m_strReorderAction == "category")
                        {
                            m_refContent.ReOrderAllLanguageCategories(taxonomy_request);
                        }
                        else if (m_strReorderAction == "users")
                        {

                                taxonomy_request.TaxonomyItemType = EkEnumeration.TaxonomyItemType.User;
                            m_refContent.ReOrderTaxonomyItems(taxonomy_request);
                        }
                    }
                    else
                    {
                        if (m_strReorderAction == "category")
                        {
                            m_refContent.ReOrderCategories(taxonomy_request);
                        }
                        else
                        {
                            if (m_strReorderAction == "users")
                            {
                                taxonomy_request.TaxonomyItemType = EkEnumeration.TaxonomyItemType.User;
                            }
                            m_refContent.ReOrderTaxonomyItems(taxonomy_request);
                        }
                    }
                }
                if (Request.QueryString["iframe"] == "true")
                {
                    Response.Write("<script type=\"text/javascript\">parent.CloseChildPage();</script>");
                }
                else
                {
                    if(m_strReorderAction == "category")
                        Response.Redirect("taxonomy.aspx?action=view&taxonomyid=" + TaxonomyId + "&rf=1&reloadtrees=Tax", true);
                    else
                        Response.Redirect("taxonomy.aspx?action=view&taxonomyid=" + TaxonomyId + "&rf=1", true);
                }
            }
        }
        else
        {
            ltr_sitepath.Text = m_refApi.SitePath;
            taxonomy_request = new TaxonomyRequest();
            taxonomy_request.TaxonomyId = TaxonomyId;
            taxonomy_request.TaxonomyLanguage = TaxonomyLanguage;

            if (m_strPageAction == "edit")
            {
                taxonomy_data = m_refContent.ReadTaxonomy(ref taxonomy_request);

                taxonomydescription.Text = taxonomy_data.TaxonomyDescription;
                taxonomydescription.ToolTip = taxonomydescription.Text;
                taxonomytitle.Text = taxonomy_data.TaxonomyName;
                taxonomytitle.ToolTip = taxonomytitle.Text;
                taxonomy_image.Text = taxonomy_data.TaxonomyImage;
                taxonomy_image.ToolTip = taxonomy_image.Text;
                taxonomy_image_thumb.ImageUrl = taxonomy_data.TaxonomyImage;
                categoryLink.Text = taxonomy_data.CategoryUrl;
                visibility.Value = taxonomy_data.Visible.ToString();
                if (Request.QueryString["taxonomyid"] != null)
                {
                    TaxonomyId = Convert.ToInt64(Request.QueryString["taxonomyid"]);
                }

                if (TaxonomyParentId > 0)
                {
                    m_bSynchronized = m_refContent.IsSynchronizedTaxonomy(TaxonomyParentId, TaxonomyLanguage);
                    if (TaxonomyId > 0)
                        chkTaxSynch.Checked = m_refContent.IsSynchronizedTaxonomy(TaxonomyId, TaxonomyLanguage);
                }
                else if (TaxonomyId > 0)
                {
                    m_bSynchronized = m_refContent.IsSynchronizedTaxonomy(TaxonomyId, TaxonomyLanguage);
                    chkTaxSynch.Checked = m_bSynchronized;
                }
                if (taxonomy_data.Visible == true)
                {
                    chkEnableDisable.Checked = true;
                }
                else
                {
                    chkEnableDisable.Checked = false;
                }
                if (taxonomy_data.TaxonomyImage != "")
                {
                    taxonomy_image_thumb.ImageUrl = (taxonomy_data.TaxonomyImage.IndexOf("/") == 0) ? taxonomy_data.TaxonomyImage : m_refApi.SitePath + taxonomy_data.TaxonomyImage;
                }
                else
                {
                    taxonomy_image_thumb.ImageUrl = m_refApi.AppImgPath + "spacer.gif";
                }
                language_data = (new SiteAPI()).GetLanguageById(TaxonomyLanguage);
                if (taxonomy_data.TaxonomyParentId == 0)
                {
                    inherittemplate.Visible = false;
                    lblInherited.Text = "No";
                    lblInherited.ToolTip = lblInherited.Text;
                    inherittemplate.Checked = taxonomy_data.TemplateInherited;
                }
                else
                {
                    inherittemplate.Visible = true;
                    lblInherited.Text = "";
                    inherittemplate.Checked = taxonomy_data.TemplateInherited;
                    if (taxonomy_data.TemplateInherited)
                    {
                        taxonomytemplate.Enabled = false;
                    }
                }
                TemplateData[] templates = null;
                templates = m_refApi.GetAllTemplates("TemplateFileName");
                taxonomytemplate.Items.Add(new System.Web.UI.WebControls.ListItem("- " + m_refMsg.GetMessage("generic select template") + " -", "0"));
                if ((templates != null) && templates.Length > 0)
                {
                    for (int i = 0; i <= templates.Length - 1; i++)
                    {
                        taxonomytemplate.Items.Add(new System.Web.UI.WebControls.ListItem(templates[i].FileName, templates[i].Id.ToString()));
                        if (taxonomy_data.TemplateId == templates[i].Id)
                        {
                            taxonomytemplate.SelectedIndex = i + 1;
                        }
                    }
                }
                if ((language_data != null) && (m_refApi.EnableMultilingual == 1))
                {
                    lblLanguage.Text = "[" + language_data.Name + "]";
                    lblLanguage.ToolTip = lblLanguage.Text;
                }
                m_strCurrentBreadcrumb = (string)(taxonomy_data.TaxonomyPath.Remove(0, 1).Replace("\\", " > "));
                if (m_strCurrentBreadcrumb == "")
                {
                    m_strCurrentBreadcrumb = "Root";
                }
                inherittemplate.Attributes.Add("onclick", "OnInheritTemplateClicked(this)");
                if (TaxonomyParentId == 0)
                {
                    tr_config.Visible = true;
                    List<int> config_list = m_refApi.EkContentRef.GetAllConfigIdListByTaxonomy(TaxonomyId, TaxonomyLanguage);
                    for (int i = 0; i <= config_list.Count - 1; i++)
                    {
                        if (config_list[i] == 0)
                        {
                            chkConfigContent.Checked = true;
                        }
                        else if (config_list[i] == 1)
                        {
                            chkConfigUser.Checked = true;
                        }
                        else if (config_list[i] == 2)
                        {
                            chkConfigGroup.Checked = true;
                        }
                    }
                }
                else
                {
                    tr_config.Visible = false;
                }

                LoadCustomPropertyList();

            }
            else
            {
                if (m_strReorderAction == "category")
                {
                    taxonomy_request.PageSize = 99999999; // pagesize of 0 used to mean "all"
                    taxonomy_arr = m_refContent.ReadAllSubCategories(taxonomy_request);
                    if (taxonomy_arr != null)
                    {
                        TotalItems = taxonomy_arr.Length;
                    }
                    else
                    {
                        TotalItems = 0;
                    }
                    if (TotalItems > 1)
                    {
                        td_msg.Text = m_refMsg.GetMessage("generic first msg");
                        OrderList.DataSource = taxonomy_arr;
                        OrderList.DataTextField = "TaxonomyName";
                        OrderList.DataValueField = "TaxonomyId";
                        OrderList.DataBind();
                        OrderList.SelectionMode = ListSelectionMode.Multiple;
                        OrderList.CssClass = "width: 100%; border-style: none; border-color: White; font-family: Verdana;font-size: x-small;";
                        if (TotalItems > 20)
                        {
                            OrderList.Rows = 20;
                        }
                        else
                        {
                            OrderList.Rows = TotalItems;
                        }
                        OrderList.Width = 300;
                        if (TotalItems > 0)
                        {
                            loadscript.Text = "document.forms[0].taxonomy_OrderList[0].selected = true;";
                        }
                        for (int i = 0; i <= taxonomy_arr.Length - 1; i++)
                        {
                            if (LinkOrder.Value == "")
                            {
                                LinkOrder.Value = Convert.ToString(taxonomy_arr[i].TaxonomyId);
                            }
                            else
                            {
                                LinkOrder.Value = Convert.ToString(taxonomy_arr[i].TaxonomyId) + ",";
                            }
                        }
                    }
                    else
                    {
                        LoadNoItem();
                    }
                }
                else if (m_strReorderAction == "users")
                {
                    DirectoryUserRequest uReq = new DirectoryUserRequest();
                    DirectoryAdvancedUserData uDirectory = new DirectoryAdvancedUserData();
                    uReq.GetItems = true;
                    uReq.DirectoryId = TaxonomyId;
                    uReq.DirectoryLanguage = TaxonomyLanguage;
                    uReq.PageSize = 99999;
                    uReq.CurrentPage = 1;
                    uDirectory = this.m_refContent.LoadDirectory(ref uReq);
                    TotalItems = uDirectory.DirectoryItems.Count();
                    if (TotalItems > 1)
                    {
                        td_msg.Text = m_refMsg.GetMessage("generic first msg");
                        OrderList.DataSource = uDirectory.DirectoryItems;
                        OrderList.DataTextField = "Username";
                        OrderList.DataValueField = "Id";
                        OrderList.DataBind();
                        OrderList.SelectionMode = ListSelectionMode.Multiple;
                        OrderList.CssClass = "width: 100%; border-style: none; border-color: White; font-family: Verdana;font-size: x-small;";
                        if (TotalItems > 20)
                        {
                            OrderList.Rows = 20;
                        }
                        else
                        {
                            OrderList.Rows = TotalItems;
                        }
                        OrderList.Width = 300;
                        if (TotalItems > 0)
                        {
                            loadscript.Text = "document.forms[0].taxonomy_OrderList[0].selected = true;";
                        }
                        for (int i = 0; i <= TotalItems - 1; i++)
                        {
                            if (LinkOrder.Value == "")
                            {
                                LinkOrder.Value = Convert.ToString(uDirectory.DirectoryItems[i].Id);
                            }
                            else
                            {
                                LinkOrder.Value = Convert.ToString(uDirectory.DirectoryItems[i].Id) + ",";
                            }
                        }
                    }
                    else
                    {
                        LoadNoItem();
                    }
                }
                else
                {
                    AllLangForm.Visible = false; // the all languages checkbox is only valid for categories
                    taxonomy_request.PageSize = 99999999;
                    taxonomy_request.IncludeItems = true;
                    taxonomy_data = m_refContent.ReadTaxonomy(ref taxonomy_request);
                    tr_ordering.Visible = true; //Not showing for items
                    if (taxonomy_data.TaxonomyItems != null)
                    {
                        TotalItems = taxonomy_data.TaxonomyItems.Length;
                        if (TotalItems > 1)
                        {
                            td_msg.Text = m_refMsg.GetMessage("generic first msg");
                            OrderList.DataSource = taxonomy_data.TaxonomyItems;
                            OrderList.DataTextField = "TaxonomyItemTitle";
                            OrderList.DataValueField = "TaxonomyItemId";
                            OrderList.DataBind();
                            OrderList.SelectionMode = ListSelectionMode.Multiple;
                            OrderList.CssClass = "width: 100%; border-style: none; border-color: White; font-family: Verdana;font-size: x-small;";
                            if (TotalItems > 20)
                            {
                                OrderList.Rows = 20;
                            }
                            else
                            {
                                OrderList.Rows = TotalItems;
                            }
                            OrderList.Width = 300;
                            if (TotalItems > 0)
                            {
                                loadscript.Text = "document.forms[0].taxonomy_OrderList[0].selected = true;";
                            }
                            foreach (TaxonomyItemData taxonomy_item in taxonomy_data.TaxonomyItems)
                            {
                                if (LinkOrder.Value == "")
                                {
                                    LinkOrder.Value = Convert.ToString(taxonomy_item.TaxonomyItemId);
                                }
                                else
                                {
                                    LinkOrder.Value = Convert.ToString(taxonomy_item.TaxonomyItemId) + ",";
                                }
                            }
                        }
                        else
                        {
                            LoadNoItem();
                        }
                    }
                }
            }
            TaxonomyToolBar();
        }
    }
コード例 #2
0
ファイル: taxonomytree.ascx.cs プロジェクト: jaytem/minGit
    protected void Page_Load(object sender, System.EventArgs e)
    {
        m_refMsg = m_refCommon.EkMsgRef;
        AppImgPath = m_refCommon.AppImgPath;
        m_strPageAction = Request.QueryString["action"];
        Utilities.SetLanguage(m_refCommon);
        TaxonomyLanguage = m_refCommon.ContentLanguage;
        TaxonomyId = Convert.ToInt64(Request.QueryString["taxonomyid"]);
        taxonomy_request = new TaxonomyRequest();
        taxonomy_request.TaxonomyId = TaxonomyId;
        taxonomy_request.TaxonomyLanguage = TaxonomyLanguage;
        m_refContent = m_refCommon.EkContentRef;
        Util_RegisterResources();
        Util_SetServerJSVariables();

        litEnable.Text = m_refMsg.GetMessage("js:Confirm enable taxonomy all languages");
        litDisable.Text = m_refMsg.GetMessage("js:Confirm disable taxonomy all languages");
        if (Page.IsPostBack)
        {
            if (Request.Form["submittedaction"] == "delete")
            {
                m_refContent.DeleteTaxonomy(taxonomy_request);
                Response.Redirect((string)("taxonomy.aspx?LangType=" + TaxonomyLanguage), true);
            }
            else if (Request.Form["submittedaction"] == "deletenode")
            {
                long CurrentDeleteId = TaxonomyId;
                if ((Request.Form["LastClickedOn"] != null) && Request.Form["LastClickedOn"] != "")
                {
                    CurrentDeleteId = Convert.ToInt64(Request.Form["LastClickedOn"]);
                }
                taxonomy_request.TaxonomyId = CurrentDeleteId;
                m_refContent.DeleteTaxonomy(taxonomy_request);
                if (CurrentDeleteId == TaxonomyId)
                {
                    Response.Redirect((string)("taxonomy.aspx?taxonomyid=" + TaxonomyId), true);
                }
                else
                {
                    Response.Redirect((string)("taxonomy.aspx?action=viewtree&taxonomyid=" + TaxonomyId + "&LangType=" + TaxonomyLanguage), true);
                }
            }
            else if (Request.Form["submittedaction"] == "enable")
            {
                long CurrentEnableId = TaxonomyId;
                if ((Request.Form["LastClickedOn"] != null) && Request.Form["LastClickedOn"] != "")
                {
                    CurrentEnableId = Convert.ToInt64(Request.Form["LastClickedOn"]);
                }
                if (Request.Form[alllanguages.UniqueID] == "true")
                {
                    m_refContent.UpdateTaxonomyVisible(CurrentEnableId, -1, true);
                }
                else
                {
                    m_refContent.UpdateTaxonomyVisible(CurrentEnableId, TaxonomyLanguage, true);
                }
                Response.Redirect((string)("taxonomy.aspx?action=viewtree&taxonomyid=" + TaxonomyId + "&LangType=" + TaxonomyLanguage), true);
            }
            else if (Request.Form["submittedaction"] == "disable")
            {
                long CurrentDisableId = TaxonomyId;
                if ((Request.Form["LastClickedOn"] != null) && Request.Form["LastClickedOn"] != "")
                {
                    CurrentDisableId = Convert.ToInt64(Request.Form["LastClickedOn"]);
                }
                if (Request.Form[alllanguages.UniqueID] == "true")
                {
                    m_refContent.UpdateTaxonomyVisible(CurrentDisableId, -1, false);
                }
                else
                {
                    m_refContent.UpdateTaxonomyVisible(CurrentDisableId, TaxonomyLanguage, false);
                }
                Response.Redirect((string)("taxonomy.aspx?action=viewtree&taxonomyid=" + TaxonomyId + "&LangType=" + TaxonomyLanguage), true);
            }
        }
        else
        {
            taxonomy_data = m_refContent.ReadTaxonomy(ref taxonomy_request);
            if (taxonomy_data != null)
            {
                TaxonomyParentId = taxonomy_data.TaxonomyParentId;
                m_strTaxonomyName = taxonomy_data.TaxonomyName;
            }
            AncestorTaxonomyId = TaxonomyId;
            m_selectedTaxonomyList = Convert.ToString(TaxonomyId);
            TaxonomyToolBar();
        }
    }
コード例 #3
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        try
        {
            m_refMsg = m_refApi.EkMsgRef;
            AppImgPath = m_refApi.AppImgPath;
            AppPath = m_refApi.AppPath;
            m_strPageAction = Request.QueryString["action"];
            Utilities.SetLanguage(m_refApi);
            TaxonomyLanguage = m_refApi.ContentLanguage;
            if ((TaxonomyLanguage == -1))
            {
                TaxonomyLanguage = m_refApi.DefaultContentLanguage;
            }
            if ((Request.QueryString["taxonomyid"] != null))
            {
                TaxonomyId = Convert.ToInt64(Request.QueryString["taxonomyid"]);
            }
            if ((Request.QueryString["parentid"] != null))
            {
                TaxonomyParentId = Convert.ToInt64(Request.QueryString["parentid"]);
                if ((TaxonomyParentId > 0))
                {
                    TitleLabel = "categorytitle";
                    DescriptionLabel = "categorydescription";
                }
            }

            if ((Page.IsPostBack))
            {
                TaxonomyData taxonomy_data = new TaxonomyData();
                taxonomy_data.TaxonomyType = Ektron.Cms.Common.EkEnumeration.TaxonomyType.Locale;
                taxonomy_data.TaxonomyDescription = Request.Form[taxonomydescription.UniqueID];
                taxonomy_data.TaxonomyName = Request.Form[taxonomytitle.UniqueID];
                taxonomy_data.TaxonomyLanguage = TaxonomyLanguage;
                taxonomy_data.TaxonomyParentId = TaxonomyParentId;
               // taxonomy_data.TaxonomyImage = Request.Form[taxonomy_image.UniqueID];
               // taxonomy_data.CategoryUrl = Request.Form[categoryLink.UniqueID];
                //if (tr_enableDisable.Visible == true)
                //{
                //    if (!string.IsNullOrEmpty(Request.Form[chkEnableDisable.UniqueID]))
                //    {
                //        taxonomy_data.Visible = true;
                //    }
                //    else
                //    {
                //        taxonomy_data.Visible = false;
                //    }
                //}
                //else
                //{
                //    taxonomy_data.Visible = true;
                //}

                //if ((Request.Form[inherittemplate.UniqueID] != null))
                //{
                //    taxonomy_data.TemplateInherited = true;
                //}
                //if ((Request.Form[taxonomytemplate.UniqueID] != null))
                //{
                //    taxonomy_data.TemplateId = Convert.ToInt64(Request.Form[taxonomytemplate.UniqueID]);
                //}
                //else
                //{
                //    taxonomy_data.TemplateId = 0;
                //}

                //If (TaxonomyId <> 0) Then
                //  taxonomy_data.TaxonomyId = TaxonomyId
                //End If
                m_refContent = m_refApi.EkContentRef;
                TaxonomyId = m_refContent.CreateTaxonomy(taxonomy_data);
                //add the default language by Default.
                TaxonomyRequest item_request = new TaxonomyRequest();
                item_request.TaxonomyId = TaxonomyId;
                item_request.TaxonomyIdList =Convert.ToString(TaxonomyLanguage);
                item_request.TaxonomyItemType = EkEnumeration.TaxonomyItemType.Locale;
                item_request.TaxonomyLanguage = TaxonomyLanguage;
                m_refContent.AddTaxonomyItem(item_request);
                if (Request.Form[alllanguages.UniqueID] == "false")
                {
                    m_refContent.UpdateTaxonomyVisible(TaxonomyId, -1, false);
                }
                if ((TaxonomyParentId == 0))
                {
                    string strConfig = string.Empty;
                    //if ((!string.IsNullOrEmpty(Request.Form[chkConfigContent.UniqueID])))
                    //{
                    //    strConfig = "0";
                    //}
                    //if ((!string.IsNullOrEmpty(Request.Form[chkConfigUser.UniqueID])))
                    //{
                    //    if ((string.IsNullOrEmpty(strConfig)))
                    //    {
                    //        strConfig = "1";
                    //    }
                    //    else
                    //    {
                    //        strConfig = strConfig + ",1";
                    //    }
                    //}
                    //if ((!string.IsNullOrEmpty(Request.Form[chkConfigGroup.UniqueID])))
                    //{
                    //    if ((string.IsNullOrEmpty(strConfig)))
                    //    {
                    //        strConfig = "2";
                    //    }
                    //    else
                    //    {
                    //        strConfig = strConfig + ",2";
                    //    }
                    //}
                    if ((!(string.IsNullOrEmpty(strConfig))))
                    {
                        m_refContent.UpdateTaxonomyConfig(TaxonomyId, strConfig);
                    }
                }
                //++++++++++++++++++++++++++++++++++++++++++++++++
                //+++++++++ Adding MetaData Information '+++++++++
                //++++++++++++++++++++++++++++++++++++++++++++++++
                //Commeneted as per Doug suggestion
                //AddCustomProperties();

                if ((Request.QueryString["iframe"] == "true"))
                {
                    Response.Write("<script type=\"text/javascript\">parent.CloseChildPage();</script>");
                }
                else
                {
                    //this should jump back to taxonomy that was added
                    //Response.Redirect("taxonomy.aspx?rf=1", True)
                    Response.Redirect("LocaleTaxonomy.aspx?action=view&view=locale&taxonomyid=" + TaxonomyId + "&rf=1", true);
                }
            }
            else
            {
                m_refContent = m_refApi.EkContentRef;
                TaxonomyRequest req = new TaxonomyRequest();
                req.TaxonomyId = TaxonomyParentId;
                req.TaxonomyLanguage = TaxonomyLanguage;

                if (TaxonomyParentId > 0)
                {
                    m_bSynchronized = m_refContent.IsSynchronizedTaxonomy(TaxonomyParentId, TaxonomyLanguage);
                }
                else if (TaxonomyId > 0)
                {
                    m_bSynchronized = m_refContent.IsSynchronizedTaxonomy(TaxonomyId, TaxonomyLanguage);
                }
                //if (!m_bSynchronized)
                //{
                //    tr_enableDisable.Visible = false;
                //}
                TaxonomyBaseData data = m_refContent.ReadTaxonomy(ref req);
                if ((data == null))
                {
                    EkException.ThrowException(new Exception("Invalid taxonomy ID: " + TaxonomyId + " parent: " + TaxonomyParentId));
                }
                language_data = (new SiteAPI()).GetLanguageById(TaxonomyLanguage);
                if (((language_data != null) && (m_refApi.EnableMultilingual == 1)))
                {
                    lblLanguage.Text = "[" + language_data.Name + "]";
                }
              //  taxonomy_image_thumb.ImageUrl = m_refApi.AppImgPath + "spacer.gif";
                m_strCurrentBreadcrumb = data.TaxonomyPath.Remove(0, 1).Replace("\\", " > ");
                if ((string.IsNullOrEmpty(m_strCurrentBreadcrumb)))
                {
                    m_strCurrentBreadcrumb = "Root";
                }
                //if ((TaxonomyParentId == 0))
                //{
                //    inherittemplate.Visible = false;
                //    lblInherited.Text = "No";
                //}
                //else
                //{
                //    inherittemplate.Checked = true;
                //    taxonomytemplate.Enabled = false;
                //    inherittemplate.Visible = true;
                //    lblInherited.Text = "";
                //}
             //   TemplateData[] templates = null;
               // templates = m_refApi.GetAllTemplates("TemplateFileName");
                //taxonomytemplate.Items.Add(new System.Web.UI.WebControls.ListItem("-select template-", "0"));
                //if ((templates != null && templates.Length > 0))
                //{
                //    for (int i = 0; i <= templates.Length - 1; i++)
                //    {
                //        taxonomytemplate.Items.Add(new System.Web.UI.WebControls.ListItem(templates[i].FileName, templates[i].Id.ToString()));
                //    }
                //}

               // inherittemplate.Attributes.Add("onclick", "OnInheritTemplateClicked(this)");
               // inherittemplate.Attributes.Add("onclick", "OnInheritTemplateClicked(this)");
                //if ((TaxonomyParentId == 0))
                //{
                //    tr_config.Visible = true;
                //}
                //else
                //{
                //    tr_config.Visible = false;
                //}
               // chkConfigContent.Checked = true;
                //LoadCustomPropertyList();
                TaxonomyToolBar();
            }
        }
        catch (System.Threading.ThreadAbortException)
        {
            //Do nothing
        }
        catch (Exception ex)
        {
            Response.Redirect(AppPath + "reterror.aspx?info=" + EkFunctions.UrlEncode(ex.Message + ".") + "&LangType=" + TaxonomyLanguage, false);
        }
    }
コード例 #4
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        m_refMsg = m_refApi.EkMsgRef;
        AppImgPath = m_refApi.AppImgPath;
        m_strPageAction = Request.QueryString["action"];
        object refAPI = m_refApi as object;
        Utilities.SetLanguage(m_refApi);
        TaxonomyLanguage = m_refApi.ContentLanguage;
        if ((TaxonomyLanguage == -1))
        {
            TaxonomyLanguage = m_refApi.DefaultContentLanguage;
        }
        if ((Request.QueryString["taxonomyid"] != null))
        {
            TaxonomyId = Convert.ToInt64(Request.QueryString["taxonomyid"]);
            hdnTaxonomyId.Value = TaxonomyId.ToString();
        }
        if ((Request.QueryString["parentid"] != null))
        {
            TaxonomyParentId = Convert.ToInt64(Request.QueryString["parentid"]);
        }
        m_refContent = m_refApi.EkContentRef;
        if ((Request.QueryString["reorder"] != null))
        {
            m_strReorderAction = Convert.ToString(Request.QueryString["reorder"]);
        }
        if ((Request.QueryString["view"] != null))
        {
            _ViewItem = Request.QueryString["view"];
        }
        if ((Page.IsPostBack))
        {
            if ((m_strPageAction == "edit"))
            {
                taxonomy_data.TaxonomyLanguage = TaxonomyLanguage;
                taxonomy_data.TaxonomyParentId = TaxonomyParentId;
                taxonomy_data.TaxonomyId = TaxonomyId;
                taxonomy_data.TaxonomyDescription = Request.Form[taxonomydescription.UniqueID];
                taxonomy_data.TaxonomyName = Request.Form[taxonomytitle.UniqueID];
                // taxonomy_data.TaxonomyImage = Request.Form[taxonomy_image.UniqueID];
                //  taxonomy_data.CategoryUrl = Request.Form[categoryLink.UniqueID];
                //if (tr_enableDisable.Visible == true)
                //{
                //    if (!string.IsNullOrEmpty(Request.Form[chkEnableDisable.UniqueID]))
                //    {
                //        taxonomy_data.Visible = true;
                //    }
                //    else
                //    {
                //        taxonomy_data.Visible = false;
                //    }
                //}
                //else
                //{
                //    taxonomy_data.Visible = Convert.ToBoolean(Request.Form[visibility.UniqueID]);
                //}
                //if ((Request.Form[inherittemplate.UniqueID] != null))
                //{
                //    taxonomy_data.TemplateInherited = true;
                //}
                //if ((Request.Form[taxonomytemplate.UniqueID] != null))
                //{
                //    taxonomy_data.TemplateId = Convert.ToInt64(Request.Form[taxonomytemplate.UniqueID]);
                //}
                //else
                //{
                //    taxonomy_data.TemplateId = 0;
                //}

                try
                {
                    m_refContent.UpdateTaxonomy(taxonomy_data);
                }
                catch (Exception ex)
                {
                    Utilities.ShowError(ex.Message);
                }
                //if (((Request.Form[chkApplyDisplayAllLanguages.UniqueID] != null)) && (Request.Form[chkApplyDisplayAllLanguages.UniqueID].ToString().ToLower() == "on"))
                //{
                //    m_refContent.UpdateTaxonomyVisible(TaxonomyId, -1, taxonomy_data.Visible);
                //}
                //else
                //{
                //    m_refContent.UpdateTaxonomyVisible(TaxonomyId, TaxonomyLanguage, taxonomy_data.Visible);
                //}
                if ((TaxonomyParentId == 0))
                {
                    string strConfig = string.Empty;
                    //if ((!string.IsNullOrEmpty(Request.Form[chkConfigContent.UniqueID])))
                    //{
                    //    strConfig = "0";
                    //}
                    //if ((!string.IsNullOrEmpty(Request.Form[chkConfigUser.UniqueID])))
                    //{
                    //    if ((string.IsNullOrEmpty(strConfig)))
                    //    {
                    //        strConfig = "1";
                    //    }
                    //    else
                    //    {
                    //        strConfig = strConfig + ",1";
                    //    }
                    //}
                    //if ((!string.IsNullOrEmpty(Request.Form[chkConfigGroup.UniqueID])))
                    //{
                    //    if ((string.IsNullOrEmpty(strConfig)))
                    //    {
                    //        strConfig = "2";
                    //    }
                    //    else
                    //    {
                    //        strConfig = strConfig + ",2";
                    //    }
                    //}
                    //if ((!(string.IsNullOrEmpty(strConfig))))
                    //{
                    //    m_refContent.UpdateTaxonomyConfig(TaxonomyId, strConfig);
                    //}
                }
                UpdateCustomProperties();

                if ((Request.QueryString["iframe"] == "true"))
                {
                    Response.Write("<script type=\"text/javascript\">parent.CloseChildPage();</script>");
                }
                else
                {
                    if ((Request.QueryString["backaction"] != null && Convert.ToString(Request.QueryString["backaction"]).ToLower() == "viewtree"))
                    {
                        Response.Redirect("LocaleTaxonomy.aspx?action=viewtree&taxonomyid=" + TaxonomyId + "&LangType=" + TaxonomyLanguage, true);
                    }
                    else if (Request.QueryString["view"] != null)
                    {
                        Response.Redirect("LocaleTaxonomy.aspx?action=view&view=" +Convert.ToString(Request.QueryString["view"]) + "&taxonomyid=" + TaxonomyId + "&rf=1", true);
                    }
                    else
                    {
                        Response.Redirect("LocaleTaxonomy.aspx?action=view&view=item&taxonomyid=" + TaxonomyId + "&rf=1", true);
                    }
                }
            }
            else
            {
                if ((!string.IsNullOrEmpty(Request.Form[LinkOrder.UniqueID])))
                {
                    taxonomy_request = new TaxonomyRequest();
                    taxonomy_request.TaxonomyId = TaxonomyId;
                    taxonomy_request.TaxonomyLanguage = TaxonomyLanguage;
                    taxonomy_request.TaxonomyIdList = Request.Form[LinkOrder.UniqueID];
                    if (!string.IsNullOrEmpty(Request.Form[chkOrderAllLang.UniqueID]))
                    {
                        if ((m_strReorderAction == "category"))
                        {
                            m_refContent.ReOrderAllLanguageCategories(taxonomy_request);
                        }
                    }
                    else
                    {
                        if ((m_strReorderAction == "category"))
                        {
                            m_refContent.ReOrderCategories(taxonomy_request);
                        }
                        else
                        {
                            m_refContent.ReOrderTaxonomyItems(taxonomy_request);
                        }
                    }
                }
                if ((Request.QueryString["iframe"] == "true"))
                {
                    Response.Write("<script type=\"text/javascript\">parent.CloseChildPage();</script>");
                }
                else
                {
                    Response.Redirect("LocaleTaxonomy.aspx?action=view&type="+ Request.QueryString["type"]+"&taxonomyid=" + TaxonomyId + "&rf=1", true);
                }
            }
        }
        else
        {
            //ltr_sitepath.Text = m_refApi.SitePath;
            taxonomy_request = new TaxonomyRequest();
            taxonomy_request.TaxonomyId = TaxonomyId;
            taxonomy_request.TaxonomyLanguage = TaxonomyLanguage;

            if ((m_strPageAction == "edit"))
            {
                taxonomy_data = m_refContent.ReadTaxonomy(ref taxonomy_request);

                taxonomydescription.Text = taxonomy_data.TaxonomyDescription;
                taxonomytitle.Text = taxonomy_data.TaxonomyName;
                //  taxonomy_image.Text = taxonomy_data.TaxonomyImage;
                // taxonomy_image_thumb.ImageUrl = taxonomy_data.TaxonomyImage;
                //   categoryLink.Text = taxonomy_data.CategoryUrl;
                visibility.Value = taxonomy_data.Visible.ToString();
                if ((Request.QueryString["taxonomyid"] != null))
                {
                    TaxonomyId = Convert.ToInt64(Request.QueryString["taxonomyid"]);
                }

                if (TaxonomyParentId > 0)
                {
                    m_bSynchronized = m_refContent.IsSynchronizedTaxonomy(TaxonomyParentId, TaxonomyLanguage);
                }
                else if (TaxonomyId > 0)
                {
                    m_bSynchronized = m_refContent.IsSynchronizedTaxonomy(TaxonomyId, TaxonomyLanguage);
                }

                // ' why in the world would you disable the visible flag if it's not synchronized???
                //If Not m_bSynchronized Then
                //tr_enableDisable.Visible = False
                //End If

                //if (taxonomy_data.Visible == true)
                //{
                //    chkEnableDisable.Checked = true;
                //}
                //else
                //{
                //    chkEnableDisable.Checked = false;
                //}
                //if (!string.IsNullOrEmpty(taxonomy_data.TaxonomyImage))
                //{
                //    taxonomy_image_thumb.ImageUrl = (taxonomy_data.TaxonomyImage.IndexOf("/") == 0 ? taxonomy_data.TaxonomyImage : m_refApi.SitePath + taxonomy_data.TaxonomyImage);
                //}
                //else
                //{
                //    taxonomy_image_thumb.ImageUrl = m_refApi.AppImgPath + "spacer.gif";
                //}
                //language_data = (new SiteAPI()).GetLanguageById(TaxonomyLanguage);
                ////if ((taxonomy_data.TaxonomyParentId == 0))
                //{
                //    inherittemplate.Visible = false;
                //    lblInherited.Text = "No";
                //    inherittemplate.Checked = taxonomy_data.TemplateInherited;
                //}
                //else
                //{
                //    inherittemplate.Visible = true;
                //    lblInherited.Text = "";
                //    inherittemplate.Checked = taxonomy_data.TemplateInherited;
                //    if ((taxonomy_data.TemplateInherited))
                //    {
                //        taxonomytemplate.Enabled = false;
                //    }
                //}
                //TemplateData[] templates = null;
                //templates = m_refApi.GetAllTemplates("TemplateFileName");
                //taxonomytemplate.Items.Add(new System.Web.UI.WebControls.ListItem("-select template-", "0"));
                //if ((templates != null && templates.Length > 0))
                //{
                //    for (int i = 0; i <= templates.Length - 1; i++)
                //    {
                //        taxonomytemplate.Items.Add(new System.Web.UI.WebControls.ListItem(templates[i].FileName, templates[i].Id.ToString()));
                //        if ((taxonomy_data.TemplateId == templates[i].Id))
                //        {
                //            taxonomytemplate.SelectedIndex = i + 1;
                //        }
                //    }
                //}
                if (((language_data != null) && (m_refApi.EnableMultilingual == 1)))
                {
                    lblLanguage.Text = "[" + language_data.Name + "]";
                }
                m_strCurrentBreadcrumb = taxonomy_data.TaxonomyPath.Remove(0, 1).Replace("\\", " > ");
                if ((string.IsNullOrEmpty(m_strCurrentBreadcrumb)))
                {
                    m_strCurrentBreadcrumb = "Root";
                }
                //admin inherittemplate.Attributes.Add("onclick", "OnInheritTemplateClicked(this)");
                if ((TaxonomyParentId == 0))
                {
                    //tr_config.Visible = true;
                    //List<Int32> config_list = m_refApi.EkContentRef.GetAllConfigIdListByTaxonomy(TaxonomyId, TaxonomyLanguage);
                    //for (int i = 0; i <= config_list.Count - 1; i++)
                    //{
                    //    if ((config_list[i] == 0))
                    //    {
                    //        chkConfigContent.Checked = true;
                    //    }
                    //    else if ((config_list[i] == 1))
                    //    {
                    //        chkConfigUser.Checked = true;
                    //    }
                    //    else if ((config_list[i] == 2))
                    //    {
                    //        chkConfigGroup.Checked = true;
                    //    }
                    //}
                }
                else
                {
                    //  tr_config.Visible = false;
                }
                LoadCustomPropertyList();
            }
            else
            {
                if ((m_strReorderAction == "category"))
                {
                    taxonomy_request.PageSize = 99999999;
                    // pagesize of 0 used to mean "all"
                    taxonomy_arr = m_refContent.ReadAllSubCategories(taxonomy_request);
                    if ((taxonomy_arr != null))
                    {
                        TotalItems = taxonomy_arr.Length;
                    }
                    else
                    {
                        TotalItems = 0;
                    }
                    if ((TotalItems > 1))
                    {
                        td_msg.Text = m_refMsg.GetMessage("generic first msg");
                        OrderList.DataSource = taxonomy_arr;
                        OrderList.DataTextField = "TaxonomyName";
                        OrderList.DataValueField = "TaxonomyId";
                        OrderList.DataBind();
                        OrderList.SelectionMode = ListSelectionMode.Multiple;
                        OrderList.CssClass = "width: 100%; border-style: none; border-color: White; font-family: Verdana;font-size: x-small;";
                        if ((TotalItems > 20))
                        {
                            OrderList.Rows = 20;
                        }
                        else
                        {
                            OrderList.Rows = TotalItems;
                        }
                        OrderList.Width = 300;
                        if ((TotalItems > 0))
                        {
                            loadscript.Text = "document.forms[0].taxonomy_OrderList[0].selected = true;";
                        }
                        for (int i = 0; i <= taxonomy_arr.Length - 1; i++)
                        {
                            if ((string.IsNullOrEmpty(LinkOrder.Value)))
                            {
                                LinkOrder.Value = Convert.ToString(taxonomy_arr[i].TaxonomyId);
                            }
                            else
                            {
                                LinkOrder.Value = Convert.ToString(taxonomy_arr[i].TaxonomyId) + ",";
                            }
                        }
                    }
                    else
                    {
                        LoadNoItem();
                    }
                }
                else
                {
                    AllLangForm.Visible = false;
                    // the all languages checkbox is only valid for categories
                    taxonomy_request.PageSize = 99999999;
                    taxonomy_request.IncludeItems = true;
                    taxonomy_data = m_refContent.ReadTaxonomy(ref taxonomy_request);
                    tr_ordering.Visible = true;
                    //Not showing for items
                    if ((taxonomy_data.TaxonomyItems != null))
                    {
                        TotalItems = taxonomy_data.TaxonomyItems.Length;
                        if ((TotalItems > 1))
                        {
                            td_msg.Text = m_refMsg.GetMessage("generic first msg");
                            OrderList.DataSource = taxonomy_data.TaxonomyItems;
                            OrderList.DataTextField = "TaxonomyItemTitle";
                            OrderList.DataValueField = "TaxonomyItemId";
                            OrderList.DataBind();
                            OrderList.SelectionMode = ListSelectionMode.Multiple;
                            OrderList.CssClass = "width: 100%; border-style: none; border-color: White; font-family: Verdana;font-size: x-small;";
                            if ((TotalItems > 20))
                            {
                                OrderList.Rows = 20;
                            }
                            else
                            {
                                OrderList.Rows = TotalItems;
                            }
                            OrderList.Width = 300;
                            if ((TotalItems > 0))
                            {
                                loadscript.Text = "document.forms[0].taxonomy_OrderList[0].selected = true;";
                            }
                            foreach (TaxonomyItemData taxonomy_item in taxonomy_data.TaxonomyItems)
                            {
                                if ((string.IsNullOrEmpty(LinkOrder.Value)))
                                {
                                    LinkOrder.Value = Convert.ToString(taxonomy_item.TaxonomyItemId);
                                }
                                else
                                {
                                    LinkOrder.Value = Convert.ToString(taxonomy_item.TaxonomyItemId) + ",";
                                }
                            }
                        }
                        else
                        {
                            LoadNoItem();
                        }
                    }
                }
            }
            TaxonomyToolBar();
        }
    }