code
stringlengths
1
2.01M
language
stringclasses
1 value
function title($field, $value) { $value = htmlspecialchars($value); return $value; }
PHP
<?php class content_input { var $modelid; var $fields; var $data; function __construct($modelid) { $this->db = pc_base::load_model('sitemodel_field_model'); $this->db_pre = $this->db->db_tablepre; $this->modelid = $modelid; $this->fields = getcache('model_field_'.$modelid,'model'); //初始化附件类 pc_base::load_sys_class('attachment','',0); $this->siteid = param::get_cookie('siteid'); $this->attachment = new attachment('content','0',$this->siteid); $this->site_config = getcache('sitelist','commons'); $this->site_config = $this->site_config[$this->siteid]; } function get($data,$isimport = 0) { $this->data = $data; $info = array(); foreach($data as $field=>$value) { //if(!isset($this->fields[$field]) || check_in($_roleid, $this->fields[$field]['unsetroleids']) || check_in($_groupid, $this->fields[$field]['unsetgroupids'])) continue; $name = $this->fields[$field]['name']; $minlength = $this->fields[$field]['minlength']; $maxlength = $this->fields[$field]['maxlength']; $pattern = $this->fields[$field]['pattern']; $errortips = $this->fields[$field]['errortips']; if(empty($errortips)) $errortips = $name.' '.L('not_meet_the_conditions'); $length = strlen($value); if($minlength && $length < $minlength) { if($isimport) { return false; } else { showmessage($name.' '.L('not_less_than').' '.$minlength.L('characters')); } } if($maxlength && $length > $maxlength) { if($isimport) { $value = str_cut($value,$maxlength,''); } else { showmessage($name.' '.L('not_more_than').' '.$maxlength.L('characters')); } } elseif($maxlength) { $value = str_cut($value,$maxlength,''); } if($pattern && $length && !preg_match($pattern, $value) && !$isimport) showmessage($errortips); $MODEL = getcache('model', 'commons'); $this->db->table_name = $this->fields[$field]['issystem'] ? $this->db_pre.$MODEL[$this->modelid]['tablename'] : $this->db_pre.$MODEL[$this->modelid]['tablename'].'_data'; if($this->fields[$field]['isunique'] && $this->db->get_one(array($field=>$value),$field) && ROUTE_A != 'edit') showmessage($name.L('the_value_must_not_repeat')); $func = $this->fields[$field]['formtype']; if(method_exists($this, $func)) $value = $this->$func($field, $value); if($this->fields[$field]['issystem']) { $info['system'][$field] = $value; } else { $info['model'][$field] = $value; } //颜色选择为隐藏域 在这里进行取值 $info['system']['style'] = $_POST['style_color'] ? strip_tags($_POST['style_color']) : ''; if($_POST['style_font_weight']) $info['system']['style'] = $info['system']['style'].';'.strip_tags($_POST['style_font_weight']); } return $info; } }?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $defaultvalue = isset($_POST['setting']['defaultvalue']) ? $_POST['setting']['defaultvalue'] : ''; //正整数 UNSIGNED && SIGNED $minnumber = isset($_POST['setting']['minnumber']) ? $_POST['setting']['minnumber'] : 1; $decimaldigits = isset($_POST['setting']['decimaldigits']) ? $_POST['setting']['decimaldigits'] : ''; switch($field_type) { case 'varchar': if(!$maxlength) $maxlength = 255; $maxlength = min($maxlength, 255); $sql = "ALTER TABLE `$tablename` ADD `$field` VARCHAR( $maxlength ) NOT NULL DEFAULT '$defaultvalue'"; $this->db->query($sql); break; case 'tinyint': if(!$maxlength) $maxlength = 3; $minnumber = intval($minnumber); $defaultvalue = intval($defaultvalue); $this->db->query("ALTER TABLE `$tablename` ADD `$field` TINYINT( $maxlength ) ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'"); break; case 'number': $minnumber = intval($minnumber); $defaultvalue = $decimaldigits == 0 ? intval($defaultvalue) : floatval($defaultvalue); $sql = "ALTER TABLE `$tablename` ADD `$field` ".($decimaldigits == 0 ? 'INT' : 'FLOAT')." ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'"; $this->db->query($sql); break; case 'smallint': $minnumber = intval($minnumber); $this->db->query("ALTER TABLE `$tablename` ADD `$field` SMALLINT ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL"); break; case 'int': $minnumber = intval($minnumber); $defaultvalue = intval($defaultvalue); $sql = "ALTER TABLE `$tablename` ADD `$field` INT ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'"; $this->db->query($sql); break; case 'mediumint': $minnumber = intval($minnumber); $defaultvalue = intval($defaultvalue); $sql = "ALTER TABLE `$tablename` ADD `$field` INT ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'"; $this->db->query($sql); break; case 'mediumtext': $this->db->query("ALTER TABLE `$tablename` ADD `$field` MEDIUMTEXT NOT NULL"); break; case 'text': $this->db->query("ALTER TABLE `$tablename` ADD `$field` TEXT NOT NULL"); break; case 'date': $this->db->query("ALTER TABLE `$tablename` ADD `$field` DATE NULL"); break; case 'datetime': $this->db->query("ALTER TABLE `$tablename` ADD `$field` DATETIME NULL"); break; case 'timestamp': $this->db->query("ALTER TABLE `$tablename` ADD `$field` TIMESTAMP NOT NULL"); break; //特殊自定义字段 case 'pages': $this->db->query("ALTER TABLE `$tablename` ADD `paginationtype` TINYINT( 1 ) NOT NULL DEFAULT '0'"); $this->db->query("ALTER TABLE `$tablename` ADD `maxcharperpage` MEDIUMINT( 6 ) NOT NULL DEFAULT '0'"); break; case 'readpoint': $defaultvalue = intval($defaultvalue); $this->db->query("ALTER TABLE `$tablename` ADD `readpoint` smallint(5) unsigned NOT NULL default '$defaultvalue'"); $this->db->query("ALTER TABLE `$tablename` ADD `paytype` tinyint(1) unsigned NOT NULL default '0'"); break; } ?>
PHP
function map($field, $value, $fieldinfo) { extract($fieldinfo); $setting = string2array($setting); $size = $setting['size']; $errortips = $this->fields[$field]['errortips']; $modelid = $this->fields[$field]['modelid']; $tips = $value ? L('editmark','','map') : L('addmark','','map'); return '<input type="button" name="'.$field.'_mark" id="'.$field.'_mark" value="'.$tips.'" class="button" onclick="omnipotent(\'selectid\',\''.APP_PATH.'api.php?op=map&field='.$field.'&modelid='.$modelid.'\',\''.L('mapmark','','map').'\',1,700,420)"><input type="hidden" name="info['.$field.']" value="'.$value.'" id="'.$field.'" >'; }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'varchar'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 0; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td>地图接口选择</td> <td> <input type="radio" name="setting[maptype]" value="2" <?php if($setting['maptype']==2) echo 'checked';?>> 百度地图 </td> </tr> <tr> <td>地图API Key </td> <td><input type="text" name="setting[api_key]" value="<?php echo $setting['api_key'];?>" size="30" class="input-text"></td> </tr> <tr> <td>默认城市</td> <td><input type="text" name="setting[defaultcity]" value="<?php echo $setting['defaultcity'];?>" size="30" class="input-text"></td> </tr> <tr> <td width="100">热门城市</td> <td> <textarea style="height:100px;width:100px;" id="options" cols="20" rows="2" name="setting[hotcitys]"><?php echo $setting['hotcitys'];?></textarea> 多个城市请使用半角逗号分隔</td> </tr> <tr> <td>地图尺寸 </td> <td> 宽度: <input type="text" name="setting[width]" value="<?php echo $setting['width'];?>" size="10" class="input-text">px 高度: <input type="text" name="setting[height]" value="<?php echo $setting['height'];?>" size="10" class="input-text">px </td> </tr> </table>
PHP
function map($field, $value) { $str = ''; $setting = string2array($this->fields[$field]['setting']); $setting[width] = $setting[width] ? $setting[width] : '600'; $setting[height] = $setting[height] ? $setting[height] : '400'; list($lngX, $latY,$zoom) = explode('|', $value); if($setting['maptype']==1) { $str = "<script src='http://app.mapabc.com/apis?&t=flashmap&v=2.4&key=$setting[api_key]&hl=zh-CN' type='text/javascript'></script>"; } elseif($setting['maptype']==2) { $str = "<script type='text/javascript' src='http://api.map.baidu.com/api?v=1.2&key=$setting[api_key]'></script>"; } $str .= '<div id="mapObj" class="view" style="width: '.$setting[width].'px; height:'.$setting[height].'px"></div>'; $str .='<script type="text/javascript">'; if($setting['maptype']==1) { $str .=' var mapObj=null; lngX = "'.$lngX.'"; latY = "'.$latY.'"; zoom = "'.$zoom.'"; var mapOptions = new MMapOptions(); mapOptions.toolbar = MConstants.MINI; mapOptions.scale = new MPoint(20,20); mapOptions.zoom = zoom; mapOptions.mapComButton = MConstants.SHOW_NO mapOptions.center = new MLngLat(lngX,latY); var mapObj = new MMap("mapObj", mapOptions); var maptools = new MMapTools(mapObj); drawPoints(); '; $str .=' function drawPoints(){ var markerOption = new MMarkerOptions(); var tipOption=new MTipOptions();//添加信息窗口 var address = "'.$address.'"; tipOption.tipType = MConstants.HTML_BUBBLE_TIP;//信息窗口标题 tipOption.title = address;//信息窗口标题 tipOption.content = address;//信息窗口内容 var markerOption = new MMarkerOptions(); markerOption.imageUrl="'.IMG_PATH.'icon/mak.png"; markerOption.picAgent=false; markerOption.imageAlign=MConstants.BOTTOM_CENTER; markerOption.tipOption = tipOption; markerOption.canShowTip= address ? true : false; markerOption.dimorphicColor="0x00A0FF"; Mmarker = new MMarker(new MLngLat(lngX,latY),markerOption); Mmarker.id="mark101"; mapObj.addOverlay(Mmarker,true) }'; } elseif($setting['maptype']==2) { $str .=' var mapObj=null; lngX = "'.$lngX.'"; latY = "'.$latY.'"; zoom = "'.$zoom.'"; var mapObj = new BMap.Map("mapObj"); var ctrl_nav = new BMap.NavigationControl({anchor:BMAP_ANCHOR_TOP_LEFT,type:BMAP_NAVIGATION_CONTROL_LARGE}); mapObj.addControl(ctrl_nav); mapObj.enableDragging(); mapObj.enableScrollWheelZoom(); mapObj.enableDoubleClickZoom(); mapObj.centerAndZoom(new BMap.Point(lngX,latY),zoom); drawPoints(); '; $str .=' function drawPoints(){ var myIcon = new BMap.Icon("'.IMG_PATH.'icon/mak.png", new BMap.Size(27, 45)); var center = mapObj.getCenter(); var point = new BMap.Point(lngX,latY); var marker = new BMap.Marker(point, {icon: myIcon}); mapObj.addOverlay(marker); }'; } $str .='</script>'; return $str; }
PHP
<?php class content_output { var $fields; var $data; function __construct($modelid,$catid = 0,$categorys = array()) { $this->modelid = $modelid; $this->catid = $catid; $this->categorys = $categorys; $this->fields = getcache('model_field_'.$modelid,'model'); } function get($data) { $this->data = $data; $this->id = $data['id']; $info = array(); foreach($this->fields as $field=>$v) { if(!isset($data[$field])) continue; $func = $v['formtype']; $value = $data[$field]; $result = method_exists($this, $func) ? $this->$func($field, $data[$field]) : $data[$field]; if($result !== false) $info[$field] = $result; } return $info; } }?>
PHP
<?php $fields = array('text'=>'单行文本', 'textarea'=>'多行文本', 'editor'=>'编辑器', 'catid'=>'栏目', 'title'=>'标题', 'box'=>'选项', 'image'=>'图片', 'images'=>'多图片', 'number'=>'数字', 'datetime'=>'日期和时间', 'posid'=>'推荐位', 'keyword'=>'关键词', 'author'=>'作者', 'copyfrom'=>'来源', 'groupid'=>'会员组', 'islink'=>'转向链接', 'template'=>'模板', 'pages'=>'分页选择', 'typeid'=>'类别', 'readpoint'=>'积分、点数', 'linkage'=>'联动菜单', 'downfile'=>'镜像下载', 'downfiles'=>'多文件上传', 'map'=>'地图字段', 'omnipotent'=>'万能字段', 'brand'=>'品牌', //eddy 增加品牌字段 ); //不允许删除的字段,这些字段讲不会在字段添加处显示 $not_allow_fields = array('catid','typeid','title','keyword','posid','template','username'); //允许添加但必须唯一的字段 $unique_fields = array('pages','readpoint','author','copyfrom','islink'); //禁止被禁用的字段列表 $forbid_fields = array('catid','title','updatetime','inputtime','url','listorder','status','template','username'); //禁止被删除的字段列表 $forbid_delete = array('catid','typeid','title','thumb','keywords','updatetime','inputtime','posids','url','listorder','status','template','username'); //可以追加 JS和CSS 的字段 $att_css_js = array('text','textarea','box','number','keyword','typeid'); ?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'varchar'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 1; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?>
PHP
function keyword($field, $value) { if($value == '') return ''; $v = ''; if(strpos($value, ',')===false) { $tags = explode(' ', $value); } else { $tags = explode(',', $value); } return $tags; }
PHP
<?php if(!$maxlength) $maxlength = 255; $maxlength = min($maxlength, 255); $fieldtype = $issystem ? 'CHAR' : 'VARCHAR'; $sql = "ALTER TABLE `$tablename` CHANGE `$field` `$field` $fieldtype( $maxlength ) NOT NULL DEFAULT '$defaultvalue'"; $db->query($sql); ?>
PHP
function omnipotent($field, $value, $fieldinfo) { extract($fieldinfo); $formtext = str_replace('{FIELD_VALUE}',$value,$formtext); $formtext = str_replace('{MODELID}',$this->modelid,$formtext); preg_match_all('/{FUNC\((.*)\)}/',$formtext,$_match); foreach($_match[1] as $key=>$match_func) { $string = ''; $params = explode('~~',$match_func); $user_func = $params[0]; $string = $user_func($params[1]); $formtext = str_replace($_match[0][$key],$string,$formtext); } $id = $this->id ? $this->id : 0; $formtext = str_replace('{ID}',$id,$formtext); $errortips = $this->fields[$field]['errortips']; if($errortips) $this->formValidator .= '$("#'.$field.'").formValidator({onshow:"",onfocus:"'.$errortips.'"}).inputValidator({min:'.$minlength.',max:'.$maxlength.',onerror:"'.$errortips.'"});'; if($errortips) $this->formValidator .= '$("#'.$field.'").formValidator({onshow:"'.$errortips.'",onfocus:"'.$errortips.'"}).inputValidator({min:1,onerror:"'.$errortips.'"});'; return $formtext; }
PHP
<?php $db->query("ALTER TABLE `$tablename` DROP `$field`"); ?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'varchar'; //字段数据库类型 $field_basic_table = 0; //是否允许作为主表字段 $field_allow_index = 0; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="100">表单</td> <td><textarea name="setting[formtext]" rows="2" cols="20" id="options" style="height:100px;width:400px;"><?php echo htmlspecialchars($setting['formtext']);?></textarea><BR> 例如:&lt;input type='text' name='info[voteid]' id='voteid' value='{FIELD_VALUE}' style='50' &gt;</td> </tr> <tr> <td>字段类型</td> <td> <select name="setting[fieldtype]" onchange="javascript:fieldtype_setting(this.value);"> <option value="varchar" <?php if($setting['fieldtype']=='varchar') echo 'selected';?>>字符 VARCHAR</option> <option value="tinyint" <?php if($setting['fieldtype']=='tinyint') echo 'selected';?>>整数 TINYINT(3)</option> <option value="smallint" <?php if($setting['fieldtype']=='smallint') echo 'selected';?>>整数 SMALLINT(5)</option> <option value="mediumint" <?php if($setting['fieldtype']=='mediumint') echo 'selected';?>>整数 MEDIUMINT(8)</option> <option value="int" <?php if($setting['fieldtype']=='int') echo 'selected';?>>整数 INT(10)</option> </select> <span id="minnumber" style="display:none"><input type="radio" name="setting[minnumber]" value="1" <?php if($setting['minnumber']==1) echo 'checked';?>/> <font color='red'>正整数</font> <input type="radio" name="setting[minnumber]" value="-1" <?php if($setting['minnumber']==-1) echo 'checked';?>/> 整数</span> </td> </tr> </table>
PHP
function linkage($field, $value, $fieldinfo) { $setting = string2array($fieldinfo['setting']); $linkageid = $setting['linkageid']; return menu_linkage($linkageid,$field,$value); }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'number'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 1; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td>菜单ID</td> <td><input type="text" id="linkageid" name="setting[linkageid]" value="<?php echo $setting['linkageid'];?>" size="5"> <input type='button' value="在列表中选择" onclick="omnipotent('selectid','?m=admin&c=linkage&a=public_get_list','在列表中选择')" class="button"> 请到导航 扩展 > 联动菜单 > 添加联动菜单</td> </tr> <tr> <td>显示方式</td> <td> <input name="setting[showtype]" value="0" type="radio" <?php if($setting['showtype']==0) echo 'checked';?>> 只显示名称 <input name="setting[showtype]" value="1" type="radio" <?php if($setting['showtype']==1) echo 'checked';?>> 显示完整路径 <input name="setting[showtype]" value="2" type="radio" <?php if($setting['showtype']==2) echo 'checked';?>> 返回联动菜单id <input name="setting[showtype]" value="3" type="radio" <?php if($setting['showtype']==3) echo 'checked';?>> 返回菜单层级数组 </td></tr> <tr> <td>路径分隔符</td> <td><input type="text" name="setting[space]" value="<?php echo $setting['space'];?>" size="5" class="input-text"> 显示完整路径时生效</td> </tr> <tr> <td>是否作为筛选字段</td> <td> <input type="radio" name="setting[filtertype]" value="1" <?php if($setting['filtertype']) echo 'checked';?> /> 是 <input type="radio" name="setting[filtertype]" value="0" <?php if(!$setting['filtertype']) echo 'checked';?>/> 否 </td> </tr> </table>
PHP
function linkage($field, $value) { $setting = string2array($this->fields[$field]['setting']); $datas = getcache($setting['linkageid'],'linkage'); $infos = $datas['data']; if($setting['showtype']==1 || $setting['showtype']==3) { $result = get_linkage($value, $setting['linkageid'], $setting['space'], $setting['showtype']); } elseif($setting['showtype']==2) { $result = $value; } else { $result = get_linkage($value, $setting['linkageid'], $setting['space'], 2); } return $result; }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'number'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 1; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="100">输入框大小</td> <td><input type="text" name="setting[size]" value="<?php echo $setting['size'];?>" size="6" class="input-text"></td> </tr> </table>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'varchar'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 1; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td>默认值</td> <td><input type="text" name="setting[defaultvalue]" value="<?php echo $setting['defaultvalue'];?>" size="40" class="input-text" ></td> </tr> </table>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'mediumtext'; //字段数据库类型 $field_basic_table = 0; //是否允许作为主表字段 $field_allow_index = 0; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 0; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td>允许上传的图片类型</td> <td><input type="text" name="setting[upload_allowext]" value="<?php echo $setting['upload_allowext'];?>" size="40" class="input-text"></td> </tr> <tr> <td>是否从已上传中选择</td> <td><input type="radio" name="setting[isselectimage]" value="1" <?php if($setting['isselectimage']) echo 'checked';?>> 是 <input type="radio" name="setting[isselectimage]" value="0" <?php if(!$setting['isselectimage']) echo 'checked';?>> 否</td> </tr> <tr> <td>允许同时上传的个数</td> <td><input type="text" name="setting[upload_number]" value="<?php echo $setting['upload_number'];?>" size=3></td> </tr> </table>
PHP
function images($field, $value) { return string2array($value); }
PHP
function images($field, $value) { //取得图片列表 $pictures = $_POST[$field.'_url']; //取得图片说明 $pictures_alt = isset($_POST[$field.'_alt']) ? $_POST[$field.'_alt'] : array(); $array = $temp = array(); if(!empty($pictures)) { foreach($pictures as $key=>$pic) { $temp['url'] = $pic; $temp['alt'] = $pictures_alt[$key]; $array[$key] = $temp; } } $array = array2string($array); return $array; }
PHP
<?php class content_form { var $modelid; var $fields; var $id; var $formValidator; function __construct($modelid,$catid = 0,$categorys = array()) { $this->modelid = $modelid; $this->catid = $catid; $this->categorys = $categorys; $this->fields = getcache('model_field_'.$modelid,'model'); $this->siteid = get_siteid(); } function get($data = array()) { $_groupid = param::get_cookie('_groupid'); $this->data = $data; if(isset($data['id'])) $this->id = $data['id']; $info = array(); $this->content_url = $data['url']; foreach($this->fields as $field=>$v) { if(defined('IN_ADMIN')) { if($v['iscore'] || check_in($_SESSION['roleid'], $v['unsetroleids'])) continue; } else { if($v['iscore'] || !$v['isadd'] || check_in($_groupid, $v['unsetgroupids'])) continue; } $func = $v['formtype']; $value = isset($data[$field]) ? htmlspecialchars($data[$field], ENT_QUOTES) : ''; if($func=='pages' && isset($data['maxcharperpage'])) { $value = $data['paginationtype'].'|'.$data['maxcharperpage']; } if(!method_exists($this, $func)) continue; $form = $this->$func($field, $value, $v); if($form !== false) { if(defined('IN_ADMIN')) { if($v['isbase']) { $star = $v['minlength'] || $v['pattern'] ? 1 : 0; $info['base'][$field] = array('name'=>$v['name'], 'tips'=>$v['tips'], 'form'=>$form, 'star'=>$star,'isomnipotent'=>$v['isomnipotent'],'formtype'=>$v['formtype']); } else { $star = $v['minlength'] || $v['pattern'] ? 1 : 0; $info['senior'][$field] = array('name'=>$v['name'], 'tips'=>$v['tips'], 'form'=>$form, 'star'=>$star,'isomnipotent'=>$v['isomnipotent'],'formtype'=>$v['formtype']); } } else { $star = $v['minlength'] || $v['pattern'] ? 1 : 0; $info[$field] = array('name'=>$v['name'], 'tips'=>$v['tips'], 'form'=>$form, 'star'=>$star,'isomnipotent'=>$v['isomnipotent'],'formtype'=>$v['formtype']); } } } return $info; } }?>
PHP
<?php if(!$maxlength) $maxlength = 255; $maxlength = min($maxlength, 255); $fieldtype = $issystem ? 'CHAR' : 'VARCHAR'; $sql = "ALTER TABLE `$tablename` CHANGE `$field` `$field` $fieldtype( $maxlength ) NOT NULL DEFAULT '$defaultvalue'"; $db->query($sql); ?>
PHP
function textarea($field, $value, $fieldinfo) { extract($fieldinfo); $setting = string2array($setting); extract($setting); if(!$value) $value = $defaultvalue; $allow_empty = 'empty:true,'; if($minlength || $pattern) $allow_empty = ''; if($errortips) $this->formValidator .= '$("#'.$field.'").formValidator({'.$allow_empty.'onshow:"'.$errortips.'",onfocus:"'.$errortips.'"}).inputValidator({min:1,onerror:"'.$errortips.'"});'; $value = empty($value) ? $setting[defaultvalue] : $value; $str = "<textarea name='info[{$field}]' id='$field' style='width:{$width}%;height:{$height}px;' $formattribute $css"; if($maxlength) $str .= " onkeyup=\"strlen_verify(this, '{$field}_len', {$maxlength})\""; $str .= ">{$value}</textarea>"; if($maxlength) $str .= L('can_enter').'<B><span id="'.$field.'_len">'.$maxlength.'</span></B> '.L('characters'); return $str; }
PHP
<?php $db->query("ALTER TABLE `$tablename` DROP `$field`"); ?>
PHP
function text($field, $value, $fieldinfo) { return form::text($field, $field, $value, 'text', 15); }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'mediumtext'; //字段数据库类型 $field_basic_table = 0; //是否允许作为主表字段 $field_allow_index = 0; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 0; //作为搜索条件 $field_allow_fulltext = 1; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
function text($field, $value) { return $value === '' ? '' : " `$field` LIKE '%$value%' "; }
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="100">文本域宽度</td> <td><input type="text" name="setting[width]" value="<?php echo $setting['width'];?>" size="10" class="input-text" > %</td> </tr> <tr> <td>文本域高度</td> <td><input type="text" name="setting[height]" value="<?php echo $setting['height'];?>" size="10" class="input-text"> px</td> </tr> <tr> <td>默认值</td> <td><textarea name="setting[defaultvalue]" rows="2" cols="20" id="defaultvalue" style="height:60px;width:250px;" ><?php echo htmlspecialchars($setting['defaultvalue']);?></textarea></td> </tr> <tr> <td>是否允许Html</td> <td><input type="radio" name="setting[enablehtml]" value="1" <?php if($setting['enablehtml']==1) {?>checked<?php }?>> 是 <input type="radio" name="setting[enablehtml]" value="0" <?php if($setting['enablehtml']==0) {?>checked<?php }?>> 否</td> </tr> </table>
PHP
function textarea($field, $value) { if(!$this->fields[$field]['enablehtml']) $value = strip_tags($value); return $value; }
PHP
<?php class content_update { var $modelid; var $fields; var $data; function __construct($modelid,$id) { $this->modelid = $modelid; $this->fields = getcache('model_field_'.$modelid,'model'); $this->id = $id; } function update($data) { $info = array(); $this->data = $data; foreach($data as $field=>$value) { if(!isset($this->fields[$field])) continue; $func = $this->fields[$field]['formtype']; $info[$field] = method_exists($this, $func) ? $this->$func($field, $value) : $value; } } }?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'number'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 1; //是否允许值唯一 ?>
PHP
<table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="100">取值范围</td> <td><input type="text" name="setting[minnumber]" value="1" size="5" class="input-text"> - <input type="text" name="setting[maxnumber]" value="" size="5" class="input-text"></td> </tr> <tr> <td>小数位数:</td> <td> <select name="setting[decimaldigits]"> <option value="-1">自动</option> <option value="0" selected>0</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> </select> </td> </tr> <tr> <td>默认值</td> <td><input type="text" name="setting[defaultvalue]" value="<?php echo $defaultvalue?>" size="40" class="input-text"></td> </tr> <tr> <td>是否作为区间字段</td> <td> <input type="radio" name="setting[rangetype]" value="1"/> 是 <input type="radio" name="setting[rangetype]" value="0" checked />否   注:区间字段可以通过filters('字段名称','模型id','自定义数组')调用 </td> </tr> </table>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="100">取值范围</td> <td><input type="text" name="setting[minnumber]" value="<?php echo $setting['minnumber'];?>" size="5" class="input-text"> - <input type="text" name="setting[maxnumber]" value="<?php echo $setting['maxnumber'];?>" size="5" class="input-text"></td> </tr> <tr> <td>小数位数:</td> <td> <select name="setting[decimaldigits]"> <option value="-1" <?php if($setting['decimaldigits']==-1) echo 'selected';?>)>自动</option> <option value="0" <?php if($setting['decimaldigits']==0) echo 'selected';?>>0</option> <option value="1" <?php if($setting['decimaldigits']==1) echo 'selected';?>>1</option> <option value="2" <?php if($setting['decimaldigits']==2) echo 'selected';?>>2</option> <option value="3" <?php if($setting['decimaldigits']==3) echo 'selected';?>>3</option> <option value="4" <?php if($setting['decimaldigits']==4) echo 'selected';?>>4</option> <option value="5" <?php if($setting['decimaldigits']==5) echo 'selected';?>>5</option> </select> </td> </tr> <tr> <td>输入框长度</td> <td><input type="text" name="setting[size]" value="<?php echo $setting['size'];?>" size="3" class="input-text"> px</td> </tr> <tr> <td>默认值</td> <td><input type="text" name="setting[defaultvalue]" value="<?php echo $setting['defaultvalue'];?>" size="40" class="input-text"></td> </tr> <tr> <td>是否作为区间字段</td> <td> <input type="radio" name="setting[rangetype]" value="1" <?php if($setting['rangetype']) echo 'checked';?> /> 是 <input type="radio" name="setting[rangetype]" value="0" <?php if(!$setting['rangetype']) echo 'checked';?> /> 否   注:区间字段可以通过filters('字段名称','模型id','自定义数组')调用 </td> </tr> </table>
PHP
function editor($field, $value, $fieldinfo) { $grouplist = getcache('grouplist','member'); $_groupid = param::get_cookie('_groupid'); $grouplist = $grouplist[$_groupid]; extract($fieldinfo); extract(string2array($setting)); $disabled_page = isset($disabled_page) ? $disabled_page : 0; if(!$height) $height = 300; $allowupload = defined('IN_ADMIN') ? 1 : $grouplist['allowattachment'] ? 1: 0; if(!$value) $value = $defaultvalue; if($minlength || $pattern) $allow_empty = ''; if($minlength) $this->formValidator .= '$("#'.$field.'").formValidator({'.$allow_empty.'onshow:"",onfocus:"'.$errortips.'"}).functionValidator({ fun:function(val,elem){ var oEditor = CKEDITOR.instances.'.$field.'; var data = oEditor.getData(); if($(\'#islink\').attr(\'checked\')){ return true; } else if(($(\'#islink\').attr(\'checked\')==false) && (data==\'\')){ return "'.$errortips.'"; } else if (data==\'\' || $.trim(data)==\'\') { return "'.$errortips.'"; } return true; } });'; return "<div id='{$field}_tip'></div>".'<textarea name="info['.$field.']" id="'.$field.'" boxid="'.$field.'">'.$value.'</textarea>'.form::editor($field,$toolbar,'content',$this->catid,'',$allowupload,1,'',$height,$disabled_page); }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'mediumtext'; //字段数据库类型 $field_basic_table = 0; //是否允许作为主表字段 $field_allow_index = 0; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 0; //作为搜索条件 $field_allow_fulltext = 1; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="100">编辑器样式:</td> <td><input type="radio" name="setting[toolbar]" value="basic" checked> 简洁型 <input type="radio" name="setting[toolbar]" value="full"> 标准型 </td> </tr> <tr> <td>默认值:</td> <td><textarea name="setting[defaultvalue]" rows="2" cols="20" id="defaultvalue" style="height:100px;width:250px;"></textarea></td> </tr> <tr> <td>是否启用关联链接:</td> <td><input type="radio" name="setting[enablekeylink]" value="1"> 是 <input type="radio" name="setting[enablekeylink]" value="0" checked> 否 <input type="text" name="setting[replacenum]" value="1" size="4" class="input-text"> 替换次数 (留空则为替换全部)</td> </tr> <tr> <td>关联链接方式:</td> <td><input type="radio" name="setting[link_mode]" value="1" <?php if($setting['link_mode']==1) echo 'checked';?>> 关键字链接 <input type="radio" name="setting[link_mode]" value="0" <?php if($setting['link_mode']==0) echo 'checked';?>> 网址链接 </td> </tr> <tr> <td>是否保存远程图片:</td> <td><input type="radio" name="setting[enablesaveimage]" value="1"> 是 <input type="radio" name="setting[enablesaveimage]" value="0" checked> 否</td> </tr> <tr> <td>编辑器默认高度:</td> <td><input type="text" name="setting[height]" value="200" size="4" class="input-text"> px</td> </tr> </table>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="225">编辑器样式:</td> <td><input type="radio" name="setting[toolbar]" value="basic" <?php if($setting['toolbar']=='basic') echo 'checked';?>>简洁型 <input type="radio" name="setting[toolbar]" value="full" <?php if($setting['toolbar']=='full') echo 'checked';?>> 标准型 </td> </tr> <tr> <td>默认值:</td> <td><textarea name="setting[defaultvalue]" rows="2" cols="20" id="defaultvalue" style="height:100px;width:250px;"><?php echo $setting['defaultvalue'];?></textarea></td> </tr> <tr> <td>是否启用关联链接:</td> <td><input type="radio" name="setting[enablekeylink]" value="1" <?php if($setting['enablekeylink']==1) echo 'checked';?>> 是 <input type="radio" name="setting[enablekeylink]" value="0" <?php if($setting['enablekeylink']==0) echo 'checked';?>> 否 <input type="text" name="setting[replacenum]" value="<?php echo $setting['replacenum'];?>" size="4" class="input-text"> 替换次数 (留空则为替换全部)</td> </tr> <tr> <td>关联链接方式:</td> <td><input type="radio" name="setting[link_mode]" value="1" <?php if($setting['link_mode']==1) echo 'checked';?>> 关键字链接 <input type="radio" name="setting[link_mode]" value="0" <?php if($setting['link_mode']==0) echo 'checked';?>> 网址链接 </td> </tr> <tr> <td>是否保存远程图片:</td> <td><input type="radio" name="setting[enablesaveimage]" value="1" <?php if($setting['enablesaveimage']==1) echo 'checked';?>> 是 <input type="radio" name="setting[enablesaveimage]" value="0" <?php if($setting['enablesaveimage']==0) echo 'checked';?>> 否</td> </tr> <tr> <td>编辑器默认高度:</td> <td><input type="text" name="setting[height]" value="<?php echo $setting['height'];?>" size="4" class="input-text"> px</td> </tr> <tr> <td>禁止显示编辑器下方的分页符与子标题:</td> <td><input type="radio" name="setting[disabled_page]" value="1" <?php if($setting['disabled_page']==1) echo 'checked';?>> 禁止 <input type="radio" name="setting[disabled_page]" value="0" <?php if($setting['disabled_page']==0) echo 'checked';?>> 显示</td> </tr> </table>
PHP
function editor($field, $value) { $setting = string2array($this->fields[$field]['setting']); if($setting['enablekeylink']) { $value = $this->_keylinks($value, $setting['replacenum'],$setting['link_mode']); } return $value; } function _base64_encode($t,$str) { return $t."\"".base64_encode($str)."\""; } function _base64_decode($t,$str) { return $t."\"".base64_decode($str)."\""; } function _keylinks($txt, $replacenum = '',$link_mode = 1) { $search = "/(alt\s*=\s*|title\s*=\s*)[\"|\'](.+?)[\"|\']/ise"; $replace = "\$this->_base64_encode('\\1','\\2')"; $replace1 = "\$this->_base64_decode('\\1','\\2')"; $txt = preg_replace($search, $replace, $txt); $keywords = $this->data['keywords']; if($keywords) $keywords = strpos(',',$keywords) === false ? explode(' ',$keywords) : explode(',',$keywords); if($link_mode && !empty($keywords)) { foreach($keywords as $keyword) { $linkdatas[] = $keyword; } } else { $linkdatas = getcache('keylink','commons'); } if($linkdatas) { $word = $replacement = array(); foreach($linkdatas as $v) { if($link_mode && $keywords) { $word1[] = '/'.preg_quote($v, '/').'/'; $word2[] = $v; $replacement[] = '<a href="javascript:;" onclick="show_ajax(this)" class="keylink">'.$v.'</a>'; } else { $word1[] = '/'.preg_quote($v[0], '/').'/'; $word2[] = $v[0]; $replacement[] = '<a href="'.$v[1].'" target="_blank" class="keylink">'.$v[0].'</a>'; } } if($replacenum != '') { $txt = preg_replace($word1, $replacement, $txt, $replacenum); } else { $txt = str_replace($word2, $replacement, $txt); } } $txt = preg_replace($search, $replace1, $txt); return $txt; }
PHP
function editor($field, $value) { $setting = string2array($this->fields[$field]['setting']); $enablesaveimage = $setting['enablesaveimage']; if(isset($_POST['spider_img'])) $enablesaveimage = 0; if($enablesaveimage) { $site_setting = string2array($this->site_config['setting']); $watermark_enable = intval($site_setting['watermark_enable']); $value = $this->attachment->download('content', $value,$watermark_enable); } return $value; }
PHP
function editor($field, $value) { $attachment_db = pc_base::load_model('attachment_model'); $attachment_db->api_update($GLOBALS['downloadfiles'],'c-'.$this->data['catid'].'-'.$this->id,1); return $value; }
PHP
function posid($field, $value, $fieldinfo) { $setting = string2array($fieldinfo['setting']); $position = getcache('position','commons'); if(empty($position)) return ''; $array = array(); foreach($position as $_key=>$_value) { if($_value['modelid'] && ($_value['modelid'] != $this->modelid) || ($_value['catid'] && strpos(','.$this->categorys[$_value['catid']]['arrchildid'].',',','.$this->catid.',')===false)) continue; $array[$_key] = $_value['name']; } $posids = array(); if(ROUTE_A=='edit') { $this->position_data_db = pc_base::load_model('position_data_model'); $result = $this->position_data_db->select(array('id'=>$this->id,'modelid'=>$this->modelid),'*','','','','posid'); $posids = implode(',', array_keys($result)); } else { $posids = $setting['defaultvalue']; } return "<input type='hidden' name='info[$field][]' value='-1'>".form::checkbox($array,$posids,"name='info[$field][]'",'',$setting['width']); }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'tinyint'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="200">每个位置宽度</td> <td><input type="text" name="setting[width]" value="<?php echo $setting['width'];?>" size="5" class="input-text"> px </td> </tr> <tr> <td>默认选中项</td> <td><input type="text" name="setting[defaultvalue]" value="<?php echo $setting['defaultvalue'];?>" size="20" class="input-text"> 多个之间用半角逗号隔开 </td> </tr> </table>
PHP
function posid($field, $value) { $number = count($value); $value = $number==1 ? 0 : 1; return $value; }
PHP
function posid($field, $value) { if(!empty($value) && is_array($value)) { if($_GET['a']=='add') { $position_data_db = pc_base::load_model('position_data_model'); $textcontent = array(); foreach($value as $r) { if($r!='-1') { if(empty($textcontent)) { foreach($this->fields AS $_key=>$_value) { if($_value['isposition']) { $textcontent[$_key] = $this->data[$_key]; } } $textcontent = array2string($textcontent); } $position_data_db->insert(array('id'=>$this->id,'catid'=>$this->data['catid'],'posid'=>$r,'module'=>'content','modelid'=>$this->modelid,'data'=>$textcontent,'listorder'=>$this->id)); } } } else { $posids = array(); $catid = $this->data['catid']; $push_api = pc_base::load_app_class('push_api','admin'); foreach($value as $r) { if($r!='-1') $posids[] = $r; } $textcontent = array(); foreach($this->fields AS $_key=>$_value) { if($_value['isposition']) { $textcontent[$_key] = $this->data[$_key]; } } //颜色选择为隐藏域 在这里进行取值 $textcontent['style'] = $_POST['style_color'] ? strip_tags($_POST['style_color']) : ''; $textcontent['inputtime'] = strtotime($textcontent['inputtime']); if($_POST['style_font_weight']) $textcontent['style'] = $textcontent['style'].';'.strip_tags($_POST['style_font_weight']); $push_api->position_update($this->id, $this->modelid, $catid, $posids, $textcontent); } } }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'varchar'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 0; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 0; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="100">文本框长度</td> <td><input type="text" name="setting[size]" value="<?php echo $setting['size'];?>" size="10" class="input-text"></td> </tr> <tr> <td>默认值</td> <td><input type="text" name="setting[defaultvalue]" value="<?php echo $setting['defaultvalue'];?>" size="40" class="input-text"></td> </tr> <tr> <td>表单显示模式</td> <td><input type="radio" name="setting[show_type]" value="1" <?php if($setting['show_type']) echo 'checked';?>/> 图片模式 <input type="radio" name="setting[show_type]" value="0" <?php if(!$setting['show_type']) echo 'checked';?>/> 文本框模式</td> </tr> <tr> <td>允许上传的图片大小</td> <td><input type="text" name="setting[upload_maxsize]" value="<?php echo $setting['upload_maxsize'];?>" size="5" class="input-text">KB 提示:1KB=1024Byte,1MB=1024KB *</td> </tr> <tr> <td>允许上传的图片类型</td> <td><input type="text" name="setting[upload_allowext]" value="<?php echo $setting['upload_allowext'];?>" size="40" class="input-text"></td> </tr> <tr> <td>是否在图片上添加水印</td> <td><input type="radio" name="setting[watermark]" value="1" <?php if($setting['watermark']) echo 'checked';?>> 是 <input type="radio" name="setting[watermark]" value="0" <?php if(!$setting['watermark']) echo 'checked';?>> 否</td> </tr> <tr> <td>是否从已上传中选择</td> <td><input type="radio" name="setting[isselectimage]" value="1" <?php if($setting['isselectimage']) echo 'checked';?>> 是 <input type="radio" name="setting[isselectimage]" value="0" <?php if(!$setting['isselectimage']) echo 'checked';?>> 否</td> </tr> <tr> <td>图像大小</td> <td>宽 <input type="text" name="setting[images_width]" value="<?php echo $setting['images_width'];?>" size="3" class="input-text">px 高 <input type="text" name="setting[images_height]" value="<?php echo $setting['images_height'];?>" size="3" class="input-text">px</td> </tr> </table>
PHP
function image($field, $value) { return trim($value); }
PHP
function typeid($field, $value, $fieldinfo) { extract($fieldinfo); $setting = string2array($setting); if(!$value) $value = $setting['defaultvalue']; if($errortips) { $errortips = $this->fields[$field]['errortips']; $this->formValidator .= '$("#'.$field.'").formValidator({onshow:"",onfocus:"'.$errortips.'"}).inputValidator({min:1,onerror:"'.$errortips.'"});'; } $usable_type = $this->categorys[$this->catid]['usable_type']; $usable_array = array(); if($usable_type) $usable_array = explode(',',$usable_type); $type_data = getcache('type_content','commons'); foreach($type_data as $_key=>$_value) { if(in_array($_key,$usable_array)) $data[$_key] = $_value['name']; } return form::select($data,$value,'name="info['.$field.']" id="'.$field.'" '.$formattribute.' '.$css,L('copyfrom_tips')); }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'smallint'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="96%"> <tr> <td>默认值</td> <td> <input type="hidden" name="setting[minnumber]" value="<?php echo $setting['minnumber'];?>"> <input type="text" name="setting[defaultvalue]" value="<?php echo $setting['defaultvalue'];?>" size="40" class="input-text"> 正整数 最大长度 5 </td> </tr> </table>
PHP
function downfile($field, $value, $fieldinfo) { $list_str = $str = ''; extract(string2array($fieldinfo['setting'])); if($value){ $value_arr = explode('|',$value); $value = $value_arr['0']; $sel_server = $value_arr['1'] ? explode(',',$value_arr['1']) : ''; $edit = 1; } else { $edit = 0; } $server_list = getcache('downservers','commons'); if(is_array($server_list)) { foreach($server_list as $_k=>$_v) { if (in_array($_v['siteid'],array(0,$fieldinfo['siteid']))) { $checked = $edit ? ((is_array($sel_server) && in_array($_k,$sel_server)) ? ' checked' : '') : ' checked'; $list_str .= "<lable id='downfile{$_k}' class='ib lh24' style='width:25%'><input type='checkbox' value='{$_k}' name='{$field}_servers[]' {$checked}> {$_v['sitename']}</lable>"; } } } $string = ' <fieldset class="blue pad-10"> <legend>'.L('mirror_server_list').'</legend>'; $string .= $list_str; $string .= '</fieldset> <div class="bk10"></div> '; if(!defined('IMAGES_INIT')) { $str = '<script type="text/javascript" src="'.JS_PATH.'swfupload/swf2ckeditor.js"></script>'; define('IMAGES_INIT', 1); } $authkey = upload_key("$upload_number,$upload_allowext,$isselectimage"); $string .= $str."<input type='text' name='info[$field]' id='$field' value='$value' class='input-text' style='width:80%'/> <input type='button' class='button' onclick=\"javascript:flashupload('{$field}_downfield', '".L('attachment_upload')."','{$field}',submit_files,'{$upload_number},{$upload_allowext},{$isselectimage}','content','$this->catid','{$authkey}')\"/ value='".L('upload_soft')."'>"; return $string; }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'varchar'; //字段数据库类型 $field_basic_table = 0; //是否允许作为主表字段 $field_allow_index = 0; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 0; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php $server_list = getcache('downservers','commons'); foreach($server_list as $_r) if (in_array($_r['siteid'],array(0,$this->siteid))) $str .='<span class="ib" style="width:25%">'.$_r['sitename'].'</span>'; ?> <fieldset> <legend>镜像服务器列表</legend> <?php echo iconv(CHARSET,'utf-8',$str)?> </fieldset> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td>附件下载方式</td> <td> <input name="setting[downloadlink]" value="0" type="radio"> 链接到真实软件地址 <input name="setting[downloadlink]" value="1" checked="checked" type="radio"> 链接到跳转页面 </td></tr> <tr> <td>文件下载方式</td> <td> <input name="setting[downloadtype]" value="0" type="radio"> 链接文件地址 <input name="setting[downloadtype]" value="1" checked="checked" type="radio"> 通过PHP读取 </td></tr> <tr> <td>允许上传的文件类型</td> <td><input type="text" name="setting[upload_allowext]" value="rar|zip" size="40" class="input-text"></td> </tr> <tr> <td>是否从已上传中选择</td> <td><input type="radio" name="setting[isselectfile]" value="1"> 是 <input type="radio" name="setting[isselectimage]" value="0" checked> 否</td> </tr> <tr> <td>允许同时上传的个数</td> <td><input type="text" name="setting[upload_number]" value="10" size=3></td> </tr> </table> <SCRIPT LANGUAGE="JavaScript"> <!-- function add_mirrorsite(obj) { var name = $(obj).siblings("#addname").val(); var url = $(obj).siblings("#addurl").val(); var servers = $("#servers").text()+name+" | "+url+"\r\n"; $("#servers").text(servers); } //--> </SCRIPT>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); $server_list = getcache('downservers','commons'); foreach($server_list as $_r) if (in_array($_r['siteid'],array(0,$this->siteid))) $str .='<span class="ib" style="width:25%">'.$_r['sitename'].'</span>'; ?> <fieldset> <legend>镜像服务器列表</legend> <?php echo $str?> </fieldset> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td>文件链接方式</td> <td> <input name="setting[downloadlink]" value="0" type="radio" <?php if(!$setting['downloadlink']) echo 'checked';?>> 链接到真实软件地址 <input name="setting[downloadlink]" value="1" type="radio" <?php if($setting['downloadlink']) echo 'checked';?>> 链接到跳转页面 </td> </tr> <tr> <td>文件下载方式</td> <td> <input name="setting[downloadtype]" value="0" type="radio" <?php if(!$setting['downloadtype']) echo 'checked';?>> 链接文件地址 <input name="setting[downloadtype]" value="1" type="radio" <?php if($setting['downloadtype']) echo 'checked';?>> 通过PHP读取 </td> <tr> <td>允许上传的文件类型</td> <td><input type="text" name="setting[upload_allowext]" value="<?php echo $setting['upload_allowext'];?>" size="40" class="input-text"></td> </tr> <tr> <td>是否从已上传中选择</td> <td><input type="radio" name="setting[isselectimage]" value="1" <?php if($setting['isselectimage']) echo 'checked';?>> 是 <input type="radio" name="setting[isselectimage]" value="0" <?php if(!$setting['isselectimage']) echo 'checked';?>> 否</td> </tr> <tr> <td>允许同时上传的个数</td> <td><input type="text" name="setting[upload_number]" value="<?php echo $setting['upload_number'];?>" size=3></td> </tr> </tr> </table> <SCRIPT LANGUAGE="JavaScript"> <!-- function add_mirrorsite(obj) { var name = $(obj).siblings("#addname").val(); var url = $(obj).siblings("#addurl").val(); var servers = $("#servers").text()+name+" | "+url+"\r\n"; $("#servers").text(servers); } //--> </SCRIPT>
PHP
function downfile($field, $value) { extract(string2array($this->fields[$field]['setting'])); $list_str = array(); if($value){ $value_arr = explode('|',$value); $fileurl = $value_arr['0']; $sel_server = $value_arr['1'] ? explode(',',$value_arr['1']) : ''; } $server_list = getcache('downservers','commons'); if(is_array($server_list)) { foreach($server_list as $_k=>$_v) { if($value && is_array($sel_server) && in_array($_k,$sel_server)) { $downloadurl = $_v[siteurl].$fileurl; if($downloadlink) { $a_k = urlencode(sys_auth("i=$this->id&s=$_v[siteurl]&m=1&f=$fileurl&d=$downloadtype&modelid=$this->modelid&catid=$this->catid", 'ENCODE', pc_base::load_config('system','auth_key'))); $list_str[] = "<a href='".APP_PATH."index.php?m=content&c=down&a_k={$a_k}' target='_blank'>{$_v[sitename]}</a>"; } else { $list_str[] = "<a href='{$downloadurl}' target='_blank'>{$_v[sitename]}</a>"; } } } } return $list_str; }
PHP
function downfile($field, $value) { //取得镜像站点列表 $result = ''; $server_list = count($_POST[$field.'_servers']) > 0 ? implode(',' ,$_POST[$field.'_servers']) : ''; $result = $value.'|'.$server_list; return $result; }
PHP
<?php if(!$maxlength) $maxlength = 255; $maxlength = min($maxlength, 255); $fieldtype = $issystem ? 'CHAR' : 'VARCHAR'; $sql = "ALTER TABLE `$tablename` CHANGE `$field` `$field` $fieldtype( $maxlength ) NOT NULL DEFAULT '$defaultvalue'"; $db->query($sql); ?>
PHP
function text($field, $value, $fieldinfo) { extract($fieldinfo); $setting = string2array($setting); $size = $setting['size']; if(!$value) $value = $defaultvalue; $type = $ispassword ? 'password' : 'text'; $errortips = $this->fields[$field]['errortips']; if($errortips || $minlength) $this->formValidator .= '$("#'.$field.'").formValidator({onshow:"",onfocus:"'.$errortips.'"}).inputValidator({min:1,onerror:"'.$errortips.'"});'; return '<input type="text" name="info['.$field.']" id="'.$field.'" size="'.$size.'" value="'.$value.'" class="input-text" '.$formattribute.' '.$css.'>'; }
PHP
<?php $db->query("ALTER TABLE `$tablename` DROP `$field`"); ?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'varchar'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 1; //作为全站搜索信息 $field_allow_isunique = 1; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="100">文本框长度</td> <td><input type="text" name="setting[size]" value="<?php echo $setting['size'];?>" size="10" class="input-text"></td> </tr> <tr> <td>默认值</td> <td><input type="text" name="setting[defaultvalue]" value="<?php echo $setting['defaultvalue'];?>" size="40" class="input-text"></td> </tr> <tr> <td>是否为密码框</td> <td><input type="radio" name="setting[ispassword]" value="1" <?php if($setting['ispassword']) echo 'checked';?>> 是 <input type="radio" name="setting[ispassword]" value="0" <?php if(!$setting['ispassword']) echo 'checked';?>> 否</td> </tr> </table>
PHP
function groupid($field, $value, $fieldinfo) { extract(string2array($fieldinfo['setting'])); $grouplist = getcache('grouplist','member'); foreach($grouplist as $_key=>$_value) { $data[$_key] = $_value['name']; } return '<input type="hidden" name="info['.$field.']" value="1">'.form::checkbox($data,$value,'name="'.$field.'[]" id="'.$field.'"','','120'); }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'varchar'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 1; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="200">默认选择的会员组</td> <td><input type="text" name="setting[groupids]" value="<?php echo $setting['groupids'];?>" size="20" class="input-text"> 填写会员组ID,多个用 “|” 分开</td> </tr> </table>
PHP
function groupid($field, $value) { if($value) $value = explode(',',$value); return $value; }
PHP
function groupid($field, $value) { $datas = ''; if(!empty($_POST[$field]) && is_array($_POST[$field])) { $datas = implode(',',$_POST[$field]); } return $datas; }
PHP
function box($field, $value, $fieldinfo) { $setting = string2array($fieldinfo['setting']); if($value=='') $value = $this->fields[$field]['defaultvalue']; $options = explode("\n",$this->fields[$field]['options']); foreach($options as $_k) { $v = explode("|",$_k); $k = trim($v[1]); $option[$k] = $v[0]; } $values = explode(',',$value); $value = array(); foreach($values as $_k) { if($_k != '') $value[] = $_k; } $value = implode(',',$value); switch($this->fields[$field]['boxtype']) { case 'radio': $string = form::radio($option,$value,"name='info[$field]' $fieldinfo[formattribute]",$setting['width'],$field); break; case 'checkbox': $string = form::checkbox($option,$value,"name='info[$field][]' $fieldinfo[formattribute]",1,$setting['width'],$field); break; case 'select': $string = form::select($option,$value,"name='info[$field]' id='$field' $fieldinfo[formattribute]"); break; case 'multiple': $string = form::select($option,$value,"name='info[$field][]' id='$field ' size=2 multiple='multiple' style='height:60px;' $fieldinfo[formattribute]"); break; } return $string; }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'int'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td width="100">选项列表</td> <td><textarea name="setting[options]" rows="2" cols="20" id="options" style="height:100px;width:200px;"><?php echo $setting['options'];?></textarea></td> </tr> <tr> <td>选项类型</td> <td> <input type="radio" name="setting[boxtype]" value="radio" <?php if($setting['boxtype']=='radio') echo 'checked';?> onclick="$('#setcols').show();$('#setsize').hide();"/> 单选按钮 <input type="radio" name="setting[boxtype]" value="checkbox" <?php if($setting['boxtype']=='checkbox') echo 'checked';?> onclick="$('#setcols').show();$('setsize').hide();"/> 复选框 <input type="radio" name="setting[boxtype]" value="select" <?php if($setting['boxtype']=='select') echo 'checked';?> onclick="$('#setcols').hide();$('setsize').show();" /> 下拉框 <input type="radio" name="setting[boxtype]" value="multiple" <?php if($setting['boxtype']=='multiple') echo 'checked';?> onclick="$('#setcols').hide();$('setsize').show();" /> 多选列表框 </td> </tr> <tr> <td>字段类型</td> <td> <select name="setting[fieldtype]" onchange="javascript:fieldtype_setting(this.value);"> <option value="varchar" <?php if($setting['fieldtype']=='varchar') echo 'selected';?>>字符 VARCHAR</option> <option value="tinyint" <?php if($setting['fieldtype']=='tinyint') echo 'selected';?>>整数 TINYINT(3)</option> <option value="smallint" <?php if($setting['fieldtype']=='smallint') echo 'selected';?>>整数 SMALLINT(5)</option> <option value="mediumint" <?php if($setting['fieldtype']=='mediumint') echo 'selected';?>>整数 MEDIUMINT(8)</option> <option value="int" <?php if($setting['fieldtype']=='int') echo 'selected';?>>整数 INT(10)</option> </select> <span id="minnumber" style="display:none"><input type="radio" name="setting[minnumber]" value="1" <?php if($setting['minnumber']==1) echo 'checked';?>/> <font color='red'>正整数</font> <input type="radio" name="setting[minnumber]" value="-1" <?php if($setting['minnumber']==-1) echo 'checked';?>/> 整数</span> </td> </tr> <tbody id="setcols" style="display:"> <tr> <td>每列宽度</td> <td><input type="text" name="setting[width]" value="<?php echo $setting['width'];?>" size="5" class="input-text"> px</td> </tr> </tbody> <tbody id="setsize" style="display:none"> <tr> <td>高度</td> <td><input type="text" name="setting[size]" value="<?php echo $setting['size'];?>" size="5" class="input-text"> 行</td> </tr> </tbody> <tr> <td>默认值</td> <td><input type="text" name="setting[defaultvalue]" size="40" class="input-text" value="<?php echo $setting['defaultvalue'];?>"></td> </tr> <tr> <td>输出格式</td> <td> <input type="radio" name="setting[outputtype]" value="1" <?php if($setting['outputtype']) echo 'checked';?> /> 输出选项值 <input type="radio" name="setting[outputtype]" value="0" <?php if(!$setting['outputtype']) echo 'checked';?> /> 输出选项名称 </td> </tr> <tr> <td>是否作为筛选字段</td> <td> <input type="radio" name="setting[filtertype]" value="1" <?php if($setting['filtertype']) echo 'checked';?> /> 是 <input type="radio" name="setting[filtertype]" value="0" <?php if(!$setting['filtertype']) echo 'checked';?>/> 否 </td> </tr> </table> <SCRIPT LANGUAGE="JavaScript"> <!-- function fieldtype_setting(obj) { if(obj!='varchar') { $('#minnumber').css('display',''); } else { $('#minnumber').css('display','none'); } } //--> </SCRIPT>
PHP
function box($field, $value) { extract(string2array($this->fields[$field]['setting'])); if($outputtype) { return $value; } else { $options = explode("\n",$this->fields[$field]['options']); foreach($options as $_k) { $v = explode("|",$_k); $k = trim($v[1]); $option[$k] = $v[0]; } $string = ''; switch($this->fields[$field]['boxtype']) { case 'radio': $string = $option[$value]; break; case 'checkbox': $value_arr = explode(',',$value); foreach($value_arr as $_v) { if($_v) $string .= $option[$_v].' 、'; } break; case 'select': $string = $option[$value]; break; case 'multiple': $value_arr = explode(',',$value); foreach($value_arr as $_v) { if($_v) $string .= $option[$_v].' 、'; } break; } return $string; } }
PHP
function box($field, $value) { if($this->fields[$field]['boxtype'] == 'checkbox') { if(!is_array($value) || empty($value)) return false; array_shift($value); $value = ','.implode(',', $value).','; return $value; } elseif($this->fields[$field]['boxtype'] == 'multiple') { if(is_array($value) && count($value)>0) { $value = ','.implode(',', $value).','; return $value; } } else { return $value; } }
PHP
function copyfrom($field, $value, $fieldinfo) { $value_data = ''; if($value && strpos($value,'|')!==false) { $arr = explode('|',$value); $value = $arr[0]; $value_data = $arr[1]; } $copyfrom_array = getcache('copyfrom','admin'); $copyfrom_datas = array(L('copyfrom_tips')); if(!empty($copyfrom_array)) { foreach($copyfrom_array as $_k=>$_v) { if($this->siteid==$_v['siteid']) $copyfrom_datas[$_k] = $_v['sitename']; } } return "<input type='text' name='info[$field]' value='$value' style='width: 400px;' class='input-text'>".form::select($copyfrom_datas,$value_data,"name='{$field}_data' "); }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'varchar'; //字段数据库类型 $field_basic_table = 0; //是否允许作为主表字段 $field_allow_index = 0; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 0; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td>默认值</td> <td><input type="text" name="setting[defaultvalue]" value="<?php echo $setting['defaultvalue'];?>" size="50" class="input-text"></td> </tr> </table>
PHP
function copyfrom($field, $value) { static $copyfrom_array; if(!$copyform_array) $copyfrom_array = getcache('copyfrom','admin'); if($value && strpos($value,'|')!==false) { $arr = explode('|',$value); $value = $arr[0]; $value_data = $arr[1]; } if($value_data) { $copyfrom_link = $copyfrom_array[$value_data]; if(!empty($copyfrom_array)) { $imgstr = ''; if($value=='') $value = $copyfrom_link['siteurl']; if($copyfrom_link['thumb']) $imgstr = "<a href='{$copyfrom_link[siteurl]}' target='_blank'><img src='{$copyfrom_link[thumb]}' height='15'></a> "; return $imgstr."<a href='$value' target='_blank' style='color:#AAA'>{$copyfrom_link[sitename]}</a>"; } } else { return $value; } }
PHP
function copyfrom($field, $value) { $field_data = $field.'_data'; if(isset($_POST[$field_data])) { $value .= '|'.$_POST[$field_data]; } return $value; }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'readpoint'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 0; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $this->db->query("ALTER TABLE `$tablename` DROP `$field`"); ?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $defaultvalue = isset($_POST['setting']['defaultvalue']) ? $_POST['setting']['defaultvalue'] : ''; $minnumber = isset($_POST['setting']['minnumber']) ? $_POST['setting']['minnumber'] : 1; $decimaldigits = isset($_POST['setting']['decimaldigits']) ? $_POST['setting']['decimaldigits'] : ''; switch($field_type) { case 'varchar': if(!$maxlength) $maxlength = 255; $maxlength = min($maxlength, 255); $fieldtype = $issystem ? 'CHAR' : 'VARCHAR'; $sql = "ALTER TABLE `$tablename` CHANGE `$oldfield` `$field` $fieldtype( $maxlength ) NOT NULL DEFAULT '$defaultvalue'"; $this->db->query($sql); break; case 'tinyint': $minnumber = intval($minnumber); $defaultvalue = intval($defaultvalue); $this->db->query("ALTER TABLE `$tablename` CHANGE `$oldfield` `$field` TINYINT ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'"); break; case 'number': $minnumber = intval($minnumber); $defaultvalue = $decimaldigits == 0 ? intval($defaultvalue) : floatval($defaultvalue); $sql = "ALTER TABLE `$tablename` CHANGE `$oldfield` `$field` ".($decimaldigits == 0 ? 'INT' : 'FLOAT')." ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'"; $this->db->query($sql); break; case 'smallint': $minnumber = intval($minnumber); $defaultvalue = intval($defaultvalue); $this->db->query("ALTER TABLE `$tablename` CHANGE `$oldfield` `$field` SMALLINT ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'"); break; case 'mediumint': $minnumber = intval($minnumber); $defaultvalue = intval($defaultvalue); $this->db->query("ALTER TABLE `$tablename` CHANGE `$oldfield` `$field` MEDIUMINT ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'"); break; case 'int': $minnumber = intval($minnumber); $defaultvalue = intval($defaultvalue); $this->db->query("ALTER TABLE `$tablename` CHANGE `$oldfield` `$field` INT ".($minnumber >= 0 ? 'UNSIGNED' : '')." NOT NULL DEFAULT '$defaultvalue'"); break; case 'mediumtext': $this->db->query("ALTER TABLE `$tablename` CHANGE `$oldfield` `$field` MEDIUMTEXT NOT NULL"); break; case 'text': $this->db->query("ALTER TABLE `$tablename` CHANGE `$oldfield` `$field` TEXT NOT NULL"); break; case 'date': $this->db->query("ALTER TABLE `$tablename` CHANGE `$oldfield` `$field` DATE NULL"); break; case 'datetime': $this->db->query("ALTER TABLE `$tablename` CHANGE `$oldfield` `$field` DATETIME NULL"); break; case 'timestamp': $this->db->query("ALTER TABLE `$tablename` CHANGE `$oldfield` `$field` TIMESTAMP NOT NULL"); break; //特殊自定义字段 case 'pages': break; case 'readpoint': $defaultvalue = intval($defaultvalue); $this->db->query("ALTER TABLE `$tablename` CHANGE `$oldfield` `readpoint` smallint(5) unsigned NOT NULL default '$defaultvalue'"); break; } ?>
PHP
function brand($field, $value, $fieldinfo) { //品牌 $brand_db = pc_base::load_model('brand_model'); $brand_1 = $brand_db->select(array('catid'=>$this->catid, 'parentid'=>0), 'id,name', '', 'name ASC'); if (is_array($brand_1)) { foreach ($brand_1 as &$b){ $b['child'] = $brand_db->select(array('catid'=>$this->catid, 'parentid'=>$b['id']), 'id,name', '', 'name ASC'); } } if(intval($value) > 0) { $brand = $brand_db->get_one('`id`='.$value, 'id,name,parentid'); if ($brand['parentid'] == 0) { $parent_brand = $brand; } else { //$brand = $brand_db->get_one('`id`='.$arrvalue[1], 'id,name,parentid'); $parent_brand = $brand_db->get_one('`id`='.$brand['parentid'], 'id,name'); } } $str = $str2 = ''; if($brand_1) { $str = '<select name="info['.$field.'][]" id="brand_1">'; foreach($brand_1 AS $b1) { $str .= "<option value='".$b1['id']."' ".(isset($parent_brand['id']) && $parent_brand['id']==$b1['id'] ? "selected":"").">".$b1['name']."</option>"; } if ($parent_brand != $brand) { $str2 .= '<select name="info['.$field.'][]" id="brand_2">'; foreach($brand_1 AS $b1) { if($b1['id'] == $parent_brand['id']) { foreach($b1['child'] AS $b2) { $str2 .= "<option value='".$b2['id']."' ".(isset($brand['id']) && $brand['id']==$b2['id'] ? "selected":"").">".$b2['name']."</option>"; } } } } else { $str2 .= '<select name="info['.$field.'][]" id="brand_2" '.((isset($brand_1[0]['child']) && $brand_1[0]['child'] && !$value) ? '' : 'style="display:none;"').'>'; foreach($brand_1[0]['child'] AS $b2) { $str2 .= "<option value='".$b2['id']."'>".$b2['name']."</option>"; } } $str .= '</select>'; $str2 .= '</select>'; } else { return "<span class='red'>此栏目暂时没有关联品牌</span>"; } $js = '<script type="text/javascript"> var brands = '.json_encode($brand_1).'; $(function(){ $("#brand_1").change(function(){ var bid_1 = this.value; var html=""; for(i in brands) { if(brands[i].id == bid_1) { for(j in brands[i].child) { html += "<option value=\'"+brands[i].child[j].id+"\'>"+brands[i].child[j].name+"</option>"; } if(html=="") { $("#brand_2").html(html).hide(); }else { $("#brand_2").show().html(html); } } } }); }); </script>'; return $str.$str2.$js; }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'varchar'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'mediumtext'; //字段数据库类型 $field_basic_table = 0; //是否允许作为主表字段 $field_allow_index = 0; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 0; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?> <table cellpadding="2" cellspacing="1" width="98%"> <tr> <td>允许上传的文件类型</td> <td><input type="text" name="setting[upload_allowext]" value="<?php echo $setting['upload_allowext'];?>" size="40" class="input-text"></td> </tr> <tr> <td>是否从已上传中选择</td> <td><input type="radio" name="setting[isselectimage]" value="1" <?php if($setting['isselectimage']) echo 'checked';?>> 是 <input type="radio" name="setting[isselectimage]" value="0" <?php if(!$setting['isselectimage']) echo 'checked';?>> 否</td> </tr> <tr> <td>允许同时上传的个数</td> <td><input type="text" name="setting[upload_number]" value="<?php echo $setting['upload_number'];?>" size=3></td> </tr> <tr> <td>文件链接方式</td> <td> <input name="setting[downloadlink]" value="0" type="radio" <?php if(!$setting['downloadlink']) echo 'checked';?>> 链接到真实软件地址 <input name="setting[downloadlink]" value="1" type="radio" <?php if($setting['downloadlink']) echo 'checked';?>> 链接到跳转页面 </td> </tr> <tr> <td>文件下载方式</td> <td> <input name="setting[downloadtype]" value="0" type="radio" <?php if(!$setting['downloadtype']) echo 'checked';?>> 链接文件地址 <input name="setting[downloadtype]" value="1" type="radio" <?php if($setting['downloadtype']) echo 'checked';?>> 通过PHP读取 </td> </tr> </table>
PHP
function downfiles($field, $value) { extract(string2array($this->fields[$field]['setting'])); $list_str = array(); $file_list = string2array($value); if(is_array($file_list)) { foreach($file_list as $_k=>$_v) { if($_v[fileurl]){ $filename = $_v[filename] ? $_v[filename] : L('click_to_down'); if($downloadlink) { $a_k = urlencode(sys_auth("i=$this->id&s=&m=1&f=$_v[fileurl]&d=$downloadtype&modelid=$this->modelid&catid=$this->catid", 'ENCODE', pc_base::load_config('system','auth_key'))); $list_str[] = "<a href='".APP_PATH."index.php?m=content&c=down&a_k={$a_k}' target='_blank'>{$filename}</a>"; } else { $list_str[] = "<a href='{$_v[fileurl]}' target='_blank'>{$filename}</a>"; } } } } return $list_str; }
PHP
function downfiles($field, $value) { $files = $_POST[$field.'_fileurl']; $files_alt = $_POST[$field.'_filename']; $array = $temp = array(); if(!empty($files)) { foreach($files as $key=>$file) { $temp['fileurl'] = $file; $temp['filename'] = $files_alt[$key]; $array[$key] = $temp; } } $array = array2string($array); return $array; }
PHP
function template($field, $value, $fieldinfo) { $sitelist = getcache('sitelist','commons'); $default_style = $sitelist[$this->siteid]['default_style']; return form::select_template($default_style,'content',$value,'name="info['.$field.']" id="'.$field.'"','show'); }
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $field_type = 'tinyint'; //字段数据库类型 $field_basic_table = 1; //是否允许作为主表字段 $field_allow_index = 1; //是否允许建立索引 $field_minlength = 0; //字符长度默认最小值 $field_maxlength = ''; //字符长度默认最大值 $field_allow_search = 1; //作为搜索条件 $field_allow_fulltext = 0; //作为全站搜索信息 $field_allow_isunique = 0; //是否允许值唯一 ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.');?>
PHP
function datetime($field, $value, $fieldinfo) { extract(string2array($fieldinfo['setting'])); $isdatetime = 0; if($fieldtype=='int') { if(!$value) $value = SYS_TIME; $format_txt = $format == 'm-d' ? 'm-d' : $format; $value = date($format_txt,$value); $isdatetime = strlen($format) > 6 ? 1 : 0; } elseif($fieldtype=='datetime') { $isdatetime = 1; } return form::date("info[$field]",$value,$isdatetime,1); }
PHP