Beispiel #1
0
        public override void RenderInEditMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            HtmlContentDb    db    = new HtmlContentDb();
            RenderParameters param = RenderParameters.fromParamList(paramList);

            string htmlContent = "";

            string editorId = "htmlcontent_" + page.ID.ToString() + "_" + identifier.ToString() + "_" + langToRenderFor.shortCode;

            // ------- CHECK THE FORM FOR ACTIONS
            string action = PageUtils.getFromForm(editorId + "_Action", "");

            if (action.Trim().ToLower() == "update")
            {
                htmlContent = PageUtils.getFromForm("name_" + editorId, "");
                bool b = db.saveUpdatedHtmlContent(page, identifier, langToRenderFor, htmlContent);
            }
            else
            {
                htmlContent = db.getHtmlContent(page, identifier, langToRenderFor, true);
            }

            // ------- START RENDERING
            // -- get the Javascript
            StringBuilder html = new StringBuilder();

            string EOL = Environment.NewLine;

            // -- render the Control

            // Add the javascript references
            CKEditorHelpers.AddPageJavascriptStatements(page, editorId, param.renderWidth, param.renderHeight, langToRenderFor);

            StringBuilder arg0 = new StringBuilder();


            arg0.Append("<div style=\"width: 100%\">");

            arg0.Append("<textarea name=\"name_" + editorId + "\" id=\"" + editorId + "\" style=\"width: " + param.renderWidth + "; height: " + param.renderHeight + ";\">");
            arg0.Append(htmlContent);
            arg0.Append("</textarea>" + EOL);

            arg0.Append("<input type=\"hidden\" name=\"" + editorId + "_Action\" value=\"update\">");

            arg0.Append("</div>");

            string formattedOutput = String.Format(param.renderTemplate, arg0.ToString());

            html.Append(formattedOutput);

            writer.WriteLine(html.ToString());
        }
Beispiel #2
0
        public override RevertToRevisionResult RevertToRevision(CmsPage oldPage, CmsPage currentPage, int[] identifiers, CmsLanguage language)
        {
            HtmlContentDb htmlDb = new HtmlContentDb();

            foreach (int identifier in identifiers)
            {
                string oldHtml = htmlDb.getHtmlContent(oldPage, identifier, language, false);
                bool   b       = htmlDb.saveUpdatedHtmlContent(currentPage, identifier, language, oldHtml);
                if (!b)
                {
                    return(RevertToRevisionResult.Failure);
                }
            } // foreach

            return(RevertToRevisionResult.Success);
        }
Beispiel #3
0
        public override void RenderInViewMode(HtmlTextWriter writer, CmsPage page, int identifier, CmsLanguage langToRenderFor, string[] paramList)
        {
            RenderParameters param = RenderParameters.fromParamList(paramList);

            if (param.outputOnlyInEditMode)
            {
                return; // output nothing
            }
            HtmlContentDb db   = new HtmlContentDb();
            string        arg0 = db.getHtmlContent(page, identifier, langToRenderFor, true);

            bool doOutput = true;

            if (param.outputOnlyIfHasContent)
            {
                if (arg0.Trim() == "")
                {
                    return; // output nothing (and short-circuit the StripHTMLTags function)
                }
                string textOnly = StringUtils.StripHTMLTags(arg0);
                if (textOnly.Trim() != "")
                {
                    doOutput = true;
                }
                else
                {
                    return; // output nothing (short-circuit everything else)
                }
            }

            if (doOutput)
            {
                string formattedOutput = String.Format(param.renderTemplate, arg0.ToString());

                writer.WriteLine(formattedOutput);
            }
        } // RenderView