示例#1
0
        //
        //====================================================================================================
        //
        public override int AddContentField(string contentName, string fieldName, CPContentBaseClass.FieldTypeIdEnum fieldType)
        {
            var contentMetadata = ContentMetadataModel.createByUniqueName(cp.core, contentName);
            var fieldMeta       = ContentFieldMetadataModel.createDefault(cp.core, fieldName, fieldType);

            contentMetadata.verifyContentField(cp.core, fieldMeta, false, "Api CPContent.AddContentField [" + contentName + "." + fieldName + "]");
            return(fieldMeta.id);
        }
示例#2
0
        //=============================================================================
        /// <summary>
        /// Go through all Content Definitions and create appropriate tables and fields.
        /// </summary>
        /// <returns></returns>
        public static string get(CoreController core)
        {
            string returnValue = "";

            try {
                Processor.Models.Domain.ContentMetadataModel metadata = null;
                StringBuilderLegacyController Stream = new StringBuilderLegacyController();
                string[,] ContentNameArray = null;
                int    ContentNameCount = 0;
                string TableName        = null;
                string ButtonList;
                //
                ButtonList = ButtonCancel + "," + ButtonRun;
                //
                Stream.add(AdminUIController.getHeaderTitleDescription("Synchronize Tables to Content Definitions", "This tools goes through all Content Definitions and creates any necessary Tables and Table Fields to support the Definition."));
                //
                if (core.docProperties.getText("Button") != "")
                {
                    //
                    //   Run Tools
                    //
                    Stream.add("Synchronizing Tables to Content Definitions<br>");
                    using (var csData = new CsModel(core)) {
                        csData.open("Content", "", "", false, 0, "id");
                        if (csData.ok())
                        {
                            do
                            {
                                metadata  = Processor.Models.Domain.ContentMetadataModel.create(core, csData.getInteger("id"));
                                TableName = metadata.tableName;
                                Stream.add("Synchronizing Content " + metadata.name + " to table " + TableName + "<br>");
                                using (var db = new DbController(core, metadata.dataSourceName)) {
                                    db.createSQLTable(TableName);
                                    if (metadata.fields.Count > 0)
                                    {
                                        foreach (var keyValuePair in metadata.fields)
                                        {
                                            ContentFieldMetadataModel field = keyValuePair.Value;
                                            Stream.add("...Field " + field.nameLc + "<br>");
                                            db.createSQLTableField(TableName, field.nameLc, field.fieldTypeId);
                                        }
                                    }
                                }
                                csData.goNext();
                            } while (csData.ok());
                            ContentNameArray = csData.getRows();
                            ContentNameCount = ContentNameArray.GetUpperBound(1) + 1;
                        }
                    }
                }
                returnValue = AdminUIController.getToolForm(core, Stream.text, ButtonList);
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(returnValue);
        }
示例#3
0
        //
        // ====================================================================================================
        /// <summary>
        /// Generate the content of a tab in the Edit Screen
        /// </summary>
        /// <param name="core"></param>
        /// <param name="adminData"></param>
        /// <param name="RecordID"></param>
        /// <param name="ContentID"></param>
        /// <param name="record_readOnly"></param>
        /// <param name="IsLandingPage"></param>
        /// <param name="IsRootPage"></param>
        /// <param name="EditTab"></param>
        /// <param name="EditorContext"></param>
        /// <param name="return_NewFieldList"></param>
        /// <param name="HelpCnt"></param>
        /// <param name="HelpIDCache"></param>
        /// <param name="helpDefaultCache"></param>
        /// <param name="HelpCustomCache"></param>
        /// <param name="AllowHelpMsgCustom"></param>
        /// <param name="helpIdIndex"></param>
        /// <returns></returns>
        public static string getTab(CoreController core, AdminDataModel adminData, EditorEnvironmentModel editorEnv, int RecordID, int ContentID, string EditTab)
        {
            string returnHtml = "";

            try {
                //
                // ----- Open the panel
                if (adminData.adminContent.fields.Count <= 0)
                {
                    //
                    // There are no visible fiels, return empty
                    LogController.logError(core, new GenericException("There is no metadata for this field."));
                }
                else
                {
                    //
                    // ----- Build an index to sort the fields by EditSortOrder
                    Dictionary <string, ContentFieldMetadataModel> sortingFields = new Dictionary <string, ContentFieldMetadataModel>();
                    foreach (var keyValuePair in adminData.adminContent.fields)
                    {
                        ContentFieldMetadataModel field = keyValuePair.Value;
                        if (field.editTabName.ToLowerInvariant() == EditTab.ToLowerInvariant())
                        {
                            if (AdminDataModel.isVisibleUserField(core, field.adminOnly, field.developerOnly, field.active, field.authorable, field.nameLc, adminData.adminContent.tableName))
                            {
                                string AlphaSort = GenericController.getIntegerString(field.editSortPriority, 10) + "-" + GenericController.getIntegerString(field.id, 10);
                                sortingFields.Add(AlphaSort, field);
                            }
                        }
                    }
                    //
                    // ----- display the record fields
                    bool AllowHelpIcon = core.visitProperty.getBoolean("AllowHelpIcon");
                    StringBuilderLegacyController resultBody = new StringBuilderLegacyController();
                    bool needUniqueEmailMessage = false;
                    foreach (var kvp in sortingFields)
                    {
                        ContentFieldMetadataModel field = kvp.Value;
                        string editorRow = EditorRowClass.getEditorRow(core, field, adminData, editorEnv);
                        resultBody.add("<tr><td colspan=2>" + editorRow + "</td></tr>");
                    }
                    //
                    // ----- add the *Required Fields footer
                    resultBody.add("<tr><td colspan=2 style=\"padding-top:10px;font-size:70%\"><div>* Field is required.</div><div>** Field must be unique.</div>");
                    if (needUniqueEmailMessage)
                    {
                        resultBody.add("<div>*** Field must be unique because this site allows login by email.</div>");
                    }
                    resultBody.add("</td></tr>");
                    //
                    // ----- close the panel
                    returnHtml = AdminUIController.getEditPanel(core, false, "", "", AdminUIController.editTable(resultBody.text));
                    adminData.editSectionPanelCount += 1;
                    resultBody = null;
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(returnHtml);
        }
示例#4
0
 //
 // ====================================================================================================
 /// <summary>
 /// Create all the tabs for the edit form
 /// </summary>
 /// <param name="core"></param>
 /// <param name="adminData"></param>
 /// <param name="readOnlyField"></param>
 /// <param name="IsLandingPage"></param>
 /// <param name="IsRootPage"></param>
 /// <param name="EditorContext"></param>
 /// <param name="TemplateIDForStyles"></param>
 /// <param name="fieldEditorList"></param>
 /// <param name="styleList"></param>
 /// <param name="styleOptionList"></param>
 /// <param name="emailIdForStyles"></param>
 /// <param name="IsTemplateTable"></param>
 /// <param name="editorAddonListJSON"></param>
 /// <returns></returns>
 public static void addContentTabs(CoreController core, AdminDataModel adminData, EditTabModel editTabs, EditorEnvironmentModel editorEnv)
 {
     try {
         // todo
         string IDList = "";
         foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminData.adminContent.fields)
         {
             ContentFieldMetadataModel field = keyValuePair.Value;
             IDList = IDList + "," + field.id;
         }
         if (!string.IsNullOrEmpty(IDList))
         {
             IDList = IDList.Substring(1);
         }
         //
         DataTable dt = core.db.executeQuery("select fieldid,helpdefault,helpcustom from ccfieldhelp where fieldid in (" + IDList + ") order by fieldid,id");
         string[,] fieldHelpArray = core.db.convertDataTabletoArray(dt);
         int              HelpCnt          = 0;
         int[]            HelpIDCache      = { };
         string[]         helpDefaultCache = { };
         string[]         HelpCustomCache  = { };
         KeyPtrController helpIdIndex      = new KeyPtrController();
         if (fieldHelpArray.GetLength(0) > 0)
         {
             HelpCnt          = fieldHelpArray.GetUpperBound(1) + 1;
             HelpIDCache      = new int[HelpCnt + 1];
             helpDefaultCache = new string[HelpCnt + 1];
             HelpCustomCache  = new string[HelpCnt + 1];
             int fieldId = -1;
             int HelpPtr = 0;
             for (HelpPtr = 0; HelpPtr < HelpCnt; HelpPtr++)
             {
                 fieldId = GenericController.encodeInteger(fieldHelpArray[0, HelpPtr]);
                 int LastFieldId = 0;
                 if (fieldId != LastFieldId)
                 {
                     LastFieldId          = fieldId;
                     HelpIDCache[HelpPtr] = fieldId;
                     helpIdIndex.setPtr(fieldId.ToString(), HelpPtr);
                     helpDefaultCache[HelpPtr] = GenericController.encodeText(fieldHelpArray[1, HelpPtr]);
                     HelpCustomCache[HelpPtr]  = GenericController.encodeText(fieldHelpArray[2, HelpPtr]);
                 }
             }
             editorEnv.allowHelpMsgCustom = true;
         }
         //
         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) && (!TabsFound.Contains(field.editTabName.ToLowerInvariant())))
             {
                 TabsFound.Add(field.editTabName.ToLowerInvariant());
                 string editTabCaption = field.editTabName;
                 if (string.IsNullOrEmpty(editTabCaption))
                 {
                     editTabCaption = "Details";
                 }
                 string tabContent = getTab(core, adminData, editorEnv, adminData.editRecord.id, adminData.adminContent.id, field.editTabName);
                 if (!string.IsNullOrEmpty(tabContent))
                 {
                     addCustomTab(core, editTabs, editTabCaption, tabContent);
                 }
             }
         }
     } catch (Exception ex) {
         LogController.logError(core, ex);
         throw;
     }
 }
        //
        //=================================================================================
        //
        //=================================================================================
        //
        public static string get(CPClass cp, CoreController core, AdminDataModel adminData)
        {
            string returnForm = "";

            try {
                //
                string            SearchValue = null;
                FindWordMatchEnum MatchOption = 0;
                int FormFieldPtr                     = 0;
                int FormFieldCnt                     = 0;
                ContentMetadataModel CDef            = null;
                string FieldName                     = null;
                StringBuilderLegacyController Stream = new StringBuilderLegacyController();
                int      FieldPtr                    = 0;
                bool     RowEven                     = false;
                string   RQS          = null;
                string[] FieldNames   = { };
                string[] FieldCaption = { };
                int[]    fieldId      = null;
                CPContentBaseClass.FieldTypeIdEnum[] fieldTypeId = { };
                string[] FieldValue             = { };
                int[]    FieldMatchOptions      = { };
                int      FieldMatchOption       = 0;
                string[] FieldLookupContentName = { };
                string[] FieldLookupList        = { };
                int      ContentId   = 0;
                int      FieldCnt    = 0;
                int      FieldSize   = 0;
                int      RowPointer  = 0;
                string   LeftButtons = "";
                string   ButtonBar   = null;
                string   Title       = null;
                string   TitleBar    = null;
                string   Content     = null;

                //
                // Process last form
                //
                string           Button      = core.docProperties.getText("button");
                IndexConfigClass IndexConfig = null;
                if (!string.IsNullOrEmpty(Button))
                {
                    switch (Button)
                    {
                    case ButtonSearch:
                        IndexConfig  = IndexConfigClass.get(core, adminData);
                        FormFieldCnt = core.docProperties.getInteger("fieldcnt");
                        if (FormFieldCnt > 0)
                        {
                            for (FormFieldPtr = 0; FormFieldPtr < FormFieldCnt; FormFieldPtr++)
                            {
                                FieldName   = GenericController.toLCase(core.docProperties.getText("fieldname" + FormFieldPtr));
                                MatchOption = (FindWordMatchEnum)core.docProperties.getInteger("FieldMatch" + FormFieldPtr);
                                switch (MatchOption)
                                {
                                case FindWordMatchEnum.MatchEquals:
                                case FindWordMatchEnum.MatchGreaterThan:
                                case FindWordMatchEnum.matchincludes:
                                case FindWordMatchEnum.MatchLessThan:
                                    SearchValue = core.docProperties.getText("FieldValue" + FormFieldPtr);
                                    break;

                                default:
                                    SearchValue = "";
                                    break;
                                }
                                if (!IndexConfig.findWords.ContainsKey(FieldName))
                                {
                                    //
                                    // fieldname not found, save if not FindWordMatchEnum.MatchIgnore
                                    //
                                    if (MatchOption != FindWordMatchEnum.MatchIgnore)
                                    {
                                        IndexConfig.findWords.Add(FieldName, new IndexConfigFindWordClass {
                                            Name        = FieldName,
                                            MatchOption = MatchOption,
                                            Value       = SearchValue
                                        });
                                    }
                                }
                                else
                                {
                                    //
                                    // fieldname was found
                                    //
                                    IndexConfig.findWords[FieldName].MatchOption = MatchOption;
                                    IndexConfig.findWords[FieldName].Value       = SearchValue;
                                }
                            }
                        }
                        GetHtmlBodyClass.setIndexSQL_SaveIndexConfig(cp, core, IndexConfig);
                        return(string.Empty);

                    case ButtonCancel:
                        return(string.Empty);
                    }
                }
                IndexConfig = IndexConfigClass.get(core, adminData);
                Button      = "CriteriaSelect";
                RQS         = core.doc.refreshQueryString;
                //
                // ----- ButtonBar
                //
                if (adminData.ignore_legacyMenuDepth > 0)
                {
                    LeftButtons += AdminUIController.getButtonPrimary(ButtonClose, "window.close();");
                }
                else
                {
                    LeftButtons += AdminUIController.getButtonPrimary(ButtonCancel);
                }
                LeftButtons += AdminUIController.getButtonPrimary(ButtonSearch);
                ButtonBar    = AdminUIController.getSectionButtonBar(core, LeftButtons, "");
                //
                // ----- TitleBar
                //
                Title = adminData.adminContent.name;
                Title = Title + " Advanced Search";
                string TitleDescription = "<div>Enter criteria for each field to identify and select your results. The results of a search will have to have all of the criteria you enter.</div>";
                TitleBar = AdminUIController.getSectionHeader(core, Title, TitleDescription);
                //
                // ----- List out all fields
                //
                CDef      = ContentMetadataModel.createByUniqueName(core, adminData.adminContent.name);
                FieldSize = 100;
                Array.Resize(ref FieldNames, FieldSize + 1);
                Array.Resize(ref FieldCaption, FieldSize + 1);
                Array.Resize(ref fieldId, FieldSize + 1);
                Array.Resize(ref fieldTypeId, FieldSize + 1);
                Array.Resize(ref FieldValue, FieldSize + 1);
                Array.Resize(ref FieldMatchOptions, FieldSize + 1);
                Array.Resize(ref FieldLookupContentName, FieldSize + 1);
                Array.Resize(ref FieldLookupList, FieldSize + 1);
                foreach (KeyValuePair <string, ContentFieldMetadataModel> keyValuePair in adminData.adminContent.fields)
                {
                    ContentFieldMetadataModel field = keyValuePair.Value;
                    if (FieldPtr >= FieldSize)
                    {
                        FieldSize = FieldSize + 100;
                        Array.Resize(ref FieldNames, FieldSize + 1);
                        Array.Resize(ref FieldCaption, FieldSize + 1);
                        Array.Resize(ref fieldId, FieldSize + 1);
                        Array.Resize(ref fieldTypeId, FieldSize + 1);
                        Array.Resize(ref FieldValue, FieldSize + 1);
                        Array.Resize(ref FieldMatchOptions, FieldSize + 1);
                        Array.Resize(ref FieldLookupContentName, FieldSize + 1);
                        Array.Resize(ref FieldLookupList, FieldSize + 1);
                    }
                    FieldName              = GenericController.toLCase(field.nameLc);
                    FieldNames[FieldPtr]   = FieldName;
                    FieldCaption[FieldPtr] = field.caption;
                    fieldId[FieldPtr]      = field.id;
                    fieldTypeId[FieldPtr]  = field.fieldTypeId;
                    if (fieldTypeId[FieldPtr] == CPContentBaseClass.FieldTypeIdEnum.Lookup)
                    {
                        ContentId = field.lookupContentId;
                        if (ContentId > 0)
                        {
                            FieldLookupContentName[FieldPtr] = MetadataController.getContentNameByID(core, ContentId);
                        }
                        FieldLookupList[FieldPtr] = field.lookupList;
                    }
                    //
                    // set prepoplate value from indexconfig
                    //
                    if (IndexConfig.findWords.ContainsKey(FieldName))
                    {
                        FieldValue[FieldPtr]        = IndexConfig.findWords[FieldName].Value;
                        FieldMatchOptions[FieldPtr] = (int)IndexConfig.findWords[FieldName].MatchOption;
                    }
                    FieldPtr += 1;
                }
                FieldCnt = FieldPtr;
                //
                // Add headers to stream
                //
                returnForm = returnForm + "<table border=0 width=100% cellspacing=0 cellpadding=4>";
                //
                RowPointer = 0;
                for (FieldPtr = 0; FieldPtr < FieldCnt; FieldPtr++)
                {
                    returnForm       = returnForm + HtmlController.inputHidden("fieldname" + FieldPtr, FieldNames[FieldPtr]);
                    RowEven          = ((RowPointer % 2) == 0);
                    FieldMatchOption = FieldMatchOptions[FieldPtr];
                    switch (fieldTypeId[FieldPtr])
                    {
                    case CPContentBaseClass.FieldTypeIdEnum.Date:
                        //
                        // Date

                        returnForm = returnForm + "<tr>"
                                     + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>"
                                     + "<td class=\"ccAdminEditField\">"
                                     + "<div style=\"display:block;float:left;width:800px;\">"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not&nbsp;empty</div>"
                                     + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchEquals).ToString(), FieldMatchOption.ToString(), "") + "=</div>"
                                     + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchGreaterThan).ToString(), FieldMatchOption.ToString(), "") + "&gt;</div>"
                                     + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, encodeInteger(FindWordMatchEnum.MatchLessThan).ToString(), FieldMatchOption.ToString(), "") + "&lt;</div>"
                                     + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputDate(core, "fieldvalue" + FieldPtr, encodeDate(FieldValue[FieldPtr])).Replace(">", " onFocus=\"ccAdvSearchText\">") + "</div>"
                                     + "</div>"
                                     + "</td>"
                                     + "</tr>";
                        break;

                    case CPContentBaseClass.FieldTypeIdEnum.Currency:
                    case CPContentBaseClass.FieldTypeIdEnum.Float:
                    case CPContentBaseClass.FieldTypeIdEnum.Integer:
                    case CPContentBaseClass.FieldTypeIdEnum.AutoIdIncrement:
                        //
                        // -- Numeric - changed FindWordMatchEnum.MatchEquals to MatchInclude to be compatible with Find Search
                        returnForm = returnForm + "<tr>"
                                     + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>"
                                     + "<td class=\"ccAdminEditField\">"
                                     + "<div style=\"display:block;float:left;width:800px;\">"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not&nbsp;empty</div>"
                                     + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.matchincludes).ToString(), FieldMatchOption.ToString(), "n" + FieldPtr) + "=</div>"
                                     + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchGreaterThan).ToString(), FieldMatchOption.ToString(), "") + "&gt;</div>"
                                     + "<div style=\"display:block;float:left;width:50px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchLessThan).ToString(), FieldMatchOption.ToString(), "") + "&lt;</div>"
                                     + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputText_Legacy(core, "fieldvalue" + FieldPtr, FieldValue[FieldPtr], 1, 5, "", false, false, "ccAdvSearchText").Replace(">", " onFocus=\"var e=getElementById('n" + FieldPtr + "');e.checked=1;\">") + "</div>"
                                     + "</div>"
                                     + "</td>"
                                     + "</tr>";
                        RowPointer += 1;
                        break;

                    case CPContentBaseClass.FieldTypeIdEnum.File:
                    case CPContentBaseClass.FieldTypeIdEnum.FileImage:
                        //
                        // File
                        //
                        returnForm = returnForm + "<tr>"
                                     + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>"
                                     + "<td class=\"ccAdminEditField\">"
                                     + "<div style=\"display:block;float:left;width:800px;\">"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not&nbsp;empty</div>"
                                     + "</div>"
                                     + "</td>"
                                     + "</tr>";
                        RowPointer = RowPointer + 1;
                        break;

                    case CPContentBaseClass.FieldTypeIdEnum.Boolean:
                        //
                        // Boolean
                        //
                        returnForm = returnForm + "<tr>"
                                     + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>"
                                     + "<td class=\"ccAdminEditField\">"
                                     + "<div style=\"display:block;float:left;width:800px;\">"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchTrue).ToString(), FieldMatchOption.ToString(), "") + "true</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchFalse).ToString(), FieldMatchOption.ToString(), "") + "false</div>"
                                     + "</div>"
                                     + "</td>"
                                     + "</tr>";
                        break;

                    case CPContentBaseClass.FieldTypeIdEnum.Text:
                    case CPContentBaseClass.FieldTypeIdEnum.LongText:
                    case CPContentBaseClass.FieldTypeIdEnum.HTML:
                    case CPContentBaseClass.FieldTypeIdEnum.HTMLCode:
                    case CPContentBaseClass.FieldTypeIdEnum.FileHTML:
                    case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode:
                    case CPContentBaseClass.FieldTypeIdEnum.FileCSS:
                    case CPContentBaseClass.FieldTypeIdEnum.FileJavascript:
                    case CPContentBaseClass.FieldTypeIdEnum.FileXML:
                        //
                        // Text
                        //
                        returnForm = returnForm + "<tr>"
                                     + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>"
                                     + "<td class=\"ccAdminEditField\">"
                                     + "<div style=\"display:block;float:left;width:800px;\">"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not&nbsp;empty</div>"
                                     + "<div style=\"display:block;float:left;width:150px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.matchincludes).ToString(), FieldMatchOption.ToString(), "t" + FieldPtr) + "includes</div>"
                                     + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputText_Legacy(core, "fieldvalue" + FieldPtr, FieldValue[FieldPtr], 1, 5, "", false, false, "ccAdvSearchText").Replace(">", " onFocus=\"var e=getElementById('t" + FieldPtr + "');e.checked=1;\">") + "</div>"
                                     + "</div>"
                                     + "</td>"
                                     + "</tr>";
                        RowPointer = RowPointer + 1;
                        break;

                    case CPContentBaseClass.FieldTypeIdEnum.Lookup:
                    case CPContentBaseClass.FieldTypeIdEnum.MemberSelect:
                        //
                        // Lookup
                        returnForm = returnForm + "<tr>"
                                     + "<td class=\"ccAdminEditCaption\">" + FieldCaption[FieldPtr] + "</td>"
                                     + "<td class=\"ccAdminEditField\">"
                                     + "<div style=\"display:block;float:left;width:800px;\">"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchIgnore).ToString(), FieldMatchOption.ToString(), "") + "ignore</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchEmpty).ToString(), FieldMatchOption.ToString(), "") + "empty</div>"
                                     + "<div style=\"display:block;float:left;width:100px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.MatchNotEmpty).ToString(), FieldMatchOption.ToString(), "") + "not&nbsp;empty</div>"
                                     + "<div style=\"display:block;float:left;width:150px;\">" + HtmlController.inputRadio("FieldMatch" + FieldPtr, ((int)FindWordMatchEnum.matchincludes).ToString(), FieldMatchOption.ToString(), "t" + FieldPtr) + "includes</div>"
                                     + "<div style=\"display:block;float:left;width:300px;\">" + HtmlController.inputText_Legacy(core, "fieldvalue" + FieldPtr, FieldValue[FieldPtr], 1, 5, "", false, false, "ccAdvSearchText").Replace(">", " onFocus=\"var e=getElementById('t" + FieldPtr + "'); e.checked= 1;\">") + "</div>"
                                     + "</div>"
                                     + "</td>"
                                     + "</tr>";
                        RowPointer = RowPointer + 1;
                        break;
                    }
                }
                returnForm = returnForm + HtmlController.tableRowStart();
                returnForm = returnForm + HtmlController.tableCellStart("120", 1, RowEven, "right") + "<img src=" + cdnPrefix + "images/spacer.gif width=120 height=1></td>";
                returnForm = returnForm + HtmlController.tableCellStart("99%", 1, RowEven, "left") + "<img src=" + cdnPrefix + "images/spacer.gif width=1 height=1></td>";
                returnForm = returnForm + kmaEndTableRow;
                returnForm = returnForm + "</table>";
                Content    = returnForm;
                //
                // Assemble LiveWindowTable
                Stream.add(ButtonBar);
                Stream.add(TitleBar);
                Stream.add(Content);
                Stream.add(ButtonBar);
                Stream.add("<input type=hidden name=fieldcnt VALUE=" + FieldCnt + ">");
                Stream.add("<input type=hidden name=" + RequestNameAdminSubForm + " VALUE=" + AdminFormIndex_SubFormAdvancedSearch + ">");
                returnForm = HtmlController.form(core, Stream.text);
                core.html.addTitle(adminData.adminContent.name + " Advanced Search");
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(returnForm);
        }
        //
        //========================================================================
        /// <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);
        }
示例#7
0
        public static string getEditorRow(CoreController core, ContentFieldMetadataModel field, AdminDataModel adminData, EditorEnvironmentModel editorEnv)
        {
            string whyReadOnlyMsg = "";

            Models.EditRecordModel editRecord = adminData.editRecord;
            object fieldValueObject           = editRecord.fieldsLc[field.nameLc].value;
            string fieldValue_text            = encodeText(fieldValueObject);
            int    fieldRows    = 1;
            string fieldHtmlId  = field.nameLc + field.id.ToString();
            string fieldCaption = field.caption;

            if (field.uniqueName)
            {
                fieldCaption = "&nbsp;**" + fieldCaption;
            }
            else
            {
                if (field.nameLc.ToLowerInvariant() == "email")
                {
                    if ((adminData.adminContent.tableName.ToLowerInvariant() == "ccmembers") && ((core.siteProperties.getBoolean("allowemaillogin", false))))
                    {
                        fieldCaption = "&nbsp;***" + fieldCaption;
                        editorEnv.needUniqueEmailMessage = true;
                    }
                }
            }
            if (field.required)
            {
                fieldCaption = "&nbsp;*" + fieldCaption;
            }
            adminData.formInputCount = adminData.formInputCount + 1;
            bool fieldForceReadOnly = false;

            //
            // Read only Special Cases
            if (editorEnv.isRootPage)
            {
                //
                // -- page content metadata, these are the special fields
                switch (GenericController.toLCase(field.nameLc))
                {
                case "active": {
                    //
                    // if active, it is read only -- if inactive, let them set it active.
                    fieldForceReadOnly = encodeBoolean(fieldValueObject);
                    if (fieldForceReadOnly)
                    {
                        whyReadOnlyMsg = "&nbsp;(disabled because you can not mark the landing page inactive)";
                    }
                    break;
                }

                case "dateexpires":
                case "pubdate":
                case "datearchive":
                case "blocksection":
                case "archiveparentid":
                case "hidemenu": {
                    //
                    // These fields are read only on landing pages
                    fieldForceReadOnly = true;
                    whyReadOnlyMsg     = "&nbsp;(disabled for the landing page)";
                    break;
                }

                case "allowinmenus":
                case "allowinchildlists": {
                    fieldValueObject   = "1";
                    fieldForceReadOnly = true;
                    whyReadOnlyMsg     = "&nbsp;(disabled for root pages)";
                }
                break;

                default: {
                    // do nothing
                    break;
                }
                }
            }
            //
            // Special Case - ccemail table Alloweid should be disabled if siteproperty AllowLinkLogin is false
            //
            if (GenericController.toLCase(adminData.adminContent.tableName) == "ccemail" && GenericController.toLCase(field.nameLc) == "allowlinkeid")
            {
                if (!(core.siteProperties.getBoolean("AllowLinkLogin", true)))
                {
                    fieldValueObject   = "0";
                    fieldForceReadOnly = true;
                    fieldValue_text    = "0";
                }
            }
            string     EditorString   = "";
            bool       editorReadOnly = (editorEnv.record_readOnly || field.readOnly || (editRecord.id != 0 && field.notEditable) || (fieldForceReadOnly));
            AddonModel editorAddon    = null;
            int        fieldTypeDefaultEditorAddonId = 0;
            var        fieldEditor = adminData.fieldTypeEditors.Find(x => (x.fieldTypeId == (int)field.fieldTypeId));

            if (fieldEditor != null)
            {
                fieldTypeDefaultEditorAddonId = (int)fieldEditor.editorAddonId;
                editorAddon = DbBaseModel.create <AddonModel>(core.cpParent, fieldTypeDefaultEditorAddonId);
            }
            bool useEditorAddon = false;

            if (editorAddon != null)
            {
                //
                //--------------------------------------------------------------------------------------------
                // ----- Custom Editor
                //--------------------------------------------------------------------------------------------
                //
                core.docProperties.setProperty("editorName", field.nameLc);
                core.docProperties.setProperty("editorValue", fieldValue_text);
                core.docProperties.setProperty("editorFieldId", field.id);
                core.docProperties.setProperty("editorFieldType", (int)field.fieldTypeId);
                core.docProperties.setProperty("editorReadOnly", editorReadOnly);
                core.docProperties.setProperty("editorWidth", "");
                core.docProperties.setProperty("editorHeight", "");
                if (field.fieldTypeId.isOneOf(CPContentBaseClass.FieldTypeIdEnum.HTML, CPContentBaseClass.FieldTypeIdEnum.HTMLCode, CPContentBaseClass.FieldTypeIdEnum.FileHTML, CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode))
                {
                    //
                    // include html related arguments
                    core.docProperties.setProperty("editorAllowActiveContent", "1");
                    core.docProperties.setProperty("editorAddonList", editorEnv.editorAddonListJSON);
                    core.docProperties.setProperty("editorStyles", editorEnv.styleList);
                    core.docProperties.setProperty("editorStyleOptions", editorEnv.styleOptionList);
                }
                EditorString = core.addon.execute(editorAddon, new BaseClasses.CPUtilsBaseClass.addonExecuteContext {
                    addonType           = BaseClasses.CPUtilsBaseClass.addonContext.ContextEditor,
                    errorContextMessage = "field editor id:" + editorAddon.id
                });
                useEditorAddon = !string.IsNullOrEmpty(EditorString);
                if (useEditorAddon)
                {
                    //
                    // -- editor worked
                    editorEnv.formFieldList += "," + field.nameLc;
                }
                else
                {
                    //
                    // -- editor failed, determine if it is missing (or inactive). If missing, remove it from the members preferences
                    using (var csData = new CsModel(core)) {
                        if (!csData.openSql("select id from ccaggregatefunctions where id=" + editorAddon.id))
                        {
                            //
                            // -- missing, not just inactive
                            EditorString = "";
                            //
                            // load user's editor preferences to fieldEditorPreferences() - this is the editor this user has picked when there are >1
                            //   fieldId:addonId,fieldId:addonId,etc
                            //   with custom FancyBox form in edit window with button "set editor preference"
                            //   this button causes a 'refresh' action, reloads fields with stream without save
                            //
                            string tmpList  = core.userProperty.getText("editorPreferencesForContent:" + adminData.adminContent.id, "");
                            int    PosStart = GenericController.strInstr(1, "," + tmpList, "," + field.id + ":");
                            if (PosStart > 0)
                            {
                                int PosEnd = GenericController.strInstr(PosStart + 1, "," + tmpList, ",");
                                if (PosEnd == 0)
                                {
                                    tmpList = tmpList.left(PosStart - 1);
                                }
                                else
                                {
                                    tmpList = tmpList.left(PosStart - 1) + tmpList.Substring(PosEnd - 1);
                                }
                                core.userProperty.setProperty("editorPreferencesForContent:" + adminData.adminContent.id, tmpList);
                            }
                        }
                    }
                }
            }
            //
            // -- style for editor wrapper used to limit the width of some editors like integer
            string editorWrapperSyle = "";

            if (!useEditorAddon)
            {
                bool IsEmptyList = false;
                //string NonEncodedLink = null;
                //string EncodedLink = null;
                //
                // if custom editor not used or if it failed
                //
                if (field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Redirect)
                {
                    //
                    // ----- Default Editor, Redirect fields (the same for normal/readonly/spelling)

                    EditorString = AdminUIEditorController.getRedirectEditor(core, field, adminData, editRecord, fieldValue_text, editorReadOnly, fieldHtmlId, field.required);
                    //string RedirectPath = core.appConfig.adminRoute;
                    //if (field.redirectPath != "") {
                    //    RedirectPath = field.redirectPath;
                    //}
                    //RedirectPath = RedirectPath + "?" + RequestNameTitleExtension + "=" + GenericController.encodeRequestVariable(" For " + editRecord.nameLc + adminData.titleExtension) + "&" + RequestNameAdminDepth + "=" + (adminData.ignore_legacyMenuDepth + 1) + "&wl0=" + field.redirectId + "&wr0=" + editRecord.id;
                    //if (field.redirectContentId != 0) {
                    //    RedirectPath = RedirectPath + "&cid=" + field.redirectContentId;
                    //} else {
                    //    RedirectPath = RedirectPath + "&cid=" + ((editRecord.contentControlId.Equals(0)) ? adminData.adminContent.id : editRecord.contentControlId);
                    //}
                    //if (editRecord.id == 0) {
                    //    EditorString += ("[available after save]");
                    //} else {
                    //    RedirectPath = GenericController.strReplace(RedirectPath, "'", "\\'");
                    //    EditorString += ("<a href=\"#\"");
                    //    EditorString += (" onclick=\" window.open('" + RedirectPath + "', '_blank', 'scrollbars=yes,toolbar=no,status=no,resizable=yes'); return false;\"");
                    //    EditorString += (">");
                    //    EditorString += ("Open in New Window</A>");
                    //}
                }
                else if (editorReadOnly)
                {
                    //
                    //--------------------------------------------------------------------------------------------
                    // ----- Display fields as read only
                    //--------------------------------------------------------------------------------------------
                    //
                    if (!string.IsNullOrEmpty(whyReadOnlyMsg))
                    {
                        whyReadOnlyMsg = "<span class=\"ccDisabledReason\">" + whyReadOnlyMsg + "</span>";
                    }
                    switch (field.fieldTypeId)
                    {
                    case CPContentBaseClass.FieldTypeIdEnum.Text:
                    case CPContentBaseClass.FieldTypeIdEnum.Link:
                    case CPContentBaseClass.FieldTypeIdEnum.ResourceLink: {
                        //
                        // ----- Text Type
                        EditorString            += AdminUIEditorController.getTextEditor(core, field.nameLc, fieldValue_text, editorReadOnly, fieldHtmlId);
                        editorEnv.formFieldList += "," + field.nameLc;
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.Boolean: {
                        //
                        // ----- Boolean ReadOnly
                        EditorString            += AdminUIEditorController.getBooleanEditor(core, field.nameLc, GenericController.encodeBoolean(fieldValueObject), editorReadOnly, fieldHtmlId);
                        editorEnv.formFieldList += "," + field.nameLc;
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.Lookup: {
                        //
                        // ----- Lookup, readonly
                        if (field.lookupContentId != 0)
                        {
                            EditorString             = AdminUIEditorController.getLookupContentEditor(core, field.nameLc, GenericController.encodeInteger(fieldValueObject), field.lookupContentId, ref IsEmptyList, editorReadOnly, fieldHtmlId, whyReadOnlyMsg, field.required, "");
                            editorEnv.formFieldList += "," + field.nameLc;
                            editorWrapperSyle        = "max-width:400px";
                        }
                        else if (field.lookupList != "")
                        {
                            EditorString             = AdminUIEditorController.getLookupListEditor(core, field.nameLc, encodeInteger(fieldValueObject), field.lookupList.Split(',').ToList(), editorReadOnly, fieldHtmlId, whyReadOnlyMsg, field.required);
                            editorEnv.formFieldList += "," + field.nameLc;
                            editorWrapperSyle        = "max-width:400px";
                        }
                        else
                        {
                            //
                            // -- log exception but dont throw
                            LogController.logWarn(core, new GenericException("Field [" + adminData.adminContent.name + "." + field.nameLc + "] is a Lookup field, but no LookupContent or LookupList has been configured"));
                            EditorString += "[Selection not configured]";
                        }
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.Date: {
                        //
                        // ----- date, readonly
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString             = AdminUIEditorController.getDateTimeEditor(core, field.nameLc, encodeDate(fieldValueObject), editorReadOnly, fieldHtmlId, field.required, whyReadOnlyMsg);
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.MemberSelect: {
                        //
                        // ----- Member Select ReadOnly
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString             = AdminUIEditorController.getMemberSelectEditor(core, field.nameLc, encodeInteger(fieldValueObject), field.memberSelectGroupId_get(core), field.memberSelectGroupName_get(core), editorReadOnly, fieldHtmlId, field.required, whyReadOnlyMsg);
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.ManyToMany: {
                        //
                        //   Placeholder
                        EditorString = AdminUIEditorController.getManyToManyEditor(core, field, "field" + field.id, fieldValue_text, editRecord.id, editorReadOnly, whyReadOnlyMsg);
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.Currency: {
                        //
                        // ----- Currency ReadOnly
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString            += (HtmlController.inputCurrency(core, field.nameLc, encodeNumber(fieldValue_text), fieldHtmlId, "text form-control", editorReadOnly, false));
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.Float: {
                        //
                        // ----- double/number/float
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString            += (HtmlController.inputNumber(core, field.nameLc, encodeNumber(fieldValue_text), fieldHtmlId, "text form-control", editorReadOnly, false));
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.AutoIdIncrement:
                    case CPContentBaseClass.FieldTypeIdEnum.Integer: {
                        //
                        // ----- Others that simply print
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString            += (HtmlController.inputInteger(core, field.nameLc, encodeInteger(fieldValue_text), fieldHtmlId, "text form-control", editorReadOnly, false));
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.HTMLCode:
                    case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode: {
                        //
                        // edit html as html (see the code)
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString            += HtmlController.inputHidden(field.nameLc, fieldValue_text);
                        fieldRows     = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10));
                        EditorString += HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, editorReadOnly, "form-control");
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.HTML:
                    case CPContentBaseClass.FieldTypeIdEnum.FileHTML: {
                        //
                        // ----- HTML types readonly
                        if (field.htmlContent)
                        {
                            //
                            // edit html as html (see the code)
                            editorEnv.formFieldList += "," + field.nameLc;
                            EditorString            += HtmlController.inputHidden(field.nameLc, fieldValue_text);
                            fieldRows     = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10));
                            EditorString += HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, editorReadOnly, "form-control");
                        }
                        else
                        {
                            //
                            // edit html as wysiwyg readonly
                            editorEnv.formFieldList += "," + field.nameLc;
                            EditorString            += AdminUIEditorController.getHtmlEditor(core, field.nameLc, fieldValue_text, editorEnv.editorAddonListJSON, editorEnv.styleList, editorEnv.styleOptionList, editorReadOnly, fieldHtmlId);
                        }
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.LongText:
                    case CPContentBaseClass.FieldTypeIdEnum.FileText: {
                        //
                        // ----- LongText, TextFile
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString            += HtmlController.inputHidden(field.nameLc, fieldValue_text);
                        fieldRows     = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10));
                        EditorString += HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, editorReadOnly, " form-control");
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.File: {
                        //
                        // ----- File ReadOnly
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString             = AdminUIEditorController.getFileEditor(core, field.nameLc, fieldValue_text, field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg);
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.FileImage: {
                        //
                        // ----- Image ReadOnly
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString             = AdminUIEditorController.getImageEditor(core, field.nameLc, fieldValue_text, field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg);
                        break;
                    }

                    default: {
                        //
                        // ----- Legacy text type -- not used unless something was missed
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString            += HtmlController.inputHidden(field.nameLc, fieldValue_text);
                        if (field.password)
                        {
                            //
                            // Password forces simple text box
                            EditorString += HtmlController.inputText_Legacy(core, field.nameLc, "*****", 0, 0, fieldHtmlId, true, true, "password form-control");
                        }
                        else if (!field.htmlContent)
                        {
                            //
                            // not HTML capable, textarea with resizing
                            if ((field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Text) && (fieldValue_text.IndexOf("\n") == -1) && (fieldValue_text.Length < 40))
                            {
                                //
                                // text field shorter then 40 characters without a CR
                                EditorString += HtmlController.inputText_Legacy(core, field.nameLc, fieldValue_text, 1, 0, fieldHtmlId, false, true, "text form-control");
                            }
                            else
                            {
                                //
                                // longer text data, or text that contains a CR
                                EditorString += HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, 10, -1, fieldHtmlId, false, true, " form-control");
                            }
                        }
                        else if (field.htmlContent)
                        {
                            //
                            // HTMLContent true, and prefered
                            fieldRows     = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".PixelHeight", 500));
                            EditorString += core.html.getFormInputHTML(field.nameLc, fieldValue_text, "500", "", false, true, editorEnv.editorAddonListJSON, editorEnv.styleList, editorEnv.styleOptionList);
                            EditorString  = "<div style=\"width:95%\">" + EditorString + "</div>";
                        }
                        else
                        {
                            //
                            // HTMLContent true, but text editor selected
                            fieldRows     = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10));
                            EditorString += HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, editorReadOnly);
                        }
                        break;
                    }
                    }
                }
                else
                {
                    //
                    // -- Not Read Only - Display fields as form elements to be modified
                    switch (field.fieldTypeId)
                    {
                    case CPContentBaseClass.FieldTypeIdEnum.Text: {
                        //
                        // ----- Text Type
                        if (field.password)
                        {
                            EditorString += AdminUIEditorController.getPasswordEditor(core, field.nameLc, fieldValue_text, false, fieldHtmlId);
                        }
                        else
                        {
                            EditorString += AdminUIEditorController.getTextEditor(core, field.nameLc, fieldValue_text, false, fieldHtmlId);
                        }
                        editorEnv.formFieldList += "," + field.nameLc;
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.Boolean: {
                        //
                        // ----- Boolean
                        EditorString            += AdminUIEditorController.getBooleanEditor(core, field.nameLc, encodeBoolean(fieldValueObject), false, fieldHtmlId);
                        editorEnv.formFieldList += "," + field.nameLc;
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.Lookup: {
                        //
                        // ----- Lookup
                        if (field.lookupContentId != 0)
                        {
                            EditorString             = AdminUIEditorController.getLookupContentEditor(core, field.nameLc, encodeInteger(fieldValueObject), field.lookupContentId, ref IsEmptyList, field.readOnly, fieldHtmlId, whyReadOnlyMsg, field.required, "");
                            editorEnv.formFieldList += "," + field.nameLc;
                            editorWrapperSyle        = "max-width:400px";
                        }
                        else if (field.lookupList != "")
                        {
                            EditorString             = AdminUIEditorController.getLookupListEditor(core, field.nameLc, encodeInteger(fieldValueObject), field.lookupList.Split(',').ToList(), field.readOnly, fieldHtmlId, whyReadOnlyMsg, field.required);
                            editorEnv.formFieldList += "," + field.nameLc;
                            editorWrapperSyle        = "max-width:400px";
                        }
                        else
                        {
                            //
                            // -- log exception but dont throw
                            LogController.logWarn(core, new GenericException("Field [" + adminData.adminContent.name + "." + field.nameLc + "] is a Lookup field, but no LookupContent or LookupList has been configured"));
                            EditorString += "[Selection not configured]";
                        }
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.Date: {
                        //
                        // ----- Date
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString             = AdminUIEditorController.getDateTimeEditor(core, field.nameLc, GenericController.encodeDate(fieldValueObject), field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg);
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.MemberSelect: {
                        //
                        // ----- Member Select
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString             = AdminUIEditorController.getMemberSelectEditor(core, field.nameLc, encodeInteger(fieldValueObject), field.memberSelectGroupId_get(core), field.memberSelectGroupName_get(core), field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg);
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.ManyToMany: {
                        //
                        //   Placeholder
                        EditorString = AdminUIEditorController.getManyToManyEditor(core, field, "field" + field.id, fieldValue_text, editRecord.id, false, whyReadOnlyMsg);
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.File: {
                        //
                        // ----- File
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString             = AdminUIEditorController.getFileEditor(core, field.nameLc, fieldValue_text, field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg);
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.FileImage: {
                        //
                        // ----- Image ReadOnly
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString             = AdminUIEditorController.getImageEditor(core, field.nameLc, fieldValue_text, field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg);
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.Currency: {
                        //
                        // ----- currency
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString            += AdminUIEditorController.getCurrencyEditor(core, field.nameLc, encodeNumberNullable(fieldValueObject), field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg);
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.Float: {
                        //
                        // ----- double/number/float
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString            += AdminUIEditorController.getNumberEditor(core, field.nameLc, encodeNumberNullable(fieldValueObject), field.readOnly, fieldHtmlId, field.required, whyReadOnlyMsg);
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.AutoIdIncrement:
                    case CPContentBaseClass.FieldTypeIdEnum.Integer: {
                        //
                        // ----- Others that simply print
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString            += (HtmlController.inputInteger(core, field.nameLc, encodeIntegerNullable(fieldValue_text), fieldHtmlId, "text form-control", editorReadOnly, false));
                        editorWrapperSyle        = "max-width:400px";
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.Link: {
                        //
                        // ----- Link (href value
                        //
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString             = AdminUIEditorController.getLinkEditor(core, field.nameLc, fieldValue_text, editorReadOnly, fieldHtmlId, field.required);
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.ResourceLink: {
                        //
                        // ----- Resource Link (src value)
                        //
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString             = AdminUIEditorController.getLinkEditor(core, field.nameLc, fieldValue_text, editorReadOnly, fieldHtmlId, field.required);
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.HTMLCode:
                    case CPContentBaseClass.FieldTypeIdEnum.FileHTMLCode: {
                        //
                        // View the content as Html, not wysiwyg
                        editorEnv.formFieldList += "," + field.nameLc;
                        EditorString             = AdminUIEditorController.getHtmlCodeEditor(core, field.nameLc, fieldValue_text, editorReadOnly, fieldHtmlId);
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.HTML:
                    case CPContentBaseClass.FieldTypeIdEnum.FileHTML: {
                        //
                        // content is html
                        editorEnv.formFieldList += "," + field.nameLc;
                        if (field.htmlContent)
                        {
                            //
                            // View the content as Html, not wysiwyg
                            EditorString = AdminUIEditorController.getHtmlCodeEditor(core, field.nameLc, fieldValue_text, editorReadOnly, fieldHtmlId);
                        }
                        else
                        {
                            //
                            // wysiwyg editor
                            EditorString = AdminUIEditorController.getHtmlEditor(core, field.nameLc, fieldValue_text, editorEnv.editorAddonListJSON, editorEnv.styleList, editorEnv.styleOptionList, editorReadOnly, fieldHtmlId);
                        }
                        //
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.LongText:
                    case CPContentBaseClass.FieldTypeIdEnum.FileText: {
                        //
                        // -- Long Text, use text editor
                        editorEnv.formFieldList += "," + field.nameLc;
                        fieldRows    = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10));
                        EditorString = HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, false, "text form-control");
                        //
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.FileCSS: {
                        //
                        // ----- CSS field
                        editorEnv.formFieldList += "," + field.nameLc;
                        fieldRows    = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10));
                        EditorString = HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, false, "styles form-control");
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.FileJavascript: {
                        //
                        // ----- Javascript field
                        editorEnv.formFieldList += "," + field.nameLc;
                        fieldRows    = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10));
                        EditorString = HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, false, "text form-control");
                        //
                        break;
                    }

                    case CPContentBaseClass.FieldTypeIdEnum.FileXML: {
                        //
                        // ----- xml field
                        editorEnv.formFieldList += "," + field.nameLc;
                        fieldRows    = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10));
                        EditorString = HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, fieldRows, -1, fieldHtmlId, false, false, "text form-control");
                        //
                        break;
                    }

                    default: {
                        //
                        // ----- Legacy text type -- not used unless something was missed
                        //
                        editorEnv.formFieldList += "," + field.nameLc;
                        if (field.password)
                        {
                            //
                            // Password forces simple text box
                            EditorString = HtmlController.inputText_Legacy(core, field.nameLc, fieldValue_text, -1, -1, fieldHtmlId, true, false, "password form-control");
                        }
                        else if (!field.htmlContent)
                        {
                            //
                            // not HTML capable, textarea with resizing
                            //
                            if ((field.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.Text) && (fieldValue_text.IndexOf("\n", StringComparison.InvariantCulture) == -1) && (fieldValue_text.Length < 40))
                            {
                                //
                                // text field shorter then 40 characters without a CR
                                //
                                EditorString = HtmlController.inputText_Legacy(core, field.nameLc, fieldValue_text, 1, -1, fieldHtmlId, false, false, "text form-control");
                            }
                            else
                            {
                                //
                                // longer text data, or text that contains a CR
                                //
                                EditorString = HtmlController.inputTextarea(core, field.nameLc, fieldValue_text, 10, -1, fieldHtmlId, false, false, "text form-control");
                            }
                        }
                        else if (field.htmlContent)
                        {
                            //
                            // HTMLContent true, and prefered
                            //
                            if (string.IsNullOrEmpty(fieldValue_text))
                            {
                                //
                                // editor needs a starting p tag to setup correctly
                                //
                                fieldValue_text = HTMLEditorDefaultCopyNoCr;
                            }
                            fieldRows     = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".PixelHeight", 500));
                            EditorString += core.html.getFormInputHTML(field.nameLc, fieldValue_text, "500", "", false, true, editorEnv.editorAddonListJSON, editorEnv.styleList, editorEnv.styleOptionList);
                            EditorString  = "<div style=\"width:95%\">" + EditorString + "</div>";
                        }
                        else
                        {
                            //
                            // HTMLContent true, but text editor selected
                            fieldRows    = (core.userProperty.getInteger(adminData.adminContent.name + "." + field.nameLc + ".RowHeight", 10));
                            EditorString = HtmlController.inputTextarea(core, field.nameLc, HtmlController.encodeHtml(fieldValue_text), fieldRows, -1, fieldHtmlId, false, false, "text");
                        }
                        break;
                    }
                    }
                }
            }
            //
            // assemble the editor row
            return(AdminUIController.getEditRow(core, EditorString, fieldCaption, field.helpDefault, field.required, false, fieldHtmlId, editorWrapperSyle));
        }
 //
 public HouseKeepEnvironmentModel(CoreController core)
 {
     try {
         archiveAlarm      = false;
         lastCheckDateTime = core.siteProperties.getDate("housekeep, last check", default);
         core.siteProperties.setProperty("housekeep, last check", core.dateTimeNowMockable);
         forceHousekeep            = core.docProperties.getBoolean("force");
         serverHousekeepHour       = core.siteProperties.getInteger("housekeep, run time hour", 2);
         runDailyTasks             = ((core.dateTimeNowMockable.Date > lastCheckDateTime.Date) && (serverHousekeepHour < core.dateTimeNowMockable.Hour));
         yesterday                 = core.dateTimeNowMockable.AddDays(-1).Date;
         aLittleWhileAgo           = core.dateTimeNowMockable.AddDays(-90).Date;
         defaultMemberName         = ContentFieldMetadataModel.getDefaultValue(core, "people", "name");
         archiveDeleteNoCookie     = core.siteProperties.getBoolean("ArchiveDeleteNoCookie", true);
         sqlDateMidnightTwoDaysAgo = DbController.encodeSQLDate(midnightTwoDaysAgo);
         midnightTwoDaysAgo        = core.dateTimeNowMockable.AddDays(-2).Date;
         thirtyDaysAgo             = core.dateTimeNowMockable.AddDays(-30).Date;
         //
         // -- Get ArchiveAgeDays - use this as the oldest data they care about
         visitArchiveAgeDays = core.siteProperties.getInteger("ArchiveRecordAgeDays", 2);
         if (visitArchiveAgeDays < 2)
         {
             visitArchiveAgeDays = 2;
             core.siteProperties.setProperty("ArchiveRecordAgeDays", 2);
         }
         visitArchiveDate = core.dateTimeNowMockable.AddDays(-visitArchiveAgeDays).Date;
         oldestVisitSummaryWeCareAbout = core.dateTimeNowMockable.Date.AddDays(-30);
         if (oldestVisitSummaryWeCareAbout < visitArchiveDate)
         {
             oldestVisitSummaryWeCareAbout = visitArchiveDate;
         }
         //
         // -- Get GuestArchiveAgeDays
         guestArchiveAgeDays = core.siteProperties.getInteger("ArchivePeopleAgeDays", 2);
         if (guestArchiveAgeDays < 2)
         {
             guestArchiveAgeDays = 2;
             core.siteProperties.setProperty("ArchivePeopleAgeDays", guestArchiveAgeDays);
         }
         //
         // -- Get EmailDropArchiveAgeDays
         emailDropArchiveAgeDays = core.siteProperties.getInteger("ArchiveEmailDropAgeDays", 90);
         if (emailDropArchiveAgeDays < 2)
         {
             emailDropArchiveAgeDays = 2;
             core.siteProperties.setProperty("ArchiveEmailDropAgeDays", emailDropArchiveAgeDays);
         }
         if (emailDropArchiveAgeDays > 365)
         {
             emailDropArchiveAgeDays = 365;
             core.siteProperties.setProperty("ArchiveEmailDropAgeDays", emailDropArchiveAgeDays);
         }
         //
         // -- Get emailLogBodyRetainDays --
         emailLogBodyRetainDays = GenericController.encodeInteger(core.siteProperties.getText("EmailLogBodyRetainDays", "7"));
         //
         defaultMemberName = ContentFieldMetadataModel.getDefaultValue(core, "people", "name");
         //
         // Check for site's archive time of day
         //
         string AlarmTimeString = core.siteProperties.getText("ArchiveTimeOfDay", "12:00:00 AM");
         if (string.IsNullOrEmpty(AlarmTimeString))
         {
             AlarmTimeString = "12:00:00 AM";
             core.siteProperties.setProperty("ArchiveTimeOfDate", AlarmTimeString);
         }
         if (!GenericController.isDate(AlarmTimeString))
         {
             AlarmTimeString = "12:00:00 AM";
             core.siteProperties.setProperty("ArchiveTimeOfDate", AlarmTimeString);
         }
         double minutesSinceMidnight         = core.dateTimeNowMockable.TimeOfDay.TotalMinutes;
         double LastCheckMinutesFromMidnight = lastCheckDateTime.TimeOfDay.TotalMinutes;
         if ((minutesSinceMidnight > LastCheckMinutesFromMidnight) && (LastCheckMinutesFromMidnight < minutesSinceMidnight))
         {
             //
             // Same Day - Midnight is before last and after current
             //
             archiveAlarm = true;
         }
         else if ((LastCheckMinutesFromMidnight > minutesSinceMidnight) && ((LastCheckMinutesFromMidnight < minutesSinceMidnight)))
         {
             //
             // New Day - Midnight is between Last and Set
             //
             archiveAlarm = true;
         }
     } catch (Exception ex) {
         LogController.logError(core, ex);
     }
 }
示例#9
0
        //
        // ====================================================================================================
        /// <summary>
        /// Create the tabs for editing a record
        /// </summary>
        /// <param name="adminData.content"></param>
        /// <param name="editRecord"></param>
        /// <returns></returns>
        public static string get(CoreController core, AdminDataModel adminData)
        {
            string returnHtml = "";

            try {
                //
                if ((!core.doc.userErrorList.Count.Equals(0)) && adminData.editRecord.loaded)
                {
                    //
                    // block load if there was a user error and it is already loaded (assume error was from response )
                }
                else if (adminData.adminContent.id <= 0)
                {
                    //
                    // Invalid Content
                    Processor.Controllers.ErrorController.addUserError(core, "There was a problem identifying the content you requested. Please return to the previous form and verify your selection.");
                    return("");
                }
                else if (adminData.editRecord.loaded && !adminData.editRecord.saved)
                {
                    //
                    //   File types need to be reloaded from the Db, because...
                    //       LoadDb - sets them to the path-page
                    //       LoadResponse - sets the blank if no change, filename if there is an upload
                    //       SaveEditRecord - if blank, no change. If a filename it saves the uploaded file
                    //       GetForm_Edit - expects the Db value to be in EditRecordValueVariants (path-page)
                    //
                    // xx This was added to bypass the load for the editrefresh case (reload the response so the editor preference can change)
                    // xx  I do not know why the following section says "reload even if it is loaded", but lets try this
                    //
                    foreach (var keyValuePair in adminData.adminContent.fields)
                    {
                        ContentFieldMetadataModel field = keyValuePair.Value;
                        if ((keyValuePair.Value.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.File) || (keyValuePair.Value.fieldTypeId == CPContentBaseClass.FieldTypeIdEnum.FileImage))
                        {
                            adminData.editRecord.fieldsLc[field.nameLc].value = adminData.editRecord.fieldsLc[field.nameLc].dbValue;
                        }
                    }
                }
                else
                {
                    //
                    // otherwise, load the record, even if it was loaded during a previous form process
                    adminData.loadEditRecord(core, true);
                }
                if (!AdminDataModel.userHasContentAccess(core, ((adminData.editRecord.contentControlId.Equals(0)) ? adminData.adminContent.id : adminData.editRecord.contentControlId)))
                {
                    Processor.Controllers.ErrorController.addUserError(core, "Your account on this system does not have access rights to edit this content.");
                    return("");
                }
                //
                // Setup Edit Referer
                string EditReferer = core.docProperties.getText(RequestNameEditReferer);
                if (string.IsNullOrEmpty(EditReferer))
                {
                    EditReferer = core.webServer.requestReferer;
                    if (!string.IsNullOrEmpty(EditReferer))
                    {
                        //
                        // special case - if you are coming from the advanced search, go back to the list page
                        EditReferer = GenericController.strReplace(EditReferer, "&af=39", "");
                        //
                        // if referer includes AdminWarningMsg (admin hint message), remove it -- this edit may fix the problem
                        int Pos = EditReferer.IndexOf("AdminWarningMsg=", StringComparison.CurrentCulture);
                        if (Pos >= 0)
                        {
                            EditReferer = EditReferer.left(Pos - 2);
                        }
                    }
                }
                core.doc.addRefreshQueryString(RequestNameEditReferer, EditReferer);
                //
                // load user's editor preferences to fieldEditorPreferences() - this is the editor this user has picked when there are >1
                //   fieldId:addonId,fieldId:addonId,etc
                //   with custom FancyBox form in edit window with button "set editor preference"
                //   this button causes a 'refresh' action, reloads fields with stream without save
                //
                //
                // ----- determine contentType for editor
                //
                CPHtml5BaseClass.EditorContentType contentType;
                if (GenericController.toLCase(adminData.adminContent.name) == "email templates")
                {
                    contentType = CPHtml5BaseClass.EditorContentType.contentTypeEmailTemplate;
                }
                else if (GenericController.toLCase(adminData.adminContent.tableName) == "cctemplates")
                {
                    contentType = CPHtml5BaseClass.EditorContentType.contentTypeWebTemplate;
                }
                else if (GenericController.toLCase(adminData.adminContent.tableName) == "ccemail")
                {
                    contentType = CPHtml5BaseClass.EditorContentType.contentTypeEmail;
                }
                else
                {
                    contentType = CPHtml5BaseClass.EditorContentType.contentTypeWeb;
                }

                EditorEnvironmentModel editorEnv = new EditorEnvironmentModel {
                    allowHelpMsgCustom     = false,
                    editorAddonListJSON    = core.html.getWysiwygAddonList(contentType),
                    isRootPage             = adminData.adminContent.tableName.ToLowerInvariant().Equals(PageContentModel.tableMetadata.tableNameLower) && (adminData.editRecord.parentId == 0) && (adminData.editRecord.id != 0),
                    needUniqueEmailMessage = false,
                    record_readOnly        = adminData.editRecord.userReadOnly,
                    styleList       = "",
                    styleOptionList = "",
                    formFieldList   = ""
                };
                //
                // ----- determine access details
                var  userContentPermissions = PermissionController.getUserContentPermissions(core, adminData.adminContent);
                bool allowDelete            = adminData.adminContent.allowDelete && userContentPermissions.allowDelete && (adminData.editRecord.id != 0);
                bool allowAdd          = adminData.adminContent.allowAdd && userContentPermissions.allowAdd;
                var  editButtonBarInfo = new EditButtonBarInfoClass(core, adminData, allowDelete, true, userContentPermissions.allowSave, allowAdd);
                //
                string adminContentTableNameLc = adminData.adminContent.tableName.ToLowerInvariant();
                bool   allowLinkAlias          = adminContentTableNameLc.Equals(PageContentModel.tableMetadata.tableNameLower);
                bool   allowPeopleGroups       = adminContentTableNameLc.Equals(PersonModel.tableMetadata.tableNameLower);;
                //
                //-----Create edit page
                if (adminContentTableNameLc.Equals(EmailModel.tableMetadata.tableNameLower))
                {
                    //
                    LogController.logTrace(core, "getFormEdit, treat as email, adminContentTableNameLower [" + adminContentTableNameLc + "]");
                    //
                    // -- email
                    bool     emailSubmitted            = false;
                    bool     emailSent                 = false;
                    DateTime LastSendTestDate          = DateTime.MinValue;
                    bool     AllowEmailSendWithoutTest = (core.siteProperties.getBoolean("AllowEmailSendWithoutTest", false));
                    if (adminData.editRecord.fieldsLc.ContainsKey("lastsendtestdate"))
                    {
                        LastSendTestDate = GenericController.encodeDate(adminData.editRecord.fieldsLc["lastsendtestdate"].value);
                    }
                    if (adminData.adminContent.id.Equals(ContentMetadataModel.getContentId(core, "System Email")))
                    {
                        //
                        LogController.logTrace(core, "getFormEdit, System email");
                        //
                        // System Email
                        emailSubmitted = false;
                        if (adminData.editRecord.id != 0)
                        {
                            if (adminData.editRecord.fieldsLc.ContainsKey("testmemberid"))
                            {
                                if (encodeInteger(adminData.editRecord.fieldsLc["testmemberid"].value) == 0)
                                {
                                    adminData.editRecord.fieldsLc["testmemberid"].value = core.session.user.id;
                                }
                            }
                        }
                        editButtonBarInfo.allowSave     = (userContentPermissions.allowSave && adminData.editRecord.allowUserSave && (!emailSubmitted) && (!emailSent));
                        editButtonBarInfo.allowSendTest = ((!emailSubmitted) && (!emailSent));
                    }
                    else if (adminData.adminContent.id.Equals(ContentMetadataModel.getContentId(core, "Conditional Email")))
                    {
                        //
                        // Conditional Email
                        emailSubmitted            = false;
                        editorEnv.record_readOnly = adminData.editRecord.userReadOnly || emailSubmitted;
                        if (adminData.editRecord.id != 0)
                        {
                            if (adminData.editRecord.fieldsLc.ContainsKey("submitted"))
                            {
                                emailSubmitted = GenericController.encodeBoolean(adminData.editRecord.fieldsLc["submitted"].value);
                            }
                        }
                        editButtonBarInfo.allowActivate   = !emailSubmitted && ((LastSendTestDate != DateTime.MinValue) || AllowEmailSendWithoutTest);
                        editButtonBarInfo.allowDeactivate = emailSubmitted;
                        editButtonBarInfo.allowSave       = userContentPermissions.allowSave && adminData.editRecord.allowUserSave && !emailSubmitted;
                    }
                    else
                    {
                        //
                        // Group Email
                        if (adminData.editRecord.id != 0)
                        {
                            emailSubmitted = encodeBoolean(adminData.editRecord.fieldsLc["submitted"].value);
                            emailSent      = encodeBoolean(adminData.editRecord.fieldsLc["sent"].value);
                        }
                        editButtonBarInfo.allowSave     = !emailSubmitted && (userContentPermissions.allowSave && adminData.editRecord.allowUserSave);
                        editButtonBarInfo.allowSend     = !emailSubmitted && ((LastSendTestDate != DateTime.MinValue) || AllowEmailSendWithoutTest);
                        editButtonBarInfo.allowSendTest = !emailSubmitted;
                        editorEnv.record_readOnly       = adminData.editRecord.userReadOnly || emailSubmitted || emailSent;
                    }
                }
                else if (adminContentTableNameLc.Equals(PageContentModel.tableMetadata.tableNameLower))
                {
                    //
                    // Page Content
                    //
                    editButtonBarInfo.allowMarkReviewed = true;
                    editButtonBarInfo.isPageContent     = true;
                    editButtonBarInfo.hasChildRecords   = true;
                    allowLinkAlias = true;
                }
                else
                {
                    //
                    // All other tables (User definined)
                    var pageContentMetadata = ContentMetadataModel.createByUniqueName(core, "page content");
                    editButtonBarInfo.isPageContent     = pageContentMetadata.isParentOf(core, adminData.adminContent.id);
                    editButtonBarInfo.hasChildRecords   = adminData.adminContent.containsField(core, "parentid");
                    editButtonBarInfo.allowMarkReviewed = core.db.isSQLTableField(adminData.adminContent.tableName, "DateReviewed");
                }
                //
                // Print common form elements
                var Stream = new StringBuilderLegacyController();
                Stream.add("\r<input type=\"hidden\" name=\"fieldEditorPreference\" id=\"fieldEditorPreference\" value=\"\">");
                string editSectionButtonBar = AdminUIController.getSectionButtonBarForEdit(core, editButtonBarInfo);
                Stream.add(editSectionButtonBar);
                var headerInfo = new RecordEditHeaderInfoClass {
                    recordId              = adminData.editRecord.id,
                    recordLockById        = adminData.editRecord.editLock.editLockByMemberId,
                    recordLockExpiresDate = encodeDate(adminData.editRecord.editLock.editLockExpiresDate),
                    recordName            = adminData.editRecord.nameLc
                };
                string titleBarDetails = AdminUIController.getEditForm_TitleBarDetails(core, headerInfo, adminData.editRecord);
                Stream.add(AdminUIController.getSectionHeader(core, "", titleBarDetails));
                {
                    var editTabs = new EditTabModel();
                    EditViewTabList.addContentTabs(core, adminData, editTabs, editorEnv);
                    if (allowPeopleGroups)
                    {
                        EditViewTabList.addCustomTab(core, editTabs, "Groups", GroupRuleEditor.get(core, adminData));
                    }
                    if (allowLinkAlias)
                    {
                        EditViewTabList.addCustomTab(core, editTabs, "Link Aliases", LinkAliasEditor.getForm_Edit_LinkAliases(core, adminData, adminData.editRecord.userReadOnly));
                    }
                    EditViewTabList.addCustomTab(core, editTabs, "Control&nbsp;Info", EditViewTabControlInfo.get(core, adminData, editorEnv));
                    Stream.add(editTabs.getTabs(core));
                }
                Stream.add(editSectionButtonBar);
                Stream.add(HtmlController.inputHidden("FormFieldList", editorEnv.formFieldList));
                returnHtml = wrapForm(core, Stream.text, adminData, AdminFormEdit);
                //
                // -- update page title
                if (adminData.editRecord.id == 0)
                {
                    core.html.addTitle("Add " + adminData.adminContent.name);
                }
                else if (adminData.editRecord.nameLc == "")
                {
                    core.html.addTitle("Edit #" + adminData.editRecord.id + " in " + adminData.editRecord.contentControlId_Name);
                }
                else
                {
                    core.html.addTitle("Edit " + adminData.editRecord.nameLc + " in " + adminData.editRecord.contentControlId_Name);
                }
            } catch (Exception ex) {
                LogController.logError(core, ex);
                throw;
            }
            return(returnHtml);
        }
        //
        //=============================================================================
        //   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);
        }