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