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