Esempio n. 1
0
 private string GetLanguageForTaxonomy(long TaxonomyId, string BGColor, bool ShowTranslated, bool ShowAllOpt, string onChangeEv)
 {
     string result = "";
         string frmName = "";
         IList<LanguageData> result_language = null;
         TaxonomyLanguageRequest taxonomy_language_request = new TaxonomyLanguageRequest();
         taxonomy_language_request.TaxonomyId = TaxonomyId;
         if (ShowTranslated)
         {
             taxonomy_language_request.IsTranslated = true;
             result_language = _Content.LoadLanguageForTaxonomy(taxonomy_language_request);
             frmName = "frm_translated";
         }
         else
         {
             taxonomy_language_request.IsTranslated = false;
             result_language = _Content.LoadLanguageForTaxonomy(taxonomy_language_request);
             frmName = "frm_nontranslated";
         }
         result = "<select id=\"" + frmName + "\" name=\"" + frmName + "\" onchange=\"" + onChangeEv + "\">" + "\r\n";
         if (ShowAllOpt)
         {
             if (TaxonomyLanguage == -1)
             {
                 result = result + "<option value=\"-1\" selected>All</option>";
             }
             else
             {
                 result = result + "<option value=\"-1\">All</option>";
             }
         }
         else
         {
             if (ShowTranslated == false)
             {
                 result = result + "<option value=\"0\">-select language-</option>";
             }
         }
         if ((result_language != null) && (result_language.Count > 0) && (_Common.EnableMultilingual == 1))
         {
             foreach (LanguageData language in result_language)
             {
                 if (TaxonomyLanguage == language.Id)
                 {
                     result = result + "<option value=" + language.Id + " selected>" + language.Name + "</option>";
                 }
                 else
                 {
                     result = result + "<option value=" + language.Id + ">" + language.Name + "</option>";
                 }
             }
         }
         else
         {
             result = "";
         }
         if (result.Length > 0)
         {
             result = result + "</select>";
         }
         return (result);
 }
Esempio n. 2
0
    protected void Page_Load(object sender, System.EventArgs e)
    {
        try
            {
                m_refMsg = m_refApi.EkMsgRef;
                AppImgPath = m_refApi.AppImgPath;
                AppPath = m_refApi.AppPath;
                ltr_sitepath.Text = m_refApi.SitePath;
                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 (Request.QueryString["iframe"] == "true")
                {
                    styles.Visible = true;
                }

                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)
                {
                    TaxonomyData taxonomy_data = new TaxonomyData();
                    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);
                    if (Request.Form[alllanguages.UniqueID] == "false")
                    {
                        m_refContent.UpdateTaxonomyVisible(TaxonomyId, -1, false);
                    }
                    m_refContent.UpdateTaxonomySynchronization(TaxonomyId, GetCheckBoxValue(chkTaxSynch));
                    // chkCreateLang
                    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 '+++++++++
                    //++++++++++++++++++++++++++++++++++++++++++++++++
                    AddCustomProperties();
                    //++++++++++++++++++++++++++++++++++++++++++++++++
                    //+++++++++ Adding Other Langs (If Applicable) +++
                    //++++++++++++++++++++++++++++++++++++++++++++++++
                    if (!GetCheckBoxValue(chkTaxSynch) && GetCheckBoxValue(chkCreateLang))
                    {   // Figure out which ones were created.
                        IList<LanguageData> result_language = null;
                        TaxonomyLanguageRequest taxonomy_language_request = new TaxonomyLanguageRequest();
                        taxonomy_language_request.TaxonomyId = TaxonomyId;
                        taxonomy_language_request.IsTranslated = false; // langs that we still need
                        result_language = m_refContent.LoadLanguageForTaxonomy(taxonomy_language_request);
                        if (result_language != null)
                        {
                            foreach(LanguageData lang in result_language)
                            {
                                UsingLanguage(m_refContent.RequestInformation, lang.Id, delegate
                                {
                                    taxonomy_data.TaxonomyId = TaxonomyId;
                                    taxonomy_data.LanguageId = lang.Id;
                                    m_refContent.CreateTaxonomy(taxonomy_data);
                                });
                            }
                        }
                    }

                    if (Request.QueryString["iframe"] == "true")
                    {
                        Packages.EktronCoreJS.Register(this);
                        closeWindow = "Ektron.ready(function(){parent.CloseChildPage();});";
                    }
                    else
                    {
                        //this should jump back to taxonomy that was added
                        //Response.Redirect("taxonomy.aspx?rf=1", True)
                        Response.Redirect("taxonomy.aspx?action=view&view=item&taxonomyid=" + TaxonomyId + "&rf=1&reloadtrees=Tax", 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);
                    }
                    chkTaxSynch.Checked = m_bSynchronized;
                    chkTaxSynch.Attributes.Add("onclick",
                        string.Format("ToggleTaxSynch(this, '{0}');", chkCreateLang.ClientID)
                        );
                    if (m_bSynchronized)
                    {
                        fs_taxsynccreate.Attributes.Add("style", "display:none;");
                    }
                    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 = (string) (data.TaxonomyPath.Remove(0, 1).Replace("\\", " > "));
                    if (m_strCurrentBreadcrumb == "")
                    {
                        m_strCurrentBreadcrumb = "Root";
                    }
                    if (TaxonomyParentId == 0)
                    {
                        inherittemplate.Visible = false;
                        lblInherited.Text = "No";
                        lblInherited.ToolTip = lblInherited.Text;
                    }
                    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("- " + 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()));
                        }
                    }

                    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((string) ("reterror.aspx?info=" + EkFunctions.UrlEncode(ex.Message + ".") + "&LangType=" + TaxonomyLanguage), false);
            }
    }