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