Пример #1
0
    private void DrawContentTemplatesTable()
    {
        TemplateData[] active_templates;
        active_templates = _ContentApi.GetEnabledTemplatesByFolder(_FolderData.Id);

        TemplateData[] template_data;
        template_data = _ContentApi.GetAllTemplates("TemplateFileName");

        Ektron.Cms.PageBuilder.TemplateModel tmodel = new Ektron.Cms.PageBuilder.TemplateModel();
        for (int i = 0; i <= template_data.Length - 1; i++)
        {
            if (template_data[i].SubType == EkEnumeration.TemplateSubType.MasterLayout)
            {
                template_data[i] = tmodel.FindByID(template_data[i].Id);
            }
        }

        int k = 0;
        int row_id = 0;
        Collection addNew = new Collection();

        bool isInheriting = IsInheritingMultiConfig();

        //If (Not foundDefault) Then
        //    isInheriting = False
        //End If

        StringBuilder str = new StringBuilder();

        str.Append(DrawContentTemplatesBreaker(isInheriting));
        str.Append("<div class=\"ektronTopSpace\"></div>");

        str.Append("<div>");
        str.Append(DrawContentTemplatesHeader());

        //if (_FolderData.Id == 0)
        //{
        //    isInheriting = false;
        //}

        Collection ActiveTemplateIdList = new Collection();
        for (k = 0; k <= active_templates.Length - 1; k++)
        {
            if (!ActiveTemplateIdList.Contains(Convert.ToString(active_templates[k].Id)))
            {
                ActiveTemplateIdList.Add(active_templates[k].Id, Convert.ToString(active_templates[k].Id), null, null);
            }
        }

        if (!ActiveTemplateIdList.Contains(Convert.ToString(_FolderData.TemplateId)))
        {
            ActiveTemplateIdList.Add(_FolderData.TemplateId, Convert.ToString(_FolderData.TemplateId), null, null);
        }

        for (k = 0; k <= template_data.Length - 1; k++)
        {
            if (ActiveTemplateIdList.Contains(Convert.ToString(template_data[k].Id)))
            {

                string typestring = "";
                if (template_data[k].SubType == EkEnumeration.TemplateSubType.Wireframes)
                {
                    typestring = " (" + MessageHelper.GetMessage("lbl pagebuilder wireframe template") + ")";
                }
                else if (template_data[k].SubType == EkEnumeration.TemplateSubType.MasterLayout)
                {
                    typestring = " (" + MessageHelper.GetMessage("lbl pagebuilder master layouts") + ")";
                }
                str.Append(DrawContentTemplatesEntry(row_id, template_data[k].FileName, typestring, template_data[k].Id, System.Convert.ToBoolean(!isInheriting), template_data[k]));
                row_id++;
            }
            else
            {
                Collection cRow = new Collection();
                string type;
                if (template_data[k].SubType == EkEnumeration.TemplateSubType.Wireframes)
                {
                    type = " (" + MessageHelper.GetMessage("lbl pagebuilder wireframe template") + ")";
                }
                else if (template_data[k].SubType == EkEnumeration.TemplateSubType.MasterLayout)
                {
                    type = " (" + MessageHelper.GetMessage("lbl pagebuilder master layouts") + ")";
                }
                else
                {
                    type = "";
                }
                cRow.Add(type, "template_type", null, null);
                cRow.Add(template_data[k].FileName, "template_name", null, null);
                cRow.Add(template_data[k].Id, "template_id", null, null);
                string url = "";
                if (template_data[k].SubType == EkEnumeration.TemplateSubType.MasterLayout)
                {
                    url = _ContentApi.EkContentRef.GetContentQlink(template_data[k].MasterLayoutID, _ContentApi.GetFolderIdForContentId(template_data[k].MasterLayoutID));
                }
                cRow.Add(url, "url", null, null);
                addNew.Add(cRow, null, null, null);
            }
        }

        str.Append(DrawContentTemplatesFooter());
        str.Append("</div>");

        str.Append("<div class=\"ektronTopSpace\"></div>");

        str.Append("<table><tbody>");
        str.Append("<tr>");
        str.Append("<td>");
        str.Append("<select name=\"addTemplate\" id=\"addTemplate\" disabled>");
        str.Append("<option value=\"0\">" + MessageHelper.GetMessage("generic select template") + "</option>");

        foreach (Collection row in addNew)
        {
            str.Append("<option value=\"" + row["template_id"] + "\"");
            if (!string.IsNullOrEmpty(Convert.ToString(row["url"])))
            {
                str.Append(" url=\"" + row["url"] + "\"");
            }
            str.Append(">" + row["template_name"] + row["template_type"] + "</option>");
        }
        str.Append("</select>");
        str.Append("</td>");
        str.Append("<td>&nbsp;</td>");
        str.Append("<td>");
        str.Append("<a href=\"#\" onclick=\"PreviewTemplate(\'" + _ContentApi.SitePath + "\', 800,600);return false;\"><img src=\"" + _AppPath + "images/UI/Icons/preview.png" + "\" alt=\""+  MessageHelper.GetMessage("lbl preview template") + "\" title=\"" + MessageHelper.GetMessage("lbl preview template") + "\" /></a>");
        str.Append("</td>");
        str.Append("<td>&nbsp;</td>");
        str.Append("<td>");
        str.Append("<a href=\"javascript:ActivateTemplate(\'" + this._ContentApi.SitePath + "\')\"><img src=\"" + _AppPath + "images/UI/icons/add.png\" alt=\"" + MessageHelper.GetMessage("add title") + "\" title=\"" + MessageHelper.GetMessage("add title") + "\" /></a>");
        str.Append("</td>");
        str.Append("</tr>");
        str.Append("</tbody></table>");

        if (row_id % 2 == 0)
        {
            str.Append("<input type=\"hidden\" name=\"tisEven\" id=\"tisEven\" value=\"1\" />");
        }
        else
        {
            str.Append("<input type=\"hidden\" name=\"tisEven\" id=\"tisEven\" value=\"0\" />");
        }

        str.Append("<div class=\"ektronTopSpace\"></div>");
        str.Append("<a href=\"javascript:OpenAddDialog()\" class=\"button buttonInlineBlock greenHover buttonAdd\">" + MessageHelper.GetMessage("lbl add new template") + "</a>");
        //str.Append("<a href=""javascript:LoadChildPage()"" class=""button buttonInlineBlock greenHover buttonAdd"">" & MessageHelper.GetMessage("lbl add new template") & "</a>")

        litBlogTemplate.Text = str.ToString();
        template_list.Text = str.ToString();
    }
Пример #2
0
    private void EditSelectedTemplate()
    {
        StringBuilder str = new StringBuilder();
        bool bShowTemplateUI = false;
        int iContType;

        if (Request.QueryString["ContType"] == null)
        {
            iContType = Ektron.Cms.Common.EkConstants.CMSContentType_Content;
        }
        else
        {
            iContType = Convert.ToInt32(Request.QueryString["ContType"]);
        }

        if (m_strType == "add")
        {
            if (iContType == Ektron.Cms.Common.EkConstants.CMSContentType_Content || iContType == Ektron.Cms.Common.EkConstants.CMSContentType_Forms || iContType == EkConstants.CMSContentType_Media || iContType == EkConstants.CMSContentType_Archive_Content || iContType == EkConstants.CMSContentType_Archive_Forms || iContType == EkConstants.CMSContentType_Archive_Media)
            {
                bShowTemplateUI = true;
            }
        }
        else
        {
            if (content_edit_data != null)
            {
                iContType = content_edit_data.Type;
                if (iContType == Ektron.Cms.Common.EkConstants.CMSContentType_Content || iContType == Ektron.Cms.Common.EkConstants.CMSContentType_Forms || iContType == EkConstants.CMSContentType_Media || iContType == EkConstants.CMSContentType_Archive_Content || iContType == EkConstants.CMSContentType_Archive_Forms || iContType == EkConstants.CMSContentType_Archive_Media)
                {
                    bShowTemplateUI = true;
                }
            }
        }
        if (!bShowTemplateUI)
        {
            str.Append( m_refMsg.GetMessage("Generic Not Applicable"));
        }
        else
        {
            if ((m_strType == "add" && (content_data != null) && (content_data.SubType == Ektron.Cms.Common.EkEnumeration.CMSContentSubtype.PageBuilderData || content_data.SubType == Ektron.Cms.Common.EkEnumeration.CMSContentSubtype.PageBuilderMasterData)) || ((content_edit_data != null) && (content_edit_data.SubType == Ektron.Cms.Common.EkEnumeration.CMSContentSubtype.PageBuilderData || content_edit_data.SubType == Ektron.Cms.Common.EkEnumeration.CMSContentSubtype.PageBuilderMasterData)))
            {
                 //show available wireframes
                Ektron.Cms.PageBuilder.WireframeModel wfm = new Ektron.Cms.PageBuilder.WireframeModel();

                Ektron.Cms.PageBuilder.WireframeData[] active_template_list = wfm.FindByFolderID(folder_data.Id);

                long selected_templateid = this.m_refContApi.GetSelectedTemplateByContent(m_refContentId, m_refContApi.RequestInformationRef.ContentLanguage);
                if (selected_templateid == 0)
                {
                    //check if this is a translation, if so, get the one from the original language
                    if (!string.IsNullOrEmpty(Request.QueryString["translate"]) && !string.IsNullOrEmpty(Request.QueryString["con_lang_id"]))
                    {
                        int originalLang = Int32.Parse(Request.QueryString["con_lang_id"]);
                        selected_templateid = this.m_refContApi.GetSelectedTemplateByContent(m_refContentId, originalLang);
                    }
                    //check if default language has one
                    if (selected_templateid == 0 && m_refContApi.RequestInformationRef.ContentLanguage != m_refContApi.RequestInformationRef.DefaultContentLanguage)
                    {
                        selected_templateid = this.m_refContApi.GetSelectedTemplateByContent(m_refContentId, m_refContApi.RequestInformationRef.DefaultContentLanguage);
                    }
                    if (selected_templateid == 0)//just use the default
                    {
                        selected_templateid = folder_data.TemplateId;
                    }
                }

                if (active_template_list.Length < 1 && selected_templateid == 0)
                {
                    phTemplates.Visible = false;
                    EditTemplateHtml.Visible = false;
                }

                str.Append("<table class=\"ektronForm\">");
                str.Append("<tr>");
                str.Append("<td class=\"label\">");
                str.Append(m_refMsg.GetMessage("template label") + ":");
                str.Append("</td>");
                str.Append("<td class=\"value\">");
                str.Append("<select id=\"templateSelect\" name=\"templateSelect\">");
                foreach (Ektron.Cms.PageBuilder.WireframeData wireframe in active_template_list)
                {
                    if (wireframe.Template.Id == selected_templateid)
                    {
                        str.Append("<option value=\"" + wireframe.Template.Id + "\" selected>" + wireframe.Path + "</option>");
                    }
                    else
                    {
                        str.Append("<option value=\"" + wireframe.Template.Id + "\">" + wireframe.Path + "</option>");
                    }
                }

                if (active_template_list.Length == 0)
                {
                    Ektron.Cms.PageBuilder.TemplateModel templModel = new Ektron.Cms.PageBuilder.TemplateModel();
                    TemplateData selectedTemplate = templModel.FindByID(selected_templateid);
                    string selectedTemplateName = (selectedTemplate != null) ? selectedTemplate.TemplateName : "";

                    str.Append("<option value=\"" + selected_templateid + "\" selected>" + selectedTemplateName + "</option>");
                }
                str.Append("</select>");
                str.Append("</td>");
                str.Append("</tr>");
                str.Append("</table>");
                if (content_edit_data != null)
                {
                    if (content_edit_data.LockedContentLink)
                    {
                        str.AppendLine("<br/>");
                        str.AppendLine("<label>Quicklink Locked:</label><input type=\"checkbox\" onclick=\"DisableTemplateSelect(this.checked)\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\"" + (content_edit_data.LockedContentLink ? "checked=\"true\"" : "") + "\"/>");
                        str.AppendLine("<br/>");
                        str.AppendLine("<label>Quicklink:</label> \"" + content_edit_data.Quicklink + "\"");
                        str.AppendLine("<script language=\"Javascript\"> DisableTemplateSelect(true) </script>");
                    }
                    else
                    {
                        str.AppendLine("<input type=\"hidden\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\" value=\"false\" />");
                    }
                }
                else
                {
                    str.AppendLine("<input type=\"hidden\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\" value=\"false\" />");
                }
            }
            else
            {
                TemplateData[] active_template_list = m_refContApi.GetEnabledTemplatesByFolder(folder_data.Id);

                if (active_template_list.Length < 1)
                {
                    phTemplates.Visible = false;
                    EditTemplateHtml.Visible = false;
                }

                long selected_folder = this.m_refContApi.GetSelectedTemplateByContent(m_refContentId, m_refContApi.RequestInformationRef.ContentLanguage);
                if (selected_folder == 0)
                {
                    selected_folder = folder_data.TemplateId;
                }

                str.Append("<table class=\"ektronForm\">");
                str.Append("<tr>");
                str.Append("<td class=\"label\">");
                str.Append(m_refMsg.GetMessage("template label") + ":");
                str.Append("</td>");
                str.Append("<td class=\"value\">");
                str.Append("<select id=\"templateSelect\" name=\"templateSelect\">");
                foreach (TemplateData template in active_template_list)
                {
                    if (template.SubType != Ektron.Cms.Common.EkEnumeration.TemplateSubType.Wireframes)
                    {
                        if (template.Id == selected_folder)
                        {
                            str.Append("<option value=\"" + template.Id + "\" selected>" + template.FileName + "</option>");
                        }
                        else
                        {
                            str.Append("<option value=\"" + template.Id + "\">" + template.FileName + "</option>");
                        }
                    }
                }

                if (active_template_list.Length == 0)
                {
                    str.Append("<option value=\"" + folder_data.TemplateId + "\">" + folder_data.TemplateFileName + "</option>");
                }
                str.Append("</select>");
                str.Append("</td>");
                str.Append("</tr>");
                str.Append("</table>");
                if (content_edit_data != null)
                {
                    if (content_edit_data.LockedContentLink)
                    {
                        str.AppendLine("<br/>");
                        str.AppendLine("<label>Quicklink Locked:</label><input type=\"checkbox\" onclick=\"DisableTemplateSelect(this.checked)\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\"" + (content_edit_data.LockedContentLink ? "checked=\"true\"" : "") + "\"/>");
                        str.AppendLine("<br/>");
                        str.AppendLine("<label>Quicklink:</label> \"" + content_edit_data.Quicklink + "\"");
                        str.AppendLine("<script language=\"Javascript\"> DisableTemplateSelect(true) </script>");
                    }
                    else
                    {
                        str.AppendLine("<input type=\"hidden\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\" value=\"false\" />");
                    }
                }
                else
                {
                    str.AppendLine("<input type=\"hidden\" name=\"chkLockedContentLink\" id=\"chkLockedContentLink\" value=\"false\" />");
                }
            }
        }

        EditTemplateHtml.Text = "<div id=\"dvTemplates\">" + str.ToString() + "</div>";
    }