Exemple #1
0
        public override string getForm(CPBaseClass cp, int dstFormId, string rqs, DateTime rightNow, applicationClass application)
        {
            string returnHtml = "";
            try
            {
                CPBlockBaseClass layout = cp.BlockNew();
                CPCSBaseClass cs = cp.CSNew();
                string body;

                layout.OpenLayout("MultiFormAjaxSample - Form 3");

                // manuiplate the html, pre-populating fields, hiding parts not needed, etc.
                // get the resulting form from the layout object
                // add the srcFormId as a hidden
                // wrap it in a form for the javascript to use during submit

                body = layout.GetHtml();
                body += cp.Html.Hidden(commonModule.rnSrcFormId, dstFormId.ToString());
                returnHtml = cp.Html.Form(body, "", "", "mfaForm3", rqs);

            }
            catch (Exception ex)
            {
                cp.Site.ErrorReport(ex, "getForm");
            }
            return returnHtml;
        }
Exemple #2
0
        public override int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightnow, applicationClass application)
        {
            int nextFormId = srcFormId;

            try
            {
                string button;
                CPCSBaseClass cs = cp.CSNew();
                string lastName;
                Boolean isInputOK = true;

                // ajax routines return a different name for button

                button = cp.Doc.GetText("ajaxButton");

                if (button == "")
                {
                    button = cp.Doc.GetText(commonModule.rnButton);
                }

                // check the input requirements
                // if user errors are handled with javascript, no need to display a message, just prevent save

                lastName = cp.Doc.GetText("lastName");
                if (lastName == "")
                {
                    isInputOK = false;
                }

                // if no user errors, process input
                // if errors, just return default nextFormId which will redisplay this form

                if (isInputOK)
                {
                    application.lastName = lastName;
                    application.changed = true;

                    // determine the next form

                    switch (button)
                    {
                        case commonModule.buttonNext:
                            //
                            nextFormId = commonModule.formIdThree;
                            break;
                    }
                }

            }
            catch (Exception ex)
            {
                cp.Site.ErrorReport(ex, "processForm");
            }

            return nextFormId;
        }
        //
        //
        //
        public static applicationClass getApplication(CPBaseClass cp, Boolean createRecordIfMissing)
        {
            applicationClass application = new applicationClass();

            try {
                CPCSBaseClass cs = cp.CSNew();
                CPCSBaseClass csSrc = cp.CSNew();

                // get id of this user's application
                // use visit property if they keep the same application for the visit
                // use visitor property if each time they open thier browser, they get the previous application
                // use user property if they only get to the application when they are associated to the current user (they should be authenticated first)

                application.completed = false;
                application.changed = false;
                application.id = cp.Visit.GetInteger("multiformAjaxSample ApplicationId");

                if (application.id != 0)
                {
                    if (!cs.Open("MultiFormAjax Application", "(dateCompleted is null)"))
                    {
                        application.id = 0;
                    }
                }

                if (cs.OK())
                {
                    application.firstName = cs.GetText("firstName");
                    application.lastName = cs.GetText("lastName");
                    application.email = cs.GetText("email");
                }
                else {
                    if (csSrc.Open("people", "id=" + cp.User.Id))
                    {
                        application.firstName = csSrc.GetText("firstName");
                        application.lastName = csSrc.GetText("lastName");
                        application.email = csSrc.GetText("email");
                    }
                    csSrc.Close();
                }
                cs.Close();

            }
            catch (Exception ex)
            {
                cp.Site.ErrorReport(ex, "Error in getApplication");
            }

            return application;
        }
 //
 //=========================================================================
 //  create user error if requestName field is not in doc properties
 //=========================================================================
 //
 public static void checkRequiredFieldText(CPBaseClass cp, string requestName, string fieldCaption)
 {
     try
     {
         if (cp.Doc.GetProperty(requestName, "") == "")
         {
             cp.UserError.Add("The field " + fieldCaption + " is required.");
         }
     }
     catch (Exception ex)
     {
         cp.Site.ErrorReport(ex, "Unexpected Error in checkRequiredFieldText");
     }
 }
 //
 //=========================================================================================================
 //   GetPageNumber
 //=========================================================================================================
 //
 public static int getPageNumber(CPBaseClass cp)
 {
     int pageNumber = cp.Utils.EncodeInteger(cp.Doc.GetProperty(rnPageNumber, "1"));
     int setPageNumber = cp.Utils.EncodeInteger(  cp.Doc.GetProperty(rnSetPageNumber,""));
     if (setPageNumber!=0)
     {
         pageNumber = setPageNumber;
     }
     if (pageNumber==0)
     {
         pageNumber=1;
     }
     return pageNumber;
 }
Exemple #6
0
        public override int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightnow, applicationClass application)
        {
            int nextFormId = srcFormId;

            try
            {
                string button;
                CPCSBaseClass cs = cp.CSNew();

                // ajax routines return a different name for button

                button = cp.Doc.GetText("ajaxButton");

                if (button == "")
                    {
                        button = cp.Doc.GetText(commonModule.rnButton);
                    }

                if (button == commonModule.buttonFinish)
                    {
                        // process the form
                        application.completed = true;
                        application.changed = true;
                    }

                // determine the next form

                switch (button)
                {
                    case commonModule.buttonPrevious:
                        //
                        nextFormId = commonModule.formIdTwo;
                        break;
                    case commonModule.buttonFinish:
                        //
                        nextFormId = commonModule.formIdFour;
                        break;
                }

            }
            catch (Exception ex)
            {
                cp.Site.ErrorReport(ex, "processForm");
            }

            return nextFormId;
        }
Exemple #7
0
        public override int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightnow, applicationClass application)
        {
            int nextFormId = srcFormId;

            try
            {
                string button;
                CPCSBaseClass cs = cp.CSNew();

                // ajax routines return a different name for button

                button = cp.Doc.GetText("ajaxButton");

                if (button == "")
                {
                    button = cp.Doc.GetText(commonModule.rnButton);
                }

                if ((button == commonModule.buttonSave) | (button == commonModule.buttonOK))
                {
                    // process the form

                }

                // determine the next form

                switch (button)
                {
                    case commonModule.buttonRestart:
                        //
                        nextFormId = commonModule.formIdOne;
                        break;
                }

            }
            catch (Exception ex)
            {
                cp.Site.ErrorReport(ex, "processForm");
            }

            return nextFormId;
        }
 //
 //=========================================================================
 //  get the field value, from cs if ok, else from stream
 //=========================================================================
 //
 public static string getFormField(CPBaseClass cp, CPCSBaseClass cs, string fieldName, string requestName)
 {
     string returnValue= "";
     try
     {
         if (cp.Doc.IsProperty(requestName))
         {
             returnValue = cp.Doc.GetText(requestName, "");
         }
         else if (cs.OK())
         {
             returnValue = cs.GetText(fieldName);
         }
     }
     catch (Exception ex)
     {
         cp.Site.ErrorReport(ex, "Unexpected Error in getFormField");
     }
     return returnValue;
 }
Exemple #9
0
        //
        // execute method is the only public
        //
        public override object Execute(CPBaseClass cp)
        {
            string returnHtml = "";
            try
            {
                string body = "";
                string rqs = cp.Doc.RefreshQueryString;
                formHandlerClass formHandler = new formHandlerClass();

                cp.Doc.SetProperty("multiformAjaxCsFrameRqs", rqs);
                body = formHandler.Execute(cp).ToString();

                cp.Doc.AddHeadJavascript("var multiformAjaxCsFrameRqs='" + rqs + "';");

                returnHtml = cp.Html.div(body,"","", "multiFormAjaxFrame");
            }
            catch (Exception ex)
            {
                cp.Site.ErrorReport("There was a unexpected exception, " + ex.ToString());
                returnHtml = "Visual Studio add-on assembly - error response";
            }
            return returnHtml;
        }
Exemple #10
0
 //
 //
 //
 private string encodeHtml( CPBaseClass cp, string source)
 {
     string returnValue = source;
     try
     {
         if (source != "")
         {
             returnValue = cp.Utils.EncodeHTML(source);
         }
     }
     catch (Exception ex)
     {
         cp.Site.ErrorReport(ex, "encodeHtml Trap");
     }
     return returnValue;
 }
Exemple #11
0
        //
        // ===============================================================================================
        // get Login
        // ===============================================================================================
        //
        private string getLogin(CPBaseClass cp, int formId, int forumId, int threadId )
        {
            //string copy = "";
            string qs = "";
            string rqs = cp.Doc.RefreshQueryString;
            string s = "<p>Login Form</p>";
            int loginAddonId;
            string loginForm;
            //
            rqs = cp.Utils.ModifyQueryString(rqs, rnFormId, "", false);
            rqs = cp.Utils.ModifyQueryString(rqs, rnForumId, "", false);
            rqs = cp.Utils.ModifyQueryString(rqs, rnThreadId, "", false);
            rqs = cp.Utils.ModifyQueryString(rqs, rnIntercept, "", false);
            //
            try
            {
                if (cp.Utils.EncodeBoolean(cp.Doc.GetProperty("register", "")))
                {
                    s = getRegister(cp, formIdThreadList, forumId, 0);
                }
                else
                {

                    CPBlockBaseClass block = cp.BlockNew();
                    //
                    block.OpenLayout("forums - login view");
                    ////
                    //copy = "<a href=\"?" + qs + "\">Forums</a>";
                    //qs = cp.Utils.ModifyQueryString(qs, rnForumId, forumId.ToString(), true);
                    //copy += "&nbsp;�&nbsp;<a href=\"?" + qs + "\">" + forumName + "</a>";
                    //qs = cp.Utils.ModifyQueryString(qs, rnForumId, "", true);
                    //qs = cp.Utils.ModifyQueryString(qs, rnThreadId, threadId.ToString(), true);
                    //copy += "&nbsp;�&nbsp;<a href=\"?" + qs + "\">" + threadName + "</a>";
                    ////block.SetInner(".foBreadCrumb", copy);
                    ////
                    //
                    // if the send password for was submitted, replace the message
                    //
                    if (cp.Doc.GetProperty(rnIntercept, "") == "password")
                    {
                        block.SetInner(".foLoginMessage", cp.UserError.GetList());
                        //if (cp.UserError.OK())
                        //{
                        //}
                        //else
                        //{
                        //    block.SetInner(".foLoginMessage", "<p>Your username and passwordTo contribute to the forum you must log in. If you do not have an account, please use the register link below.</p>");
                        //}
                    }
                    loginAddonId = cp.Site.GetInteger("LOGIN PAGE ADDONID", "0");
                    if (loginAddonId != 0)
                    {
                        loginForm = cp.Utils.ExecuteAddon(loginAddonId.ToString());
                        if (loginForm == "")
                        {
                            cp.Response.Redirect("?" + cp.Doc.RefreshQueryString + "#");
                        }
                        else
                        {
                            block.SetInner("#foLoginPasswordCell", loginForm);
                        }
                    }
                    qs = rqs;
                    qs = cp.Utils.ModifyQueryString(qs, rnFormId, formIdForumList.ToString(), true);
                    qs = cp.Utils.ModifyQueryString(qs, rnForumId, "", false);
                    block.SetOuter(".foCancelButton", "<a href=\"?" + qs + "\">Cancel</a>");
                    s = block.GetHtml();
                    qs = rqs;
                    qs = cp.Utils.ModifyQueryString(qs, rnFormId, formId.ToString(), true);
                    qs = cp.Utils.ModifyQueryString(qs, rnThreadId, threadId.ToString(), true);
                    qs = cp.Utils.ModifyQueryString(qs, rnForumId, forumId.ToString(), true);
                    s = s.Replace("$formAction$", "?" + qs + "&requestBinary=1");
                    qs = cp.Utils.ModifyQueryString(qs, "register", "true", true);
                    s = s.Replace("$registerLink$", "?" + qs);
                }
                //
                //
                //
            }
            catch (Exception e)
            {
                cp.Site.ErrorReport(e, "method Trap");
            }
            return s;
        }
 //
 //====================================================================================================
 public static PageContentModel @add(CPBaseClass cp)
 {
     return(@add <PageContentModel>(cp));
 }
Exemple #13
0
 //
 // ===============================================================================================
 // process Thread List
 // ===============================================================================================
 //
 private int processThreadList(CPBaseClass cp)
 {
     return formIdThreadList;
 }
Exemple #14
0
 //
 //====================================================================================================
 public static _blankModel create(CPBaseClass cp, string recordGuid)
 {
     return(create <_blankModel>(cp, recordGuid));
 }
Exemple #15
0
 //
 //====================================================================================================
 public static void delete(CPBaseClass cp, int recordId)
 {
     delete <_blankModel>(cp, recordId);
 }
Exemple #16
0
 //
 // ===============================================================================
 // handle errors for this class
 // ===============================================================================
 //
 private void errorReport(CPBaseClass cp, Exception ex, string method)
 {
     cp.Site.ErrorReport(ex, "error in addonTemplateCs2005.blankClass.getForm");
 }
Exemple #17
0
 //
 //====================================================================================================
 public static List <_blankModel> createList(CPBaseClass cp, string sqlCriteria, string sqlOrderBy = "id")
 {
     return(createList <_blankModel>(cp, sqlCriteria, sqlOrderBy));
 }
Exemple #18
0
        //
        //-------------------------------------------------
        // getResult
        //-------------------------------------------------
        //
        public string getHtml(CPBaseClass cp)
        {
            string result  = "";
            string row     = "";
            string rowList = "";
            int    rowPtr  = 0;
            int    colPtr  = 0;
            string styleClass;
            string content;
            string userErrors;
            string returnHeadJs = "";
            string jsonData     = "";
            string jsonRow      = "";
            string chartHtmlId  = "afwChart" + GnericController.getRandomHtmlId(cp);
            string captionColumn;
            //string clickLink;
            string jsonRowList = "";

            //
            // add user errors
            //
            userErrors = cp.Utils.EncodeText(cp.UserError.GetList());
            if (userErrors != "")
            {
                warning = userErrors;
            }
            //
            // headers
            //
            jsonData += Constants.cr + "data.addColumn('date', 'Date');";
            rowList   = "";
            if (gridIncludesCaptionColumn)
            {
                rowList += Constants.cr + "<th>" + localXAxisCaption + "</th>";
            }
            for (colPtr = 0; colPtr <= columnMax; colPtr++)
            {
                styleClass = columns[colPtr].captionClass;
                if (styleClass != "")
                {
                    styleClass = " class=\"" + styleClass + "\"";
                }
                content = columns[colPtr].caption;
                if (content == "")
                {
                    content = "&nbsp;";
                }
                rowList  += Constants.cr + "<th" + styleClass + ">" + content + "</th>";
                jsonData += Constants.cr + "data.addColumn('number', '" + content + "');";
            }
            if (gridIncludeHeaderRow)
            {
                result += ""
                          + Constants.cr + "<thead>"
                          + Constants.cr2 + "<tr>"
                          + indent(indent(rowList))
                          + Constants.cr2 + "</tr>"
                          + Constants.cr + "</thead>"
                          + "";
            }
            //
            // body
            //
            rowList     = "";
            jsonRowList = "";
            if (localIsEmptyReport)
            {
                styleClass = columns[0].cellClass;
                if (styleClass != "")
                {
                    styleClass = " class=\"" + styleClass + "\"";
                }
                row      = Constants.cr + "<td style=\"text-align:left\" " + styleClass + " colspan=\"" + (columnMax + 1) + "\">[empty]</td>";
                rowList += ""
                           + Constants.cr + "<tr>"
                           + indent(row)
                           + Constants.cr + "</tr>";
            }
            else
            {
                for (rowPtr = 0; rowPtr <= rowCnt; rowPtr++)
                {
                    row = "";
                    //
                    // first column is the date
                    //
                    DateTime rowDate;
                    rowDate = rows[rowPtr].date;
                    jsonRow = "new Date(" + rowDate.Year + "," + (rowDate.Month - 1) + "," + rowDate.Day + ")";
                    if (gridIncludesCaptionColumn)
                    {
                        captionColumn = rows[rowPtr].date.ToShortDateString();
                        if (captionColumn == "")
                        {
                            captionColumn = "&nbsp;";
                        }
                        row += Constants.cr + "<th class=\"" + rows[rowPtr].captionClass + "\">" + captionColumn + "</th>";
                    }
                    //
                    // additional columns are numeric
                    //
                    for (colPtr = 0; colPtr <= columnMax; colPtr++)
                    {
                        styleClass = columns[colPtr].cellClass;
                        if (styleClass != "")
                        {
                            styleClass = " class=\"" + styleClass + "\"";
                        }
                        row     += Constants.cr + "<td" + styleClass + ">" + chartData[rowPtr, colPtr].yValue + "</td>";
                        jsonRow += "," + chartData[rowPtr, colPtr].yValue;
                    }
                    jsonRowList += "," + Constants.cr + "[" + jsonRow + "]";
                    if (rowPtr % 2 == 0)
                    {
                        styleClass = "";
                    }
                    else
                    {
                        styleClass = " class=\"afwOdd\"";
                    }
                    rowList += ""
                               + Constants.cr + "<tr" + styleClass + ">"
                               + indent(row)
                               + Constants.cr + "</tr>";
                }
            }
            if (jsonRowList != "")
            {
                jsonData += Constants.cr + "data.addRows([" + jsonRowList.Substring(1) + "]);";
            }
            result += ""
                      + Constants.cr + "<tbody>"
                      + indent(rowList)
                      + Constants.cr + "</tbody>"
                      + "";
            result = ""
                     + Constants.cr + "<table class=\"afwListReportTableCollapse\">"
                     + indent(result)
                     + Constants.cr + "</table>";
            result = ""
                     + Constants.cr + "<div class=\"afwGridCon\">"
                     + indent(result)
                     + Constants.cr + "</div>";
            //
            // chart
            //
            result = ""
                     + Constants.cr + "<div id=\"" + chartHtmlId + "\" class=\"afwChartCon\" style=\"width:" + localChartWidth.ToString() + "px; height:" + localChartHeight.ToString() + "px;\"></div>"
                     + result;
            //
            // reportCon
            //
            result = ""
                     + Constants.cr + "<div class=\"afwReportCon\">"
                     + indent(result)
                     + Constants.cr + "</div>";
            //
            if (localHtmlLeftOfTable != "")
            {
                result = ""
                         + Constants.cr + "<div class=\"afwLeftSideHtml\">"
                         + indent(localHtmlLeftOfTable)
                         + Constants.cr + "</div>"
                         + Constants.cr + "<div class=\"afwRightSideHtml\">"
                         + indent(result)
                         + Constants.cr + "</div>"
                         + Constants.cr + "<div style=\"clear:both\"></div>"
                         + "";
            }
            if (localHtmlBeforeTable != "")
            {
                result = ""
                         + localHtmlBeforeTable
                         + result
                         + "";
            }
            if (localHtmlAfterTable != "")
            {
                result = ""
                         + result
                         + localHtmlAfterTable
                         + "";
            }
            //
            // headers
            //
            if (localDescription != "")
            {
                result = Constants.cr + "<p id=\"afwDescription\">" + localDescription + "</p>" + result;
            }
            if (localWarning != "")
            {
                result = Constants.cr + "<div id=\"afwWarning\">" + localWarning + "</div>" + result;
            }
            if (localTitle != "")
            {
                result = Constants.cr + "<h2 id=\"afwTitle\">" + localTitle + "</h2>" + result;
            }
            //
            // add form
            //
            if (localIncludeForm)
            {
                if (localButtonList != "")
                {
                    localButtonList = ""
                                      + Constants.cr + "<div class=\"afwButtonCon\">"
                                      + indent(localButtonList)
                                      + Constants.cr + "</div>";
                }
                result = Constants.cr + cp.Html.Form(localButtonList + result + localButtonList + localHiddenList, "", "", "", localFormActionQueryString, "");
                //body = ""
                //    + cr + cp.Html.Form( localButtonList + body + localHiddenList )
                //    + cr + "<form action=\"" + localFormAction + "\" method=\"post\" enctype=\"MULTIPART/FORM-DATA\">"
                //    + indent(localButtonList + body + localHiddenList)
                //    + cr + "</form>";
            }
            if (_includeBodyPadding)
            {
                result = cp.Html.div(result, "", "afwBodyPad", "");
            }
            ;
            if (_includeBodyColor)
            {
                result = cp.Html.div(result, "", "afwBodyColor", "");
            }
            ;
            //
            // if outer container, add styles and javascript
            //
            if (localIsOuterContainer)
            {
                cp.Doc.AddHeadJavascript(Properties.Resources.javascript);
                cp.Doc.AddHeadStyle(Properties.Resources.styles);
                result = ""
                         + Constants.cr + "<div id=\"afw\">"
                         + indent(result)
                         + Constants.cr + "</div>";
            }
            returnHeadJs += ""
                            + Constants.cr + "function drawChart() {"
                            + Constants.cr + "var data = new google.visualization.DataTable();"
                            + jsonData
                            + Constants.cr + "var options={title:'" + localTitle + "',hAxis:{title:'" + localXAxisCaption + "',titleTextStyle:{color: 'red'}},displayAnnotations: true};"
                            + Constants.cr + "var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('" + chartHtmlId + "'));"
                            + Constants.cr + "chart.draw(data, options);"
                            + Constants.cr + "}"
                            + Constants.cr + "google.load(\"visualization\", \"1\", {packages:[\"annotatedtimeline\"]});"
                            + Constants.cr + "jQuery(document).ready(drawChart);"
                            + Constants.cr + "//google.setOnLoadCallback(drawChart);"
                            + "";
            result      += "<script Language=\"JavaScript\" type=\"text/javascript\">" + returnHeadJs + "</script>";
            returnHeadJs = "";
            cp.Doc.AddHeadJavascript(returnHeadJs);
            //
            // -- set the optional title of the portal subnav
            if (!string.IsNullOrEmpty(portalSubNavTitle))
            {
                cp.Doc.SetProperty("portalSubNavTitle", portalSubNavTitle);
            }
            return(result);
        }
Exemple #19
0
 //<------ replace this with a list all model fields not part of the base model
 //
 //====================================================================================================
 public static _blankModel @add(CPBaseClass cp)
 {
     return(@add <_blankModel>(cp));
 }
Exemple #20
0
 //
 //====================================================================================================
 public static int getRecordId(CPBaseClass cp, string ccGuid)
 {
     return(baseModel.getRecordId <_blankModel>(cp, ccGuid));
 }
Exemple #21
0
 //
 //====================================================================================================
 public static string getRecordName(CPBaseClass cp, string ccGuid)
 {
     return(baseModel.getRecordName <_blankModel>(cp, ccGuid));
 }
Exemple #22
0
 //
 //====================================================================================================
 public static string getRecordName(CPBaseClass cp, int recordId)
 {
     return(baseModel.getRecordName <_blankModel>(cp, recordId));
 }
Exemple #23
0
 //
 // ===============================================================================================
 // get New Post
 // ===============================================================================================
 //
 private string getNewPost(CPBaseClass cp, int threadId)
 {
     string s = "";
     string forumName = "";
     //string forumCopy = "";
     string qs;
     string rqs = cp.Doc.RefreshQueryString;
     string zs = "";
     CPCSBaseClass cs = cp.CSNew();
     //string company = "";
     string sql;
     string copy;
     int forumId = 0;
     string threadName = "";
     string threadCopy = "";
     Random random = new Random();
     //
     rqs = cp.Utils.ModifyQueryString(rqs, rnFormId, "", false);
     rqs = cp.Utils.ModifyQueryString(rqs, rnForumId, "", false);
     rqs = cp.Utils.ModifyQueryString(rqs, rnThreadId, "", false);
     rqs = cp.Utils.ModifyQueryString(rqs, rnIntercept, "", false);
     //
     try
     {
         CPBlockBaseClass block = cp.BlockNew();
         //
         sql = "select f.id as forumId,f.name as forumName, t.name as threadName, t.copy as threadCopy from ccforumThreads t left join ccForums f on f.id=t.forumId where t.id=" + threadId;
         cs.OpenSQL( sql );
         if (cs.OK())
         {
             forumName = cs.GetText("forumName");
             forumId = cs.GetInteger("forumId");
             threadName = cs.GetText("threadName");
             threadCopy = cs.GetText("threadCopy");
         }
         cs.Close();
         //
         block.OpenLayout("forums - new post view");
         qs = rqs;
         //
         copy = "<a href=\"?" + qs + "\">Forums</a>";
         qs = cp.Utils.ModifyQueryString(qs, rnForumId, forumId.ToString(), true);
         copy += "&nbsp;�&nbsp;<a href=\"?" + qs + "\">" + forumName + "</a>";
         qs = cp.Utils.ModifyQueryString(qs, rnForumId, "", true);
         qs = cp.Utils.ModifyQueryString(qs, rnThreadId, threadId.ToString(), true);
         copy += "&nbsp;�&nbsp;<a href=\"?" + qs + "\">" + threadName + "</a>";
         block.SetInner(".foBreadCrumb", copy );
         //
         block.SetInner(".foThreadTitle", threadName);
         block.SetInner(".foThreadCopy", threadCopy);
         block.SetInner(".foHeadThreadName", threadName);
         block.SetInner(".foBodyTitleThreadName", threadName);
         block.SetInner(".foInputName", cp.User.Name);
         string testString = cp.Doc.GetProperty("foTextAreaPost", zs);
         testString = encodeHtml(cp,testString);
         // - for CP that returns null if source is empty -- testString = cp.Utils.encodeHtml(testString);
         block.SetInner(".foTextAreaPost", testString);
         block.SetInner(".foInputFile", "<input type=\"file\" name=\"foInputFile\">");
         block.SetOuter(".foSourceForm", cp.Html.Hidden(rnSourceForm, formIdNewPost.ToString(), "", ""));
         //
         int createKey = random.Next(0, 2147483647);
         block.SetOuter(".foCreateKey", cp.Html.Hidden(rnCreateKey, createKey.ToString(), "", ""));
         //
         s = block.GetHtml();
         //
         qs = rqs;
         qs = cp.Utils.ModifyQueryString(qs, rnThreadId, threadId.ToString(), true);
         s = s.Replace("$formAction$", "?" + qs + "&requestBinary=1");
     }
     catch (Exception e)
     {
         cp.Site.ErrorReport(e, "getPostList Trap");
     }
     return s;
 }
Exemple #24
0
        //
        // ===============================================================================
        // get Form
        // ===============================================================================
        //
        public string getForm(CPBaseClass cp, int dstFormId, string rqs, DateTime rightNow, ref int appId)
        {
            string returnHtml = "";

            try
            {
                string           form     = "";
                CPBlockBaseClass layout   = cp.BlockNew();
                string           returnJs = "";
                CPCSBaseClass    cs       = cp.CSNew();
                //
                // open layout, grab form, add hiddens, replace back into layout
                //
                layout.OpenLayout("sample layout");
                if (layout.GetHtml() == "")
                {
                    layout.Load(sampleLayout);
                    cs.Insert("Layouts");
                    cs.SetField("name", "sample layout");
                    cs.SetField("layout", layout.GetHtml());
                    cs.Close();
                }
                //
                form  = layout.GetInner("#myForm");
                form += cp.Html.Hidden(statics.rnSrcFormId, dstFormId.ToString(), "", "");
                form += cp.Html.Hidden(statics.rnAppId, appId.ToString(), "", "");
                if (!cp.UserError.OK())
                {
                    form = cp.Html.div(cp.UserError.GetList(), "", "", "") + form;
                }
                form = cp.Html.Form(form, "", "", "", "", "");
                layout.SetOuter("#myForm", form);
                //
                // Populate the layout
                // attempt to open the application record. It is created in the process so this may fail.
                //      if not cs.OK(), the getFormField will return blank.
                //
                cs.Open("people", "id=" + cp.User.Id.ToString(), "", true, "", 1, 1);
                if (true)
                {
                    //
                    // either server-side
                    //
                    layout.SetOuter(".myInputRow input", cp.Html.InputText("name", statics.getFormField(cp, cs, "name"), "", "", false, "", ""));
                }
                else
                {
                    //
                    // or client-side
                    //
                    returnJs += statics.cr + "jQuery('.myInputRow myLabel').html('" + statics.getFormField(cp, cs, "name") + "')";
                }
                cs.Close();
                //
                // apply any javascript to doc
                //
                if (returnJs != "")
                {
                    cp.Doc.AddHeadJavascript("jQuery(document).ready(function(){" + returnJs + statics.cr + "});");
                }
                //
                // return converted layout
                //
                returnHtml = layout.GetHtml();
            }
            catch (Exception ex)
            {
                errorReport(cp, ex, "getForm");
            }
            return(returnHtml);
        }
 //
 //-------------------------------------------------
 // getResult
 //-------------------------------------------------
 //
 public string getHtml(CPBaseClass cp)
 {
     string returnHtml = "";
     string row = "";
     string rowList = "";
     int rowPtr = 0;
     int colPtr = 0;
     string styleClass;
     string content;
     string userErrors;
     string returnHeadJs = "";
     string jsonData = "";
     string jsonRow = "";
     string chartHtmlId = "afwChart" + (new Random()).Next(10000, 99999);
     string captionColumn;
     string clickLink;
     //
     // add user errors
     //
     userErrors = cp.Utils.EncodeText(  cp.UserError.GetList());
     if ( userErrors!="")
     {
         warning = userErrors;
     }
     //
     // headers
     //
     jsonRow = "'" + localXAxisCaption + "'";
     rowList = "";
     if (gridIncludesCaptionColumn)
     {
         rowList += cr + "<th>" + localXAxisCaption + "</th>";
     }
     for (colPtr = 0; colPtr <= columnMax; colPtr++)
     {
         styleClass = columns[colPtr].captionClass;
         if (styleClass != "")
         {
             styleClass = " class=\"" + styleClass + "\"";
         }
         content = columns[colPtr].caption;
         if (content == "")
         {
             content = "&nbsp;";
         }
         rowList += cr + "<th" + styleClass + ">" + content + "</th>";
         jsonRow += ",'" + content + "'";
     }
     jsonData = cr + "[" + jsonRow + "]";
     if (gridIncludeHeaderRow)
     {
         returnHtml += ""
             + cr + "<thead>"
             + cr2 + "<tr>"
             + indent(indent(rowList))
             + cr2 + "</tr>"
             + cr + "</thead>"
             + "";
     }
     //
     // body
     //
     rowList = "";
     if (localIsEmptyReport)
     {
         styleClass = columns[0].cellClass;
         if (styleClass != "")
         {
             styleClass = " class=\"" + styleClass + "\"";
         }
         row = cr + "<td style=\"text-align:left\" " + styleClass + " colspan=\"" + (columnMax+1) + "\">[empty]</td>";
         rowList += ""
             + cr + "<tr>"
             + indent(row)
             + cr + "</tr>";
     }
     else
     {
         for (rowPtr = 0; rowPtr <= rowCnt; rowPtr++)
         {
             row = "";
             //
             // first column is a text caption
             //
             jsonRow = "'" + rows[rowPtr].caption + "'";
             if (gridIncludesCaptionColumn)
             {
                 captionColumn = rows[rowPtr].caption;
                 if (captionColumn=="")
                 {
                     captionColumn = "&nbsp;";
                 }
                 row += cr + "<th class=\"" + rows[rowPtr].captionClass + "\">" + captionColumn + "</th>";
             }
             //
             // additional columns are numeric
             //
             for (colPtr = 0; colPtr <= columnMax; colPtr++)
             {
                 styleClass = columns[colPtr].cellClass;
                 if (styleClass != "")
                 {
                     styleClass = " class=\"" + styleClass + "\"";
                 }
                 clickLink = barData[rowPtr, colPtr].clickLink;
                 if (clickLink == "")
                 {
                     row += cr + "<td" + styleClass + ">" + barData[rowPtr, colPtr].height + "</td>";
                 }
                 else
                 {
                     row += cr + "<td" + styleClass + " onclick=\"location.href='"+clickLink+"';\" style=\"cursor:pointer;\">" + barData[rowPtr, colPtr].height + "</td>";
                 }
                 jsonRow += "," + barData[rowPtr, colPtr].height;
             }
             jsonData += cr + ",[" + jsonRow + "]";
             if (rowPtr % 2 == 0)
             {
                 styleClass = "";
             }
             else
             {
                 styleClass = " class=\"afwOdd\"";
             }
             rowList += ""
                 + cr + "<tr" + styleClass + ">"
                 + indent(row)
                 + cr + "</tr>";
         }
     }
     returnHtml += ""
         + cr + "<tbody>"
         + indent(rowList)
         + cr + "</tbody>"
         + "";
     returnHtml = ""
         + cr + "<table class=\"afwListReportTableCollapse\">"
         + indent(returnHtml)
         + cr + "</table>";
     returnHtml = ""
         + cr + "<div class=\"afwGridCon\">"
         + indent(returnHtml)
         + cr + "</div>";
     //
     // bar chart
     //
     returnHtml = cr + "<div id=\"" + chartHtmlId + "\" class=\"afwChartCon\" style=\"width:" + localChartWidth.ToString() + "px; height:" + localChartHeight.ToString() + "px;\"></div>" + returnHtml;
     //
     if (localHtmlLeftOfTable != "")
     {
         returnHtml = ""
             + cr + "<div class=\"afwLeftSideHtml\">"
             + indent(localHtmlLeftOfTable)
             + cr + "</div>"
             + cr + "<div class=\"afwRightSideHtml\">"
             + indent(returnHtml)
             + cr + "</div>"
             + cr + "<div style=\"clear:both\"></div>"
             + "";
     }
     if (localHtmlBeforeTable != "")
     {
         returnHtml = ""
             + localHtmlBeforeTable
             + returnHtml
             + "";
     }
     if (localHtmlAfterTable != "")
     {
         returnHtml = ""
             + returnHtml
             + localHtmlAfterTable
             + "";
     }
     //
     // headers
     //
     if (localDescription != "")
     {
         returnHtml = cr + "<p id=\"afwDescription\">" + localDescription + "</p>" + returnHtml;
     }
     if (localWarning != "")
     {
         returnHtml = cr + "<div id=\"afwWarning\">" + localWarning + "</div>" + returnHtml;
     }
     if (localTitle != "")
     {
         returnHtml = cr + "<h2 id=\"afwTitle\">" + localTitle + "</h2>" + returnHtml;
     }
     //
     // add form
     //
     if (localIncludeForm)
     {
         if (localButtonList != "")
         {
             localButtonList = ""
                 + cr + "<div class=\"afwButtonCon\">"
                 + indent(localButtonList)
                 + cr + "</div>";
         }
         returnHtml = cr + cp.Html.Form(localButtonList + returnHtml + localButtonList + localHiddenList, "", "", "", localFormActionQueryString, "");
         //body = ""
         //    + cr + cp.Html.Form( localButtonList + body + localHiddenList )
         //    + cr + "<form action=\"" + localFormAction + "\" method=\"post\" enctype=\"MULTIPART/FORM-DATA\">"
         //    + indent(localButtonList + body + localHiddenList)
         //    + cr + "</form>";
     }
     returnHtml = cp.Html.div(returnHtml, "", "afwBodyPad", "");
     returnHtml = cp.Html.div(returnHtml, "", "afwBodyColor", "");
     //
     // if outer container, add styles and javascript
     //
     if (localIsOuterContainer)
     {
         cp.Doc.AddHeadJavascript(Properties.Resources.javascript);
         cp.Doc.AddHeadStyle(Properties.Resources.styles);
         returnHtml = ""
             + cr + "<div id=\"afw\">"
             + indent(returnHtml)
             + cr + "</div>";
     }
     returnHeadJs += ""
         + cr + "google.load(\"visualization\", \"1\", {packages:[\"corechart\"]});"
         + cr + "google.setOnLoadCallback(drawChart);"
         + cr + "function drawChart() {"
         + cr + "var data = google.visualization.arrayToDataTable([" + jsonData + "]);"
         + cr + "var options={title:'" + localTitle + "',hAxis:{title:'" + localXAxisCaption + "',titleTextStyle:{color: 'red'}}};"
         + cr + "var chart = new google.visualization.ColumnChart(document.getElementById('" + chartHtmlId + "'));"
         + cr + "chart.draw(data, options);"
         + cr + "}";
     returnHtml += "<script Language=\"JavaScript\" type=\"text/javascript\">" + returnHeadJs + "</script>";
     returnHeadJs = "";
     //cp.Doc.AddHeadJavascript(returnHeadJs);
     return returnHtml;
 }
 //
 // ===============================================================================
 // handle errors for this class
 // ===============================================================================
 //
 private void errorReport(CPBaseClass cp, Exception ex, string method)
 {
     cp.Site.ErrorReport(ex, "error in addonSampleCs2005r4.addonClass.getForm");
 }
Exemple #27
0
 //
 //====================================================================================================
 public void save(CPBaseClass cp)
 {
     base.save(cp);
 }
 //
 // ====================================================================================================
 /// <summary>
 ///         ''' convert string into a style "background-image: url(backgroundImage)
 ///         ''' </summary>
 ///         ''' <param name="backgroundImage"></param>
 ///         ''' <returns></returns>
 public static string encodeStyleBackgroundImage(CPBaseClass cp, string backgroundImage)
 {
     return(string.IsNullOrWhiteSpace(backgroundImage) ? string.Empty : "background-image: url('" + cp.Site.FilePath + backgroundImage + "');");
 }
 //
 // ===============================================================================
 // handle errors for this class
 // ===============================================================================
 //
 private void errorReport(CPBaseClass cp, Exception ex, string method)
 {
     cp.Site.ErrorReport(ex, "error in addonTemplateCs2005.blankClass.getForm");
 }
            //
            public override object Execute(CPBaseClass cp)
            {
                try {
                    //
                    // -- create output form

                    var tool = new PortalFramework.ToolSimpleClass();
                    //var form = cp.AdminUI.NewToolForm();
                    if (!string.IsNullOrEmpty(cp.Doc.GetText("button")))
                    {
                        //
                        // -- process button click
                        if (cp.Doc.GetText("button").Equals(buttonCancel))
                        {
                            cp.Response.Redirect("?");
                            return(string.Empty);
                        }
                        string uploadFile       = "";
                        string uploadFolderPath = cp.TempFiles.CreateUniqueFolder();
                        if (!cp.TempFiles.SaveUpload(uploadFormInputName, uploadFolderPath, ref uploadFile))
                        {
                            //
                            // -- upload failed
                            tool.failMessage = "Upload failed";
                        }
                        else
                        {
                            var userMessageList = new List <string>();
                            Contensive.HtmlImport.ImporttypeEnum importTypeId = (Contensive.HtmlImport.ImporttypeEnum)cp.Doc.GetInteger("importTypeId");
                            if (!Contensive.HtmlImport.Controllers.ImportController.processImportFile(cp, uploadFolderPath + uploadFile, importTypeId, cp.Doc.GetInteger("layoutId"), cp.Doc.GetInteger("pageTemplateId"), cp.Doc.GetInteger("emailTemplateId"), cp.Doc.GetInteger("emailId"), ref userMessageList))
                            {
                                tool.failMessage = "Error<br><br>" + string.Join("<br>", userMessageList);
                            }
                            else
                            {
                                tool.successMessage = "Success<br><br>" + string.Join("<br>", userMessageList);
                            }
                        }
                        cp.TempFiles.DeleteFolder(uploadFolderPath);
                    }
                    //
                    // -- populate output form
                    tool.title       = "Html Importer";
                    tool.description = cp.Html5.P("This tool uploads and imports html files and converts the html to Mustache-format compatible layouts, templates and addons. See reference at the end of this document.");
                    {
                        var importTypeList = new List <string>()
                        {
                            "Import Destination set in Html File", "Layout For Addon", "Page Template", "Email Template", "Email"
                        };
                        string editRow = cp.AdminUI.GetEditRow("Select Import Type", cp.AdminUI.GetLookupListEditor("importTypeId", importTypeList, 1, "hiImportTypeid"),
                                                               "Select the type of html you are importing.", "");
                        tool.body += cp.Html5.Div(editRow, "", "hiImportType");
                    }
                    {
                        //form.Body += cp.AdminUI.GetEditRow("Select Layout", cp.AdminUI.GetLookupContentEditor("layoutId", "Layouts", cp.Doc.GetInteger("layoutId")), "(Optional) Select the Layout you want to populate with this html document. Leave blank if the target is set in a meta tag of the html document.", "hiSelectLayout");
                        string editRow = cp.AdminUI.GetEditRow("Select Layout", cp.AdminUI.GetLookupContentEditor("layoutId", "Layouts", cp.Doc.GetInteger("layoutId")),
                                                               "Select the Layout you want to populate with this html document.", "hiSelectLayout");
                        tool.body += cp.Html5.Div(editRow, "", "hiSelectLayoutId");
                    }
                    {
                        string editRow = cp.AdminUI.GetEditRow("Select Page Template", cp.AdminUI.GetLookupContentEditor("pageTemplateId", "Page Templates", cp.Doc.GetInteger("pagetemplateId")),
                                                               "Select the Page Template you want to populate with this html document. " +
                                                               "Page templates import just the html body. Head metadata and associated resources have to be manually configured.", "hiSelectPageTemplate");
                        tool.body += cp.Html5.Div(editRow, "", "hiSelectPageTemplateId");
                    }
                    {
                        string editRow = cp.AdminUI.GetEditRow("Select Email Template", cp.AdminUI.GetLookupContentEditor("emailTemplateId", "Email Templates", cp.Doc.GetInteger("emailtemplateId")),
                                                               "Select the Email Template you want to populate with this html document. " +
                                                               "Email templates import the entire html document including the head tag elements. If they are missing the system will create them.", "hiSelectPageTemplate");
                        tool.body += cp.Html5.Div(editRow, "", "hiSelectEmailTemplateId");
                    }
                    {
                        string editRow = cp.AdminUI.GetEditRow("Select Email", cp.AdminUI.GetLookupContentEditor("emailId", "Email", cp.Doc.GetInteger("emailId")),
                                                               "Select the Group, System or Conditional Email you want to populate with this html document. ", "hiSelectEmail");
                        tool.body += cp.Html5.Div(editRow, "", "hiSelectEmailId");
                    }

                    tool.body += cp.AdminUI.GetEditRow("Html Upload", cp.AdminUI.GetFileEditor(uploadFormInputName, ""), "Select the file you need to import. The file may include directives the determine the save location and Mustache replacements.");

                    //
                    tool.footer += cp.Html5.H4("Instructions");
                    tool.footer += cp.Html5.Div(
                        cp.Html5.P("Use this tool to upload an html file for use as a page template or layout. Page templates are used for web pages. Layouts are generic records used by add-ons to construct forms.")
                        + cp.Html5.P("Upload an html file to create or update a template or layout from that file. Upload a zip file and the files will be unzipped and all non-html files will be copied to the websites root www directory. All html files wil be imported.")
                        , "ml-4"
                        );
                    //
                    tool.footer += cp.Html5.H5("Import Type");
                    tool.footer += cp.Html5.Div(
                        cp.Html5.P("Select the type of data being imported. There are two ways to set the destination, html meta tags or select manually.")
                        + cp.Html5.Ol(""
                                      + cp.Html5.Li("Meta Tag. Include in your html file a meta tag with name set to either 'layout' or 'template' and content set to the name of the record."
                                                    + "<pre>" + cp.Utils.EncodeHTML("<meta name=\"template\" content=\"One Column Template\">") + "</pre>"
                                                    + "<pre>" + cp.Utils.EncodeHTML("<meta name=\"layout\" content=\"Join Form\">") + "</pre>"
                                                    + "<pre>" + cp.Utils.EncodeHTML("<meta name=\"email\" content=\"Invitation Email\">") + "</pre>"
                                                    + "")
                                      + cp.Html5.Li("Manual Select. Select the template and/or layout on this form and the html will be saved to a record with the same name as the uploaded file.")
                                      )
                        , "ml-4"
                        );
                    //
                    tool.footer += cp.Html5.H5("data-mustache-variable");
                    {
                        string indent = "";
                        indent      += cp.Html5.P("Mustache is a popular templating scheme. You may choose to include mustache tags in your html directly in which case the html may not render well in a browser. You can alternativly choose to set special styles outlined here and the import tool will add the Mustache tags you indicate. Reference any of the many <a href=\"https://mustache.github.io/mustache.5.html\">Mustache references online</a>.");
                        tool.footer += cp.Html5.Div(indent, "ml-4");
                    }
                    tool.footer += cp.Html5.H5("Mustache Variable");
                    {
                        string sample = "";
                        sample += "<p>My name is <span data-mustache-variable=\"firstName\">Sample Name</span>.</p>";
                        sample += "\n<p>My name is <span>{{{firstName}}}</span>.</p>";
                        string indent = "";
                        indent      += cp.Html5.P("Replace the content of the html tag with a Mustache Basic tag.");
                        indent      += "<pre>" + cp.Utils.EncodeHTML(sample) + "</pre>";
                        tool.footer += cp.Html5.Div(indent, "ml-4");
                    }
                    //
                    tool.footer += cp.Html5.H5("data-mustache-section");
                    {
                        string sample = "";
                        sample += "<ul data-mustache-section=\"staff\">"
                                  + "\n\t<li data-mustache-variable=\"name\">Sample Name</li>"
                                  + "\n\t<li data-delete>Name To Skip</li>"
                                  + "\n</ul>"
                                  + "\n<ul>"
                                  + "\n\t{{#staff}}"
                                  + "\n\t<li class=\"\">{{name}}</li>"
                                  + "\n\t{{/staff}}"
                                  + "\n</ul>";
                        string indent = "";
                        indent      += cp.Html5.P("Add a Mustache Section around content to be removed or repeated. If the object property is false, null, or an empty list, the section is removed. If the value is true the section is included. If the value is a list the section is repeated for each item in the list.");
                        indent      += "<pre>" + cp.Utils.EncodeHTML(sample) + "</pre>";
                        tool.footer += cp.Html5.Div(indent, "ml-4");
                    }
                    //
                    tool.footer += cp.Html5.H5("data-mustache-inverted-section");
                    {
                        string indent = "";
                        indent += cp.Html5.P("Add a Mustache Inverted Section data attrbiute around content to be included if the object property value is false.");
                        indent += "<pre>"
                                  + cp.Utils.EncodeHTML(""
                                                        + "\n<div data-mustache-inverted-section=\"emptyList\">"
                                                        + "\n\t<p>No items were found.</p>"
                                                        + "\n</div>"
                                                        + "\n<div>"
                                                        + "\n\t{{^emptyList}}"
                                                        + "\n\t<p>No items were found.</p>"
                                                        + "\n\t{{/itemList}}"
                                                        + "\n</div>"
                                                        + "")
                                  + "</pre>";
                        tool.footer += cp.Html5.Div(indent, "ml-4");
                    }

                    tool.footer += cp.Html5.H5("data-mustache-value");
                    {
                        string sample = "";
                        sample += "<p>My example is <span value=\"0\" data-mustache-value=\"id\">content</span>.</p>";
                        sample += "\n<p>My example is <span value=\"{{id}}\">content</span>.</p>";
                        string indent = "";
                        indent      += cp.Html5.P("Replace the value of the html tag with a Mustache Value tag .");
                        indent      += "<pre>" + cp.Utils.EncodeHTML(sample) + "</pre>";
                        tool.footer += cp.Html5.Div(indent, "ml-4");
                    }
                    //
                    tool.footer += cp.Html5.H5("data-body");
                    {
                        string sample = "";
                        sample += "<body><span data-body>This content will be included without the span tag</span> and this copy will not be imported</body>";
                        sample += "\nThis content will be included without the span tag";
                        string indent = "";
                        indent      += cp.Html5.P("The data-body attribute is used to locate the html to be processed. Anything outside of this region will not be processed. If a data-body attribute is found, only the html within that element will be included. If no data-body is used, the content of the entire html body tag is imported.");
                        indent      += "<pre>" + cp.Utils.EncodeHTML(sample) + "</pre>";
                        tool.footer += cp.Html5.Div(indent, "ml-4");
                    }
                    //
                    tool.footer += cp.Html5.H5("data-layout");
                    {
                        string sample = "";
                        sample += "<body><span data-layout=\"New-Site-Header\">This content will be saved to the layout named 'New-Site-Header' without the span tag</span> and this copy will not be imported. If a tag includes both a data-delete and a data-layout, the innter content will be saved to a layout and deleted from the html.</body>";
                        sample += "\nThis content will be included without the span tag";
                        string indent = "";
                        indent      += cp.Html5.P("If a data-layout attribute is found, the html within that element will be saved to the named layout record.");
                        indent      += "<pre>" + cp.Utils.EncodeHTML(sample) + "</pre>";
                        tool.footer += cp.Html5.Div(indent, "ml-4");
                    }
                    //
                    tool.footer += cp.Html5.H5("data-href");
                    {
                        string sample = "";
                        sample += "<body><p><a href=\"MainMenu.html\" data-href=\"{{/mainmenu}}\">Click here to see the main menu.</a></p></body>";
                        sample += "\nThe html will click to MainMenu.html during design. When imported, it will click to /menumenu.";
                        string indent = "";
                        indent      += cp.Html5.P("Adds an href to the current element, replacing what is there if it has one.");
                        indent      += "<pre>" + cp.Utils.EncodeHTML(sample) + "</pre>";
                        tool.footer += cp.Html5.Div(indent, "ml-4");
                    }
                    //
                    tool.footer += cp.Html5.H5("data-src");
                    {
                        string sample = "";
                        sample += "<body><image src=\"placeholder-image.jpg\" data-src=\"{{user-photo}}\"></body>";
                        sample += "\nThe html will show placeholder-image.jpg. When imported, the src will be the mustache tag {{user-photo}}.";
                        string indent = "";
                        indent      += cp.Html5.P("Adds an src to the current element, replacing what is there if it has one.");
                        indent      += "<pre>" + cp.Utils.EncodeHTML(sample) + "</pre>";
                        tool.footer += cp.Html5.Div(indent, "ml-4");
                    }
                    //
                    tool.footer += cp.Html5.H5("data-addon");
                    {
                        string sample = "";
                        sample += "<span data-addon=\"content_box\">content</span>";
                        sample += "\n<span>{% \"content box\" %}</span>";
                        string indent = "";
                        indent      += cp.Html5.P("NOTE: If the addon name contains spaces, replace each space with a _ instead. Ex. content box would be content_box. Replace the inner content of the html tag with the addon after the Mustache Addon tag.");
                        indent      += "<pre>" + cp.Utils.EncodeHTML(sample) + "</pre>";
                        tool.footer += cp.Html5.Div(indent, "ml-4");
                    }
                    //
                    tool.footer += cp.Html5.H5("data-delete");
                    {
                        string sample = "";
                        sample += "<p>This is in the layout.<span data-delete>This is not.</span></p>";
                        sample += "\n<p>This is in the layout.</p>";
                        string indent = "";
                        indent      += cp.Html5.P("Delete the tag that contains this class, and all child tags.");
                        indent      += "<pre>" + cp.Utils.EncodeHTML(sample) + "</pre>";
                        tool.footer += cp.Html5.Div(indent, "ml-4");
                    }

                    tool.addFormButton("Upload");
                    tool.addFormButton("Cancel");
                    return(tool.getHtml(cp));
                }
                catch (Exception ex) {
                    //
                    // -- the execute method should typically not throw an error into the consuming method. Log and return.
                    cp.Site.ErrorReport(ex);
                    throw;
                }
            }
 //
 // ====================================================================================================
 /// <summary>
 /// The user is not authenticated and this activity is not for anonymous access
 /// </summary>
 /// <param name="cp"></param>
 /// <returns></returns>
 public static string getResponseUnauthorized(CPBaseClass cp)
 {
     cp.Response.SetStatus(HttpErrorEnum.unauthorized + " Unauthorized");
     return(string.Empty);
 }
Exemple #32
0
            //
            //====================================================================================================
            /// <summary>
            /// Import a file and process the html. Save the result.
            /// </summary>
            /// <param name="cp"></param>
            /// <param name="htmlSourceTempPathFilename"></param>
            /// <param name="importTypeId"></param>
            /// <param name="layoutId">If not 0, the imported html will be saved to the record in this table.</param>
            /// <param name="pageTemplateId">If not 0, the imported html will be saved to the record in this table.</param>
            /// <param name="emailTemplateId">If not 0, the imported html will be saved to the record in this table.</param>
            /// <param name="emailId">If not 0, the imported html will be saved to the record in this table.</param>
            /// <param name="userMessageList">If there were any processing errors caused by the data, return them here. These can be presented to the user.</param>
            /// <returns></returns>
            public static bool processImportFile(CPBaseClass cp, string htmlSourceTempPathFilename, ImporttypeEnum importTypeId, int layoutId, int pageTemplateId, int emailTemplateId, int emailId, ref List <string> userMessageList)
            {
                try {
                    if (System.IO.Path.GetExtension(htmlSourceTempPathFilename).Equals(".zip"))
                    {
                        //
                        // -- upload file is a zip and unzip to temp and copy assets to wwwroot
                        cp.TempFiles.UnzipFile(htmlSourceTempPathFilename);
                        cp.TempFiles.DeleteFile(htmlSourceTempPathFilename);
                        //
                        // -- copy non-html files to wwwroot
                        copyNonHtmlFilesToWWW(cp, cp.TempFiles.GetPath(htmlSourceTempPathFilename), "");
                    }
                    //
                    // -- import all html files in the root folder
                    string tempPath      = cp.TempFiles.GetPath(htmlSourceTempPathFilename);
                    bool   htmlFileFound = false;
                    foreach (var file in cp.TempFiles.FileList(tempPath))
                    {
                        if (file.Extension.ToLowerInvariant().Equals(".html"))
                        {
                            //
                            // -- process each html file one at a time
                            userMessageList.Add("Processing file " + cp.CdnFiles.GetFilename(file.Name));
                            string newRecordName = Path.GetFileNameWithoutExtension(file.Name);
                            htmlFileFound = true;
                            HtmlDocument htmlDoc = new HtmlDocument();
                            htmlDoc.Load(cp.TempFiles.PhysicalFilePath + tempPath + file.Name, Encoding.UTF8);
                            if (htmlDoc == null)
                            {
                                //
                                // -- body tag not found, import the whole document
                                userMessageList.Add("The file is empty.");
                                return(false);
                            }
                            //
                            // -- get record names for each import type
                            string layoutRecordName        = string.Empty;
                            string pageTemplateRecordName  = string.Empty;
                            string emailTemplateRecordName = string.Empty;
                            string emailRecordName         = string.Empty;
                            //
                            // -- search for meta name=template|layout content=recordaname
                            var metadataList = htmlDoc.DocumentNode.SelectNodes("//meta");
                            if (metadataList != null)
                            {
                                foreach (var metadataNode in metadataList)
                                {
                                    switch (metadataNode.GetAttributeValue("name", String.Empty).ToLowerInvariant())
                                    {
                                    case "layout": {
                                        layoutRecordName = metadataNode.GetAttributeValue("content", String.Empty);
                                        break;
                                    }

                                    case "template":
                                    case "pagetemplate": {
                                        pageTemplateRecordName = metadataNode.GetAttributeValue("content", String.Empty);
                                        break;
                                    }

                                    case "emailtemplate": {
                                        emailTemplateRecordName = metadataNode.GetAttributeValue("content", String.Empty);
                                        break;
                                    }

                                    case "email": {
                                        emailRecordName = metadataNode.GetAttributeValue("content", String.Empty);
                                        break;
                                    }

                                    default: {
                                        break;
                                    }
                                    }
                                }
                            }
                            //
                            // -- process the document html
                            if (!processHtmlDoc(cp, htmlDoc, importTypeId, ref userMessageList))
                            {
                                return(false);
                            }
                            //
                            // -- save manual layout
                            LayoutModel layout = null;
                            {
                                if (importTypeId.Equals(ImporttypeEnum.LayoutForAddon) && layoutId.Equals(0) & string.IsNullOrWhiteSpace(layoutRecordName))
                                {
                                    //
                                    // -- layout type but no layout selected, and no layout imported, use filename
                                    layoutRecordName = newRecordName;
                                }
                                if (importTypeId.Equals(ImporttypeEnum.LayoutForAddon) && !layoutId.Equals(0))
                                {
                                    layout = DbBaseModel.create <LayoutModel>(cp, layoutId);
                                    if (layout == null)
                                    {
                                        userMessageList.Add("The layout selected could not be found.");
                                        return(false);
                                    }
                                    layout.layout.content = htmlDoc.DocumentNode.OuterHtml;
                                    layout.save(cp);
                                }
                                //
                                // -- save meta layout
                                if ((layout == null) && !string.IsNullOrWhiteSpace(layoutRecordName))
                                {
                                    layout = DbBaseModel.createByUniqueName <LayoutModel>(cp, layoutRecordName);
                                    if (layout == null)
                                    {
                                        layout      = DbBaseModel.addDefault <LayoutModel>(cp);
                                        layout.name = layoutRecordName;
                                    }
                                    layout.layout.content = htmlDoc.DocumentNode.OuterHtml;
                                    layout.save(cp);
                                    userMessageList.Add("Saved Layout '" + layoutRecordName + "'.");
                                }
                            }
                            //
                            // -- save page template
                            PageTemplateModel pageTemplate = null;
                            {
                                if (importTypeId.Equals(ImporttypeEnum.PageTemplate) && pageTemplateId.Equals(0) & string.IsNullOrWhiteSpace(pageTemplateRecordName))
                                {
                                    //
                                    // -- layout type but no layout selected, and no layout imported, use filename
                                    pageTemplateRecordName = newRecordName;
                                }
                                if (importTypeId.Equals(ImporttypeEnum.PageTemplate) && !pageTemplateId.Equals(0))
                                {
                                    pageTemplate = DbBaseModel.create <PageTemplateModel>(cp, pageTemplateId);
                                    if (pageTemplate == null)
                                    {
                                        userMessageList.Add("The template selected could not be found.");
                                        return(false);
                                    }
                                    pageTemplate.bodyHTML = htmlDoc.DocumentNode.OuterHtml;
                                    pageTemplate.save(cp);
                                    userMessageList.Add("Saved Page Template '" + pageTemplateRecordName + "'.");
                                }
                                //
                                // -- save meta template
                                if ((pageTemplate == null) && !string.IsNullOrWhiteSpace(pageTemplateRecordName))
                                {
                                    pageTemplate = DbBaseModel.createByUniqueName <PageTemplateModel>(cp, pageTemplateRecordName);
                                    if (pageTemplate == null)
                                    {
                                        pageTemplate      = DbBaseModel.addDefault <PageTemplateModel>(cp);
                                        pageTemplate.name = pageTemplateRecordName;
                                    }
                                    //
                                    // -- try to resolve the various relative urls possible into the primary url, then to a reoot relative url
                                    string urlProtocolDomainSlash = "https://" + cp.Site.DomainPrimary + "/";
                                    string bodyhtml = htmlDoc.DocumentNode.OuterHtml;
                                    bodyhtml = genericController.convertLinksToAbsolute(bodyhtml, urlProtocolDomainSlash);
                                    bodyhtml = bodyhtml.Replace(urlProtocolDomainSlash, "/");
                                    //
                                    pageTemplate.bodyHTML = bodyhtml;
                                    pageTemplate.save(cp);
                                    userMessageList.Add("Saved Page Template '" + pageTemplateRecordName + "'.");
                                }
                            }
                            //
                            // -- save email template
                            EmailTemplateModel emailTemplate = null;
                            {
                                if (importTypeId.Equals(ImporttypeEnum.EmailTemplate) && emailTemplateId.Equals(0) & string.IsNullOrWhiteSpace(emailTemplateRecordName))
                                {
                                    //
                                    // --  type but no layout selected, and no layout imported, use filename
                                    emailTemplateRecordName = newRecordName;
                                }
                                if (importTypeId.Equals(ImporttypeEnum.EmailTemplate) && !emailTemplateId.Equals(0))
                                {
                                    emailTemplate = DbBaseModel.create <EmailTemplateModel>(cp, emailTemplateId);
                                    if (emailTemplate == null)
                                    {
                                        userMessageList.Add("The template selected could not be found.");
                                        return(false);
                                    }
                                    emailTemplate.bodyHTML = htmlDoc.DocumentNode.OuterHtml;
                                    emailTemplate.save(cp);
                                }
                                //
                                // -- save meta template
                                if ((emailTemplate == null) && !string.IsNullOrWhiteSpace(emailTemplateRecordName))
                                {
                                    emailTemplate = DbBaseModel.createByUniqueName <EmailTemplateModel>(cp, emailTemplateRecordName);
                                    if (emailTemplate == null)
                                    {
                                        emailTemplate      = DbBaseModel.addDefault <EmailTemplateModel>(cp);
                                        emailTemplate.name = emailTemplateRecordName;
                                    }
                                    emailTemplate.bodyHTML = htmlDoc.DocumentNode.OuterHtml;
                                    emailTemplate.save(cp);
                                    userMessageList.Add("Saved Email Template '" + emailTemplateRecordName + "'.");
                                }
                            }
                            //
                            // -- save email
                            EmailModel email = null;
                            {
                                if (importTypeId.Equals(5) && emailId.Equals(0) & string.IsNullOrWhiteSpace(emailRecordName))
                                {
                                    //
                                    // -- layout type but no layout selected, and no layout imported, use filename
                                    emailRecordName = newRecordName;
                                }
                                if (!emailId.Equals(0))
                                {
                                    email = DbBaseModel.create <EmailModel>(cp, emailId);
                                    if (email == null)
                                    {
                                        userMessageList.Add("The email selected could not be found.");
                                        return(false);
                                    }
                                    email.copyFilename.content = htmlDoc.DocumentNode.OuterHtml;
                                    email.save(cp);
                                    userMessageList.Add("Saved Email '" + emailRecordName + "'.");
                                }
                                //
                                // -- save meta template
                                if ((email == null) && !string.IsNullOrWhiteSpace(emailRecordName))
                                {
                                    email = DbBaseModel.createByUniqueName <EmailModel>(cp, emailRecordName);
                                    if (email == null)
                                    {
                                        email      = DbBaseModel.addDefault <EmailModel>(cp);
                                        email.name = emailRecordName;
                                    }
                                    email.copyFilename.content = htmlDoc.DocumentNode.OuterHtml;
                                    email.save(cp);
                                    userMessageList.Add("Saved Email '" + emailRecordName + "'.");
                                }
                            }
                        }
                    }
                    if (!htmlFileFound)
                    {
                        userMessageList.Add("No files were found with .HTML extension. Only files with .HTML extensions are imported.");
                        return(false);
                    }
                    return(true);
                } catch (Exception ex) {
                    cp.Site.ErrorReport(ex);
                    throw;
                }
            }
 //
 //====================================================================================================
 public static PageContentModel create(CPBaseClass cp, int recordId)
 {
     return(create <PageContentModel>(cp, recordId));
 }
Exemple #34
0
 //
 //====================================================================================================
 /// <summary>
 /// Process and return an htmlagility object. Any processing errors are returned in userMessageList. If UserMessageList.count is 0, there wre no errors.
 /// </summary>
 /// <param name="cp"></param>
 /// <param name="htmlDoc"></param>
 /// <param name="importTypeId"></param>
 /// <param name="userMessageList"></param>
 /// <returns></returns>
 private static bool processHtmlDoc(CPBaseClass cp, HtmlDocument htmlDoc, ImporttypeEnum importTypeId, ref List <string> userMessageList)
 {
     //
     // -- get body (except email template because it uses the full html document
     if (importTypeId != ImporttypeEnum.EmailTemplate)
     {
         //
         // -- find the data-body or body tag
         {
             string             xPath    = "//*[@data-body]";
             HtmlNodeCollection nodeList = htmlDoc.DocumentNode.SelectNodes(xPath);
             if (nodeList != null)
             {
                 //
                 // -- import data-body
                 userMessageList.Add("Body set by data-body attribute.");
                 htmlDoc.LoadHtml(nodeList.First().InnerHtml);
             }
             else
             {
                 HtmlNode bodyNode = htmlDoc.DocumentNode.SelectSingleNode("//body");
                 if (bodyNode == null)
                 {
                     //
                     // -- no body found, use entire document
                     userMessageList.Add("No Body found, entire document imported.");
                 }
                 else
                 {
                     //
                     // -- use body
                     string body = bodyNode.InnerHtml;
                     if (string.IsNullOrWhiteSpace(body))
                     {
                         //
                         // -- body tag not found, import the whole document
                         userMessageList.Add("The content does not include a data-body attribute and the body tag is empty.");
                         return(false);
                     }
                     //
                     // -- body found, set the htmlDoc to the body
                     userMessageList.Add("Html Body imported.");
                     htmlDoc.LoadHtml(body);
                 }
             }
         }
     }
     //
     // -- process data-layout nodes. Within each node found, run all other controllers inddividually then save
     DataLayoutController.process(cp, htmlDoc, ref userMessageList);
     //
     // -- process the body
     DataDeleteController.process(htmlDoc);
     MustacheVariableController.process(htmlDoc);
     MustacheSectionController.process(htmlDoc);
     MustacheTruthyController.process(htmlDoc);
     MustacheInvertedSectionController.process(htmlDoc);
     MustacheValueController.process(htmlDoc);
     DataAddonController.process(cp, htmlDoc);
     DataHrefController.process(htmlDoc);
     DataSrcController.process(htmlDoc);
     //
     return(true);
 }
Exemple #35
0
 //
 // returns true if this user has access to this forum
 //
 bool userHasAccess(CPBaseClass cp, int forumId)
 {
     bool returnValue = false;
     try
     {
         string sql;
         CPCSBaseClass cs = cp.CSNew();
         //
         if (forumId==0)
         {
             returnValue = true;
         }
         else if (cp.User.IsAdmin)
         {
             returnValue = true;
         }
         else
         {
             if (cp.User.IsAuthenticated)
             {
                 sql = ""
                     + "select f.id"
                     + " from (((ccforums f"
                     + " left join ccforumGroupRules gr on gr.forumId=f.id)"
                     + " left join ccMemberRules mr on mr.groupId=gr.groupId)"
                     + " left join ccmembers m on m.id=mr.memberid)"
                     + " where (f.id=" + forumId + ")"
                     + " and(f.active<>0)"
                     + " and ("
                     +   " (f.block is null)"
                     +   " or(f.block=0)"
                     +   " or(mr.memberid=" + cp.User.Id + ")"
                     + " )"
                     + "";
             }
             else
             {
                 sql = "select f.id"
                     + " from ccforums f"
                     + " where (f.id=" + forumId + ")"
                     + " and(f.active<>0)"
                     + " and((f.block is null)or(f.block=0))"
                     + "";
             }
             cs.OpenSQL(sql );
             returnValue = cs.OK();
             cs.Close();
         }
     }
     catch(Exception ex)
     {
         cp.Site.ErrorReport(ex, "userHasAccess Trap");
     }
     return returnValue;
 }
            //
            // ====================================================================================================
            /// <summary>
            /// create list of records for this domain model
            /// </summary>
            /// <param name="cp"></param>
            /// <param name="organizationId"></param>
            /// <param name="pageSize"></param>
            /// <param name="pageNumber"></param>
            /// <returns></returns>
            public static List <BlankDomainModel> createList(CPBaseClass cp, int organizationId, int pageSize, int pageNumber)
            {
                string sql = Contensive.Addon.Forum.Properties.Resources.sampleSql.Replace("{organizationId}", organizationId.ToString());

                return(createListFromSql <BlankDomainModel>(cp, sql, pageSize, pageNumber));
            }
Exemple #37
0
        //
        // ===============================================================================================
        // get Forum List
        // ===============================================================================================
        //
        private string getForumList(CPBaseClass cp, bool isEditing)
        {
            const string copyRecordName = "forums - Forum Intro";
            //
            CPBlockBaseClass block = cp.BlockNew();
            CPBlockBaseClass blockPublic = cp.BlockNew();
            CPBlockBaseClass blockPrivate = cp.BlockNew();
            CPBlockBaseClass listItemOdd = cp.BlockNew();
            CPBlockBaseClass listItemEven = cp.BlockNew();
            CPBlockBaseClass listItem;
            CPCSBaseClass cs = cp.CSNew();
            string imageUrl = "";
            string listPublic = "";
            string listPrivate = "";
            int ptr = 0;
            string copy = "";
            string sql = "";
            string forumATag = "";
            //string postATag = "";
            string qs = "";
            string rqs = "";
            DateTime lastDate;
            string forumName;
            string forumDescription;
            int forumId;
            bool segregatePrivate = cp.Utils.EncodeBoolean(cp.Site.GetProperty("Forums - Segregate Private Forums","0"));
            string forumLayout = "";
            int listPrivateCnt = 0;
            int listPublicCnt = 0;
            bool isAuthenticated = cp.User.IsAuthenticated;
            bool forumBlocked = true;
            //
            block.OpenLayout("forums - forum list view");
            listItemOdd.Load(block.GetOuter(".foItemOdd"));
            listItemEven.Load(block.GetOuter(".foItemEven"));
            listPublic = block.GetOuter(".foHead");
            listPrivate = listPublic;
            //
            rqs = cp.Doc.RefreshQueryString;
            rqs = cp.Utils.ModifyQueryString(rqs, rnFormId, "", false);
            rqs = cp.Utils.ModifyQueryString(rqs, rnForumId, "", false);
            rqs = cp.Utils.ModifyQueryString(rqs, rnThreadId, "", false);
            rqs = cp.Utils.ModifyQueryString(rqs, rnIntercept, "", false);
            //
            copy = cp.Content.GetCopy(copyRecordName, "<p>Welcome to our forums.</p>");
            //if (isEditing)
            //{
            //    copyRecordId = cp.Content.GetRecordID("copy content", copyRecordName);
            //    copy = cp.Content.GetEditLink("copy content", copyRecordId.ToString(), false, copyRecordName, true) + copy;
            //}
            block.SetInner(".foForumIntro", copy);
            //
            if (!cp.User.IsAuthenticated)
            {
                //
                // not authenticated - block anything marked block
                //
                //qs = rqs;
                //qs = cp.Utils.ModifyQueryString(qs, "forceInterceptForm", "login", true);
                //copy = "<a href=\"?" + qs + "\">Login</a>";
                //block.SetOuter(".foButtonLogin", copy);
                //qs = cp.Utils.ModifyQueryString(qs, "forceInterceptForm", "register", true);
                //copy = "<a href=\"?" + qs + "\">Register</a>";
                //block.SetOuter(".foButtonRegister", copy);
                block.SetOuter(".foButtonNewForum", "");
                //block.SetOuter(".foButtonLogout", "");
                //
                //sql = ""
                //    + "select f.id"
                //    + ",f.block"
                //    + ",f.name"
                //    + ",f.overview"
                //    + ",f.threads"
                //    + ",f.posts"
                //    + ",p.name as lastTitle"
                //    + ",p.dateAdded as lastDate"
                //    + ",m.name as authorName"
                //    + ",m.nickname as authorNickname"
                //    + ",f.imageFilename"
                //    + ",f.lastpostid "
                //    + ",f.contentControlId "
                //    + " from ((ccforums f"
                //    + " left join ccforumPosts p on p.id=f.lastpostid)"
                //    + " left join ccmembers m on m.id=p.createdby)"
                //    + " where (f.active<>0)"
                //    + " and ((f.block is null)or(f.block=0))"
                //    + " order by p.dateAdded desc"
                //    + "";
            }
            else if (cp.User.IsAdmin)
            {
                //
                // admin - allow new forum button and show all forums
                //
                qs = rqs;
                qs = cp.Utils.ModifyQueryString(qs, rnFormId, formIdNewForum.ToString(), true);
                copy = "<a href=\"?" + qs + "\">New Forum</a>";
                block.SetOuter(".foButtonNewForum", copy);
                //qs = rqs;
                //qs = cp.Utils.ModifyQueryString(qs, rnIntercept, "logout", true);
                //copy = "<a href=\"?" + qs + "\">Logout</a>";
                //block.SetOuter(".foButtonLogout", copy);
                //block.SetOuter(".foButtonLogin", "");
                //block.SetOuter(".foButtonRegister", "");
                //
                // block nothing
                //
                //sql = ""
                //    + "select f.id"
                //    + ",f.block"
                //    + ",f.name"
                //    + ",f.overview"
                //    + ",f.threads"
                //    + ",f.posts"
                //    + ",p.name as lastTitle"
                //    + ",p.dateAdded as lastDate"
                //    + ",m.name as authorName"
                //    + ",m.nickname as authorNickname"
                //    + ",f.imageFilename"
                //    + ",f.lastpostid "
                //    + ",f.contentControlId"
                //    + " from ((ccforums f"
                //    + " left join ccforumPosts p on p.id=f.lastpostid)"
                //    + " left join ccmembers m on m.id=p.createdby)"
                //    + " where (f.active<>0)"
                //    + " order by p.dateAdded desc"
                //    + "";
            }
            else
            {
                //
                // authenticated but not admin - blocking
                //
                block.SetOuter(".foButtonNewForum", "");
                //qs = rqs;
                //qs = cp.Utils.ModifyQueryString(qs, rnIntercept, "logout", true);
                //copy = "<a href=\"?" + qs + "\">Logout</a>";
                //block.SetOuter(".foButtonLogout", copy);
                //block.SetOuter(".foButtonLogin", "");
                //block.SetOuter(".foButtonRegister", "");
                //
                //sql = ""
                //    + "select f.id"
                //    + ",f.block"
                //    + ",f.name"
                //    + ",f.overview"
                //    + ",f.threads"
                //    + ",f.posts"
                //    + ",p.name as lastTitle"
                //    + ",p.dateAdded as lastDate"
                //    + ",m.name as authorName"
                //    + ",m.nickname as authorNickname"
                //    + ",f.imageFilename"
                //    + ",f.lastpostid "
                //    + ",f.contentControlId "
                //    + " from ((((ccforums f"
                //    + " left join ccforumPosts p on p.id=f.lastpostid)"
                //    + " left join ccmembers m on m.id=p.createdby)"
                //    + " left join ccforumGroupRules gr on gr.forumId=f.id)"
                //    + " left join ccMemberRules mr on mr.groupId=gr.groupId)"
                //    + " where (f.active<>0)"
                //    + " and ((mr.memberid=" + cp.User.Id + ")or(f.block is null)or(f.block=0))"
                //    + " group by f.id,f.block,f.name,f.overview,f.threads,f.posts,p.name ,p.dateAdded,m.name,m.nickname,f.imageFilename,f.lastpostid,f.contentControlId"
                //    + " order by p.dateAdded desc"
                //    + "";
            }
            //
            // new direction -- list all forums, but if blocked put login button over threads/posts
            //
            sql = ""
                + "select f.id"
                + ",f.block"
                + ",f.name"
                + ",f.overview"
                + ",f.threads"
                + ",f.posts"
                + ",p.name as lastTitle"
                + ",p.dateAdded as lastDate"
                + ",m.name as authorName"
                + ",m.nickname as authorNickname"
                + ",f.imageFilename"
                + ",f.lastpostid "
                + ",f.contentControlId"
                + " from ((ccforums f"
                + " left join ccforumPosts p on p.id=f.lastpostid)"
                + " left join ccmembers m on m.id=p.createdby)"
                + " where (f.active<>0)"
                + " order by p.dateAdded desc"
                + "";
            cs.OpenSQL2(sql, "", 100, 1);
            ptr = 0;
            while ( cs.OK() ) {
                if ((ptr % 2) == 0)
                {
                    listItem = listItemEven;
                }
                else
                {
                    listItem = listItemOdd;
                }
                forumId = cs.GetInteger( "id" );
                //
                forumBlocked = (!isAuthenticated & cs.GetBoolean("block"));
                forumATag = "<a";
                if (forumBlocked)
                {
                    forumATag += " class=\"loginLightbox\"";
                }
                qs = cp.Utils.ModifyQueryString(rqs, rnForumId, cs.GetText("id"), true);
                forumATag += " href=\"?" + qs + "\">";
                qs = cp.Utils.ModifyQueryString(rqs, rnPostId, cs.GetText("lastpostid"), true);
                //postATag = "<a href=\"?" + qs + "\">";
                imageUrl = cs.GetText("imageFilename");
                if ( imageUrl == "" )
                {
                    imageUrl = "/aoForums/defaultForumIcon.png";
                } else {
                    imageUrl = cp.Site.FilePath + imageUrl;
                }
                listItem.SetInner(".foOverviewImage", forumATag + "<img src=\"" + imageUrl + "\" width=\"80\" height=\"80\"></a>");
                copy = "";
                //
                forumName = cs.GetText("name");
                if ( forumName=="")
                {
                    forumName = "Forum " + forumId.ToString();
                }
                forumName = forumATag + forumName + "</a>";
                if (isEditing)
                {
                    forumName = cs.GetEditLink(false) + forumName;
                }
                listItem.SetInner(".foOverviewName", forumName);
                //
                forumDescription = cs.GetText("overview");
                if ( forumDescription!="")
                {
                    forumDescription = forumATag + forumDescription + "</a>";
                }
                listItem.SetInner(".foOverviewCopy", forumDescription);
                listItem.SetInner(".foThreads", cp.Utils.EncodeInteger( cs.GetText("threads")).ToString());
                listItem.SetInner(".foPosts", cp.Utils.EncodeInteger(  cs.GetText("posts")).ToString());
                lastDate = cs.GetDate("lastDate");
                if (lastDate < new DateTime(2000, 1, 1))
                {
                    listItem.SetInner(".foLastPost", "");
                    //listItem.SetInner(".foLastTitle", "");
                    //listItem.SetInner(".foAuthorName", "");
                    //listItem.SetInner(".foLastDate", "");
                }
                else
                {

                    //listItem.SetInner(".foLastTitle", postATag + cs.GetText("lastTitle") + "</a>");
                    copy = cs.GetText("authorNickname").Trim();
                    if (copy=="")
                    {
                        copy = cs.GetText("authorName");
                    }
                    listItem.SetInner(".foAuthorName", copy);
                    listItem.SetInner(".foLastDate", lastDate.ToShortDateString());
                }
                if (segregatePrivate & cs.GetBoolean("block"))
                {
                    listPrivate += listItem.GetHtml();
                    listPrivateCnt += 1;
                }
                else
                {
                    listPublic += listItem.GetHtml();
                }
                listPublicCnt += 1;
                listPublicCnt += 1;
                ptr += 1;
                cs.GoNext();
            }
            if (segregatePrivate & (listPrivateCnt > 0))
            {
                forumLayout = block.GetOuter(".foForums");
                //
                blockPrivate.Load(forumLayout);
                blockPrivate.SetInner(".foForums", listPrivate );
                blockPrivate.SetInner(".foOverview", "Closed Forums");
                //
                blockPublic.Load(forumLayout);
                blockPublic.SetInner(".foForums", listPublic);
                blockPublic.SetInner(".foOverview", "Public Forums");
                //
                block.SetOuter(".foForums", blockPublic.GetHtml() + blockPrivate.GetHtml());
            }
            else
            {
                block.SetInner(".foForums", listPublic);
            }
            return block.GetHtml();
        }
 //
 // ====================================================================================================
 /// <summary>
 /// create list of records for this domain model
 /// </summary>
 /// <param name="cp"></param>
 /// <param name="organizationId"></param>
 /// <param name="pageSize"></param>
 /// <returns></returns>
 public static List <BlankDomainModel> createList(CPBaseClass cp, int organizationId, int pageSize)
 => createList(cp, organizationId, pageSize, 1);
Exemple #39
0
 //
 // ===============================================================================================
 //
 // ===============================================================================================
 //
 private string getNewForum(CPBaseClass cp)
 {
     //const string foPrepopulateFlag = "foPrepopulateFlag";
     string s = "";
     //string forumName = "";
     //string forumCopy = "";
     string qs;
     string rqs = cp.Doc.RefreshQueryString;
     string zs = "";
     CPCSBaseClass cs = cp.CSNew();
     //string company = "";
     CPBlockBaseClass block = cp.BlockNew();
     CPBlockBaseClass li = cp.BlockNew();
     string list = "";
     int ptr = 0;
     //int groupId;
     string groupCaption = "";
     string copy = "";
     Random random = new Random();
     //
     try
     {
         //
         block.OpenLayout("forums - new forum view");
         qs = rqs;
         qs = cp.Utils.ModifyQueryString(qs, rnFormId, "", true);
         qs = cp.Utils.ModifyQueryString(qs, rnForumId, "", true);
         qs = cp.Utils.ModifyQueryString(qs, rnThreadId, "", true);
         //
         block.SetInner(".foBreadCrumb", "<a href=\"?" + qs + "\">Forums</a>");
         ////
         block.SetInner(".foInputTitle", "<input type=\"text\" name=\"foInputTitle\" value=\"" + cp.Doc.GetProperty("foInputTitle", zs) + "\">");
         block.SetInner(".foInputDescription", encodeHtml(cp,cp.Doc.GetProperty("foInputDescription", zs)));
         block.SetOuter(".foInputModerator", cp.Html.SelectContent("foModeratorGroupid", cp.Doc.GetProperty("foModeratorGroupid", zs), "groups", "", "No Moderator Group", "", ""));
         block.SetOuter(".foInputBlock", cp.Html.CheckBox("foInputBlock", cp.Utils.EncodeBoolean(cp.Doc.GetProperty("foInputBlock", "")), "", "foInputBlock"));
         block.SetOuter(".foSourceForm", cp.Html.Hidden(rnSourceForm, formIdNewForum.ToString(), "", ""));
         //
         li.Load( block.GetOuter(".foInputAllowGroupsItem"));
         if ( !cs.Open( "groups","","caption",true,"caption,name,id",100,1 ) )
         {
             block.SetOuter("foInputAllowGroupsList", "");
         }
         else
         {
             while ( cs.OK())
             {
                 groupCaption = "";
                 groupCaption = cs.GetText( "caption" );
                 if ( groupCaption=="")
                 {
                     groupCaption = cs.GetText( "name" );
                 }
                 li.SetInner(".foCaption", groupCaption);
                 copy = ""
                     + cp.Html.CheckBox("foGroup" + ptr, true, "", "")
                     + cp.Html.Hidden("foGroupId" + ptr, cs.GetInteger("id").ToString(), "", "")
                     + "";
                 li.SetInner(".foGroupInput", copy);
                 list += li.GetHtml();
                 ptr += 1;
                 cs.GoNext();
             }
             list += cp.Html.Hidden("foGroupCnt", ptr.ToString(), "", "");
             block.SetInner(".foInputAllowGroupsList", list);
         }
         //
         int createKey = random.Next(0, 2147483647);
         block.SetOuter(".foCreateKey", cp.Html.Hidden(rnCreateKey, createKey.ToString(), "", ""));
         //
         s = block.GetHtml();
         //
         qs = rqs;
         qs = cp.Utils.ModifyQueryString(qs, rnFormId, formIdNewForum.ToString(), true);
         qs = cp.Utils.ModifyQueryString(qs, rnForumId, "", true);
         qs = cp.Utils.ModifyQueryString(qs, rnThreadId, "", true);
         qs = cp.Utils.ModifyQueryString(qs, rnIntercept, "", true);
         s = s.Replace("$formAction$", "?" + qs + "&requestBinary=1");
     }
     catch (Exception e)
     {
         cp.Site.ErrorReport(e, "getPostList Trap");
     }
     return s;
 }
 //
 //-------------------------------------------------
 // get
 //-------------------------------------------------
 //
 public string getHtml(CPBaseClass cp)
 {
     string s = "";
     int rowPtr = 0;
     int fieldSetPtr = 0;
     string row = "";
     string rowName;
     string rowValue;
     string userErrors;
     //
     // add user errors
     //
     userErrors = cp.Utils.EncodeText(cp.UserError.GetList());
     if (userErrors != "")
     {
         warning = userErrors;
     }
     //
     //
     //
     if (localBody != "")
     {
         s += localBody;
         /*
         body += ""
             + cr + "<div class=\"afwBodyColor\">"
             + indent(localBody)
             + cr + "</div>";
         */
     }
     for (rowPtr = 0; rowPtr <= rowCnt; rowPtr++)
     {
         //
         // check for fieldSetOpens
         //
         for (fieldSetPtr = 0; fieldSetPtr <= fieldSetMax; fieldSetPtr++)
         {
             if (fieldSets[fieldSetPtr].rowOpen == rowPtr)
             {
                 s += cr + "<fieldset class=\"afwFieldSet\">";
                 if (fieldSets[fieldSetPtr].caption != "")
                 {
                     s += cr + "<legend>" + fieldSets[fieldSetPtr].caption + "</legend>";
                 }
             }
         }
         row = "";
         rowName = rows[rowPtr].name;
         if (rowName == "") rowName = "&nbsp;";
         row += cr + cp.Html.div(rowName, "", "afwFormRowName", "");
         rowValue = rows[rowPtr].value;
         if (rowValue == "") rowValue = "&nbsp;";
         row += cr + cp.Html.div(rowValue, "", "afwFormRowValue", "");
         s += cr + cp.Html.div(row, "", "afwFormRow", rows[rowPtr].htmlId);
         //
         // check for fieldSetCloses
         //
         for (fieldSetPtr = fieldSetMax; fieldSetPtr >= 0; fieldSetPtr--)
         {
             if (fieldSets[fieldSetPtr].rowClose == rowPtr)
             {
                 s += cr + "</fieldset>";
             }
         }
     }
     //
     // headers
     //
     if (localDescription != "")
     {
         s = cr + "<p id=\"afwDescription\">" + localDescription + "</p>" + s;
     }
     if (localWarning != "")
     {
         s = cr + "<div id=\"afwWarning\">" + localWarning + "</div>" + s;
     }
     if (localTitle != "")
     {
         s = cr + "<h2 id=\"afwTitle\">" + localTitle + "</h2>" + s;
     }
     //
     // add form
     //
     if (localIncludeForm)
     {
         if (localButtonList != "")
         {
             localButtonList = ""
                 + cr + "<div class=\"afwButtonCon\">"
                 + indent(localButtonList)
                 + cr + "</div>";
         }
         s = cr + cp.Html.Form(localButtonList + s + localButtonList + localHiddenList, "", "", "", localFormActionQueryString, "");
         //body = ""
         //    + cr + "<form action=\"" + localFormAction + "\" method=\"post\" enctype=\"MULTIPART/FORM-DATA\">"
         //    + indent(localButtonList + body + localHiddenList)
         //    + cr + "</form>";
     }
     //
     // body padding and color
     //
     s = cp.Html.div(s, "",  "afwBodyPad", "");
     s = cp.Html.div(s, "", "afwBodyColor", "");
     //
     // if outer container, add styles and javascript
     //
     if (localIsOuterContainer)
     {
         cp.Doc.AddHeadJavascript(Properties.Resources.javascript);
         cp.Doc.AddHeadStyle(Properties.Resources.styles);
         s = ""
             + cr + "<div id=\"afw\">"
             + indent(s)
             + cr + "</div>";
     }
     return s;
 }
Exemple #41
0
 //
 // ===============================================================================================
 // get New Thread
 // ===============================================================================================
 //
 private string getNewThread(CPBaseClass cp, int forumId )
 {
     string s = "";
     string forumName = "";
     string forumCopy = "";
     string qs;
     string rqs = cp.Doc.RefreshQueryString;
     string zs = "";
     CPCSBaseClass cs = cp.CSNew();
     string company = "";
     Random random = new Random();
     //
     rqs = cp.Utils.ModifyQueryString(rqs, rnFormId, "", false);
     rqs = cp.Utils.ModifyQueryString(rqs, rnForumId, "", false);
     rqs = cp.Utils.ModifyQueryString(rqs, rnThreadId, "", false);
     rqs = cp.Utils.ModifyQueryString(rqs, rnIntercept, "", false);
     try
     {
         CPBlockBaseClass block = cp.BlockNew();
         //
         cs.Open( "Forums", "id=" + forumId,"",true,"",1,1 );
         if ( cs.OK() )
         {
             forumName = cs.GetText("name");
             forumCopy = cs.GetText("forumCopy");
             if (forumCopy.Length < 20)
             {
                 forumCopy = cs.GetText("forumOverview");
             }
         }
         cs.Close();
         //
         if (cp.Doc.GetProperty(rnSourceForm,zs)!=formIdNewThread.ToString())
         {
             //
             // prepopulate the form from the person's member record
             //
             cs.Open("people", "id=" + cp.User.Id,"",true,"",1,1);
             cp.Doc.SetProperty("foInputName",cs.GetText("name"));
             cp.Doc.SetProperty("foInputTitle",cs.GetText("title"));
             company = cs.GetText( "organizationId" );
             if ( company=="")
             {
                 company = cs.GetText( "company" );
             }
             cp.Doc.SetProperty("foInputOrg",company);
             cs.Close();
         }
         //
         block.OpenLayout("forums - new thread view");
         qs = rqs;
         qs = cp.Utils.ModifyQueryString(qs, rnFormId, "", true);
         qs = cp.Utils.ModifyQueryString(qs, rnForumId, "", true);
         //
         block.SetInner(".foBreadCrumb", "<a href=\"?" + qs + "\">Forums</a>&nbsp;�&nbsp;" + forumName );
         block.SetInner(".foForumTitle", forumName);
         block.SetInner(".foHeadForumName", forumName);
         block.SetInner(".foBodyTitleForumName", forumName);
         block.SetInner(".foForumCopy", forumCopy);
         //
         block.SetInner(".foInputThreadTitle", "<input type=\"text\" name=\"foInputThreadTitle\" value=\"" + cp.Doc.GetProperty("foInputThreadTitle",zs) + "\">");
         block.SetInner(".foInputName", "<input type=\"text\" name=\"foInputName\" value=\"" + cp.Doc.GetProperty("foInputName", zs) + "\">");
         block.SetInner(".foInputTitle", "<input type=\"text\" name=\"foInputTitle\" value=\"" + cp.Doc.GetProperty("foInputTitle", zs) + "\">");
         block.SetInner(".foInputOrg", "<input type=\"text\" name=\"foInputOrg\" value=\"" + cp.Doc.GetProperty("foInputOrg", zs) + "\">");
         block.SetInner(".foTextAreaPost", encodeHtml(cp,cp.Doc.GetProperty("foTextAreaPost", zs)));
         block.SetInner(".foInputFile", "<input type=\"file\" name=\"foInputFile\">");
         block.SetOuter(".foSourceForm", cp.Html.Hidden(rnSourceForm, formIdNewThread.ToString(), "", ""));
         //
         int createKey = random.Next(0, 2147483647);
         block.SetOuter(".foCreateKey", cp.Html.Hidden(rnCreateKey, createKey.ToString(), "", ""));
         //
         s = block.GetHtml();
         //
         qs = rqs;
         qs = cp.Utils.ModifyQueryString(qs, rnFormId, formIdNewThread.ToString(), true);
         qs = cp.Utils.ModifyQueryString(qs, rnForumId, forumId.ToString(), true);
         s = s.Replace("$formAction$", "?" + qs + "&requestBinary=1");
     }
     catch (Exception e)
     {
         cp.Site.ErrorReport(e ,"getPostList Trap");
     }
     return s;
 }
 //
 //-------------------------------------------------
 // get
 //-------------------------------------------------
 //
 public string getHtml(CPBaseClass cp)
 {
     string s = "";
     string navList = "";
     string navItem = "";
     string userErrors;
     //
     // add user errors
     //
     userErrors = cp.Utils.EncodeText(cp.UserError.GetList());
     if (userErrors != "")
     {
         warning = userErrors;
     }
     //
     // title at top
     //
     if (localTitle != "")
     {
         s += cr + "<h2 class=\"afwManagerTitle\">" + localTitle + "</h2>";
     }
     //
     // build nav
     //
     for (navPtr = 0; navPtr <= navMax; navPtr++)
     {
         navItem = navs[navPtr].caption;
         if (navItem != "")
         {
             if (navs[navPtr].link != "")
             {
                 navItem = "<a href=\"" + navs[navPtr].link + "\">" + navItem + "</a>";
             }
             else
             {
                 navItem = "<a href=\"#\" onclick=\"return false;\">" + navItem + "</a>";
             }
             if (navs[navPtr].active)
             {
                 navItem = "<li class=\"afwNavActive\">" + navItem + "</li>";
             }
             else
             {
                 navItem = cr + "<li>" + navItem + "</li>";
             }
             navList += navItem;
         }
     }
     if (navList != "")
     {
         s += ""
             + cr + "<ul class=\"afwNav\">"
             + indent( navList )
             + cr + "</ul>";
     }
     //
     // description under nav, over body
     //
     if (localDescription != "")
     {
         s += cr + "<div class=\"afwManagerDescription\">" + localDescription + "</div>";
     }
     if (localWarning != "")
     {
         s += cr + "<div id=\"afwWarning\">" + localWarning + "</div>";
     }
     //
     // body
     //
     if (localBody != "")
     {
         //
         // body padding and color
         //
         s += cp.Html.div(localBody, "", "afwBodyPad", "");
         /*
         s += ""
             + cr + "<div class=\"afwBodyPad\">"
             + indent(  )
             + cr + "</ul>";
          */
     }
     //
     // if outer container, add styles and javascript
     //
     if (localIsOuterContainer)
     {
         cp.Doc.AddHeadJavascript(Properties.Resources.javascript);
         cp.Doc.AddHeadStyle(Properties.Resources.styles);
         s = ""
             + cr + "<div id=\"afw\">"
             + indent(s)
             + cr + "</div>";
     }
     return s;
 }
 //
 // ====================================================================================================
 /// <summary>
 /// create list of records for this domain model
 /// </summary>
 /// <param name="cp"></param>
 /// <param name="organizationId"></param>
 /// <returns></returns>
 public static List <BlankDomainModel> createList(CPBaseClass cp, int organizationId)
 => createList(cp, organizationId, 99999, 1);
Exemple #44
0
 //
 //====================================================================================================
 public static void delete(CPBaseClass cp, string ccGuid)
 {
     delete <_blankModel>(cp, ccGuid);
 }
 //
 //-------------------------------------------------
 // get
 //-------------------------------------------------
 //
 public string getHtml(CPBaseClass cp)
 {
     string s = "";
     string list = "";
     string item = "";
     string userErrors;
     string tabStyleClass;
     //
     // if outer container, add styles and javascript
     //
     if (localIsOuterContainer)
     {
         cp.Doc.AddHeadJavascript(Properties.Resources.javascript);
         cp.Doc.AddHeadStyle(Properties.Resources.styles);
     }
     //
     // add user errors
     //
     userErrors = cp.Utils.EncodeText(cp.UserError.GetList());
     if (userErrors != "")
     {
         warning = userErrors;
     }
     //
     for (tabPtr = 0; tabPtr <= tabMax; tabPtr++)
     {
         item = navs[tabPtr].caption;
         if (item != "")
         {
             tabStyleClass = navs[tabPtr].styleClass;
             if (navs[tabPtr].link != "")
             {
                 item = "<a href=\"" + navs[tabPtr].link + "\">" + item + "</a>";
             }
             if (navs[tabPtr].active)
             {
                 tabStyleClass += " afwTabActive";
             }
             if (tabStyleClass != "")
             {
                 tabStyleClass = " class=\"" + tabStyleClass + "\"";
             }
             item = cr + "<li"+tabStyleClass+">" + item + "</li>";
             list += item;
         }
     }
     if (list != "")
     {
         s += ""
             + cr + "<ul class=\"afwBodyTabs\">"
             + indent(list)
             + cr + "</ul>";
     }
     //
     // headers
     //
     if (localDescription != "")
     {
         s = cr + "<p id=\"afwDescription\">" + localDescription + "</p>" + s;
     }
     if (localWarning != "")
     {
         s = cr + "<div id=\"afwWarning\">" + localWarning + "</div>" + s;
     }
     if (localTitle != "")
     {
         s = cr + "<h2 id=\"afwTitle\">" + localTitle + "</h2>" + s;
     }
     if (localBody != "")
     {
         s += localBody;
     }
     s = ""
         + cr + "<div class=\"afwTabbedBody\">"
         + indent(s)
         + cr + "</div>";
     //
     // if outer container, add styles and javascript
     //
     if (localIsOuterContainer)
     {
         cp.Doc.AddHeadJavascript(Properties.Resources.javascript);
         cp.Doc.AddHeadStyle(Properties.Resources.styles);
         s = ""
             + cr + "<div id=\"afw\">"
             + indent(s)
             + cr + "</div>";
     }
     return s;
 }
 //
 //=========================================================================================================
 //   GetPageSize
 //=========================================================================================================
 //
 public static int getPageSize(CPBaseClass cp)
 {
     int pageSize = cp.Utils.EncodeInteger(cp.Doc.GetProperty(rnPageSize, "20"));
     int setPageSize = cp.Utils.EncodeInteger(cp.Doc.GetProperty(rnSetPageSize, ""));
     if (setPageSize != 0)
     {
         pageSize = setPageSize;
     }
     if (pageSize == 0)
     {
         pageSize = 20;
     }
     return pageSize;
 }
 //
 // ===============================================================================
 // handle errors for this class
 // ===============================================================================
 //
 private void errorReport(CPBaseClass cp, Exception ex, string method)
 {
     cp.Site.ErrorReport(ex, "error in aoForums2.sendUpdatesClass." + method);
 }
Exemple #48
0
 //
 //====================================================================================================
 public static _blankModel createByName(CPBaseClass cp, string recordName)
 {
     return(createByName <_blankModel>(cp, recordName));
 }
        //
        //-------------------------------------------------
        // getResult
        //-------------------------------------------------
        //
        public string getHtml(CPBaseClass cp)
        {
            StringBuilder s = new StringBuilder( "" );
            string row = "";
            StringBuilder rowList = new StringBuilder("");
            int rowPtr = 0;
            int colPtr = 0;
            int colPtrDownload = 0;
            string styleClass;
            string content;
            string userErrors;
            string sortLink;
            string columnSort = cp.Doc.GetText("columnSort");
            string sortField="";
            string csvDownload = "";
            CPCSBaseClass cs = cp.CSNew();
            string csvFilename = "";
            DateTime rightNow = DateTime.Now;
            //
            // initialize - setup Db and/or read Db values
            //
            reportDbInit(cp);
            //
            if (!localFrameRqsSet)
            {
                refreshQueryString = cp.Doc.RefreshQueryString;
            }
            if (!localFormActionQueryStringSet)
            {
                // set locals not public property bc public also sets the includeForm
                localFormActionQueryString = localFrameRqs;
                localFormActionQueryStringSet = true;
                //formActionQueryString = localFrameRqs;
            }
            //
            // add user errors
            //
            userErrors = cp.Utils.EncodeText(  cp.UserError.GetList());
            if ( userErrors!="")
            {
                warning = userErrors;
            }
            //
            // headers
            //
            if (formIncludeHeader)
            {
                rowList = new StringBuilder("");
                for (colPtr = 0; colPtr <= columnMax; colPtr++)
                {
                    if (columns[colPtr].visible)
                    {
                        styleClass = columns[colPtr].captionClass;
                        if (styleClass != "")
                        {
                            styleClass = " class=\"" + styleClass + "\"";
                        }
                        content = columns[colPtr].caption;
                        sortField = columns[colPtr].name;
                        if (content == "")
                        {
                            content = "&nbsp;";
                        }
                        else if (columns[colPtr].sortable)
                        {
                            if (localFrameRqsSet)
                            {
                                sortLink = "?" + localFrameRqs + "&columnSort=" + sortField;
                            }
                            else
                            {
                                sortLink = "?" + cp.Doc.RefreshQueryString + "&columnSort=" + sortField;
                            }
                            if (columnSort == sortField)
                            {
                                sortLink += "Desc";
                            }
                            content = "<a href=\"" + sortLink + "\">" + content + "</a>";
                        }
                        rowList.Append( cr + "<th" + styleClass + ">" + content + "</th>" );
                    }
                }
                s.Append (""
                    + cr + "<thead>"
                    + cr2 + "<tr>"
                    + indent(indent(rowList.ToString() ))
                    + cr2 + "</tr>"
                    + cr + "</thead>"
                    + "" );
                if (localAddCsvDownloadCurrentPage)
                {
                    colPtrDownload = 0;
                    for (colPtr = 0; colPtr <= columnMax; colPtr++)
                    {
                        if (columns[colPtr].downloadable)
                        {
                            if (colPtrDownload == 0)
                            {
                                csvDownload += "\"" + columns[colPtr].caption.Replace("\"", "\"\"") + "\"";
                            }
                            else
                            {
                                csvDownload += ",\"" + columns[colPtr].caption.Replace("\"", "\"\"") + "\"";
                            }
                            colPtrDownload += 1;
                        }
                    }
                }
            }
            //
            // body
            //
            rowList = new StringBuilder( "" );
            if (localIsEmptyReport)
            {
                styleClass = columns[0].cellClass;
                if (styleClass != "")
                {
                    styleClass = " class=\"" + styleClass + "\"";
                }
                row = cr + "<td style=\"text-align:left\" " + styleClass + " colspan=\"" + (columnMax+1) + "\">[empty]</td>";
                rowList.Append( ""
                    + cr + "<tr>"
                    + indent(row)
                    + cr + "</tr>" );
            }
            else
            {
                for (rowPtr = 0; rowPtr <= rowCnt; rowPtr++)
                {
                    row = "";
                    colPtrDownload = 0;
                    for (colPtr = 0; colPtr <= columnMax; colPtr++)
                    {
                        styleClass = columns[colPtr].cellClass;
                        if (columns[colPtr].visible)
                        {
                            if (styleClass != "")
                            {
                                styleClass = " class=\"" + styleClass + "\"";
                            }
                            row += cr + "<td" + styleClass + ">" + localReportCells[rowPtr, colPtr] + "</td>";
                        }
                        if (localAddCsvDownloadCurrentPage && !localExcludeRowFromDownload[rowPtr])
                        {
                            if (columns[colPtr].downloadable)
                            {
                                if (colPtrDownload == 0)
                                {
                                    csvDownload += Environment.NewLine;
                                }
                                else
                                {
                                    csvDownload += ",";
                                }
                                csvDownload += "\"" + localDownloadData[rowPtr, colPtr].Replace("\"", "\"\"") + "\"";
                                colPtrDownload += 1;
                            }

                        }
                    }
                    styleClass = localRowClasses[rowPtr];
                    if (rowPtr % 2 != 0)
                    {
                        styleClass += " afwOdd";
                    }
                    if (styleClass != "" )
                    {
                        styleClass = " class=\"" + styleClass + "\"";
                    }
                    rowList.Append( ""
                        + cr + "<tr" + styleClass + ">"
                        + indent(row)
                        + cr + "</tr>" );
                }
            }

            if (localAddCsvDownloadCurrentPage)
            {
                if (cs.Insert("tasks"))
                {
                    csvFilename = cs.GetFilename("filename", "export.csv");
                    cp.File.SaveVirtual(csvFilename, csvDownload);
                    cs.SetField("Name", "Export: " + localTitle + ", " + rightNow.ToShortDateString());
                    cs.SetField("command", "BuildCSV");
                    cs.SetField("filename", csvFilename);
                    cs.SetField( "DateCompleted", rightNow.ToShortDateString());
                    cs.SetField("DateStarted", rightNow.ToShortDateString());
                    cs.SetField("ResultMessage", "OK");
                }
                cs.Close();
            }
            s.Append( ""
                + cr + "<tbody>"
                + indent(rowList.ToString() )
                + cr + "</tbody>"
                + "" );
            s = new StringBuilder( ""
                + cr + "<table class=\"afwListReportTable\">"
                + indent(s.ToString())
                + cr + "</table>" );
            if (localHtmlLeftOfTable != "")
            {
                s = new StringBuilder(""
                        + cr + "<div class=\"afwLeftSideHtml\">"
                        + indent(localHtmlLeftOfTable)
                        + cr + "</div>"
                        + cr + "<div class=\"afwRightSideHtml\">"
                        + indent(s.ToString())
                        + cr + "</div>"
                        + cr + "<div style=\"clear:both\"></div>"
                        + "");
            }
            if (localHtmlBeforeTable != "")
            {
                s = new StringBuilder(""
                    + localHtmlBeforeTable
                    + s.ToString()
                    + "") ;
            }
            if (localHtmlAfterTable != "")
            {
                s.Append(localHtmlAfterTable);
            }
            //
            // headers
            //
            if (localAddCsvDownloadCurrentPage)
            {
                s = new StringBuilder( cr + "<p id=\"afwDescription\"><a href=\"" + cp.Site.FilePath + csvFilename + "\">Click here</a> to download the data, or access it in the future from the <a href=\"?af=30\">Download Manager</a>.</p>" + s.ToString()  );
            }
            if (localDescription != "")
            {
                s = new StringBuilder( cr + "<p id=\"afwDescription\">" + localDescription + "</p>" + s.ToString());
            }
            if (localWarning != "")
            {
                s = new StringBuilder( cr + "<div id=\"afwWarning\">" + localWarning + "</div>" + s.ToString());
            }
            if (localTitle != "")
            {
                s = new StringBuilder( cr + "<h2 id=\"afwTitle\">" + localTitle + "</h2>" + s.ToString()) ;
            }
            //
            // add form
            //
            if (localIncludeForm)
            {
                if (localButtonList != "")
                {
                    localButtonList = ""
                        + cr + "<div class=\"afwButtonCon\">"
                        + indent(localButtonList)
                        + cr + "</div>";
                }
                s = new StringBuilder( cr + cp.Html.Form(  localButtonList + s.ToString()  + localButtonList + localHiddenList, "", "",  "",  localFormActionQueryString, ""));
                //body = ""
                //    + cr + cp.Html.Form( localButtonList + body + localHiddenList )
                //    + cr + "<form action=\"" + localFormAction + "\" method=\"post\" enctype=\"MULTIPART/FORM-DATA\">"
                //    + indent(localButtonList + body + localHiddenList)
                //    + cr + "</form>";
            }
            s = new StringBuilder( cp.Html.div(s.ToString() , "", "afwBodyPad", ""));
            s = new StringBuilder( cp.Html.div(s.ToString() , "", "afwBodyColor", ""));
            //
            // if outer container, add styles and javascript
            //
            if (localIsOuterContainer)
            {
                cp.Doc.AddHeadJavascript(Properties.Resources.javascript);
                cp.Doc.AddHeadStyle(Properties.Resources.styles);
                s = new StringBuilder(  ""
                    + cr + "<div id=\"afw\">"
                    + indent(s.ToString() )
                    + cr + "</div>" );
            }
            return s.ToString() ;
        }
 private void reportDbInit(CPBaseClass cp)
 {
     try
     {
         int colPtr;
         string colName;
         string colCaption;
         string colSortOrder;
         string colCaptionClass;
         string colCellClass;
         bool colSortable = false ;
         bool colVisible = true;
         bool colDownloadable = true;
         string textVisible = "";
         //string textDownloadable = "";
         CPCSBaseClass cs = cp.CSNew();
         int reportId;
         string sqlCriteria;
         //
         if (localGuid != "")
         {
             sqlCriteria = "ccguid=" + cp.Db.EncodeSQLText(localGuid);
             if (!cs.Open("Admin Framework Reports", sqlCriteria))
             {
                 cs.Close();
                 if(localName=="")
                 {
                     localName=localTitle;
                 }
                 cs.Insert("Admin Framework reports");
                 cs.SetField("ccguid", localGuid);
                 cs.SetField("name", localName );
                 cs.SetField("title", localTitle);
                 //cs.SetField("description", localDescription);
             }
             reportId = cs.GetInteger("id");
             localName = cs.GetText("name");
             localTitle = cs.GetText("title");
             //localDescription = cs.GetText("description");
             // tmp solution for reports created with a name and no title
             if((localTitle=="")&&(localName!=""))
             {
                 localTitle = localName;
             }
             cs.Close();
             //
             //
             for (colPtr = 0; colPtr <= columnMax; colPtr++)
             {
                 colCaption = columns[colPtr].caption;
                 colName = columns[colPtr].name;
                 colSortOrder = (colPtr * 10).ToString();
                 colSortOrder = colSortOrder.PadLeft(4 - colSortOrder.Length, '0');
                 colCaptionClass = columns[colPtr].captionClass;
                 colCellClass = columns[colPtr].cellClass;
                 colSortable = columns[colPtr].sortable; // not part of Db config
                 colVisible = columns[colPtr].visible;
                 colDownloadable = columns[colPtr].downloadable;
                 if (colName == "")
                 {
                     colName = colCaption;
                 }
                 if ((colName != "") && (reportId != 0))
                 {
                     if (!cs.Open("Admin Framework Report Columns", "(reportId=" + reportId.ToString() + ")and(name=" + cp.Db.EncodeSQLText(colName) + ")", "id"))
                     {
                         cs.Close();
                         cs.Insert("Admin Framework Report Columns");
                         cs.SetField("reportId", reportId.ToString());
                         cs.SetField("name", colName);
                         cs.SetField("caption", colCaption);
                         cs.SetField("sortOrder", colSortOrder);
                         cs.SetField("captionClass", colCaptionClass);
                         cs.SetField("cellClass", colCellClass);
                         cs.SetField("visible", colVisible.ToString());
                         // for another day
                         //cs.SetField("downloadable", colDownloadable.ToString());
                     }
                     else
                     {
                         // tmp - if name but not caption, use the other
                         colCaption = cs.GetText("caption");
                         colName = cs.GetText("name");
                         if (colCaption == "")
                         {
                             colCaption = colName;
                         }
                         else if (colName == "")
                         {
                             colName = colCaption;
                         }
                         columns[colPtr].name = colName;
                         columns[colPtr].caption = colCaption;
                         columns[colPtr].captionClass = cs.GetText("captionClass");
                         columns[colPtr].cellClass = cs.GetText("cellClass");
                         textVisible = cs.GetText("visible");
                         if (textVisible == "")
                         {
                             cs.SetField("visible", colVisible.ToString());
                         }
                         else
                         {
                             columns[colPtr].visible = cp.Utils.EncodeBoolean(  textVisible);
                         }
                         // for another day
                         //textDownloadable = cs.GetText("downloadable");
                         //if (textDownloadable == "")
                         //{
                         //    cs.SetField("downloadable", textDownloadable.ToString());
                         //}
                         //else
                         //{
                         //    columns[colPtr].visible = cp.Utils.EncodeBoolean(textDownloadable);
                         //}
                     }
                     cs.Close();
                 }
             }
         }
     }
     catch(Exception ex)
     {
         cp.Site.ErrorReport(ex, "Exception in reportListClass.init");
     }
 }
Exemple #51
0
 public override object Execute(CPBaseClass cp)
 {
     return("Hello World");
 }
Exemple #52
0
 //
 //====================================================================================================
 public static _blankModel create(CPBaseClass cp, int recordId)
 {
     return(create <_blankModel>(cp, recordId));
 }
Exemple #53
0
 //
 //
 //
 private void errorReport(Exception ex, CPBaseClass cp, string method)
 {
     cp.Site.ErrorReport(ex, "error in aoManagerTemplate.multiFormAjaxSample." + method);
 }
        //
        // ====================================================================================================
        //
        public static string getNodeList(CPBaseClass cp, string DataRecordList, List <string> tempPathFileList, string tempExportPath)
        {
            try {
                string result = "";
                if (DataRecordList != "")
                {
                    result += System.Environment.NewLine + "\t" + "<DataRecordList>" + ExportController.EncodeCData(DataRecordList) + "</DataRecordList>";
                    string[] DataRecords = Strings.Split(DataRecordList, System.Environment.NewLine);
                    string   RecordNodes = "";
                    for (var Ptr = 0; Ptr <= Information.UBound(DataRecords); Ptr++)
                    {
                        string FieldNodes     = "";
                        string DataRecordName = "";
                        string DataRecordGuid = "";
                        string DataRecord     = DataRecords[Ptr];
                        if (DataRecord != "")
                        {
                            string[] DataSplit = Strings.Split(DataRecord, ",");
                            if (Information.UBound(DataSplit) >= 0)
                            {
                                string DataContentName = Strings.Trim(DataSplit[0]);
                                int    DataContentId   = cp.Content.GetID(DataContentName);
                                if (DataContentId <= 0)
                                {
                                    RecordNodes = ""
                                                  + RecordNodes
                                                  + System.Environment.NewLine + "\t" + "<!-- data missing, content not found during export, content=\"" + DataContentName + "\" guid=\"" + DataRecordGuid + "\" name=\"" + DataRecordName + "\" -->";
                                }
                                else
                                {
                                    bool   supportsGuid = cp.Content.IsField(DataContentName, "ccguid");
                                    string Criteria;
                                    if (Information.UBound(DataSplit) == 0)
                                    {
                                        Criteria = "";
                                    }
                                    else
                                    {
                                        string TestString = Strings.Trim(DataSplit[1]);
                                        if (TestString == "")
                                        {
                                            //
                                            // blank is a select all
                                            //
                                            Criteria       = "";
                                            DataRecordName = "";
                                            DataRecordGuid = "";
                                        }
                                        else if (!supportsGuid)
                                        {
                                            //
                                            // if no guid, this is name
                                            //
                                            DataRecordName = TestString;
                                            DataRecordGuid = "";
                                            Criteria       = "name=" + cp.Db.EncodeSQLText(DataRecordName);
                                        }
                                        else if ((Strings.Len(TestString) == 38) & (Strings.Left(TestString, 1) == "{") & (Strings.Right(TestString, 1) == "}"))
                                        {
                                            //
                                            // guid {726ED098-5A9E-49A9-8840-767A74F41D01} format
                                            //
                                            DataRecordGuid = TestString;
                                            DataRecordName = "";
                                            Criteria       = "ccguid=" + cp.Db.EncodeSQLText(DataRecordGuid);
                                        }
                                        else if ((Strings.Len(TestString) == 36) & (Strings.Mid(TestString, 9, 1) == "-"))
                                        {
                                            //
                                            // guid 726ED098-5A9E-49A9-8840-767A74F41D01 format
                                            //
                                            DataRecordGuid = TestString;
                                            DataRecordName = "";
                                            Criteria       = "ccguid=" + cp.Db.EncodeSQLText(DataRecordGuid);
                                        }
                                        else if ((Strings.Len(TestString) == 32) & (Strings.InStr(1, TestString, " ") == 0))
                                        {
                                            //
                                            // guid 726ED0985A9E49A98840767A74F41D01 format
                                            //
                                            DataRecordGuid = TestString;
                                            DataRecordName = "";
                                            Criteria       = "ccguid=" + cp.Db.EncodeSQLText(DataRecordGuid);
                                        }
                                        else
                                        {
                                            //
                                            // use name
                                            //
                                            DataRecordName = TestString;
                                            DataRecordGuid = "";
                                            Criteria       = "name=" + cp.Db.EncodeSQLText(DataRecordName);
                                        }
                                    }
                                    using (CPCSBaseClass CSData = cp.CSNew()) {
                                        if (!CSData.Open(DataContentName, Criteria, "id"))
                                        {
                                            RecordNodes = ""
                                                          + RecordNodes
                                                          + System.Environment.NewLine + "\t" + "<!-- data missing, record not found during export, content=\"" + DataContentName + "\" guid=\"" + DataRecordGuid + "\" name=\"" + DataRecordName + "\" -->";
                                        }
                                        else
                                        {
                                            //
                                            // determine all valid fields
                                            //
                                            int    fieldCnt = 0;
                                            string Sql      = "select * from ccFields where contentid=" + DataContentId;

                                            string   fieldLookupListValue = "";
                                            string[] fieldNames           = Array.Empty <string>();
                                            int[]    fieldTypes           = Array.Empty <int>();
                                            string[] fieldLookupContent   = Array.Empty <string>();
                                            string[] fieldLookupList      = Array.Empty <string>();
                                            string   FieldLookupContentName;
                                            int      FieldTypeNumber;
                                            string   FieldName;
                                            using (CPCSBaseClass csFields = cp.CSNew()) {
                                                if (csFields.Open("content fields", "contentid=" + DataContentId))
                                                {
                                                    do
                                                    {
                                                        FieldName = csFields.GetText("name");
                                                        if (FieldName != "")
                                                        {
                                                            int FieldLookupContentID = 0;
                                                            FieldLookupContentName = "";
                                                            FieldTypeNumber        = csFields.GetInteger("type");
                                                            switch (Strings.LCase(FieldName))
                                                            {
                                                            case "ccguid":
                                                            case "name":
                                                            case "id":
                                                            case "dateadded":
                                                            case "createdby":
                                                            case "modifiedby":
                                                            case "modifieddate":
                                                            case "createkey":
                                                            case "contentcontrolid":
                                                            case "editsourceid":
                                                            case "editarchive":
                                                            case "editblank":
                                                            case "contentcategoryid": {
                                                                break;
                                                            }

                                                            default: {
                                                                if (FieldTypeNumber == 7)
                                                                {
                                                                    FieldLookupContentID = csFields.GetInteger("Lookupcontentid");
                                                                    fieldLookupListValue = csFields.GetText("LookupList");
                                                                    if (FieldLookupContentID != 0)
                                                                    {
                                                                        FieldLookupContentName = cp.Content.GetRecordName("content", FieldLookupContentID);
                                                                    }
                                                                }
                                                                //CPContentBaseClass.FieldTypeIdEnum.File
                                                                switch (FieldTypeNumber)
                                                                {
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.File:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.FileImage:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.Lookup:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.Boolean:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.FileCSS:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.FileJavascript:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.FileText:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.FileXML:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.Currency:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.Float:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.Integer:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.Date:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.Link:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.LongText:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.ResourceLink:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.Text:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.HTML:
                                                                case (int)CPContentBaseClass.FieldTypeIdEnum.FileHTML: {
                                                                    var oldFieldNames = fieldNames;
                                                                    fieldNames = new string[fieldCnt + 1];
                                                                    //
                                                                    // this is a keeper
                                                                    //
                                                                    if (oldFieldNames != null)
                                                                    {
                                                                        Array.Copy(oldFieldNames, fieldNames, Math.Min(fieldCnt + 1, oldFieldNames.Length));
                                                                    }
                                                                    var oldFieldTypes = fieldTypes;
                                                                    fieldTypes = new int[fieldCnt + 1];
                                                                    if (oldFieldTypes != null)
                                                                    {
                                                                        Array.Copy(oldFieldTypes, fieldTypes, Math.Min(fieldCnt + 1, oldFieldTypes.Length));
                                                                    }
                                                                    var oldFieldLookupContent = fieldLookupContent;
                                                                    fieldLookupContent = new string[fieldCnt + 1];
                                                                    if (oldFieldLookupContent != null)
                                                                    {
                                                                        Array.Copy(oldFieldLookupContent, fieldLookupContent, Math.Min(fieldCnt + 1, oldFieldLookupContent.Length));
                                                                    }
                                                                    var oldFieldLookupList = fieldLookupList;
                                                                    fieldLookupList = new string[fieldCnt + 1];
                                                                    if (oldFieldLookupList != null)
                                                                    {
                                                                        Array.Copy(oldFieldLookupList, fieldLookupList, Math.Min(fieldCnt + 1, oldFieldLookupList.Length));
                                                                    }
                                                                    // fieldLookupContent
                                                                    fieldNames[fieldCnt]         = FieldName;
                                                                    fieldTypes[fieldCnt]         = FieldTypeNumber;
                                                                    fieldLookupContent[fieldCnt] = FieldLookupContentName;
                                                                    fieldLookupList[fieldCnt]    = fieldLookupListValue;
                                                                    fieldCnt = fieldCnt + 1;
                                                                    break;
                                                                }
                                                                }

                                                                break;
                                                            }
                                                            }
                                                        }

                                                        csFields.GoNext();
                                                    }while (csFields.OK());
                                                }
                                                csFields.Close();
                                            }
                                            //
                                            // output records
                                            //
                                            DataRecordGuid = "";
                                            while (CSData.OK())
                                            {
                                                FieldNodes     = "";
                                                DataRecordName = CSData.GetText("name");
                                                if (supportsGuid)
                                                {
                                                    DataRecordGuid = CSData.GetText("ccguid");
                                                    if (DataRecordGuid == "")
                                                    {
                                                        DataRecordGuid = cp.Utils.CreateGuid();
                                                        CSData.SetField("ccGuid", DataRecordGuid);
                                                    }
                                                }
                                                int fieldPtr;
                                                for (fieldPtr = 0; fieldPtr <= fieldCnt - 1; fieldPtr++)
                                                {
                                                    FieldName       = fieldNames[fieldPtr];
                                                    FieldTypeNumber = cp.Utils.EncodeInteger(fieldTypes[fieldPtr]);
                                                    // Dim ContentID As Integer
                                                    string FieldValue;
                                                    switch (FieldTypeNumber)
                                                    {
                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.File:
                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.FileImage: {
                                                        //
                                                        // files -- copy pathFilename to tmp folder and save pathFilename to fieldValue
                                                        FieldValue = CSData.GetText(FieldName).ToString();
                                                        if ((!string.IsNullOrWhiteSpace(FieldValue)))
                                                        {
                                                            string pathFilename = FieldValue;
                                                            cp.CdnFiles.Copy(pathFilename, tempExportPath + pathFilename, cp.TempFiles);
                                                            if (!tempPathFileList.Contains(tempExportPath + pathFilename))
                                                            {
                                                                tempPathFileList.Add(tempExportPath + pathFilename);
                                                                string path     = FileController.getPath(pathFilename);
                                                                string filename = FileController.getFilename(pathFilename);
                                                                result += System.Environment.NewLine + "\t" + "<Resource name=\"" + System.Net.WebUtility.HtmlEncode(filename) + "\" type=\"content\" path=\"" + System.Net.WebUtility.HtmlEncode(path) + "\" />";
                                                            }
                                                        }

                                                        break;
                                                    }

                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.Boolean: {
                                                        //
                                                        // true/false
                                                        //
                                                        FieldValue = CSData.GetBoolean(FieldName).ToString();
                                                        break;
                                                    }

                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.FileCSS:
                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.FileJavascript:
                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.FileText:
                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.FileXML: {
                                                        //
                                                        // text files
                                                        //
                                                        FieldValue = CSData.GetText(FieldName);
                                                        FieldValue = ExportController.EncodeCData(FieldValue);
                                                        break;
                                                    }

                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.Integer: {
                                                        //
                                                        // integer
                                                        //
                                                        FieldValue = CSData.GetInteger(FieldName).ToString();
                                                        break;
                                                    }

                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.Currency:
                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.Float: {
                                                        //
                                                        // numbers
                                                        //
                                                        FieldValue = CSData.GetNumber(FieldName).ToString();
                                                        break;
                                                    }

                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.Date: {
                                                        //
                                                        // date
                                                        //
                                                        FieldValue = CSData.GetDate(FieldName).ToString();
                                                        break;
                                                    }

                                                    case (int)CPContentBaseClass.FieldTypeIdEnum.Lookup: {
                                                        //
                                                        // lookup
                                                        //
                                                        FieldValue = "";
                                                        int FieldValueInteger = CSData.GetInteger(FieldName);
                                                        if ((FieldValueInteger != 0))
                                                        {
                                                            FieldLookupContentName = fieldLookupContent[fieldPtr];
                                                            fieldLookupListValue   = fieldLookupList[fieldPtr];
                                                            if ((FieldLookupContentName != ""))
                                                            {
                                                                //
                                                                // content lookup
                                                                //
                                                                if (cp.Content.IsField(FieldLookupContentName, "ccguid"))
                                                                {
                                                                    using (CPCSBaseClass CSlookup = cp.CSNew()) {
                                                                        CSlookup.OpenRecord(FieldLookupContentName, FieldValueInteger);
                                                                        if (CSlookup.OK())
                                                                        {
                                                                            FieldValue = CSlookup.GetText("ccguid");
                                                                            if (FieldValue == "")
                                                                            {
                                                                                FieldValue = cp.Utils.CreateGuid();
                                                                                CSlookup.SetField("ccGuid", FieldValue);
                                                                            }
                                                                        }
                                                                        CSlookup.Close();
                                                                    }
                                                                }
                                                            }
                                                            else if (fieldLookupListValue != "")
                                                            {
                                                                //
                                                                // list lookup, ok to save integer
                                                                //
                                                                FieldValue = FieldValueInteger.ToString();
                                                            }
                                                        }

                                                        break;
                                                    }

                                                    default: {
                                                        //
                                                        // text types
                                                        //
                                                        FieldValue = CSData.GetText(FieldName);
                                                        FieldValue = ExportController.EncodeCData(FieldValue);
                                                        break;
                                                    }
                                                    }
                                                    FieldNodes = FieldNodes + System.Environment.NewLine + "\t" + "<field name=\"" + System.Net.WebUtility.HtmlEncode(FieldName) + "\">" + FieldValue + "</field>";
                                                }
                                                RecordNodes = ""
                                                              + RecordNodes
                                                              + System.Environment.NewLine + "\t" + "<record content=\"" + System.Net.WebUtility.HtmlEncode(DataContentName) + "\" guid=\"" + DataRecordGuid + "\" name=\"" + System.Net.WebUtility.HtmlEncode(DataRecordName) + "\">"
                                                              + ExportController.tabIndent(cp, FieldNodes)
                                                              + System.Environment.NewLine + "\t" + "</record>";
                                                CSData.GoNext();
                                            }
                                        }
                                        CSData.Close();
                                    }
                                }
                            }
                        }
                    }
                    if (RecordNodes != "")
                    {
                        result = ""
                                 + result
                                 + System.Environment.NewLine + "\t" + "<data>"
                                 + ExportController.tabIndent(cp, RecordNodes)
                                 + System.Environment.NewLine + "\t" + "</data>";
                    }
                }
                return(result);
            } catch (Exception ex) {
                cp.Site.ErrorReport(ex);
                return(string.Empty);
            }
        }
 //
 //-------------------------------------------------
 // initialize
 //  read the report and column settings from the Db
 //  if no localGuid set, sync to Db does not work
 //  if the report does not exist in teh Db, use the input values
 //-------------------------------------------------
 //
 public reportListClass(CPBaseClass cp)
 {
 }
 //
 // ====================================================================================================
 /// <summary>
 /// The user is authenticated, but their role does not allow this activity
 /// </summary>
 /// <param name="cp"></param>
 /// <returns></returns>
 public static string getResponseForbidden(CPBaseClass cp)
 {
     cp.Response.SetStatus(HttpErrorEnum.forbidden + " Forbidden");
     return(string.Empty);
 }
 //
 // ===============================================================================
 // process Form
 // ===============================================================================
 //
 public int processForm(CPBaseClass cp, int srcFormId, string rqs, DateTime rightNow, ref int appId)
 {
     int nextFormId = srcFormId;
     try
     {
         string button = cp.Doc.GetProperty(statics.rnButton, "");
         CPCSBaseClass cs = cp.CSNew();
         //
         if (button != "")
         {
             //
             // server-side validation
             // add client-side validation in the javascript tab of the addon. (but still always include server-side)
             //
             statics.checkRequiredFieldText( cp, "name", "Name");
             //
             if (cp.UserError.OK())
             {
                 cs.Open("people", "id=" + cp.User.Id.ToString(), "", true, "", 1, 1);
                 cs.SetField("name", cp.Doc.GetText("name", ""));
                 cs.Close();
             }
         }
     }
     catch (Exception ex)
     {
         errorReport(cp, ex, "processForm");
     }
     return nextFormId;
 }
 //
 // ====================================================================================================
 //
 public static string getResponseServerError(CPBaseClass cp)
 {
     cp.Response.SetStatus(HttpErrorEnum.internalServerError + " Internal Server Error");
     return(string.Empty);
 }
 //
 // ===============================================================================
 // get Form
 // ===============================================================================
 //
 public string getForm(CPBaseClass cp, int dstFormId, string rqs, DateTime rightNow, ref int appId)
 {
     string returnHtml = "";
     try
     {
         string form = "";
         CPBlockBaseClass layout = cp.BlockNew();
         string returnJs = "";
         CPCSBaseClass cs = cp.CSNew();
         //
         // open layout, grab form, add hiddens, replace back into layout
         //
         layout.OpenLayout("sample layout");
         if (layout.GetHtml() == "")
         {
             layout.Load(sampleLayout);
             cs.Insert("Layouts");
             cs.SetField("name", "sample layout");
             cs.SetField("layout", layout.GetHtml());
             cs.Close();
         }
         //
         form = layout.GetInner("#myForm");
         form += cp.Html.Hidden(statics.rnSrcFormId, dstFormId.ToString(), "", "");
         form += cp.Html.Hidden(statics.rnAppId, appId.ToString(), "", "");
         if (!cp.UserError.OK())
         {
             form = cp.Html.div(cp.UserError.GetList(), "", "", "") + form;
         }
         form = cp.Html.Form(form, "", "", "", "", "");
         layout.SetOuter("#myForm", form);
         //
         // Populate the layout
         // attempt to open the application record. It is created in the process so this may fail.
         //      if not cs.OK(), the getFormField will return blank.
         //
         cs.Open("people", "id=" + cp.User.Id.ToString(), "", true, "", 1, 1);
         if (true)
         {
             //
             // either server-side
             //
             layout.SetOuter(".myInputRow input", cp.Html.InputText("name", statics.getFormField(cp, cs, "name"), "", "", false, "", ""));
         }
         else
         {
             //
             // or client-side
             //
             returnJs += statics.cr + "jQuery('.myInputRow myLabel').html('" + statics.getFormField(cp, cs, "name") + "')";
         }
         cs.Close();
         //
         // apply any javascript to doc
         //
         if (returnJs != "")
         {
             cp.Doc.AddHeadJavascript("jQuery(document).ready(function(){" + returnJs + statics.cr + "});");
         }
         //
         // return converted layout
         //
         returnHtml = layout.GetHtml();
     }
     catch (Exception ex)
     {
         errorReport(cp, ex, "getForm");
     }
     return returnHtml;
 }
 //
 // ====================================================================================================
 /// <summary>
 /// constructor, authentication required
 /// </summary>
 /// <param name="cp"></param>
 public ApplicationController(CPBaseClass cp)
 {
     this.cp = cp;
 }