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