コード例 #1
0
        //
        //====================================================================================================
        // Replace with main_GetPageArgs()
        //
        // Used Interally by main_GetPageLink to main_Get the TemplateID of the parents
        //====================================================================================================
        //
        internal int getPageDynamicLink_GetTemplateID(int PageID, string UsedIDList)
        {
            int result = 0;

            try {
                int ParentID   = 0;
                int templateId = 0;
                using (var csData = new CsModel(core)) {
                    if (csData.openRecord("Page Content", PageID, "TemplateID,ParentID"))
                    {
                        templateId = csData.getInteger("TemplateID");
                        ParentID   = csData.getInteger("ParentID");
                    }
                }
                //
                // Chase page tree to main_Get templateid
                if (templateId == 0 && ParentID != 0)
                {
                    if (!GenericController.isInDelimitedString(UsedIDList, ParentID.ToString(), ","))
                    {
                        result = getPageDynamicLink_GetTemplateID(ParentID, UsedIDList + "," + ParentID);
                    }
                }
                return(result);
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
        }
コード例 #2
0
 //
 //====================================================================================================
 /// <summary>
 /// Open dataset for the record specified
 /// </summary>
 /// <param name="contentName"></param>
 /// <param name="recordId"></param>
 /// <param name="selectFieldList"></param>
 /// <param name="activeOnly"></param>
 /// <returns></returns>
 public override bool OpenRecord(string contentName, int recordId, string selectFieldList, bool activeOnly)
 {
     try {
         if (!cs.openRecord(contentName, recordId, selectFieldList))
         {
             return(false);
         }
         if (!activeOnly || cs.getBoolean("active"))
         {
             return(true);
         }
         cs.close();
         return(false);
     } catch (Exception ex) {
         LogController.logError(cp.core, ex);
         throw;
     }
 }
コード例 #3
0
        //
        //====================================================================================================
        /// <summary>
        /// Get the Configure Edit
        /// </summary>
        /// <param name="cp"></param>
        /// <returns></returns>
        public static string get(CPClass cp)
        {
            CoreController core = cp.core;

            try {
                KeyPtrController Index = new KeyPtrController();
                int    ContentId       = cp.Doc.GetInteger(RequestNameToolContentId);
                var    contentMetadata = ContentMetadataModel.create(core, ContentId, true, true);
                int    RecordCount     = 0;
                int    formFieldId     = 0;
                string StatusMessage   = "";
                string ErrorMessage    = "";
                bool   ReloadCDef      = cp.Doc.GetBoolean("ReloadCDef");
                if (contentMetadata != null)
                {
                    string ToolButton = cp.Doc.GetText("Button");
                    //
                    if (!string.IsNullOrEmpty(ToolButton))
                    {
                        bool AllowContentAutoLoad = false;
                        if (ToolButton != ButtonCancel)
                        {
                            //
                            // Save the form changes
                            //
                            AllowContentAutoLoad = cp.Site.GetBoolean("AllowContentAutoLoad", true);
                            cp.Site.SetProperty("AllowContentAutoLoad", "false");
                            //
                            // ----- Save the input
                            //
                            RecordCount = GenericController.encodeInteger(cp.Doc.GetInteger("dtfaRecordCount"));
                            if (RecordCount > 0)
                            {
                                int RecordPointer = 0;
                                for (RecordPointer = 0; RecordPointer < RecordCount; RecordPointer++)
                                {
                                    //
                                    string formFieldName = cp.Doc.GetText("dtfaName." + RecordPointer);
                                    CPContentBaseClass.FieldTypeIdEnum formFieldTypeId = (CPContentBaseClass.FieldTypeIdEnum)cp.Doc.GetInteger("dtfaType." + RecordPointer);
                                    formFieldId = GenericController.encodeInteger(cp.Doc.GetInteger("dtfaID." + RecordPointer));
                                    bool formFieldInherited = cp.Doc.GetBoolean("dtfaInherited." + RecordPointer);
                                    //
                                    // problem - looking for the name in the Db using the form's name, but it could have changed.
                                    // have to look field up by id
                                    //
                                    foreach (KeyValuePair <string, Processor.Models.Domain.ContentFieldMetadataModel> cdefFieldKvp in contentMetadata.fields)
                                    {
                                        if (cdefFieldKvp.Value.id == formFieldId)
                                        {
                                            //
                                            // Field was found in CDef
                                            //
                                            if (cdefFieldKvp.Value.inherited && (!formFieldInherited))
                                            {
                                                //
                                                // Was inherited, but make a copy of the field
                                                //
                                                using (var CSTarget = new CsModel(core)) {
                                                    if (CSTarget.insert("Content Fields"))
                                                    {
                                                        using (var CSSource = new CsModel(core)) {
                                                            if (CSSource.openRecord("Content Fields", formFieldId))
                                                            {
                                                                CSSource.copyRecord(CSTarget);
                                                            }
                                                        }
                                                        formFieldId = CSTarget.getInteger("ID");
                                                        CSTarget.set("ContentID", ContentId);
                                                    }
                                                    CSTarget.close();
                                                }
                                                ReloadCDef = true;
                                            }
                                            else if ((!cdefFieldKvp.Value.inherited) && (formFieldInherited))
                                            {
                                                //
                                                // Was a field, make it inherit from it's parent
                                                MetadataController.deleteContentRecord(core, "Content Fields", formFieldId);
                                                ReloadCDef = true;
                                            }
                                            else if ((!cdefFieldKvp.Value.inherited) && (!formFieldInherited))
                                            {
                                                //
                                                // not inherited, save the field values and mark for a reload
                                                //
                                                {
                                                    if (formFieldName.IndexOf(" ") != -1)
                                                    {
                                                        //
                                                        // remoave spaces from new name
                                                        //
                                                        StatusMessage = StatusMessage + "<LI>Field [" + formFieldName + "] was renamed [" + GenericController.strReplace(formFieldName, " ", "") + "] because the field name can not include spaces.</LI>";
                                                        formFieldName = GenericController.strReplace(formFieldName, " ", "");
                                                    }
                                                    //
                                                    string SQL = null;
                                                    //
                                                    if ((!string.IsNullOrEmpty(formFieldName)) && ((int)formFieldTypeId != 0) && ((cdefFieldKvp.Value.nameLc == "") || (cdefFieldKvp.Value.fieldTypeId == 0)))
                                                    {
                                                        //
                                                        // Create Db field, Field is good but was not before
                                                        //
                                                        core.db.createSQLTableField(contentMetadata.tableName, formFieldName, formFieldTypeId);
                                                        StatusMessage = StatusMessage + "<LI>Field [" + formFieldName + "] was saved to this content definition and a database field was created in [" + contentMetadata.tableName + "].</LI>";
                                                    }
                                                    else if ((string.IsNullOrEmpty(formFieldName)) || ((int)formFieldTypeId == 0))
                                                    {
                                                        //
                                                        // name blank or type=0 - do nothing but tell them
                                                        //
                                                        if (string.IsNullOrEmpty(formFieldName) && ((int)formFieldTypeId == 0))
                                                        {
                                                            ErrorMessage += "<LI>Field number " + (RecordPointer + 1) + " was saved to this content definition but no database field was created because a name and field type are required.</LI>";
                                                        }
                                                        else if (formFieldName == "unnamedfield" + formFieldId.ToString())
                                                        {
                                                            ErrorMessage += "<LI>Field number " + (RecordPointer + 1) + " was saved to this content definition but no database field was created because a field name is required.</LI>";
                                                        }
                                                        else
                                                        {
                                                            ErrorMessage += "<LI>Field [" + formFieldName + "] was saved to this content definition but no database field was created because a field type are required.</LI>";
                                                        }
                                                    }
                                                    else if ((formFieldName == cdefFieldKvp.Value.nameLc) && (formFieldTypeId != cdefFieldKvp.Value.fieldTypeId))
                                                    {
                                                        //
                                                        // Field Type changed, must be done manually
                                                        //
                                                        ErrorMessage += "<LI>Field [" + formFieldName + "] changed type from [" + DbBaseModel.getRecordName <ContentFieldTypeModel>(core.cpParent, (int)cdefFieldKvp.Value.fieldTypeId) + "] to [" + DbBaseModel.getRecordName <ContentFieldTypeModel>(core.cpParent, (int)formFieldTypeId) + "]. This may have caused a problem converting content.</LI>";
                                                        int DataSourceTypeId = core.db.getDataSourceType();
                                                        switch (DataSourceTypeId)
                                                        {
                                                        case DataSourceTypeODBCMySQL:
                                                            SQL = "alter table " + contentMetadata.tableName + " change " + cdefFieldKvp.Value.nameLc + " " + cdefFieldKvp.Value.nameLc + " " + core.db.getSQLAlterColumnType(formFieldTypeId) + ";";
                                                            break;

                                                        default:
                                                            SQL = "alter table " + contentMetadata.tableName + " alter column " + cdefFieldKvp.Value.nameLc + " " + core.db.getSQLAlterColumnType(formFieldTypeId) + ";";
                                                            break;
                                                        }
                                                        core.db.executeNonQuery(SQL);
                                                    }
                                                    SQL = "Update ccFields"
                                                          + " Set name=" + DbController.encodeSQLText(formFieldName)
                                                          + ",type=" + (int)formFieldTypeId
                                                          + ",caption=" + DbController.encodeSQLText(cp.Doc.GetText("dtfaCaption." + RecordPointer))
                                                          + ",DefaultValue=" + DbController.encodeSQLText(cp.Doc.GetText("dtfaDefaultValue." + RecordPointer))
                                                          + ",EditSortPriority=" + DbController.encodeSQLText(GenericController.encodeText(cp.Doc.GetInteger("dtfaEditSortPriority." + RecordPointer)))
                                                          + ",Active=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaActive." + RecordPointer))
                                                          + ",ReadOnly=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaReadOnly." + RecordPointer))
                                                          + ",Authorable=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaAuthorable." + RecordPointer))
                                                          + ",Required=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaRequired." + RecordPointer))
                                                          + ",UniqueName=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaUniqueName." + RecordPointer))
                                                          + ",TextBuffered=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaTextBuffered." + RecordPointer))
                                                          + ",Password="******"dtfaPassword." + RecordPointer))
                                                          + ",HTMLContent=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaHTMLContent." + RecordPointer))
                                                          + ",EditTab=" + DbController.encodeSQLText(cp.Doc.GetText("dtfaEditTab." + RecordPointer))
                                                          + ",Scramble=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaScramble." + RecordPointer)) + "";
                                                    if (core.session.isAuthenticatedAdmin())
                                                    {
                                                        SQL += ",adminonly=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaAdminOnly." + RecordPointer));
                                                    }
                                                    if (core.session.isAuthenticatedDeveloper())
                                                    {
                                                        SQL += ",DeveloperOnly=" + DbController.encodeSQLBoolean(cp.Doc.GetBoolean("dtfaDeveloperOnly." + RecordPointer));
                                                    }
                                                    SQL += " where ID=" + formFieldId;
                                                    core.db.executeNonQuery(SQL);
                                                    ReloadCDef = true;
                                                }
                                            }
                                            break;
                                        }
                                    }
                                }
                            }
                            core.cache.invalidateAll();
                            core.clearMetaData();
                        }
                        if (ToolButton == ButtonAdd)
                        {
                            //
                            // ----- Insert a blank Field
                            var defaultValues = ContentMetadataModel.getDefaultValueDict(core, ContentFieldModel.tableMetadata.contentName);
                            var field         = ContentFieldModel.addDefault <ContentFieldModel>(core.cpParent, defaultValues);
                            field.name             = "unnamedField" + field.id.ToString();
                            field.contentId        = ContentId;
                            field.editSortPriority = 0;
                            field.save(core.cpParent);
                            ReloadCDef = true;
                        }
                        //
                        // ----- Button Reload CDef
                        if (ToolButton == ButtonSaveandInvalidateCache)
                        {
                            core.cache.invalidateAll();
                            core.clearMetaData();
                        }
                        //
                        // ----- Restore Content Autoload site property
                        //
                        if (AllowContentAutoLoad)
                        {
                            cp.Site.SetProperty("AllowContentAutoLoad", AllowContentAutoLoad.ToString());
                        }
                        //
                        // ----- Cancel or Save, reload CDef and go
                        //
                        if ((ToolButton == ButtonCancel) || (ToolButton == ButtonOK))
                        {
                            //
                            // ----- Exit back to menu
                            //
                            return(core.webServer.redirect(core.appConfig.adminRoute, "Tool-ConfigureContentEdit, ok or cancel button, go to root."));
                        }
                    }
                }
                //
                //   Print Output
                string description = ""
                                     + HtmlController.p("Use this tool to add or modify content definition fields and the underlying sql table fields.")
                                     + ((ContentId.Equals(0)) ? "" : ""
                                        + HtmlController.ul(""
                                                            + HtmlController.li(HtmlController.a("Edit Content", "?aa=0&cid=3&id=" + ContentId + "&tx=&ad=0&asf=1&af=4", "nav-link btn btn-primary"), "nav-item mr-1")
                                                            + HtmlController.li(HtmlController.a("Edit Records", "?cid=" + ContentId, "nav-link btn btn-primary"), "nav-item mr-1")
                                                            + HtmlController.li(HtmlController.a("Select Different Fields", "?af=105", "nav-link btn btn-primary"), "nav-item mr-1")
                                                            , "nav")
                                        );
                StringBuilderLegacyController Stream = new StringBuilderLegacyController();
                Stream.add(AdminUIController.getHeaderTitleDescription("Manage Admin Edit Fields", description));
                //
                // -- status of last operation
                if (!string.IsNullOrEmpty(StatusMessage))
                {
                    Stream.add(AdminUIController.getToolFormRow(core, "<UL>" + StatusMessage + "</UL>"));
                }
                //
                // -- errors with last operations
                if (!string.IsNullOrEmpty(ErrorMessage))
                {
                    Stream.add(HtmlController.div("There was a problem saving these changes" + "<UL>" + ErrorMessage + "</UL>", "ccError"));
                }
                if (ReloadCDef)
                {
                    contentMetadata = Processor.Models.Domain.ContentMetadataModel.create(core, ContentId, true, true);
                }
                string ButtonList = ButtonCancel + "," + ButtonSelect;
                if (ContentId == 0)
                {
                    //
                    // content tables that have edit forms to Configure
                    bool isEmptyList = false;
                    Stream.add(AdminUIController.getToolFormInputRow(core, "Select a Content Definition to Configure", AdminUIEditorController.getLookupContentEditor(core, RequestNameToolContentId, ContentId, ContentMetadataModel.getContentId(core, "Content"), ref isEmptyList, false, "", "", false, "")));
                }
                else
                {
                    //
                    // Configure edit form
                    Stream.add(HtmlController.inputHidden(RequestNameToolContentId, ContentId));
                    Stream.add(core.html.getPanelTop());
                    ButtonList = ButtonCancel + "," + ButtonSave + "," + ButtonOK + "," + ButtonAdd;
                    //
                    // Get a new copy of the content definition
                    //
                    Stream.add(SpanClassAdminNormal + "<P><B>" + contentMetadata.name + "</b></P>");
                    Stream.add("<table border=\"0\" cellpadding=\"1\" cellspacing=\"1\" width=\"100%\">");
                    //
                    int  ParentContentId  = contentMetadata.parentId;
                    bool AllowCDefInherit = false;
                    Processor.Models.Domain.ContentMetadataModel ParentCDef = null;
                    if (ParentContentId == -1)
                    {
                        AllowCDefInherit = false;
                    }
                    else
                    {
                        AllowCDefInherit = true;
                        string ParentContentName = MetadataController.getContentNameByID(core, ParentContentId);
                        ParentCDef = Processor.Models.Domain.ContentMetadataModel.create(core, ParentContentId, true, true);
                    }
                    bool NeedFootNote1 = false;
                    bool NeedFootNote2 = false;
                    if (contentMetadata.fields.Count > 0)
                    {
                        //
                        // -- header row
                        Stream.add("<tr>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\"></td>");
                        if (!AllowCDefInherit)
                        {
                            Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Inherited*</b></span></td>");
                            NeedFootNote1 = true;
                        }
                        else
                        {
                            Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Inherited</b></span></td>");
                        }
                        Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>Field</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>Caption</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>Edit Tab</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"100\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>Default</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>Type</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b>Edit<br>Order</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Active</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b>Read<br>Only</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Auth</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Req</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Unique</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b>Text<br>Buffer</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b><br>Pass</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "<b>Text<br>Scrm</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b><br>HTML</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b>Admin<br>Only</b></span></td>");
                        Stream.add("<td valign=\"bottom\" width=\"50\" class=\"ccPanelInput\" align=\"left\">" + SpanClassAdminSmall + "<b>Dev<br>Only</b></span></td>");
                        Stream.add("</tr>");
                        RecordCount = 0;
                        //
                        // Build a select template for Type
                        //
                        string TypeSelectTemplate = core.html.selectFromContent("menuname", -1, "Content Field Types", "", "unknown");
                        //
                        // Index the sort order
                        //
                        List <FieldSortClass> fieldList = new List <FieldSortClass>();
                        int FieldCount = contentMetadata.fields.Count;
                        foreach (var keyValuePair in contentMetadata.fields)
                        {
                            FieldSortClass fieldSort = new FieldSortClass();
                            string         sortOrder = "";
                            fieldSort.field = keyValuePair.Value;
                            sortOrder       = "";
                            if (fieldSort.field.active)
                            {
                                sortOrder += "0";
                            }
                            else
                            {
                                sortOrder += "1";
                            }
                            if (fieldSort.field.authorable)
                            {
                                sortOrder += "0";
                            }
                            else
                            {
                                sortOrder += "1";
                            }
                            sortOrder     += fieldSort.field.editTabName + getIntegerString(fieldSort.field.editSortPriority, 10) + getIntegerString(fieldSort.field.id, 10);
                            fieldSort.sort = sortOrder;
                            fieldList.Add(fieldSort);
                        }
                        fieldList.Sort((p1, p2) => p1.sort.CompareTo(p2.sort));
                        StringBuilderLegacyController StreamValidRows = new StringBuilderLegacyController();
                        var contentFieldsCdef = Processor.Models.Domain.ContentMetadataModel.createByUniqueName(core, "content fields");
                        foreach (FieldSortClass fieldsort in fieldList)
                        {
                            StringBuilderLegacyController streamRow = new StringBuilderLegacyController();
                            bool rowValid = true;
                            //
                            // If Field has name and type, it is locked and can not be changed
                            //
                            bool FieldLocked = (fieldsort.field.nameLc != "") && (fieldsort.field.fieldTypeId != 0);
                            //
                            // put the menu into the current menu format
                            //
                            formFieldId = fieldsort.field.id;
                            streamRow.add(HtmlController.inputHidden("dtfaID." + RecordCount, formFieldId));
                            streamRow.add("<tr>");
                            //
                            // edit button
                            //
                            streamRow.add("<td class=\"ccPanelInput\" align=\"left\">" + AdminUIController.getRecordEditAnchorTag(core, contentFieldsCdef, formFieldId) + "</td>");
                            //
                            // Inherited
                            //
                            if (!AllowCDefInherit)
                            {
                                //
                                // no parent
                                //
                                streamRow.add("<td class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "False</span></td>");
                            }
                            else if (fieldsort.field.inherited)
                            {
                                //
                                // inherited property
                                //
                                streamRow.add("<td class=\"ccPanelInput\" align=\"center\">" + HtmlController.checkbox("dtfaInherited." + RecordCount, fieldsort.field.inherited) + "</td>");
                            }
                            else
                            {
                                Processor.Models.Domain.ContentFieldMetadataModel parentField = null;
                                //
                                // CDef has a parent, but the field is non-inherited, test for a matching Parent Field
                                //
                                if (ParentCDef == null)
                                {
                                    foreach (KeyValuePair <string, Processor.Models.Domain.ContentFieldMetadataModel> kvp in ParentCDef.fields)
                                    {
                                        if (kvp.Value.nameLc == fieldsort.field.nameLc)
                                        {
                                            parentField = kvp.Value;
                                            break;
                                        }
                                    }
                                }
                                if (parentField == null)
                                {
                                    streamRow.add("<td class=\"ccPanelInput\" align=\"center\">" + SpanClassAdminSmall + "False**</span></td>");
                                    NeedFootNote2 = true;
                                }
                                else
                                {
                                    streamRow.add("<td class=\"ccPanelInput\" align=\"center\">" + HtmlController.checkbox("dtfaInherited." + RecordCount, fieldsort.field.inherited) + "</td>");
                                }
                            }
                            //
                            // name
                            //
                            bool tmpValue = string.IsNullOrEmpty(fieldsort.field.nameLc);
                            rowValid = rowValid && !tmpValue;
                            streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>");
                            if (fieldsort.field.inherited)
                            {
                                streamRow.add(SpanClassAdminSmall + fieldsort.field.nameLc + "&nbsp;</SPAN>");
                            }
                            else if (FieldLocked)
                            {
                                streamRow.add(SpanClassAdminSmall + fieldsort.field.nameLc + "&nbsp;</SPAN><input type=hidden name=dtfaName." + RecordCount + " value=\"" + fieldsort.field.nameLc + "\">");
                            }
                            else
                            {
                                streamRow.add(HtmlController.inputText_Legacy(core, "dtfaName." + RecordCount, fieldsort.field.nameLc, 1, 10));
                            }
                            streamRow.add("</nobr></td>");
                            //
                            // caption
                            //
                            streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>");
                            if (fieldsort.field.inherited)
                            {
                                streamRow.add(SpanClassAdminSmall + fieldsort.field.caption + "</SPAN>");
                            }
                            else
                            {
                                streamRow.add(HtmlController.inputText_Legacy(core, "dtfaCaption." + RecordCount, fieldsort.field.caption, 1, 10));
                            }
                            streamRow.add("</nobr></td>");
                            //
                            // Edit Tab
                            //
                            streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>");
                            if (fieldsort.field.inherited)
                            {
                                streamRow.add(SpanClassAdminSmall + fieldsort.field.editTabName + "</SPAN>");
                            }
                            else
                            {
                                streamRow.add(HtmlController.inputText_Legacy(core, "dtfaEditTab." + RecordCount, fieldsort.field.editTabName, 1, 10));
                            }
                            streamRow.add("</nobr></td>");
                            //
                            // default
                            //
                            streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>");
                            if (fieldsort.field.inherited)
                            {
                                streamRow.add(SpanClassAdminSmall + GenericController.encodeText(fieldsort.field.defaultValue) + "</SPAN>");
                            }
                            else
                            {
                                streamRow.add(HtmlController.inputText_Legacy(core, "dtfaDefaultValue." + RecordCount, GenericController.encodeText(fieldsort.field.defaultValue), 1, 10));
                            }
                            streamRow.add("</nobr></td>");
                            //
                            // type
                            //
                            rowValid = rowValid && (fieldsort.field.fieldTypeId > 0);
                            streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>");
                            if (fieldsort.field.inherited)
                            {
                                using (var csData = new CsModel(core)) {
                                    csData.openRecord("Content Field Types", (int)fieldsort.field.fieldTypeId);
                                    if (!csData.ok())
                                    {
                                        streamRow.add(SpanClassAdminSmall + "Unknown[" + fieldsort.field.fieldTypeId + "]</SPAN>");
                                    }
                                    else
                                    {
                                        streamRow.add(SpanClassAdminSmall + csData.getText("Name") + "</SPAN>");
                                    }
                                }
                            }
                            else if (FieldLocked)
                            {
                                streamRow.add(DbBaseModel.getRecordName <ContentFieldTypeModel>(core.cpParent, (int)fieldsort.field.fieldTypeId) + HtmlController.inputHidden("dtfaType." + RecordCount, (int)fieldsort.field.fieldTypeId));
                            }
                            else
                            {
                                string TypeSelect = TypeSelectTemplate;
                                TypeSelect = GenericController.strReplace(TypeSelect, "menuname", "dtfaType." + RecordCount, 1, 99, 1);
                                TypeSelect = GenericController.strReplace(TypeSelect, "=\"" + fieldsort.field.fieldTypeId + "\"", "=\"" + fieldsort.field.fieldTypeId + "\" selected", 1, 99, 1);
                                streamRow.add(TypeSelect);
                            }
                            streamRow.add("</nobr></td>");
                            //
                            // sort priority
                            //
                            streamRow.add("<td class=\"ccPanelInput\" align=\"left\"><nobr>");
                            if (fieldsort.field.inherited)
                            {
                                streamRow.add(SpanClassAdminSmall + fieldsort.field.editSortPriority + "</SPAN>");
                            }
                            else
                            {
                                streamRow.add(HtmlController.inputText_Legacy(core, "dtfaEditSortPriority." + RecordCount, fieldsort.field.editSortPriority.ToString(), 1, 10));
                            }
                            streamRow.add("</nobr></td>");
                            //
                            // active
                            //
                            streamRow.add(configureEdit_CheckBox("dtfaActive." + RecordCount, fieldsort.field.active, fieldsort.field.inherited));
                            //
                            // read only
                            //
                            streamRow.add(configureEdit_CheckBox("dtfaReadOnly." + RecordCount, fieldsort.field.readOnly, fieldsort.field.inherited));
                            //
                            // authorable
                            //
                            streamRow.add(configureEdit_CheckBox("dtfaAuthorable." + RecordCount, fieldsort.field.authorable, fieldsort.field.inherited));
                            //
                            // required
                            //
                            streamRow.add(configureEdit_CheckBox("dtfaRequired." + RecordCount, fieldsort.field.required, fieldsort.field.inherited));
                            //
                            // UniqueName
                            //
                            streamRow.add(configureEdit_CheckBox("dtfaUniqueName." + RecordCount, fieldsort.field.uniqueName, fieldsort.field.inherited));
                            //
                            // text buffered
                            //
                            streamRow.add(configureEdit_CheckBox("dtfaTextBuffered." + RecordCount, fieldsort.field.textBuffered, fieldsort.field.inherited));
                            //
                            // password
                            //
                            streamRow.add(configureEdit_CheckBox("dtfaPassword." + RecordCount, fieldsort.field.password, fieldsort.field.inherited));
                            //
                            // scramble
                            //
                            streamRow.add(configureEdit_CheckBox("dtfaScramble." + RecordCount, fieldsort.field.scramble, fieldsort.field.inherited));
                            //
                            // HTML Content
                            //
                            streamRow.add(configureEdit_CheckBox("dtfaHTMLContent." + RecordCount, fieldsort.field.htmlContent, fieldsort.field.inherited));
                            //
                            // Admin Only
                            //
                            if (core.session.isAuthenticatedAdmin())
                            {
                                streamRow.add(configureEdit_CheckBox("dtfaAdminOnly." + RecordCount, fieldsort.field.adminOnly, fieldsort.field.inherited));
                            }
                            //
                            // Developer Only
                            //
                            if (core.session.isAuthenticatedDeveloper())
                            {
                                streamRow.add(configureEdit_CheckBox("dtfaDeveloperOnly." + RecordCount, fieldsort.field.developerOnly, fieldsort.field.inherited));
                            }
                            //
                            streamRow.add("</tr>");
                            RecordCount = RecordCount + 1;
                            //
                            // rows are built - put the blank rows at the top
                            //
                            if (!rowValid)
                            {
                                Stream.add(streamRow.text);
                            }
                            else
                            {
                                StreamValidRows.add(streamRow.text);
                            }
                        }
                        Stream.add(StreamValidRows.text);
                        Stream.add(HtmlController.inputHidden("dtfaRecordCount", RecordCount));
                    }
                    Stream.add("</table>");
                    //
                    Stream.add(core.html.getPanelBottom());
                    if (NeedFootNote1)
                    {
                        Stream.add("<br>*Field Inheritance is not allowed because this Content Definition has no parent.");
                    }
                    if (NeedFootNote2)
                    {
                        Stream.add("<br>**This field can not be inherited because the Parent Content Definition does not have a field with the same name.");
                    }
                }
                Stream.add(HtmlController.inputHidden("ReloadCDef", ReloadCDef));
                //
                // -- assemble form
                return(AdminUIController.getToolForm(core, Stream.text, ButtonList));
            } catch (Exception ex) {
                LogController.logError(core, ex);
                return(toolExceptionMessage);
            }
        }
コード例 #4
0
        //
        //====================================================================================================
        //
        public static void processAfterSave_LibraryFiles(CoreController core, bool isDelete, string contentName, int recordID, string recordName, int recordParentID, bool useContentWatchLink)
        {
            //
            // if a AltSizeList is blank, make large,medium,small and thumbnails
            //
            if (core.siteProperties.getBoolean("ImageAllowSFResize", true) && (!isDelete))
            {
                using (var csData = new CsModel(core)) {
                    if (csData.openRecord("library files", recordID))
                    {
                        string Filename = csData.getText("filename");
                        int    Pos      = Filename.LastIndexOf("/") + 1;
                        string FilePath = "";
                        if (Pos > 0)
                        {
                            FilePath = Filename.left(Pos);
                            Filename = Filename.Substring(Pos);
                        }
                        csData.set("filesize", core.wwwFiles.getFileSize(FilePath + Filename));
                        Pos = Filename.LastIndexOf(".") + 1;
                        if (Pos > 0)
                        {
                            string FilenameExt   = Filename.Substring(Pos);
                            string FilenameNoExt = Filename.left(Pos - 1);
                            if (GenericController.strInstr(1, "jpg,gif,png", FilenameExt, 1) != 0)
                            {
                                ImageEditController sf = new ImageEditController();
                                if (sf.load(FilePath + Filename, core.wwwFiles))
                                {
                                    //
                                    //
                                    //
                                    csData.set("height", sf.height);
                                    csData.set("width", sf.width);
                                    string AltSizeList  = csData.getText("AltSizeList");
                                    bool   RebuildSizes = (string.IsNullOrEmpty(AltSizeList));
                                    if (RebuildSizes)
                                    {
                                        AltSizeList = "";
                                        //
                                        // Attempt to make 640x
                                        //
                                        if (sf.width >= 640)
                                        {
                                            sf.height = GenericController.encodeInteger(sf.height * (640 / sf.width));
                                            sf.width  = 640;
                                            sf.save(FilePath + FilenameNoExt + "-640x" + sf.height + "." + FilenameExt, core.wwwFiles);
                                            AltSizeList = AltSizeList + Environment.NewLine + "640x" + sf.height;
                                        }
                                        //
                                        // Attempt to make 320x
                                        //
                                        if (sf.width >= 320)
                                        {
                                            sf.height = GenericController.encodeInteger(sf.height * (320 / sf.width));
                                            sf.width  = 320;
                                            sf.save(FilePath + FilenameNoExt + "-320x" + sf.height + "." + FilenameExt, core.wwwFiles);

                                            AltSizeList = AltSizeList + Environment.NewLine + "320x" + sf.height;
                                        }
                                        //
                                        // Attempt to make 160x
                                        //
                                        if (sf.width >= 160)
                                        {
                                            sf.height = GenericController.encodeInteger(sf.height * (160 / sf.width));
                                            sf.width  = 160;
                                            sf.save(FilePath + FilenameNoExt + "-160x" + sf.height + "." + FilenameExt, core.wwwFiles);
                                            AltSizeList = AltSizeList + Environment.NewLine + "160x" + sf.height;
                                        }
                                        //
                                        // Attempt to make 80x
                                        //
                                        if (sf.width >= 80)
                                        {
                                            sf.height = GenericController.encodeInteger(sf.height * (80 / sf.width));
                                            sf.width  = 80;
                                            sf.save(FilePath + FilenameNoExt + "-180x" + sf.height + "." + FilenameExt, core.wwwFiles);
                                            AltSizeList = AltSizeList + Environment.NewLine + "80x" + sf.height;
                                        }
                                        csData.set("AltSizeList", AltSizeList);
                                    }
                                    sf.Dispose();
                                    sf = null;
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #5
0
        //
        //========================================================================
        /// <summary>
        /// Control edit tab
        /// </summary>
        /// <param name="core"></param>
        /// <param name="adminData"></param>
        /// <returns></returns>
        public static string get(CoreController core, AdminDataModel adminData, EditorEnvironmentModel editorEnv)
        {
            string result = null;

            try {
                bool disabled = false;
                //
                var tabPanel = new StringBuilderLegacyController();
                if (string.IsNullOrEmpty(adminData.adminContent.name))
                {
                    //
                    // Content not found or not loaded
                    if (adminData.adminContent.id == 0)
                    {
                        //
                        LogController.logError(core, new GenericException("No content definition was specified for this page"));
                        return(HtmlController.p("No content was specified."));
                    }
                    else
                    {
                        //
                        // Content Definition was not specified
                        LogController.logError(core, new GenericException("The content definition specified for this page [" + adminData.adminContent.id + "] was not found"));
                        return(HtmlController.p("No content was specified."));
                    }
                }
                //
                // ----- Authoring status
                bool FieldRequired = false;


                List <string> TabsFound = new List <string>();
                foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminData.adminContent.fields)
                {
                    ContentFieldMetadataModel field = keyValuePair.Value;
                    if ((field.editTabName.ToLowerInvariant().Equals("control info")) && (field.authorable) && (field.active))
                    {
                        tabPanel.add(EditorRowClass.getEditorRow(core, field, adminData, editorEnv));
                    }
                }
                //
                // ----- RecordID
                {
                    string fieldValue  = (adminData.editRecord.id == 0) ? "(available after save)" : adminData.editRecord.id.ToString();
                    string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore", fieldValue, true, "");
                    string fieldHelp   = "This is the unique number that identifies this record within this content.";
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Record Number", fieldHelp, true, false, ""));
                }
                //
                // -- Active
                {
                    string htmlId      = "fieldActive";
                    string fieldEditor = HtmlController.checkbox("active", adminData.editRecord.active, htmlId, disabled, "", adminData.editRecord.userReadOnly);
                    string fieldHelp   = "When unchecked, add-ons can ignore this record as if it was temporarily deleted.";
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Active", fieldHelp, false, false, htmlId));
                }
                //
                // -- GUID
                {
                    string guidSetHtmlId   = "guidSet" + GenericController.getRandomInteger(core).ToString();
                    string guidInputHtmlId = "guidInput" + GenericController.getRandomInteger(core).ToString();
                    string fieldValue      = GenericController.encodeText(adminData.editRecord.fieldsLc["ccguid"].value);
                    string fieldEditor     = "";
                    if (adminData.editRecord.userReadOnly)
                    {
                        //
                        // -- readonly
                        fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore", fieldValue, true, "");
                    }
                    else if (string.IsNullOrEmpty(fieldValue))
                    {
                        //
                        // add a set button
                        string setButton        = "<input id=\"" + guidSetHtmlId + "\" type=\"submit\" value=\"Set\" class=\"btn btn-primary btn-sm\">";
                        string setButtonWrapped = "<div class=\"input-group-append\">" + setButton + "</div>";
                        string inputCell        = AdminUIEditorController.getTextEditor(core, "ccguid", "", false, guidInputHtmlId);
                        fieldEditor = HtmlController.div(inputCell + setButtonWrapped, "input-group");
                        string newGuid   = GenericController.getGUID(true);
                        string onClickFn = "function(e){e.preventDefault();e.stopPropagation();$('#" + guidInputHtmlId + "').val('" + newGuid + "');}";
                        string script    = "$('body').on('click','#" + guidSetHtmlId + "'," + onClickFn + ")";
                        core.html.addScriptCode(script, "Admin edit control-info-tab guid set button");
                    }
                    else
                    {
                        //
                        // field is read-only except for developers
                        fieldEditor = AdminUIEditorController.getTextEditor(core, "ccguid", fieldValue, !core.session.isAuthenticatedDeveloper(), guidInputHtmlId);
                    }
                    string FieldHelp = "This is a unique number that identifies this record globally. A GUID is not required, but when set it should never be changed. GUIDs are used to synchronize records. When empty, you can create a new guid. Only Developers can modify the guid.";
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "GUID", FieldHelp, false, false, guidInputHtmlId));
                }
                //
                // ----- EID (Encoded ID)
                {
                    if (GenericController.toUCase(adminData.adminContent.tableName) == GenericController.toUCase("ccMembers"))
                    {
                        string htmlId      = "fieldGuid";
                        bool   AllowEId    = (core.siteProperties.getBoolean("AllowLinkLogin", true)) || (core.siteProperties.getBoolean("AllowLinkRecognize", true));
                        string fieldHelp   = "This string is an authentication token that can be used in the URL for the next 15 minutes to log in as this user.";
                        string fieldEditor = "";
                        if (!AllowEId)
                        {
                            fieldEditor = "(link login and link recognize are disabled in security preferences)";
                        }
                        else if (adminData.editRecord.id == 0)
                        {
                            fieldEditor = "(available after save)";
                        }
                        else
                        {
                            string eidQueryString = "eid=" + WebUtility.UrlEncode(SecurityController.encodeToken(core, adminData.editRecord.id, core.doc.profileStartTime.AddMinutes(15)));
                            string sampleUrl      = core.webServer.requestProtocol + core.webServer.requestDomain + "/" + core.siteProperties.serverPageDefault + "?" + eidQueryString;
                            if (core.siteProperties.getBoolean("AllowLinkLogin", true))
                            {
                                fieldHelp = " If " + eidQueryString + " is added to a url querystring for this site, the user be logged in as this person.";
                            }
                            else
                            {
                                fieldHelp = " If " + eidQueryString + " is added to a url querystring for this site, the user be recognized in as this person, but not logged in.";
                            }
                            fieldHelp  += " To enable, disable or modify this feature, use the security tab on the Preferences page.";
                            fieldHelp  += "<br>For example: " + sampleUrl;
                            fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_eid", eidQueryString, true, htmlId);
                        }
                        tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Member Link Login Querystring", fieldHelp, true, false, htmlId));
                    }
                }
                //
                // ----- Controlling Content
                {
                    string HTMLFieldString          = "";
                    string FieldHelp                = "The content in which this record is stored. This is similar to a database table.";
                    ContentFieldMetadataModel field = null;
                    if (adminData.adminContent.fields.ContainsKey("contentcontrolid"))
                    {
                        field = adminData.adminContent.fields["contentcontrolid"];
                        //
                        // if this record has a parent id, only include CDefs compatible with the parent record - otherwise get all for the table
                        FieldHelp     = GenericController.encodeText(field.helpMessage);
                        FieldRequired = GenericController.encodeBoolean(field.required);
                        int FieldValueInteger = (adminData.editRecord.contentControlId.Equals(0)) ? adminData.adminContent.id : adminData.editRecord.contentControlId;
                        if (!core.session.isAuthenticatedAdmin())
                        {
                            HTMLFieldString = HTMLFieldString + HtmlController.inputHidden("contentControlId", FieldValueInteger);
                        }
                        else
                        {
                            string RecordContentName = adminData.editRecord.contentControlId_Name;
                            string TableName2        = MetadataController.getContentTablename(core, RecordContentName);
                            int    TableId           = MetadataController.getRecordIdByUniqueName(core, "Tables", TableName2);
                            //
                            // Test for parentid
                            int  ParentId = 0;
                            bool ContentSupportsParentId = false;
                            if (adminData.editRecord.id > 0)
                            {
                                using (var csData = new CsModel(core)) {
                                    if (csData.openRecord(RecordContentName, adminData.editRecord.id))
                                    {
                                        ContentSupportsParentId = csData.isFieldSupported("ParentID");
                                        if (ContentSupportsParentId)
                                        {
                                            ParentId = csData.getInteger("ParentID");
                                        }
                                    }
                                }
                            }
                            bool IsEmptyList = false;
                            if (core.session.isAuthenticatedAdmin())
                            {
                                //
                                // administrator, and either ( no parentid or does not support it), let them select any content compatible with the table
                                string sqlFilter  = "(ContentTableID=" + TableId + ")";
                                int    contentCId = MetadataController.getRecordIdByUniqueName(core, ContentModel.tableMetadata.contentName, ContentModel.tableMetadata.contentName);
                                HTMLFieldString += AdminUIEditorController.getLookupContentEditor(core, "contentcontrolid", FieldValueInteger, contentCId, ref IsEmptyList, adminData.editRecord.userReadOnly, "", "", true, sqlFilter);
                                FieldHelp        = FieldHelp + " (Only administrators have access to this control. Changing the Controlling Content allows you to change who can author the record, as well as how it is edited.)";
                            }
                        }
                    }
                    if (string.IsNullOrEmpty(HTMLFieldString))
                    {
                        HTMLFieldString = adminData.editRecord.contentControlId_Name;
                    }
                    tabPanel.add(AdminUIController.getEditRow(core, HTMLFieldString, "Controlling Content", FieldHelp, FieldRequired, false, ""));
                }
                //
                // ----- Created By
                {
                    string FieldHelp  = "The people account of the user who created this record.";
                    string fieldValue = "";
                    if (adminData.editRecord == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else if (adminData.editRecord.id == 0)
                    {
                        fieldValue = "(available after save)";
                    }
                    else if (adminData.editRecord.createdBy == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else
                    {
                        int FieldValueInteger = adminData.editRecord.createdBy.id;
                        if (FieldValueInteger == 0)
                        {
                            fieldValue = "(not set)";
                        }
                        else
                        {
                            using (var csData = new CsModel(core)) {
                                csData.open("people", "(id=" + FieldValueInteger + ")", "name,active", false);
                                if (!csData.ok())
                                {
                                    fieldValue = "#" + FieldValueInteger + ", (deleted)";
                                }
                                else
                                {
                                    fieldValue = "#" + FieldValueInteger + ", " + csData.getText("name");
                                    if (!csData.getBoolean("active"))
                                    {
                                        fieldValue += " (inactive)";
                                    }
                                }
                                csData.close();
                            }
                        }
                    }
                    string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_createdBy", fieldValue, true, "");
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Created By", FieldHelp, FieldRequired, false, ""));
                }
                //
                // ----- Created Date
                {
                    string FieldHelp  = "The date and time when this record was originally created.";
                    string fieldValue = "";
                    if (adminData.editRecord == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else if (adminData.editRecord.id == 0)
                    {
                        fieldValue = "(available after save)";
                    }
                    else
                    {
                        if (GenericController.encodeDateMinValue(adminData.editRecord.dateAdded) == DateTime.MinValue)
                        {
                            fieldValue = "(not set)";
                        }
                        else
                        {
                            fieldValue = adminData.editRecord.dateAdded.ToString();
                        }
                    }
                    string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_createdDate", fieldValue, true, "");
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Created Date", FieldHelp, FieldRequired, false, ""));
                }
                //
                // ----- Modified By
                {
                    string FieldHelp  = "The people account of the last user who modified this record.";
                    string fieldValue = "";
                    if (adminData.editRecord == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else if (adminData.editRecord.id == 0)
                    {
                        fieldValue = "(available after save)";
                    }
                    else if (adminData.editRecord.modifiedBy == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else
                    {
                        int FieldValueInteger = adminData.editRecord.modifiedBy.id;
                        if (FieldValueInteger == 0)
                        {
                            fieldValue = "(not set)";
                        }
                        else
                        {
                            using (var csData = new CsModel(core)) {
                                csData.open("people", "(id=" + FieldValueInteger + ")", "name,active", false);
                                if (!csData.ok())
                                {
                                    fieldValue = "#" + FieldValueInteger + ", (deleted)";
                                }
                                else
                                {
                                    fieldValue = "#" + FieldValueInteger + ", " + csData.getText("name");
                                    if (!csData.getBoolean("active"))
                                    {
                                        fieldValue += " (inactive)";
                                    }
                                }
                                csData.close();
                            }
                        }
                    }
                    string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_modifiedBy", fieldValue, true, "");
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Modified By", FieldHelp, FieldRequired, false, ""));
                }
                //
                // ----- Modified Date
                {
                    string FieldHelp  = "The date and time when this record was last modified.";
                    string fieldValue = "";
                    if (adminData.editRecord == null)
                    {
                        fieldValue = "(not set)";
                    }
                    else if (adminData.editRecord.id == 0)
                    {
                        fieldValue = "(available after save)";
                    }
                    else
                    {
                        if (GenericController.encodeDateMinValue(adminData.editRecord.modifiedDate) == DateTime.MinValue)
                        {
                            fieldValue = "(not set)";
                        }
                        else
                        {
                            fieldValue = adminData.editRecord.modifiedDate.ToString();
                        }
                    }
                    string fieldEditor = AdminUIEditorController.getTextEditor(core, "ignore_modifiedBy", fieldValue, true, "");
                    tabPanel.add(AdminUIController.getEditRow(core, fieldEditor, "Modified Date", FieldHelp, false, false, ""));
                }
                string s = AdminUIController.editTable(tabPanel.text);
                result = AdminUIController.getEditPanel(core, true, "Control Information", "", s);
                adminData.editSectionPanelCount += 1;
                tabPanel = null;
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(result);
        }
コード例 #6
0
        //
        //========================================================================
        //
        public static string get(CoreController core)
        {
            try {
                //
                string   Button        = null;
                string   SQL           = null;
                string   RQS           = null;
                int      PageSize      = 0;
                int      PageNumber    = 0;
                int      TopCount      = 0;
                int      RowPointer    = 0;
                int      DataRowCount  = 0;
                string   PreTableCopy  = "";
                string   PostTableCopy = "";
                int      ColumnPtr     = 0;
                string[] ColCaption    = null;
                string[] ColAlign      = null;
                string[] ColWidth      = null;
                string[,] Cells = null;
                string AdminURL                    = null;
                int    RowCnt                      = 0;
                int    RowPtr                      = 0;
                int    ContentId                   = 0;
                string Format                      = null;
                string Name                        = null;
                string title                       = null;
                string Description                 = null;
                string ButtonCommaListLeft         = null;
                string ButtonCommaListRight        = null;
                int    ContentPadding              = 0;
                string ContentSummary              = "";
                StringBuilderLegacyController Tab0 = new StringBuilderLegacyController();
                StringBuilderLegacyController Tab1 = new StringBuilderLegacyController();
                string Content                     = "";
                string SQLFieldName                = null;
                var    adminMenu                   = new EditTabModel();
                //
                const int ColumnCnt = 4;
                //
                Button    = core.docProperties.getText(RequestNameButton);
                ContentId = core.docProperties.getInteger("ContentID");
                Format    = core.docProperties.getText("Format");
                //
                title                = "Custom Report Manager";
                Description          = "Custom Reports are a way for you to create a snapshot of data to view or download. To request a report, select the Custom Reports tab, check the report(s) you want, and click the [Request Download] Button. When your report is ready, it will be available in the <a href=\"?" + rnAdminForm + "=30\">Download Manager</a>. To create a new custom report, select the Request New Report tab, enter a name and SQL statement, and click the Apply button.";
                ContentPadding       = 0;
                ButtonCommaListLeft  = ButtonCancel + "," + ButtonDelete + "," + ButtonRequestDownload;
                ButtonCommaListRight = "";
                SQLFieldName         = "SQLQuery";
                //
                if (!core.session.isAuthenticatedAdmin())
                {
                    //
                    // Must be a developer
                    //
                    Description = Description + "You can not access the Custom Report Manager because your account is not configured as an administrator.";
                }
                else
                {
                    //
                    // Process Requests
                    //
                    if (!string.IsNullOrEmpty(Button))
                    {
                        switch (Button)
                        {
                        case ButtonCancel:
                            return(core.webServer.redirect("/" + core.appConfig.adminRoute, "CustomReports, Cancel Button Pressed"));

                        case ButtonDelete:
                            RowCnt = core.docProperties.getInteger("RowCnt");
                            if (RowCnt > 0)
                            {
                                for (RowPtr = 0; RowPtr < RowCnt; RowPtr++)
                                {
                                    if (core.docProperties.getBoolean("Row" + RowPtr))
                                    {
                                        MetadataController.deleteContentRecord(core, "Custom Reports", core.docProperties.getInteger("RowID" + RowPtr));
                                    }
                                }
                            }
                            break;

                        case ButtonRequestDownload:
                        case ButtonApply:
                            //
                            Name = core.docProperties.getText("name");
                            SQL  = core.docProperties.getText(SQLFieldName);
                            if (!string.IsNullOrEmpty(Name) || !string.IsNullOrEmpty(SQL))
                            {
                                if ((string.IsNullOrEmpty(Name)) || (string.IsNullOrEmpty(SQL)))
                                {
                                    Processor.Controllers.ErrorController.addUserError(core, "A name and SQL Query are required to save a new custom report.");
                                }
                                else
                                {
                                    int customReportId = 0;
                                    using (var csData = new CsModel(core)) {
                                        csData.insert("Custom Reports");
                                        if (csData.ok())
                                        {
                                            customReportId = csData.getInteger("id");
                                            csData.set("Name", Name);
                                            csData.set(SQLFieldName, SQL);
                                        }
                                        csData.close();
                                    }
                                    requestDownload(core, customReportId);
                                }
                            }
                            //
                            RowCnt = core.docProperties.getInteger("RowCnt");
                            if (RowCnt > 0)
                            {
                                for (RowPtr = 0; RowPtr < RowCnt; RowPtr++)
                                {
                                    if (core.docProperties.getBoolean("Row" + RowPtr))
                                    {
                                        int customReportId = core.docProperties.getInteger("RowID" + RowPtr);
                                        using (var csData = new CsModel(core)) {
                                            csData.openRecord("Custom Reports", customReportId);
                                            if (csData.ok())
                                            {
                                                SQL  = csData.getText(SQLFieldName);
                                                Name = csData.getText("Name");
                                            }
                                        }
                                        requestDownload(core, customReportId);
                                    }
                                }
                            }
                            break;
                        }
                    }
                    //
                    // Build Tab0
                    //
                    Tab0.add("<p>The following is a list of available custom reports.</p>");
                    //
                    RQS      = core.doc.refreshQueryString;
                    PageSize = core.docProperties.getInteger(RequestNamePageSize);
                    if (PageSize == 0)
                    {
                        PageSize = 50;
                    }
                    PageNumber = core.docProperties.getInteger(RequestNamePageNumber);
                    if (PageNumber == 0)
                    {
                        PageNumber = 1;
                    }
                    AdminURL = "/" + core.appConfig.adminRoute;
                    TopCount = PageNumber * PageSize;
                    //
                    // Setup Headings
                    //
                    ColCaption = new string[ColumnCnt + 1];
                    ColAlign   = new string[ColumnCnt + 1];
                    ColWidth   = new string[ColumnCnt + 1];
                    Cells      = new string[PageSize + 1, ColumnCnt + 1];
                    //
                    ColCaption[ColumnPtr] = "Select<br><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=10 height=1>";
                    ColAlign[ColumnPtr]   = "center";
                    ColWidth[ColumnPtr]   = "10";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    ColCaption[ColumnPtr] = "Name";
                    ColAlign[ColumnPtr]   = "left";
                    ColWidth[ColumnPtr]   = "100%";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    ColCaption[ColumnPtr] = "Created By<br><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=100 height=1>";
                    ColAlign[ColumnPtr]   = "left";
                    ColWidth[ColumnPtr]   = "100";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    ColCaption[ColumnPtr] = "Date Created<br><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=150 height=1>";
                    ColAlign[ColumnPtr]   = "left";
                    ColWidth[ColumnPtr]   = "150";
                    ColumnPtr             = ColumnPtr + 1;
                    //
                    //   Get Data
                    //
                    using (var csData = new CsModel(core)) {
                        RowPointer = 0;
                        if (!csData.open("Custom Reports"))
                        {
                            Cells[0, 1] = "There are no custom reports defined";
                            RowPointer  = 1;
                        }
                        else
                        {
                            DataRowCount = csData.getRowCount();
                            while (csData.ok() && (RowPointer < PageSize))
                            {
                                int customReportId = csData.getInteger("ID");
                                Cells[RowPointer, 0] = HtmlController.checkbox("Row" + RowPointer) + HtmlController.inputHidden("RowID" + RowPointer, customReportId);
                                Cells[RowPointer, 1] = csData.getText("name");
                                Cells[RowPointer, 2] = csData.getText("CreatedBy");
                                Cells[RowPointer, 3] = csData.getDate("DateAdded").ToShortDateString();
                                RowPointer           = RowPointer + 1;
                                csData.goNext();
                            }
                        }
                        csData.close();
                    }
                    string Cell = null;
                    Tab0.add(HtmlController.inputHidden("RowCnt", RowPointer));
                    Cell = AdminUIController.getReport(core, RowPointer, ColCaption, ColAlign, ColWidth, Cells, PageSize, PageNumber, PreTableCopy, PostTableCopy, DataRowCount, "ccPanel");
                    Tab0.add("<div>" + Cell + "</div>");
                    //
                    // Build RequestContent Form
                    //
                    Tab1.add("<p>Use this form to create a new custom report. Enter the SQL Query for the report, and a name that will be used as a caption.</p>");
                    //
                    Tab1.add("<table border=\"0\" cellpadding=\"3\" cellspacing=\"0\" width=\"100%\">");
                    //
                    Tab1.add("<tr>");
                    Tab1.add("<td align=right>Name</td>");
                    Tab1.add("<td>" + HtmlController.inputText_Legacy(core, "Name", "", 1, 40) + "</td>");
                    Tab1.add("</tr>");
                    //
                    Tab1.add("<tr>");
                    Tab1.add("<td align=right>SQL Query</td>");
                    Tab1.add("<td>" + HtmlController.inputText_Legacy(core, SQLFieldName, "", 8, 40) + "</td>");
                    Tab1.add("</tr>");
                    //
                    Tab1.add("<tr><td width=\"120\"><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"120\" height=\"1\"></td><td width=\"100%\">&nbsp;</td></tr></table>");
                    //
                    // Build and add tabs
                    //
                    adminMenu.addEntry("Custom&nbsp;Reports", Tab0.text, "ccAdminTab");
                    adminMenu.addEntry("Request&nbsp;New&nbsp;Report", Tab1.text, "ccAdminTab");
                    Content = adminMenu.getTabs(core);
                    //
                }
                //
                core.html.addTitle("Custom Reports");
                //
                return(AdminUIController.getToolBody(core, title, ButtonCommaListLeft, ButtonCommaListRight, true, true, Description, ContentSummary, ContentPadding, Content));
            } catch (Exception ex) {
                LogController.logError(core, ex);
                return(toolExceptionMessage);
            }
        }
コード例 #7
0
        //=============================================================================
        //   Print the manual query form
        //=============================================================================
        //
        public static string get(CoreController core)
        {
            string result = null;

            try {
                //
                int       Count      = 0;
                int       Pointer    = 0;
                int       TableId    = 0;
                string    TableName  = "";
                string    FieldName  = null;
                string    IndexName  = null;
                string    DataSource = "";
                DataTable RSSchema   = null;
                string    Button     = null;
                string[,] Rows = null;
                int    RowMax       = 0;
                int    RowPointer   = 0;
                string Copy         = "";
                bool   TableRowEven = false;
                int    TableColSpan = 0;
                string ButtonList;
                //
                ButtonList = ButtonCancel + "," + ButtonSelect;
                result     = AdminUIController.getHeaderTitleDescription("Modify Database Indexes", "This tool adds and removes database indexes.");
                //
                // Process Input
                //
                Button  = core.docProperties.getText("Button");
                TableId = core.docProperties.getInteger("TableID");
                //
                // Get Tablename and DataSource
                //
                using (var csData = new CsModel(core)) {
                    csData.openRecord("Tables", TableId, "Name,DataSourceID");
                    if (csData.ok())
                    {
                        TableName  = csData.getText("name");
                        DataSource = csData.getText("DataSourceID");
                    }
                }
                using (var db = new DbController(core, DataSource)) {
                    //
                    if ((TableId != 0) && (TableId == core.docProperties.getInteger("previoustableid")) && (!string.IsNullOrEmpty(Button)))
                    {
                        //
                        // Drop Indexes
                        //
                        Count = core.docProperties.getInteger("DropCount");
                        if (Count > 0)
                        {
                            for (Pointer = 0; Pointer < Count; Pointer++)
                            {
                                if (core.docProperties.getBoolean("DropIndex." + Pointer))
                                {
                                    IndexName = core.docProperties.getText("DropIndexName." + Pointer);
                                    result   += "<br>Dropping index [" + IndexName + "] from table [" + TableName + "]";
                                    db.deleteIndex(TableName, IndexName);
                                }
                            }
                        }
                        //
                        // Add Indexes
                        //
                        Count = core.docProperties.getInteger("AddCount");
                        if (Count > 0)
                        {
                            for (Pointer = 0; Pointer < Count; Pointer++)
                            {
                                if (core.docProperties.getBoolean("AddIndex." + Pointer))
                                {
                                    FieldName = core.docProperties.getText("AddIndexFieldName." + Pointer);
                                    IndexName = TableName + FieldName;
                                    result   += "<br>Adding index [" + IndexName + "] to table [" + TableName + "] for field [" + FieldName + "]";
                                    db.createSQLIndex(TableName, IndexName, FieldName);
                                }
                            }
                        }
                    }
                    //
                    TableColSpan = 3;
                    result      += HtmlController.tableStart(2, 0, 0);
                    //
                    // Select Table Form
                    //
                    result += HtmlController.tableRow("<br><br><B>Select table to index</b>", TableColSpan, false);
                    result += HtmlController.tableRow(core.html.selectFromContent("TableID", TableId, "Tables", "", "Select a SQL table to start"), TableColSpan, false);
                    if (TableId != 0)
                    {
                        //
                        // Add/Drop Indexes form
                        //
                        result += HtmlController.inputHidden("PreviousTableID", TableId);
                        //
                        // Drop Indexes
                        //
                        result  += HtmlController.tableRow("<br><br><B>Select indexes to remove</b>", TableColSpan, TableRowEven);
                        RSSchema = db.getIndexSchemaData(TableName);


                        if (RSSchema.Rows.Count == 0)
                        {
                            //
                            // ----- no result
                            //
                            Copy   += core.dateTimeNowMockable + " A schema was returned, but it contains no indexs.";
                            result += HtmlController.tableRow(Copy, TableColSpan, TableRowEven);
                        }
                        else
                        {
                            Rows   = db.convertDataTabletoArray(RSSchema);
                            RowMax = Rows.GetUpperBound(1);
                            for (RowPointer = 0; RowPointer <= RowMax; RowPointer++)
                            {
                                IndexName = GenericController.encodeText(Rows[5, RowPointer]);
                                if (!string.IsNullOrEmpty(IndexName))
                                {
                                    result      += HtmlController.tableRowStart();
                                    Copy         = HtmlController.checkbox("DropIndex." + RowPointer, false) + HtmlController.inputHidden("DropIndexName." + RowPointer, IndexName) + GenericController.encodeText(IndexName);
                                    result      += HtmlController.td(Copy, "", 0, TableRowEven);
                                    result      += HtmlController.td(GenericController.encodeText(Rows[17, RowPointer]), "", 0, TableRowEven);
                                    result      += HtmlController.td("&nbsp;", "", 0, TableRowEven);
                                    result      += kmaEndTableRow;
                                    TableRowEven = !TableRowEven;
                                }
                            }
                            result += HtmlController.inputHidden("DropCount", RowMax + 1);
                        }
                        //
                        // Add Indexes
                        //
                        TableRowEven = false;
                        result      += HtmlController.tableRow("<br><br><B>Select database fields to index</b>", TableColSpan, TableRowEven);
                        RSSchema     = db.getColumnSchemaData(TableName);
                        if (RSSchema.Rows.Count == 0)
                        {
                            //
                            // ----- no result
                            //
                            Copy   += core.dateTimeNowMockable + " A schema was returned, but it contains no indexs.";
                            result += HtmlController.tableRow(Copy, TableColSpan, TableRowEven);
                        }
                        else
                        {
                            Rows = db.convertDataTabletoArray(RSSchema);
                            //
                            RowMax = Rows.GetUpperBound(1);
                            for (RowPointer = 0; RowPointer <= RowMax; RowPointer++)
                            {
                                result      += HtmlController.tableRowStart();
                                Copy         = HtmlController.checkbox("AddIndex." + RowPointer, false) + HtmlController.inputHidden("AddIndexFieldName." + RowPointer, Rows[3, RowPointer]) + GenericController.encodeText(Rows[3, RowPointer]);
                                result      += HtmlController.td(Copy, "", 0, TableRowEven);
                                result      += HtmlController.td("&nbsp;", "", 0, TableRowEven);
                                result      += HtmlController.td("&nbsp;", "", 0, TableRowEven);
                                result      += kmaEndTableRow;
                                TableRowEven = !TableRowEven;
                            }
                            result += HtmlController.inputHidden("AddCount", RowMax + 1);
                        }
                        //
                        // Spacers
                        //
                        result += HtmlController.tableRowStart();
                        result += HtmlController.td(nop2(300, 1), "200");
                        result += HtmlController.td(nop2(200, 1), "200");
                        result += HtmlController.td("&nbsp;", "100%");
                        result += kmaEndTableRow;
                    }
                    result += kmaEndTable;
                    //
                    // Buttons
                    //
                    result = AdminUIController.getToolForm(core, result, ButtonList);
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(result);
        }
コード例 #8
0
        //
        //====================================================================================================
        //
        public static string get(CoreController core)
        {
            string result = "";

            try {
                string Button = core.docProperties.getText("Button");
                if (Button == ButtonCancelAll)
                {
                    //
                    // Cancel to the admin site
                    return(core.webServer.redirect(core.appConfig.adminRoute, "Tools-List, cancel button"));
                }
                //
                const string RequestNameAddField     = "addfield";
                const string RequestNameAddFieldId   = "addfieldID";
                StringBuilderLegacyController Stream = new StringBuilderLegacyController();
                Stream.add(AdminUIController.getHeaderTitleDescription("Configure Admin Listing", "Configure the Administration Content Listing Page."));
                //
                //   Load Request
                int    ToolsAction          = core.docProperties.getInteger("dta");
                int    TargetFieldID        = core.docProperties.getInteger("fi");
                int    ContentId            = core.docProperties.getInteger(RequestNameToolContentId);
                string FieldNameToAdd       = GenericController.toUCase(core.docProperties.getText(RequestNameAddField));
                int    FieldIDToAdd         = core.docProperties.getInteger(RequestNameAddFieldId);
                string ButtonList           = ButtonCancel + "," + ButtonSelect;
                bool   ReloadCDef           = core.docProperties.getBoolean("ReloadCDef");
                bool   AllowContentAutoLoad = false;
                //
                //--------------------------------------------------------------------------------
                // Process actions
                //--------------------------------------------------------------------------------
                //
                if (ContentId != 0)
                {
                    ButtonList = ButtonCancel + "," + ButtonSaveandInvalidateCache;
                    string ContentName = Local_GetContentNameByID(core, ContentId);
                    Processor.Models.Domain.ContentMetadataModel CDef = Processor.Models.Domain.ContentMetadataModel.create(core, ContentId, false, true);
                    string FieldName        = null;
                    int    ColumnWidthTotal = 0;
                    int    fieldId          = 0;
                    if (ToolsAction != 0)
                    {
                        //
                        // Block contentautoload, then force a load at the end
                        //
                        AllowContentAutoLoad = (core.siteProperties.getBoolean("AllowContentAutoLoad", true));
                        core.siteProperties.setProperty("AllowContentAutoLoad", false);
                        int    SourceContentId = 0;
                        string SourceName      = null;
                        //
                        // Make sure the FieldNameToAdd is not-inherited, if not, create new field
                        //
                        if (FieldIDToAdd != 0)
                        {
                            foreach (var keyValuePair in CDef.fields)
                            {
                                Processor.Models.Domain.ContentFieldMetadataModel field = keyValuePair.Value;
                                if (field.id == FieldIDToAdd)
                                {
                                    if (field.inherited)
                                    {
                                        SourceContentId = field.contentId;
                                        SourceName      = field.nameLc;
                                        using (var CSSource = new CsModel(core)) {
                                            CSSource.open("Content Fields", "(ContentID=" + SourceContentId + ")and(Name=" + DbController.encodeSQLText(SourceName) + ")");
                                            if (CSSource.ok())
                                            {
                                                using (var CSTarget = new CsModel(core)) {
                                                    CSTarget.insert("Content Fields");
                                                    if (CSTarget.ok())
                                                    {
                                                        CSSource.copyRecord(CSTarget);
                                                        CSTarget.set("ContentID", ContentId);
                                                        ReloadCDef = true;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                        //
                        // Make sure all fields are not-inherited, if not, create new fields
                        //
                        int ColumnNumberMax = 0;
                        foreach (var keyValuePair in CDef.adminColumns)
                        {
                            Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass adminColumn = keyValuePair.Value;
                            Processor.Models.Domain.ContentFieldMetadataModel field = CDef.fields[adminColumn.Name];
                            if (field.inherited)
                            {
                                SourceContentId = field.contentId;
                                SourceName      = field.nameLc;
                                using (var CSSource = new CsModel(core)) {
                                    if (CSSource.open("Content Fields", "(ContentID=" + SourceContentId + ")and(Name=" + DbController.encodeSQLText(SourceName) + ")"))
                                    {
                                        using (var CSTarget = new CsModel(core)) {
                                            if (CSTarget.insert("Content Fields"))
                                            {
                                                CSSource.copyRecord(CSTarget);
                                                CSTarget.set("ContentID", ContentId);
                                                ReloadCDef = true;
                                            }
                                        }
                                    }
                                }
                            }
                            if (ColumnNumberMax < field.indexColumn)
                            {
                                ColumnNumberMax = field.indexColumn;
                            }
                            ColumnWidthTotal += adminColumn.Width;
                        }
                        //
                        // ----- Perform any actions first
                        //
                        int  columnPtr      = 0;
                        bool MoveNextColumn = false;
                        switch (ToolsAction)
                        {
                        case ToolsActionAddField: {
                            //
                            // Add a field to the Listing Page
                            //
                            if (FieldIDToAdd != 0)
                            {
                                columnPtr = 0;
                                if (CDef.adminColumns.Count > 1)
                                {
                                    foreach (var keyValuePair in CDef.adminColumns)
                                    {
                                        Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass adminColumn = keyValuePair.Value;
                                        Processor.Models.Domain.ContentFieldMetadataModel field = CDef.fields[adminColumn.Name];
                                        using (var csData = new CsModel(core)) {
                                            csData.openRecord("Content Fields", field.id);
                                            csData.set("IndexColumn", (columnPtr) * 10);
                                            csData.set("IndexWidth", Math.Floor((adminColumn.Width * 80) / (double)ColumnWidthTotal));
                                        }
                                        columnPtr += 1;
                                    }
                                }
                                using (var csData = new CsModel(core)) {
                                    if (csData.openRecord("Content Fields", FieldIDToAdd))
                                    {
                                        csData.set("IndexColumn", columnPtr * 10);
                                        csData.set("IndexWidth", 20);
                                        csData.set("IndexSortPriority", 99);
                                        csData.set("IndexSortDirection", 1);
                                    }
                                }
                                ReloadCDef = true;
                            }
                            //
                            break;
                        }

                        case ToolsActionRemoveField: {
                            //
                            // Remove a field to the Listing Page
                            //
                            if (CDef.adminColumns.Count > 1)
                            {
                                columnPtr = 0;
                                foreach (var keyValuePair in CDef.adminColumns)
                                {
                                    Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass adminColumn = keyValuePair.Value;
                                    Processor.Models.Domain.ContentFieldMetadataModel field = CDef.fields[adminColumn.Name];
                                    using (var csData = new CsModel(core)) {
                                        csData.openRecord("Content Fields", field.id);
                                        if (fieldId == TargetFieldID)
                                        {
                                            csData.set("IndexColumn", 0);
                                            csData.set("IndexWidth", 0);
                                            csData.set("IndexSortPriority", 0);
                                            csData.set("IndexSortDirection", 0);
                                        }
                                        else
                                        {
                                            csData.set("IndexColumn", (columnPtr) * 10);
                                            csData.set("IndexWidth", Math.Floor((adminColumn.Width * 100) / (double)ColumnWidthTotal));
                                        }
                                    }
                                    columnPtr += 1;
                                }
                                ReloadCDef = true;
                            }
                            break;
                        }

                        case ToolsActionMoveFieldRight: {
                            //
                            // Move column field right
                            //
                            if (CDef.adminColumns.Count > 1)
                            {
                                MoveNextColumn = false;
                                columnPtr      = 0;
                                foreach (var keyValuePair in CDef.adminColumns)
                                {
                                    Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass adminColumn = keyValuePair.Value;
                                    Processor.Models.Domain.ContentFieldMetadataModel field = CDef.fields[adminColumn.Name];
                                    FieldName = adminColumn.Name;
                                    using (var csData = new CsModel(core)) {
                                        csData.openRecord("Content Fields", field.id);
                                        if ((CDef.fields[FieldName.ToLowerInvariant()].id == TargetFieldID) && (columnPtr < CDef.adminColumns.Count))
                                        {
                                            csData.set("IndexColumn", (columnPtr + 1) * 10);
                                            //
                                            MoveNextColumn = true;
                                        }
                                        else if (MoveNextColumn)
                                        {
                                            //
                                            // This is one past target
                                            //
                                            csData.set("IndexColumn", (columnPtr - 1) * 10);
                                            MoveNextColumn = false;
                                        }
                                        else
                                        {
                                            //
                                            // not target or one past target
                                            //
                                            csData.set("IndexColumn", (columnPtr) * 10);
                                            MoveNextColumn = false;
                                        }
                                        csData.set("IndexWidth", Math.Floor((adminColumn.Width * 100) / (double)ColumnWidthTotal));
                                    }
                                    columnPtr += 1;
                                }
                                ReloadCDef = true;
                            }
                            // end case
                            break;
                        }

                        case ToolsActionMoveFieldLeft: {
                            //
                            // Move Index column field left
                            //
                            if (CDef.adminColumns.Count > 1)
                            {
                                MoveNextColumn = false;
                                columnPtr      = 0;
                                foreach (var keyValuePair in CDef.adminColumns.Reverse())
                                {
                                    Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass adminColumn = keyValuePair.Value;
                                    Processor.Models.Domain.ContentFieldMetadataModel field = CDef.fields[adminColumn.Name];
                                    FieldName = adminColumn.Name;
                                    using (var csData = new CsModel(core)) {
                                        csData.openRecord("Content Fields", field.id);
                                        if ((field.id == TargetFieldID) && (columnPtr < CDef.adminColumns.Count))
                                        {
                                            csData.set("IndexColumn", (columnPtr - 1) * 10);
                                            //
                                            MoveNextColumn = true;
                                        }
                                        else if (MoveNextColumn)
                                        {
                                            //
                                            // This is one past target
                                            //
                                            csData.set("IndexColumn", (columnPtr + 1) * 10);
                                            MoveNextColumn = false;
                                        }
                                        else
                                        {
                                            //
                                            // not target or one past target
                                            //
                                            csData.set("IndexColumn", (columnPtr) * 10);
                                            MoveNextColumn = false;
                                        }
                                        csData.set("IndexWidth", Math.Floor((adminColumn.Width * 100) / (double)ColumnWidthTotal));
                                    }
                                    columnPtr += 1;
                                }
                                ReloadCDef = true;
                            }
                            break;
                        }

                        default: {
                            // do nothing
                            break;
                        }
                        }
                        //
                        // Get a new copy of the content definition
                        //
                        CDef = Processor.Models.Domain.ContentMetadataModel.create(core, ContentId, false, true);
                    }
                    if (Button == ButtonSaveandInvalidateCache)
                    {
                        core.cache.invalidateAll();
                        core.clearMetaData();
                        return(core.webServer.redirect("?af=" + AdminFormToolConfigureListing + "&ContentID=" + ContentId, "Tools-ConfigureListing, Save and Invalidate Cache, Go to back ConfigureListing tools"));
                    }
                    //
                    //--------------------------------------------------------------------------------
                    //   Display the form
                    //--------------------------------------------------------------------------------
                    //
                    if (!string.IsNullOrEmpty(ContentName))
                    {
                        Stream.add("<br><br><B>" + ContentName + "</b><br>");
                    }
                    Stream.add("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"99%\"><tr>");
                    Stream.add("<td width=\"5%\">&nbsp;</td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>10%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>20%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>30%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>40%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>50%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>60%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>70%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>80%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>90%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>100%</nobr></td>");
                    Stream.add("<td width=\"4%\" align=\"center\">&nbsp;</td>");
                    Stream.add("</tr></TABLE>");
                    //
                    Stream.add("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"99%\"><tr>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.gif\" width=\"1\" height=\"10\"><IMG alt=\"\" src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/Images/spacer.gif\" width=\"100%\" height=\"10\"></nobr></td>");
                    Stream.add("</tr></TABLE>");
                    //
                    // print the column headers
                    //
                    ColumnWidthTotal = 0;
                    int InheritedFieldCount = 0;
                    if (CDef.adminColumns.Count > 0)
                    {
                        //
                        // Calc total width
                        //
                        foreach (KeyValuePair <string, Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass> kvp in CDef.adminColumns)
                        {
                            ColumnWidthTotal += kvp.Value.Width;
                        }
                        if (ColumnWidthTotal > 0)
                        {
                            Stream.add("<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"90%\">");
                            int ColumnCount = 0;
                            foreach (KeyValuePair <string, Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass> kvp in CDef.adminColumns)
                            {
                                //
                                // print column headers - anchored so they sort columns
                                //
                                int ColumnWidth = encodeInteger(100 * (kvp.Value.Width / (double)ColumnWidthTotal));
                                FieldName = kvp.Value.Name;
                                var tempVar = CDef.fields[FieldName.ToLowerInvariant()];
                                fieldId = tempVar.id;
                                string Caption = tempVar.caption;
                                if (tempVar.inherited)
                                {
                                    Caption             += "*";
                                    InheritedFieldCount += 1;
                                }
                                string AStart = "<A href=\"" + core.webServer.requestPage + "?" + RequestNameToolContentId + "=" + ContentId + "&af=" + AdminFormToolConfigureListing + "&fi=" + fieldId + "&dtcn=" + ColumnCount;
                                Stream.add("<td width=\"" + ColumnWidth + "%\" valign=\"top\" align=\"left\">" + SpanClassAdminNormal + Caption + "<br>");
                                Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/black.GIF\" width=\"100%\" height=\"1\">");
                                Stream.add(AStart + "&dta=" + ToolsActionRemoveField + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonDeleteUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionMoveFieldRight + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonMoveRightUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionMoveFieldLeft + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonMoveLeftUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionSetAZ + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonSortazUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionSetZA + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonSortzaUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionExpand + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonOpenUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A><br>");
                                Stream.add(AStart + "&dta=" + ToolsActionContract + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonCloseUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A>");
                                Stream.add("</SPAN></td>");
                                ColumnCount += 1;
                            }
                            Stream.add("</tr>");
                            Stream.add("</TABLE>");
                        }
                    }
                    //
                    // ----- If anything was inherited, put up the message
                    //
                    if (InheritedFieldCount > 0)
                    {
                        Stream.add("<P class=\"ccNormal\">* This field was inherited from the Content Definition's Parent. Inherited fields will automatically change when the field in the parent is changed. If you alter these settings, this connection will be broken, and the field will no longer inherit it's properties.</P class=\"ccNormal\">");
                    }
                    //
                    // ----- now output a list of fields to add
                    //
                    if (CDef.fields.Count == 0)
                    {
                        Stream.add(SpanClassAdminNormal + "This Content Definition has no fields</SPAN><br>");
                    }
                    else
                    {
                        Stream.add(SpanClassAdminNormal + "<br>");
                        bool skipField = false;
                        foreach (KeyValuePair <string, Processor.Models.Domain.ContentFieldMetadataModel> keyValuePair in CDef.fields)
                        {
                            Processor.Models.Domain.ContentFieldMetadataModel field = keyValuePair.Value;
                            //
                            // test if this column is in use
                            //
                            skipField = false;
                            if (CDef.adminColumns.Count > 0)
                            {
                                foreach (KeyValuePair <string, Processor.Models.Domain.ContentMetadataModel.MetaAdminColumnClass> kvp in CDef.adminColumns)
                                {
                                    if (field.nameLc == kvp.Value.Name)
                                    {
                                        skipField = true;
                                        break;
                                    }
                                }
                            }
                            //
                            // display the column if it is not in use
                            //
                            if (skipField)
                            {
                                if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileText)
                                {
                                    //
                                    // text filename can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (text file field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileCSS)
                                {
                                    //
                                    // text filename can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (css file field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileXML)
                                {
                                    //
                                    // text filename can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (xml file field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileJavascript)
                                {
                                    //
                                    // text filename can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (javascript file field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.LongText)
                                {
                                    //
                                    // long text can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (long text field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileImage)
                                {
                                    //
                                    // long text can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (image field)<br>");
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Redirect)
                                {
                                    //
                                    // long text can not be search
                                    //
                                    Stream.add("<IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/Spacer.gif\" width=\"50\" height=\"15\" border=\"0\"> " + field.caption + " (redirect field)<br>");
                                }
                                else
                                {
                                    //
                                    // can be used as column header
                                    //
                                    Stream.add("<A href=\"" + core.webServer.requestPage + "?" + RequestNameToolContentId + "=" + ContentId + "&af=" + AdminFormToolConfigureListing + "&fi=" + field.id + "&dta=" + ToolsActionAddField + "&" + RequestNameAddFieldId + "=" + field.id + "\"><IMG src=\"https://s3.amazonaws.com/cdn.contensive.com/assets/20200122/images/LibButtonAddUp.gif\" width=\"50\" height=\"15\" border=\"0\"></A> " + field.caption + "<br>");
                                }
                            }
                        }
                    }
                }
                //
                //--------------------------------------------------------------------------------
                // print the content tables that have Listing Pages to Configure
                //--------------------------------------------------------------------------------
                //
                string FormPanel = SpanClassAdminNormal + "Select a Content Definition to Configure its Listing Page<br>";
                FormPanel += core.html.selectFromContent("ContentID", ContentId, "Content");
                Stream.add(core.html.getPanel(FormPanel));
                core.siteProperties.setProperty("AllowContentAutoLoad", AllowContentAutoLoad);
                Stream.add(HtmlController.inputHidden("ReloadCDef", ReloadCDef));
                result = AdminUIController.getToolForm(core, Stream.text, ButtonList);
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(result);
        }
コード例 #9
0
        //
        //=============================================================================
        //   Print the Configure Index Form
        //=============================================================================
        //
        public static string get(CPClass cp, CoreController core, AdminDataModel adminData)
        {
            string result = "";

            try {
                // todo refactor out
                ContentMetadataModel adminContent = adminData.adminContent;
                string Button = core.docProperties.getText(RequestNameButton);
                if (Button == ButtonOK)
                {
                    //
                    // -- Process OK, remove subform from querystring and return empty
                    cp.Doc.AddRefreshQueryString(RequestNameAdminSubForm, "");
                    return(result);
                }
                //
                //   Load Request
                if (Button == ButtonReset)
                {
                    //
                    // -- Process reset
                    core.userProperty.setProperty(AdminDataModel.IndexConfigPrefix + adminContent.id.ToString(), "");
                }
                IndexConfigClass IndexConfig         = IndexConfigClass.get(core, adminData);
                int          ToolsAction             = core.docProperties.getInteger("dta");
                int          TargetFieldId           = core.docProperties.getInteger("fi");
                string       TargetFieldName         = core.docProperties.getText("FieldName");
                int          ColumnPointer           = core.docProperties.getInteger("dtcn");
                const string RequestNameAddField     = "addfield";
                string       FieldNameToAdd          = GenericController.toUCase(core.docProperties.getText(RequestNameAddField));
                const string RequestNameAddFieldId   = "addfieldID";
                int          FieldIDToAdd            = core.docProperties.getInteger(RequestNameAddFieldId);
                bool         normalizeSaveLoad       = core.docProperties.getBoolean("NeedToReloadConfig");
                bool         AllowContentAutoLoad    = false;
                StringBuilderLegacyController Stream = new StringBuilderLegacyController();
                string Title       = "Set Columns: " + adminContent.name;
                string Description = "Use the icons to add, remove and modify your personal column prefernces for this content (" + adminContent.name + "). Hit OK when complete. Hit Reset to restore your column preferences for this content to the site's default column preferences.";
                Stream.add(AdminUIController.getHeaderTitleDescription(Title, Description));
                //
                //--------------------------------------------------------------------------------
                // Process actions
                //--------------------------------------------------------------------------------
                //
                if (adminContent.id != 0)
                {
                    var CDef             = ContentMetadataModel.create(core, adminContent.id);
                    int ColumnWidthTotal = 0;
                    if (ToolsAction != 0)
                    {
                        //
                        // Block contentautoload, then force a load at the end
                        //
                        AllowContentAutoLoad = (core.siteProperties.getBoolean("AllowContentAutoLoad", true));
                        core.siteProperties.setProperty("AllowContentAutoLoad", false);
                        bool   reloadMetadata  = false;
                        int    SourceContentId = 0;
                        string SourceName      = null;
                        //
                        // Make sure the FieldNameToAdd is not-inherited, if not, create new field
                        //
                        if (FieldIDToAdd != 0)
                        {
                            foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminContent.fields)
                            {
                                ContentFieldMetadataModel field = keyValuePair.Value;
                                if (field.id == FieldIDToAdd)
                                {
                                    if (field.inherited)
                                    {
                                        SourceContentId = field.contentId;
                                        SourceName      = field.nameLc;
                                        //
                                        // -- copy the field
                                        using (var CSSource = new CsModel(core)) {
                                            if (CSSource.open("Content Fields", "(ContentID=" + SourceContentId + ")and(Name=" + DbController.encodeSQLText(SourceName) + ")"))
                                            {
                                                using (var CSTarget = new CsModel(core)) {
                                                    if (CSTarget.insert("Content Fields"))
                                                    {
                                                        CSSource.copyRecord(CSTarget);
                                                        CSTarget.set("ContentID", adminContent.id);
                                                        reloadMetadata = true;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                    break;
                                }
                            }
                        }
                        //
                        // Make sure all fields are not-inherited, if not, create new fields
                        //
                        foreach (var column in IndexConfig.columns)
                        {
                            ContentFieldMetadataModel field = adminContent.fields[column.Name.ToLowerInvariant()];
                            if (field.inherited)
                            {
                                SourceContentId = field.contentId;
                                SourceName      = field.nameLc;
                                using (var CSSource = new CsModel(core)) {
                                    if (CSSource.open("Content Fields", "(ContentID=" + SourceContentId + ")and(Name=" + DbController.encodeSQLText(SourceName) + ")"))
                                    {
                                        using (var CSTarget = new CsModel(core)) {
                                            if (CSTarget.insert("Content Fields"))
                                            {
                                                CSSource.copyRecord(CSTarget);
                                                CSTarget.set("ContentID", adminContent.id);
                                                reloadMetadata = true;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        //
                        // get current values for Processing
                        //
                        foreach (var column in IndexConfig.columns)
                        {
                            ColumnWidthTotal += column.Width;
                        }
                        //
                        // ----- Perform any actions first
                        //
                        switch (ToolsAction)
                        {
                        case ToolsActionAddField: {
                            //
                            // Add a field to the index form
                            //
                            if (FieldIDToAdd != 0)
                            {
                                IndexConfigColumnClass column = null;
                                foreach (var columnx in IndexConfig.columns)
                                {
                                    columnx.Width = encodeInteger((columnx.Width * 80) / (double)ColumnWidthTotal);
                                }
                                {
                                    column = new IndexConfigColumnClass();
                                    using (var csData = new CsModel(core)) {
                                        if (csData.openRecord("Content Fields", FieldIDToAdd))
                                        {
                                            column.Name  = csData.getText("name");
                                            column.Width = 20;
                                        }
                                    }
                                    IndexConfig.columns.Add(column);
                                    normalizeSaveLoad = true;
                                }
                            }
                            //
                            break;
                        }

                        case ToolsActionRemoveField: {
                            //
                            // Remove a field to the index form
                            int columnWidthTotal = 0;
                            var dstColumns       = new List <IndexConfigColumnClass>();
                            foreach (var column in IndexConfig.columns)
                            {
                                if (column.Name != TargetFieldName.ToLowerInvariant())
                                {
                                    dstColumns.Add(column);
                                    columnWidthTotal += column.Width;
                                }
                            }
                            IndexConfig.columns = dstColumns;
                            normalizeSaveLoad   = true;
                            break;
                        }

                        case ToolsActionMoveFieldLeft: {
                            if (IndexConfig.columns.First().Name != TargetFieldName.ToLowerInvariant())
                            {
                                int listIndex = 0;
                                foreach (var column in IndexConfig.columns)
                                {
                                    if (column.Name == TargetFieldName.ToLowerInvariant())
                                    {
                                        break;
                                    }
                                    listIndex += 1;
                                }
                                IndexConfig.columns.swap(listIndex, listIndex - 1);
                                normalizeSaveLoad = true;
                            }
                            break;
                        }

                        case ToolsActionMoveFieldRight: {
                            if (IndexConfig.columns.Last().Name != TargetFieldName.ToLowerInvariant())
                            {
                                int listIndex = 0;
                                foreach (var column in IndexConfig.columns)
                                {
                                    if (column.Name == TargetFieldName.ToLowerInvariant())
                                    {
                                        break;
                                    }
                                    listIndex += 1;
                                }
                                IndexConfig.columns.swap(listIndex, listIndex + 1);
                                normalizeSaveLoad = true;
                            }
                            break;
                        }

                        case ToolsActionExpand: {
                            foreach (var column in IndexConfig.columns)
                            {
                                if (column.Name == TargetFieldName.ToLowerInvariant())
                                {
                                    column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 1.1);
                                }
                                else
                                {
                                    column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 0.9);
                                }
                            }
                            normalizeSaveLoad = true;
                            break;
                        }

                        case ToolsActionContract: {
                            foreach (var column in IndexConfig.columns)
                            {
                                if (column.Name != TargetFieldName.ToLowerInvariant())
                                {
                                    column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 1.1);
                                }
                                else
                                {
                                    column.Width = Convert.ToInt32(Convert.ToDouble(column.Width) * 0.9);
                                }
                            }
                            normalizeSaveLoad = true;
                            break;
                        }
                        }
                        //
                        // Reload CDef if it changed
                        //
                        if (reloadMetadata)
                        {
                            core.clearMetaData();
                            core.cache.invalidateAll();
                            CDef = ContentMetadataModel.createByUniqueName(core, adminContent.name);
                        }
                        //
                        // save indexconfig
                        //
                        if (normalizeSaveLoad)
                        {
                            //
                            // Normalize the widths of the remaining columns
                            ColumnWidthTotal = 0;
                            foreach (var column in IndexConfig.columns)
                            {
                                ColumnWidthTotal += column.Width;
                            }
                            foreach (var column in IndexConfig.columns)
                            {
                                column.Width = encodeInteger((1000 * column.Width) / (double)ColumnWidthTotal);
                            }
                            GetHtmlBodyClass.setIndexSQL_SaveIndexConfig(cp, core, IndexConfig);
                            IndexConfig = IndexConfigClass.get(core, adminData);
                        }
                    }
                    //
                    //--------------------------------------------------------------------------------
                    //   Display the form
                    //--------------------------------------------------------------------------------
                    //
                    Stream.add("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"99%\"><tr>");
                    Stream.add("<td width=\"5%\">&nbsp;</td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>10%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>20%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>30%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>40%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>50%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>60%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>70%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>80%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>90%</nobr></td>");
                    Stream.add("<td width=\"9%\" align=\"center\" class=\"ccAdminSmall\"><nobr>100%</nobr></td>");
                    Stream.add("<td width=\"4%\" align=\"center\">&nbsp;</td>");
                    Stream.add("</tr></table>");
                    //
                    Stream.add("<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"99%\"><tr>");
                    Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>");
                    Stream.add("<td width=\"9%\"><nobr><img src=\"" + cdnPrefix + "images/black.gif\" width=\"1\" height=\"10\" ><img alt=\"space\" src=\"" + cdnPrefix + "images/spacer.gif\" width=\"100%\" height=\"10\" ></nobr></td>");
                    Stream.add("</tr></table>");
                    //
                    // print the column headers
                    //
                    ColumnWidthTotal = 0;
                    int InheritedFieldCount = 0;
                    if (IndexConfig.columns.Count > 0)
                    {
                        //
                        // Calc total width
                        //
                        foreach (var column in IndexConfig.columns)
                        {
                            ColumnWidthTotal += column.Width;
                        }
                        if (ColumnWidthTotal > 0)
                        {
                            Stream.add("<table border=\"0\" cellpadding=\"5\" cellspacing=\"0\" width=\"90%\">");
                            //
                            // -- header
                            Stream.add("<tr>");
                            int    ColumnWidth = 0;
                            int    fieldId     = 0;
                            string Caption     = null;
                            foreach (var column in IndexConfig.columns)
                            {
                                //
                                // print column headers - anchored so they sort columns
                                //
                                ColumnWidth = encodeInteger(100 * (column.Width / (double)ColumnWidthTotal));
                                ContentFieldMetadataModel field = adminContent.fields[column.Name.ToLowerInvariant()];
                                fieldId = field.id;
                                Caption = field.caption;
                                if (field.inherited)
                                {
                                    Caption             = Caption + "*";
                                    InheritedFieldCount = InheritedFieldCount + 1;
                                }
                                Stream.add("<td class=\"small\" width=\"" + ColumnWidth + "%\" valign=\"top\" align=\"left\" style=\"background-color:white;border: 1px solid #555;\">" + Caption + "</td>");
                            }
                            Stream.add("</tr>");
                            //
                            // -- body
                            Stream.add("<tr>");
                            foreach (var column in IndexConfig.columns)
                            {
                                //
                                // print column headers - anchored so they sort columns
                                //
                                ColumnWidth = encodeInteger(100 * (column.Width / (double)ColumnWidthTotal));
                                ContentFieldMetadataModel field = adminContent.fields[column.Name.ToLowerInvariant()];
                                fieldId = field.id;
                                Caption = field.caption;
                                if (field.inherited)
                                {
                                    Caption             = Caption + "*";
                                    InheritedFieldCount = InheritedFieldCount + 1;
                                }
                                int    ColumnPtr = 0;
                                string link      = "?" + core.doc.refreshQueryString + "&FieldName=" + HtmlController.encodeHtml(field.nameLc) + "&fi=" + fieldId + "&dtcn=" + ColumnPtr + "&" + RequestNameAdminSubForm + "=" + AdminFormIndex_SubFormSetColumns;
                                Stream.add("<td width=\"" + ColumnWidth + "%\" valign=\"top\" align=\"left\">");
                                Stream.add(HtmlController.div(AdminUIController.getDeleteLink(link + "&dta=" + ToolsActionRemoveField), "text-center"));
                                Stream.add(HtmlController.div(AdminUIController.getArrowRightLink(link + "&dta=" + ToolsActionMoveFieldRight), "text-center"));
                                Stream.add(HtmlController.div(AdminUIController.getArrowLeftLink(link + "&dta=" + ToolsActionMoveFieldLeft), "text-center"));
                                Stream.add(HtmlController.div(AdminUIController.getExpandLink(link + "&dta=" + ToolsActionExpand), "text-center"));
                                Stream.add(HtmlController.div(AdminUIController.getContractLink(link + "&dta=" + ToolsActionContract), "text-center"));
                                Stream.add("</td>");
                            }
                            Stream.add("</tr>");
                            Stream.add("</table>");
                        }
                    }
                    //
                    // ----- If anything was inherited, put up the message
                    //
                    if (InheritedFieldCount > 0)
                    {
                        Stream.add("<p class=\"ccNormal\">* This field was inherited from the Content Definition's Parent. Inherited fields will automatically change when the field in the parent is changed. If you alter these settings, this connection will be broken, and the field will no longer inherit it's properties.</P class=\"ccNormal\">");
                    }
                    //
                    // ----- now output a list of fields to add
                    //
                    if (CDef.fields.Count == 0)
                    {
                        Stream.add(SpanClassAdminNormal + "This Content Definition has no fields</span><br>");
                    }
                    else
                    {
                        foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminContent.fields)
                        {
                            ContentFieldMetadataModel field = keyValuePair.Value;
                            //
                            // display the column if it is not in use
                            if ((IndexConfig.columns.Find(x => x.Name == field.nameLc) == null))
                            {
                                if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.File)
                                {
                                    //
                                    // file can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileText)
                                {
                                    //
                                    // filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (text file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileHTML)
                                {
                                    //
                                    // filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (html file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode)
                                {
                                    //
                                    // filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (html code file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileCSS)
                                {
                                    //
                                    // css filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (css file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileXML)
                                {
                                    //
                                    // xml filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (xml file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileJavascript)
                                {
                                    //
                                    // javascript filename can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (javascript file field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.LongText)
                                {
                                    //
                                    // can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (long text field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.HTML)
                                {
                                    //
                                    // can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (html field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileImage)
                                {
                                    //
                                    // can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (image field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Redirect)
                                {
                                    //
                                    // can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (redirect field)"));
                                }
                                else if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.ManyToMany)
                                {
                                    //
                                    // many to many can not be search
                                    Stream.add(HtmlController.div(iconNotAvailable + "&nbsp;" + field.caption + " (many-to-many field)"));
                                }
                                else
                                {
                                    //
                                    // can be used as column header
                                    string link = "?" + core.doc.refreshQueryString + "&fi=" + field.id + "&dta=" + ToolsActionAddField + "&" + RequestNameAddFieldId + "=" + field.id + "&" + RequestNameAdminSubForm + "=" + AdminFormIndex_SubFormSetColumns;
                                    Stream.add(HtmlController.div(AdminUIController.getPlusLink(link, "&nbsp;" + field.caption)));
                                }
                            }
                        }
                    }
                }
                //
                //--------------------------------------------------------------------------------
                // print the content tables that have index forms to Configure
                //--------------------------------------------------------------------------------
                //
                core.siteProperties.setProperty("AllowContentAutoLoad", GenericController.encodeText(AllowContentAutoLoad));
                string Content = ""
                                 + Stream.text
                                 + HtmlController.inputHidden("cid", adminContent.id.ToString())
                                 + HtmlController.inputHidden(rnAdminForm, "1")
                                 + HtmlController.inputHidden(RequestNameAdminSubForm, AdminFormIndex_SubFormSetColumns)
                                 + "";
                //
                // -- assemble form
                result = AdminUIController.getToolForm(core, Content, ButtonOK + "," + ButtonReset);
                core.html.addTitle(Title);
            } catch (Exception ex) {
                LogController.logError(core, ex);
            }
            return(result);
        }