Pman.Dialog.CmsBlog.Old.bjs
authoredward <edward@roojs.com>
Tue, 14 Mar 2017 06:45:55 +0000 (14:45 +0800)
committeredward <edward@roojs.com>
Tue, 14 Mar 2017 06:45:55 +0000 (14:45 +0800)
Pman.Dialog.CmsBlog.Old.js

Pman.Dialog.CmsBlog.Old.bjs
Pman.Dialog.CmsBlog.Old.js [new file with mode: 0644]

index 921af41..629d426 100644 (file)
  "path" : "/home/edward/gitlive/Pman.Cms/Pman.Dialog.CmsBlog.Old.bjs",
  "permname" : "",
  "modOrder" : "001",
+ "strings" : {
+  "2f26e35d61be90501e099089dc533638" : "Select Images",
+  "f3912172e6bf57f8979782f4a2342233" : "Appears in Block",
+  "95cb4f45ab7ff3984f25ab8668499020" : "Select Parent",
+  "c1df1da7a1ce305a3b60af9d5733ac1d" : "Contents",
+  "f2a6c498fb90ee345d997f888fce3b18" : "Delete",
+  "ebd9bec4d70abc789d439c1f136b0538" : "Layout",
+  "20bec77364d863100a1f9325873a8504" : "Select Page Type",
+  "a517747c3d12f99244ae598910d979c5" : "Author",
+  "779e2624ddf330fb05b51ae59faf212d" : "Select Status Type",
+  "6a5b847af3d97df722040debdbccfbed" : "Page Type",
+  "30d1a216420426fcbd43ca70acd4aa48" : "Select interests",
+  "e6b391a8d2c4d45902a23a8b6585703d" : "URL",
+  "ec211f7c20af43e742bf2570c3cb84f9" : "Add",
+  "778551900655782c5c7827332b08cf3f" : "Save and close",
+  "77174410b72decfd0b259961f1f65a8f" : "Attributes:",
+  "b28a711cf7e94ec793ef926633997529" : "Seq",
+  "1243daf593fa297e07ab03bf06d925af" : "Searching...",
+  "580b21aac58f1b73cece26e272cdfbee" : "Add Link",
+  "8bc84316c4078bf66723fd019616d920" : "Descriptions",
+  "83dad8107f9459efe2b4fabcf5b63108" : "Select Language",
+  "76729937a5eb6b0fd88c42581161facd" : "Select Category",
+  "0b8d92bc19b720bb1065649535463409" : "Translations",
+  "d41d8cd98f00b204e9800998ecf8427e" : "",
+  "867343577fa1f33caa632a19543bd252" : "Keywords",
+  "340c2ee497b85d5954b01c64de7f44f6" : "Select Person",
+  "69dd756ae9c23191a5bb9b61f0857432" : "Date to Publish",
+  "3adbdb3ac060038aa0e6e6c138ef9873" : "Category",
+  "57e195426892c5515935f21d97228814" : "Extended Contents",
+  "d88aa1eee60ba140f07d5f81769cec74" : "<< Edit Translations",
+  "b9c49611cfda3259a2b837b39489e650" : "Add Image",
+  "ea4788705e6873b424c65e91c2846b19" : "Cancel",
+  "cfcd208495d565ef66e7dff9f98764da" : "0",
+  "bd88a20b53a47f7b5704a83a15ff5506" : "Saved Version",
+  "70a4bc2672e2e3912e6476a2bd7ba29b" : "Parent page",
+  "31bb2f6e9b8fb11cbb7fb63c6025223f" : "Select Template",
+  "c02bd0c22c290ae599ee2f3ff2023fd3" : "Manage Images / Attachments >>",
+  "b78a3223503896721cca1303f776159b" : "Title",
+  "39f64cc9436cacfbceda3b7bdeb8e24c" : "Styles (CSS)",
+  "e64df1d7c22b9638f084ce8a4aff3ff3" : "Target URL",
+  "a240fa27925a635b08dc28c9e4f9216d" : "Order",
+  "287234a1ff35a314b5b6bc4e5828e745" : "Attributes",
+  "99e7707748ae048e17c5810fad119e0b" : "Select Page",
+  "06933067aafd48425d67bcb01bba5cb6" : "Update",
+  "8adedb6a6226807ba810215dd3b3c61b" : "Menu links to Page",
+  "b5216c9b4e0ac0afd9c76eb1d12ad1b9" : "Select Section",
+  "308f2757bfc9ce92fb00ff93fdffd279" : "Images / Attachments",
+  "1351017ac6423911223bc19a8cb7c653" : "Filename",
+  "c9cc8cce247e49bae79f15173ce97354" : "Save",
+  "e659b52eba1f0299b2d8ca3483919e72" : "Type:",
+  "c70952e4ab3806c049737cd7d2b8896b" : "Interests",
+  "aa6356b678bc4fc78253c9edf65bff03" : "Edit Page / Blog Entry",
+  "d52f80f80467bb575253a5a39ca016a7" : "Page link /  Name / Order",
+  "fff0d600f8a0b5e19e88bfb821dd1157" : "Images",
+  "fb3f11443065d5f4d8303ad913db9680" : "Replaces (ignore)"
+ },
  "items" : [
+  {
+   "listeners" : {
+    "show" : "function (_self)\n{\n    // @see the contentpanel - center - resize handler.\n\n    var w = Roo.lib.Dom.getViewWidth();\n    var h = Roo.lib.Dom.getViewHeight();    \n    this.resizeTo(w-50, h-50);\n    this.center();\n    \n    var ew = Math.max(250, w-150); // was 350?/ why?\n    var eh = Math.max(250, h-350) ;\n    \n    var bd = _this.form.findField('body');\n    if (bd.resizeEl) { \n        bd.width = ew;\n        bd.height = eh;\n        // since render delays resize.. \n       bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );\n        _this.bodycol.el.setWidth(bd.width+20);\n    }\n    var bd = _this.form.findField('extended');\n    if (bd.resizeEl) { \n        bd.width = ew;\n        bd.height = eh;\n        // since render delays resize.. \n       bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );\n       _this.extendcol.el.setWidth(bd.width+20);\n    }\n     var bd = _this.form.findField('extra_css');\n    if (bd) { \n        bd.el.setWidth(ew);\n       _this.keywordscol.el.setWidth(ew+20);\n    }\n    Pman.Cms.pageEditAddCustomFields();\n    // fix messed up scroll.\n    _this.dialog.layout.el.dom.scrollTop = 0;\n\n}"
+   },
+   "modal" : true,
+   "collapsible" : false,
+   "background" : true,
+   "title" : "Edit Page / Blog Entry",
+   "xtype" : "LayoutDialog",
+   "| function setStylesheets" : "function() {\n    var sheets = [];\n    \n    sheets.push(rootURL + '/Pman/Cms/templates/undoreset.css');\n    \n    if(typeof(uiConfig) !== 'undefined'  && typeof(uiConfig.cms_css) != 'undefined'){\n        Roo.each(uiConfig.cms_css, function(v){\n            sheets.push(rootURL + v);\n        })\n    }\n    \n    new Pman.Request({\n       url : baseURL + '/Roo/Cms_page.php',\n       method : 'GET',\n       params : {\n           _stylesheets : 1\n       }, \n       success : function(res) {\n            Roo.log(res);\n            if(res.data._stylesheets.length){\n                var setting = res.data._stylesheets.split(\"\\n\");\n                \n                Roo.each(setting, function(s){\n                    sheets.push(s.replace('{rootURL}', rootURL));\n                });\n                \n            }\n            Roo.log(sheets);\n            Roo.log(_this.form.findField('body'));\n            _this.form.findField('body').removeStylesheets();\n            _this.form.findField('extended').removeStylesheets();\n\n            _this.form.findField('body').setStylesheets(sheets);\n            _this.form.findField('extended').setStylesheets(sheets);\n\n            _this.trform.findField('body').removeStylesheets();\n            _this.trform.findField('extended').removeStylesheets();\n            \n            _this.trform.findField('body').setStylesheets(sheets);\n            _this.trform.findField('extended').setStylesheets(sheets);\n       }\n   });\n\n}",
+   "width" : 850,
+   "$ xns" : "Roo",
+   "closable" : true,
+   "resizable" : false,
+   "height" : 600,
+   "items" : [
+    {
+     "xtype" : "LayoutRegion",
+     "$ xns" : "Roo",
+     "* prop" : "center",
+     "titlebar" : false
+    },
+    {
+     "listeners" : {
+      "expanded" : "function (_self)\n{\n    var id = _this.form.findField('id').getValue() * 1;\n    \n    if(id < 1){\n        Roo.MessageBox.alert('Error', 'Save first');\n        this.collapse();\n        return;\n    }\n    \n    var w = Roo.lib.Dom.getViewWidth();\n    var h = Roo.lib.Dom.getViewHeight();\n    \n    _self.resizeTo.defer(110, _self,[ w-400,  h-350] );\n    \n    _this.panel.region.collapse();\n    \n}"
+     },
+     "collapsedTitle" : "Translations",
+     "collapsible" : true,
+     "fitToFrame" : true,
+     "title" : "Translations",
+     "xtype" : "LayoutRegion",
+     "collapsed" : true,
+     "$ xns" : "Roo",
+     "split" : true,
+     "* prop" : "west",
+     "titlebar" : true
+    },
+    {
+     "listeners" : {
+      "expanded" : "function (_self)\n{\n    var id = _this.form.findField('id').getValue() * 1;\n    \n    if(id < 1){\n        Roo.MessageBox.alert('Error', 'Save first');\n        this.collapse();\n        return;\n    }\n    \n    var w = Roo.lib.Dom.getViewWidth();\n    var h = Roo.lib.Dom.getViewHeight();\n    \n    _self.resizeTo.defer(110, _self,[ w-400,  h] );\n    _this.trpanel.region.collapse();\n}"
+     },
+     "collapsedTitle" : "Images / Attachments",
+     "collapsible" : true,
+     "fitToFrame" : true,
+     "title" : "Images / Attachments",
+     "xtype" : "LayoutRegion",
+     "collapsed" : true,
+     "$ xns" : "Roo",
+     "split" : true,
+     "* prop" : "east",
+     "titlebar" : true
+    },
+    {
+     "listeners" : {
+      "resize" : "function (_self, width, height)\n{\n      Roo.log(\"RESIZE, \" + width + ',' + height);\n    \n    var ew = Math.max(250, width-50);\n    var eh = Math.max(250,height-50) ;\n    if (!_this.form) {\n        return;\n        }\n    \n    var bd = _this.form.findField('body');\n    if (bd.resizeEl) { \n        bd.width = ew;\n        bd.height = eh;\n        // since render delays resize.. \n        Roo.log('resizing body to ' + bd.width);        \n       bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );\n        _this.bodycol.el.setWidth(bd.width+20);\n    }\n    \n    \n    bd = _this.form.findField('extended');\n    if (bd.resizeEl) { \n        bd.width = ew;\n        bd.height = eh;\n        \n        Roo.log('resizing extended to ' + bd.width);\n        // since render delays resize.. \n       bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );\n       _this.extendcol.el.setWidth(bd.width+20);\n    }\n    bd = _this.form.findField('extra_css');\n    if (bd) { \n        bd.el.setWidth(ew);\n       _this.keywordscol.el.setWidth(ew+20);\n    }\n    // fix for messed up rendering of dialog?\n    _this.dialog.layout.el.dom.scrollTop = 0;\n}",
+      "render" : "function (_self)\n{\n  _this.cpanel = _self;\n}"
+     },
+     "autoScroll" : true,
+     "fitToFrame" : true,
+     "region" : "center",
+     "xtype" : "ContentPanel",
+     "$ xns" : "Roo",
+     "items" : [
+      {
+       "xtype" : "Toolbar",
+       "$ xns" : "Roo",
+       "* prop" : "toolbar",
+       "items" : [
+        {
+         "listeners" : {
+          "click" : "function (_self, e)\n{\n    if (_this.trpanel.region.collapsed) {\n        _this.trpanel.region.expand();\n    } else {\n        _this.trpanel.region.collapse(); \n    }\n    \n}"
+         },
+         "text" : "<< Edit Translations",
+         "xtype" : "Button",
+         "$ xns" : "Roo.Toolbar"
+        },
+        {
+         "xtype" : "Fill",
+         "$ xns" : "Roo.Toolbar"
+        },
+        {
+         "listeners" : {
+          "click" : "function (_self, e)\n{\n    if (_this.panel.region.collapsed) {\n        _this.panel.region.expand();\n    } else {\n        _this.panel.region.collapse();\n    }\n    \n}"
+         },
+         "text" : "Manage Images / Attachments >>",
+         "xtype" : "Button",
+         "$ xns" : "Roo.Toolbar"
+        }
+       ]
+      },
+      {
+       "listeners" : {
+        "|actionfailed" : "function (_self, action)\n{\n    _this.dialog.el.unmask(); \n    Pman.standardActionFailed(_self, action);\n}\n",
+        "|actioncomplete" : "function (_self, action)\n{\n\n   if (action.type == 'setdata') {\n\n        _this.dialog.setStylesheets();\n        \n        _this.trpanel.region.collapse(); \n        _this.panel.region.collapse();\n        \n        _this.trpanel.el.mask('Save first');\n        _this.panel.el.mask('Save first');\n        \n        _this.loaded = false;\n        _this.interestsCol.hide();\n        \n        _this.form.findField('category_page_id').fieldEl.select('label',true).first().dom.innerHTML = 'Category';\n        \n        if ( _this.data.id) {\n            _this.dialog.el.mask(\"Loading\");\n            this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n        } else {\n\n            _this.loaded = true;\n            var is_draft = typeof(_this.data.is_draft) != 'undefined' ? _this.data.is_draft : 1;\n            this.findField('is_draft').setValue(is_draft);\n            _this.page_type.setValue(_this.data.page_type_id);\n            _this.page_type.el.dom.value = _this.data.page_type_id_display_name;\n            \n            if(_this.data.page_type_id_name == 'blog' && AppModules.indexOf(\"Crm\") !== -1){\n                _this.interestsCol.show();\n            }\n            /*\n            var catlabel= _this.form.findField('category_page_id').fieldEl.select('label',true).first()\n            catlabel.dom.innerHTML = 'Category';            \n            if(_this.data.page_type_id_name == 'category'){\n                catlabel.dom.innerHTML = 'Parent Category';\n            } \n            */\n            var catlabel= _this.form.findField('parent_id').fieldEl.select('label',true).first();\n            catlabel.dom.innerHTML = 'Parent page';            \n            if(_this.data.page_type_id_name == 'category'){\n                catlabel.dom.innerHTML = 'Parent';\n            }\n        }\n       return;\n    }\n    \n    if (action.type == 'load') {\n    \n        //_this.data = action.result.data;\n        \n        var d = action.result.data;\n        \n        _this.dialog.el.unmask();\n       _this.grid.getDataSource().load();\n       _this.trform.reset();\n       _this.form.findField('body').originalValue = _this.form.findField('body').getValue();\n       _this.form.findField('extended').originalValue = _this.form.findField('extended').getValue();\n       \n       /*\n        var catlabel= _this.form.findField('category_page_id').fieldEl.select('label',true).first()\n        catlabel.dom.innerHTML = 'Category';            \n        \n        if(_this.data.page_type_id_name == 'category'){\n            catlabel.dom.innerHTML = 'Parent Category';\n        }\n        */\n        \n        var catlabel= _this.form.findField('parent_id').fieldEl.select('label',true).first();\n        catlabel.dom.innerHTML = 'Parent page';            \n        if(_this.data.page_type_id_name == 'category'){\n            catlabel.dom.innerHTML = 'Parent';\n        }\n        \n        // better if this was not here... - not sure which project uses it?\n        \n        if(_this.data.page_type_id_name == 'blog' && AppModules.indexOf(\"Crm\") !== -1){\n            _this.interestsCol.show();\n        }\n        if(typeof(d['interests']) != 'undefined'){\n            _this.form.findField('interest').setValue(Roo.decode(d['interests']));\n        }\n        \n        _this.trpanel.el.unmask();\n        _this.panel.el.unmask();\n        \n        // fix scrolling..\n        _this.cpanel.el.dom.scrollTop = 0;\n        \n        // fix messed up scroll.\n        _this.dialog.layout.el.dom.scrollTop = 0;\n        return;\n    }\n    if (action.type =='submit') {\n       \n       _this.dialog.el.unmask();\n       \n       if(!_this.exit){\n            this.load({ method: 'GET', params: { '_id' : action.result.data.id }});\n            return;\n       }\n       \n       _this.dialog.hide();\n       \n\n        if (_this.callback) {\n           _this.callback.call(_this, action.result.data);\n        }\n        _this.form.reset();\n        return;\n    }\n}\n",
+        "|rendered" : "function (_self)\n{\n    _this.form = _self;\n}\n"
+       },
+       "labelAlign" : "right",
+       "$ url" : "baseURL + '/Roo/cms_page.php'",
+       "method" : "POST",
+       "style" : "margin: 5px",
+       "xtype" : "Form",
+       "labelWidth" : 120,
+       "$ showHide" : "function()\n{\n    var in_rss= 0;\n    var is_menu= 0;\n    var is_element  = 0;\n    var is_category = 0;\n    var page_type_name = _this.form.findField('page_type_id_name').getValue();\n    switch(page_type_name){\n        case 'page' :\n            is_element = 0;\n        break;\n        \n        case 'element' :\n            is_element = 1;\n        break;\n        \n        case 'blog' :\n            in_rss = 1;\n        break;\n        \n        case 'menu' :\n            is_menu = 1;\n        break;\n        \n        case 'category' :\n            in_rss = 1;\n            is_category = 1;\n        break;\n    }\n    \n    var is_system_page = _this.form.findField('is_system_page').getValue() * 1;\n    var is_attachment = _this.form.findField('is_attachment').getValue() * 1;\n    var has_extended = _this.form.findField('has_extended').getValue() * 1;\n    \n    var vis = {\n        is_attachment : !in_rss,\n        \n        category_type_id : in_rss && !is_menu,\n         page_link : 1, //!in_rss, // always show page link.. may not be needed though..\n        target_url : is_menu,\n        \n        category_page_id : !is_category,\n        \n        parent_id : !in_rss || is_category ,\n        published : in_rss ,\n        \n        to_replace_id :false, // !in_rss, // is this used.\n        is_draft : !is_system_page,\n        author_id : in_rss && !is_menu  && !is_attachment,\n        \n        template_id : !is_attachment && !is_menu && !is_system_page,\n        element_id : is_element &&   !is_menu, \n        menu_page_id : is_menu,\n \n        has_extended : !is_menu && !is_attachment, // always shown.\n        extended : has_extended && !is_menu  && !is_attachment,\n        body : !is_attachment && !is_menu,\n        keywords : !is_attachment && !is_menu, \n        descriptions : !is_attachment && !is_menu,\n        extra_css : !is_attachment && !is_menu\n    };\n\n    for(var k in vis) {\n        var el = _this.form.findField(k);\n        if (!el) {\n            Roo.log(\"missing field \" + k);\n            continue;\n        }\n        el.actionMode = 'fieldEl';\n        if (vis[k]) {\n            el.show();\n        } else{\n            el.hide();\n        }\n\n    }\n    \n    \n    _this.trform.showHide();\n    \n    if(typeof(_this.form.editors) == 'undefined'){\n        _this.form.editors = {\n            body : _this.form.findField('body').wrap.isVisible(),\n            extended : _this.form.findField('extended').wrap.isVisible()\n       };\n       \n       if(_this.form.editors.body){\n            setInterval(_this.form.findField('body').autosave, 60000);\n       }\n       \n       if(_this.form.editors.extended){\n            setInterval(_this.form.findField('extended').autosave, 60000);\n       }\n   }\n   \n   if(!_this.form.editors.body && _this.form.findField('body').wrap.isVisible()){\n        setInterval(_this.form.findField('body').autosave, 60000);\n        _this.form.editors.body = true;\n   }\n   \n   if(!_this.form.editors.extended && _this.form.findField('extended').wrap.isVisible()){\n        setInterval(_this.form.findField('extended').autosave, 60000);\n        _this.form.editors.extended = true;\n   }\n    \n    \n    \n}\n",
+       "$ xns" : "Roo.form",
+       "items" : [
+        {
+         "xtype" : "Column",
+         "labelWidth" : 200,
+         "width" : 750,
+         "$ xns" : "Roo.form",
+         "items" : [
+          {
+           "labelAlign" : "right",
+           "hideLabels" : false,
+           "style" : "height:30px;overflow:hidden",
+           "xtype" : "Row",
+           "labelWidth" : 200,
+           "width" : 850,
+           "$ xns" : "Roo.form",
+           "items" : [
+            {
+             "fieldLabel" : "Type:",
+             "xtype" : "Hidden",
+             "width" : 1,
+             "$ xns" : "Roo.form"
+            },
+            {
+             "hideLabels" : true,
+             "xtype" : "Row",
+             "style" : "height:30px;overflow:hidden",
+             "labelWidth" : 0,
+             "width" : 600,
+             "$ xns" : "Roo.form",
+             "items" : [
+              {
+               "listeners" : {
+                "render" : "function (_self)\n{\n    _this.page_type = _self;\n}",
+                "select" : "function (combo, record, index)\n{\n//    _this.grid.footer.onClick('first');\n    var page_type_name = record.data.name;\n    _this.form.findField('page_type_id_name').setValue(page_type_name);\n    if(page_type_name == 'blog' || page_type_name == 'category'){ // blog || category unset attachment\n        _this.form.findField('is_attachment').setValue(0);\n        return;\n    }\n    if (_this.form) { \n        _this.form.showHide.defer(100, _this.form);      \n    } \n    \n}"
+               },
+               "alwaysQuery" : true,
+               "listWidth" : 400,
+               "triggerAction" : "all",
+               "fieldLabel" : "Page Type",
+               "forceSelection" : true,
+               "selectOnFocus" : true,
+               "pageSize" : 20,
+               "displayField" : "display_name",
+               "emptyText" : "Select Status Type",
+               "hiddenName" : "page_type_id",
+               "minChars" : 2,
+               "valueField" : "id",
+               "xtype" : "ComboBox",
+               "typeAhead" : false,
+               "editable" : false,
+               "$ xns" : "Roo.form",
+               "name" : "page_type_id_display_name",
+               "qtip" : "Select Page Type",
+               "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>",
+               "loadingText" : "Searching...",
+               "items" : [
+                {
+                 "listeners" : {
+                  "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    // set more here\n    o.params.etype = 'cms_page_type'; \n}\n"
+                 },
+                 "xtype" : "Store",
+                 "remoteSort" : true,
+                 "$ sortInfo" : "{ direction : 'ASC', field: 'seqid' }",
+                 "$ xns" : "Roo.data",
+                 "* prop" : "store",
+                 "items" : [
+                  {
+                   "$ url" : "baseURL + '/Roo/core_enum.php'",
+                   "xtype" : "HttpProxy",
+                   "method" : "GET",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "proxy"
+                  },
+                  {
+                   "id" : "id",
+                   "root" : "data",
+                   "xtype" : "JsonReader",
+                   "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"display_name\",\"type\":\"string\"}]",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "reader",
+                   "totalProperty" : "total"
+                  }
+                 ]
+                }
+               ]
+              },
+              {
+               "style" : "padding-left:  -70px;",
+               "xtype" : "Column",
+               "labelWidth" : 60,
+               "width" : 200,
+               "$ xns" : "Roo.form",
+               "items" : [
+                {
+                 "fieldLabel" : "Seq",
+                 "xtype" : "NumberField",
+                 "decimalPrecision" : 0,
+                 "width" : 50,
+                 "$ xns" : "Roo.form",
+                 "name" : "seq_id"
+                }
+               ]
+              }
+             ]
+            }
+           ]
+          },
+          {
+           "labelAlign" : "right",
+           "hideLabels" : false,
+           "style" : "height:30px;overflow:hidden",
+           "xtype" : "Row",
+           "labelWidth" : 200,
+           "width" : 800,
+           "$ xns" : "Roo.form",
+           "items" : [
+            {
+             "fieldLabel" : "Attributes:",
+             "xtype" : "Hidden",
+             "width" : 1,
+             "$ xns" : "Roo.form"
+            },
+            {
+             "hideLabels" : true,
+             "xtype" : "Row",
+             "style" : "height:30px;overflow:hidden",
+             "labelWidth" : 0,
+             "width" : 540,
+             "$ xns" : "Roo.form",
+             "items" : [
+              {
+               "fieldLabel" : "Attributes",
+               "xtype" : "Checkbox",
+               "boxLabel" : "Draft",
+               "width" : 100,
+               "$ xns" : "Roo.form",
+               "name" : "is_draft"
+              },
+              {
+               "listeners" : {
+                "check" : "function (_self, checked)\n{  \n   if (_this.form) {\n\n       (function() { \n            _this.form.showHide();\n            _this.panel.fireEvent('resize', _this.panel, [ _this.panel.el.getWidth(), _this.panel.el.getHeight() ]  );\n            \n       }).defer(100);\n    }\n}"
+               },
+               "inputValue" : 1,
+               "xtype" : "Checkbox",
+               "boxLabel" : "Has Extended content?",
+               "width" : 180,
+               "$ xns" : "Roo.form",
+               "name" : "has_extended"
+              },
+              {
+               "listeners" : {
+                "check" : "function (_self, checked)\n{  \n   if (_this.form) { \n \n     _this.form.showHide.defer(100, _this.form);      \n   }\n}"
+               },
+               "inputValue" : 1,
+               "xtype" : "Checkbox",
+               "boxLabel" : "Downloads first Attachment",
+               "width" : 180,
+               "$ xns" : "Roo.form",
+               "name" : "is_attachment"
+              }
+             ]
+            }
+           ]
+          },
+          {
+           "listWidth" : 400,
+           "triggerAction" : "all",
+           "fieldLabel" : "Author",
+           "forceSelection" : true,
+           "selectOnFocus" : true,
+           "pageSize" : 40,
+           "displayField" : "name",
+           "emptyText" : "Select Person",
+           "hiddenName" : "author_id",
+           "minChars" : 2,
+           "valueField" : "id",
+           "xtype" : "ComboBox",
+           "allowBlank" : true,
+           "typeAhead" : false,
+           "editable" : true,
+           "width" : 300,
+           "$ xns" : "Roo.form",
+           "name" : "author_id_name",
+           "qtip" : "Select Person",
+           "queryParam" : "query[name]",
+           "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b>  - {company_id_name}</div>",
+           "loadingText" : "Searching...",
+           "items" : [
+            {
+             "listeners" : {
+              "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n\n    o.params.active = 1;\n    o.params['query[is_owner]'] = 1;\n}\n"
+             },
+             "xtype" : "Store",
+             "remoteSort" : true,
+             "$ sortInfo" : "{ direction : 'ASC', field: 'name' }",
+             "$ xns" : "Roo.data",
+             "* prop" : "store",
+             "items" : [
+              {
+               "$ url" : "baseURL + '/Roo/Person.php'",
+               "xtype" : "HttpProxy",
+               "method" : "GET",
+               "$ xns" : "Roo.data",
+               "* prop" : "proxy"
+              },
+              {
+               "id" : "id",
+               "root" : "data",
+               "xtype" : "JsonReader",
+               "$ xns" : "Roo.data",
+               "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"name\",\"type\":\"string\"}]",
+               "* prop" : "reader",
+               "totalProperty" : "total"
+              }
+             ]
+            }
+           ]
+          },
+          {
+           "listWidth" : 400,
+           "triggerAction" : "all",
+           "fieldLabel" : "Category",
+           "forceSelection" : true,
+           "selectOnFocus" : true,
+           "pageSize" : 20,
+           "displayField" : "title",
+           "emptyText" : "Select Category",
+           "hiddenName" : "category_page_id",
+           "minChars" : 2,
+           "valueField" : "id",
+           "xtype" : "ComboBox",
+           "allowBlank" : true,
+           "typeAhead" : true,
+           "editable" : false,
+           "width" : 200,
+           "$ xns" : "Roo.form",
+           "name" : "category_page_id_title",
+           "qtip" : "Select Category",
+           "queryParam" : "",
+           "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> </div>",
+           "loadingText" : "Searching...",
+           "items" : [
+            {
+             "listeners" : {
+              "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    o.params.page_type_id_name= 'CATEGORY';\n    // set more here\n}\n"
+             },
+             "xtype" : "Store",
+             "$ xns" : "Roo.data",
+             "$ sortInfo" : "{ field: 'title', dir: 'ASC' }",
+             "* prop" : "store",
+             "items" : [
+              {
+               "$ url" : "baseURL + '/Roo/cms_page.php'",
+               "method" : "GET",
+               "xtype" : "HttpProxy",
+               "$ xns" : "Roo.data",
+               "* prop" : "proxy"
+              },
+              {
+               "id" : "id",
+               "root" : "data",
+               "xtype" : "JsonReader",
+               "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"title\",\"type\":\"string\"}]",
+               "$ xns" : "Roo.data",
+               "* prop" : "reader",
+               "totalProperty" : "total"
+              }
+             ]
+            }
+           ]
+          },
+          {
+           "listeners" : {
+            "select" : "function (combo, record, index)\n{\n   var page_type_name = _this.form.findField('page_type_id_name').getValue();\n   if (page_type_name == 'page') { // page\n        return;\n   }\n   // do not default to put 'Home' at the beginning.\n   if (!(record.data.parent_id *1)) {\n        return;\n   }\n   var pl = _this.form.findField('page_link');\n   var lk = pl.getValue();\n   var new_link = record.data.page_link + '/';\n   if (lk.length) {\n        new_link += lk.split('/').pop();\n   }\n   pl.setValue(new_link);\n   \n}"
+           },
+           "listWidth" : 600,
+           "triggerAction" : "all",
+           "fieldLabel" : "Parent page",
+           "forceSelection" : true,
+           "selectOnFocus" : true,
+           "pageSize" : 40,
+           "displayField" : "page_link",
+           "emptyText" : "Select Parent",
+           "hiddenName" : "parent_id",
+           "minChars" : 2,
+           "valueField" : "id",
+           "xtype" : "ComboBox",
+           "allowBlank" : true,
+           "typeAhead" : true,
+           "Boolean alwaysQuery" : true,
+           "editable" : true,
+           "width" : 400,
+           "$ xns" : "Roo.form",
+           "name" : "parent_id_title",
+           "qtip" : "Select Category ",
+           "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>",
+           "loadingText" : "Searching...",
+           "items" : [
+            {
+             "listeners" : {
+              "beforeload" : "function (_self, options)\n{\n     options.params['search[page_link_no_empty]'] =1;\n     \n     options.params.page_type_id = _this.data.page_type_id;\n     \n     var id = _this.form.findField('id').getValue() * 1;\n     \n     if(id > 0){\n        options.params['!id'] = id;\n     }\n     /*\n     options.params.is_element = 0;\n     var page_type_name = _this.page_type.findRecord() ? _this.page_type.findRecord().data.name: _this.firstPageType.name;\n     options.params.is_menuitem = page_type_name == 'menu' ? 1 : 0;    \n     */\n}"
+             },
+             "xtype" : "Store",
+             "remoteSort" : true,
+             "$ sortInfo" : "{ field: 'page_link', direction: 'ASC' }",
+             "$ xns" : "Roo.data",
+             "* prop" : "store",
+             "items" : [
+              {
+               "$ url" : "baseURL + '/Roo/cms_page.php'",
+               "method" : "GET",
+               "xtype" : "HttpProxy",
+               "$ xns" : "Roo.data",
+               "* prop" : "proxy"
+              },
+              {
+               "id" : "id",
+               "root" : "data",
+               "xtype" : "JsonReader",
+               "$ fields" : "[\n { name: 'id', type: 'int' },\n 'title',\n 'page_link' \n]",
+               "$ xns" : "Roo.data",
+               "* prop" : "reader",
+               "totalProperty" : "total"
+              }
+             ]
+            }
+           ]
+          },
+          {
+           "xtype" : "Row",
+           "labelWidth" : 200,
+           "$ xns" : "Roo.form",
+           "items" : [
+            {
+             "format" : "Y-m-d",
+             "fieldLabel" : "Date to Publish",
+             "xtype" : "DateField",
+             "width" : 200,
+             "$ xns" : "Roo.form",
+             "altFormats" : "Y-m-d H:i:s",
+             "name" : "published"
+            },
+            {
+             "fieldLabel" : "Replaces (ignore)",
+             "xtype" : "TextField",
+             "width" : 75,
+             "$ xns" : "Roo.form",
+             "name" : "to_replace_id"
+            }
+           ]
+          },
+          {
+           "listeners" : {
+            "keyup" : "function (_self, e)\n{\n    if (_this.page_type.getRawValue() == 'Category') {\n    \n        _this.form.findField('page_link').setValue(this.getValue().replace(/[\\s]/ig, '-').toLowerCase());\n    \n    }\n}"
+           },
+           "fieldLabel" : "Title",
+           "xtype" : "TextField",
+           "width" : 400,
+           "$ xns" : "Roo.form",
+           "name" : "title"
+          },
+          {
+           "fieldLabel" : "Page link /  Name / Order",
+           "xtype" : "TextField",
+           "width" : 400,
+           "$ xns" : "Roo.form",
+           "name" : "page_link"
+          },
+          {
+           "fieldLabel" : "Target URL",
+           "xtype" : "TextField",
+           "width" : 400,
+           "$ xns" : "Roo.form",
+           "name" : "target_url"
+          },
+          {
+           "$ tpl" : "'<div class=\"x-grid-cell-text x-btn button\"><b>{template_clean}</b></div>'\n",
+           "alwaysQuery" : true,
+           "listWidth" : 400,
+           "triggerAction" : "all",
+           "fieldLabel" : "Layout",
+           "forceSelection" : true,
+           "selectOnFocus" : true,
+           "pageSize" : 20,
+           "displayField" : "template_clean",
+           "emptyText" : "Select Template",
+           "hiddenName" : "template_id",
+           "minChars" : 2,
+           "valueField" : "id",
+           "xtype" : "ComboBox",
+           "allowBlank" : true,
+           "typeAhead" : true,
+           "editable" : true,
+           "width" : 400,
+           "$ xns" : "Roo.form",
+           "name" : "template_id_template_clean",
+           "qtip" : "Select Category ",
+           "loadingText" : "Searching...",
+           "items" : [
+            {
+             "listeners" : {
+              "beforeload" : "function (_self, options)\n{\n \n    options.params._rescan = 1;\n   options.params._clean_name = 1;\n//    options.params.lang = 'en';\n    options.params['!template[0]'] = 'master.html';\n    //options.params['!template[1]'] = 'index.html';\n}"
+             },
+             "xtype" : "Store",
+             "remoteSort" : true,
+             "$ sortInfo" : "{ field: 'template', direction: 'ASC' }",
+             "$ xns" : "Roo.data",
+             "* prop" : "store",
+             "items" : [
+              {
+               "$ url" : "baseURL + '/Roo/Cms_template'",
+               "method" : "GET",
+               "xtype" : "HttpProxy",
+               "$ xns" : "Roo.data",
+               "* prop" : "proxy"
+              },
+              {
+               "id" : "id",
+               "root" : "data",
+               "xtype" : "JsonReader",
+               "$ fields" : "[\n { name: 'id', type: 'int' }, {name: 'template', type: 'string'}\n]",
+               "$ xns" : "Roo.data",
+               "* prop" : "reader",
+               "totalProperty" : "total"
+              }
+             ]
+            }
+           ]
+          },
+          {
+           "alwaysQuery" : true,
+           "listWidth" : 400,
+           "triggerAction" : "all",
+           "fieldLabel" : "Appears in Block",
+           "forceSelection" : true,
+           "selectOnFocus" : true,
+           "pageSize" : 20,
+           "displayField" : "name",
+           "emptyText" : "Select Section",
+           "hiddenName" : "element_id",
+           "minChars" : 2,
+           "valueField" : "id",
+           "xtype" : "ComboBox",
+           "allowBlank" : true,
+           "typeAhead" : true,
+           "editable" : true,
+           "width" : 400,
+           "$ xns" : "Roo.form",
+           "name" : "element_id_name",
+           "qtip" : "Select Category ",
+           "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b></div>",
+           "loadingText" : "Searching...",
+           "items" : [
+            {
+             "listeners" : {
+              "beforeload" : "function (_self, options)\n{\n    var par = _this.form.findField('parent_id').getValue() * 1;\n    if (!par) {\n        Roo.MessageBox.alert(\"Error\", \"Select on what parent page it appears\");\n        return false;\n    }\n    \n    options.params._cms_page_id = par;\n}"
+             },
+             "xtype" : "Store",
+             "remoteSort" : true,
+             "$ sortInfo" : "{ field: 'name', direction: 'ASC' }",
+             "$ xns" : "Roo.data",
+             "* prop" : "store",
+             "items" : [
+              {
+               "$ url" : "baseURL + '/Roo/Cms_template_element'",
+               "method" : "GET",
+               "xtype" : "HttpProxy",
+               "$ xns" : "Roo.data",
+               "* prop" : "proxy"
+              },
+              {
+               "id" : "id",
+               "root" : "data",
+               "xtype" : "JsonReader",
+               "$ fields" : "[\n { name: 'id', type: 'int' }, {name: 'template', type: 'string'}\n]",
+               "$ xns" : "Roo.data",
+               "* prop" : "reader",
+               "totalProperty" : "total"
+              }
+             ]
+            }
+           ]
+          },
+          {
+           "alwaysQuery" : true,
+           "listWidth" : 600,
+           "triggerAction" : "all",
+           "fieldLabel" : "Menu links to Page",
+           "forceSelection" : true,
+           "selectOnFocus" : true,
+           "pageSize" : 40,
+           "displayField" : "page_link",
+           "emptyText" : "Select Page",
+           "hiddenName" : "menu_page_id",
+           "minChars" : 2,
+           "valueField" : "id",
+           "xtype" : "ComboBox",
+           "allowBlank" : true,
+           "typeAhead" : true,
+           "editable" : true,
+           "width" : 400,
+           "$ xns" : "Roo.form",
+           "name" : "menu_page_id_page_link",
+           "qtip" : "Select Category ",
+           "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><span style=\"color:#1b809e\">[{page_type_id_display_name}] </span><b>{title} </b><i>{page_link}</i></div>",
+           "loadingText" : "Searching...",
+           "items" : [
+            {
+             "listeners" : {
+              "beforeload" : "function (_self, options)\n{\n    options.params = options.params || {};\n    \n    options.params['search[page_link_no_empty]'] =1;\n     \n    options.params['page_type_id_name[0]'] = 'page';\n    options.params['page_type_id_name[1]'] = 'blog';\n     /*\n     options.params.is_element = 0;\n     options.params.is_menuitem = 0;     \n     */\n}"
+             },
+             "xtype" : "Store",
+             "remoteSort" : true,
+             "$ sortInfo" : "{ field: 'title', direction: 'ASC' }",
+             "$ xns" : "Roo.data",
+             "* prop" : "store",
+             "items" : [
+              {
+               "$ url" : "baseURL + '/Roo/cms_page.php'",
+               "method" : "GET",
+               "xtype" : "HttpProxy",
+               "$ xns" : "Roo.data",
+               "* prop" : "proxy"
+              },
+              {
+               "id" : "id",
+               "root" : "data",
+               "xtype" : "JsonReader",
+               "$ fields" : "[\n    {\n        \"name\":\"id\",\n        \"type\":\"int\"\n    },\n    {\n        \"name\":\"title\",\n        \"type\":\"string\"\n    },\n    {\n        \"name\":\"page_link\",\n        \"type\":\"string\"\n    },\n    {\n        \"name\":\"page_type_id_display_name\",\n        \"type\":\"string\"\n    }\n]",
+               "$ xns" : "Roo.data",
+               "* prop" : "reader",
+               "totalProperty" : "total"
+              }
+             ]
+            }
+           ]
+          }
+         ]
+        },
+        {
+         "listeners" : {
+          "render" : "function (_self)\n{\n  _this.bodycol = _self;\n}"
+         },
+         "labelAlign" : "top",
+         "xtype" : "Column",
+         "width" : 900,
+         "$ xns" : "Roo.form",
+         "items" : [
+          {
+           "listeners" : {
+            "stylesheetsclick" : "function (_self)\n{\n    Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){\n        _this.dialog.setStylesheets();\n    })\n    \n}",
+            "savedpreview" : "function (_self)\n{\n    Roo.log('saved preview');\n    \n    var id = _this.form.findField('id').getValue() * 1;\n    \n    var successFn = function(res){\n        return res.data.POST.source;\n    };\n    \n    var params = {\n        action : 'AUTOSAVE',\n        remarks : 'BODY',\n        on_id : (id < 1) ? 0 : id,\n        on_table : 'cms_page',\n        successFn : successFn\n    };\n    \n    \n    Pman.Dialog.CoreAutoSavePreview.show(params, function(res){\n        _self.setValue(res);\n        _self.originalValue = res;\n    });\n}",
+            "autosave" : "function (_self)\n{\n    Roo.log('autosave');\n    \n    var id = _this.form.findField('id').getValue() * 1;\n    /*\n    if(!_self.editorcore.sourceEditMode){\n        _self.syncValue();\n    }else{\n        _self.pushValue();\n    }\n    */\n    new Pman.Request({\n        url : baseURL + '/Roo/Events.php',\n        method :'POST',\n        params : {\n            id : 0,\n            action : 'AUTOSAVE',\n            on_id : (id > 0) ? id : 0,\n            on_table : 'cms_page',\n            remarks : 'BODY',\n            source: _self.getValue()\n        },\n        success : function() {\n            _self.originalValue = _self.getValue();\n            \n        },\n        failure : function() \n        {\n            //Roo.MessageBox.alert(\"Error\", \"autosave failed\");\n            Roo.log('body autosave failed?!');\n        }\n    });\n    \n}"
+           },
+           "fieldLabel" : "Contents",
+           "xtype" : "HtmlEditor",
+           "width" : 550,
+           "$ xns" : "Roo.form",
+           "resizable" : "s",
+           "$ autosave" : "function() {\n    \n    var body = _this.form.findField('body');\n    \n    if(!body.wrap.isVisible(true) || body.getValue() == '' || !body.isDirty()){\n        Roo.log('body not dirty');\n        return;\n    }\n    \n    Roo.log('body dirty, auto save!');\n    \n    body.fireEvent('autosave', body);\n        \n   \n}\n",
+           "$ array white" : "[ 'iframe' ]",
+           "name" : "body",
+           "height" : 140,
+           "items" : [
+            {
+             "xtype" : "ToolbarStandard",
+             "$ xns" : "Roo.form.HtmlEditor",
+             "* prop" : "toolbars[]",
+             "items" : [
+              {
+               "listeners" : {
+                "render" : "function (_self)\n{\n    _this.bodyimgselect = _self;\n}",
+                "beforequery" : "function (combo, query, forceAll, cancel, e)\n{\n \n    var id = _this.form.findField('id').getValue() * 1;    \n    if (!id) {\n        Roo.MessageBox.alert(\"Error\", \"Save Document First before adding images\");\n        return false;\n    }\n}",
+                "select" : "function (combo, record, index)\n{\n    Roo.log(record);\n    (function() { \n        combo.setValue('');\n    }).defer(100);\n    \n    var editor = _this.form.findField('body').editorcore;\n    \n    var curnode = editor.getSelectedNode();\n    \n    if (curnode && curnode.tagName == 'IMG') {\n        curnode.src= String.format('{0}/Images/{1}/{2}#attachment-{1}',\n                baseURL,  record.data.id, record.data.filename\n            );\n            // note -forces an update... hopefully...\n        editor.owner.fireEvent('editorevent', editor, false);\n    } else {\n    \n        editor.insertAtCursor(\n            String.format('<img src=\"{0}/Images/{1}/{2}#attachment-{1}\">',\n            baseURL,  record.data.id, record.data.filename\n            )\n        );\n\n    }\n    \n}"
+               },
+               "$ tpl" : "'<div class=\"x-grid-cell-text x-btn button\"><img src=\"' + baseURL + '/Images/Thumb/150x150/{id}.jpg\" height=\"150\" width=\"150\"><b>{filename}</b> </div>'",
+               "alwaysQuery" : true,
+               "listWidth" : 400,
+               "triggerAction" : "all",
+               "fieldLabel" : "Images",
+               "forceSelection" : true,
+               "selectOnFocus" : true,
+               "pageSize" : 20,
+               "displayField" : "name",
+               "emptyText" : "Add Image",
+               "minChars" : 2,
+               "valueField" : "id",
+               "xtype" : "ComboBox",
+               "typeAhead" : true,
+               "editable" : false,
+               "width" : 100,
+               "$ xns" : "Roo.form",
+               "* prop" : "btns[]",
+               "qtip" : "Select Images",
+               "queryParam" : "search",
+               "loadingText" : "Searching...",
+               "items" : [
+                {
+                 "listeners" : {
+                  "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n\n    var id = _this.form.findField('id').getValue() * 1;    \n    if (!id) {\n        Roo.MessageBox.alert(\"Error\", \"Save press release first\");\n        return false;\n    }\n    o.params.onid = id;\n    o.params.ontable = 'cms_page';\n   // o.params.imgtype = 'PressRelease';\n    //o.params['query[imagesize]'] = '150x150';\n    // set more here\n}\n"
+                 },
+                 "xtype" : "Store",
+                 "remoteSort" : true,
+                 "$ sortInfo" : "{ direction : 'ASC', field: 'id' }",
+                 "$ xns" : "Roo.data",
+                 "* prop" : "store",
+                 "items" : [
+                  {
+                   "$ url" : "baseURL + '/Roo/Images.php'",
+                   "xtype" : "HttpProxy",
+                   "method" : "GET",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "proxy"
+                  },
+                  {
+                   "id" : "id",
+                   "root" : "data",
+                   "xtype" : "JsonReader",
+                   "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"filename\",\"type\":\"string\"},{\"name\":\"url_thumb\",\"type\":\"string\"}]",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "reader",
+                   "totalProperty" : "total"
+                  }
+                 ]
+                }
+               ]
+              },
+              {
+               "listeners" : {
+                "select" : "function (combo, record, index)\n{\n    Roo.log(record);\n    (function() { \n        combo.setValue('');\n    }).defer(100);\n    var editor = _this.form.findField('body');\n    editor.editorcore.insertAtCursor(\n            String.format('<a href=\"#page-{0}\">{1}</a>',\n            record.data.page_link,  record.data.title\n            )\n     );\n\n    \n }"
+               },
+               "listWidth" : 200,
+               "triggerAction" : "all",
+               "forceSelection" : true,
+               "selectOnFocus" : true,
+               "pageSize" : 40,
+               "displayField" : "page_link",
+               "emptyText" : "Add Link",
+               "hiddenName" : "add_link_id",
+               "minChars" : 2,
+               "valueField" : "id",
+               "xtype" : "ComboBox",
+               "allowBlank" : true,
+               "typeAhead" : true,
+               "editable" : true,
+               "width" : 100,
+               "$ xns" : "Roo.form",
+               "* prop" : "btns[]",
+               "name" : "add_link",
+               "qtip" : "Select Category ",
+               "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>",
+               "loadingText" : "Searching...",
+               "items" : [
+                {
+                 "listeners" : {
+                  "beforeload" : "function (_self, options)\n{\n     options.params['search[page_link_no_empty]'] =1;\n     /*\n     options.params.is_element = 0;\n     options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     \n     */\n}"
+                 },
+                 "xtype" : "Store",
+                 "remoteSort" : true,
+                 "$ sortInfo" : "{ field: 'page_link', direction: 'ASC' }",
+                 "$ xns" : "Roo.data",
+                 "* prop" : "store",
+                 "items" : [
+                  {
+                   "$ url" : "baseURL + '/Roo/cms_page.php'",
+                   "method" : "GET",
+                   "xtype" : "HttpProxy",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "proxy"
+                  },
+                  {
+                   "id" : "id",
+                   "root" : "data",
+                   "xtype" : "JsonReader",
+                   "$ fields" : "[\n { name: 'id', type: 'int' },\n 'title',\n 'page_link' \n]",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "reader",
+                   "totalProperty" : "total"
+                  }
+                 ]
+                }
+               ]
+              },
+              {
+               "xtype" : "Separator",
+               "$ xns" : "Roo.Toolbar",
+               "* prop" : "btns[]"
+              },
+              {
+               "listeners" : {
+                "click" : "function (_self, e)\n{\n    this.scope.owner.fireEvent('savedpreview', this.scope.owner);\n}"
+               },
+               "String cls" : "x-init-enable",
+               "text" : "Saved Version",
+               "xtype" : "Button",
+               "$ xns" : "Roo.Toolbar",
+               "* prop" : "btns[]"
+              }
+             ]
+            },
+            {
+             "xtype" : "ToolbarContext",
+             "$ xns" : "Roo.form.HtmlEditor",
+             "* prop" : "toolbars[]"
+            }
+           ]
+          }
+         ]
+        },
+        {
+         "listeners" : {
+          "render" : "function (_self)\n{\n  _this.extendcol = _self;\n}"
+         },
+         "labelAlign" : "top",
+         "xtype" : "Column",
+         "width" : 900,
+         "$ xns" : "Roo.form",
+         "items" : [
+          {
+           "listeners" : {
+            "stylesheetsclick" : "function (_self)\n{\n    Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){\n        _this.dialog.setStylesheets();\n    })\n    \n}",
+            "savedpreview" : "function (_self)\n{\n    var id = _this.form.findField('id').getValue() * 1;\n    \n    var successFn = function(res){\n        return res.data.POST.source;\n    };\n    \n    var params = {\n        action : 'AUTOSAVE',\n        remarks : 'EXTENDED',\n        on_id : (id < 1) ? 0 : id,\n        on_table : 'cms_page',\n        successFn : successFn\n    };\n    \n    \n    Pman.Dialog.CoreAutoSavePreview.show(params, function(res){\n        _self.setValue(res);\n        _self.originalValue = res;\n    });\n}",
+            "autosave" : "function (_self)\n{\n    var id = _this.form.findField('id').getValue() * 1;\n    \n    /*\n    if(!_self.editorcore.sourceEditMode){\n        _self.syncValue();\n    }else{\n        _self.pushValue();\n    }\n    */\n    new Pman.Request({\n        url : baseURL + '/Roo/Events.php',\n        method :'POST',\n        params : {\n            id : 0,\n            action : 'AUTOSAVE',\n            on_id : (id > 0) ? id : 0,\n            on_table : 'cms_page',\n            remarks : 'EXTENDED',\n            source: _self.getValue()\n        },\n        success : function() {\n            _self.originalValue = _self.getValue();\n            \n        },\n        failure : function() \n        {\n            //Roo.MessageBox.alert(\"Error\", \"autosave failed\");\n            Roo.log('extended autosave failed?!');\n        }\n    });\n}"
+           },
+           "fieldLabel" : "Extended Contents",
+           "xtype" : "HtmlEditor",
+           "width" : 550,
+           "$ xns" : "Roo.form",
+           "resizable" : "s",
+           "$ autosave" : "function() {\n    \n    var extended = _this.form.findField('extended');\n    \n    if(!extended.wrap.isVisible(true) || extended.getValue() == '' || !extended.isDirty()){\n        Roo.log('extend not dirty');\n        return;\n    }\n\n    \n    Roo.log('extend dirty, auto save!');\n    \n    extended.fireEvent('autosave', extended);\n}\n",
+           "$ array white" : "[ 'iframe' ]",
+           "name" : "extended",
+           "height" : 160,
+           "items" : [
+            {
+             "xtype" : "ToolbarStandard",
+             "$ xns" : "Roo.form.HtmlEditor",
+             "* prop" : "toolbars[]",
+             "items" : [
+              {
+               "listeners" : {
+                "render" : "function (_self)\n{\n    _this.extendimgselect = _self;\n}",
+                "beforequery" : "function (combo, query, forceAll, cancel, e)\n{\n \n    var id = _this.form.findField('id').getValue() * 1;    \n    if (!id) {\n        Roo.MessageBox.alert(\"Error\", \"Save Document First before adding images\");\n        return false;\n    }\n}",
+                "select" : "function (combo, record, index)\n{\n    Roo.log(record);\n    (function() { \n        combo.setValue('');\n    }).defer(100);\n    \n    var editor = _this.form.findField('extended').editorcore;\n    \n    var curnode = editor.getSelectedNode();\n    \n    if (curnode && curnode.tagName == 'IMG') {\n        curnode.src= String.format('{0}/Images/{1}/{2}#image-{1}',\n                baseURL,  record.data.id, record.data.filename\n            );\n            // note -forces an update... hopefully...\n        editor.owner.fireEvent('editorevent', editor, false);\n    } else {\n    \n        editor.insertAtCursor(\n            String.format('<img src=\"{0}/Images/{1}/{2}#image-{1}\">',\n            baseURL,  record.data.id, record.data.filename\n            )\n        );\n\n    }\n    \n}"
+               },
+               "alwaysQuery" : true,
+               "listWidth" : 400,
+               "triggerAction" : "all",
+               "fieldLabel" : "Images",
+               "forceSelection" : true,
+               "selectOnFocus" : true,
+               "pageSize" : 20,
+               "displayField" : "name",
+               "emptyText" : "Add Image",
+               "minChars" : 2,
+               "valueField" : "id",
+               "xtype" : "ComboBox",
+               "typeAhead" : true,
+               "editable" : false,
+               "width" : 100,
+               "$ xns" : "Roo.form",
+               "* prop" : "btns[]",
+               "qtip" : "Select Images",
+               "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><img src=\"{url_thumb}\" height=\"150\" width=\"150\"><b>{filename}</b> </div>",
+               "loadingText" : "Searching...",
+               "items" : [
+                {
+                 "listeners" : {
+                  "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n\n    var id = _this.form.findField('id').getValue() * 1;    \n    if (!id) {\n        Roo.MessageBox.alert(\"Error\", \"Save press release first\");\n        return false;\n    }\n    o.params.onid = id;\n    o.params.ontable = 'cms_page';\n   // o.params.imgtype = 'PressRelease';\n    //o.params['query[imagesize]'] = '150x150';\n    // set more here\n}\n"
+                 },
+                 "xtype" : "Store",
+                 "remoteSort" : true,
+                 "$ sortInfo" : "{ direction : 'ASC', field: 'id' }",
+                 "$ xns" : "Roo.data",
+                 "* prop" : "store",
+                 "items" : [
+                  {
+                   "$ url" : "baseURL + '/Roo/Images.php'",
+                   "xtype" : "HttpProxy",
+                   "method" : "GET",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "proxy"
+                  },
+                  {
+                   "id" : "id",
+                   "root" : "data",
+                   "xtype" : "JsonReader",
+                   "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"filename\",\"type\":\"string\"},{\"name\":\"url_thumb\",\"type\":\"string\"}]",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "reader",
+                   "totalProperty" : "total"
+                  }
+                 ]
+                }
+               ]
+              },
+              {
+               "listeners" : {
+                "select" : "function (combo, record, index)\n{\n    Roo.log(record);\n    (function() { \n        combo.setValue('');\n    }).defer(100);\n    var editor = _this.form.findField('body');\n    editor.editorcore.insertAtCursor(\n            String.format('<a href=\"#page-{0}\">{1}</a>',\n            record.data.page_link,  record.data.title\n            )\n     );\n\n    \n }"
+               },
+               "listWidth" : 200,
+               "triggerAction" : "all",
+               "forceSelection" : true,
+               "selectOnFocus" : true,
+               "pageSize" : 40,
+               "displayField" : "page_link",
+               "emptyText" : "Add Link",
+               "hiddenName" : "add_link_id",
+               "minChars" : 2,
+               "valueField" : "id",
+               "xtype" : "ComboBox",
+               "allowBlank" : true,
+               "typeAhead" : true,
+               "editable" : true,
+               "width" : 100,
+               "$ xns" : "Roo.form",
+               "* prop" : "btns[]",
+               "name" : "add_link",
+               "qtip" : "Select Category ",
+               "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>",
+               "loadingText" : "Searching...",
+               "items" : [
+                {
+                 "listeners" : {
+                  "beforeload" : "function (_self, options)\n{\n     options.params['search[page_link_no_empty]'] =1;\n     /*\n     options.params.is_element = 0;\n     options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     \n     */\n}"
+                 },
+                 "xtype" : "Store",
+                 "remoteSort" : true,
+                 "$ sortInfo" : "{ field: 'page_link', direction: 'ASC' }",
+                 "$ xns" : "Roo.data",
+                 "* prop" : "store",
+                 "items" : [
+                  {
+                   "$ url" : "baseURL + '/Roo/cms_page.php'",
+                   "method" : "GET",
+                   "xtype" : "HttpProxy",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "proxy"
+                  },
+                  {
+                   "id" : "id",
+                   "root" : "data",
+                   "xtype" : "JsonReader",
+                   "$ fields" : "[\n { name: 'id', type: 'int' },\n 'title',\n 'page_link' \n]",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "reader",
+                   "totalProperty" : "total"
+                  }
+                 ]
+                }
+               ]
+              },
+              {
+               "xtype" : "Separator",
+               "$ xns" : "Roo.Toolbar",
+               "* prop" : "btns[]"
+              },
+              {
+               "listeners" : {
+                "click" : "function (_self, e)\n{\n    this.scope.owner.fireEvent('savedpreview', this.scope.owner);\n}"
+               },
+               "text" : "Saved Version",
+               "xtype" : "Button",
+               "$ xns" : "Roo.Toolbar",
+               "* prop" : "btns[]"
+              }
+             ]
+            },
+            {
+             "xtype" : "ToolbarContext",
+             "$ xns" : "Roo.form.HtmlEditor",
+             "$ styles" : "typeof(uiConfig) != 'undefined' ? (uiConfig['Roo.form.HtmlEditor.ToolbarContext.styles'] || {}) : {}",
+             "* prop" : "toolbars[]"
+            }
+           ]
+          }
+         ]
+        },
+        {
+         "listeners" : {
+          "render" : "function (_self)\n{\n  _this.keywordscol = _self;\n}"
+         },
+         "labelAlign" : "top",
+         "xtype" : "Column",
+         "width" : 950,
+         "$ xns" : "Roo.form",
+         "items" : [
+          {
+           "xtype" : "Row",
+           "$ xns" : "Roo.form",
+           "items" : [
+            {
+             "fieldLabel" : "Keywords",
+             "xtype" : "TextArea",
+             "width" : 350,
+             "$ xns" : "Roo.form",
+             "name" : "keywords",
+             "height" : 150
+            },
+            {
+             "fieldLabel" : "Descriptions",
+             "xtype" : "TextArea",
+             "width" : 350,
+             "$ xns" : "Roo.form",
+             "name" : "descriptions",
+             "height" : 150
+            }
+           ]
+          },
+          {
+           "xtype" : "Row",
+           "$ xns" : "Roo.form",
+           "items" : [
+            {
+             "fieldLabel" : "Styles (CSS)",
+             "xtype" : "TextArea",
+             "width" : 700,
+             "$ xns" : "Roo.form",
+             "name" : "extra_css",
+             "height" : 150
+            }
+           ]
+          }
+         ]
+        },
+        {
+         "listeners" : {
+          "render" : "function (_self)\n{\n    _this.interestsCol = _self;\n}"
+         },
+         "labelAlign" : "top",
+         "xtype" : "Column",
+         "$ xns" : "Roo.form",
+         "items" : [
+          {
+           "listeners" : {
+            "render" : "function (_self)\n{\n    _this.interests = _self;\n    /*\n    _self.combo.addicon.setStyle( {\n        position : 'absolute',\n        right: '9px',\n        top : '2px',\n        float : 'left'\n    });\n    */\n}"
+           },
+           "fieldLabel" : "Interests",
+           "xtype" : "ComboBoxArray",
+           "hiddenName" : "interest",
+           "width" : 300,
+           "$ xns" : "Roo.form",
+           "name" : "interest_name",
+           "items" : [
+            {
+             "alwaysQuery" : true,
+             "listWidth" : 400,
+             "triggerAction" : "all",
+             "fieldLabel" : "Interests",
+             "forceSelection" : true,
+             "selectOnFocus" : true,
+             "displayField" : "display_name",
+             "emptyText" : "Select interests",
+             "minChars" : 2,
+             "valueField" : "id",
+             "xtype" : "ComboBox",
+             "allowBlank" : true,
+             "editable" : true,
+             "width" : 285,
+             "$ xns" : "Roo.form",
+             "* prop" : "combo",
+             "queryParam" : "query[name]",
+             "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>",
+             "items" : [
+              {
+               "listeners" : {
+                "beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    o.params.etype = 'crm_interest';\n}\n"
+               },
+               "xtype" : "Store",
+               "remoteSort" : true,
+               "$ sortInfo" : "{ direction : 'ASC', field: 'name' }",
+               "$ xns" : "Roo.data",
+               "* prop" : "store",
+               "items" : [
+                {
+                 "$ url" : "baseURL + '/Roo/Core_enum.php'",
+                 "method" : "GET",
+                 "xtype" : "HttpProxy",
+                 "$ xns" : "Roo.data",
+                 "* prop" : "proxy"
+                },
+                {
+                 "id" : "id",
+                 "root" : "data",
+                 "xtype" : "JsonReader",
+                 "$ fields" : "[\n    {\"name\":\"id\",\"type\":\"int\"},\n    {\"name\":\"name\",\"type\":\"string\"},\n    {\"name\":\"display_name\",\"type\":\"string\"}\n]",
+                 "$ xns" : "Roo.data",
+                 "* prop" : "reader",
+                 "totalProperty" : "total"
+                }
+               ]
+              }
+             ]
+            }
+           ]
+          }
+         ]
+        },
+        {
+         "xtype" : "Hidden",
+         "$ xns" : "Roo.form",
+         "name" : "id"
+        },
+        {
+         "xtype" : "Hidden",
+         "$ xns" : "Roo.form",
+         "name" : "is_system_page"
+        },
+        {
+         "xtype" : "Hidden",
+         "$ xns" : "Roo.form",
+         "name" : "is_menuitem"
+        },
+        {
+         "xtype" : "Hidden",
+         "$ xns" : "Roo.form",
+         "name" : "page_type_id_name"
+        },
+        {
+         "listeners" : {
+          "render" : "function (_self)\n{\n    _this.user_defined_fields = _self;\n}"
+         },
+         "xtype" : "Column",
+         "$ xns" : "Roo.form"
+        }
+       ]
+      }
+     ]
+    },
+    {
+     "listeners" : {
+      "|activate" : "function() {\n    _this.panel = this;\n    if (_this.grid) {\n        _this.grid.footer.onClick('first');\n    }\n}"
+     },
+     "region" : "east",
+     "fitToframe" : true,
+     "background" : false,
+     "title" : "Images / Attachments",
+     "xtype" : "GridPanel",
+     "fitContainer" : true,
+     "$ xns" : "Roo",
+     "tableName" : "Images",
+     "items" : [
+      {
+       "listeners" : {
+        "|rowdblclick" : "function (_self, rowIndex, e)\n{\n    var rd = _this.grid.getDataSource().getAt(rowIndex);\n    var id = rd.data.id;\n    var url = String.format('{0}/Images/{1}/{2}', baseURL, rd.data.id, rd.data.filename);\n    _this.form.findField('contents').execCmd('insertimage', url);\n\n}",
+        "|render" : "function() { \n    _this.grid = this; \n    //_this.dialog = Pman.Dialog.FILL_IN\n    if (_this.panel.active) {\n       //this.footer.onClick('first');\n    }\n}"
+       },
+       "autoExpandColumn" : "title",
+       "xtype" : "EditorGrid",
+       "loadMask" : true,
+       "clicksToEdit" : 1,
+       "$ xns" : "Roo.grid",
+       "* prop" : "grid",
+       "items" : [
+        {
+         "listeners" : {
+          "|beforeload" : "function (_self, o)\n{\n    var id = _this.form.findField('id').getValue() * 1;\n\n    if (id < 1) {\n        this.removeAll();\n        return false;\n    } \n    o.params = o.params || {};    \n    o.params.limit = 9999;          \n    o.params.onid = id;\n    o.params.ontable = 'cms_page';\n}",
+          "update" : "function (_self, rec, operation)\n{\n    \n    new Pman.Request({\n        url : baseURL+'/Roo/Images.php',\n        method : 'POST',\n        params : rec.data,\n        success: function(res)\n        {\n            Roo.log(\"GOT success\");\n            // update the data...\n            _this.grid.ds.load({});\n        },\n        failure : function(res)\n        {\n            \n        }\n        \n        \n    });\n}"
+         },
+         "xtype" : "Store",
+         "$ xns" : "Roo.data",
+         "* prop" : "dataSource",
+         "items" : [
+          {
+           "$ url" : "baseURL + '/Roo/Images.php'",
+           "method" : "GET",
+           "xtype" : "HttpProxy",
+           "$ xns" : "Roo.data",
+           "* prop" : "proxy"
+          },
+          {
+           "id" : "id",
+           "root" : "data",
+           "xtype" : "JsonReader",
+           "$ xns" : "Roo.data",
+           "$ fields" : "[\n    {\n        'name': 'id',\n        'type': 'int'\n    },\n    {\n        'name': 'filename',\n        'type': 'string'\n    },\n    {\n        'name': 'ontable',\n        'type': 'string'\n    },\n    {\n        'name': 'onid',\n        'type': 'int'\n    },\n    {\n        'name': 'mimetype',\n        'type': 'string'\n    },\n    {\n        'name': 'width',\n        'type': 'int'\n    },\n    {\n        'name': 'height',\n        'type': 'int'\n    },\n    {\n        'name': 'filesize',\n        'type': 'int'\n    },\n    {\n        'name': 'displayorder',\n        'type': 'int'\n    },\n    {\n        'name': 'language',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id',\n        'type': 'int'\n    },\n    {\n        'name': 'created',\n        'type': 'date',\n        'dateFormat': 'Y-m-d'\n    },\n    {\n        'name': 'imgtype',\n        'type': 'string'\n    },\n    {\n        'name': 'linkurl',\n        'type': 'string'\n    },\n    {\n        'name': 'descript',\n        'type': 'string'\n    },\n    {\n        'name': 'title',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_id',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_filename',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_ontable',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_onid',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_mimetype',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_width',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_height',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_filesize',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_displayorder',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_language',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_parent_image_id',\n        'type': 'int'\n    },\n    {\n        'name': 'parent_image_id_created',\n        'type': 'date'\n    },\n    {\n        'name': 'parent_image_id_imgtype',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_linkurl',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_descript',\n        'type': 'string'\n    },\n    {\n        'name': 'parent_image_id_title',\n        'type': 'string'\n    }\n]",
+           "* prop" : "reader",
+           "totalProperty" : "total"
+          }
+         ]
+        },
+        {
+         "xtype" : "Toolbar",
+         "$ xns" : "Roo",
+         "* prop" : "toolbar",
+         "items" : [
+          {
+           "listeners" : {
+            "|click" : "function()\n{\n    var id = _this.form.findField('id').getValue() * 1;\n    \n    if(id < 1){\n        return;\n    }\n    \n    Pman.Dialog.Image.show( { id : 0, onid : id, ontable: 'cms_page' }, function() {\n        Roo.log('load?????');\n        _this.grid.ds.load({});\n    }); \n\n}\n        "
+           },
+           "text" : "Add",
+           "xtype" : "Button",
+           "cls" : "x-btn-text-icon",
+           "$ icon" : "Roo.rootURL + 'images/default/dd/drop-add.gif'",
+           "$ xns" : "Roo"
+          },
+          {
+           "listeners" : {
+            "|click" : "function()\n{\n    var selection = _this.grid.getSelectionModel().getSelectedCell();\n    var sn = _this.grid.ds.getAt(selection[0]);\n    if (!sn || isNaN(sn.id *1)) {\n        Roo.MessageBox.alert(\"Error\", \"Select a image\"); \n        return;\n    }\n    Roo.MessageBox.confirm(\"Confirm\", \"Are sure you want to delete this image?\", function (v){\n        if (v != 'yes') {\n            return;\n        }\n        \n        new Pman.Request({\n            url : baseURL + '/Roo/Images.php',\n            method: 'POST',\n            params : {\n                _delete : sn.id\n            },\n            success : function()\n            {\n                Roo.log('Got Success!!');\n               _this.grid.ds.load({});\n            }\n        });\n    });\n}\n        "
+           },
+           "text" : "Delete",
+           "xtype" : "Button",
+           "cls" : "x-btn-text-icon",
+           "$ icon" : "rootURL + '/Pman/templates/images/trash.gif'",
+           "$ xns" : "Roo"
+          }
+         ]
+        },
+        {
+         "xtype" : "ColumnModel",
+         "sortable" : false,
+         "header" : "",
+         "width" : 75,
+         "$ renderer" : "function(v,x,r) { \n    return  String.format('<img src=\"{0}/Images/Thumb/100/{1}/{2}\" height=\"100\">', baseURL, v, r.data.filename); \n}",
+         "$ xns" : "Roo.grid",
+         "* prop" : "colModel[]",
+         "dataIndex" : "id"
+        },
+        {
+         "xtype" : "ColumnModel",
+         "width" : 100,
+         "header" : "Filename",
+         "$ renderer" : "function(v) { return String.format('{0}', v); }",
+         "$ xns" : "Roo.grid",
+         "* prop" : "colModel[]",
+         "dataIndex" : "filename"
+        },
+        {
+         "xtype" : "ColumnModel",
+         "width" : 50,
+         "header" : "Order",
+         "$ renderer" : "function(v) { return String.format('{0}', v); }",
+         "$ xns" : "Roo.grid",
+         "* prop" : "colModel[]",
+         "dataIndex" : "displayorder",
+         "items" : [
+          {
+           "xtype" : "GridEditor",
+           "$ xns" : "Roo.grid",
+           "* prop" : "editor",
+           "items" : [
+            {
+             "listeners" : {
+              "focus" : "function (_self)\n{\n    if (this.value == 0) {\n        this.el.dom.value = '';\n    }\n}"
+             },
+             "xtype" : "NumberField",
+             "$ xns" : "Roo.form",
+             "decimalPrecision" : 0,
+             "* prop" : "field"
+            }
+           ]
+          }
+         ]
+        },
+        {
+         "xtype" : "ColumnModel",
+         "width" : 100,
+         "header" : "Title",
+         "$ renderer" : "function(v) { return String.format('{0}', v); }",
+         "$ xns" : "Roo.grid",
+         "* prop" : "colModel[]",
+         "dataIndex" : "title",
+         "items" : [
+          {
+           "xtype" : "GridEditor",
+           "$ xns" : "Roo.grid",
+           "* prop" : "editor",
+           "items" : [
+            {
+             "xtype" : "TextField",
+             "$ xns" : "Roo.form",
+             "* prop" : "field"
+            }
+           ]
+          }
+         ]
+        },
+        {
+         "xtype" : "ColumnModel",
+         "width" : 300,
+         "header" : "URL",
+         "$ renderer" : "function(v)\n{\n    return String.format('{0}', (v) ? v : '');\n}",
+         "$ xns" : "Roo.grid",
+         "* prop" : "colModel[]",
+         "dataIndex" : "linkurl",
+         "items" : [
+          {
+           "xtype" : "GridEditor",
+           "$ xns" : "Roo.grid",
+           "* prop" : "editor",
+           "items" : [
+            {
+             "xtype" : "TextField",
+             "$ xns" : "Roo.form",
+             "* prop" : "field"
+            }
+           ]
+          }
+         ]
+        }
+       ]
+      }
+     ]
+    },
+    {
+     "listeners" : {
+      "resize" : "function (_self, width, height)\n{\n    Roo.log('resize called');\n    var ew = Math.max(250, width-50);\n    var eh = Math.max(250,height-50) ;\n    if (!_this.trform) {\n        return;\n        }\n        _this.trform.showHide();\n   \n    var bd = _this.trform.findField('body');\n    if (bd.resizeEl) { \n        bd.width = ew;\n        bd.height = eh;\n        // since render delays resize.. \n        bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );\n        _this.trbodycol.el.setWidth(bd.width+20);\n    }\n    var bd = _this.trform.findField('extended');\n    if (bd.resizeEl) { \n        bd.width = ew;\n        bd.height = eh;\n        // since render delays resize.. \n        bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );\n        _this.trextendcol.el.setWidth(bd.width+20);\n    }\n\n}",
+      "render" : "function (_self)\n{\n  _this.trpanel = _self;\n}"
+     },
+     "autoScroll" : true,
+     "fitToFrame" : true,
+     "region" : "west",
+     "xtype" : "ContentPanel",
+     "$ xns" : "Roo",
+     "items" : [
+      {
+       "listeners" : {
+        "|actionfailed" : "function (_self, action)\n{\n    _this.dialog.el.unmask();\n \n    Pman.standardActionFailed(_self, action);\n}\n",
+        "|actioncomplete" : "function (_self, action)\n{\n\n   if (action.type =='submit') {\n       //   _this.dialog.el.mask(\"Saving\");\n        return;\n    }\n    \n    if (action.type == 'setdata') {    \n          \n          if ( _this.data.id) {\n               // _this.dialog.el.mask(\"Loading\");\n                this.load({ method: 'GET', params: { '_id' : _this.data.id }});\n           } else {\n                \n                //_this.loaded = true;\n                 this.trpanel.el.mask(\"save first\");\n          }\n\n       return;\n      \n    }\n    \n    if (action.type == 'load') {\n//        _this.dialog.el.unmask();\n        this.showHide();\n        \n        _this.trform.findField('body').originalValue = _this.trform.findField('body').getValue();\n       _this.trform.findField('extended').originalValue = _this.trform.findField('extended').getValue();\n  \n        return;\n    }\n}\n",
+        "|rendered" : "function (_self)\n{\n    _this.trform = _self;\n}\n"
+       },
+       "labelAlign" : "right",
+       "$ url" : "baseURL + '/Roo/cms_page.php'",
+       "method" : "POST",
+       "style" : "margin: 5px",
+       "xtype" : "Form",
+       "labelWidth" : 120,
+       "$ showHide" : "function() {\n\n  //  var in_rss= _this.form.findField('in_rss').getValue() * 1;\n    var has_extended = _this.form.findField('has_extended').getValue() * 1;\n    var has_lang = _this.trform.findField('language').getValue().length;\n    \n    var vis = {\n        //category_id : in_rss,\n        //page_link : !in_rss, // blogs which have perm links?\n        //is_element : !in_rss,        \n        //parent_id : !in_rss,\n        //published : in_rss,\n        //to_replace_id : !in_rss, // is this used.\n        //has_extended : true, // always shown.\n        extended : has_lang && has_extended,\n        body : has_lang,\n        title : has_lang,\n        descriptions : has_lang,\n        keywords : has_lang\n        //author_id : in_rss\n        \n    };\n    for(var k in vis) {\n        var el = _this.trform.findField(k);\n        el.actionMode = 'fieldEl';\n        if (    vis[k]) {\n            Roo.log(\"show: \" + k);\n            el.show();\n        } else{ \n            Roo.log(\"hide: \" + k);\n            el.hide();\n        }\n\n    }\n\n    _this.updateRow.el[has_lang ? 'show' : 'hide']();\n    // we should now trigger the panel resize event..\n   \n    \n    if(typeof(_this.trform.editors) == 'undefined'){\n        _this.trform.editors = {\n            body : _this.trform.findField('body').wrap.isVisible(),\n            extended : _this.trform.findField('extended').wrap.isVisible()\n       };\n       if(_this.trform.editors.body){\n            setInterval(_this.trform.findField('body').autosave, 60000);\n       }\n       \n       if(_this.trform.editors.extended){\n            setInterval(_this.trform.findField('extended').autosave, 60000);\n       }\n   }\n   \n   if(!_this.trform.editors.body && _this.trform.findField('body').wrap.isVisible()){\n        setInterval(_this.trform.findField('body').autosave, 60000);\n        _this.trform.editors.body = true;\n   }\n   \n   if(!_this.trform.editors.extended && _this.trform.findField('extended').wrap.isVisible()){\n        setInterval(_this.trform.findField('extended').autosave, 60000);\n        _this.trform.editors.extended = true;\n   }\n    \n    \n    \n    \n}\n",
+       "$ xns" : "Roo.form",
+       "items" : [
+        {
+         "labelAlign" : "top",
+         "xtype" : "Column",
+         "width" : 400,
+         "$ xns" : "Roo.form",
+         "items" : [
+          {
+           "labelAlign" : "top",
+           "xtype" : "Row",
+           "width" : 400,
+           "$ xns" : "Roo.form",
+           "items" : [
+            {
+             "listeners" : {
+              "add" : "function (combo)\n{\n    Pman.Dialog.CmsLanguagePick.show({_with_name : true}, function( res) {\n       // Roo.log(res);\n        combo.setValue(res.lang);\n        combo.el.dom.value = res.lang_name;\n        (function() { \n            _this.trform.showHide();\n           _this.trpanel.fireEvent('resize', _this.trpanel, [ _this.trpanel.el.getWidth(), _this.trpanel.el.getHeight() ]  );\n       }).defer(100); \n    });\n    \n}",
+              "render" : "function (_self)\n{\n    _this.language = _self;\n}",
+              "select" : "function (combo, record, index)\n{\n    (function() { \n        _this.trform.showHide();\n       _this.trpanel.fireEvent('resize', _this.trpanel, [ _this.trpanel.el.getWidth(), _this.trpanel.el.getHeight() ]  );\n   }).defer(100); \n    \n    \n   _this.trform.load({\n    \n        method: 'GET', \n        params: {\n            'lookup[language]' : record.data.language,\n            'lookup[translation_of_id]' : _this.data.id,\n            'lookup[_id]' : 1\n        }\n   });\n}"
+             },
+             "alwaysQuery" : true,
+             "listWidth" : 400,
+             "triggerAction" : "all",
+             "fieldLabel" : "Select Language",
+             "forceSelection" : true,
+             "selectOnFocus" : true,
+             "pageSize" : 20,
+             "displayField" : "language_name",
+             "emptyText" : "Select Language",
+             "hiddenName" : "language",
+             "minChars" : 2,
+             "valueField" : "language",
+             "xtype" : "ComboBox",
+             "typeAhead" : false,
+             "editable" : false,
+             "$ xns" : "Roo.form",
+             "name" : "language_name",
+             "qtip" : "Select Language",
+             "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{language_name}</b> </div>",
+             "loadingText" : "Searching...",
+             "items" : [
+              {
+               "listeners" : {
+                "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n    \n    o.params._distinct = 'language';\n    o.params._columns ='language_name,language';\n    o.params._with_name = true;\n    \n    if(_this.form.findField('id').getValue()*1 > 0){\n        o.params.translation_of_id = _this.form.findField('id').getValue();\n    }\n    \n}\n"
+               },
+               "xtype" : "Store",
+               "remoteSort" : true,
+               "$ sortInfo" : "{ direction : 'ASC', field: 'language' }",
+               "$ xns" : "Roo.data",
+               "* prop" : "store",
+               "items" : [
+                {
+                 "$ url" : "baseURL + '/Roo/Cms_page.php'",
+                 "method" : "GET",
+                 "xtype" : "HttpProxy",
+                 "$ xns" : "Roo.data",
+                 "* prop" : "proxy"
+                },
+                {
+                 "id" : "id",
+                 "root" : "data",
+                 "xtype" : "JsonReader",
+                 "$ fields" : "[{\"name\":\"language\",\"type\":\"string\"}]",
+                 "$ xns" : "Roo.data",
+                 "* prop" : "reader",
+                 "totalProperty" : "total"
+                }
+               ]
+              }
+             ]
+            },
+            {
+             "listeners" : {
+              "render" : "function (_self)\n{\n_this.updateRow = _self;\n}"
+             },
+             "xtype" : "Row",
+             "style" : "padding-top:12px;padding-left:30px;float:left",
+             "width" : 100,
+             "$ xns" : "Roo.form",
+             "items" : [
+              {
+               "listeners" : {
+                "click" : " function()\n {\n    //   _this.dialog.el.mask(\"Saving\");\n    if(!_this.trform.findField('body').editorcore.sourceEditMode){\n        _this.trform.findField('body').syncValue(); \n        _this.trform.findField('extended').syncValue();\n    }else{\n        _this.trform.findField('body').pushValue();\n        _this.trform.findField('extended').pushValue();\n    }\n    \n    _this.trform.findField('parent_id').setValue(_this.form.findField('parent_id').getValue());\n    _this.trform.findField('element_id').setValue(_this.form.findField('element_id').getValue());\n    _this.trform.findField('translation_of_id').setValue(_this.form.findField('id').getValue());\n    _this.trform.findField('is_menuitem').setValue(_this.form.findField('is_menuitem').getValue());\n    _this.trform.findField('menu_page_id').setValue(_this.form.findField('menu_page_id').getValue());\n    \n    if(_this.trform.findField('element_id').getValue()*1 > 0){\n        _this.trform.findField('is_element').setValue(1);\n    }\n    \n    _this.trform.doAction(\"submit\");\n}\n"
+               },
+               "text" : "Update",
+               "xtype" : "Button",
+               "$ xns" : "Roo"
+              }
+             ]
+            }
+           ]
+          },
+          {
+           "fieldLabel" : "Title",
+           "xtype" : "TextField",
+           "width" : 400,
+           "$ xns" : "Roo.form",
+           "name" : "title"
+          }
+         ]
+        },
+        {
+         "listeners" : {
+          "render" : "function (_self)\n{\n  _this.trbodycol = _self;\n}"
+         },
+         "labelAlign" : "top",
+         "xtype" : "Column",
+         "width" : 1000,
+         "$ xns" : "Roo.form",
+         "items" : [
+          {
+           "listeners" : {
+            "stylesheetsclick" : "function (_self)\n{\n    Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){\n        _this.dialog.setStylesheets();\n    })\n    \n}",
+            "savedpreview" : "function (_self)\n{\n    var id = _this.trform.findField('id').getValue() * 1;\n    \n    var successFn = function(res){\n        return res.data.POST.source;\n    };\n    \n    var params = {\n        action : 'AUTOSAVE',\n        remarks : 'BODY',\n        on_id : (id < 1) ? 0 : id,\n        on_table : 'cms_page',\n        successFn : successFn\n    };\n    \n    \n    Pman.Dialog.CoreAutoSavePreview.show(params, function(res){\n        _self.setValue(res);\n        _self.originalValue = res;\n    });\n}",
+            "autosave" : "function (_self)\n{\n    var id = _this.trform.findField('id').getValue() * 1;\n    \n    /*\n    if(!_self.editorcore.sourceEditMode){\n        _self.syncValue();\n    }else{\n        _self.pushValue();\n    }\n    */\n    new Pman.Request({\n        url : baseURL + '/Roo/Events.php',\n        method :'POST',\n        params : {\n            id : 0,\n            action : 'AUTOSAVE',\n            on_id : (id > 0) ? id : 0,\n            on_table : 'cms_page',\n            remarks : 'BODY',\n            source: _self.getValue()\n        },\n        success : function() {\n            _self.originalValue = _self.getValue();\n            \n        },\n        failure : function() \n        {\n            //Roo.MessageBox.alert(\"Error\", \"autosave failed\");\n            Roo.log('tr body autosave failed?!');\n        }\n    });\n}"
+           },
+           "fieldLabel" : "Contents",
+           "xtype" : "HtmlEditor",
+           "$ xns" : "Roo.form",
+           "resizable" : "s",
+           "$ autosave" : "function() {\n    \n    var body = _this.trform.findField('body');\n    \n    if(!body.wrap.isVisible(true) || body.getValue() == '' || !body.isDirty()){\n        Roo.log('tr body not dirty');\n        return;\n    }\n\n    Roo.log('tr body dirty, auto save!');\n    \n    body.fireEvent('autosave', body);\n}\n",
+           "$ array white" : "[ 'iframe' ]",
+           "name" : "body",
+           "height" : 140,
+           "items" : [
+            {
+             "xtype" : "ToolbarStandard",
+             "$ xns" : "Roo.form.HtmlEditor",
+             "* prop" : "toolbars[]",
+             "items" : [
+              {
+               "listeners" : {
+                "render" : "function (_self)\n{\n    _this.trbodyimgselect = _self;\n}",
+                "beforequery" : "function (combo, query, forceAll, cancel, e)\n{\n \n    var id = _this.form.findField('id').getValue() * 1;    \n    if (!id) {\n        Roo.MessageBox.alert(\"Error\", \"Save press release first\");\n        return false;\n    }\n}",
+                "select" : "function (combo, record, index)\n{\n    Roo.log(record);\n    (function() { \n        combo.setValue('');\n    }).defer(100);\n    \n    var editor = _this.trform.findField('body').editorcore;\n    \n    var curnode = editor.getSelectedNode();\n    \n    if (curnode && curnode.tagName == 'IMG') {\n        curnode.src= String.format('{0}/Images/{1}/{2}#attachment-{1}',\n                baseURL,  record.data.id, record.data.filename\n            );\n            // note -forces an update... hopefully...\n        editor.owner.fireEvent('editorevent', editor, false);\n    } else {\n    \n        editor.insertAtCursor(\n            String.format('<img src=\"{0}/Images/{1}/{2}#attachment-{1}\">',\n            baseURL,  record.data.id, record.data.filename\n            )\n        );\n\n    }\n    \n}"
+               },
+               "$ tpl" : "'<div class=\"x-grid-cell-text x-btn button\"><img src=\"' + baseURL + '/Images/Thumb/150x150/{id}.jpg\" height=\"150\" width=\"150\"><b>{filename}</b> </div>'",
+               "alwaysQuery" : true,
+               "listWidth" : 400,
+               "triggerAction" : "all",
+               "fieldLabel" : "Images",
+               "forceSelection" : true,
+               "selectOnFocus" : true,
+               "pageSize" : 20,
+               "displayField" : "name",
+               "emptyText" : "Add Image",
+               "minChars" : 2,
+               "valueField" : "id",
+               "xtype" : "ComboBox",
+               "typeAhead" : true,
+               "editable" : false,
+               "width" : 100,
+               "$ xns" : "Roo.form",
+               "* prop" : "btns[]",
+               "qtip" : "Select Images",
+               "loadingText" : "Searching...",
+               "items" : [
+                {
+                 "listeners" : {
+                  "|beforeload" : "function (_self, o){\n    o.params = o.params || {};\n\n    var id = _this.form.findField('id').getValue() * 1;    \n    if (!id) {\n        Roo.MessageBox.alert(\"Error\", \"Save press release first\");\n        return false;\n    }\n    o.params.onid = id;\n    o.params.ontable = 'cms_page';\n   // o.params.imgtype = 'PressRelease';\n    //o.params['query[imagesize]'] = '150x150';\n    // set more here\n}\n"
+                 },
+                 "xtype" : "Store",
+                 "remoteSort" : true,
+                 "$ sortInfo" : "{ direction : 'ASC', field: 'id' }",
+                 "$ xns" : "Roo.data",
+                 "* prop" : "store",
+                 "items" : [
+                  {
+                   "$ url" : "baseURL + '/Roo/Images.php'",
+                   "xtype" : "HttpProxy",
+                   "method" : "GET",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "proxy"
+                  },
+                  {
+                   "id" : "id",
+                   "root" : "data",
+                   "xtype" : "JsonReader",
+                   "$ fields" : "[{\"name\":\"id\",\"type\":\"int\"},{\"name\":\"filename\",\"type\":\"string\"},{\"name\":\"url_thumb\",\"type\":\"string\"}]",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "reader",
+                   "totalProperty" : "total"
+                  }
+                 ]
+                }
+               ]
+              },
+              {
+               "listeners" : {
+                "select" : "function (combo, record, index)\n{\n  //  Roo.log(record);\n    (function() { \n        combo.setValue('');\n    }).defer(100);\n    var editor = _this.form.findField('body');\n    editor.insertAtCursor(\n            String.format('<a href=\"#page-{0}\">{1}</a>',\n            record.data.page_link,  record.data.title\n            )\n     );\n\n    \n }"
+               },
+               "listWidth" : 200,
+               "triggerAction" : "all",
+               "forceSelection" : true,
+               "selectOnFocus" : true,
+               "pageSize" : 40,
+               "displayField" : "page_link",
+               "emptyText" : "Add Link",
+               "hiddenName" : "add_link_id",
+               "minChars" : 2,
+               "valueField" : "id",
+               "xtype" : "ComboBox",
+               "allowBlank" : true,
+               "typeAhead" : true,
+               "editable" : true,
+               "width" : 100,
+               "$ xns" : "Roo.form",
+               "* prop" : "btns[]",
+               "name" : "add_link",
+               "qtip" : "Select Category ",
+               "tpl" : "<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>",
+               "loadingText" : "Searching...",
+               "items" : [
+                {
+                 "listeners" : {
+                  "beforeload" : "function (_self, options)\n{\n     options.params['search[page_link_no_empty]'] =1; \n     /*\n     options.params.is_element = 0;\n     options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     \n     */\n}"
+                 },
+                 "xtype" : "Store",
+                 "remoteSort" : true,
+                 "$ sortInfo" : "{ field: 'page_link', direction: 'ASC' }",
+                 "$ xns" : "Roo.data",
+                 "* prop" : "store",
+                 "items" : [
+                  {
+                   "$ url" : "baseURL + '/Roo/cms_page.php'",
+                   "method" : "GET",
+                   "xtype" : "HttpProxy",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "proxy"
+                  },
+                  {
+                   "id" : "id",
+                   "root" : "data",
+                   "xtype" : "JsonReader",
+                   "$ fields" : "[\n { name: 'id', type: 'int' },\n 'title',\n 'page_link' \n]",
+                   "$ xns" : "Roo.data",
+                   "* prop" : "reader",
+                   "totalProperty" : "total"
+                  }
+                 ]
+                }
+               ]
+              },
+              {
+               "xtype" : "Separator",
+               "$ xns" : "Roo.Toolbar",
+               "* prop" : "btns[]"
+              },
+              {
+               "listeners" : {
+                "click" : "function (_self, e)\n{\n    this.scope.owner.fireEvent('savedpreview', this.scope.owner);\n}"
+               },
+               "text" : "Saved Version",
+               "xtype" : "Button",
+               "$ xns" : "Roo.Toolbar",
+               "* prop" : "btns[]"
+              }
+             ]
+            },
+            {
+             "xtype" : "ToolbarContext",
+             "$ xns" : "Roo.form.HtmlEditor",
+             "* prop" : "toolbars[]"
+            }
+           ]
+          }
+         ]
+        },
+        {
+         "listeners" : {
+          "render" : "function (_self)\n{\n  _this.trextendcol = _self;\n}"
+         },
+         "labelAlign" : "top",
+         "xtype" : "Column",
+         "$ xns" : "Roo.form",
+         "items" : [
+          {
+           "listeners" : {
+            "stylesheetsclick" : "function (_self)\n{\n    Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){\n        _this.dialog.setStylesheets();\n    })\n    \n}",
+            "savedpreview" : "function (_self)\n{\n    var id = _this.trform.findField('id').getValue() * 1;\n    \n    var successFn = function(res){\n        return res.data.POST.source;\n    };\n    \n    var params = {\n        action : 'AUTOSAVE',\n        remarks : 'EXTENDED',\n        on_id : (id < 1) ? 0 : id,\n        on_table : 'cms_page',\n        successFn : successFn\n    };\n    \n    \n    Pman.Dialog.CoreAutoSavePreview.show(params, function(res){\n        _self.setValue(res);\n        _self.originalValue = res;\n    });\n}",
+            "autosave" : "function (_self)\n{\n    var id = _this.trform.findField('id').getValue() * 1;\n    \n    /*\n    if(!_self.editorcore.sourceEditMode){\n        _self.syncValue();\n    }else{\n        _self.pushValue();\n    }\n    */\n    \n    new Pman.Request({\n        url : baseURL + '/Roo/Events.php',\n        method :'POST',\n        params : {\n            id : 0,\n            action : 'AUTOSAVE',\n            on_id : (id > 0) ? id : 0,\n            on_table : 'cms_page',\n            remarks : 'EXTENDED',\n            source: _self.getValue()\n        },\n        success : function() {\n            _self.originalValue = _self.getValue();\n            \n        },\n        failure : function() \n        {\n            //Roo.MessageBox.alert(\"Error\", \"autosave failed\");\n            Roo.log('tr extended autosave failed?!');\n        }\n    });\n}"
+           },
+           "fieldLabel" : "Extended Contents",
+           "xtype" : "HtmlEditor",
+           "$ xns" : "Roo.form",
+           "resizable" : "s",
+           "$ autosave" : "function() {\n    \n    var extended = _this.trform.findField('extended');\n    \n    if(!extended.wrap.isVisible(true) || extended.getValue() == '' || !extended.isDirty()){\n        Roo.log('tr extend not dirty');\n        return;\n    }\n\n    \n    Roo.log('tr extend dirty, auto save!');\n    \n    extended.fireEvent('autosave', extended);\n        \n   \n}\n",
+           "$ array white" : "[ 'iframe' ]",
+           "name" : "extended",
+           "height" : 140,
+           "items" : [
+            {
+             "xtype" : "ToolbarStandard",
+             "$ xns" : "Roo.form.HtmlEditor",
+             "* prop" : "toolbars[]",
+             "items" : [
+              {
+               "xtype" : "Separator",
+               "$ xns" : "Roo.Toolbar",
+               "* prop" : "btns[]"
+              },
+              {
+               "listeners" : {
+                "click" : "function (_self, e)\n{\n    this.scope.owner.fireEvent('savedpreview', this.scope.owner);\n}"
+               },
+               "text" : "Saved Version",
+               "xtype" : "Button",
+               "$ xns" : "Roo.Toolbar",
+               "* prop" : "btns[]"
+              }
+             ]
+            },
+            {
+             "xtype" : "ToolbarContext",
+             "$ xns" : "Roo.form.HtmlEditor",
+             "$ styles" : "typeof(uiConfig) != 'undefined' ? (uiConfig['Roo.form.HtmlEditor.ToolbarContext.styles'] || {}) : {}",
+             "* prop" : "toolbars[]"
+            }
+           ]
+          }
+         ]
+        },
+        {
+         "listeners" : {
+          "render" : "function (_self)\n{\n  _this.trkeywordscol = _self;\n}"
+         },
+         "labelAlign" : "top",
+         "xtype" : "Column",
+         "$ xns" : "Roo.form",
+         "items" : [
+          {
+           "fieldLabel" : "Keywords",
+           "xtype" : "TextArea",
+           "width" : 450,
+           "$ xns" : "Roo.form",
+           "name" : "keywords",
+           "height" : 150
+          },
+          {
+           "fieldLabel" : "Descriptions",
+           "xtype" : "TextArea",
+           "width" : 450,
+           "$ xns" : "Roo.form",
+           "name" : "descriptions",
+           "height" : 150
+          }
+         ]
+        },
+        {
+         "xtype" : "Hidden",
+         "$ xns" : "Roo.form",
+         "name" : "id"
+        },
+        {
+         "xtype" : "Hidden",
+         "$ xns" : "Roo.form",
+         "name" : "element_id"
+        },
+        {
+         "xtype" : "Hidden",
+         "$ xns" : "Roo.form",
+         "name" : "menu_page_id"
+        },
+        {
+         "xtype" : "Hidden",
+         "$ xns" : "Roo.form",
+         "name" : "is_menuitem"
+        },
+        {
+         "xtype" : "Hidden",
+         "value" : 0,
+         "$ xns" : "Roo.form",
+         "name" : "is_element"
+        },
+        {
+         "xtype" : "Hidden",
+         "$ xns" : "Roo.form",
+         "name" : "translation_of_id"
+        },
+        {
+         "xtype" : "Hidden",
+         "$ xns" : "Roo.form",
+         "name" : "parent_id"
+        }
+       ]
+      }
+     ]
+    },
+    {
+     "listeners" : {
+      "|click" : " function() {\n\n    _this.form.reset();\n\n    _this.dialog.hide();\n\n}\n"
+     },
+     "text" : "Cancel",
+     "xtype" : "Button",
+     "$ xns" : "Roo",
+     "* prop" : "buttons[]"
+    },
+    {
+     "listeners" : {
+      "|click" : " function() {\n\n        _this.exit = false;\n        \n       _this.dialog.el.mask(\"Saving\");\n       \n       if(!_this.form.findField('body').editorcore.sourceEditMode){\n            _this.form.findField('body').syncValue();\n            _this.form.findField('extended').syncValue();\n        }else{\n            _this.form.findField('body').pushValue();\n            _this.form.findField('extended').pushValue();\n        }\n        \n        if(_this.data.page_type_id_name != 'blog' && AppModules.indexOf(\"Crm\") == -1){\n            _this.interests.reset();\n        }\n        \n     _this.form.doAction(\"submit\");\n\n}\n"
+     },
+     "text" : "Save",
+     "xtype" : "Button",
+     "$ xns" : "Roo",
+     "* prop" : "buttons[]"
+    },
+    {
+     "listeners" : {
+      "|click" : " function() {\n\n        _this.exit = true;\n        \n       _this.dialog.el.mask(\"Saving\");\n       \n       if(!_this.form.findField('body').editorcore.sourceEditMode){\n            _this.form.findField('body').syncValue();\n            _this.form.findField('extended').syncValue();\n        }else{\n            _this.form.findField('body').pushValue();\n            _this.form.findField('extended').pushValue();\n        }\n        \n        if(_this.data.page_type_id_name != 'blog' && AppModules.indexOf(\"Crm\") == -1){\n            _this.interests.reset();\n        }\n        \n     _this.form.doAction(\"submit\");\n\n}\n"
+     },
+     "text" : "Save and close",
+     "xtype" : "Button",
+     "$ xns" : "Roo",
+     "* prop" : "buttons[]"
+    }
+   ]
+  }
  ]
 }
\ No newline at end of file
diff --git a/Pman.Dialog.CmsBlog.Old.js b/Pman.Dialog.CmsBlog.Old.js
new file mode 100644 (file)
index 0000000..fac51e0
--- /dev/null
@@ -0,0 +1,3428 @@
+//<script type="text/javascript">
+
+// Auto generated file - created by app.Builder.js- do not edit directly (at present!)
+
+Roo.namespace('Pman.Dialog.CmsBlog');
+
+Pman.Dialog.CmsBlog.Old = {
+
+ _strings : {
+  '2f26e35d61be90501e099089dc533638' :"Select Images",
+  'f3912172e6bf57f8979782f4a2342233' :"Appears in Block",
+  '95cb4f45ab7ff3984f25ab8668499020' :"Select Parent",
+  'c1df1da7a1ce305a3b60af9d5733ac1d' :"Contents",
+  'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
+  'ebd9bec4d70abc789d439c1f136b0538' :"Layout",
+  '20bec77364d863100a1f9325873a8504' :"Select Page Type",
+  'a517747c3d12f99244ae598910d979c5' :"Author",
+  '779e2624ddf330fb05b51ae59faf212d' :"Select Status Type",
+  '6a5b847af3d97df722040debdbccfbed' :"Page Type",
+  '30d1a216420426fcbd43ca70acd4aa48' :"Select interests",
+  'e6b391a8d2c4d45902a23a8b6585703d' :"URL",
+  'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
+  '778551900655782c5c7827332b08cf3f' :"Save and close",
+  '77174410b72decfd0b259961f1f65a8f' :"Attributes:",
+  'b28a711cf7e94ec793ef926633997529' :"Seq",
+  '1243daf593fa297e07ab03bf06d925af' :"Searching...",
+  '580b21aac58f1b73cece26e272cdfbee' :"Add Link",
+  '8bc84316c4078bf66723fd019616d920' :"Descriptions",
+  '83dad8107f9459efe2b4fabcf5b63108' :"Select Language",
+  '76729937a5eb6b0fd88c42581161facd' :"Select Category ",
+  '76729937a5eb6b0fd88c42581161facd' :"Select Category",
+  '0b8d92bc19b720bb1065649535463409' :"Translations",
+  'd41d8cd98f00b204e9800998ecf8427e' :"",
+  '867343577fa1f33caa632a19543bd252' :"Keywords",
+  '340c2ee497b85d5954b01c64de7f44f6' :"Select Person",
+  '69dd756ae9c23191a5bb9b61f0857432' :"Date to Publish",
+  '3adbdb3ac060038aa0e6e6c138ef9873' :"Category",
+  '57e195426892c5515935f21d97228814' :"Extended Contents",
+  'd88aa1eee60ba140f07d5f81769cec74' :"<< Edit Translations",
+  'b9c49611cfda3259a2b837b39489e650' :"Add Image",
+  'ea4788705e6873b424c65e91c2846b19' :"Cancel",
+  'cfcd208495d565ef66e7dff9f98764da' :"0",
+  'bd88a20b53a47f7b5704a83a15ff5506' :"Saved Version",
+  '70a4bc2672e2e3912e6476a2bd7ba29b' :"Parent page",
+  '31bb2f6e9b8fb11cbb7fb63c6025223f' :"Select Template",
+  'c02bd0c22c290ae599ee2f3ff2023fd3' :"Manage Images / Attachments >>",
+  'b78a3223503896721cca1303f776159b' :"Title",
+  '39f64cc9436cacfbceda3b7bdeb8e24c' :"Styles (CSS)",
+  'e64df1d7c22b9638f084ce8a4aff3ff3' :"Target URL",
+  'a240fa27925a635b08dc28c9e4f9216d' :"Order",
+  '287234a1ff35a314b5b6bc4e5828e745' :"Attributes",
+  '99e7707748ae048e17c5810fad119e0b' :"Select Page",
+  '06933067aafd48425d67bcb01bba5cb6' :"Update",
+  '8adedb6a6226807ba810215dd3b3c61b' :"Menu links to Page",
+  'b5216c9b4e0ac0afd9c76eb1d12ad1b9' :"Select Section",
+  '308f2757bfc9ce92fb00ff93fdffd279' :"Images / Attachments",
+  '1351017ac6423911223bc19a8cb7c653' :"Filename",
+  'c9cc8cce247e49bae79f15173ce97354' :"Save",
+  'e659b52eba1f0299b2d8ca3483919e72' :"Type:",
+  'c70952e4ab3806c049737cd7d2b8896b' :"Interests",
+  'aa6356b678bc4fc78253c9edf65bff03' :"Edit Page / Blog Entry",
+  'd52f80f80467bb575253a5a39ca016a7' :"Page link /  Name / Order",
+  'fff0d600f8a0b5e19e88bfb821dd1157' :"Images",
+  'fb3f11443065d5f4d8303ad913db9680' :"Replaces (ignore)"
+ },
+
+ dialog : false,
+ callback:  false,
+
+ show : function(data, cb)
+ {
+  if (!this.dialog) {
+   this.create();
+  }
+
+  this.callback = cb;
+  this.data = data;
+  this.dialog.show(this.data._el);
+  if (this.form) {
+   this.form.reset();
+   this.form.setValues(data);
+   this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
+  }
+
+ },
+
+ create : function()
+ {
+   var _this = this;
+   this.dialog = Roo.factory({
+    xtype : 'LayoutDialog',
+    background : true,
+    closable : true,
+    collapsible : false,
+    height : 600,
+    modal : true,
+    resizable : false,
+    setStylesheets : function() {
+        var sheets = [];
+        
+        sheets.push(rootURL + '/Pman/Cms/templates/undoreset.css');
+        
+        if(typeof(uiConfig) !== 'undefined'  && typeof(uiConfig.cms_css) != 'undefined'){
+            Roo.each(uiConfig.cms_css, function(v){
+                sheets.push(rootURL + v);
+            })
+        }
+        
+        new Pman.Request({
+           url : baseURL + '/Roo/Cms_page.php',
+           method : 'GET',
+           params : {
+               _stylesheets : 1
+           }, 
+           success : function(res) {
+                Roo.log(res);
+                if(res.data._stylesheets.length){
+                    var setting = res.data._stylesheets.split("\n");
+                    
+                    Roo.each(setting, function(s){
+                        sheets.push(s.replace('{rootURL}', rootURL));
+                    });
+                    
+                }
+                Roo.log(sheets);
+                Roo.log(_this.form.findField('body'));
+                _this.form.findField('body').removeStylesheets();
+                _this.form.findField('extended').removeStylesheets();
+    
+                _this.form.findField('body').setStylesheets(sheets);
+                _this.form.findField('extended').setStylesheets(sheets);
+    
+                _this.trform.findField('body').removeStylesheets();
+                _this.trform.findField('extended').removeStylesheets();
+                
+                _this.trform.findField('body').setStylesheets(sheets);
+                _this.trform.findField('extended').setStylesheets(sheets);
+           }
+       });
+    
+    },
+    title : _this._strings['aa6356b678bc4fc78253c9edf65bff03'] /* Edit Page / Blog Entry */,
+    width : 850,
+    listeners : {
+     show : function (_self)
+      {
+          // @see the contentpanel - center - resize handler.
+      
+          var w = Roo.lib.Dom.getViewWidth();
+          var h = Roo.lib.Dom.getViewHeight();    
+          this.resizeTo(w-50, h-50);
+          this.center();
+          
+          var ew = Math.max(250, w-150); // was 350?/ why?
+          var eh = Math.max(250, h-350) ;
+          
+          var bd = _this.form.findField('body');
+          if (bd.resizeEl) { 
+              bd.width = ew;
+              bd.height = eh;
+              // since render delays resize.. 
+             bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
+              _this.bodycol.el.setWidth(bd.width+20);
+          }
+          var bd = _this.form.findField('extended');
+          if (bd.resizeEl) { 
+              bd.width = ew;
+              bd.height = eh;
+              // since render delays resize.. 
+             bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
+             _this.extendcol.el.setWidth(bd.width+20);
+          }
+           var bd = _this.form.findField('extra_css');
+          if (bd) { 
+              bd.el.setWidth(ew);
+             _this.keywordscol.el.setWidth(ew+20);
+          }
+          Pman.Cms.pageEditAddCustomFields();
+          // fix messed up scroll.
+          _this.dialog.layout.el.dom.scrollTop = 0;
+      
+      }
+    },
+    xns : Roo,
+    '|xns' : 'Roo',
+    center : {
+     xtype : 'LayoutRegion',
+     titlebar : false,
+     xns : Roo,
+     '|xns' : 'Roo'
+    },
+    east : {
+     xtype : 'LayoutRegion',
+     collapsed : true,
+     collapsedTitle : 'Images / Attachments',
+     collapsible : true,
+     fitToFrame : true,
+     split : true,
+     title : _this._strings['308f2757bfc9ce92fb00ff93fdffd279'] /* Images / Attachments */,
+     titlebar : true,
+     listeners : {
+      expanded : function (_self)
+       {
+           var id = _this.form.findField('id').getValue() * 1;
+           
+           if(id < 1){
+               Roo.MessageBox.alert('Error', 'Save first');
+               this.collapse();
+               return;
+           }
+           
+           var w = Roo.lib.Dom.getViewWidth();
+           var h = Roo.lib.Dom.getViewHeight();
+           
+           _self.resizeTo.defer(110, _self,[ w-400,  h] );
+           _this.trpanel.region.collapse();
+       }
+     },
+     xns : Roo,
+     '|xns' : 'Roo'
+    },
+    west : {
+     xtype : 'LayoutRegion',
+     collapsed : true,
+     collapsedTitle : 'Translations',
+     collapsible : true,
+     fitToFrame : true,
+     split : true,
+     title : _this._strings['0b8d92bc19b720bb1065649535463409'] /* Translations */,
+     titlebar : true,
+     listeners : {
+      expanded : function (_self)
+       {
+           var id = _this.form.findField('id').getValue() * 1;
+           
+           if(id < 1){
+               Roo.MessageBox.alert('Error', 'Save first');
+               this.collapse();
+               return;
+           }
+           
+           var w = Roo.lib.Dom.getViewWidth();
+           var h = Roo.lib.Dom.getViewHeight();
+           
+           _self.resizeTo.defer(110, _self,[ w-400,  h-350] );
+           
+           _this.panel.region.collapse();
+           
+       }
+     },
+     xns : Roo,
+     '|xns' : 'Roo'
+    },
+    buttons : [
+     {
+      xtype : 'Button',
+      text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
+      listeners : {
+       click : function() {
+        
+            _this.form.reset();
+        
+            _this.dialog.hide();
+        
+        }
+      },
+      xns : Roo,
+      '|xns' : 'Roo'
+     },
+     {
+      xtype : 'Button',
+      text : _this._strings['c9cc8cce247e49bae79f15173ce97354'] /* Save */,
+      listeners : {
+       click : function() {
+        
+                _this.exit = false;
+                
+               _this.dialog.el.mask("Saving");
+               
+               if(!_this.form.findField('body').editorcore.sourceEditMode){
+                    _this.form.findField('body').syncValue();
+                    _this.form.findField('extended').syncValue();
+                }else{
+                    _this.form.findField('body').pushValue();
+                    _this.form.findField('extended').pushValue();
+                }
+                
+                if(_this.data.page_type_id_name != 'blog' && AppModules.indexOf("Crm") == -1){
+                    _this.interests.reset();
+                }
+                
+             _this.form.doAction("submit");
+        
+        }
+      },
+      xns : Roo,
+      '|xns' : 'Roo'
+     },
+     {
+      xtype : 'Button',
+      text : _this._strings['778551900655782c5c7827332b08cf3f'] /* Save and close */,
+      listeners : {
+       click : function() {
+        
+                _this.exit = true;
+                
+               _this.dialog.el.mask("Saving");
+               
+               if(!_this.form.findField('body').editorcore.sourceEditMode){
+                    _this.form.findField('body').syncValue();
+                    _this.form.findField('extended').syncValue();
+                }else{
+                    _this.form.findField('body').pushValue();
+                    _this.form.findField('extended').pushValue();
+                }
+                
+                if(_this.data.page_type_id_name != 'blog' && AppModules.indexOf("Crm") == -1){
+                    _this.interests.reset();
+                }
+                
+             _this.form.doAction("submit");
+        
+        }
+      },
+      xns : Roo,
+      '|xns' : 'Roo'
+     }
+    ],
+    items  : [
+     {
+      xtype : 'ContentPanel',
+      autoScroll : true,
+      fitToFrame : true,
+      region : 'center',
+      listeners : {
+       render : function (_self)
+        {
+          _this.cpanel = _self;
+        },
+       resize : function (_self, width, height)
+        {
+              Roo.log("RESIZE, " + width + ',' + height);
+            
+            var ew = Math.max(250, width-50);
+            var eh = Math.max(250,height-50) ;
+            if (!_this.form) {
+                return;
+                }
+            
+            var bd = _this.form.findField('body');
+            if (bd.resizeEl) { 
+                bd.width = ew;
+                bd.height = eh;
+                // since render delays resize.. 
+                Roo.log('resizing body to ' + bd.width);        
+               bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
+                _this.bodycol.el.setWidth(bd.width+20);
+            }
+            
+            
+            bd = _this.form.findField('extended');
+            if (bd.resizeEl) { 
+                bd.width = ew;
+                bd.height = eh;
+                
+                Roo.log('resizing extended to ' + bd.width);
+                // since render delays resize.. 
+               bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
+               _this.extendcol.el.setWidth(bd.width+20);
+            }
+            bd = _this.form.findField('extra_css');
+            if (bd) { 
+                bd.el.setWidth(ew);
+               _this.keywordscol.el.setWidth(ew+20);
+            }
+            // fix for messed up rendering of dialog?
+            _this.dialog.layout.el.dom.scrollTop = 0;
+        }
+      },
+      xns : Roo,
+      '|xns' : 'Roo',
+      toolbar : {
+       xtype : 'Toolbar',
+       xns : Roo,
+       '|xns' : 'Roo',
+       items  : [
+        {
+         xtype : 'Button',
+         text : _this._strings['d88aa1eee60ba140f07d5f81769cec74'] /* << Edit Translations */,
+         listeners : {
+          click : function (_self, e)
+           {
+               if (_this.trpanel.region.collapsed) {
+                   _this.trpanel.region.expand();
+               } else {
+                   _this.trpanel.region.collapse(); 
+               }
+               
+           }
+         },
+         xns : Roo.Toolbar,
+         '|xns' : 'Roo.Toolbar'
+        },
+        {
+         xtype : 'Fill',
+         xns : Roo.Toolbar,
+         '|xns' : 'Roo.Toolbar'
+        },
+        {
+         xtype : 'Button',
+         text : _this._strings['c02bd0c22c290ae599ee2f3ff2023fd3'] /* Manage Images / Attachments >> */,
+         listeners : {
+          click : function (_self, e)
+           {
+               if (_this.panel.region.collapsed) {
+                   _this.panel.region.expand();
+               } else {
+                   _this.panel.region.collapse();
+               }
+               
+           }
+         },
+         xns : Roo.Toolbar,
+         '|xns' : 'Roo.Toolbar'
+        }
+       ]
+      },
+      items  : [
+       {
+        xtype : 'Form',
+        labelAlign : 'right',
+        labelWidth : 120,
+        method : 'POST',
+        showHide : function()
+        {
+            var in_rss= 0;
+            var is_menu= 0;
+            var is_element  = 0;
+            var is_category = 0;
+            var page_type_name = _this.form.findField('page_type_id_name').getValue();
+            switch(page_type_name){
+                case 'page' :
+                    is_element = 0;
+                break;
+                
+                case 'element' :
+                    is_element = 1;
+                break;
+                
+                case 'blog' :
+                    in_rss = 1;
+                break;
+                
+                case 'menu' :
+                    is_menu = 1;
+                break;
+                
+                case 'category' :
+                    in_rss = 1;
+                    is_category = 1;
+                break;
+            }
+            
+            var is_system_page = _this.form.findField('is_system_page').getValue() * 1;
+            var is_attachment = _this.form.findField('is_attachment').getValue() * 1;
+            var has_extended = _this.form.findField('has_extended').getValue() * 1;
+            
+            var vis = {
+                is_attachment : !in_rss,
+                
+                category_type_id : in_rss && !is_menu,
+                 page_link : 1, //!in_rss, // always show page link.. may not be needed though..
+                target_url : is_menu,
+                
+                category_page_id : !is_category,
+                
+                parent_id : !in_rss || is_category ,
+                published : in_rss ,
+                
+                to_replace_id :false, // !in_rss, // is this used.
+                is_draft : !is_system_page,
+                author_id : in_rss && !is_menu  && !is_attachment,
+                
+                template_id : !is_attachment && !is_menu && !is_system_page,
+                element_id : is_element &&   !is_menu, 
+                menu_page_id : is_menu,
+         
+                has_extended : !is_menu && !is_attachment, // always shown.
+                extended : has_extended && !is_menu  && !is_attachment,
+                body : !is_attachment && !is_menu,
+                keywords : !is_attachment && !is_menu, 
+                descriptions : !is_attachment && !is_menu,
+                extra_css : !is_attachment && !is_menu
+            };
+        
+            for(var k in vis) {
+                var el = _this.form.findField(k);
+                if (!el) {
+                    Roo.log("missing field " + k);
+                    continue;
+                }
+                el.actionMode = 'fieldEl';
+                if (vis[k]) {
+                    el.show();
+                } else{
+                    el.hide();
+                }
+        
+            }
+            
+            
+            _this.trform.showHide();
+            
+            if(typeof(_this.form.editors) == 'undefined'){
+                _this.form.editors = {
+                    body : _this.form.findField('body').wrap.isVisible(),
+                    extended : _this.form.findField('extended').wrap.isVisible()
+               };
+               
+               if(_this.form.editors.body){
+                    setInterval(_this.form.findField('body').autosave, 60000);
+               }
+               
+               if(_this.form.editors.extended){
+                    setInterval(_this.form.findField('extended').autosave, 60000);
+               }
+           }
+           
+           if(!_this.form.editors.body && _this.form.findField('body').wrap.isVisible()){
+                setInterval(_this.form.findField('body').autosave, 60000);
+                _this.form.editors.body = true;
+           }
+           
+           if(!_this.form.editors.extended && _this.form.findField('extended').wrap.isVisible()){
+                setInterval(_this.form.findField('extended').autosave, 60000);
+                _this.form.editors.extended = true;
+           }
+            
+            
+            
+        },
+        style : 'margin: 5px',
+        url : baseURL + '/Roo/cms_page.php',
+        listeners : {
+         actioncomplete : function (_self, action)
+          {
+          
+             if (action.type == 'setdata') {
+          
+                  _this.dialog.setStylesheets();
+                  
+                  _this.trpanel.region.collapse(); 
+                  _this.panel.region.collapse();
+                  
+                  _this.trpanel.el.mask('Save first');
+                  _this.panel.el.mask('Save first');
+                  
+                  _this.loaded = false;
+                  _this.interestsCol.hide();
+                  
+                  _this.form.findField('category_page_id').fieldEl.select('label',true).first().dom.innerHTML = 'Category';
+                  
+                  if ( _this.data.id) {
+                      _this.dialog.el.mask("Loading");
+                      this.load({ method: 'GET', params: { '_id' : _this.data.id }});
+                  } else {
+          
+                      _this.loaded = true;
+                      var is_draft = typeof(_this.data.is_draft) != 'undefined' ? _this.data.is_draft : 1;
+                      this.findField('is_draft').setValue(is_draft);
+                      _this.page_type.setValue(_this.data.page_type_id);
+                      _this.page_type.el.dom.value = _this.data.page_type_id_display_name;
+                      
+                      if(_this.data.page_type_id_name == 'blog' && AppModules.indexOf("Crm") !== -1){
+                          _this.interestsCol.show();
+                      }
+                      /*
+                      var catlabel= _this.form.findField('category_page_id').fieldEl.select('label',true).first()
+                      catlabel.dom.innerHTML = 'Category';            
+                      if(_this.data.page_type_id_name == 'category'){
+                          catlabel.dom.innerHTML = 'Parent Category';
+                      } 
+                      */
+                      var catlabel= _this.form.findField('parent_id').fieldEl.select('label',true).first();
+                      catlabel.dom.innerHTML = 'Parent page';            
+                      if(_this.data.page_type_id_name == 'category'){
+                          catlabel.dom.innerHTML = 'Parent';
+                      }
+                  }
+                 return;
+              }
+              
+              if (action.type == 'load') {
+              
+                  //_this.data = action.result.data;
+                  
+                  var d = action.result.data;
+                  
+                  _this.dialog.el.unmask();
+                 _this.grid.getDataSource().load();
+                 _this.trform.reset();
+                 _this.form.findField('body').originalValue = _this.form.findField('body').getValue();
+                 _this.form.findField('extended').originalValue = _this.form.findField('extended').getValue();
+                 
+                 /*
+                  var catlabel= _this.form.findField('category_page_id').fieldEl.select('label',true).first()
+                  catlabel.dom.innerHTML = 'Category';            
+                  
+                  if(_this.data.page_type_id_name == 'category'){
+                      catlabel.dom.innerHTML = 'Parent Category';
+                  }
+                  */
+                  
+                  var catlabel= _this.form.findField('parent_id').fieldEl.select('label',true).first();
+                  catlabel.dom.innerHTML = 'Parent page';            
+                  if(_this.data.page_type_id_name == 'category'){
+                      catlabel.dom.innerHTML = 'Parent';
+                  }
+                  
+                  // better if this was not here... - not sure which project uses it?
+                  
+                  if(_this.data.page_type_id_name == 'blog' && AppModules.indexOf("Crm") !== -1){
+                      _this.interestsCol.show();
+                  }
+                  if(typeof(d['interests']) != 'undefined'){
+                      _this.form.findField('interest').setValue(Roo.decode(d['interests']));
+                  }
+                  
+                  _this.trpanel.el.unmask();
+                  _this.panel.el.unmask();
+                  
+                  // fix scrolling..
+                  _this.cpanel.el.dom.scrollTop = 0;
+                  
+                  // fix messed up scroll.
+                  _this.dialog.layout.el.dom.scrollTop = 0;
+                  return;
+              }
+              if (action.type =='submit') {
+                 
+                 _this.dialog.el.unmask();
+                 
+                 if(!_this.exit){
+                      this.load({ method: 'GET', params: { '_id' : action.result.data.id }});
+                      return;
+                 }
+                 
+                 _this.dialog.hide();
+                 
+          
+                  if (_this.callback) {
+                     _this.callback.call(_this, action.result.data);
+                  }
+                  _this.form.reset();
+                  return;
+              }
+          },
+         actionfailed : function (_self, action)
+          {
+              _this.dialog.el.unmask(); 
+              Pman.standardActionFailed(_self, action);
+          },
+         rendered : function (_self)
+          {
+              _this.form = _self;
+          }
+        },
+        xns : Roo.form,
+        '|xns' : 'Roo.form',
+        items  : [
+         {
+          xtype : 'Column',
+          labelWidth : 200,
+          width : 750,
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          items  : [
+           {
+            xtype : 'Row',
+            hideLabels : false,
+            labelAlign : 'right',
+            labelWidth : 200,
+            style : 'height:30px;overflow:hidden',
+            width : 850,
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            items  : [
+             {
+              xtype : 'Hidden',
+              fieldLabel : _this._strings['e659b52eba1f0299b2d8ca3483919e72'] /* Type: */,
+              width : 1,
+              xns : Roo.form,
+              '|xns' : 'Roo.form'
+             },
+             {
+              xtype : 'Row',
+              hideLabels : true,
+              labelWidth : 0,
+              style : 'height:30px;overflow:hidden',
+              width : 600,
+              xns : Roo.form,
+              '|xns' : 'Roo.form',
+              items  : [
+               {
+                xtype : 'ComboBox',
+                alwaysQuery : true,
+                displayField : 'display_name',
+                editable : false,
+                emptyText : _this._strings['779e2624ddf330fb05b51ae59faf212d'] /* Select Status Type */,
+                fieldLabel : _this._strings['6a5b847af3d97df722040debdbccfbed'] /* Page Type */,
+                forceSelection : true,
+                hiddenName : 'page_type_id',
+                listWidth : 400,
+                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+                minChars : 2,
+                name : 'page_type_id_display_name',
+                pageSize : 20,
+                qtip : _this._strings['20bec77364d863100a1f9325873a8504'] /* Select Page Type */,
+                selectOnFocus : true,
+                tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
+                triggerAction : 'all',
+                typeAhead : false,
+                valueField : 'id',
+                listeners : {
+                 render : function (_self)
+                  {
+                      _this.page_type = _self;
+                  },
+                 select : function (combo, record, index)
+                  {
+                  //    _this.grid.footer.onClick('first');
+                      var page_type_name = record.data.name;
+                      _this.form.findField('page_type_id_name').setValue(page_type_name);
+                      if(page_type_name == 'blog' || page_type_name == 'category'){ // blog || category unset attachment
+                          _this.form.findField('is_attachment').setValue(0);
+                          return;
+                      }
+                      if (_this.form) { 
+                          _this.form.showHide.defer(100, _this.form);      
+                      } 
+                      
+                  }
+                },
+                xns : Roo.form,
+                '|xns' : 'Roo.form',
+                store : {
+                 xtype : 'Store',
+                 remoteSort : true,
+                 sortInfo : { direction : 'ASC', field: 'seqid' },
+                 listeners : {
+                  beforeload : function (_self, o){
+                       o.params = o.params || {};
+                       // set more here
+                       o.params.etype = 'cms_page_type'; 
+                   }
+                 },
+                 xns : Roo.data,
+                 '|xns' : 'Roo.data',
+                 proxy : {
+                  xtype : 'HttpProxy',
+                  method : 'GET',
+                  url : baseURL + '/Roo/core_enum.php',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 },
+                 reader : {
+                  xtype : 'JsonReader',
+                  fields : [{"name":"id","type":"int"},{"name":"display_name","type":"string"}],
+                  id : 'id',
+                  root : 'data',
+                  totalProperty : 'total',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 }
+                }
+               },
+               {
+                xtype : 'Column',
+                labelWidth : 60,
+                style : 'padding-left:  -70px;',
+                width : 200,
+                xns : Roo.form,
+                '|xns' : 'Roo.form',
+                items  : [
+                 {
+                  xtype : 'NumberField',
+                  decimalPrecision : 0,
+                  fieldLabel : _this._strings['b28a711cf7e94ec793ef926633997529'] /* Seq */,
+                  name : 'seq_id',
+                  width : 50,
+                  xns : Roo.form,
+                  '|xns' : 'Roo.form'
+                 }
+                ]
+               }
+              ]
+             }
+            ]
+           },
+           {
+            xtype : 'Row',
+            hideLabels : false,
+            labelAlign : 'right',
+            labelWidth : 200,
+            style : 'height:30px;overflow:hidden',
+            width : 800,
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            items  : [
+             {
+              xtype : 'Hidden',
+              fieldLabel : _this._strings['77174410b72decfd0b259961f1f65a8f'] /* Attributes: */,
+              width : 1,
+              xns : Roo.form,
+              '|xns' : 'Roo.form'
+             },
+             {
+              xtype : 'Row',
+              hideLabels : true,
+              labelWidth : 0,
+              style : 'height:30px;overflow:hidden',
+              width : 540,
+              xns : Roo.form,
+              '|xns' : 'Roo.form',
+              items  : [
+               {
+                xtype : 'Checkbox',
+                boxLabel : 'Draft',
+                fieldLabel : _this._strings['287234a1ff35a314b5b6bc4e5828e745'] /* Attributes */,
+                name : 'is_draft',
+                width : 100,
+                xns : Roo.form,
+                '|xns' : 'Roo.form'
+               },
+               {
+                xtype : 'Checkbox',
+                boxLabel : 'Has Extended content?',
+                inputValue : 1,
+                name : 'has_extended',
+                width : 180,
+                listeners : {
+                 check : function (_self, checked)
+                  {  
+                     if (_this.form) {
+                  
+                         (function() { 
+                              _this.form.showHide();
+                              _this.panel.fireEvent('resize', _this.panel, [ _this.panel.el.getWidth(), _this.panel.el.getHeight() ]  );
+                              
+                         }).defer(100);
+                      }
+                  }
+                },
+                xns : Roo.form,
+                '|xns' : 'Roo.form'
+               },
+               {
+                xtype : 'Checkbox',
+                boxLabel : 'Downloads first Attachment',
+                inputValue : 1,
+                name : 'is_attachment',
+                width : 180,
+                listeners : {
+                 check : function (_self, checked)
+                  {  
+                     if (_this.form) { 
+                   
+                       _this.form.showHide.defer(100, _this.form);      
+                     }
+                  }
+                },
+                xns : Roo.form,
+                '|xns' : 'Roo.form'
+               }
+              ]
+             }
+            ]
+           },
+           {
+            xtype : 'ComboBox',
+            allowBlank : true,
+            displayField : 'name',
+            editable : true,
+            emptyText : _this._strings['340c2ee497b85d5954b01c64de7f44f6'] /* Select Person */,
+            fieldLabel : _this._strings['a517747c3d12f99244ae598910d979c5'] /* Author */,
+            forceSelection : true,
+            hiddenName : 'author_id',
+            listWidth : 400,
+            loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+            minChars : 2,
+            name : 'author_id_name',
+            pageSize : 40,
+            qtip : _this._strings['340c2ee497b85d5954b01c64de7f44f6'] /* Select Person */,
+            queryParam : 'query[name]',
+            selectOnFocus : true,
+            tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b>  - {company_id_name}</div>',
+            triggerAction : 'all',
+            typeAhead : false,
+            valueField : 'id',
+            width : 300,
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            store : {
+             xtype : 'Store',
+             remoteSort : true,
+             sortInfo : { direction : 'ASC', field: 'name' },
+             listeners : {
+              beforeload : function (_self, o){
+                   o.params = o.params || {};
+               
+                   o.params.active = 1;
+                   o.params['query[is_owner]'] = 1;
+               }
+             },
+             xns : Roo.data,
+             '|xns' : 'Roo.data',
+             proxy : {
+              xtype : 'HttpProxy',
+              method : 'GET',
+              url : baseURL + '/Roo/Person.php',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             },
+             reader : {
+              xtype : 'JsonReader',
+              fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}],
+              id : 'id',
+              root : 'data',
+              totalProperty : 'total',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             }
+            }
+           },
+           {
+            xtype : 'ComboBox',
+            allowBlank : true,
+            displayField : 'title',
+            editable : false,
+            emptyText : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category */,
+            fieldLabel : _this._strings['3adbdb3ac060038aa0e6e6c138ef9873'] /* Category */,
+            forceSelection : true,
+            hiddenName : 'category_page_id',
+            listWidth : 400,
+            loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+            minChars : 2,
+            name : 'category_page_id_title',
+            pageSize : 20,
+            qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category */,
+            queryParam : '',
+            selectOnFocus : true,
+            tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> </div>',
+            triggerAction : 'all',
+            typeAhead : true,
+            valueField : 'id',
+            width : 200,
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            store : {
+             xtype : 'Store',
+             sortInfo : { field: 'title', dir: 'ASC' },
+             listeners : {
+              beforeload : function (_self, o){
+                   o.params = o.params || {};
+                   o.params.page_type_id_name= 'CATEGORY';
+                   // set more here
+               }
+             },
+             xns : Roo.data,
+             '|xns' : 'Roo.data',
+             proxy : {
+              xtype : 'HttpProxy',
+              method : 'GET',
+              url : baseURL + '/Roo/cms_page.php',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             },
+             reader : {
+              xtype : 'JsonReader',
+              fields : [{"name":"id","type":"int"},{"name":"title","type":"string"}],
+              id : 'id',
+              root : 'data',
+              totalProperty : 'total',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             }
+            }
+           },
+           {
+            xtype : 'ComboBox',
+            allowBlank : true,
+            alwaysQuery : true,
+            displayField : 'page_link',
+            editable : true,
+            emptyText : _this._strings['95cb4f45ab7ff3984f25ab8668499020'] /* Select Parent */,
+            fieldLabel : _this._strings['70a4bc2672e2e3912e6476a2bd7ba29b'] /* Parent page */,
+            forceSelection : true,
+            hiddenName : 'parent_id',
+            listWidth : 600,
+            loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+            minChars : 2,
+            name : 'parent_id_title',
+            pageSize : 40,
+            qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
+            selectOnFocus : true,
+            tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
+            triggerAction : 'all',
+            typeAhead : true,
+            valueField : 'id',
+            width : 400,
+            listeners : {
+             select : function (combo, record, index)
+              {
+                 var page_type_name = _this.form.findField('page_type_id_name').getValue();
+                 if (page_type_name == 'page') { // page
+                      return;
+                 }
+                 // do not default to put 'Home' at the beginning.
+                 if (!(record.data.parent_id *1)) {
+                      return;
+                 }
+                 var pl = _this.form.findField('page_link');
+                 var lk = pl.getValue();
+                 var new_link = record.data.page_link + '/';
+                 if (lk.length) {
+                      new_link += lk.split('/').pop();
+                 }
+                 pl.setValue(new_link);
+                 
+              }
+            },
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            store : {
+             xtype : 'Store',
+             remoteSort : true,
+             sortInfo : { field: 'page_link', direction: 'ASC' },
+             listeners : {
+              beforeload : function (_self, options)
+               {
+                    options.params['search[page_link_no_empty]'] =1;
+                    
+                    options.params.page_type_id = _this.data.page_type_id;
+                    
+                    var id = _this.form.findField('id').getValue() * 1;
+                    
+                    if(id > 0){
+                       options.params['!id'] = id;
+                    }
+                    /*
+                    options.params.is_element = 0;
+                    var page_type_name = _this.page_type.findRecord() ? _this.page_type.findRecord().data.name: _this.firstPageType.name;
+                    options.params.is_menuitem = page_type_name == 'menu' ? 1 : 0;    
+                    */
+               }
+             },
+             xns : Roo.data,
+             '|xns' : 'Roo.data',
+             proxy : {
+              xtype : 'HttpProxy',
+              method : 'GET',
+              url : baseURL + '/Roo/cms_page.php',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             },
+             reader : {
+              xtype : 'JsonReader',
+              fields : [
+               { name: 'id', type: 'int' },
+               'title',
+               'page_link' 
+              ],
+              id : 'id',
+              root : 'data',
+              totalProperty : 'total',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             }
+            }
+           },
+           {
+            xtype : 'Row',
+            labelWidth : 200,
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            items  : [
+             {
+              xtype : 'DateField',
+              altFormats : 'Y-m-d H:i:s',
+              fieldLabel : _this._strings['69dd756ae9c23191a5bb9b61f0857432'] /* Date to Publish */,
+              format : 'Y-m-d',
+              name : 'published',
+              width : 200,
+              xns : Roo.form,
+              '|xns' : 'Roo.form'
+             },
+             {
+              xtype : 'TextField',
+              fieldLabel : _this._strings['fb3f11443065d5f4d8303ad913db9680'] /* Replaces (ignore) */,
+              name : 'to_replace_id',
+              width : 75,
+              xns : Roo.form,
+              '|xns' : 'Roo.form'
+             }
+            ]
+           },
+           {
+            xtype : 'TextField',
+            fieldLabel : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
+            name : 'title',
+            width : 400,
+            listeners : {
+             keyup : function (_self, e)
+              {
+                  if (_this.page_type.getRawValue() == 'Category') {
+                  
+                      _this.form.findField('page_link').setValue(this.getValue().replace(/[\s]/ig, '-').toLowerCase());
+                  
+                  }
+              }
+            },
+            xns : Roo.form,
+            '|xns' : 'Roo.form'
+           },
+           {
+            xtype : 'TextField',
+            fieldLabel : _this._strings['d52f80f80467bb575253a5a39ca016a7'] /* Page link /  Name / Order */,
+            name : 'page_link',
+            width : 400,
+            xns : Roo.form,
+            '|xns' : 'Roo.form'
+           },
+           {
+            xtype : 'TextField',
+            fieldLabel : _this._strings['e64df1d7c22b9638f084ce8a4aff3ff3'] /* Target URL */,
+            name : 'target_url',
+            width : 400,
+            xns : Roo.form,
+            '|xns' : 'Roo.form'
+           },
+           {
+            xtype : 'ComboBox',
+            allowBlank : true,
+            alwaysQuery : true,
+            displayField : 'template_clean',
+            editable : true,
+            emptyText : _this._strings['31bb2f6e9b8fb11cbb7fb63c6025223f'] /* Select Template */,
+            fieldLabel : _this._strings['ebd9bec4d70abc789d439c1f136b0538'] /* Layout */,
+            forceSelection : true,
+            hiddenName : 'template_id',
+            listWidth : 400,
+            loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+            minChars : 2,
+            name : 'template_id_template_clean',
+            pageSize : 20,
+            qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
+            selectOnFocus : true,
+            tpl : '<div class="x-grid-cell-text x-btn button"><b>{template_clean}</b></div>',
+            triggerAction : 'all',
+            typeAhead : true,
+            valueField : 'id',
+            width : 400,
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            store : {
+             xtype : 'Store',
+             remoteSort : true,
+             sortInfo : { field: 'template', direction: 'ASC' },
+             listeners : {
+              beforeload : function (_self, options)
+               {
+                
+                   options.params._rescan = 1;
+                  options.params._clean_name = 1;
+               //    options.params.lang = 'en';
+                   options.params['!template[0]'] = 'master.html';
+                   //options.params['!template[1]'] = 'index.html';
+               }
+             },
+             xns : Roo.data,
+             '|xns' : 'Roo.data',
+             proxy : {
+              xtype : 'HttpProxy',
+              method : 'GET',
+              url : baseURL + '/Roo/Cms_template',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             },
+             reader : {
+              xtype : 'JsonReader',
+              fields : [
+               { name: 'id', type: 'int' }, {name: 'template', type: 'string'}
+              ],
+              id : 'id',
+              root : 'data',
+              totalProperty : 'total',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             }
+            }
+           },
+           {
+            xtype : 'ComboBox',
+            allowBlank : true,
+            alwaysQuery : true,
+            displayField : 'name',
+            editable : true,
+            emptyText : _this._strings['b5216c9b4e0ac0afd9c76eb1d12ad1b9'] /* Select Section */,
+            fieldLabel : _this._strings['f3912172e6bf57f8979782f4a2342233'] /* Appears in Block */,
+            forceSelection : true,
+            hiddenName : 'element_id',
+            listWidth : 400,
+            loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+            minChars : 2,
+            name : 'element_id_name',
+            pageSize : 20,
+            qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
+            selectOnFocus : true,
+            tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b></div>',
+            triggerAction : 'all',
+            typeAhead : true,
+            valueField : 'id',
+            width : 400,
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            store : {
+             xtype : 'Store',
+             remoteSort : true,
+             sortInfo : { field: 'name', direction: 'ASC' },
+             listeners : {
+              beforeload : function (_self, options)
+               {
+                   var par = _this.form.findField('parent_id').getValue() * 1;
+                   if (!par) {
+                       Roo.MessageBox.alert("Error", "Select on what parent page it appears");
+                       return false;
+                   }
+                   
+                   options.params._cms_page_id = par;
+               }
+             },
+             xns : Roo.data,
+             '|xns' : 'Roo.data',
+             proxy : {
+              xtype : 'HttpProxy',
+              method : 'GET',
+              url : baseURL + '/Roo/Cms_template_element',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             },
+             reader : {
+              xtype : 'JsonReader',
+              fields : [
+               { name: 'id', type: 'int' }, {name: 'template', type: 'string'}
+              ],
+              id : 'id',
+              root : 'data',
+              totalProperty : 'total',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             }
+            }
+           },
+           {
+            xtype : 'ComboBox',
+            allowBlank : true,
+            alwaysQuery : true,
+            displayField : 'page_link',
+            editable : true,
+            emptyText : _this._strings['99e7707748ae048e17c5810fad119e0b'] /* Select Page */,
+            fieldLabel : _this._strings['8adedb6a6226807ba810215dd3b3c61b'] /* Menu links to Page */,
+            forceSelection : true,
+            hiddenName : 'menu_page_id',
+            listWidth : 600,
+            loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+            minChars : 2,
+            name : 'menu_page_id_page_link',
+            pageSize : 40,
+            qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
+            selectOnFocus : true,
+            tpl : '<div class=\"x-grid-cell-text x-btn button\"><span style=\"color:#1b809e\">[{page_type_id_display_name}] </span><b>{title} </b><i>{page_link}</i></div>',
+            triggerAction : 'all',
+            typeAhead : true,
+            valueField : 'id',
+            width : 400,
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            store : {
+             xtype : 'Store',
+             remoteSort : true,
+             sortInfo : { field: 'title', direction: 'ASC' },
+             listeners : {
+              beforeload : function (_self, options)
+               {
+                   options.params = options.params || {};
+                   
+                   options.params['search[page_link_no_empty]'] =1;
+                    
+                   options.params['page_type_id_name[0]'] = 'page';
+                   options.params['page_type_id_name[1]'] = 'blog';
+                    /*
+                    options.params.is_element = 0;
+                    options.params.is_menuitem = 0;     
+                    */
+               }
+             },
+             xns : Roo.data,
+             '|xns' : 'Roo.data',
+             proxy : {
+              xtype : 'HttpProxy',
+              method : 'GET',
+              url : baseURL + '/Roo/cms_page.php',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             },
+             reader : {
+              xtype : 'JsonReader',
+              fields : [
+                  {
+                      "name":"id",
+                      "type":"int"
+                  },
+                  {
+                      "name":"title",
+                      "type":"string"
+                  },
+                  {
+                      "name":"page_link",
+                      "type":"string"
+                  },
+                  {
+                      "name":"page_type_id_display_name",
+                      "type":"string"
+                  }
+              ],
+              id : 'id',
+              root : 'data',
+              totalProperty : 'total',
+              xns : Roo.data,
+              '|xns' : 'Roo.data'
+             }
+            }
+           }
+          ]
+         },
+         {
+          xtype : 'Column',
+          labelAlign : 'top',
+          width : 900,
+          listeners : {
+           render : function (_self)
+            {
+              _this.bodycol = _self;
+            }
+          },
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          items  : [
+           {
+            xtype : 'HtmlEditor',
+            autosave : function() {
+                
+                var body = _this.form.findField('body');
+                
+                if(!body.wrap.isVisible(true) || body.getValue() == '' || !body.isDirty()){
+                    Roo.log('body not dirty');
+                    return;
+                }
+                
+                Roo.log('body dirty, auto save!');
+                
+                body.fireEvent('autosave', body);
+                    
+               
+            },
+            fieldLabel : _this._strings['c1df1da7a1ce305a3b60af9d5733ac1d'] /* Contents */,
+            height : 140,
+            name : 'body',
+            resizable : 's',
+            white : [ 'iframe' ],
+            width : 550,
+            listeners : {
+             autosave : function (_self)
+              {
+                  Roo.log('autosave');
+                  
+                  var id = _this.form.findField('id').getValue() * 1;
+                  /*
+                  if(!_self.editorcore.sourceEditMode){
+                      _self.syncValue();
+                  }else{
+                      _self.pushValue();
+                  }
+                  */
+                  new Pman.Request({
+                      url : baseURL + '/Roo/Events.php',
+                      method :'POST',
+                      params : {
+                          id : 0,
+                          action : 'AUTOSAVE',
+                          on_id : (id > 0) ? id : 0,
+                          on_table : 'cms_page',
+                          remarks : 'BODY',
+                          source: _self.getValue()
+                      },
+                      success : function() {
+                          _self.originalValue = _self.getValue();
+                          
+                      },
+                      failure : function() 
+                      {
+                          //Roo.MessageBox.alert("Error", "autosave failed");
+                          Roo.log('body autosave failed?!');
+                      }
+                  });
+                  
+              },
+             savedpreview : function (_self)
+              {
+                  Roo.log('saved preview');
+                  
+                  var id = _this.form.findField('id').getValue() * 1;
+                  
+                  var successFn = function(res){
+                      return res.data.POST.source;
+                  };
+                  
+                  var params = {
+                      action : 'AUTOSAVE',
+                      remarks : 'BODY',
+                      on_id : (id < 1) ? 0 : id,
+                      on_table : 'cms_page',
+                      successFn : successFn
+                  };
+                  
+                  
+                  Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
+                      _self.setValue(res);
+                      _self.originalValue = res;
+                  });
+              },
+             stylesheetsclick : function (_self)
+              {
+                  Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
+                      _this.dialog.setStylesheets();
+                  })
+                  
+              }
+            },
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            toolbars : [
+             {
+              xtype : 'ToolbarStandard',
+              xns : Roo.form.HtmlEditor,
+              '|xns' : 'Roo.form.HtmlEditor',
+              btns : [
+               {
+                xtype : 'ComboBox',
+                alwaysQuery : true,
+                displayField : 'name',
+                editable : false,
+                emptyText : _this._strings['b9c49611cfda3259a2b837b39489e650'] /* Add Image */,
+                fieldLabel : _this._strings['fff0d600f8a0b5e19e88bfb821dd1157'] /* Images */,
+                forceSelection : true,
+                listWidth : 400,
+                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+                minChars : 2,
+                pageSize : 20,
+                qtip : _this._strings['2f26e35d61be90501e099089dc533638'] /* Select Images */,
+                queryParam : 'search',
+                selectOnFocus : true,
+                tpl : '<div class="x-grid-cell-text x-btn button"><img src="' + baseURL + '/Images/Thumb/150x150/{id}.jpg" height="150" width="150"><b>{filename}</b> </div>',
+                triggerAction : 'all',
+                typeAhead : true,
+                valueField : 'id',
+                width : 100,
+                listeners : {
+                 beforequery : function (combo, query, forceAll, cancel, e)
+                  {
+                   
+                      var id = _this.form.findField('id').getValue() * 1;    
+                      if (!id) {
+                          Roo.MessageBox.alert("Error", "Save Document First before adding images");
+                          return false;
+                      }
+                  },
+                 render : function (_self)
+                  {
+                      _this.bodyimgselect = _self;
+                  },
+                 select : function (combo, record, index)
+                  {
+                      Roo.log(record);
+                      (function() { 
+                          combo.setValue('');
+                      }).defer(100);
+                      
+                      var editor = _this.form.findField('body').editorcore;
+                      
+                      var curnode = editor.getSelectedNode();
+                      
+                      if (curnode && curnode.tagName == 'IMG') {
+                          curnode.src= String.format('{0}/Images/{1}/{2}#attachment-{1}',
+                                  baseURL,  record.data.id, record.data.filename
+                              );
+                              // note -forces an update... hopefully...
+                          editor.owner.fireEvent('editorevent', editor, false);
+                      } else {
+                      
+                          editor.insertAtCursor(
+                              String.format('<img src="{0}/Images/{1}/{2}#attachment-{1}">',
+                              baseURL,  record.data.id, record.data.filename
+                              )
+                          );
+                  
+                      }
+                      
+                  }
+                },
+                xns : Roo.form,
+                '|xns' : 'Roo.form',
+                store : {
+                 xtype : 'Store',
+                 remoteSort : true,
+                 sortInfo : { direction : 'ASC', field: 'id' },
+                 listeners : {
+                  beforeload : function (_self, o){
+                       o.params = o.params || {};
+                   
+                       var id = _this.form.findField('id').getValue() * 1;    
+                       if (!id) {
+                           Roo.MessageBox.alert("Error", "Save press release first");
+                           return false;
+                       }
+                       o.params.onid = id;
+                       o.params.ontable = 'cms_page';
+                      // o.params.imgtype = 'PressRelease';
+                       //o.params['query[imagesize]'] = '150x150';
+                       // set more here
+                   }
+                 },
+                 xns : Roo.data,
+                 '|xns' : 'Roo.data',
+                 proxy : {
+                  xtype : 'HttpProxy',
+                  method : 'GET',
+                  url : baseURL + '/Roo/Images.php',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 },
+                 reader : {
+                  xtype : 'JsonReader',
+                  fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}],
+                  id : 'id',
+                  root : 'data',
+                  totalProperty : 'total',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 }
+                }
+               },
+               {
+                xtype : 'ComboBox',
+                allowBlank : true,
+                displayField : 'page_link',
+                editable : true,
+                emptyText : _this._strings['580b21aac58f1b73cece26e272cdfbee'] /* Add Link */,
+                forceSelection : true,
+                hiddenName : 'add_link_id',
+                listWidth : 200,
+                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+                minChars : 2,
+                name : 'add_link',
+                pageSize : 40,
+                qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
+                selectOnFocus : true,
+                tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
+                triggerAction : 'all',
+                typeAhead : true,
+                valueField : 'id',
+                width : 100,
+                listeners : {
+                 select : function (combo, record, index)
+                  {
+                      Roo.log(record);
+                      (function() { 
+                          combo.setValue('');
+                      }).defer(100);
+                      var editor = _this.form.findField('body');
+                      editor.editorcore.insertAtCursor(
+                              String.format('<a href="#page-{0}">{1}</a>',
+                              record.data.page_link,  record.data.title
+                              )
+                       );
+                  
+                      
+                   }
+                },
+                xns : Roo.form,
+                '|xns' : 'Roo.form',
+                store : {
+                 xtype : 'Store',
+                 remoteSort : true,
+                 sortInfo : { field: 'page_link', direction: 'ASC' },
+                 listeners : {
+                  beforeload : function (_self, options)
+                   {
+                        options.params['search[page_link_no_empty]'] =1;
+                        /*
+                        options.params.is_element = 0;
+                        options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     
+                        */
+                   }
+                 },
+                 xns : Roo.data,
+                 '|xns' : 'Roo.data',
+                 proxy : {
+                  xtype : 'HttpProxy',
+                  method : 'GET',
+                  url : baseURL + '/Roo/cms_page.php',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 },
+                 reader : {
+                  xtype : 'JsonReader',
+                  fields : [
+                   { name: 'id', type: 'int' },
+                   'title',
+                   'page_link' 
+                  ],
+                  id : 'id',
+                  root : 'data',
+                  totalProperty : 'total',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 }
+                }
+               },
+               {
+                xtype : 'Separator',
+                xns : Roo.Toolbar,
+                '|xns' : 'Roo.Toolbar'
+               },
+               {
+                xtype : 'Button',
+                cls : 'x-init-enable',
+                text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      this.scope.owner.fireEvent('savedpreview', this.scope.owner);
+                  }
+                },
+                xns : Roo.Toolbar,
+                '|xns' : 'Roo.Toolbar'
+               }
+              ]
+             },
+             {
+              xtype : 'ToolbarContext',
+              xns : Roo.form.HtmlEditor,
+              '|xns' : 'Roo.form.HtmlEditor'
+             }
+            ]
+           }
+          ]
+         },
+         {
+          xtype : 'Column',
+          labelAlign : 'top',
+          width : 900,
+          listeners : {
+           render : function (_self)
+            {
+              _this.extendcol = _self;
+            }
+          },
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          items  : [
+           {
+            xtype : 'HtmlEditor',
+            autosave : function() {
+                
+                var extended = _this.form.findField('extended');
+                
+                if(!extended.wrap.isVisible(true) || extended.getValue() == '' || !extended.isDirty()){
+                    Roo.log('extend not dirty');
+                    return;
+                }
+            
+                
+                Roo.log('extend dirty, auto save!');
+                
+                extended.fireEvent('autosave', extended);
+            },
+            fieldLabel : _this._strings['57e195426892c5515935f21d97228814'] /* Extended Contents */,
+            height : 160,
+            name : 'extended',
+            resizable : 's',
+            white : [ 'iframe' ],
+            width : 550,
+            listeners : {
+             autosave : function (_self)
+              {
+                  var id = _this.form.findField('id').getValue() * 1;
+                  
+                  /*
+                  if(!_self.editorcore.sourceEditMode){
+                      _self.syncValue();
+                  }else{
+                      _self.pushValue();
+                  }
+                  */
+                  new Pman.Request({
+                      url : baseURL + '/Roo/Events.php',
+                      method :'POST',
+                      params : {
+                          id : 0,
+                          action : 'AUTOSAVE',
+                          on_id : (id > 0) ? id : 0,
+                          on_table : 'cms_page',
+                          remarks : 'EXTENDED',
+                          source: _self.getValue()
+                      },
+                      success : function() {
+                          _self.originalValue = _self.getValue();
+                          
+                      },
+                      failure : function() 
+                      {
+                          //Roo.MessageBox.alert("Error", "autosave failed");
+                          Roo.log('extended autosave failed?!');
+                      }
+                  });
+              },
+             savedpreview : function (_self)
+              {
+                  var id = _this.form.findField('id').getValue() * 1;
+                  
+                  var successFn = function(res){
+                      return res.data.POST.source;
+                  };
+                  
+                  var params = {
+                      action : 'AUTOSAVE',
+                      remarks : 'EXTENDED',
+                      on_id : (id < 1) ? 0 : id,
+                      on_table : 'cms_page',
+                      successFn : successFn
+                  };
+                  
+                  
+                  Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
+                      _self.setValue(res);
+                      _self.originalValue = res;
+                  });
+              },
+             stylesheetsclick : function (_self)
+              {
+                  Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
+                      _this.dialog.setStylesheets();
+                  })
+                  
+              }
+            },
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            toolbars : [
+             {
+              xtype : 'ToolbarStandard',
+              xns : Roo.form.HtmlEditor,
+              '|xns' : 'Roo.form.HtmlEditor',
+              btns : [
+               {
+                xtype : 'ComboBox',
+                alwaysQuery : true,
+                displayField : 'name',
+                editable : false,
+                emptyText : _this._strings['b9c49611cfda3259a2b837b39489e650'] /* Add Image */,
+                fieldLabel : _this._strings['fff0d600f8a0b5e19e88bfb821dd1157'] /* Images */,
+                forceSelection : true,
+                listWidth : 400,
+                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+                minChars : 2,
+                pageSize : 20,
+                qtip : _this._strings['2f26e35d61be90501e099089dc533638'] /* Select Images */,
+                selectOnFocus : true,
+                tpl : '<div class=\"x-grid-cell-text x-btn button\"><img src=\"{url_thumb}\" height=\"150\" width=\"150\"><b>{filename}</b> </div>',
+                triggerAction : 'all',
+                typeAhead : true,
+                valueField : 'id',
+                width : 100,
+                listeners : {
+                 beforequery : function (combo, query, forceAll, cancel, e)
+                  {
+                   
+                      var id = _this.form.findField('id').getValue() * 1;    
+                      if (!id) {
+                          Roo.MessageBox.alert("Error", "Save Document First before adding images");
+                          return false;
+                      }
+                  },
+                 render : function (_self)
+                  {
+                      _this.extendimgselect = _self;
+                  },
+                 select : function (combo, record, index)
+                  {
+                      Roo.log(record);
+                      (function() { 
+                          combo.setValue('');
+                      }).defer(100);
+                      
+                      var editor = _this.form.findField('extended').editorcore;
+                      
+                      var curnode = editor.getSelectedNode();
+                      
+                      if (curnode && curnode.tagName == 'IMG') {
+                          curnode.src= String.format('{0}/Images/{1}/{2}#image-{1}',
+                                  baseURL,  record.data.id, record.data.filename
+                              );
+                              // note -forces an update... hopefully...
+                          editor.owner.fireEvent('editorevent', editor, false);
+                      } else {
+                      
+                          editor.insertAtCursor(
+                              String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
+                              baseURL,  record.data.id, record.data.filename
+                              )
+                          );
+                  
+                      }
+                      
+                  }
+                },
+                xns : Roo.form,
+                '|xns' : 'Roo.form',
+                store : {
+                 xtype : 'Store',
+                 remoteSort : true,
+                 sortInfo : { direction : 'ASC', field: 'id' },
+                 listeners : {
+                  beforeload : function (_self, o){
+                       o.params = o.params || {};
+                   
+                       var id = _this.form.findField('id').getValue() * 1;    
+                       if (!id) {
+                           Roo.MessageBox.alert("Error", "Save press release first");
+                           return false;
+                       }
+                       o.params.onid = id;
+                       o.params.ontable = 'cms_page';
+                      // o.params.imgtype = 'PressRelease';
+                       //o.params['query[imagesize]'] = '150x150';
+                       // set more here
+                   }
+                 },
+                 xns : Roo.data,
+                 '|xns' : 'Roo.data',
+                 proxy : {
+                  xtype : 'HttpProxy',
+                  method : 'GET',
+                  url : baseURL + '/Roo/Images.php',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 },
+                 reader : {
+                  xtype : 'JsonReader',
+                  fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}],
+                  id : 'id',
+                  root : 'data',
+                  totalProperty : 'total',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 }
+                }
+               },
+               {
+                xtype : 'ComboBox',
+                allowBlank : true,
+                displayField : 'page_link',
+                editable : true,
+                emptyText : _this._strings['580b21aac58f1b73cece26e272cdfbee'] /* Add Link */,
+                forceSelection : true,
+                hiddenName : 'add_link_id',
+                listWidth : 200,
+                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+                minChars : 2,
+                name : 'add_link',
+                pageSize : 40,
+                qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
+                selectOnFocus : true,
+                tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
+                triggerAction : 'all',
+                typeAhead : true,
+                valueField : 'id',
+                width : 100,
+                listeners : {
+                 select : function (combo, record, index)
+                  {
+                      Roo.log(record);
+                      (function() { 
+                          combo.setValue('');
+                      }).defer(100);
+                      var editor = _this.form.findField('body');
+                      editor.editorcore.insertAtCursor(
+                              String.format('<a href="#page-{0}">{1}</a>',
+                              record.data.page_link,  record.data.title
+                              )
+                       );
+                  
+                      
+                   }
+                },
+                xns : Roo.form,
+                '|xns' : 'Roo.form',
+                store : {
+                 xtype : 'Store',
+                 remoteSort : true,
+                 sortInfo : { field: 'page_link', direction: 'ASC' },
+                 listeners : {
+                  beforeload : function (_self, options)
+                   {
+                        options.params['search[page_link_no_empty]'] =1;
+                        /*
+                        options.params.is_element = 0;
+                        options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     
+                        */
+                   }
+                 },
+                 xns : Roo.data,
+                 '|xns' : 'Roo.data',
+                 proxy : {
+                  xtype : 'HttpProxy',
+                  method : 'GET',
+                  url : baseURL + '/Roo/cms_page.php',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 },
+                 reader : {
+                  xtype : 'JsonReader',
+                  fields : [
+                   { name: 'id', type: 'int' },
+                   'title',
+                   'page_link' 
+                  ],
+                  id : 'id',
+                  root : 'data',
+                  totalProperty : 'total',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 }
+                }
+               },
+               {
+                xtype : 'Separator',
+                xns : Roo.Toolbar,
+                '|xns' : 'Roo.Toolbar'
+               },
+               {
+                xtype : 'Button',
+                text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      this.scope.owner.fireEvent('savedpreview', this.scope.owner);
+                  }
+                },
+                xns : Roo.Toolbar,
+                '|xns' : 'Roo.Toolbar'
+               }
+              ]
+             },
+             {
+              xtype : 'ToolbarContext',
+              styles : typeof(uiConfig) != 'undefined' ? (uiConfig['Roo.form.HtmlEditor.ToolbarContext.styles'] || {}) : {},
+              xns : Roo.form.HtmlEditor,
+              '|xns' : 'Roo.form.HtmlEditor'
+             }
+            ]
+           }
+          ]
+         },
+         {
+          xtype : 'Column',
+          labelAlign : 'top',
+          width : 950,
+          listeners : {
+           render : function (_self)
+            {
+              _this.keywordscol = _self;
+            }
+          },
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          items  : [
+           {
+            xtype : 'Row',
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            items  : [
+             {
+              xtype : 'TextArea',
+              fieldLabel : _this._strings['867343577fa1f33caa632a19543bd252'] /* Keywords */,
+              height : 150,
+              name : 'keywords',
+              width : 350,
+              xns : Roo.form,
+              '|xns' : 'Roo.form'
+             },
+             {
+              xtype : 'TextArea',
+              fieldLabel : _this._strings['8bc84316c4078bf66723fd019616d920'] /* Descriptions */,
+              height : 150,
+              name : 'descriptions',
+              width : 350,
+              xns : Roo.form,
+              '|xns' : 'Roo.form'
+             }
+            ]
+           },
+           {
+            xtype : 'Row',
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            items  : [
+             {
+              xtype : 'TextArea',
+              fieldLabel : _this._strings['39f64cc9436cacfbceda3b7bdeb8e24c'] /* Styles (CSS) */,
+              height : 150,
+              name : 'extra_css',
+              width : 700,
+              xns : Roo.form,
+              '|xns' : 'Roo.form'
+             }
+            ]
+           }
+          ]
+         },
+         {
+          xtype : 'Column',
+          labelAlign : 'top',
+          listeners : {
+           render : function (_self)
+            {
+                _this.interestsCol = _self;
+            }
+          },
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          items  : [
+           {
+            xtype : 'ComboBoxArray',
+            fieldLabel : _this._strings['c70952e4ab3806c049737cd7d2b8896b'] /* Interests */,
+            hiddenName : 'interest',
+            name : 'interest_name',
+            width : 300,
+            listeners : {
+             render : function (_self)
+              {
+                  _this.interests = _self;
+                  /*
+                  _self.combo.addicon.setStyle( {
+                      position : 'absolute',
+                      right: '9px',
+                      top : '2px',
+                      float : 'left'
+                  });
+                  */
+              }
+            },
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            combo : {
+             xtype : 'ComboBox',
+             allowBlank : true,
+             alwaysQuery : true,
+             displayField : 'display_name',
+             editable : true,
+             emptyText : _this._strings['30d1a216420426fcbd43ca70acd4aa48'] /* Select interests */,
+             fieldLabel : _this._strings['c70952e4ab3806c049737cd7d2b8896b'] /* Interests */,
+             forceSelection : true,
+             listWidth : 400,
+             minChars : 2,
+             queryParam : 'query[name]',
+             selectOnFocus : true,
+             tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
+             triggerAction : 'all',
+             valueField : 'id',
+             width : 285,
+             xns : Roo.form,
+             '|xns' : 'Roo.form',
+             store : {
+              xtype : 'Store',
+              remoteSort : true,
+              sortInfo : { direction : 'ASC', field: 'name' },
+              listeners : {
+               beforeload : function (_self, o){
+                    o.params = o.params || {};
+                    o.params.etype = 'crm_interest';
+                }
+              },
+              xns : Roo.data,
+              '|xns' : 'Roo.data',
+              proxy : {
+               xtype : 'HttpProxy',
+               method : 'GET',
+               url : baseURL + '/Roo/Core_enum.php',
+               xns : Roo.data,
+               '|xns' : 'Roo.data'
+              },
+              reader : {
+               xtype : 'JsonReader',
+               fields : [
+                   {"name":"id","type":"int"},
+                   {"name":"name","type":"string"},
+                   {"name":"display_name","type":"string"}
+               ],
+               id : 'id',
+               root : 'data',
+               totalProperty : 'total',
+               xns : Roo.data,
+               '|xns' : 'Roo.data'
+              }
+             }
+            }
+           }
+          ]
+         },
+         {
+          xtype : 'Hidden',
+          name : 'id',
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         },
+         {
+          xtype : 'Hidden',
+          name : 'is_system_page',
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         },
+         {
+          xtype : 'Hidden',
+          name : 'is_menuitem',
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         },
+         {
+          xtype : 'Hidden',
+          name : 'page_type_id_name',
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         },
+         {
+          xtype : 'Column',
+          listeners : {
+           render : function (_self)
+            {
+                _this.user_defined_fields = _self;
+            }
+          },
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         }
+        ]
+       }
+      ]
+     },
+     {
+      xtype : 'GridPanel',
+      background : false,
+      fitContainer : true,
+      fitToframe : true,
+      region : 'east',
+      tableName : 'Images',
+      title : _this._strings['308f2757bfc9ce92fb00ff93fdffd279'] /* Images / Attachments */,
+      listeners : {
+       activate : function() {
+            _this.panel = this;
+            if (_this.grid) {
+                _this.grid.footer.onClick('first');
+            }
+        }
+      },
+      xns : Roo,
+      '|xns' : 'Roo',
+      grid : {
+       xtype : 'EditorGrid',
+       autoExpandColumn : 'title',
+       clicksToEdit : 1,
+       loadMask : true,
+       listeners : {
+        render : function() { 
+             _this.grid = this; 
+             //_this.dialog = Pman.Dialog.FILL_IN
+             if (_this.panel.active) {
+                //this.footer.onClick('first');
+             }
+         },
+        rowdblclick : function (_self, rowIndex, e)
+         {
+             var rd = _this.grid.getDataSource().getAt(rowIndex);
+             var id = rd.data.id;
+             var url = String.format('{0}/Images/{1}/{2}', baseURL, rd.data.id, rd.data.filename);
+             _this.form.findField('contents').execCmd('insertimage', url);
+         
+         }
+       },
+       xns : Roo.grid,
+       '|xns' : 'Roo.grid',
+       toolbar : {
+        xtype : 'Toolbar',
+        xns : Roo,
+        '|xns' : 'Roo',
+        items  : [
+         {
+          xtype : 'Button',
+          cls : 'x-btn-text-icon',
+          icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
+          text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
+          listeners : {
+           click : function()
+            {
+                var id = _this.form.findField('id').getValue() * 1;
+                
+                if(id < 1){
+                    return;
+                }
+                
+                Pman.Dialog.Image.show( { id : 0, onid : id, ontable: 'cms_page' }, function() {
+                    Roo.log('load?????');
+                    _this.grid.ds.load({});
+                }); 
+            
+            }
+          },
+          xns : Roo,
+          '|xns' : 'Roo'
+         },
+         {
+          xtype : 'Button',
+          cls : 'x-btn-text-icon',
+          icon : rootURL + '/Pman/templates/images/trash.gif',
+          text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
+          listeners : {
+           click : function()
+            {
+                var selection = _this.grid.getSelectionModel().getSelectedCell();
+                var sn = _this.grid.ds.getAt(selection[0]);
+                if (!sn || isNaN(sn.id *1)) {
+                    Roo.MessageBox.alert("Error", "Select a image"); 
+                    return;
+                }
+                Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
+                    if (v != 'yes') {
+                        return;
+                    }
+                    
+                    new Pman.Request({
+                        url : baseURL + '/Roo/Images.php',
+                        method: 'POST',
+                        params : {
+                            _delete : sn.id
+                        },
+                        success : function()
+                        {
+                            Roo.log('Got Success!!');
+                           _this.grid.ds.load({});
+                        }
+                    });
+                });
+            }
+          },
+          xns : Roo,
+          '|xns' : 'Roo'
+         }
+        ]
+       },
+       dataSource : {
+        xtype : 'Store',
+        listeners : {
+         beforeload : function (_self, o)
+          {
+              var id = _this.form.findField('id').getValue() * 1;
+          
+              if (id < 1) {
+                  this.removeAll();
+                  return false;
+              } 
+              o.params = o.params || {};    
+              o.params.limit = 9999;          
+              o.params.onid = id;
+              o.params.ontable = 'cms_page';
+          },
+         update : function (_self, rec, operation)
+          {
+              
+              new Pman.Request({
+                  url : baseURL+'/Roo/Images.php',
+                  method : 'POST',
+                  params : rec.data,
+                  success: function(res)
+                  {
+                      Roo.log("GOT success");
+                      // update the data...
+                      _this.grid.ds.load({});
+                  },
+                  failure : function(res)
+                  {
+                      
+                  }
+                  
+                  
+              });
+          }
+        },
+        xns : Roo.data,
+        '|xns' : 'Roo.data',
+        proxy : {
+         xtype : 'HttpProxy',
+         method : 'GET',
+         url : baseURL + '/Roo/Images.php',
+         xns : Roo.data,
+         '|xns' : 'Roo.data'
+        },
+        reader : {
+         xtype : 'JsonReader',
+         fields : [
+             {
+                 'name': 'id',
+                 'type': 'int'
+             },
+             {
+                 'name': 'filename',
+                 'type': 'string'
+             },
+             {
+                 'name': 'ontable',
+                 'type': 'string'
+             },
+             {
+                 'name': 'onid',
+                 'type': 'int'
+             },
+             {
+                 'name': 'mimetype',
+                 'type': 'string'
+             },
+             {
+                 'name': 'width',
+                 'type': 'int'
+             },
+             {
+                 'name': 'height',
+                 'type': 'int'
+             },
+             {
+                 'name': 'filesize',
+                 'type': 'int'
+             },
+             {
+                 'name': 'displayorder',
+                 'type': 'int'
+             },
+             {
+                 'name': 'language',
+                 'type': 'string'
+             },
+             {
+                 'name': 'parent_image_id',
+                 'type': 'int'
+             },
+             {
+                 'name': 'created',
+                 'type': 'date',
+                 'dateFormat': 'Y-m-d'
+             },
+             {
+                 'name': 'imgtype',
+                 'type': 'string'
+             },
+             {
+                 'name': 'linkurl',
+                 'type': 'string'
+             },
+             {
+                 'name': 'descript',
+                 'type': 'string'
+             },
+             {
+                 'name': 'title',
+                 'type': 'string'
+             },
+             {
+                 'name': 'parent_image_id_id',
+                 'type': 'int'
+             },
+             {
+                 'name': 'parent_image_id_filename',
+                 'type': 'string'
+             },
+             {
+                 'name': 'parent_image_id_ontable',
+                 'type': 'string'
+             },
+             {
+                 'name': 'parent_image_id_onid',
+                 'type': 'int'
+             },
+             {
+                 'name': 'parent_image_id_mimetype',
+                 'type': 'string'
+             },
+             {
+                 'name': 'parent_image_id_width',
+                 'type': 'int'
+             },
+             {
+                 'name': 'parent_image_id_height',
+                 'type': 'int'
+             },
+             {
+                 'name': 'parent_image_id_filesize',
+                 'type': 'int'
+             },
+             {
+                 'name': 'parent_image_id_displayorder',
+                 'type': 'int'
+             },
+             {
+                 'name': 'parent_image_id_language',
+                 'type': 'string'
+             },
+             {
+                 'name': 'parent_image_id_parent_image_id',
+                 'type': 'int'
+             },
+             {
+                 'name': 'parent_image_id_created',
+                 'type': 'date'
+             },
+             {
+                 'name': 'parent_image_id_imgtype',
+                 'type': 'string'
+             },
+             {
+                 'name': 'parent_image_id_linkurl',
+                 'type': 'string'
+             },
+             {
+                 'name': 'parent_image_id_descript',
+                 'type': 'string'
+             },
+             {
+                 'name': 'parent_image_id_title',
+                 'type': 'string'
+             }
+         ],
+         id : 'id',
+         root : 'data',
+         totalProperty : 'total',
+         xns : Roo.data,
+         '|xns' : 'Roo.data'
+        }
+       },
+       colModel : [
+        {
+         xtype : 'ColumnModel',
+         dataIndex : 'id',
+         header : _this._strings['d41d8cd98f00b204e9800998ecf8427e'] /*  */,
+         renderer : function(v,x,r) { 
+             return  String.format('<img src="{0}/Images/Thumb/100/{1}/{2}" height="100">', baseURL, v, r.data.filename); 
+         },
+         sortable : false,
+         width : 75,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid'
+        },
+        {
+         xtype : 'ColumnModel',
+         dataIndex : 'filename',
+         header : _this._strings['1351017ac6423911223bc19a8cb7c653'] /* Filename */,
+         renderer : function(v) { return String.format('{0}', v); },
+         width : 100,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid'
+        },
+        {
+         xtype : 'ColumnModel',
+         dataIndex : 'displayorder',
+         header : _this._strings['a240fa27925a635b08dc28c9e4f9216d'] /* Order */,
+         renderer : function(v) { return String.format('{0}', v); },
+         width : 50,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         editor : {
+          xtype : 'GridEditor',
+          xns : Roo.grid,
+          '|xns' : 'Roo.grid',
+          field : {
+           xtype : 'NumberField',
+           decimalPrecision : 0,
+           listeners : {
+            focus : function (_self)
+             {
+                 if (this.value == 0) {
+                     this.el.dom.value = '';
+                 }
+             }
+           },
+           xns : Roo.form,
+           '|xns' : 'Roo.form'
+          }
+         }
+        },
+        {
+         xtype : 'ColumnModel',
+         dataIndex : 'title',
+         header : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
+         renderer : function(v) { return String.format('{0}', v); },
+         width : 100,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         editor : {
+          xtype : 'GridEditor',
+          xns : Roo.grid,
+          '|xns' : 'Roo.grid',
+          field : {
+           xtype : 'TextField',
+           xns : Roo.form,
+           '|xns' : 'Roo.form'
+          }
+         }
+        },
+        {
+         xtype : 'ColumnModel',
+         dataIndex : 'linkurl',
+         header : _this._strings['e6b391a8d2c4d45902a23a8b6585703d'] /* URL */,
+         renderer : function(v)
+         {
+             return String.format('{0}', (v) ? v : '');
+         },
+         width : 300,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid',
+         editor : {
+          xtype : 'GridEditor',
+          xns : Roo.grid,
+          '|xns' : 'Roo.grid',
+          field : {
+           xtype : 'TextField',
+           xns : Roo.form,
+           '|xns' : 'Roo.form'
+          }
+         }
+        }
+       ]
+      }
+     },
+     {
+      xtype : 'ContentPanel',
+      autoScroll : true,
+      fitToFrame : true,
+      region : 'west',
+      listeners : {
+       render : function (_self)
+        {
+          _this.trpanel = _self;
+        },
+       resize : function (_self, width, height)
+        {
+            Roo.log('resize called');
+            var ew = Math.max(250, width-50);
+            var eh = Math.max(250,height-50) ;
+            if (!_this.trform) {
+                return;
+                }
+                _this.trform.showHide();
+           
+            var bd = _this.trform.findField('body');
+            if (bd.resizeEl) { 
+                bd.width = ew;
+                bd.height = eh;
+                // since render delays resize.. 
+                bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
+                _this.trbodycol.el.setWidth(bd.width+20);
+            }
+            var bd = _this.trform.findField('extended');
+            if (bd.resizeEl) { 
+                bd.width = ew;
+                bd.height = eh;
+                // since render delays resize.. 
+                bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
+                _this.trextendcol.el.setWidth(bd.width+20);
+            }
+        
+        }
+      },
+      xns : Roo,
+      '|xns' : 'Roo',
+      items  : [
+       {
+        xtype : 'Form',
+        labelAlign : 'right',
+        labelWidth : 120,
+        method : 'POST',
+        showHide : function() {
+        
+          //  var in_rss= _this.form.findField('in_rss').getValue() * 1;
+            var has_extended = _this.form.findField('has_extended').getValue() * 1;
+            var has_lang = _this.trform.findField('language').getValue().length;
+            
+            var vis = {
+                //category_id : in_rss,
+                //page_link : !in_rss, // blogs which have perm links?
+                //is_element : !in_rss,        
+                //parent_id : !in_rss,
+                //published : in_rss,
+                //to_replace_id : !in_rss, // is this used.
+                //has_extended : true, // always shown.
+                extended : has_lang && has_extended,
+                body : has_lang,
+                title : has_lang,
+                descriptions : has_lang,
+                keywords : has_lang
+                //author_id : in_rss
+                
+            };
+            for(var k in vis) {
+                var el = _this.trform.findField(k);
+                el.actionMode = 'fieldEl';
+                if (    vis[k]) {
+                    Roo.log("show: " + k);
+                    el.show();
+                } else{ 
+                    Roo.log("hide: " + k);
+                    el.hide();
+                }
+        
+            }
+        
+            _this.updateRow.el[has_lang ? 'show' : 'hide']();
+            // we should now trigger the panel resize event..
+           
+            
+            if(typeof(_this.trform.editors) == 'undefined'){
+                _this.trform.editors = {
+                    body : _this.trform.findField('body').wrap.isVisible(),
+                    extended : _this.trform.findField('extended').wrap.isVisible()
+               };
+               if(_this.trform.editors.body){
+                    setInterval(_this.trform.findField('body').autosave, 60000);
+               }
+               
+               if(_this.trform.editors.extended){
+                    setInterval(_this.trform.findField('extended').autosave, 60000);
+               }
+           }
+           
+           if(!_this.trform.editors.body && _this.trform.findField('body').wrap.isVisible()){
+                setInterval(_this.trform.findField('body').autosave, 60000);
+                _this.trform.editors.body = true;
+           }
+           
+           if(!_this.trform.editors.extended && _this.trform.findField('extended').wrap.isVisible()){
+                setInterval(_this.trform.findField('extended').autosave, 60000);
+                _this.trform.editors.extended = true;
+           }
+            
+            
+            
+            
+        },
+        style : 'margin: 5px',
+        url : baseURL + '/Roo/cms_page.php',
+        listeners : {
+         actioncomplete : function (_self, action)
+          {
+          
+             if (action.type =='submit') {
+                 //   _this.dialog.el.mask("Saving");
+                  return;
+              }
+              
+              if (action.type == 'setdata') {    
+                    
+                    if ( _this.data.id) {
+                         // _this.dialog.el.mask("Loading");
+                          this.load({ method: 'GET', params: { '_id' : _this.data.id }});
+                     } else {
+                          
+                          //_this.loaded = true;
+                           this.trpanel.el.mask("save first");
+                    }
+          
+                 return;
+                
+              }
+              
+              if (action.type == 'load') {
+          //        _this.dialog.el.unmask();
+                  this.showHide();
+                  
+                  _this.trform.findField('body').originalValue = _this.trform.findField('body').getValue();
+                 _this.trform.findField('extended').originalValue = _this.trform.findField('extended').getValue();
+            
+                  return;
+              }
+          },
+         actionfailed : function (_self, action)
+          {
+              _this.dialog.el.unmask();
+           
+              Pman.standardActionFailed(_self, action);
+          },
+         rendered : function (_self)
+          {
+              _this.trform = _self;
+          }
+        },
+        xns : Roo.form,
+        '|xns' : 'Roo.form',
+        items  : [
+         {
+          xtype : 'Column',
+          labelAlign : 'top',
+          width : 400,
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          items  : [
+           {
+            xtype : 'Row',
+            labelAlign : 'top',
+            width : 400,
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            items  : [
+             {
+              xtype : 'ComboBox',
+              alwaysQuery : true,
+              displayField : 'language_name',
+              editable : false,
+              emptyText : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
+              fieldLabel : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
+              forceSelection : true,
+              hiddenName : 'language',
+              listWidth : 400,
+              loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+              minChars : 2,
+              name : 'language_name',
+              pageSize : 20,
+              qtip : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
+              selectOnFocus : true,
+              tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{language_name}</b> </div>',
+              triggerAction : 'all',
+              typeAhead : false,
+              valueField : 'language',
+              listeners : {
+               add : function (combo)
+                {
+                    Pman.Dialog.CmsLanguagePick.show({_with_name : true}, function( res) {
+                       // Roo.log(res);
+                        combo.setValue(res.lang);
+                        combo.el.dom.value = res.lang_name;
+                        (function() { 
+                            _this.trform.showHide();
+                           _this.trpanel.fireEvent('resize', _this.trpanel, [ _this.trpanel.el.getWidth(), _this.trpanel.el.getHeight() ]  );
+                       }).defer(100); 
+                    });
+                    
+                },
+               render : function (_self)
+                {
+                    _this.language = _self;
+                },
+               select : function (combo, record, index)
+                {
+                    (function() { 
+                        _this.trform.showHide();
+                       _this.trpanel.fireEvent('resize', _this.trpanel, [ _this.trpanel.el.getWidth(), _this.trpanel.el.getHeight() ]  );
+                   }).defer(100); 
+                    
+                    
+                   _this.trform.load({
+                    
+                        method: 'GET', 
+                        params: {
+                            'lookup[language]' : record.data.language,
+                            'lookup[translation_of_id]' : _this.data.id,
+                            'lookup[_id]' : 1
+                        }
+                   });
+                }
+              },
+              xns : Roo.form,
+              '|xns' : 'Roo.form',
+              store : {
+               xtype : 'Store',
+               remoteSort : true,
+               sortInfo : { direction : 'ASC', field: 'language' },
+               listeners : {
+                beforeload : function (_self, o){
+                     o.params = o.params || {};
+                     
+                     o.params._distinct = 'language';
+                     o.params._columns ='language_name,language';
+                     o.params._with_name = true;
+                     
+                     if(_this.form.findField('id').getValue()*1 > 0){
+                         o.params.translation_of_id = _this.form.findField('id').getValue();
+                     }
+                     
+                 }
+               },
+               xns : Roo.data,
+               '|xns' : 'Roo.data',
+               proxy : {
+                xtype : 'HttpProxy',
+                method : 'GET',
+                url : baseURL + '/Roo/Cms_page.php',
+                xns : Roo.data,
+                '|xns' : 'Roo.data'
+               },
+               reader : {
+                xtype : 'JsonReader',
+                fields : [{"name":"language","type":"string"}],
+                id : 'id',
+                root : 'data',
+                totalProperty : 'total',
+                xns : Roo.data,
+                '|xns' : 'Roo.data'
+               }
+              }
+             },
+             {
+              xtype : 'Row',
+              style : 'padding-top:12px;padding-left:30px;float:left',
+              width : 100,
+              listeners : {
+               render : function (_self)
+                {
+                _this.updateRow = _self;
+                }
+              },
+              xns : Roo.form,
+              '|xns' : 'Roo.form',
+              items  : [
+               {
+                xtype : 'Button',
+                text : _this._strings['06933067aafd48425d67bcb01bba5cb6'] /* Update */,
+                listeners : {
+                 click : function()
+                   {
+                      //   _this.dialog.el.mask("Saving");
+                      if(!_this.trform.findField('body').editorcore.sourceEditMode){
+                          _this.trform.findField('body').syncValue(); 
+                          _this.trform.findField('extended').syncValue();
+                      }else{
+                          _this.trform.findField('body').pushValue();
+                          _this.trform.findField('extended').pushValue();
+                      }
+                      
+                      _this.trform.findField('parent_id').setValue(_this.form.findField('parent_id').getValue());
+                      _this.trform.findField('element_id').setValue(_this.form.findField('element_id').getValue());
+                      _this.trform.findField('translation_of_id').setValue(_this.form.findField('id').getValue());
+                      _this.trform.findField('is_menuitem').setValue(_this.form.findField('is_menuitem').getValue());
+                      _this.trform.findField('menu_page_id').setValue(_this.form.findField('menu_page_id').getValue());
+                      
+                      if(_this.trform.findField('element_id').getValue()*1 > 0){
+                          _this.trform.findField('is_element').setValue(1);
+                      }
+                      
+                      _this.trform.doAction("submit");
+                  }
+                },
+                xns : Roo,
+                '|xns' : 'Roo'
+               }
+              ]
+             }
+            ]
+           },
+           {
+            xtype : 'TextField',
+            fieldLabel : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
+            name : 'title',
+            width : 400,
+            xns : Roo.form,
+            '|xns' : 'Roo.form'
+           }
+          ]
+         },
+         {
+          xtype : 'Column',
+          labelAlign : 'top',
+          width : 1000,
+          listeners : {
+           render : function (_self)
+            {
+              _this.trbodycol = _self;
+            }
+          },
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          items  : [
+           {
+            xtype : 'HtmlEditor',
+            autosave : function() {
+                
+                var body = _this.trform.findField('body');
+                
+                if(!body.wrap.isVisible(true) || body.getValue() == '' || !body.isDirty()){
+                    Roo.log('tr body not dirty');
+                    return;
+                }
+            
+                Roo.log('tr body dirty, auto save!');
+                
+                body.fireEvent('autosave', body);
+            },
+            fieldLabel : _this._strings['c1df1da7a1ce305a3b60af9d5733ac1d'] /* Contents */,
+            height : 140,
+            name : 'body',
+            resizable : 's',
+            white : [ 'iframe' ],
+            listeners : {
+             autosave : function (_self)
+              {
+                  var id = _this.trform.findField('id').getValue() * 1;
+                  
+                  /*
+                  if(!_self.editorcore.sourceEditMode){
+                      _self.syncValue();
+                  }else{
+                      _self.pushValue();
+                  }
+                  */
+                  new Pman.Request({
+                      url : baseURL + '/Roo/Events.php',
+                      method :'POST',
+                      params : {
+                          id : 0,
+                          action : 'AUTOSAVE',
+                          on_id : (id > 0) ? id : 0,
+                          on_table : 'cms_page',
+                          remarks : 'BODY',
+                          source: _self.getValue()
+                      },
+                      success : function() {
+                          _self.originalValue = _self.getValue();
+                          
+                      },
+                      failure : function() 
+                      {
+                          //Roo.MessageBox.alert("Error", "autosave failed");
+                          Roo.log('tr body autosave failed?!');
+                      }
+                  });
+              },
+             savedpreview : function (_self)
+              {
+                  var id = _this.trform.findField('id').getValue() * 1;
+                  
+                  var successFn = function(res){
+                      return res.data.POST.source;
+                  };
+                  
+                  var params = {
+                      action : 'AUTOSAVE',
+                      remarks : 'BODY',
+                      on_id : (id < 1) ? 0 : id,
+                      on_table : 'cms_page',
+                      successFn : successFn
+                  };
+                  
+                  
+                  Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
+                      _self.setValue(res);
+                      _self.originalValue = res;
+                  });
+              },
+             stylesheetsclick : function (_self)
+              {
+                  Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
+                      _this.dialog.setStylesheets();
+                  })
+                  
+              }
+            },
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            toolbars : [
+             {
+              xtype : 'ToolbarStandard',
+              xns : Roo.form.HtmlEditor,
+              '|xns' : 'Roo.form.HtmlEditor',
+              btns : [
+               {
+                xtype : 'ComboBox',
+                alwaysQuery : true,
+                displayField : 'name',
+                editable : false,
+                emptyText : _this._strings['b9c49611cfda3259a2b837b39489e650'] /* Add Image */,
+                fieldLabel : _this._strings['fff0d600f8a0b5e19e88bfb821dd1157'] /* Images */,
+                forceSelection : true,
+                listWidth : 400,
+                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+                minChars : 2,
+                pageSize : 20,
+                qtip : _this._strings['2f26e35d61be90501e099089dc533638'] /* Select Images */,
+                selectOnFocus : true,
+                tpl : '<div class="x-grid-cell-text x-btn button"><img src="' + baseURL + '/Images/Thumb/150x150/{id}.jpg" height="150" width="150"><b>{filename}</b> </div>',
+                triggerAction : 'all',
+                typeAhead : true,
+                valueField : 'id',
+                width : 100,
+                listeners : {
+                 beforequery : function (combo, query, forceAll, cancel, e)
+                  {
+                   
+                      var id = _this.form.findField('id').getValue() * 1;    
+                      if (!id) {
+                          Roo.MessageBox.alert("Error", "Save press release first");
+                          return false;
+                      }
+                  },
+                 render : function (_self)
+                  {
+                      _this.trbodyimgselect = _self;
+                  },
+                 select : function (combo, record, index)
+                  {
+                      Roo.log(record);
+                      (function() { 
+                          combo.setValue('');
+                      }).defer(100);
+                      
+                      var editor = _this.trform.findField('body').editorcore;
+                      
+                      var curnode = editor.getSelectedNode();
+                      
+                      if (curnode && curnode.tagName == 'IMG') {
+                          curnode.src= String.format('{0}/Images/{1}/{2}#attachment-{1}',
+                                  baseURL,  record.data.id, record.data.filename
+                              );
+                              // note -forces an update... hopefully...
+                          editor.owner.fireEvent('editorevent', editor, false);
+                      } else {
+                      
+                          editor.insertAtCursor(
+                              String.format('<img src="{0}/Images/{1}/{2}#attachment-{1}">',
+                              baseURL,  record.data.id, record.data.filename
+                              )
+                          );
+                  
+                      }
+                      
+                  }
+                },
+                xns : Roo.form,
+                '|xns' : 'Roo.form',
+                store : {
+                 xtype : 'Store',
+                 remoteSort : true,
+                 sortInfo : { direction : 'ASC', field: 'id' },
+                 listeners : {
+                  beforeload : function (_self, o){
+                       o.params = o.params || {};
+                   
+                       var id = _this.form.findField('id').getValue() * 1;    
+                       if (!id) {
+                           Roo.MessageBox.alert("Error", "Save press release first");
+                           return false;
+                       }
+                       o.params.onid = id;
+                       o.params.ontable = 'cms_page';
+                      // o.params.imgtype = 'PressRelease';
+                       //o.params['query[imagesize]'] = '150x150';
+                       // set more here
+                   }
+                 },
+                 xns : Roo.data,
+                 '|xns' : 'Roo.data',
+                 proxy : {
+                  xtype : 'HttpProxy',
+                  method : 'GET',
+                  url : baseURL + '/Roo/Images.php',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 },
+                 reader : {
+                  xtype : 'JsonReader',
+                  fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}],
+                  id : 'id',
+                  root : 'data',
+                  totalProperty : 'total',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 }
+                }
+               },
+               {
+                xtype : 'ComboBox',
+                allowBlank : true,
+                displayField : 'page_link',
+                editable : true,
+                emptyText : _this._strings['580b21aac58f1b73cece26e272cdfbee'] /* Add Link */,
+                forceSelection : true,
+                hiddenName : 'add_link_id',
+                listWidth : 200,
+                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
+                minChars : 2,
+                name : 'add_link',
+                pageSize : 40,
+                qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
+                selectOnFocus : true,
+                tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
+                triggerAction : 'all',
+                typeAhead : true,
+                valueField : 'id',
+                width : 100,
+                listeners : {
+                 select : function (combo, record, index)
+                  {
+                    //  Roo.log(record);
+                      (function() { 
+                          combo.setValue('');
+                      }).defer(100);
+                      var editor = _this.form.findField('body');
+                      editor.insertAtCursor(
+                              String.format('<a href="#page-{0}">{1}</a>',
+                              record.data.page_link,  record.data.title
+                              )
+                       );
+                  
+                      
+                   }
+                },
+                xns : Roo.form,
+                '|xns' : 'Roo.form',
+                store : {
+                 xtype : 'Store',
+                 remoteSort : true,
+                 sortInfo : { field: 'page_link', direction: 'ASC' },
+                 listeners : {
+                  beforeload : function (_self, options)
+                   {
+                        options.params['search[page_link_no_empty]'] =1; 
+                        /*
+                        options.params.is_element = 0;
+                        options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     
+                        */
+                   }
+                 },
+                 xns : Roo.data,
+                 '|xns' : 'Roo.data',
+                 proxy : {
+                  xtype : 'HttpProxy',
+                  method : 'GET',
+                  url : baseURL + '/Roo/cms_page.php',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 },
+                 reader : {
+                  xtype : 'JsonReader',
+                  fields : [
+                   { name: 'id', type: 'int' },
+                   'title',
+                   'page_link' 
+                  ],
+                  id : 'id',
+                  root : 'data',
+                  totalProperty : 'total',
+                  xns : Roo.data,
+                  '|xns' : 'Roo.data'
+                 }
+                }
+               },
+               {
+                xtype : 'Separator',
+                xns : Roo.Toolbar,
+                '|xns' : 'Roo.Toolbar'
+               },
+               {
+                xtype : 'Button',
+                text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      this.scope.owner.fireEvent('savedpreview', this.scope.owner);
+                  }
+                },
+                xns : Roo.Toolbar,
+                '|xns' : 'Roo.Toolbar'
+               }
+              ]
+             },
+             {
+              xtype : 'ToolbarContext',
+              xns : Roo.form.HtmlEditor,
+              '|xns' : 'Roo.form.HtmlEditor'
+             }
+            ]
+           }
+          ]
+         },
+         {
+          xtype : 'Column',
+          labelAlign : 'top',
+          listeners : {
+           render : function (_self)
+            {
+              _this.trextendcol = _self;
+            }
+          },
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          items  : [
+           {
+            xtype : 'HtmlEditor',
+            autosave : function() {
+                
+                var extended = _this.trform.findField('extended');
+                
+                if(!extended.wrap.isVisible(true) || extended.getValue() == '' || !extended.isDirty()){
+                    Roo.log('tr extend not dirty');
+                    return;
+                }
+            
+                
+                Roo.log('tr extend dirty, auto save!');
+                
+                extended.fireEvent('autosave', extended);
+                    
+               
+            },
+            fieldLabel : _this._strings['57e195426892c5515935f21d97228814'] /* Extended Contents */,
+            height : 140,
+            name : 'extended',
+            resizable : 's',
+            white : [ 'iframe' ],
+            listeners : {
+             autosave : function (_self)
+              {
+                  var id = _this.trform.findField('id').getValue() * 1;
+                  
+                  /*
+                  if(!_self.editorcore.sourceEditMode){
+                      _self.syncValue();
+                  }else{
+                      _self.pushValue();
+                  }
+                  */
+                  
+                  new Pman.Request({
+                      url : baseURL + '/Roo/Events.php',
+                      method :'POST',
+                      params : {
+                          id : 0,
+                          action : 'AUTOSAVE',
+                          on_id : (id > 0) ? id : 0,
+                          on_table : 'cms_page',
+                          remarks : 'EXTENDED',
+                          source: _self.getValue()
+                      },
+                      success : function() {
+                          _self.originalValue = _self.getValue();
+                          
+                      },
+                      failure : function() 
+                      {
+                          //Roo.MessageBox.alert("Error", "autosave failed");
+                          Roo.log('tr extended autosave failed?!');
+                      }
+                  });
+              },
+             savedpreview : function (_self)
+              {
+                  var id = _this.trform.findField('id').getValue() * 1;
+                  
+                  var successFn = function(res){
+                      return res.data.POST.source;
+                  };
+                  
+                  var params = {
+                      action : 'AUTOSAVE',
+                      remarks : 'EXTENDED',
+                      on_id : (id < 1) ? 0 : id,
+                      on_table : 'cms_page',
+                      successFn : successFn
+                  };
+                  
+                  
+                  Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
+                      _self.setValue(res);
+                      _self.originalValue = res;
+                  });
+              },
+             stylesheetsclick : function (_self)
+              {
+                  Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
+                      _this.dialog.setStylesheets();
+                  })
+                  
+              }
+            },
+            xns : Roo.form,
+            '|xns' : 'Roo.form',
+            toolbars : [
+             {
+              xtype : 'ToolbarStandard',
+              xns : Roo.form.HtmlEditor,
+              '|xns' : 'Roo.form.HtmlEditor',
+              btns : [
+               {
+                xtype : 'Separator',
+                xns : Roo.Toolbar,
+                '|xns' : 'Roo.Toolbar'
+               },
+               {
+                xtype : 'Button',
+                text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      this.scope.owner.fireEvent('savedpreview', this.scope.owner);
+                  }
+                },
+                xns : Roo.Toolbar,
+                '|xns' : 'Roo.Toolbar'
+               }
+              ]
+             },
+             {
+              xtype : 'ToolbarContext',
+              styles : typeof(uiConfig) != 'undefined' ? (uiConfig['Roo.form.HtmlEditor.ToolbarContext.styles'] || {}) : {},
+              xns : Roo.form.HtmlEditor,
+              '|xns' : 'Roo.form.HtmlEditor'
+             }
+            ]
+           }
+          ]
+         },
+         {
+          xtype : 'Column',
+          labelAlign : 'top',
+          listeners : {
+           render : function (_self)
+            {
+              _this.trkeywordscol = _self;
+            }
+          },
+          xns : Roo.form,
+          '|xns' : 'Roo.form',
+          items  : [
+           {
+            xtype : 'TextArea',
+            fieldLabel : _this._strings['867343577fa1f33caa632a19543bd252'] /* Keywords */,
+            height : 150,
+            name : 'keywords',
+            width : 450,
+            xns : Roo.form,
+            '|xns' : 'Roo.form'
+           },
+           {
+            xtype : 'TextArea',
+            fieldLabel : _this._strings['8bc84316c4078bf66723fd019616d920'] /* Descriptions */,
+            height : 150,
+            name : 'descriptions',
+            width : 450,
+            xns : Roo.form,
+            '|xns' : 'Roo.form'
+           }
+          ]
+         },
+         {
+          xtype : 'Hidden',
+          name : 'id',
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         },
+         {
+          xtype : 'Hidden',
+          name : 'element_id',
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         },
+         {
+          xtype : 'Hidden',
+          name : 'menu_page_id',
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         },
+         {
+          xtype : 'Hidden',
+          name : 'is_menuitem',
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         },
+         {
+          xtype : 'Hidden',
+          name : 'is_element',
+          value : 0,
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         },
+         {
+          xtype : 'Hidden',
+          name : 'translation_of_id',
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         },
+         {
+          xtype : 'Hidden',
+          name : 'parent_id',
+          xns : Roo.form,
+          '|xns' : 'Roo.form'
+         }
+        ]
+       }
+      ]
+     }
+    ]
+   });
+ }
+};