/source/includes/classes/render.php
http://prosporous.googlecode.com/ · PHP · 241 lines · 232 code · 3 blank · 6 comment · 5 complexity · ba42c2811472166f85d5c1994f6111b1 MD5 · raw file
- <?php
- /**
- * Created on 2010-4-30
- *
- * @author Niap <zpr9527@163.com>
- *
- */
- class render{
- private $name;
- private $fieldLabel;
- private $type;
- private $config;
- private $back = "";
- private $disable = false;
- function set_name($name){
- $this->name = $name;
- }
- function set_fieldLabel($fieldLabel){
- $this->fieldLabel = $fieldLabel;
- }
- function set_type($type){
- $this->type = $type;
- }
- function set_config($config){
- $this->config = $config;
- }
- function get_js(){
- $config = json_decode($this->config,true);
- $this->config = $this->config?"disabled:'true',":"";
- switch($this->type){
- case 'datefield':
- $js ="{
- ".$this->disable."
- xtype: 'datefield',
- fieldLabel: '{$this->fieldLabel}',
- name: '{$this->name}',
- format:'{$config['format']}',
- ".$this->back."
- anchor:'30%'
- }";
- break;
- case 'textarea':
- $js ="{
- ".$this->disable."
- xtype: 'textarea',
- fieldLabel: '{$this->fieldLabel}',
- name: '{$this->name}',
- anchor:'98%',
- ".$this->back."
- height:{$config['height']}
- }";
- break;
- case 'htmleditor':
- $js="{
- ".$this->disable."
- xtype:'htmleditor',
- name:'{$this->name}',
- fieldLabel:'{$this->fieldLabel}',
- height:{$config['height']},
- ".$this->back."
- anchor:'98%'
- }";
-
- break;
- case 'fckeditor':
- $js="{
- ".$this->disable."
- xtype:'textarea',
- name:'{$this->name}',
- value:'',
- anchor:'98%',
- height:100,
- fieldLabel:'{$this->fieldLabel}',
- ".$this->back."
- listeners:{
- focus:function(f){
- var myMask = new Ext.LoadMask(Ext.getBody(), {msg:'???'});
- myMask.show();
- var w=f.getSize();
- fckEditor = new FCKeditor('{$this->name}') ;
- fckEditor.Height='{$config['height']}';
- fckEditor.Width=w.width;
- fckEditor.BasePath = '/plug-in/fck/' ;
- fckEditor.ReplaceTextarea() ;
- myMask.hide();
- }
- }}
- ";
- break;
- case 'swfupload':
- $js ="{
- ".$this->disable."
- xtype: 'fileuploadfield',
- fieldLabel: '{$this->fieldLabel}',
- ".$this->back."
- anchor:'50%',
- name: '{$this->name}',
- buttonCfg: {
- text: '',
- iconCls: 'upload-icon'
- }
- }
- ";
- break;
- case 'combo':
- $js ="{
- ".$this->disable."
- typeAhead: true,
- name : '{$this->name}_',
- hiddenName : '{$this->name}',
- xtype: 'combo',
- anchor:'30%',
- fieldLabel : '{$this->fieldLabel}',
- store:new Ext.data.SimpleStore({
- fields:['name','value'],
- data:[{$config['pair']}]}),
- mode:'local',
- displayField:'name',
- ".$this->back."
- selectOnFocus:true,
- valueField :'value',
- triggerAction:'all'
- }
- ";
- break;
- case 'radiogroup':
- $config_num = count($config);
- $items = '';
- foreach($config as $id => $data){
- if($data['checked']=='1'){
- $checked = ", checked: true";
- }else
- $checked = "";
-
- $items.= "{boxLabel: '{$data['name']}', name: '{$this->name}', inputValue: {$data['value']}{$checked}}";
- if($id < $config_num-1){
- $items.= ",";
- }
- }
- $js ="{
- ".$this->disable."
- xtype: 'radiogroup',
- fieldLabel: '{$this->fieldLabel}',
- ".$this->back."
- columns: 5,
- anchor:'50%',
- items: [
- {$items}
- ]
- }
- ";
- break;
- case 'checkboxgroup':
- $config_num = count($config);
- $items = '';
- foreach($config as $id => $data){
- if($data['checked']=='1'){
- $checked = ", checked: true";
- }else
- $checked = "";
- $items.= "{boxLabel: '{$data['name']}', name: '{$data['value']}'{$checked}}";
- if($id < $config_num-1){
- $items.= ",";
- }
- }
- $js ="{
- ".$this->disable."
- xtype: 'checkboxgroup',
- fieldLabel: '{$this->fieldLabel}',
- ".$this->back."
- columns: 5,
- anchor:'50%',
- items: [
- {$items}
- ]
- }
- ";
- break;
- case 'password':
- $js ="{
- ".$this->disable."
- xtype: 'textfield',
- inputType: 'password',
- fieldLabel: '{$this->fieldLabel}',
- ".$this->back."
- name: '{$this->name}'
- }";
- if($config['confirm']){
- $js .=',';
- $js .="{
- ".$this->disable."
- fieldLabel: '??{$this->fieldLabel}',
- name: '{$this->name}-cfrm',
- xtype: 'textfield',
- inputType: 'password',
- vtype: 'password',
- ".$this->back."
- initialPassField: '{$this->name}'
- }";
- }
- break;
- default:
- $js="{
- disabled:'true',
- xtype: '{$this->type}',
- fieldLabel: '{$this->fieldLabel}',
- name: '{$this->name}',
- ".$this->back."
- anchor:'60%'
- }";
- }
- return $js;
- }
- function get_plugjs(){
- switch($this->type){
- case 'datefield':
- $plugjs ='Date.dayNames = ["?", "?", "?", "?", "?", "?", "?"];
- if (Ext.DatePicker) {
- Ext.apply(Ext.DatePicker.prototype, {
- todayText: "??",
- minText: "?????????",
- maxText: "?????????",
- disabledDaysText: "",
- disabledDatesText: "",
- monthNames: Date.monthNames,
- dayNames: Date.dayNames,
- nextText: "?? (Control+Right)",
- prevText: "?? (Control+Left)",
- monthYearText: "????? (Control+Up/Down ????)",
- todayTip: "{0} (Spacebar)",
- okText: "??",
- cancelText: "??",
- format: "y?m?d?"
- });
- }';
- break;
- }
-
- }
- }
- ?>