Pman.Dialog.CmsBlog.bjs
[Pman.Cms] / Pman.Dialog.CmsBlog.js
1 //<script type="text/javascript">
2
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
4
5 Roo.namespace('Pman.Dialog');
6
7 Pman.Dialog.CmsBlog = {
8
9  _strings : {
10   '2f26e35d61be90501e099089dc533638' :"Select Images",
11   'f3912172e6bf57f8979782f4a2342233' :"Appears in Block",
12   '95cb4f45ab7ff3984f25ab8668499020' :"Select Parent",
13   'c1df1da7a1ce305a3b60af9d5733ac1d' :"Contents",
14   'f2a6c498fb90ee345d997f888fce3b18' :"Delete",
15   'ebd9bec4d70abc789d439c1f136b0538' :"Layout",
16   '20bec77364d863100a1f9325873a8504' :"Select Page Type",
17   'a517747c3d12f99244ae598910d979c5' :"Author",
18   '31fde7b05ac8952dacf4af8a704074ec' :"Preview",
19   '779e2624ddf330fb05b51ae59faf212d' :"Select Status Type",
20   '5834d26e96dbae06029496e5b111dca2' :"Has Extended content?",
21   '6a5b847af3d97df722040debdbccfbed' :"Page Type",
22   '30d1a216420426fcbd43ca70acd4aa48' :"Select interests",
23   'f03ab16cd58372c77ba45a3d9a5a1cb9' :"Draft",
24   'cc6892c9705afcfa61c53698756ba51b' :"Page Class",
25   'e6b391a8d2c4d45902a23a8b6585703d' :"URL",
26   '03368e3c1eb4d2a9048775874301b19f' :"Select category",
27   'ec211f7c20af43e742bf2570c3cb84f9' :"Add",
28   '778551900655782c5c7827332b08cf3f' :"Save and close",
29   '77174410b72decfd0b259961f1f65a8f' :"Attributes:",
30   'b28a711cf7e94ec793ef926633997529' :"Seq",
31   '1243daf593fa297e07ab03bf06d925af' :"Searching...",
32   '8a53accfc94c2500b00575ce0e0d786f' :"Primary Image",
33   '580b21aac58f1b73cece26e272cdfbee' :"Add Link",
34   '8bc84316c4078bf66723fd019616d920' :"Descriptions",
35   '83dad8107f9459efe2b4fabcf5b63108' :"Select Language",
36   '76729937a5eb6b0fd88c42581161facd' :"Select Category ",
37   '0b8d92bc19b720bb1065649535463409' :"Translations",
38   '14c21301c0faf9d5561b8a580be21a13' :"Select class",
39   'd41d8cd98f00b204e9800998ecf8427e' :"",
40   '867343577fa1f33caa632a19543bd252' :"Keywords",
41   '340c2ee497b85d5954b01c64de7f44f6' :"Select Person",
42   '69dd756ae9c23191a5bb9b61f0857432' :"Date to Publish",
43   '3adbdb3ac060038aa0e6e6c138ef9873' :"Category",
44   '57e195426892c5515935f21d97228814' :"Extended Contents",
45   'd88aa1eee60ba140f07d5f81769cec74' :"<< Edit Translations",
46   'b9c49611cfda3259a2b837b39489e650' :"Add Image",
47   'ea4788705e6873b424c65e91c2846b19' :"Cancel",
48   'cfcd208495d565ef66e7dff9f98764da' :"0",
49   'd8e4d1f5e445107e505b2cf63a1fb65c' :"Extra CSS",
50   'bd88a20b53a47f7b5704a83a15ff5506' :"Saved Version",
51   '31bb2f6e9b8fb11cbb7fb63c6025223f' :"Select Template",
52   'c02bd0c22c290ae599ee2f3ff2023fd3' :"Manage Images / Attachments >>",
53   'b78a3223503896721cca1303f776159b' :"Title",
54   '39f64cc9436cacfbceda3b7bdeb8e24c' :"Styles (CSS)",
55   'e64df1d7c22b9638f084ce8a4aff3ff3' :"Target URL",
56   '98e93e8f7adfe14832db6caed713d849' :"Meta Tags",
57   'a240fa27925a635b08dc28c9e4f9216d' :"Order",
58   '287234a1ff35a314b5b6bc4e5828e745' :"Attributes",
59   '99e7707748ae048e17c5810fad119e0b' :"Select Page",
60   '06933067aafd48425d67bcb01bba5cb6' :"Update",
61   '8adedb6a6226807ba810215dd3b3c61b' :"Menu links to Page",
62   'b5216c9b4e0ac0afd9c76eb1d12ad1b9' :"Select Section",
63   '2ad41a2ff4f0dac97d63aff331d5e6e7' :"Downloads first Attachment",
64   '308f2757bfc9ce92fb00ff93fdffd279' :"Images / Attachments",
65   '76eb64a1725ee953c664e15c9213b2fd' :"Extended Content",
66   '1351017ac6423911223bc19a8cb7c653' :"Filename",
67   'c9cc8cce247e49bae79f15173ce97354' :"Save",
68   'e659b52eba1f0299b2d8ca3483919e72' :"Type:",
69   'c70952e4ab3806c049737cd7d2b8896b' :"Interests",
70   'aa6356b678bc4fc78253c9edf65bff03' :"Edit Page / Blog Entry",
71   'd52f80f80467bb575253a5a39ca016a7' :"Page link /  Name / Order",
72   'fff0d600f8a0b5e19e88bfb821dd1157' :"Images",
73   '30269022e9d8f51beaabb52e5d0de2b7' :"Parent",
74   'fb3f11443065d5f4d8303ad913db9680' :"Replaces (ignore)"
75  },
76  _named_strings : {
77   'seq_id_fieldLabel' : 'b28a711cf7e94ec793ef926633997529' /* Seq */ ,
78   'to_replace_id_fieldLabel' : 'fb3f11443065d5f4d8303ad913db9680' /* Replaces (ignore) */ ,
79   'template_id_template_clean_fieldLabel' : 'ebd9bec4d70abc789d439c1f136b0538' /* Layout */ ,
80   'page_cls_name_fieldLabel' : 'cc6892c9705afcfa61c53698756ba51b' /* Page Class */ ,
81   'language_name_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
82   'template_id_template_clean_qtip' : '76729937a5eb6b0fd88c42581161facd' /* Select Category  */ ,
83   'author_id_name_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
84   'page_type_id_display_name_fieldLabel' : '6a5b847af3d97df722040debdbccfbed' /* Page Type */ ,
85   'has_extended_boxLabel' : '5834d26e96dbae06029496e5b111dca2' /* Has Extended content? */ ,
86   'language_name_emptyText' : '83dad8107f9459efe2b4fabcf5b63108' /* Select Language */ ,
87   'author_id_name_qtip' : '340c2ee497b85d5954b01c64de7f44f6' /* Select Person */ ,
88   'menu_page_id_page_link_qtip' : '76729937a5eb6b0fd88c42581161facd' /* Select Category  */ ,
89   'published_fieldLabel' : '69dd756ae9c23191a5bb9b61f0857432' /* Date to Publish */ ,
90   'author_id_name_fieldLabel' : 'a517747c3d12f99244ae598910d979c5' /* Author */ ,
91   'element_id_name_qtip' : '76729937a5eb6b0fd88c42581161facd' /* Select Category  */ ,
92   'parent_id_title_qtip' : '76729937a5eb6b0fd88c42581161facd' /* Select Category  */ ,
93   'element_id_name_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
94   'author_id_name_emptyText' : '340c2ee497b85d5954b01c64de7f44f6' /* Select Person */ ,
95   'is_attachment_boxLabel' : '2ad41a2ff4f0dac97d63aff331d5e6e7' /* Downloads first Attachment */ ,
96   'extra_css_fieldLabel' : '39f64cc9436cacfbceda3b7bdeb8e24c' /* Styles (CSS) */ ,
97   'template_id_template_clean_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
98   'parent_id_title_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
99   'is_draft_fieldLabel' : '287234a1ff35a314b5b6bc4e5828e745' /* Attributes */ ,
100   'add_link_emptyText' : '580b21aac58f1b73cece26e272cdfbee' /* Add Link */ ,
101   'keywords_fieldLabel' : '867343577fa1f33caa632a19543bd252' /* Keywords */ ,
102   'descriptions_fieldLabel' : '8bc84316c4078bf66723fd019616d920' /* Descriptions */ ,
103   'add_link_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
104   'menu_page_id_page_link_emptyText' : '99e7707748ae048e17c5810fad119e0b' /* Select Page */ ,
105   'element_id_name_fieldLabel' : 'f3912172e6bf57f8979782f4a2342233' /* Appears in Block */ ,
106   'is_element_value' : 'cfcd208495d565ef66e7dff9f98764da' /* 0 */ ,
107   'target_url_fieldLabel' : 'e64df1d7c22b9638f084ce8a4aff3ff3' /* Target URL */ ,
108   'interest_name_fieldLabel' : 'c70952e4ab3806c049737cd7d2b8896b' /* Interests */ ,
109   'language_name_qtip' : '83dad8107f9459efe2b4fabcf5b63108' /* Select Language */ ,
110   'page_type_id_display_name_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
111   'language_name_fieldLabel' : '83dad8107f9459efe2b4fabcf5b63108' /* Select Language */ ,
112   'element_id_name_emptyText' : 'b5216c9b4e0ac0afd9c76eb1d12ad1b9' /* Select Section */ ,
113   'menu_page_id_page_link_fieldLabel' : '8adedb6a6226807ba810215dd3b3c61b' /* Menu links to Page */ ,
114   'page_type_id_display_name_emptyText' : '779e2624ddf330fb05b51ae59faf212d' /* Select Status Type */ ,
115   'template_id_template_clean_emptyText' : '31bb2f6e9b8fb11cbb7fb63c6025223f' /* Select Template */ ,
116   'menu_page_id_page_link_loadingText' : '1243daf593fa297e07ab03bf06d925af' /* Searching... */ ,
117   'extended_fieldLabel' : '57e195426892c5515935f21d97228814' /* Extended Contents */ ,
118   'add_link_qtip' : '76729937a5eb6b0fd88c42581161facd' /* Select Category  */ ,
119   'category_name_fieldLabel' : '3adbdb3ac060038aa0e6e6c138ef9873' /* Category */ ,
120   'page_type_id_display_name_qtip' : '20bec77364d863100a1f9325873a8504' /* Select Page Type */ ,
121   'body_fieldLabel' : 'c1df1da7a1ce305a3b60af9d5733ac1d' /* Contents */ ,
122   'parent_id_title_emptyText' : '95cb4f45ab7ff3984f25ab8668499020' /* Select Parent */ ,
123   'title_fieldLabel' : 'b78a3223503896721cca1303f776159b' /* Title */ ,
124   'is_draft_boxLabel' : 'f03ab16cd58372c77ba45a3d9a5a1cb9' /* Draft */ ,
125   'page_link_fieldLabel' : 'd52f80f80467bb575253a5a39ca016a7' /* Page link /  Name / Order */ ,
126   'parent_id_title_fieldLabel' : '30269022e9d8f51beaabb52e5d0de2b7' /* Parent */ 
127  },
128
129  dialog : false,
130  callback:  false,
131
132  show : function(data, cb)
133  {
134   if (!this.dialog) {
135    this.create();
136   }
137
138   this.callback = cb;
139   this.data = data;
140   this.dialog.show(this.data._el);
141   if (this.form) {
142    this.form.reset();
143    this.form.setValues(data);
144    this.form.fireEvent('actioncomplete', this.form,  { type: 'setdata', data: data });
145   }
146
147  },
148
149  create : function()
150  {
151    var _this = this;
152    this.dialog = Roo.factory({
153     xtype : 'LayoutDialog',
154     background : true,
155     closable : true,
156     collapsible : false,
157     height : 600,
158     modal : true,
159     resizable : false,
160     setStylesheets : function() {
161         var sheets = [];
162         
163         sheets.push(rootURL + '/Pman/Cms/templates/undoreset.css');
164         
165         if(typeof(uiConfig) !== 'undefined'  && typeof(uiConfig.cms_css) != 'undefined'){
166             Roo.each(uiConfig.cms_css, function(v){
167                 sheets.push(rootURL + v);
168             })
169         }
170         
171         new Pman.Request({
172            url : baseURL + '/Roo/Cms_page.php',
173            method : 'GET',
174            params : {
175                _stylesheets : 1
176            }, 
177            success : function(res) {
178                 Roo.log(res);
179                 if(res.data._stylesheets.length){
180                     var setting = res.data._stylesheets.split("\n");
181                     
182                     Roo.each(setting, function(s){
183                         sheets.push(s.replace('{rootURL}', rootURL));
184                     });
185                     
186                 }
187     
188                 _this.form1.findField('body').removeStylesheets();
189                 _this.form2.findField('extended').removeStylesheets();
190     
191                 _this.form1.findField('body').setStylesheets(sheets);
192                 _this.form2.findField('extended').setStylesheets(sheets);
193     
194                 _this.trform1.findField('body').removeStylesheets();
195                 _this.trform2.findField('extended').removeStylesheets();
196                 
197                 _this.trform1.findField('body').setStylesheets(sheets);
198                 _this.trform2.findField('extended').setStylesheets(sheets);
199            }
200        });
201     
202     },
203     title : _this._strings['aa6356b678bc4fc78253c9edf65bff03'] /* Edit Page / Blog Entry */,
204     width : 850,
205     listeners : {
206      show : function (_self)
207       {
208           // @see the contentpanel - center - resize handler.
209       
210           _this.centerLayoutPanel.getLayout().getRegion('south').showPanel(0);
211           
212           var w = Roo.lib.Dom.getViewWidth();
213           var h = Roo.lib.Dom.getViewHeight();
214           this.resizeTo(w-50, h-50);
215           this.center();
216           
217           _this.centerLayoutPanel.getLayout().getRegion('south').resizeTo(h - 450);
218           
219           _this.westLayoutPanel.getLayout().getRegion('south').resizeTo(h - 450);
220           
221           Pman.Cms.pageEditAddCustomFields();
222           
223           /*
224           var ew = Math.max(250, w-150); // was 350?/ why?
225           //var eh = Math.max(250, h-350) ;
226           var eh = 200;
227           
228           var bd = _this.form1.findField('body');
229           
230           if (bd.resizeEl) { 
231               bd.width = ew;
232               bd.height = eh;
233               // since render delays resize.. 
234              bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
235               //_this.bodycol.el.setWidth(bd.width+20);
236           }
237           var bd = _this.form2.findField('extended');
238           if (bd.resizeEl) { 
239               bd.width = ew;
240               bd.height = eh;
241               // since render delays resize.. 
242              bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
243            //  _this.extendcol.el.setWidth(bd.width+20);
244           }
245            var bd = _this.form3.findField('extra_css');
246           if (bd) { 
247               bd.el.setWidth(ew);
248              //_this.keywordscol.el.setWidth(ew+20);
249           }
250           
251           // fix messed up scroll.
252           _this.dialog.layout.el.dom.scrollTop = 0;
253           
254           */
255       }
256     },
257     xns : Roo,
258     '|xns' : 'Roo',
259     center : {
260      xtype : 'LayoutRegion',
261      titlebar : false,
262      xns : Roo,
263      '|xns' : 'Roo'
264     },
265     east : {
266      xtype : 'LayoutRegion',
267      collapsed : true,
268      collapsedTitle : 'Images / Attachments',
269      collapsible : true,
270      fitToFrame : true,
271      split : true,
272      title : _this._strings['308f2757bfc9ce92fb00ff93fdffd279'] /* Images / Attachments */,
273      titlebar : true,
274      listeners : {
275       expanded : function (_self)
276        {
277            var id = _this.form.findField('id').getValue() * 1;
278            
279            if(id < 1){
280                Roo.MessageBox.alert('Error', 'Save first');
281                this.collapse();
282                return;
283            }
284            
285            var w = Roo.lib.Dom.getViewWidth();
286            var h = Roo.lib.Dom.getViewHeight();
287            
288            _self.resizeTo.defer(110, _self,[ w-400,  h] );
289            _this.dialog.getLayout().getRegion('west').collapse();
290        }
291      },
292      xns : Roo,
293      '|xns' : 'Roo'
294     },
295     west : {
296      xtype : 'LayoutRegion',
297      collapsed : true,
298      collapsedTitle : 'Translations',
299      collapsible : true,
300      fitToFrame : true,
301      split : true,
302      title : _this._strings['0b8d92bc19b720bb1065649535463409'] /* Translations */,
303      titlebar : true,
304      listeners : {
305       beforecollapse : function (_self)
306        {
307            if(!_this.trform || !_this.trform1 || !_this.trform2){
308                return true;
309            }
310            
311            if(
312                !_this.trform.isDirty() &&
313                !_this.trform1.isDirty() &&
314                !_this.trform2.isDirty() &&
315                !_this.trform3.isDirty()
316            ) {
317                return true;
318            }
319            
320            Roo.MessageBox.confirm(
321                "Confirm", 
322                "Do you want to save the translation",
323                function(res) {
324                    if(res != 'yes') {
325                        _self.collapse(true, true);
326                        return true;
327                    }
328                    
329                    return false;
330                }
331            );
332            
333            return false;
334        },
335       collapsed : function (_self)
336        {
337            
338        },
339       expanded : function (_self)
340        {
341            var id = _this.form.findField('id').getValue() * 1;
342            
343            if(id < 1){
344                Roo.MessageBox.alert('Error', 'Save first');
345                this.collapse();
346                return;
347            }
348            
349            var w = Roo.lib.Dom.getViewWidth();
350            var h = Roo.lib.Dom.getViewHeight();
351            
352            _self.resizeTo.defer(110, _self,[ w-400,  h-350] );
353            
354            _this.panel.region.collapse();
355            
356        }
357      },
358      xns : Roo,
359      '|xns' : 'Roo'
360     },
361     buttons : [
362      {
363       xtype : 'Button',
364       text : _this._strings['31fde7b05ac8952dacf4af8a704074ec'] /* Preview */,
365       listeners : {
366        click : function() {
367             
368             var page_link = _this.form.findField('page_link').getValue();
369             
370             if(!page_link.length){
371                 Roo.MessageBox.alert('Error', 'Please fill in the page link');
372                 return;
373             }
374             
375             if(!uiConfig || typeof(uiConfig.cms_page_preview_base) == 'undefined'){
376                 Roo.MessageBox.alert('Error', 'Please setup [cms_page_preivew_base] in uiConfig');
377                 return;
378             }
379             
380             var url = uiConfig.cms_page_preview_base + page_link;
381             
382             window.open(url);
383         }
384       },
385       xns : Roo,
386       '|xns' : 'Roo'
387      },
388      {
389       xtype : 'Button',
390       text : _this._strings['ea4788705e6873b424c65e91c2846b19'] /* Cancel */,
391       listeners : {
392        click : function() {
393         
394             if(
395                 _this.trform.isDirty() ||
396                 _this.trform1.isDirty() ||
397                 _this.trform2.isDirty() ||
398                 _this.trform3.isDirty()
399             ) {
400                 Roo.MessageBox.confirm(
401                     "Confirm", 
402                     "Do you want to save the translation",
403                     function(res) {
404                         if(res != 'yes') {
405                             _this.form.reset();
406         
407                             _this.dialog.hide();
408                             return;
409                         }
410                         
411                     }
412                 );
413                 
414                 return;
415             }
416             
417             _this.form.reset();
418         
419             _this.dialog.hide();
420         
421         }
422       },
423       xns : Roo,
424       '|xns' : 'Roo'
425      },
426      {
427       xtype : 'Button',
428       text : _this._strings['c9cc8cce247e49bae79f15173ce97354'] /* Save */,
429       listeners : {
430        click : function() {
431             _this.exit = false;
432             
433             if(!_this.form1.findField('body').editorcore.sourceEditMode){
434                 _this.form1.findField('body').syncValue();
435                 _this.form2.findField('extended').syncValue();
436                 Roo.log('syncValue');
437             }else{
438                 _this.form1.findField('body').pushValue();
439                 _this.form2.findField('extended').pushValue();
440                 Roo.log('pushValue');
441             }
442             
443             if(_this.data.page_type_id_name != 'blog' && AppModules.indexOf("Crm") == -1){
444                 _this.interests.reset();
445             }
446                 
447             if(
448                 _this.trform.isDirty() ||
449                 _this.trform1.isDirty() ||
450                 _this.trform2.isDirty() ||
451                 _this.trform3.isDirty()
452             ) {
453                 Roo.MessageBox.confirm(
454                     "Confirm", 
455                     "Do you want to save the translation",
456                     function(res) {
457                         if(res != 'yes') {
458                             _this.dialog.el.mask("Saving");
459                             _this.form.doAction("submit");
460                             return;
461                         }
462                         
463                     }
464                 );
465                     
466                 return;
467             }
468             
469             _this.dialog.el.mask("Saving");
470             _this.form.doAction("submit");
471         
472         }
473       },
474       xns : Roo,
475       '|xns' : 'Roo'
476      },
477      {
478       xtype : 'Button',
479       text : _this._strings['778551900655782c5c7827332b08cf3f'] /* Save and close */,
480       listeners : {
481        click : function() {
482         
483                 _this.exit = true;
484                
485                if(!_this.form1.findField('body').editorcore.sourceEditMode){
486                     _this.form1.findField('body').syncValue();
487                     _this.form2.findField('extended').syncValue();
488                 }else{
489                     _this.form1.findField('body').pushValue();
490                     _this.form2.findField('extended').pushValue();
491                 }
492                 
493                 if(_this.data.page_type_id_name != 'blog' && AppModules.indexOf("Crm") == -1){
494                     _this.interests.reset();
495                 }
496                 
497                 
498                 if(
499                     _this.trform.isDirty() ||
500                     _this.trform1.isDirty() ||
501                     _this.trform2.isDirty() ||
502                     _this.trform3.isDirty()
503                 ) {
504                     Roo.MessageBox.confirm(
505                         "Confirm", 
506                         "Do you want to save the translation",
507                         function(res) {
508                             if(res != 'yes') {
509                                 _this.dialog.el.mask("Saving");
510                                 _this.form.doAction("submit");
511                                 return;
512                             }
513                             
514                         }
515                     );
516                     
517                     return;
518                 }
519                 
520             _this.dialog.el.mask("Saving");
521              _this.form.doAction("submit");
522         
523         }
524       },
525       xns : Roo,
526       '|xns' : 'Roo'
527      }
528     ],
529     items  : [
530      {
531       xtype : 'NestedLayoutPanel',
532       background : false,
533       fitContainer : true,
534       fitToFrame : true,
535       region : 'center',
536       listeners : {
537        render : function (_self)
538         {
539             _this.centerLayoutPanel = this;
540             
541         }
542       },
543       xns : Roo,
544       '|xns' : 'Roo',
545       layout : {
546        xtype : 'BorderLayout',
547        xns : Roo,
548        '|xns' : 'Roo',
549        center : {
550         xtype : 'LayoutRegion',
551         tabPosition : 'top',
552         xns : Roo,
553         '|xns' : 'Roo'
554        },
555        south : {
556         xtype : 'LayoutRegion',
557         height : 250,
558         split : true,
559         tabPosition : 'top',
560         xns : Roo,
561         '|xns' : 'Roo'
562        },
563        items  : [
564         {
565          xtype : 'ContentPanel',
566          autoScroll : true,
567          fitToFrame : true,
568          region : 'center',
569          listeners : {
570           render : function (_self)
571            {
572              _this.cpanel = _self;
573            },
574           resize : function (_self, width, height)
575            {
576                Roo.log("RESIZE, " + width + ',' + height);
577                
578                var ew = Math.max(250, width - 10);
579                var eh = _this.centerLayoutPanel.getLayout().getRegion('south').el.getHeight() - 30;
580                
581                if (!_this.form) {
582                    return;
583                }
584                var bd;
585                if (_this.form1) {
586                    bd = _this.form1.findField('body');
587                    if (bd.resizeEl) { 
588                        bd.width = ew;
589                        bd.height = eh;
590                        // since render delays resize.. 
591                        Roo.log('resizing body to ' + bd.width);        
592                       bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
593                     //   _this.bodycol.el.setWidth(bd.width+20);
594                    }
595                }
596                
597                if (_this.form2) {
598                    bd = _this.form2.findField('extended');
599                    
600                    if (bd.resizeEl) { 
601                        bd.width = ew;
602                        bd.height = eh;
603                        
604                        Roo.log('resizing extended to ' + bd.width);
605                        // since render delays resize.. 
606                       bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
607                    //   _this.extendcol.el.setWidth(bd.width+20);
608                    }
609                }
610                if (_this.form3) {
611                    
612                    bd = _this.form3.findField('extra_css');
613                    if (bd) { 
614                        bd.el.setWidth(ew);
615                        bd.el.setHeight(eh);
616                   //    _this.keywordscol.el.setWidth(ew+20);
617                    }
618                // fix for messed up rendering of dialog?
619                }
620                
621                try { 
622                    _this.dialog.layout.el.dom.scrollTop = 0;
623                } catch (e) { 
624                    // noop... - the above sometimes fails...
625                }
626            }
627          },
628          xns : Roo,
629          '|xns' : 'Roo',
630          toolbar : {
631           xtype : 'Toolbar',
632           xns : Roo,
633           '|xns' : 'Roo',
634           items  : [
635            {
636             xtype : 'Button',
637             text : _this._strings['d88aa1eee60ba140f07d5f81769cec74'] /* << Edit Translations */,
638             listeners : {
639              click : function (_self, e)
640               {
641                   if (_this.dialog.getLayout().getRegion('west').collapsed) {
642                       _this.dialog.getLayout().getRegion('west').expand();
643                   } else {
644                       _this.dialog.getLayout().getRegion('west').collapse();
645                   }
646                   
647               }
648             },
649             xns : Roo.Toolbar,
650             '|xns' : 'Roo.Toolbar'
651            },
652            {
653             xtype : 'Fill',
654             xns : Roo.Toolbar,
655             '|xns' : 'Roo.Toolbar'
656            },
657            {
658             xtype : 'Button',
659             text : _this._strings['c02bd0c22c290ae599ee2f3ff2023fd3'] /* Manage Images / Attachments >> */,
660             listeners : {
661              click : function (_self, e)
662               {
663                   if (_this.panel.region.collapsed) {
664                       _this.panel.region.expand();
665                   } else {
666                       _this.panel.region.collapse();
667                   }
668                   
669               }
670             },
671             xns : Roo.Toolbar,
672             '|xns' : 'Roo.Toolbar'
673            }
674           ]
675          },
676          items  : [
677           {
678            xtype : 'Form',
679            is_copy : function() 
680            { 
681                _this.form.setValues(_this.data);
682                
683                var d = _this.data;
684            
685                _this.dialog.el.unmask();
686               _this.grid.getDataSource().load();
687               
688               _this.trform.reset();
689               _this.trform1.reset();
690               _this.trform2.reset();
691               
692               _this.form1.findField('body').originalValue = _this.form1.findField('body').getValue();
693               _this.form2.findField('extended').originalValue = _this.form2.findField('extended').getValue();
694               
695               /*
696                var catlabel= _this.form.findField('category_page_id').fieldEl.select('label',true).first()
697                catlabel.dom.innerHTML = 'Category';            
698                
699                if(_this.data.page_type_id_name == 'category'){
700                    catlabel.dom.innerHTML = 'Parent Category';
701                }
702                */
703                /*
704                var catlabel= _this.form.findField('parent_id').fieldEl.select('label',true).first();
705                catlabel.dom.innerHTML = 'Parent page';            
706                if(_this.data.page_type_id_name == 'category'){
707                    catlabel.dom.innerHTML = 'Parent';
708                }
709                */
710                // better if this was not here... - not sure which project uses it?
711                
712                if(_this.data.page_type_id_name == 'blog' && AppModules.indexOf("Crm") !== -1){
713                    _this.interestsCol.show();
714                }
715                
716                if(typeof(d['interests']) != 'undefined'){
717                    _this.form.findField('interest').setValue(Roo.decode(d['interests']));
718                }
719                
720                if(typeof(d['categories']) != 'undefined'){
721                    _this.form.findField('category').setValue(Roo.decode(d['categories']));
722                }
723                
724                if(typeof(d['page_classes']) != 'undefined'){
725                    _this.form.findField('page_cls').setValue(Roo.decode(d['page_classes']));
726                }
727                
728                _this.trpanel.el.unmask();
729                _this.panel.el.unmask();
730                
731                // fix scrolling..
732                _this.cpanel.el.dom.scrollTop = 0;
733                
734                // fix messed up scroll.
735                _this.dialog.layout.el.dom.scrollTop = 0;
736                return;
737            },
738            labelAlign : 'right',
739            labelWidth : 120,
740            method : 'POST',
741            showHide : function()
742            {
743                var in_rss= 0;
744                var is_menu= 0;
745                var is_element  = 0;
746                var is_category = 0;
747                
748                var page_type_name = _this.form.findField('page_type_id_name').getValue();
749                
750                switch(page_type_name){
751                    case 'page' :
752                        is_element = 0;
753                    break;
754                    
755                    case 'element' :
756                        is_element = 1;
757                    break;
758                    
759                    case 'blog' :
760                        in_rss = 1;
761                    break;
762                    
763                    case 'menu' :
764                        is_menu = 1;
765                    break;
766                    
767                    case 'category' :
768                        in_rss = 1;
769                        is_category = 1;
770                    break;
771                }
772                
773                var is_system_page = _this.form.findField('is_system_page').getValue() * 1;
774                var is_attachment = _this.form.findField('is_attachment').getValue() * 1;
775                var has_extended = _this.form.findField('has_extended').getValue() * 1;
776                
777                var vis = {
778                    is_attachment : !in_rss,
779                    
780                    category_type_id : in_rss && !is_menu,
781                    page_link : 1, //!in_rss, // always show page link.. may not be needed though..
782                    target_url : is_menu,
783                    
784                    category : !is_category,
785                    
786                    parent_id : !in_rss || is_category ,
787                    published : in_rss ,
788                    
789                    to_replace_id :false, // !in_rss, // is this used.
790                    is_draft : !is_system_page,
791                    author_id : in_rss && !is_menu  && !is_attachment,
792                    
793                    template_id : !is_attachment && !is_menu && !is_system_page,
794                    element_id : is_element &&   !is_menu, 
795                    menu_page_id : is_menu,
796                    page_cls : is_element
797             
798                  //  has_extended : !is_menu && !is_attachment, // always shown.
799                  //  extended : has_extended && !is_menu  && !is_attachment,
800                   // body : !is_attachment && !is_menu,
801                    //keywords : !is_attachment && !is_menu, 
802                   // descriptions : !is_attachment && !is_menu
803                   // extra_css : !is_attachment && !is_menu
804                };
805            
806                for(var k in vis) {
807                    var el = _this.form.findField(k);
808                    
809                    if (!el) {
810                        Roo.log("missing field " + k);
811                        continue;
812                    }
813                    
814                    el.actionMode = 'fieldEl';
815                    
816                    if (vis[k]) {
817                        el.show();
818                    } else{
819                        el.hide();
820                    }
821                    
822                }
823                
824                _this.centerLayoutPanel.getLayout().getRegion('south').show();
825                _this.centerLayoutPanel.getLayout().getRegion('south').unhidePanel(0);
826                _this.centerLayoutPanel.getLayout().getRegion('south').unhidePanel(1);
827                _this.centerLayoutPanel.getLayout().getRegion('south').unhidePanel(2);
828                _this.centerLayoutPanel.getLayout().getRegion('south').unhidePanel(3);
829                
830                if(is_attachment || is_menu){
831                
832                    _this.centerLayoutPanel.getLayout().getRegion('south').hide();
833                    
834                }
835                
836                if(!has_extended && !is_attachment && !is_menu){
837                    _this.centerLayoutPanel.getLayout().getRegion('south').hidePanel(1);
838                    _this.centerLayoutPanel.getLayout().getRegion('south').showPanel(0);
839                }
840                
841                
842                _this.trform.showHide();
843                
844                if(typeof(_this.form.editors) == 'undefined'){
845                    _this.form.editors = {
846                        body : _this.form1.findField('body').wrap.isVisible(),
847                        extended : _this.form2.findField('extended').wrap.isVisible()
848                   };
849                   
850                   if(_this.form.editors.body){
851                        setInterval(_this.form1.findField('body').autosave, 60000);
852                   }
853                   
854                   if(_this.form.editors.extended){
855                        setInterval(_this.form2.findField('extended').autosave, 60000);
856                   }
857               }
858               
859               if(!_this.form.editors.body && _this.form1.findField('body').wrap.isVisible()){
860                    setInterval(_this.form1.findField('body').autosave, 60000);
861                    _this.form.editors.body = true;
862               }
863               
864               if(!_this.form.editors.extended && _this.form2.findField('extended').wrap.isVisible()){
865                    setInterval(_this.form2.findField('extended').autosave, 60000);
866                    _this.form.editors.extended = true;
867               }
868                
869                
870                
871            },
872            style : 'margin: 5px',
873            url : baseURL + '/Roo/cms_page.php',
874            listeners : {
875             actioncomplete : function (_self, action)
876              {
877              
878                 if (action.type == 'setdata') {
879              
880                      _this.form.addForm(_this.form1);
881                      _this.form.addForm(_this.form2);
882                      _this.form.addForm(_this.form3);
883                      _this.form.addForm(_this.form4);
884                      
885                      _this.dialog.setStylesheets();
886                      
887                      _this.dialog.getLayout().getRegion('west').collapse();
888                      _this.panel.region.collapse();
889                      
890                      _this.trpanel.el.mask('Save first');
891                      _this.panel.el.mask('Save first');
892                      
893                      _this.loaded = false;
894                      _this.interestsCol.hide();
895                      
896                      //_this.form.findField('category_page_id').fieldEl.select('label',true).first().dom.innerHTML = 'Category';
897                      
898                      _this.trform.reset();
899                      _this.trform1.reset();
900                      _this.trform2.reset();
901                      _this.trform3.reset();
902                      
903                      if ( _this.data.id) {
904                          _this.dialog.el.mask("Loading");
905                          this.load({ method: 'GET', params: { '_id' : _this.data.id, '_with_primary_image' : 1 }});
906                      } else {
907              
908                          _this.loaded = true;
909                          var is_draft = typeof(_this.data.is_draft) != 'undefined' ? _this.data.is_draft : 1;
910                          this.findField('is_draft').setValue(is_draft);
911                          _this.page_type.setValue(_this.data.page_type_id);
912                          _this.page_type.el.dom.value = _this.data.page_type_id_display_name;
913                          
914                          if(_this.data.page_type_id_name == 'blog' && AppModules.indexOf("Crm") !== -1){
915                              _this.interestsCol.show();
916                          }
917                          
918                          _this.form.showHide();
919                          
920                          /*
921                          var catlabel= _this.form.findField('category_page_id').fieldEl.select('label',true).first()
922                          catlabel.dom.innerHTML = 'Category';            
923                          if(_this.data.page_type_id_name == 'category'){
924                              catlabel.dom.innerHTML = 'Parent Category';
925                          } 
926                          */
927                          
928                          /*
929                          var catlabel= _this.form.findField('parent_id').fieldEl.select('label',true).first();
930                          catlabel.dom.innerHTML = 'Parent page';
931                          if(_this.data.page_type_id_name == 'category'){
932                              catlabel.dom.innerHTML = 'Parent';
933                          }
934                          */
935                          
936                      }
937                      
938                      if(_this.data._is_copy){
939                          _this.form.is_copy();
940                      }
941                      
942                      return;
943                  }
944                  
945                  if (action.type == 'load') {
946                  
947                      //_this.data = action.result.data;
948                      
949                      var d = action.result.data;
950                      
951                      _this.dialog.el.unmask();
952                     _this.grid.getDataSource().load();
953                     
954                     _this.trform.reset();
955                     _this.trform1.reset();
956                     _this.trform2.reset();
957                     
958                     _this.trform.addForm(_this.trform1);
959                     _this.trform.addForm(_this.trform2);
960                      
961                     _this.form1.findField('body').originalValue = _this.form1.findField('body').getValue();
962                     _this.form2.findField('extended').originalValue = _this.form2.findField('extended').getValue();
963                     _this.form3.findField('extra_css').originalValue = _this.form3.findField('extra_css').getValue();
964                     _this.form4.findField('keywords').originalValue = _this.form4.findField('keywords').getValue();
965                     _this.form4.findField('descriptions').originalValue = _this.form4.findField('descriptions').getValue();
966                     
967                     /*
968                      var catlabel= _this.form.findField('category_page_id').fieldEl.select('label',true).first()
969                      catlabel.dom.innerHTML = 'Category';            
970                      
971                      if(_this.data.page_type_id_name == 'category'){
972                          catlabel.dom.innerHTML = 'Parent Category';
973                      }
974                      */
975                      /*
976                      var catlabel= _this.form.findField('parent_id').fieldEl.select('label',true).first();
977                      catlabel.dom.innerHTML = 'Parent page';            
978                      if(_this.data.page_type_id_name == 'category'){
979                          catlabel.dom.innerHTML = 'Parent';
980                      }
981                      */
982                      // better if this was not here... - not sure which project uses it?
983                      
984                      if(_this.data.page_type_id_name == 'blog' && AppModules.indexOf("Crm") !== -1){
985                          _this.interestsCol.show();
986                      }
987                      
988                      if(typeof(d['interests']) != 'undefined'){
989                          _this.form.findField('interest').setValue(Roo.decode(d['interests']));
990                      }
991                      
992                      if(typeof(d['categories']) != 'undefined'){
993                          _this.form.findField('category').setValue(Roo.decode(d['categories']));
994                      }
995                      
996                      if(typeof(d['page_classes']) != 'undefined'){
997                          _this.form.findField('page_cls').setValue(Roo.decode(d['page_classes']));
998                      }
999                      
1000                      _this.trpanel.el.unmask();
1001                      _this.panel.el.unmask();
1002                      
1003                      // fix scrolling..
1004                      _this.cpanel.el.dom.scrollTop = 0;
1005                      
1006                      // fix messed up scroll.
1007                      _this.dialog.layout.el.dom.scrollTop = 0;
1008                      
1009                      return;
1010                  }
1011                  if (action.type =='submit') {
1012                     
1013                     _this.dialog.el.unmask();
1014                     
1015                     if(!_this.exit){
1016                          this.load({ method: 'GET', params: { '_id' : action.result.data.id }});
1017                          return;
1018                     }
1019                     
1020                     _this.dialog.hide();
1021                     
1022              
1023                      if (_this.callback) {
1024                         _this.callback.call(_this, action.result.data);
1025                      }
1026                      _this.form.reset();
1027                      return;
1028                  }
1029              },
1030             actionfailed : function (_self, action)
1031              {
1032                  _this.dialog.el.unmask(); 
1033                  Pman.standardActionFailed(_self, action);
1034              },
1035             rendered : function (_self)
1036              {
1037                  _this.form = _self;
1038              }
1039            },
1040            xns : Roo.form,
1041            '|xns' : 'Roo.form',
1042            items  : [
1043             {
1044              xtype : 'Column',
1045              labelWidth : 200,
1046              width : 750,
1047              xns : Roo.form,
1048              '|xns' : 'Roo.form',
1049              items  : [
1050               {
1051                xtype : 'Row',
1052                hideLabels : false,
1053                labelAlign : 'right',
1054                labelWidth : 200,
1055                style : 'height:30px;overflow:hidden',
1056                width : 850,
1057                xns : Roo.form,
1058                '|xns' : 'Roo.form',
1059                items  : [
1060                 {
1061                  xtype : 'Hidden',
1062                  fieldLabel : _this._strings['e659b52eba1f0299b2d8ca3483919e72'] /* Type: */,
1063                  width : 1,
1064                  xns : Roo.form,
1065                  '|xns' : 'Roo.form'
1066                 },
1067                 {
1068                  xtype : 'Row',
1069                  hideLabels : true,
1070                  labelWidth : 0,
1071                  style : 'height:30px;overflow:hidden',
1072                  width : 600,
1073                  xns : Roo.form,
1074                  '|xns' : 'Roo.form',
1075                  items  : [
1076                   {
1077                    xtype : 'ComboBox',
1078                    alwaysQuery : true,
1079                    displayField : 'display_name',
1080                    editable : false,
1081                    emptyText : _this._strings['779e2624ddf330fb05b51ae59faf212d'] /* Select Status Type */,
1082                    fieldLabel : _this._strings['6a5b847af3d97df722040debdbccfbed'] /* Page Type */,
1083                    forceSelection : true,
1084                    hiddenName : 'page_type_id',
1085                    listWidth : 400,
1086                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1087                    minChars : 2,
1088                    name : 'page_type_id_display_name',
1089                    pageSize : 20,
1090                    qtip : _this._strings['20bec77364d863100a1f9325873a8504'] /* Select Page Type */,
1091                    selectOnFocus : true,
1092                    tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
1093                    triggerAction : 'all',
1094                    typeAhead : false,
1095                    valueField : 'id',
1096                    listeners : {
1097                     render : function (_self)
1098                      {
1099                          _this.page_type = _self;
1100                      },
1101                     select : function (combo, record, index)
1102                      {
1103                      //    _this.grid.footer.onClick('first');
1104                          var page_type_name = record.data.name;
1105                          _this.form.findField('page_type_id_name').setValue(page_type_name);
1106                          if(page_type_name == 'blog' || page_type_name == 'category'){ // blog || category unset attachment
1107                              _this.form.findField('is_attachment').setValue(0);
1108                              return;
1109                          }
1110                          if (_this.form) { 
1111                              _this.form.showHide.defer(100, _this.form);      
1112                          } 
1113                          
1114                      }
1115                    },
1116                    xns : Roo.form,
1117                    '|xns' : 'Roo.form',
1118                    store : {
1119                     xtype : 'Store',
1120                     remoteSort : true,
1121                     sortInfo : { direction : 'ASC', field: 'seqid' },
1122                     listeners : {
1123                      beforeload : function (_self, o){
1124                           o.params = o.params || {};
1125                           // set more here
1126                           o.params.etype = 'cms_page_type'; 
1127                       }
1128                     },
1129                     xns : Roo.data,
1130                     '|xns' : 'Roo.data',
1131                     proxy : {
1132                      xtype : 'HttpProxy',
1133                      method : 'GET',
1134                      url : baseURL + '/Roo/core_enum.php',
1135                      xns : Roo.data,
1136                      '|xns' : 'Roo.data'
1137                     },
1138                     reader : {
1139                      xtype : 'JsonReader',
1140                      fields : [{"name":"id","type":"int"},{"name":"display_name","type":"string"}],
1141                      id : 'id',
1142                      root : 'data',
1143                      totalProperty : 'total',
1144                      xns : Roo.data,
1145                      '|xns' : 'Roo.data'
1146                     }
1147                    }
1148                   },
1149                   {
1150                    xtype : 'Column',
1151                    labelWidth : 60,
1152                    style : 'padding-left:  -70px;',
1153                    width : 200,
1154                    xns : Roo.form,
1155                    '|xns' : 'Roo.form',
1156                    items  : [
1157                     {
1158                      xtype : 'NumberField',
1159                      decimalPrecision : 0,
1160                      fieldLabel : _this._strings['b28a711cf7e94ec793ef926633997529'] /* Seq */,
1161                      name : 'seq_id',
1162                      width : 50,
1163                      xns : Roo.form,
1164                      '|xns' : 'Roo.form'
1165                     }
1166                    ]
1167                   }
1168                  ]
1169                 }
1170                ]
1171               },
1172               {
1173                xtype : 'Row',
1174                hideLabels : false,
1175                labelAlign : 'right',
1176                labelWidth : 200,
1177                style : 'height:30px;overflow:hidden',
1178                width : 800,
1179                xns : Roo.form,
1180                '|xns' : 'Roo.form',
1181                items  : [
1182                 {
1183                  xtype : 'Hidden',
1184                  fieldLabel : _this._strings['77174410b72decfd0b259961f1f65a8f'] /* Attributes: */,
1185                  width : 1,
1186                  xns : Roo.form,
1187                  '|xns' : 'Roo.form'
1188                 },
1189                 {
1190                  xtype : 'Row',
1191                  hideLabels : true,
1192                  labelWidth : 0,
1193                  style : 'height:30px;overflow:hidden',
1194                  width : 540,
1195                  xns : Roo.form,
1196                  '|xns' : 'Roo.form',
1197                  items  : [
1198                   {
1199                    xtype : 'Checkbox',
1200                    boxLabel : _this._strings['f03ab16cd58372c77ba45a3d9a5a1cb9'] /* Draft */,
1201                    fieldLabel : _this._strings['287234a1ff35a314b5b6bc4e5828e745'] /* Attributes */,
1202                    name : 'is_draft',
1203                    width : 100,
1204                    xns : Roo.form,
1205                    '|xns' : 'Roo.form'
1206                   },
1207                   {
1208                    xtype : 'Checkbox',
1209                    boxLabel : _this._strings['5834d26e96dbae06029496e5b111dca2'] /* Has Extended content? */,
1210                    inputValue : 1,
1211                    name : 'has_extended',
1212                    width : 180,
1213                    listeners : {
1214                     check : function (_self, checked)
1215                      {  
1216                         if (_this.form) {
1217                      
1218                             (function() { 
1219                                  _this.form.showHide();
1220                                  _this.panel.fireEvent('resize', _this.panel, [ _this.panel.el.getWidth(), _this.panel.el.getHeight() ]  );
1221                                  
1222                             }).defer(100);
1223                          }
1224                      }
1225                    },
1226                    xns : Roo.form,
1227                    '|xns' : 'Roo.form'
1228                   },
1229                   {
1230                    xtype : 'Checkbox',
1231                    boxLabel : _this._strings['2ad41a2ff4f0dac97d63aff331d5e6e7'] /* Downloads first Attachment */,
1232                    inputValue : 1,
1233                    name : 'is_attachment',
1234                    width : 180,
1235                    listeners : {
1236                     check : function (_self, checked)
1237                      {  
1238                         if (_this.form) { 
1239                       
1240                           _this.form.showHide.defer(100, _this.form);      
1241                         }
1242                      }
1243                    },
1244                    xns : Roo.form,
1245                    '|xns' : 'Roo.form'
1246                   }
1247                  ]
1248                 }
1249                ]
1250               },
1251               {
1252                xtype : 'ComboBox',
1253                allowBlank : true,
1254                displayField : 'name',
1255                editable : true,
1256                emptyText : _this._strings['340c2ee497b85d5954b01c64de7f44f6'] /* Select Person */,
1257                fieldLabel : _this._strings['a517747c3d12f99244ae598910d979c5'] /* Author */,
1258                forceSelection : true,
1259                hiddenName : 'author_id',
1260                listWidth : 400,
1261                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1262                minChars : 2,
1263                name : 'author_id_name',
1264                pageSize : 40,
1265                qtip : _this._strings['340c2ee497b85d5954b01c64de7f44f6'] /* Select Person */,
1266                queryParam : 'query[name]',
1267                selectOnFocus : true,
1268                tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b>  - {company_id_name}</div>',
1269                triggerAction : 'all',
1270                typeAhead : false,
1271                valueField : 'id',
1272                width : 300,
1273                xns : Roo.form,
1274                '|xns' : 'Roo.form',
1275                store : {
1276                 xtype : 'Store',
1277                 remoteSort : true,
1278                 sortInfo : { direction : 'ASC', field: 'name' },
1279                 listeners : {
1280                  beforeload : function (_self, o){
1281                       o.params = o.params || {};
1282                   
1283                       o.params.active = 1;
1284                       o.params['query[is_owner]'] = 1;
1285                   }
1286                 },
1287                 xns : Roo.data,
1288                 '|xns' : 'Roo.data',
1289                 proxy : {
1290                  xtype : 'HttpProxy',
1291                  method : 'GET',
1292                  url : baseURL + '/Roo/core_person',
1293                  xns : Roo.data,
1294                  '|xns' : 'Roo.data'
1295                 },
1296                 reader : {
1297                  xtype : 'JsonReader',
1298                  fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}],
1299                  id : 'id',
1300                  root : 'data',
1301                  totalProperty : 'total',
1302                  xns : Roo.data,
1303                  '|xns' : 'Roo.data'
1304                 }
1305                }
1306               },
1307               {
1308                xtype : 'ComboBoxArray',
1309                fieldLabel : _this._strings['3adbdb3ac060038aa0e6e6c138ef9873'] /* Category */,
1310                hiddenName : 'category',
1311                name : 'category_name',
1312                width : 400,
1313                xns : Roo.form,
1314                '|xns' : 'Roo.form',
1315                combo : {
1316                 xtype : 'ComboBox',
1317                 allowBlank : false,
1318                 alwaysQuery : true,
1319                 displayField : 'display_fullpath',
1320                 editable : true,
1321                 emptyText : _this._strings['03368e3c1eb4d2a9048775874301b19f'] /* Select category */,
1322                 fieldLabel : _this._strings['3adbdb3ac060038aa0e6e6c138ef9873'] /* Category */,
1323                 forceSelection : true,
1324                 listWidth : 400,
1325                 minChars : 2,
1326                 pageSize : 40,
1327                 queryParam : 'search[name]',
1328                 selectOnFocus : true,
1329                 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{fullpath}</b> </div>',
1330                 triggerAction : 'all',
1331                 valueField : 'id',
1332                 width : 385,
1333                 xns : Roo.form,
1334                 '|xns' : 'Roo.form',
1335                 store : {
1336                  xtype : 'Store',
1337                  remoteSort : true,
1338                  sortInfo : { field: 'tree_sequence', direction: 'ASC' },
1339                  listeners : {
1340                   beforeload : function (_self, o){
1341                        o.params = o.params || {};
1342                        
1343                        o.params.page_type_id_name= 'CATEGORY';
1344                        
1345                        o.params._with_fullpath = 1;
1346                    }
1347                  },
1348                  xns : Roo.data,
1349                  '|xns' : 'Roo.data',
1350                  proxy : {
1351                   xtype : 'HttpProxy',
1352                   method : 'GET',
1353                   url : baseURL + '/Roo/cms_page.php',
1354                   xns : Roo.data,
1355                   '|xns' : 'Roo.data'
1356                  },
1357                  reader : {
1358                   xtype : 'JsonReader',
1359                   fields : [
1360                       {"name":"id","type":"int"},
1361                       {"name":"name","type":"string"},
1362                       {"name":"display_name","type":"string"}
1363                   ],
1364                   id : 'id',
1365                   root : 'data',
1366                   totalProperty : 'total',
1367                   xns : Roo.data,
1368                   '|xns' : 'Roo.data'
1369                  }
1370                 }
1371                }
1372               },
1373               {
1374                xtype : 'ComboBox',
1375                allowBlank : true,
1376                alwaysQuery : true,
1377                displayField : 'page_link',
1378                editable : true,
1379                emptyText : _this._strings['95cb4f45ab7ff3984f25ab8668499020'] /* Select Parent */,
1380                fieldLabel : _this._strings['30269022e9d8f51beaabb52e5d0de2b7'] /* Parent */,
1381                forceSelection : true,
1382                hiddenName : 'parent_id',
1383                listWidth : 600,
1384                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1385                minChars : 2,
1386                name : 'parent_id_title',
1387                pageSize : 40,
1388                qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
1389                selectOnFocus : true,
1390                tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
1391                triggerAction : 'all',
1392                typeAhead : true,
1393                valueField : 'id',
1394                width : 400,
1395                listeners : {
1396                 select : function (combo, record, index)
1397                  {
1398                     var page_type_name = _this.form.findField('page_type_id_name').getValue();
1399                     if (page_type_name == 'page') { // page
1400                          return;
1401                     }
1402                     // do not default to put 'Home' at the beginning.
1403                     if (!record || !(record.data.parent_id *1)) {
1404                          return;
1405                     }
1406                     var pl = _this.form.findField('page_link');
1407                     var lk = pl.getValue();
1408                     var new_link = record.data.page_link + '/';
1409                     if (lk.length) {
1410                          new_link += lk.split('/').pop();
1411                     }
1412                     pl.setValue(new_link);
1413                     
1414                  }
1415                },
1416                xns : Roo.form,
1417                '|xns' : 'Roo.form',
1418                store : {
1419                 xtype : 'Store',
1420                 remoteSort : true,
1421                 sortInfo : { field: 'page_link', direction: 'ASC' },
1422                 listeners : {
1423                  beforeload : function (_self, options)
1424                   {
1425                        options.params['search[page_link_no_empty]'] =1;
1426                        
1427                        if(_this.form.findField('page_type_id').getRawValue() == 'Elements'){
1428                           options.params._page_type = 'page,element';
1429                        } else {
1430                           options.params.page_type_id = _this.form.findField('page_type_id').getValue() * 1;
1431                        }
1432                        
1433                        var id = _this.form.findField('id').getValue() * 1;
1434                        
1435                        if(id > 0){
1436                           options.params['!id'] = id;
1437                        }
1438                        
1439                        
1440                        /*
1441                        options.params.is_element = 0;
1442                        var page_type_name = _this.page_type.findRecord() ? _this.page_type.findRecord().data.name: _this.firstPageType.name;
1443                        options.params.is_menuitem = page_type_name == 'menu' ? 1 : 0;    
1444                        */
1445                   }
1446                 },
1447                 xns : Roo.data,
1448                 '|xns' : 'Roo.data',
1449                 proxy : {
1450                  xtype : 'HttpProxy',
1451                  method : 'GET',
1452                  url : baseURL + '/Roo/cms_page.php',
1453                  xns : Roo.data,
1454                  '|xns' : 'Roo.data'
1455                 },
1456                 reader : {
1457                  xtype : 'JsonReader',
1458                  fields : [
1459                   { name: 'id', type: 'int' },
1460                   'title',
1461                   'page_link' 
1462                  ],
1463                  id : 'id',
1464                  root : 'data',
1465                  totalProperty : 'total',
1466                  xns : Roo.data,
1467                  '|xns' : 'Roo.data'
1468                 }
1469                }
1470               },
1471               {
1472                xtype : 'Row',
1473                labelWidth : 200,
1474                xns : Roo.form,
1475                '|xns' : 'Roo.form',
1476                items  : [
1477                 {
1478                  xtype : 'DateField',
1479                  altFormats : 'Y-m-d H:i:s',
1480                  fieldLabel : _this._strings['69dd756ae9c23191a5bb9b61f0857432'] /* Date to Publish */,
1481                  format : 'Y-m-d',
1482                  name : 'published',
1483                  width : 200,
1484                  xns : Roo.form,
1485                  '|xns' : 'Roo.form'
1486                 },
1487                 {
1488                  xtype : 'TextField',
1489                  fieldLabel : _this._strings['fb3f11443065d5f4d8303ad913db9680'] /* Replaces (ignore) */,
1490                  name : 'to_replace_id',
1491                  width : 75,
1492                  xns : Roo.form,
1493                  '|xns' : 'Roo.form'
1494                 }
1495                ]
1496               },
1497               {
1498                xtype : 'TextField',
1499                fieldLabel : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
1500                name : 'title',
1501                width : 400,
1502                listeners : {
1503                 keyup : function (_self, e)
1504                  {
1505                      if (_this.page_type.getRawValue() == 'Category') {
1506                      
1507                          _this.form.findField('page_link').setValue(this.getValue().replace(/[\s]/ig, '-').toLowerCase());
1508                      
1509                      }
1510                  }
1511                },
1512                xns : Roo.form,
1513                '|xns' : 'Roo.form'
1514               },
1515               {
1516                xtype : 'TextField',
1517                fieldLabel : _this._strings['d52f80f80467bb575253a5a39ca016a7'] /* Page link /  Name / Order */,
1518                name : 'page_link',
1519                width : 400,
1520                xns : Roo.form,
1521                '|xns' : 'Roo.form'
1522               },
1523               {
1524                xtype : 'TextField',
1525                fieldLabel : _this._strings['e64df1d7c22b9638f084ce8a4aff3ff3'] /* Target URL */,
1526                name : 'target_url',
1527                width : 400,
1528                xns : Roo.form,
1529                '|xns' : 'Roo.form'
1530               },
1531               {
1532                xtype : 'ComboBox',
1533                allowBlank : true,
1534                alwaysQuery : true,
1535                displayField : 'template_clean',
1536                editable : true,
1537                emptyText : _this._strings['31bb2f6e9b8fb11cbb7fb63c6025223f'] /* Select Template */,
1538                fieldLabel : _this._strings['ebd9bec4d70abc789d439c1f136b0538'] /* Layout */,
1539                forceSelection : true,
1540                hiddenName : 'template_id',
1541                listWidth : 400,
1542                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1543                minChars : 2,
1544                name : 'template_id_template_clean',
1545                pageSize : 20,
1546                qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
1547                selectOnFocus : true,
1548                tpl : '<div class="x-grid-cell-text x-btn button"><b>{template_clean}</b></div>',
1549                triggerAction : 'all',
1550                typeAhead : true,
1551                valueField : 'id',
1552                width : 400,
1553                xns : Roo.form,
1554                '|xns' : 'Roo.form',
1555                store : {
1556                 xtype : 'Store',
1557                 remoteSort : true,
1558                 sortInfo : { field: 'template', direction: 'ASC' },
1559                 listeners : {
1560                  beforeload : function (_self, options)
1561                   {
1562                    
1563                       options.params._rescan = 1;
1564                      options.params._clean_name = 1;
1565                   //    options.params.lang = 'en';
1566                       options.params['!template[0]'] = 'master.html';
1567                       //options.params['!template[1]'] = 'index.html';
1568                   }
1569                 },
1570                 xns : Roo.data,
1571                 '|xns' : 'Roo.data',
1572                 proxy : {
1573                  xtype : 'HttpProxy',
1574                  method : 'GET',
1575                  url : baseURL + '/Roo/Cms_template',
1576                  xns : Roo.data,
1577                  '|xns' : 'Roo.data'
1578                 },
1579                 reader : {
1580                  xtype : 'JsonReader',
1581                  fields : [
1582                   { name: 'id', type: 'int' }, {name: 'template', type: 'string'}
1583                  ],
1584                  id : 'id',
1585                  root : 'data',
1586                  totalProperty : 'total',
1587                  xns : Roo.data,
1588                  '|xns' : 'Roo.data'
1589                 }
1590                }
1591               },
1592               {
1593                xtype : 'ComboBox',
1594                allowBlank : true,
1595                alwaysQuery : true,
1596                displayField : 'name',
1597                editable : true,
1598                emptyText : _this._strings['b5216c9b4e0ac0afd9c76eb1d12ad1b9'] /* Select Section */,
1599                fieldLabel : _this._strings['f3912172e6bf57f8979782f4a2342233'] /* Appears in Block */,
1600                forceSelection : true,
1601                hiddenName : 'element_id',
1602                listWidth : 400,
1603                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1604                minChars : 2,
1605                name : 'element_id_name',
1606                pageSize : 20,
1607                qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
1608                selectOnFocus : true,
1609                tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{name}</b></div>',
1610                triggerAction : 'all',
1611                typeAhead : true,
1612                valueField : 'id',
1613                width : 400,
1614                xns : Roo.form,
1615                '|xns' : 'Roo.form',
1616                store : {
1617                 xtype : 'Store',
1618                 remoteSort : true,
1619                 sortInfo : { field: 'name', direction: 'ASC' },
1620                 listeners : {
1621                  beforeload : function (_self, options)
1622                   {
1623                       var par = _this.form.findField('parent_id').getValue() * 1;
1624                       if (!par) {
1625                           Roo.MessageBox.alert("Error", "Select on what parent page it appears");
1626                           return false;
1627                       }
1628                       
1629                       options.params._cms_page_id = par;
1630                   }
1631                 },
1632                 xns : Roo.data,
1633                 '|xns' : 'Roo.data',
1634                 proxy : {
1635                  xtype : 'HttpProxy',
1636                  method : 'GET',
1637                  url : baseURL + '/Roo/Cms_template_element',
1638                  xns : Roo.data,
1639                  '|xns' : 'Roo.data'
1640                 },
1641                 reader : {
1642                  xtype : 'JsonReader',
1643                  fields : [
1644                   { name: 'id', type: 'int' }, {name: 'template', type: 'string'}
1645                  ],
1646                  id : 'id',
1647                  root : 'data',
1648                  totalProperty : 'total',
1649                  xns : Roo.data,
1650                  '|xns' : 'Roo.data'
1651                 }
1652                }
1653               },
1654               {
1655                xtype : 'ComboBox',
1656                allowBlank : true,
1657                alwaysQuery : true,
1658                displayField : 'page_link',
1659                editable : true,
1660                emptyText : _this._strings['99e7707748ae048e17c5810fad119e0b'] /* Select Page */,
1661                fieldLabel : _this._strings['8adedb6a6226807ba810215dd3b3c61b'] /* Menu links to Page */,
1662                forceSelection : true,
1663                hiddenName : 'menu_page_id',
1664                listWidth : 600,
1665                loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
1666                minChars : 2,
1667                name : 'menu_page_id_page_link',
1668                pageSize : 40,
1669                qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
1670                selectOnFocus : true,
1671                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>',
1672                triggerAction : 'all',
1673                typeAhead : true,
1674                valueField : 'id',
1675                width : 400,
1676                xns : Roo.form,
1677                '|xns' : 'Roo.form',
1678                store : {
1679                 xtype : 'Store',
1680                 remoteSort : true,
1681                 sortInfo : { field: 'title', direction: 'ASC' },
1682                 listeners : {
1683                  beforeload : function (_self, options)
1684                   {
1685                       options.params = options.params || {};
1686                       
1687                       options.params['search[page_link_no_empty]'] =1;
1688                        
1689                       options.params['page_type_id_name[0]'] = 'page';
1690                       options.params['page_type_id_name[1]'] = 'blog';
1691                        /*
1692                        options.params.is_element = 0;
1693                        options.params.is_menuitem = 0;     
1694                        */
1695                   }
1696                 },
1697                 xns : Roo.data,
1698                 '|xns' : 'Roo.data',
1699                 proxy : {
1700                  xtype : 'HttpProxy',
1701                  method : 'GET',
1702                  url : baseURL + '/Roo/cms_page.php',
1703                  xns : Roo.data,
1704                  '|xns' : 'Roo.data'
1705                 },
1706                 reader : {
1707                  xtype : 'JsonReader',
1708                  fields : [
1709                      {
1710                          "name":"id",
1711                          "type":"int"
1712                      },
1713                      {
1714                          "name":"title",
1715                          "type":"string"
1716                      },
1717                      {
1718                          "name":"page_link",
1719                          "type":"string"
1720                      },
1721                      {
1722                          "name":"page_type_id_display_name",
1723                          "type":"string"
1724                      }
1725                  ],
1726                  id : 'id',
1727                  root : 'data',
1728                  totalProperty : 'total',
1729                  xns : Roo.data,
1730                  '|xns' : 'Roo.data'
1731                 }
1732                }
1733               },
1734               {
1735                xtype : 'ComboBoxArray',
1736                fieldLabel : _this._strings['cc6892c9705afcfa61c53698756ba51b'] /* Page Class */,
1737                hiddenName : 'page_cls',
1738                name : 'page_cls_name',
1739                width : 400,
1740                xns : Roo.form,
1741                '|xns' : 'Roo.form',
1742                combo : {
1743                 xtype : 'ComboBox',
1744                 allowBlank : true,
1745                 alwaysQuery : true,
1746                 displayField : 'display_name',
1747                 editable : true,
1748                 emptyText : _this._strings['14c21301c0faf9d5561b8a580be21a13'] /* Select class */,
1749                 fieldLabel : _this._strings['cc6892c9705afcfa61c53698756ba51b'] /* Page Class */,
1750                 forceSelection : true,
1751                 listWidth : 400,
1752                 minChars : 2,
1753                 queryParam : 'query[search]',
1754                 selectOnFocus : true,
1755                 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
1756                 triggerAction : 'all',
1757                 valueField : 'name',
1758                 width : 385,
1759                 xns : Roo.form,
1760                 '|xns' : 'Roo.form',
1761                 store : {
1762                  xtype : 'Store',
1763                  remoteSort : true,
1764                  sortInfo : { direction : 'ASC', field: 'seqid' },
1765                  listeners : {
1766                   beforeload : function (_self, o){
1767                        o.params = o.params || {};
1768                    
1769                        o.params.etype = 'cms_page_class'; 
1770                    }
1771                  },
1772                  xns : Roo.data,
1773                  '|xns' : 'Roo.data',
1774                  proxy : {
1775                   xtype : 'HttpProxy',
1776                   method : 'GET',
1777                   url : baseURL + '/Roo/core_enum.php',
1778                   xns : Roo.data,
1779                   '|xns' : 'Roo.data'
1780                  },
1781                  reader : {
1782                   xtype : 'JsonReader',
1783                   fields : [
1784                       {"name":"id","type":"int"},
1785                       {"name":"name","type":"string"},
1786                       {"name":"display_name","type":"string"}
1787                   ],
1788                   id : 'id',
1789                   root : 'data',
1790                   totalProperty : 'total',
1791                   xns : Roo.data,
1792                   '|xns' : 'Roo.data'
1793                  }
1794                 }
1795                }
1796               }
1797              ]
1798             },
1799             {
1800              xtype : 'Column',
1801              labelWidth : 200,
1802              width : 250,
1803              xns : Roo.form,
1804              '|xns' : 'Roo.form',
1805              items  : [
1806               {
1807                xtype : 'FieldSet',
1808                hideLabels : true,
1809                labelAlign : 'top',
1810                legend : _this._strings['8a53accfc94c2500b00575ce0e0d786f'] /* Primary Image */,
1811                style : 'width: 165px;',
1812                xns : Roo.form,
1813                '|xns' : 'Roo.form',
1814                items  : [
1815                 {
1816                  xtype : 'DisplayField',
1817                  height : 150,
1818                  icon : 'rootURL + \'images/default/dd/drop-add.gif\'',
1819                  name : 'primary_image_id',
1820                  style : 'border: 1px solid #ccc;',
1821                  valueRenderer : function(v) {
1822                  
1823                      if (!v || v * 1 < 1) {
1824                          return '<div style="width: 150px; height: 150px; background-color: grey;" title="Using zero order image">&nbsp;</div>';
1825                      }
1826                      
1827                      return String.format('<img src="{0}/Images/Thumb/150/{1}" width="150" title="Using zero order image">', baseURL, v); 
1828                  },
1829                  width : 150,
1830                  xns : Roo.form,
1831                  '|xns' : 'Roo.form'
1832                 }
1833                ]
1834               }
1835              ]
1836             },
1837             {
1838              xtype : 'Column',
1839              listeners : {
1840               render : function (_self)
1841                {
1842                    _this.interestsCol = _self;
1843                }
1844              },
1845              xns : Roo.form,
1846              '|xns' : 'Roo.form',
1847              items  : [
1848               {
1849                xtype : 'ComboBoxArray',
1850                fieldLabel : _this._strings['c70952e4ab3806c049737cd7d2b8896b'] /* Interests */,
1851                hiddenName : 'interest',
1852                name : 'interest_name',
1853                width : 300,
1854                listeners : {
1855                 render : function (_self)
1856                  {
1857                      _this.interests = _self;
1858                      /*
1859                      _self.combo.addicon.setStyle( {
1860                          position : 'absolute',
1861                          right: '9px',
1862                          top : '2px',
1863                          float : 'left'
1864                      });
1865                      */
1866                  }
1867                },
1868                xns : Roo.form,
1869                '|xns' : 'Roo.form',
1870                combo : {
1871                 xtype : 'ComboBox',
1872                 allowBlank : true,
1873                 alwaysQuery : true,
1874                 displayField : 'display_name',
1875                 editable : true,
1876                 emptyText : _this._strings['30d1a216420426fcbd43ca70acd4aa48'] /* Select interests */,
1877                 fieldLabel : _this._strings['c70952e4ab3806c049737cd7d2b8896b'] /* Interests */,
1878                 forceSelection : true,
1879                 listWidth : 400,
1880                 minChars : 2,
1881                 queryParam : 'query[name]',
1882                 selectOnFocus : true,
1883                 tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{display_name}</b> </div>',
1884                 triggerAction : 'all',
1885                 valueField : 'id',
1886                 width : 285,
1887                 xns : Roo.form,
1888                 '|xns' : 'Roo.form',
1889                 store : {
1890                  xtype : 'Store',
1891                  remoteSort : true,
1892                  sortInfo : { direction : 'ASC', field: 'name' },
1893                  listeners : {
1894                   beforeload : function (_self, o){
1895                        o.params = o.params || {};
1896                        o.params.etype = 'crm_interest';
1897                    }
1898                  },
1899                  xns : Roo.data,
1900                  '|xns' : 'Roo.data',
1901                  proxy : {
1902                   xtype : 'HttpProxy',
1903                   method : 'GET',
1904                   url : baseURL + '/Roo/Core_enum.php',
1905                   xns : Roo.data,
1906                   '|xns' : 'Roo.data'
1907                  },
1908                  reader : {
1909                   xtype : 'JsonReader',
1910                   fields : [
1911                       {"name":"id","type":"int"},
1912                       {"name":"name","type":"string"},
1913                       {"name":"display_name","type":"string"}
1914                   ],
1915                   id : 'id',
1916                   root : 'data',
1917                   totalProperty : 'total',
1918                   xns : Roo.data,
1919                   '|xns' : 'Roo.data'
1920                  }
1921                 }
1922                }
1923               }
1924              ]
1925             },
1926             {
1927              xtype : 'Hidden',
1928              name : 'id',
1929              xns : Roo.form,
1930              '|xns' : 'Roo.form'
1931             },
1932             {
1933              xtype : 'Hidden',
1934              name : 'is_system_page',
1935              xns : Roo.form,
1936              '|xns' : 'Roo.form'
1937             },
1938             {
1939              xtype : 'Hidden',
1940              name : 'is_menuitem',
1941              xns : Roo.form,
1942              '|xns' : 'Roo.form'
1943             },
1944             {
1945              xtype : 'Hidden',
1946              name : 'page_type_id_name',
1947              xns : Roo.form,
1948              '|xns' : 'Roo.form'
1949             },
1950             {
1951              xtype : 'Column',
1952              listeners : {
1953               render : function (_self)
1954                {
1955                    _this.user_defined_fields = _self;
1956                }
1957              },
1958              xns : Roo.form,
1959              '|xns' : 'Roo.form'
1960             }
1961            ]
1962           }
1963          ]
1964         },
1965         {
1966          xtype : 'ContentPanel',
1967          background : false,
1968          fitContainer : true,
1969          fitToFrame : true,
1970          region : 'south',
1971          title : _this._strings['c1df1da7a1ce305a3b60af9d5733ac1d'] /* Contents */,
1972          xns : Roo,
1973          '|xns' : 'Roo',
1974          items  : [
1975           {
1976            xtype : 'Form',
1977            labelAlign : 'top',
1978            labelWidth : 80,
1979            method : 'POST',
1980            url : baseURL + '/Roo/cms_page.php',
1981            listeners : {
1982             rendered : function (form)
1983              {
1984                  _this.form1 = form;
1985              }
1986            },
1987            xns : Roo.form,
1988            '|xns' : 'Roo.form',
1989            items  : [
1990             {
1991              xtype : 'Row',
1992              hideLabels : true,
1993              xns : Roo.form,
1994              '|xns' : 'Roo.form',
1995              items  : [
1996               {
1997                xtype : 'HtmlEditor',
1998                autosave : function() {
1999                    
2000                    var body = _this.form1.findField('body');
2001                    
2002                    if(!body.wrap.isVisible(true) || body.getValue() == '' || !body.isDirty()){
2003                        Roo.log('body not dirty');
2004                        return;
2005                    }
2006                    
2007                    Roo.log('body dirty, auto save!');
2008                    
2009                    body.fireEvent('autosave', body);
2010                        
2011                   
2012                },
2013                fieldLabel : _this._strings['c1df1da7a1ce305a3b60af9d5733ac1d'] /* Contents */,
2014                height : 150,
2015                name : 'body',
2016                resizable : 's',
2017                white : [ 'iframe' ],
2018                width : 550,
2019                listeners : {
2020                 autosave : function (_self)
2021                  {
2022                      Roo.log('autosave');
2023                      
2024                      var id = _this.form.findField('id').getValue() * 1;
2025                      /*
2026                      if(!_self.editorcore.sourceEditMode){
2027                          _self.syncValue();
2028                      }else{
2029                          _self.pushValue();
2030                      }
2031                      */
2032                      new Pman.Request({
2033                          url : baseURL + '/Roo/Events.php',
2034                          method :'POST',
2035                          params : {
2036                              id : 0,
2037                              action : 'AUTOSAVE',
2038                              on_id : (id > 0) ? id : 0,
2039                              on_table : 'cms_page',
2040                              remarks : 'BODY',
2041                              source: _self.getValue()
2042                          },
2043                          success : function() {
2044                              _self.originalValue = _self.getValue();
2045                              
2046                          },
2047                          failure : function() 
2048                          {
2049                              //Roo.MessageBox.alert("Error", "autosave failed");
2050                              Roo.log('body autosave failed?!');
2051                          }
2052                      });
2053                      
2054                  },
2055                 savedpreview : function (_self)
2056                  {
2057                      Roo.log('saved preview');
2058                      
2059                      var id = _this.form.findField('id').getValue() * 1;
2060                      
2061                      var successFn = function(res){
2062                          return res.data.POST.source;
2063                      };
2064                      
2065                      var params = {
2066                          action : 'AUTOSAVE',
2067                          remarks : 'BODY',
2068                          on_id : (id < 1) ? 0 : id,
2069                          on_table : 'cms_page',
2070                          successFn : successFn
2071                      };
2072                      
2073                      
2074                      Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
2075                          _self.setValue(res);
2076                          _self.originalValue = res;
2077                      });
2078                  },
2079                 stylesheetsclick : function (_self)
2080                  {
2081                      Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
2082                          _this.dialog.setStylesheets();
2083                      })
2084                      
2085                  }
2086                },
2087                xns : Roo.form,
2088                '|xns' : 'Roo.form',
2089                toolbars : [
2090                 {
2091                  xtype : 'ToolbarStandard',
2092                  xns : Roo.form.HtmlEditor,
2093                  '|xns' : 'Roo.form.HtmlEditor',
2094                  btns : [
2095                   {
2096                    xtype : 'ComboBox',
2097                    alwaysQuery : true,
2098                    displayField : 'name',
2099                    editable : false,
2100                    emptyText : _this._strings['b9c49611cfda3259a2b837b39489e650'] /* Add Image */,
2101                    fieldLabel : _this._strings['fff0d600f8a0b5e19e88bfb821dd1157'] /* Images */,
2102                    forceSelection : true,
2103                    listWidth : 400,
2104                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
2105                    minChars : 2,
2106                    pageSize : 20,
2107                    qtip : _this._strings['2f26e35d61be90501e099089dc533638'] /* Select Images */,
2108                    queryParam : 'search',
2109                    selectOnFocus : true,
2110                    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>',
2111                    triggerAction : 'all',
2112                    typeAhead : true,
2113                    valueField : 'id',
2114                    width : 100,
2115                    listeners : {
2116                     beforequery : function (combo, query, forceAll, cancel, e)
2117                      {
2118                       
2119                          var id = _this.form.findField('id').getValue() * 1;    
2120                          if (!id) {
2121                              Roo.MessageBox.alert("Error", "Save Document First before adding images");
2122                              return false;
2123                          }
2124                      },
2125                     render : function (_self)
2126                      {
2127                          _this.bodyimgselect = _self;
2128                      },
2129                     select : function (combo, record, index)
2130                      {
2131                          Roo.log(record);
2132                          (function() { 
2133                              combo.setValue('');
2134                          }).defer(100);
2135                          
2136                          var editor = _this.form.findField('body').editorcore;
2137                          
2138                          var curnode = editor.getSelectedNode();
2139                          
2140                          if (curnode && curnode.tagName == 'IMG') {
2141                              curnode.src= String.format('{0}/Images/{1}/{2}#attachment-{1}',
2142                                      baseURL,  record.data.id, record.data.filename
2143                                  );
2144                                  // note -forces an update... hopefully...
2145                              editor.owner.fireEvent('editorevent', editor, false);
2146                          } else {
2147                          
2148                              editor.insertAtCursor(
2149                                  String.format('<img src="{0}/Images/{1}/{2}#attachment-{1}">',
2150                                  baseURL,  record.data.id, record.data.filename
2151                                  )
2152                              );
2153                      
2154                          }
2155                          
2156                      }
2157                    },
2158                    xns : Roo.form,
2159                    '|xns' : 'Roo.form',
2160                    store : {
2161                     xtype : 'Store',
2162                     remoteSort : true,
2163                     sortInfo : { direction : 'ASC', field: 'id' },
2164                     listeners : {
2165                      beforeload : function (_self, o){
2166                           o.params = o.params || {};
2167                       
2168                           var id = _this.form.findField('id').getValue() * 1;    
2169                           if (!id) {
2170                               Roo.MessageBox.alert("Error", "Save press release first");
2171                               return false;
2172                           }
2173                           o.params.onid = id;
2174                           o.params.ontable = 'cms_page';
2175                          // o.params.imgtype = 'PressRelease';
2176                           //o.params['query[imagesize]'] = '150x150';
2177                           // set more here
2178                       }
2179                     },
2180                     xns : Roo.data,
2181                     '|xns' : 'Roo.data',
2182                     proxy : {
2183                      xtype : 'HttpProxy',
2184                      method : 'GET',
2185                      url : baseURL + '/Roo/Images.php',
2186                      xns : Roo.data,
2187                      '|xns' : 'Roo.data'
2188                     },
2189                     reader : {
2190                      xtype : 'JsonReader',
2191                      fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}],
2192                      id : 'id',
2193                      root : 'data',
2194                      totalProperty : 'total',
2195                      xns : Roo.data,
2196                      '|xns' : 'Roo.data'
2197                     }
2198                    }
2199                   },
2200                   {
2201                    xtype : 'ComboBox',
2202                    allowBlank : true,
2203                    displayField : 'page_link',
2204                    editable : true,
2205                    emptyText : _this._strings['580b21aac58f1b73cece26e272cdfbee'] /* Add Link */,
2206                    forceSelection : true,
2207                    hiddenName : 'add_link_id',
2208                    listWidth : 200,
2209                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
2210                    minChars : 2,
2211                    name : 'add_link',
2212                    pageSize : 40,
2213                    qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
2214                    selectOnFocus : true,
2215                    tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
2216                    triggerAction : 'all',
2217                    typeAhead : true,
2218                    valueField : 'id',
2219                    width : 100,
2220                    listeners : {
2221                     select : function (combo, record, index)
2222                      {
2223                          Roo.log(record);
2224                          (function() { 
2225                              combo.setValue('');
2226                          }).defer(100);
2227                          var editor = _this.form.findField('body');
2228                          editor.editorcore.insertAtCursor(
2229                                  String.format('<a href="#page-{0}">{1}</a>',
2230                                  record.data.page_link,  record.data.title
2231                                  )
2232                           );
2233                      
2234                          
2235                       }
2236                    },
2237                    xns : Roo.form,
2238                    '|xns' : 'Roo.form',
2239                    store : {
2240                     xtype : 'Store',
2241                     remoteSort : true,
2242                     sortInfo : { field: 'page_link', direction: 'ASC' },
2243                     listeners : {
2244                      beforeload : function (_self, options)
2245                       {
2246                            options.params['search[page_link_no_empty]'] =1;
2247                            /*
2248                            options.params.is_element = 0;
2249                            options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     
2250                            */
2251                       }
2252                     },
2253                     xns : Roo.data,
2254                     '|xns' : 'Roo.data',
2255                     proxy : {
2256                      xtype : 'HttpProxy',
2257                      method : 'GET',
2258                      url : baseURL + '/Roo/cms_page.php',
2259                      xns : Roo.data,
2260                      '|xns' : 'Roo.data'
2261                     },
2262                     reader : {
2263                      xtype : 'JsonReader',
2264                      fields : [
2265                       { name: 'id', type: 'int' },
2266                       'title',
2267                       'page_link' 
2268                      ],
2269                      id : 'id',
2270                      root : 'data',
2271                      totalProperty : 'total',
2272                      xns : Roo.data,
2273                      '|xns' : 'Roo.data'
2274                     }
2275                    }
2276                   },
2277                   {
2278                    xtype : 'Separator',
2279                    xns : Roo.Toolbar,
2280                    '|xns' : 'Roo.Toolbar'
2281                   },
2282                   {
2283                    xtype : 'Button',
2284                    cls : 'x-init-enable',
2285                    text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
2286                    listeners : {
2287                     click : function (_self, e)
2288                      {
2289                          this.scope.owner.fireEvent('savedpreview', this.scope.owner);
2290                      }
2291                    },
2292                    xns : Roo.Toolbar,
2293                    '|xns' : 'Roo.Toolbar'
2294                   }
2295                  ]
2296                 },
2297                 {
2298                  xtype : 'ToolbarContext',
2299                  xns : Roo.form.HtmlEditor,
2300                  '|xns' : 'Roo.form.HtmlEditor'
2301                 }
2302                ]
2303               }
2304              ]
2305             }
2306            ]
2307           }
2308          ]
2309         },
2310         {
2311          xtype : 'ContentPanel',
2312          background : false,
2313          fitContainer : true,
2314          fitToFrame : true,
2315          region : 'south',
2316          title : _this._strings['76eb64a1725ee953c664e15c9213b2fd'] /* Extended Content */,
2317          xns : Roo,
2318          '|xns' : 'Roo',
2319          items  : [
2320           {
2321            xtype : 'Form',
2322            labelAlign : 'top',
2323            labelWidth : 80,
2324            method : 'POST',
2325            url : baseURL + '/Roo/cms_page.php',
2326            listeners : {
2327             rendered : function (form)
2328              {
2329                  _this.form2 = form;
2330              }
2331            },
2332            xns : Roo.form,
2333            '|xns' : 'Roo.form',
2334            items  : [
2335             {
2336              xtype : 'Row',
2337              hideLabels : true,
2338              xns : Roo.form,
2339              '|xns' : 'Roo.form',
2340              items  : [
2341               {
2342                xtype : 'HtmlEditor',
2343                autosave : function() {
2344                    
2345                    var extended = _this.form2.findField('extended');
2346                    
2347                    if(!extended.wrap.isVisible(true) || extended.getValue() == '' || !extended.isDirty()){
2348                        Roo.log('extend not dirty');
2349                        return;
2350                    }
2351                
2352                    
2353                    Roo.log('extend dirty, auto save!');
2354                    
2355                    extended.fireEvent('autosave', extended);
2356                },
2357                fieldLabel : _this._strings['57e195426892c5515935f21d97228814'] /* Extended Contents */,
2358                height : 150,
2359                name : 'extended',
2360                resizable : 's',
2361                white : [ 'iframe' ],
2362                width : 550,
2363                listeners : {
2364                 autosave : function (_self)
2365                  {
2366                      var id = _this.form.findField('id').getValue() * 1;
2367                      
2368                      /*
2369                      if(!_self.editorcore.sourceEditMode){
2370                          _self.syncValue();
2371                      }else{
2372                          _self.pushValue();
2373                      }
2374                      */
2375                      new Pman.Request({
2376                          url : baseURL + '/Roo/Events.php',
2377                          method :'POST',
2378                          params : {
2379                              id : 0,
2380                              action : 'AUTOSAVE',
2381                              on_id : (id > 0) ? id : 0,
2382                              on_table : 'cms_page',
2383                              remarks : 'EXTENDED',
2384                              source: _self.getValue()
2385                          },
2386                          success : function() {
2387                              _self.originalValue = _self.getValue();
2388                              
2389                          },
2390                          failure : function() 
2391                          {
2392                              //Roo.MessageBox.alert("Error", "autosave failed");
2393                              Roo.log('extended autosave failed?!');
2394                          }
2395                      });
2396                  },
2397                 savedpreview : function (_self)
2398                  {
2399                      var id = _this.form.findField('id').getValue() * 1;
2400                      
2401                      var successFn = function(res){
2402                          return res.data.POST.source;
2403                      };
2404                      
2405                      var params = {
2406                          action : 'AUTOSAVE',
2407                          remarks : 'EXTENDED',
2408                          on_id : (id < 1) ? 0 : id,
2409                          on_table : 'cms_page',
2410                          successFn : successFn
2411                      };
2412                      
2413                      
2414                      Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
2415                          _self.setValue(res);
2416                          _self.originalValue = res;
2417                      });
2418                  },
2419                 stylesheetsclick : function (_self)
2420                  {
2421                      Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
2422                          _this.dialog.setStylesheets();
2423                      })
2424                      
2425                  }
2426                },
2427                xns : Roo.form,
2428                '|xns' : 'Roo.form',
2429                toolbars : [
2430                 {
2431                  xtype : 'ToolbarStandard',
2432                  xns : Roo.form.HtmlEditor,
2433                  '|xns' : 'Roo.form.HtmlEditor',
2434                  btns : [
2435                   {
2436                    xtype : 'ComboBox',
2437                    alwaysQuery : true,
2438                    displayField : 'name',
2439                    editable : false,
2440                    emptyText : _this._strings['b9c49611cfda3259a2b837b39489e650'] /* Add Image */,
2441                    fieldLabel : _this._strings['fff0d600f8a0b5e19e88bfb821dd1157'] /* Images */,
2442                    forceSelection : true,
2443                    listWidth : 400,
2444                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
2445                    minChars : 2,
2446                    pageSize : 20,
2447                    qtip : _this._strings['2f26e35d61be90501e099089dc533638'] /* Select Images */,
2448                    selectOnFocus : true,
2449                    tpl : '<div class=\"x-grid-cell-text x-btn button\"><img src=\"{url_thumb}\" height=\"150\" width=\"150\"><b>{filename}</b> </div>',
2450                    triggerAction : 'all',
2451                    typeAhead : true,
2452                    valueField : 'id',
2453                    width : 100,
2454                    listeners : {
2455                     beforequery : function (combo, query, forceAll, cancel, e)
2456                      {
2457                       
2458                          var id = _this.form.findField('id').getValue() * 1;    
2459                          if (!id) {
2460                              Roo.MessageBox.alert("Error", "Save Document First before adding images");
2461                              return false;
2462                          }
2463                      },
2464                     render : function (_self)
2465                      {
2466                          _this.extendimgselect = _self;
2467                      },
2468                     select : function (combo, record, index)
2469                      {
2470                          Roo.log(record);
2471                          (function() { 
2472                              combo.setValue('');
2473                          }).defer(100);
2474                          
2475                          var editor = _this.form.findField('extended').editorcore;
2476                          
2477                          var curnode = editor.getSelectedNode();
2478                          
2479                          if (curnode && curnode.tagName == 'IMG') {
2480                              curnode.src= String.format('{0}/Images/{1}/{2}#image-{1}',
2481                                      baseURL,  record.data.id, record.data.filename
2482                                  );
2483                                  // note -forces an update... hopefully...
2484                              editor.owner.fireEvent('editorevent', editor, false);
2485                          } else {
2486                          
2487                              editor.insertAtCursor(
2488                                  String.format('<img src="{0}/Images/{1}/{2}#image-{1}">',
2489                                  baseURL,  record.data.id, record.data.filename
2490                                  )
2491                              );
2492                      
2493                          }
2494                          
2495                      }
2496                    },
2497                    xns : Roo.form,
2498                    '|xns' : 'Roo.form',
2499                    store : {
2500                     xtype : 'Store',
2501                     remoteSort : true,
2502                     sortInfo : { direction : 'ASC', field: 'id' },
2503                     listeners : {
2504                      beforeload : function (_self, o){
2505                           o.params = o.params || {};
2506                       
2507                           var id = _this.form.findField('id').getValue() * 1;    
2508                           if (!id) {
2509                               Roo.MessageBox.alert("Error", "Save press release first");
2510                               return false;
2511                           }
2512                           o.params.onid = id;
2513                           o.params.ontable = 'cms_page';
2514                          // o.params.imgtype = 'PressRelease';
2515                           //o.params['query[imagesize]'] = '150x150';
2516                           // set more here
2517                       }
2518                     },
2519                     xns : Roo.data,
2520                     '|xns' : 'Roo.data',
2521                     proxy : {
2522                      xtype : 'HttpProxy',
2523                      method : 'GET',
2524                      url : baseURL + '/Roo/Images.php',
2525                      xns : Roo.data,
2526                      '|xns' : 'Roo.data'
2527                     },
2528                     reader : {
2529                      xtype : 'JsonReader',
2530                      fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}],
2531                      id : 'id',
2532                      root : 'data',
2533                      totalProperty : 'total',
2534                      xns : Roo.data,
2535                      '|xns' : 'Roo.data'
2536                     }
2537                    }
2538                   },
2539                   {
2540                    xtype : 'ComboBox',
2541                    allowBlank : true,
2542                    displayField : 'page_link',
2543                    editable : true,
2544                    emptyText : _this._strings['580b21aac58f1b73cece26e272cdfbee'] /* Add Link */,
2545                    forceSelection : true,
2546                    hiddenName : 'add_link_id',
2547                    listWidth : 200,
2548                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
2549                    minChars : 2,
2550                    name : 'add_link',
2551                    pageSize : 40,
2552                    qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
2553                    selectOnFocus : true,
2554                    tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
2555                    triggerAction : 'all',
2556                    typeAhead : true,
2557                    valueField : 'id',
2558                    width : 100,
2559                    listeners : {
2560                     select : function (combo, record, index)
2561                      {
2562                          Roo.log(record);
2563                          (function() { 
2564                              combo.setValue('');
2565                          }).defer(100);
2566                          var editor = _this.form.findField('body');
2567                          editor.editorcore.insertAtCursor(
2568                                  String.format('<a href="#page-{0}">{1}</a>',
2569                                  record.data.page_link,  record.data.title
2570                                  )
2571                           );
2572                      
2573                          
2574                       }
2575                    },
2576                    xns : Roo.form,
2577                    '|xns' : 'Roo.form',
2578                    store : {
2579                     xtype : 'Store',
2580                     remoteSort : true,
2581                     sortInfo : { field: 'page_link', direction: 'ASC' },
2582                     listeners : {
2583                      beforeload : function (_self, options)
2584                       {
2585                            options.params['search[page_link_no_empty]'] =1;
2586                            /*
2587                            options.params.is_element = 0;
2588                            options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     
2589                            */
2590                       }
2591                     },
2592                     xns : Roo.data,
2593                     '|xns' : 'Roo.data',
2594                     proxy : {
2595                      xtype : 'HttpProxy',
2596                      method : 'GET',
2597                      url : baseURL + '/Roo/cms_page.php',
2598                      xns : Roo.data,
2599                      '|xns' : 'Roo.data'
2600                     },
2601                     reader : {
2602                      xtype : 'JsonReader',
2603                      fields : [
2604                       { name: 'id', type: 'int' },
2605                       'title',
2606                       'page_link' 
2607                      ],
2608                      id : 'id',
2609                      root : 'data',
2610                      totalProperty : 'total',
2611                      xns : Roo.data,
2612                      '|xns' : 'Roo.data'
2613                     }
2614                    }
2615                   },
2616                   {
2617                    xtype : 'Separator',
2618                    xns : Roo.Toolbar,
2619                    '|xns' : 'Roo.Toolbar'
2620                   },
2621                   {
2622                    xtype : 'Button',
2623                    text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
2624                    listeners : {
2625                     click : function (_self, e)
2626                      {
2627                          this.scope.owner.fireEvent('savedpreview', this.scope.owner);
2628                      }
2629                    },
2630                    xns : Roo.Toolbar,
2631                    '|xns' : 'Roo.Toolbar'
2632                   }
2633                  ]
2634                 },
2635                 {
2636                  xtype : 'ToolbarContext',
2637                  styles : typeof(uiConfig) != 'undefined' ? (uiConfig['Roo.form.HtmlEditor.ToolbarContext.styles'] || {}) : {},
2638                  xns : Roo.form.HtmlEditor,
2639                  '|xns' : 'Roo.form.HtmlEditor'
2640                 }
2641                ]
2642               }
2643              ]
2644             }
2645            ]
2646           }
2647          ]
2648         },
2649         {
2650          xtype : 'ContentPanel',
2651          background : false,
2652          fitContainer : true,
2653          fitToFrame : true,
2654          region : 'south',
2655          title : _this._strings['d8e4d1f5e445107e505b2cf63a1fb65c'] /* Extra CSS */,
2656          xns : Roo,
2657          '|xns' : 'Roo',
2658          items  : [
2659           {
2660            xtype : 'Form',
2661            labelAlign : 'top',
2662            labelWidth : 80,
2663            method : 'POST',
2664            url : baseURL + '/Roo/cms_page.php',
2665            listeners : {
2666             rendered : function (form)
2667              {
2668                  _this.form3 = form;
2669              }
2670            },
2671            xns : Roo.form,
2672            '|xns' : 'Roo.form',
2673            items  : [
2674             {
2675              xtype : 'Row',
2676              hideLabels : true,
2677              xns : Roo.form,
2678              '|xns' : 'Roo.form',
2679              items  : [
2680               {
2681                xtype : 'TextArea',
2682                fieldLabel : _this._strings['39f64cc9436cacfbceda3b7bdeb8e24c'] /* Styles (CSS) */,
2683                height : 200,
2684                name : 'extra_css',
2685                width : 700,
2686                xns : Roo.form,
2687                '|xns' : 'Roo.form'
2688               }
2689              ]
2690             }
2691            ]
2692           }
2693          ]
2694         },
2695         {
2696          xtype : 'ContentPanel',
2697          background : false,
2698          fitContainer : true,
2699          fitToFrame : true,
2700          region : 'south',
2701          title : _this._strings['98e93e8f7adfe14832db6caed713d849'] /* Meta Tags */,
2702          xns : Roo,
2703          '|xns' : 'Roo',
2704          items  : [
2705           {
2706            xtype : 'Form',
2707            labelAlign : 'top',
2708            labelWidth : 80,
2709            method : 'POST',
2710            url : baseURL + '/Roo/cms_page.php',
2711            listeners : {
2712             rendered : function (form)
2713              {
2714                  _this.form4 = form;
2715              }
2716            },
2717            xns : Roo.form,
2718            '|xns' : 'Roo.form',
2719            items  : [
2720             {
2721              xtype : 'Row',
2722              xns : Roo.form,
2723              '|xns' : 'Roo.form',
2724              items  : [
2725               {
2726                xtype : 'TextArea',
2727                fieldLabel : _this._strings['867343577fa1f33caa632a19543bd252'] /* Keywords */,
2728                height : 100,
2729                name : 'keywords',
2730                width : 340,
2731                xns : Roo.form,
2732                '|xns' : 'Roo.form'
2733               },
2734               {
2735                xtype : 'TextArea',
2736                fieldLabel : _this._strings['8bc84316c4078bf66723fd019616d920'] /* Descriptions */,
2737                height : 100,
2738                name : 'descriptions',
2739                width : 340,
2740                xns : Roo.form,
2741                '|xns' : 'Roo.form'
2742               }
2743              ]
2744             }
2745            ]
2746           }
2747          ]
2748         }
2749        ]
2750       }
2751      },
2752      {
2753       xtype : 'GridPanel',
2754       background : false,
2755       fitContainer : true,
2756       fitToframe : true,
2757       region : 'east',
2758       tableName : 'Images',
2759       title : _this._strings['308f2757bfc9ce92fb00ff93fdffd279'] /* Images / Attachments */,
2760       listeners : {
2761        activate : function() {
2762             _this.panel = this;
2763             if (_this.grid) {
2764                 _this.grid.footer.onClick('first');
2765             }
2766         }
2767       },
2768       xns : Roo,
2769       '|xns' : 'Roo',
2770       grid : {
2771        xtype : 'EditorGrid',
2772        autoExpandColumn : 'title',
2773        clicksToEdit : 1,
2774        loadMask : true,
2775        listeners : {
2776         render : function() { 
2777              _this.grid = this; 
2778              //_this.dialog = Pman.Dialog.FILL_IN
2779              if (_this.panel.active) {
2780                 //this.footer.onClick('first');
2781              }
2782          },
2783         rowdblclick : function (_self, rowIndex, e)
2784          {
2785              var rd = _this.grid.getDataSource().getAt(rowIndex);
2786              var id = rd.data.id;
2787              var url = String.format('{0}/Images/{1}/{2}', baseURL, rd.data.id, rd.data.filename);
2788              _this.form.findField('contents').execCmd('insertimage', url);
2789          
2790          }
2791        },
2792        xns : Roo.grid,
2793        '|xns' : 'Roo.grid',
2794        toolbar : {
2795         xtype : 'Toolbar',
2796         xns : Roo,
2797         '|xns' : 'Roo',
2798         items  : [
2799          {
2800           xtype : 'Button',
2801           cls : 'x-btn-text-icon',
2802           icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
2803           text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
2804           listeners : {
2805            click : function()
2806             {
2807                 var id = _this.form.findField('id').getValue() * 1;
2808                 
2809                 if(id < 1){
2810                     return;
2811                 }
2812                 
2813                 Pman.Dialog.Image.show( { id : 0, onid : id, ontable: 'cms_page' }, function() {
2814                     _this.grid.ds.load({});
2815                 }); 
2816             
2817             }
2818           },
2819           xns : Roo,
2820           '|xns' : 'Roo'
2821          },
2822          {
2823           xtype : 'Button',
2824           cls : 'x-btn-text-icon',
2825           icon : rootURL + '/Pman/templates/images/trash.gif',
2826           text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
2827           listeners : {
2828            click : function()
2829             {
2830                 var selection = _this.grid.getSelectionModel().getSelectedCell();
2831                 var sn = _this.grid.ds.getAt(selection[0]);
2832                 if (!sn || isNaN(sn.id *1)) {
2833                     Roo.MessageBox.alert("Error", "Select a image"); 
2834                     return;
2835                 }
2836                 Roo.MessageBox.confirm("Confirm", "Are sure you want to delete this image?", function (v){
2837                     if (v != 'yes') {
2838                         return;
2839                     }
2840                     
2841                     new Pman.Request({
2842                         url : baseURL + '/Roo/Images.php',
2843                         method: 'POST',
2844                         params : {
2845                             _delete : sn.id
2846                         },
2847                         success : function()
2848                         {
2849                             Roo.log('Got Success!!');
2850                            _this.grid.ds.load({});
2851                         }
2852                     });
2853                 });
2854             }
2855           },
2856           xns : Roo,
2857           '|xns' : 'Roo'
2858          }
2859         ]
2860        },
2861        dataSource : {
2862         xtype : 'Store',
2863         listeners : {
2864          beforeload : function (_self, o)
2865           {
2866               var id = _this.form.findField('id').getValue() * 1;
2867           
2868               if (id < 1) {
2869                   this.removeAll();
2870                   return false;
2871               } 
2872               o.params = o.params || {};    
2873               o.params.limit = 9999;          
2874               o.params.onid = id;
2875               o.params.ontable = 'cms_page';
2876           },
2877          update : function (_self, rec, operation)
2878           {
2879               
2880               new Pman.Request({
2881                   url : baseURL+'/Roo/Images.php',
2882                   method : 'POST',
2883                   params : rec.data,
2884                   success: function(res)
2885                   {
2886                       Roo.log("GOT success");
2887                       // update the data...
2888                       _this.grid.ds.load({});
2889                   },
2890                   failure : function(res)
2891                   {
2892                       Roo.MessageBox.alert('Error', res.errorMsg);
2893                       _this.grid.ds.load({});
2894                   }
2895                   
2896                   
2897               });
2898           }
2899         },
2900         xns : Roo.data,
2901         '|xns' : 'Roo.data',
2902         proxy : {
2903          xtype : 'HttpProxy',
2904          method : 'GET',
2905          url : baseURL + '/Roo/Images.php',
2906          xns : Roo.data,
2907          '|xns' : 'Roo.data'
2908         },
2909         reader : {
2910          xtype : 'JsonReader',
2911          fields : [
2912              {
2913                  'name': 'id',
2914                  'type': 'int'
2915              },
2916              {
2917                  'name': 'filename',
2918                  'type': 'string'
2919              },
2920              {
2921                  'name': 'ontable',
2922                  'type': 'string'
2923              },
2924              {
2925                  'name': 'onid',
2926                  'type': 'int'
2927              },
2928              {
2929                  'name': 'mimetype',
2930                  'type': 'string'
2931              },
2932              {
2933                  'name': 'width',
2934                  'type': 'int'
2935              },
2936              {
2937                  'name': 'height',
2938                  'type': 'int'
2939              },
2940              {
2941                  'name': 'filesize',
2942                  'type': 'int'
2943              },
2944              {
2945                  'name': 'displayorder',
2946                  'type': 'int'
2947              },
2948              {
2949                  'name': 'language',
2950                  'type': 'string'
2951              },
2952              {
2953                  'name': 'parent_image_id',
2954                  'type': 'int'
2955              },
2956              {
2957                  'name': 'created',
2958                  'type': 'date',
2959                  'dateFormat': 'Y-m-d'
2960              },
2961              {
2962                  'name': 'imgtype',
2963                  'type': 'string'
2964              },
2965              {
2966                  'name': 'linkurl',
2967                  'type': 'string'
2968              },
2969              {
2970                  'name': 'descript',
2971                  'type': 'string'
2972              },
2973              {
2974                  'name': 'title',
2975                  'type': 'string'
2976              },
2977              {
2978                  'name': 'parent_image_id_id',
2979                  'type': 'int'
2980              },
2981              {
2982                  'name': 'parent_image_id_filename',
2983                  'type': 'string'
2984              },
2985              {
2986                  'name': 'parent_image_id_ontable',
2987                  'type': 'string'
2988              },
2989              {
2990                  'name': 'parent_image_id_onid',
2991                  'type': 'int'
2992              },
2993              {
2994                  'name': 'parent_image_id_mimetype',
2995                  'type': 'string'
2996              },
2997              {
2998                  'name': 'parent_image_id_width',
2999                  'type': 'int'
3000              },
3001              {
3002                  'name': 'parent_image_id_height',
3003                  'type': 'int'
3004              },
3005              {
3006                  'name': 'parent_image_id_filesize',
3007                  'type': 'int'
3008              },
3009              {
3010                  'name': 'parent_image_id_displayorder',
3011                  'type': 'int'
3012              },
3013              {
3014                  'name': 'parent_image_id_language',
3015                  'type': 'string'
3016              },
3017              {
3018                  'name': 'parent_image_id_parent_image_id',
3019                  'type': 'int'
3020              },
3021              {
3022                  'name': 'parent_image_id_created',
3023                  'type': 'date'
3024              },
3025              {
3026                  'name': 'parent_image_id_imgtype',
3027                  'type': 'string'
3028              },
3029              {
3030                  'name': 'parent_image_id_linkurl',
3031                  'type': 'string'
3032              },
3033              {
3034                  'name': 'parent_image_id_descript',
3035                  'type': 'string'
3036              },
3037              {
3038                  'name': 'parent_image_id_title',
3039                  'type': 'string'
3040              }
3041          ],
3042          id : 'id',
3043          root : 'data',
3044          totalProperty : 'total',
3045          xns : Roo.data,
3046          '|xns' : 'Roo.data'
3047         }
3048        },
3049        colModel : [
3050         {
3051          xtype : 'ColumnModel',
3052          dataIndex : 'id',
3053          header : _this._strings['d41d8cd98f00b204e9800998ecf8427e'] /*  */,
3054          renderer : function(v,x,r) { 
3055              return  String.format('<img src="{0}/Images/Thumb/100/{1}/{2}" height="100">', baseURL, v, r.data.filename); 
3056          },
3057          sortable : false,
3058          width : 75,
3059          xns : Roo.grid,
3060          '|xns' : 'Roo.grid'
3061         },
3062         {
3063          xtype : 'ColumnModel',
3064          dataIndex : 'filename',
3065          header : _this._strings['1351017ac6423911223bc19a8cb7c653'] /* Filename */,
3066          renderer : function(v) { return String.format('{0}', v); },
3067          width : 200,
3068          xns : Roo.grid,
3069          '|xns' : 'Roo.grid'
3070         },
3071         {
3072          xtype : 'ColumnModel',
3073          dataIndex : 'displayorder',
3074          header : _this._strings['a240fa27925a635b08dc28c9e4f9216d'] /* Order */,
3075          renderer : function(v) { return String.format('{0}', v); },
3076          width : 50,
3077          xns : Roo.grid,
3078          '|xns' : 'Roo.grid',
3079          editor : {
3080           xtype : 'GridEditor',
3081           xns : Roo.grid,
3082           '|xns' : 'Roo.grid',
3083           field : {
3084            xtype : 'NumberField',
3085            decimalPrecision : 0,
3086            listeners : {
3087             focus : function (_self)
3088              {
3089                  if (this.value == 0) {
3090                      this.el.dom.value = '';
3091                  }
3092              }
3093            },
3094            xns : Roo.form,
3095            '|xns' : 'Roo.form'
3096           }
3097          }
3098         },
3099         {
3100          xtype : 'ColumnModel',
3101          dataIndex : 'title',
3102          header : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
3103          renderer : function(v) { return String.format('{0}', v); },
3104          width : 100,
3105          xns : Roo.grid,
3106          '|xns' : 'Roo.grid',
3107          editor : {
3108           xtype : 'GridEditor',
3109           xns : Roo.grid,
3110           '|xns' : 'Roo.grid',
3111           field : {
3112            xtype : 'TextField',
3113            xns : Roo.form,
3114            '|xns' : 'Roo.form'
3115           }
3116          }
3117         },
3118         {
3119          xtype : 'ColumnModel',
3120          dataIndex : 'linkurl',
3121          header : _this._strings['e6b391a8d2c4d45902a23a8b6585703d'] /* URL */,
3122          renderer : function(v)
3123          {
3124              return String.format('{0}', (v) ? v : '');
3125          },
3126          width : 300,
3127          xns : Roo.grid,
3128          '|xns' : 'Roo.grid',
3129          editor : {
3130           xtype : 'GridEditor',
3131           xns : Roo.grid,
3132           '|xns' : 'Roo.grid',
3133           field : {
3134            xtype : 'TextField',
3135            xns : Roo.form,
3136            '|xns' : 'Roo.form'
3137           }
3138          }
3139         }
3140        ]
3141       }
3142      },
3143      {
3144       xtype : 'NestedLayoutPanel',
3145       background : false,
3146       fitContainer : true,
3147       fitToFrame : true,
3148       region : 'west',
3149       listeners : {
3150        render : function (_self)
3151         {
3152             _this.westLayoutPanel = this;
3153             
3154         }
3155       },
3156       xns : Roo,
3157       '|xns' : 'Roo',
3158       layout : {
3159        xtype : 'BorderLayout',
3160        xns : Roo,
3161        '|xns' : 'Roo',
3162        center : {
3163         xtype : 'LayoutRegion',
3164         tabPosition : 'top',
3165         xns : Roo,
3166         '|xns' : 'Roo'
3167        },
3168        south : {
3169         xtype : 'LayoutRegion',
3170         height : 250,
3171         split : true,
3172         tabPosition : 'top',
3173         xns : Roo,
3174         '|xns' : 'Roo'
3175        },
3176        items  : [
3177         {
3178          xtype : 'ContentPanel',
3179          autoScroll : true,
3180          fitToFrame : true,
3181          region : 'center',
3182          listeners : {
3183           render : function (_self)
3184            {
3185              _this.trpanel = _self;
3186            },
3187           resize : function (_self, width, height)
3188            {
3189                Roo.log('resize called');
3190                
3191                var ew = Math.max(250, width - 10);
3192                var eh = _this.westLayoutPanel.getLayout().getRegion('south').el.getHeight() - 30;
3193                
3194                
3195                if (!_this.trform) {
3196                    return;
3197                }
3198                
3199                var bd = _this.trform1.findField('body');
3200                
3201                if (bd.resizeEl) { 
3202                    bd.width = ew;
3203                    bd.height = eh;
3204                    // since render delays resize.. 
3205                    bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
3206                   // _this.trbodycol.el.setWidth(bd.width+20);
3207                }
3208                var bd = _this.trform2.findField('extended');
3209                if (bd.resizeEl) { 
3210                    bd.width = ew;
3211                    bd.height = eh;
3212                    // since render delays resize.. 
3213                    bd.resizeEl.resizeTo.defer(110, bd.resizeEl,[ bd.width, bd.height  ] );
3214                   // _this.trextendcol.el.setWidth(bd.width+20);
3215                }
3216            
3217            }
3218          },
3219          xns : Roo,
3220          '|xns' : 'Roo',
3221          items  : [
3222           {
3223            xtype : 'Form',
3224            labelAlign : 'right',
3225            labelWidth : 120,
3226            method : 'POST',
3227            showHide : function() {
3228            
3229              //  var in_rss= _this.form.findField('in_rss').getValue() * 1;
3230                var has_extended = _this.form.findField('has_extended').getValue() * 1;
3231                var has_lang = _this.trform.findField('language').getValue().length;
3232                
3233                _this.westLayoutPanel.getLayout().getRegion('south').show();
3234                _this.westLayoutPanel.getLayout().getRegion('south').unhidePanel(0);
3235                _this.westLayoutPanel.getLayout().getRegion('south').unhidePanel(1);
3236                _this.westLayoutPanel.getLayout().getRegion('south').unhidePanel(2);
3237                
3238                if(!has_lang){
3239                    _this.westLayoutPanel.getLayout().getRegion('south').hide();
3240                }
3241                
3242                if(!has_extended && has_lang){
3243                    _this.westLayoutPanel.getLayout().getRegion('south').hidePanel(1);
3244                    _this.westLayoutPanel.getLayout().getRegion('south').showPanel(0);
3245                }
3246                
3247                var vis = {
3248                    title : has_lang
3249                    
3250                };
3251                for(var k in vis) {
3252                    var el = _this.trform.findField(k);
3253                    el.actionMode = 'fieldEl';
3254                    if (    vis[k]) {
3255                        Roo.log("show: " + k);
3256                        el.show();
3257                    } else{ 
3258                        Roo.log("hide: " + k);
3259                        el.hide();
3260                    }
3261                }
3262            
3263                _this.updateRow.el[has_lang ? 'show' : 'hide']();
3264               
3265                
3266                if(typeof(_this.trform.editors) == 'undefined'){
3267                    _this.trform.editors = {
3268                        body : _this.trform1.findField('body').wrap.isVisible(),
3269                        extended : _this.trform2.findField('extended').wrap.isVisible()
3270                   };
3271                   if(_this.trform.editors.body){
3272                        setInterval(_this.trform1.findField('body').autosave, 60000);
3273                   }
3274                   
3275                   if(_this.trform.editors.extended){
3276                        setInterval(_this.trform2.findField('extended').autosave, 60000);
3277                   }
3278               }
3279               
3280               if(!_this.trform.editors.body && _this.trform1.findField('body').wrap.isVisible()){
3281                    setInterval(_this.trform1.findField('body').autosave, 60000);
3282                    _this.trform.editors.body = true;
3283               }
3284               
3285               if(!_this.trform.editors.extended && _this.trform2.findField('extended').wrap.isVisible()){
3286                    setInterval(_this.trform2.findField('extended').autosave, 60000);
3287                    _this.trform.editors.extended = true;
3288               }
3289                
3290                
3291            },
3292            style : 'margin: 5px',
3293            trackResetOnLoad : true,
3294            url : baseURL + '/Roo/cms_page.php',
3295            listeners : {
3296             actioncomplete : function (_self, action)
3297              {
3298                  if (action.type =='submit') {
3299                      return;
3300                  }
3301                  
3302                  if (action.type == 'setdata') {
3303                      _this.trform.addForm(_this.trform1);
3304                      _this.trform.addForm(_this.trform2);
3305                      _this.trform.addForm(_this.trform3);
3306                      
3307                      if ( _this.data.id) {
3308                          
3309                              this.load({ method: 'GET', params: { '_id' : _this.data.id }});
3310                      } else {
3311                          this.trpanel.el.mask("save first");
3312                      }
3313              
3314                     return;
3315                    
3316                  }
3317                  
3318                  if (action.type == 'load') {
3319              //        _this.dialog.el.unmask();
3320                      this.showHide();
3321                      
3322                      _this.trform1.findField('body').originalValue = _this.trform1.findField('body').getValue();
3323                     _this.trform2.findField('extended').originalValue = _this.trform2.findField('extended').getValue();
3324                     _this.trform3.findField('keywords').originalValue = _this.trform3.findField('keywords').getValue();
3325                     _this.trform3.findField('descriptions').originalValue = _this.trform3.findField('descriptions').getValue();
3326                      
3327                      return;
3328                  }
3329              },
3330             actionfailed : function (_self, action)
3331              {
3332                  _this.dialog.el.unmask();
3333               
3334                  Pman.standardActionFailed(_self, action);
3335              },
3336             rendered : function (_self)
3337              {
3338                  _this.trform = _self;
3339              }
3340            },
3341            xns : Roo.form,
3342            '|xns' : 'Roo.form',
3343            items  : [
3344             {
3345              xtype : 'Column',
3346              labelAlign : 'top',
3347              width : 500,
3348              xns : Roo.form,
3349              '|xns' : 'Roo.form',
3350              items  : [
3351               {
3352                xtype : 'Row',
3353                labelAlign : 'top',
3354                width : 400,
3355                xns : Roo.form,
3356                '|xns' : 'Roo.form',
3357                items  : [
3358                 {
3359                  xtype : 'ComboBox',
3360                  alwaysQuery : true,
3361                  displayField : 'language_name',
3362                  editable : false,
3363                  emptyText : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
3364                  fieldLabel : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
3365                  forceSelection : true,
3366                  hiddenName : 'language',
3367                  listWidth : 400,
3368                  loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
3369                  minChars : 2,
3370                  name : 'language_name',
3371                  pageSize : 20,
3372                  qtip : _this._strings['83dad8107f9459efe2b4fabcf5b63108'] /* Select Language */,
3373                  selectOnFocus : true,
3374                  tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{language_name}</b> </div>',
3375                  triggerAction : 'all',
3376                  typeAhead : false,
3377                  valueField : 'language',
3378                  listeners : {
3379                   add : function (combo)
3380                    {
3381                        Pman.Dialog.CmsLanguagePick.show({_with_name : true}, function( res) {
3382                           // Roo.log(res);
3383                           
3384                           _this.trform.reset();
3385                            _this.trform1.reset();
3386                            _this.trform2.reset();
3387                            
3388                            combo.setValue(res.lang);
3389                            combo.el.dom.value = res.lang_name;
3390                            (function() { 
3391                                
3392                                _this.trform.showHide();
3393                               _this.trpanel.fireEvent('resize', _this.trpanel, [ _this.trpanel.el.getWidth(), _this.trpanel.el.getHeight() ]  );
3394                           }).defer(100); 
3395                        });
3396                        
3397                    },
3398                   render : function (_self)
3399                    {
3400                        _this.language = _self;
3401                    },
3402                   select : function (combo, record, index)
3403                    {
3404                        (function() { 
3405                            _this.trform.showHide();
3406                           _this.trpanel.fireEvent('resize', _this.trpanel, [ _this.trpanel.el.getWidth(), _this.trpanel.el.getHeight() ]  );
3407                       }).defer(100); 
3408                        
3409                       _this.trform.load({
3410                        
3411                            method: 'GET', 
3412                            params: {
3413                                'lookup[language]' : record.data.language,
3414                                'lookup[translation_of_id]' : _this.data.id,
3415                                'lookup[_id]' : 1
3416                            }
3417                       });
3418                    }
3419                  },
3420                  xns : Roo.form,
3421                  '|xns' : 'Roo.form',
3422                  store : {
3423                   xtype : 'Store',
3424                   remoteSort : true,
3425                   sortInfo : { direction : 'ASC', field: 'language' },
3426                   listeners : {
3427                    beforeload : function (_self, o){
3428                         o.params = o.params || {};
3429                         
3430                         o.params._distinct = 'language';
3431                         o.params._columns ='language_name,language';
3432                         o.params._with_name = true;
3433                         
3434                         if(_this.form.findField('id').getValue()*1 > 0){
3435                             o.params.translation_of_id = _this.form.findField('id').getValue();
3436                         }
3437                         
3438                     }
3439                   },
3440                   xns : Roo.data,
3441                   '|xns' : 'Roo.data',
3442                   proxy : {
3443                    xtype : 'HttpProxy',
3444                    method : 'GET',
3445                    url : baseURL + '/Roo/Cms_page.php',
3446                    xns : Roo.data,
3447                    '|xns' : 'Roo.data'
3448                   },
3449                   reader : {
3450                    xtype : 'JsonReader',
3451                    fields : [{"name":"language","type":"string"}],
3452                    id : 'id',
3453                    root : 'data',
3454                    totalProperty : 'total',
3455                    xns : Roo.data,
3456                    '|xns' : 'Roo.data'
3457                   }
3458                  }
3459                 },
3460                 {
3461                  xtype : 'Row',
3462                  style : 'padding-top:12px;padding-left:30px;float:left',
3463                  width : 100,
3464                  listeners : {
3465                   render : function (_self)
3466                    {
3467                    _this.updateRow = _self;
3468                    }
3469                  },
3470                  xns : Roo.form,
3471                  '|xns' : 'Roo.form',
3472                  items  : [
3473                   {
3474                    xtype : 'Button',
3475                    text : _this._strings['06933067aafd48425d67bcb01bba5cb6'] /* Update */,
3476                    listeners : {
3477                     click : function()
3478                       {
3479                          //   _this.dialog.el.mask("Saving");
3480                          if(!_this.trform1.findField('body').editorcore.sourceEditMode){
3481                              _this.trform1.findField('body').syncValue(); 
3482                              _this.trform2.findField('extended').syncValue();
3483                          }else{
3484                              _this.trform1.findField('body').pushValue();
3485                              _this.trform2.findField('extended').pushValue();
3486                          }
3487                          
3488                          _this.trform.findField('parent_id').setValue(_this.form.findField('parent_id').getValue());
3489                          _this.trform.findField('element_id').setValue(_this.form.findField('element_id').getValue());
3490                          _this.trform.findField('translation_of_id').setValue(_this.form.findField('id').getValue());
3491                          _this.trform.findField('is_menuitem').setValue(_this.form.findField('is_menuitem').getValue());
3492                          _this.trform.findField('menu_page_id').setValue(_this.form.findField('menu_page_id').getValue());
3493                          
3494                          if(_this.trform.findField('element_id').getValue()*1 > 0){
3495                              _this.trform.findField('is_element').setValue(1);
3496                          }
3497                          
3498                          _this.trform.doAction("submit");
3499                      }
3500                    },
3501                    xns : Roo,
3502                    '|xns' : 'Roo'
3503                   }
3504                  ]
3505                 }
3506                ]
3507               },
3508               {
3509                xtype : 'TextField',
3510                fieldLabel : _this._strings['b78a3223503896721cca1303f776159b'] /* Title */,
3511                name : 'title',
3512                width : 400,
3513                xns : Roo.form,
3514                '|xns' : 'Roo.form'
3515               }
3516              ]
3517             },
3518             {
3519              xtype : 'Hidden',
3520              name : 'id',
3521              xns : Roo.form,
3522              '|xns' : 'Roo.form'
3523             },
3524             {
3525              xtype : 'Hidden',
3526              name : 'element_id',
3527              xns : Roo.form,
3528              '|xns' : 'Roo.form'
3529             },
3530             {
3531              xtype : 'Hidden',
3532              name : 'menu_page_id',
3533              xns : Roo.form,
3534              '|xns' : 'Roo.form'
3535             },
3536             {
3537              xtype : 'Hidden',
3538              name : 'is_menuitem',
3539              xns : Roo.form,
3540              '|xns' : 'Roo.form'
3541             },
3542             {
3543              xtype : 'Hidden',
3544              name : 'is_element',
3545              value : 0,
3546              xns : Roo.form,
3547              '|xns' : 'Roo.form'
3548             },
3549             {
3550              xtype : 'Hidden',
3551              name : 'translation_of_id',
3552              xns : Roo.form,
3553              '|xns' : 'Roo.form'
3554             },
3555             {
3556              xtype : 'Hidden',
3557              name : 'parent_id',
3558              xns : Roo.form,
3559              '|xns' : 'Roo.form'
3560             }
3561            ]
3562           }
3563          ]
3564         },
3565         {
3566          xtype : 'ContentPanel',
3567          background : false,
3568          fitContainer : true,
3569          fitToFrame : true,
3570          region : 'south',
3571          title : _this._strings['c1df1da7a1ce305a3b60af9d5733ac1d'] /* Contents */,
3572          xns : Roo,
3573          '|xns' : 'Roo',
3574          items  : [
3575           {
3576            xtype : 'Form',
3577            labelAlign : 'top',
3578            labelWidth : 80,
3579            method : 'POST',
3580            url : baseURL + '/Roo/cms_page.php',
3581            listeners : {
3582             rendered : function (form)
3583              {
3584                  _this.trform1 = form;
3585              }
3586            },
3587            xns : Roo.form,
3588            '|xns' : 'Roo.form',
3589            items  : [
3590             {
3591              xtype : 'Row',
3592              hideLabels : true,
3593              xns : Roo.form,
3594              '|xns' : 'Roo.form',
3595              items  : [
3596               {
3597                xtype : 'HtmlEditor',
3598                autosave : function() {
3599                    
3600                    var body = _this.trform1.findField('body');
3601                    
3602                    if(!body.wrap.isVisible(true) || body.getValue() == '' || !body.isDirty()){
3603                        Roo.log('tr body not dirty');
3604                        return;
3605                    }
3606                
3607                    Roo.log('tr body dirty, auto save!');
3608                    
3609                    body.fireEvent('autosave', body);
3610                },
3611                fieldLabel : _this._strings['c1df1da7a1ce305a3b60af9d5733ac1d'] /* Contents */,
3612                height : 140,
3613                name : 'body',
3614                resizable : 's',
3615                white : [ 'iframe' ],
3616                listeners : {
3617                 autosave : function (_self)
3618                  {
3619                      var id = _this.trform.findField('id').getValue() * 1;
3620                      
3621                      /*
3622                      if(!_self.editorcore.sourceEditMode){
3623                          _self.syncValue();
3624                      }else{
3625                          _self.pushValue();
3626                      }
3627                      */
3628                      new Pman.Request({
3629                          url : baseURL + '/Roo/Events.php',
3630                          method :'POST',
3631                          params : {
3632                              id : 0,
3633                              action : 'AUTOSAVE',
3634                              on_id : (id > 0) ? id : 0,
3635                              on_table : 'cms_page',
3636                              remarks : 'BODY',
3637                              source: _self.getValue()
3638                          },
3639                          success : function() {
3640                              _self.originalValue = _self.getValue();
3641                              
3642                          },
3643                          failure : function() 
3644                          {
3645                              //Roo.MessageBox.alert("Error", "autosave failed");
3646                              Roo.log('tr body autosave failed?!');
3647                          }
3648                      });
3649                  },
3650                 savedpreview : function (_self)
3651                  {
3652                      var id = _this.trform.findField('id').getValue() * 1;
3653                      
3654                      var successFn = function(res){
3655                          return res.data.POST.source;
3656                      };
3657                      
3658                      var params = {
3659                          action : 'AUTOSAVE',
3660                          remarks : 'BODY',
3661                          on_id : (id < 1) ? 0 : id,
3662                          on_table : 'cms_page',
3663                          successFn : successFn
3664                      };
3665                      
3666                      
3667                      Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
3668                          _self.setValue(res);
3669                          _self.originalValue = res;
3670                      });
3671                  },
3672                 stylesheetsclick : function (_self)
3673                  {
3674                      Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
3675                          _this.dialog.setStylesheets();
3676                      })
3677                      
3678                  }
3679                },
3680                xns : Roo.form,
3681                '|xns' : 'Roo.form',
3682                toolbars : [
3683                 {
3684                  xtype : 'ToolbarStandard',
3685                  xns : Roo.form.HtmlEditor,
3686                  '|xns' : 'Roo.form.HtmlEditor',
3687                  btns : [
3688                   {
3689                    xtype : 'ComboBox',
3690                    alwaysQuery : true,
3691                    displayField : 'name',
3692                    editable : false,
3693                    emptyText : _this._strings['b9c49611cfda3259a2b837b39489e650'] /* Add Image */,
3694                    fieldLabel : _this._strings['fff0d600f8a0b5e19e88bfb821dd1157'] /* Images */,
3695                    forceSelection : true,
3696                    listWidth : 400,
3697                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
3698                    minChars : 2,
3699                    pageSize : 20,
3700                    qtip : _this._strings['2f26e35d61be90501e099089dc533638'] /* Select Images */,
3701                    selectOnFocus : true,
3702                    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>',
3703                    triggerAction : 'all',
3704                    typeAhead : true,
3705                    valueField : 'id',
3706                    width : 100,
3707                    listeners : {
3708                     beforequery : function (combo, query, forceAll, cancel, e)
3709                      {
3710                       
3711                          var id = _this.form.findField('id').getValue() * 1;    
3712                          if (!id) {
3713                              Roo.MessageBox.alert("Error", "Save press release first");
3714                              return false;
3715                          }
3716                      },
3717                     render : function (_self)
3718                      {
3719                          _this.trbodyimgselect = _self;
3720                      },
3721                     select : function (combo, record, index)
3722                      {
3723                          Roo.log(record);
3724                          (function() { 
3725                              combo.setValue('');
3726                          }).defer(100);
3727                          
3728                          var editor = _this.trform.findField('body').editorcore;
3729                          
3730                          var curnode = editor.getSelectedNode();
3731                          
3732                          if (curnode && curnode.tagName == 'IMG') {
3733                              curnode.src= String.format('{0}/Images/{1}/{2}#attachment-{1}',
3734                                      baseURL,  record.data.id, record.data.filename
3735                                  );
3736                                  // note -forces an update... hopefully...
3737                              editor.owner.fireEvent('editorevent', editor, false);
3738                          } else {
3739                          
3740                              editor.insertAtCursor(
3741                                  String.format('<img src="{0}/Images/{1}/{2}#attachment-{1}">',
3742                                  baseURL,  record.data.id, record.data.filename
3743                                  )
3744                              );
3745                      
3746                          }
3747                          
3748                      }
3749                    },
3750                    xns : Roo.form,
3751                    '|xns' : 'Roo.form',
3752                    store : {
3753                     xtype : 'Store',
3754                     remoteSort : true,
3755                     sortInfo : { direction : 'ASC', field: 'id' },
3756                     listeners : {
3757                      beforeload : function (_self, o){
3758                           o.params = o.params || {};
3759                       
3760                           var id = _this.form.findField('id').getValue() * 1;    
3761                           if (!id) {
3762                               Roo.MessageBox.alert("Error", "Save press release first");
3763                               return false;
3764                           }
3765                           o.params.onid = id;
3766                           o.params.ontable = 'cms_page';
3767                          // o.params.imgtype = 'PressRelease';
3768                           //o.params['query[imagesize]'] = '150x150';
3769                           // set more here
3770                       }
3771                     },
3772                     xns : Roo.data,
3773                     '|xns' : 'Roo.data',
3774                     proxy : {
3775                      xtype : 'HttpProxy',
3776                      method : 'GET',
3777                      url : baseURL + '/Roo/Images.php',
3778                      xns : Roo.data,
3779                      '|xns' : 'Roo.data'
3780                     },
3781                     reader : {
3782                      xtype : 'JsonReader',
3783                      fields : [{"name":"id","type":"int"},{"name":"filename","type":"string"},{"name":"url_thumb","type":"string"}],
3784                      id : 'id',
3785                      root : 'data',
3786                      totalProperty : 'total',
3787                      xns : Roo.data,
3788                      '|xns' : 'Roo.data'
3789                     }
3790                    }
3791                   },
3792                   {
3793                    xtype : 'ComboBox',
3794                    allowBlank : true,
3795                    displayField : 'page_link',
3796                    editable : true,
3797                    emptyText : _this._strings['580b21aac58f1b73cece26e272cdfbee'] /* Add Link */,
3798                    forceSelection : true,
3799                    hiddenName : 'add_link_id',
3800                    listWidth : 200,
3801                    loadingText : _this._strings['1243daf593fa297e07ab03bf06d925af'] /* Searching... */,
3802                    minChars : 2,
3803                    name : 'add_link',
3804                    pageSize : 40,
3805                    qtip : _this._strings['76729937a5eb6b0fd88c42581161facd'] /* Select Category  */,
3806                    selectOnFocus : true,
3807                    tpl : '<div class=\"x-grid-cell-text x-btn button\"><b>{title}</b> <i>{page_link}</i> </div>',
3808                    triggerAction : 'all',
3809                    typeAhead : true,
3810                    valueField : 'id',
3811                    width : 100,
3812                    listeners : {
3813                     select : function (combo, record, index)
3814                      {
3815                        //  Roo.log(record);
3816                          (function() { 
3817                              combo.setValue('');
3818                          }).defer(100);
3819                          var editor = _this.form.findField('body');
3820                          editor.insertAtCursor(
3821                                  String.format('<a href="#page-{0}">{1}</a>',
3822                                  record.data.page_link,  record.data.title
3823                                  )
3824                           );
3825                      
3826                          
3827                       }
3828                    },
3829                    xns : Roo.form,
3830                    '|xns' : 'Roo.form',
3831                    store : {
3832                     xtype : 'Store',
3833                     remoteSort : true,
3834                     sortInfo : { field: 'page_link', direction: 'ASC' },
3835                     listeners : {
3836                      beforeload : function (_self, options)
3837                       {
3838                            options.params['search[page_link_no_empty]'] =1; 
3839                            /*
3840                            options.params.is_element = 0;
3841                            options.params.is_menuitem = _this.form.findField('is_menuitem').getValue() * 1;     
3842                            */
3843                       }
3844                     },
3845                     xns : Roo.data,
3846                     '|xns' : 'Roo.data',
3847                     proxy : {
3848                      xtype : 'HttpProxy',
3849                      method : 'GET',
3850                      url : baseURL + '/Roo/cms_page.php',
3851                      xns : Roo.data,
3852                      '|xns' : 'Roo.data'
3853                     },
3854                     reader : {
3855                      xtype : 'JsonReader',
3856                      fields : [
3857                       { name: 'id', type: 'int' },
3858                       'title',
3859                       'page_link' 
3860                      ],
3861                      id : 'id',
3862                      root : 'data',
3863                      totalProperty : 'total',
3864                      xns : Roo.data,
3865                      '|xns' : 'Roo.data'
3866                     }
3867                    }
3868                   },
3869                   {
3870                    xtype : 'Separator',
3871                    xns : Roo.Toolbar,
3872                    '|xns' : 'Roo.Toolbar'
3873                   },
3874                   {
3875                    xtype : 'Button',
3876                    text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
3877                    listeners : {
3878                     click : function (_self, e)
3879                      {
3880                          this.scope.owner.fireEvent('savedpreview', this.scope.owner);
3881                      }
3882                    },
3883                    xns : Roo.Toolbar,
3884                    '|xns' : 'Roo.Toolbar'
3885                   }
3886                  ]
3887                 },
3888                 {
3889                  xtype : 'ToolbarContext',
3890                  xns : Roo.form.HtmlEditor,
3891                  '|xns' : 'Roo.form.HtmlEditor'
3892                 }
3893                ]
3894               }
3895              ]
3896             }
3897            ]
3898           }
3899          ]
3900         },
3901         {
3902          xtype : 'ContentPanel',
3903          background : false,
3904          fitContainer : true,
3905          fitToFrame : true,
3906          region : 'south',
3907          title : _this._strings['76eb64a1725ee953c664e15c9213b2fd'] /* Extended Content */,
3908          xns : Roo,
3909          '|xns' : 'Roo',
3910          items  : [
3911           {
3912            xtype : 'Form',
3913            labelAlign : 'top',
3914            labelWidth : 80,
3915            method : 'POST',
3916            url : baseURL + '/Roo/cms_page.php',
3917            listeners : {
3918             rendered : function (form)
3919              {
3920                  _this.trform2 = form;
3921              }
3922            },
3923            xns : Roo.form,
3924            '|xns' : 'Roo.form',
3925            items  : [
3926             {
3927              xtype : 'Row',
3928              hideLabels : true,
3929              xns : Roo.form,
3930              '|xns' : 'Roo.form',
3931              items  : [
3932               {
3933                xtype : 'HtmlEditor',
3934                autosave : function() {
3935                    
3936                    var extended = _this.trform2.findField('extended');
3937                    
3938                    if(!extended.wrap.isVisible(true) || extended.getValue() == '' || !extended.isDirty()){
3939                        Roo.log('tr extend not dirty');
3940                        return;
3941                    }
3942                
3943                    
3944                    Roo.log('tr extend dirty, auto save!');
3945                    
3946                    extended.fireEvent('autosave', extended);
3947                        
3948                   
3949                },
3950                fieldLabel : _this._strings['57e195426892c5515935f21d97228814'] /* Extended Contents */,
3951                height : 140,
3952                name : 'extended',
3953                resizable : 's',
3954                white : [ 'iframe' ],
3955                listeners : {
3956                 autosave : function (_self)
3957                  {
3958                      var id = _this.trform.findField('id').getValue() * 1;
3959                      
3960                      /*
3961                      if(!_self.editorcore.sourceEditMode){
3962                          _self.syncValue();
3963                      }else{
3964                          _self.pushValue();
3965                      }
3966                      */
3967                      
3968                      new Pman.Request({
3969                          url : baseURL + '/Roo/Events.php',
3970                          method :'POST',
3971                          params : {
3972                              id : 0,
3973                              action : 'AUTOSAVE',
3974                              on_id : (id > 0) ? id : 0,
3975                              on_table : 'cms_page',
3976                              remarks : 'EXTENDED',
3977                              source: _self.getValue()
3978                          },
3979                          success : function() {
3980                              _self.originalValue = _self.getValue();
3981                              
3982                          },
3983                          failure : function() 
3984                          {
3985                              //Roo.MessageBox.alert("Error", "autosave failed");
3986                              Roo.log('tr extended autosave failed?!');
3987                          }
3988                      });
3989                  },
3990                 savedpreview : function (_self)
3991                  {
3992                      var id = _this.trform.findField('id').getValue() * 1;
3993                      
3994                      var successFn = function(res){
3995                          return res.data.POST.source;
3996                      };
3997                      
3998                      var params = {
3999                          action : 'AUTOSAVE',
4000                          remarks : 'EXTENDED',
4001                          on_id : (id < 1) ? 0 : id,
4002                          on_table : 'cms_page',
4003                          successFn : successFn
4004                      };
4005                      
4006                      
4007                      Pman.Dialog.CoreAutoSavePreview.show(params, function(res){
4008                          _self.setValue(res);
4009                          _self.originalValue = res;
4010                      });
4011                  },
4012                 stylesheetsclick : function (_self)
4013                  {
4014                      Pman.Dialog.CmsApplyStyleSheets.show({}, function(res){
4015                          _this.dialog.setStylesheets();
4016                      })
4017                      
4018                  }
4019                },
4020                xns : Roo.form,
4021                '|xns' : 'Roo.form',
4022                toolbars : [
4023                 {
4024                  xtype : 'ToolbarStandard',
4025                  xns : Roo.form.HtmlEditor,
4026                  '|xns' : 'Roo.form.HtmlEditor',
4027                  btns : [
4028                   {
4029                    xtype : 'Separator',
4030                    xns : Roo.Toolbar,
4031                    '|xns' : 'Roo.Toolbar'
4032                   },
4033                   {
4034                    xtype : 'Button',
4035                    text : _this._strings['bd88a20b53a47f7b5704a83a15ff5506'] /* Saved Version */,
4036                    listeners : {
4037                     click : function (_self, e)
4038                      {
4039                          this.scope.owner.fireEvent('savedpreview', this.scope.owner);
4040                      }
4041                    },
4042                    xns : Roo.Toolbar,
4043                    '|xns' : 'Roo.Toolbar'
4044                   }
4045                  ]
4046                 },
4047                 {
4048                  xtype : 'ToolbarContext',
4049                  styles : typeof(uiConfig) != 'undefined' ? (uiConfig['Roo.form.HtmlEditor.ToolbarContext.styles'] || {}) : {},
4050                  xns : Roo.form.HtmlEditor,
4051                  '|xns' : 'Roo.form.HtmlEditor'
4052                 }
4053                ]
4054               }
4055              ]
4056             }
4057            ]
4058           }
4059          ]
4060         },
4061         {
4062          xtype : 'ContentPanel',
4063          background : false,
4064          fitContainer : true,
4065          fitToFrame : true,
4066          region : 'south',
4067          title : _this._strings['98e93e8f7adfe14832db6caed713d849'] /* Meta Tags */,
4068          xns : Roo,
4069          '|xns' : 'Roo',
4070          items  : [
4071           {
4072            xtype : 'Form',
4073            labelAlign : 'top',
4074            labelWidth : 80,
4075            method : 'POST',
4076            url : baseURL + '/Roo/cms_page.php',
4077            listeners : {
4078             rendered : function (form)
4079              {
4080                  _this.trform3 = form;
4081              }
4082            },
4083            xns : Roo.form,
4084            '|xns' : 'Roo.form',
4085            items  : [
4086             {
4087              xtype : 'Row',
4088              xns : Roo.form,
4089              '|xns' : 'Roo.form',
4090              items  : [
4091               {
4092                xtype : 'TextArea',
4093                fieldLabel : _this._strings['867343577fa1f33caa632a19543bd252'] /* Keywords */,
4094                height : 100,
4095                name : 'keywords',
4096                width : 340,
4097                xns : Roo.form,
4098                '|xns' : 'Roo.form'
4099               },
4100               {
4101                xtype : 'TextArea',
4102                fieldLabel : _this._strings['8bc84316c4078bf66723fd019616d920'] /* Descriptions */,
4103                height : 100,
4104                name : 'descriptions',
4105                width : 340,
4106                xns : Roo.form,
4107                '|xns' : 'Roo.form'
4108               }
4109              ]
4110             }
4111            ]
4112           }
4113          ]
4114         }
4115        ]
4116       }
4117      }
4118     ]
4119    });
4120  }
4121 };