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