Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // load configuration
            this.config = Configuration.GetConfiguration();

            // load language
            if (!String.IsNullOrEmpty(Request.QueryString["lang"]))
            {
                this.lang = Language.GetLanguage(Request.QueryString["lang"]);
                dialogBody.Attributes["dir"] = this.lang.Direction;
            }
            dialogBody.Attributes["onload"] = "SpawDialog.dialogInit();";

            // load theme
            if (!String.IsNullOrEmpty(Request.QueryString["theme"]))
            {
                this.theme = Solmetra.Spaw2.Theme.GetTheme(Request.QueryString["theme"]);
            }

            // set output charset
            if (!String.IsNullOrEmpty(Request.QueryString["charset"]))
                Response.ContentEncoding = System.Text.Encoding.GetEncoding(Request.QueryString["charset"]);

            if (this.config != null && this.theme != null && this.lang != null)
            {
                // load control
                string module = Request.QueryString["module"];
                string dialog = Request.QueryString["dialog"];
                if (!String.IsNullOrEmpty(module) && module.IndexOfAny(new char[2] { '/', '\\' }) == -1
                    && !String.IsNullOrEmpty(dialog) && dialog.IndexOfAny(new char[2] { '/', '\\' }) == -1)
                {
                    Page.Title = "SPAW Editor v.2d: " + this.lang.GetMessage(module, dialog, "title");
                    DialogControl dialog_control = (DialogControl)LoadControl(Configuration.PluginDirectory + module + "/dialogs/" + dialog + ".ascx");
                    dialog_control.Configuration = this.config;
                    dialog_control.Theme = this.theme;
                    dialog_control.Language = this.lang;

                    header_template = this.theme.TemplateDialogHeader.Replace("{SPAW DIALOG TITLE}", this.lang.GetMessage(module, dialog, "title")).Replace("{SPAW DIR}", Configuration.SpawDirectory);
                    footer_template = this.theme.TemplateDialogFooter.Replace("{SPAW DIR}", Configuration.SpawDirectory);

                    DialogHeader.Controls.Add(new LiteralControl(header_template));
                    DialogFooter.Controls.Add(new LiteralControl(footer_template));

                    DialogContent.Controls.Add(dialog_control);
                }
            }
        }
Exemple #2
0
 public static Theme GetTheme(string name)
 {
     Theme t = new Theme(name);
     t.LoadData();
     return t;
 }
Exemple #3
0
        public void Render(HtmlTextWriter writer, string prefix, Theme theme)
        {
            StringBuilder js_sb = new StringBuilder();
            StringBuilder html_sb = new StringBuilder();

            html_sb.Append("<span style=\"white-space: nowrap;\">");

            int i = 0; // counter for toolbar item names
            if (this._items != null)
            {
                foreach (ToolbarItem tbi in this._items)
                {
                    string id = prefix + "_" + this.Name + "_" + i.ToString();
                    switch (tbi.GetType().Name)
                    {
                        case "ToolbarImage":
                            js_sb.Append(prefix + "_obj.addToolbarItem(new SpawTbImage(\"" + tbi.Module + "\",\"" + tbi.Name + "\",\"" + id + "\"),\"" + this.Name + "\");");
                            html_sb.Append("<img id=\"" + id + "\" src=\"" + Configuration.PluginDirectory + tbi.Module + "/lib/theme/" + theme.Name + "/img/tb_" + tbi.Name + ".gif\"");

                            if (theme.IsCustomStyleToolbarItem(tbi.Name))
                                html_sb.Append(" style=\"" + theme.CustomToolbarItemStyles[tbi.Name] + "\"");
                            else if (!String.IsNullOrEmpty(theme.DefaultToolbarImageStyle))
                                html_sb.Append(" style=\"" + theme.DefaultToolbarImageStyle + "\"");

                            if (theme.IsCustomCssClassToolbarItem(tbi.Name))
                                html_sb.Append(" class=\"" + theme.CustomToolbarItemCssClasses[tbi.Name] + "\"");
                            else if (!String.IsNullOrEmpty(theme.DefaultToolbarImageCssClass))
                                html_sb.Append(" class=\"" + theme.DefaultToolbarImageCssClass + "\"");

                            html_sb.Append(" alt=\"\" />");

                            break;

                        case "ToolbarButton":
                            string img_src = tbi.Module + "/lib/theme/" + theme.Name + "/img/tb_" + tbi.Name + ".gif";
                            ToolbarButton tbb = (ToolbarButton)tbi;
                            if (!File.Exists(Configuration.PhysicalPluginDirectory + img_src))
                            {
                                // use default plugin button
                                img_src = "core/lib/theme/" + theme.Name + "/img/tb__plugin.gif";
                            }
                            js_sb.Append(prefix+"_obj.addToolbarItem(new SpawTbButton(\""+tbb.Module+"\",\""+tbb.Name+"\",\""+id+"\",\""+tbb.OnEnabledCheck+"\",\""+tbb.OnPushedCheck+"\",\""+tbb.OnClick+"\",\""+Configuration.PluginDirectory+img_src+"\","+(tbb.ShowInContextMenu?"true":"false")+"),\""+this.Name+"\");");

                            html_sb.Append("<img id=\"" + id + "\" src=\"" + Configuration.PluginDirectory + img_src + "\"");

                            if (theme.IsCustomStyleToolbarItem(tbb.Name))
                                html_sb.Append(" style=\"" + theme.CustomToolbarItemStyles[tbb.Name] + " cursor: default;\"");
                            else if (!String.IsNullOrEmpty(theme.DefaultToolbarButtonStyle))
                                html_sb.Append(" style=\"" + theme.DefaultToolbarButtonStyle + " cursor: default;\"");
                            else
                                html_sb.Append(" style=\"cursor: default;\"");

                            if (theme.IsCustomCssClassToolbarItem(tbb.Name))
                                html_sb.Append(" class=\"" + theme.CustomToolbarItemCssClasses[tbb.Name] + "\"");
                            else if (!String.IsNullOrEmpty(theme.DefaultToolbarButtonCssClass))
                                html_sb.Append(" class=\"" + theme.DefaultToolbarButtonCssClass + "\"");

                            html_sb.Append(" onclick=\"SpawPG" + tbb.Module + "." + tbb.OnClick + "(" + prefix + "_obj.getTargetEditor()," + prefix + "_obj.getToolbarItem('" + id + "'), this);\"");
                            html_sb.Append(" onmouseover=\"" + prefix + "_obj.theme.buttonOver(" + prefix + "_obj.getToolbarItem('" + id + "'), this);\"");
                            html_sb.Append(" onmouseout=\"" + prefix + "_obj.theme.buttonOut(" + prefix + "_obj.getToolbarItem('" + id + "'), this);\"");
                            html_sb.Append(" onmousedown=\"" + prefix + "_obj.theme.buttonDown(" + prefix + "_obj.getToolbarItem('" + id + "'), this);\"");
                            html_sb.Append(" onmouseup=\"" + prefix + "_obj.theme.buttonUp(" + prefix + "_obj.getToolbarItem('" + id + "'), this);\"");
                            html_sb.Append(" alt=\"" + this.Editor.Language.GetMessage(tbb.Module, tbb.Name, "title") + "\"");
                            html_sb.Append(" title=\"" + this.Editor.Language.GetMessage(tbb.Module, tbb.Name, "title") + "\"");
                            html_sb.Append(" unselectable=\"on\"");
                            html_sb.Append(" />");

                            break;

                        case "ToolbarDropdown":
                            ToolbarDropdown tbd = (ToolbarDropdown)tbi;
                            if (tbd.Data != null && tbd.Data.Count > 0)
                            {
                                js_sb.Append(prefix + "_obj.addToolbarItem(new SpawTbDropdown(\"" + tbd.Module + "\",\"" + tbd.Name + "\",\"" + id + "\",\"" + tbd.OnEnabledCheck + "\",\"" + tbd.OnStatusCheck + "\",\"" + tbd.OnChange + "\"),\"" + this.Name + "\");");

                                html_sb.Append("<select size=\"1\" id=\"" + id + "\" ");

                                if (theme.IsCustomStyleToolbarItem(tbd.Name))
                                    html_sb.Append(" style=\"" + theme.CustomToolbarItemStyles[tbd.Name] + "\"");
                                else if (!String.IsNullOrEmpty(theme.DefaultToolbarDropdownStyle))
                                    html_sb.Append(" style=\"" + theme.DefaultToolbarDropdownStyle + "\"");

                                if (theme.IsCustomCssClassToolbarItem(tbd.Name))
                                    html_sb.Append(" class=\"" + theme.CustomToolbarItemCssClasses[tbd.Name] + "\"");
                                else if (!String.IsNullOrEmpty(theme.DefaultToolbarDropdownCssClass))
                                    html_sb.Append(" class=\"" + theme.DefaultToolbarDropdownCssClass + "\"");

                                html_sb.Append(" onchange=\"SpawPG" + tbd.Module + "." + tbd.OnChange + "(" + prefix + "_obj.getTargetEditor()," + prefix + "_obj.getToolbarItem('" + id + "'), this);\"");
                                html_sb.Append(" onmouseover=\"" + prefix + "_obj.theme.dropdownOver(" + prefix + "_obj.getToolbarItem('" + id + "'), this);\"");
                                html_sb.Append(" onmouseout=\"" + prefix + "_obj.theme.dropdownOut(" + prefix + "_obj.getToolbarItem('" + id + "'), this);\"");
                                html_sb.Append(" onmousedown=\"" + prefix + "_obj.theme.dropdownDown(" + prefix + "_obj.getToolbarItem('" + id + "'), this);\"");
                                html_sb.Append(" onmouseup=\"" + prefix + "_obj.theme.dropdownUp(" + prefix + "_obj.getToolbarItem('" + id + "'), this);\"");
                                html_sb.Append(">");

                                html_sb.Append("<option>" + this.Editor.Language.GetMessage(tbd.Module, tbd.Name, "title") + "</option>");

                                foreach (ListItem li in tbd.Data)
                                    html_sb.Append("<option value=\"" + li.Value + "\">" + li.Text + "</option>");

                                html_sb.Append("</select>");
                            }
                            break;
                        default:
                            break;
                    }
                    i++;
                }
                html_sb.Append("</span>");
                js_sb.Insert(0, "<script type=\"text/javascript\">\n<!--\n");
                js_sb.Append("\n//-->\n</script>");

                writer.Write(js_sb.ToString());
                writer.Write(html_sb.ToString());
            }
        }
Exemple #4
0
        private void ApplyDefaults()
        {
            if (this.Pages.Count == 0)
                // add first page
                this._pages.Add(new EditorPage(this.ID, this.ID, String.Empty));

            // language
            if (this._language == null)
                //this._language = Language.GetLanguage(this.Configuration["default_lang"].Value);
                this._language = Language.GetLanguage(Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName);

            // theme
            if (this._theme == null)
                this._theme = Theme.GetTheme(this.Configuration["default_theme"].Value);

            // toolbarset
            if (this._toolbars == null)
            {
                this._toolbars = new Dictionary<string, Toolbar>();
                foreach (XmlNode tbnode in this.Configuration["toolbarset_" + this.Configuration["default_toolbarset"].Value].XmlNode.SelectNodes("toolbar"))
                {
                    string toolbarToLoad = tbnode.Attributes["name"].Value;
                    if (tbnode.Attributes["substitute"] != null)
                        toolbarToLoad = tbnode.Attributes["substitute"].Value;
                    this._toolbars.Add(tbnode.Attributes["name"].Value, Toolbar.GetToolbar(this, toolbarToLoad));
                }
            }

            // values
            if (String.IsNullOrEmpty(this.Stylesheet))
                this.Stylesheet = this.Configuration["default_stylesheet"].Value;
        }