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