Exemplo n.º 1
0
        private StringBuilder exportTemplate(string template)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("<template name=\"{0}\">\n", template);
            sb.AppendFormat("\t<code>\n{0}\n\t</code>\n", CMSUtility.HtmlEncode(Provider.Database.GetValue("select HTMLCode from Template where FileName={0}", template).ToString()));
            Module[] modules = Module.Read(template);
            getSerializedModule(sb, modules, "\t");
            sb.Append("</template>\n");
            return(sb);
        }
Exemplo n.º 2
0
        internal override string show()
        {
            StringBuilder sb = new StringBuilder();

            string commentLink   = Provider.GetModuleResource("Comment");
            string emailLink     = Provider.GetModuleResource("Feedback");
            string printLink     = Provider.GetModuleResource("Print");
            string recommendLink = Provider.GetModuleResource("Recommend");

            Entities.Content content = Provider.Content;

            bool     commentsModuleExist = this.ContainerPage == null;
            Comments mdlComments         = null;

            if (this.ContainerPage != null)
            {
                commentsModuleExist = this.ContainerPage.HasModule(typeof(Comments));
                if (commentsModuleExist)
                {
                    mdlComments = (Comments)this.ContainerPage.GetModule(typeof(Comments));
                }
            }

            if (String.IsNullOrEmpty(this.printPage))
            {
                this.printPage = "Print.ashx";
            }

            Hashtable tools = new Hashtable();

            tools["comment"] = (commentsModuleExist || Provider.DesignMode) ? String.Format("<a class=\"comment\" href=\"javascript:{0}\">{1}</a>", mdlComments == null ? "void(0)" : mdlComments.getWriteCommentJS(), getToolHtml(commentIcon, commentLink)) : "";
            tools["email"]   = String.Format("<a class=\"email\" href=\"mailto:{0}?subject={1}\">{2}</a>", Provider.Configuration.AuthEmail, content == null ? "" : CMSUtility.HtmlEncode(content.Title), getToolHtml(emailIcon, emailLink));
            tools["print"]   = content != null?String.Format("<a class=\"print\" href=\"{0}?item={1}\" target=\"_blank\">{2}</a>", printPage, content.Id, getToolHtml(printIcon, printLink)) : "";

            tools["recommendation"] = String.Format("<a class=\"recommend\" href=\"javascript:recommend({0})\">{1}</a>", this.Id, getToolHtml(recommendIcon, recommendLink));

            foreach (string toolName in this.toolOrder.Split(','))
            {
                if (tools.ContainsKey(toolName))
                {
                    sb.Append(tools[toolName]);
                }
            }

            return(sb.ToString());
        }
Exemplo n.º 3
0
 private void getSerializedModule(StringBuilder sb, IEnumerable modules, string tab)
 {
     sb.AppendFormat("{0}<modules>\n", tab);
     foreach (Module mdl in modules)
     {
         sb.AppendFormat("{0}\t<module name=\"{1}\">\n{0}\t\t<serializedData>\n{2}\n{0}\t\t</serializedData>\n", tab, mdl.Name, CMSUtility.HtmlEncode(mdl.Serialize()));
         if (mdl is IRegionContainer)
         {
             List <Module> childModules = (mdl as ModuleContainer).ChildModules;
             getSerializedModule(sb, childModules, tab + "\t");
         }
         sb.AppendFormat("{0}\t</module>\n", tab);
     }
     sb.AppendFormat("{0}</modules>\n", tab);
 }
Exemplo n.º 4
0
        internal override string show()
        {
            StringBuilder sb = new StringBuilder();

            string thanksMessage = Provider.GetModuleResource("Your message has been sent. Thank you.");

            string errorMessage = "";

            if (Provider.Request["contactUsForm"] == this.Id.ToString())
            {
                Entities.ContactUs contactUs = new Entities.ContactUs();
                contactUs.Email   = Provider.Request["email"];
                contactUs.Message = Provider.Request["message"];
                contactUs.Name    = Provider.Request["name"];
                contactUs.Subject = Provider.Request["subject"];

                try
                {
                    if (Provider.Session["captcha"].ToString() != Provider.Request["capt"])
                    {
                        throw new Exception("Lütfen işlem sonucunu tekrar giriniz.");
                    }

                    contactUs.Save();
                    if (sendMail)
                    {
                        Provider.SendMail(contactUs.Email, contactUs.Name, Provider.Configuration.AuthEmail, Provider.Configuration.SiteName, Provider.GetResource("From visitor: ") + contactUs.Subject, contactUs.Message + "<br/><br/>" + contactUs.Name + "<br/>" + contactUs.Email);
                    }
                    return(thanksMessage);
                }
                catch (Exception ex)
                {
                    errorMessage = ex.Message.Replace("\n", "<br/>\n");
                }
            }

            sb.Append("<form action=\"" + Provider.Request.RawUrl + "\" method=\"post\">");
            sb.AppendFormat("<input type=\"hidden\" name=\"contactUsForm\" value=\"{0}\"/>", this.Id);

            if (errorMessage != "")
            {
                sb.AppendFormat("<div class=\"error\">{0}</div>", errorMessage);
            }

            sb.AppendFormat("{0}<br/>", Provider.GetModuleResource("Your Name"));
            sb.AppendFormat("<input class=\"name\" type=\"text\" name=\"name\" value=\"{0}\"/><br/>", CMSUtility.HtmlEncode(Provider.Request["name"]));
            sb.AppendFormat("{0}<br/>", Provider.GetModuleResource("Your Email Address"));
            sb.AppendFormat("<input class=\"email\" type=\"text\" name=\"email\" value=\"{0}\"/><br/><br/>", CMSUtility.HtmlEncode(Provider.Request["email"]));

            sb.AppendFormat("{0}<br/>", Provider.GetModuleResource("Subject"));
            sb.AppendFormat(@"<select class=""subject"" name=""subject"" value=""{0}"">
                <option value="""">{1}</option>
                <option value=""{2}"">{2}</option>
                <option value=""{3}"">{3}</option>
                <option value=""{4}"">{4}</option>
                <option value=""{5}"">{5}</option></select><br/>", CMSUtility.HtmlEncode(Provider.Request["subject"]),
                            Provider.GetResource("Select"),
                            Provider.GetModuleResource("Thank"),
                            Provider.GetModuleResource("Complaint"),
                            Provider.GetModuleResource("Request"),
                            Provider.GetModuleResource("Recommendation"));
            sb.AppendFormat("{0}<br/>", Provider.GetModuleResource("Your Message"));
            sb.AppendFormat("<textarea class=\"message\" name=\"message\">{0}</textarea><br/><br/>", CMSUtility.HtmlEncode(Provider.Request["message"]));

            var r = new Random();
            int a = r.Next(10) + 1;
            int b = r.Next(10) + 1;

            Provider.Session["captcha"] = (a + b).ToString();
            sb.AppendFormat(a + " + " + b + " = ? ");
            sb.AppendFormat("<input class=\"capt\" type=\"text\" name=\"capt\" value=\"\"/><br/>");


            sb.AppendFormat("<input class=\"send\" type=\"submit\" value=\"{0}\"/>", Provider.GetResource("Send"));

            sb.Append("</form>");

            return(sb.ToString());
        }
Exemplo n.º 5
0
        internal override string show()
        {
            string q = Provider.Request["q"];

            if (q == null)
            {
                q = "";
            }

            StringBuilder sb = new StringBuilder();

            sb.AppendFormat("<form id=\"fSearch_{0}\" method=\"get\" action=\"{1}\">", this.Id, this.resultsPage);
            sb.AppendFormat("<input class=\"searchText\" type=\"text\" name=\"q\" value=\"{0}\"/>", CMSUtility.HtmlEncode(q));
            sb.AppendFormat("<span class=\"cbtn cSearchResults\" onClick=\"$('fSearch_{0}').submit();return false;\"></span>", this.Id);
            sb.AppendFormat("</form>");
            return(sb.ToString());
        }
Exemplo n.º 6
0
        private void getGridList()
        {
            string entityName = context.Request["entityName"];

            string where = context.Request["extraFilter"] ?? "";
            string orderBy = context.Request["orderBy"] ?? "";
            string page    = String.IsNullOrEmpty(context.Request["page"]) ? "0" : context.Request["page"];
            string limit   = String.IsNullOrEmpty(context.Request["limit"]) ? "20" : context.Request["limit"];
            int    fieldNo = 0;

            Type       entityType   = Provider.GetEntityType(entityName);
            BaseEntity sampleEntity = Provider.CreateEntity(entityType);

            while (context.Request.Form["f_" + fieldNo] != null)
            {
                string op    = context.Request.Form["o_" + fieldNo];
                string field = context.Request.Form["f_" + fieldNo];
                string val   = context.Request.Form["c_" + fieldNo];
                where += (where == "" ? "" : " AND ") + field + op + val;
                fieldNo++;
            }
            if (!string.IsNullOrWhiteSpace(context.Request.Form["search"]))
            {
                string search = context.Request.Form["search"];
                if (!search.Contains("%"))
                {
                    search = "%" + search + "%";
                }
                where += " AND " + sampleEntity.GetNameColumn() + "like" + search;
            }

            FilterParser filterParser = new FilterParser(where, entityName);

            where = filterParser.GetWhere();

            DataTable dt = Provider.ReadList(entityType, Int32.Parse(page), Int32.Parse(limit), orderBy, where, filterParser.GetParams());

            context.Response.Write("<table class=\"bk-grid\" border=\"0\" cellspacing=\"0\" cellpadding=\"2\">\n");
            if (dt != null)
            {
                context.Response.Write("\t<tr>\n");
                foreach (DataColumn dc in dt.Columns)
                {
                    if (dc.ColumnName == "_CinarRowNumber")
                    {
                        continue;                                     //***
                    }
                    string columnName  = dc.ColumnName;
                    string columnTitle = Provider.TranslateColumnName(entityName, columnName);
                    context.Response.Write("\t\t<th id=\"h_" + dc.ColumnName + "\">" + columnTitle + "</th>\n");
                }
                context.Response.Write("\t</tr>\n");
            }
            if (dt != null)
            {
                if (dt.Rows.Count == 0)
                {
                    context.Response.Write("\t<tr><td style=\"padding:30px;text-align:center\" colspan=\"50\">" + Provider.GetResource("No record") + "</td></tr>\n");
                }
                else
                {
                    for (int i = 0; i < dt.Rows.Count; i++)
                    {
                        DataRow dr = dt.Rows[i];
                        context.Response.Write("\t<tr id=\"r_" + dr[0] + "\">\n");
                        foreach (DataColumn dc in dt.Columns)
                        {
                            if (dc.ColumnName == "_CinarRowNumber")
                            {
                                continue;                                     //***
                            }
                            object valObj  = dr[dc.ColumnName];
                            string dispVal = "";
                            if (dr.IsNull(dc))
                            {
                                dispVal = "";
                            }
                            else if (dc.DataType == typeof(Boolean))
                            {
                                dispVal = ((bool)valObj) ? Provider.GetResource("Yes") : Provider.GetResource("No");
                            }
                            else if (dc.DataType == typeof(String))
                            {
                                string str = Regex.Replace(valObj.ToString(), "<.*?>", string.Empty);
                                if (str.Length > 50)
                                {
                                    dispVal = CMSUtility.HtmlEncode(str.StrCrop(50)); // str.Substring(0, 50) + "..."
                                }
                                else
                                {
                                    dispVal = str;
                                }
                            }
                            else if (dc.DataType == typeof(DateTime))
                            {
                                dispVal = ((DateTime)valObj).ToString(Provider.Configuration.DefaultDateFormat);
                            }
                            else
                            {
                                dispVal = valObj.ToString();
                            }
                            context.Response.Write("\t\t<td value=\"" + CMSUtility.HtmlEncode(valObj) + "\">" + dispVal + "</td>\n");
                        }
                        context.Response.Write("\t</tr>\n");
                    }
                }
            }
            context.Response.Write("</table>");
        }