本文整理汇总了PHP中model::isDefField方法的典型用法代码示例。如果您正苦于以下问题:PHP model::isDefField方法的具体用法?PHP model::isDefField怎么用?PHP model::isDefField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类model
的用法示例。
在下文中一共展示了model::isDefField方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: dosave
function dosave()
{
include_once iPATH . 'include/tag.class.php';
$id = $_POST['id'];
$mid = $_POST['mid'];
$FArray = model::field($mid);
$model = model::data($mid);
$content = array();
if ($_POST['content']) {
foreach ($_POST['content'] as $field => $value) {
if (model::isDefField($field)) {
switch ($field) {
case "userid":
$value = intval($value);
break;
case "fid":
$value = $fid = intval($value);
empty($value) && javascript::alert('请选择所属栏目');
break;
case "orderNum":
$value = _int($value);
break;
case "top":
$value = _int($value);
break;
case "title":
$value = dhtmlspecialchars($value);
empty($value) && javascript::alert('标题不能为空!');
break;
case "editor":
$value = dhtmlspecialchars($value);
break;
case "tags":
$value = iTAG::split(dhtmlspecialchars($value), true);
break;
case "type":
$value = intval($value);
break;
case "vlink":
$value = implode(',', $value);
break;
case "postype":
$value = empty($value) ? intval($value) : "1";
break;
case "pubdate":
$value = _strtotime($value);
break;
case "clink":
$value = dhtmlspecialchars($value);
if ($value) {
$clinklen = strlen($value);
for ($i = 0; $i < $clinklen; $i++) {
!preg_match("/[a-zA-Z0-9_\\-~" . preg_quote($this->iCMS->config['CLsplit'], '/') . "]/", $value[$i]) && javascript::alert('自定链接只能由英文字母、数字或_-~组成(不支持中文)');
}
}
break;
}
} elseif ($F = $FArray[$field]) {
switch ($F['type']) {
case "number":
$value = intval($value);
break;
case "calendar":
$value = _strtotime($value);
break;
case in_array($F['type'], array('text', 'textarea', 'radio', 'select', 'email', 'url', 'image', 'upload')):
$value = dhtmlspecialchars($value);
break;
case in_array($F['type'], array('checkbox', 'multiple')):
$value = implode(',', $value);
break;
case 'editor':
$this->iCMS->config['autoformat'] && ($value = autoformat($value));
break;
default:
$value = dhtmlspecialchars($value);
}
}
WordFilter($value) && javascript::alert($field . '字段包含被系统屏蔽的字符,请返回重新填写。');
$content[$field] = $value;
$PF[] = $field;
}
}
if (empty($content['clink'])) {
include iPATH . 'include/cn.class.php';
$content['clink'] = CN::pinyin($content['title'], $this->iCMS->config['CLsplit']);
}
$table = model::tbn($_POST['table']);
$MF = explode(',', $model['field']);
$diff = array_diff_values($PF, $MF);
if ($diff['-']) {
foreach ($diff['-'] as $field) {
$content[$field] = '';
}
}
//缺少的字段 填认空值
$SELFURL = __SELF__ . (empty($_POST['REFERER']) ? '?mo=content&do=manage' : $_POST['REFERER']);
$forum = new forum();
if (empty($id)) {
empty($content['userid']) && ($content['userid'] = member::$uId);
//.........这里部分代码省略.........
示例2:
if ($rs['hidden']) {
?>
[隐藏字段]<?php
}
?>
</td>
<td><?php
echo $rs['description'];
?>
</td>
<td><!--{$content.<?php
echo $rs['field'];
?>
}--></td>
<td><?php
if (!model::isDefField($rs['field'])) {
?>
<a href="<?php
echo __ADMINCP__;
?>
=models&do=addfield&id=<?php
echo $rs['mid'];
?>
&fid=<?php
echo $rs['id'];
?>
">编辑</a> |
<a href="<?php
echo __ADMINCP__;
?>
=models&do=delfield&id=<?php
示例3: form
//.........这里部分代码省略.........
$html .= '<option value="0"> == 不选择 == </option>';
$valArray = explode(',', $val);
foreach ((array) $optArray as $value => $text) {
$selected = in_array($value, $valArray) ? ' selected="selected"' : '';
$html .= '<option value="' . $value . '"' . $selected . '>' . $text . '</option>';
}
$html .= '</select>';
break;
case "calendar":
$html = '<input name="content[' . $id . ']" class="txt datepicker" value="' . get_date($val, 'Y-m-d H:i:s') . '" id="' . $id . '" type="text"/>';
break;
// case "image":
// $html='<input name="content['.$id.']" id="image_'.$id.'" type="text" value="'.$val.'" class="txt" style="width:450px"/>';
// $html.='<button type="button" class="selectdefault button" hidefocus=true to="image_'.$id.'"><span>选 择</span></button>';
// $html.='<div id="image_'.$id.'_menu" style="display:none;">';
// $html.='<ul>';
// $html.='<li onClick="iCMS.showDialog(\''.__ADMINCP__.'=dialog&do=Aupload\',\'image_'.$id.'\',\'本地上传\',400,150);">本地上传</li>';
// $html.='<li onClick="iCMS.showDialog(\''.__ADMINCP__.'=dialog&do=file&click=file&type=gif,jpg,png,bmp,jpeg\',\'image_'.$id.'\',\'从网站选择\');">从网站选择</li>';
// $html.='<li onClick="viewPic(\'image_'.$id.'\');">查看缩略图</li>';
// $html.='<li onClick="crop(\'image_'.$id.'\');">剪裁图片</li>';
// $html.='</ul></div>';
// break;
// case "image":
// $html='<input name="content['.$id.']" id="image_'.$id.'" type="text" value="'.$val.'" class="txt" style="width:450px"/>';
// $html.='<button type="button" class="selectdefault button" hidefocus=true to="image_'.$id.'"><span>选 择</span></button>';
// $html.='<div id="image_'.$id.'_menu" style="display:none;">';
// $html.='<ul>';
// $html.='<li onClick="iCMS.showDialog(\''.__ADMINCP__.'=dialog&do=Aupload\',\'image_'.$id.'\',\'本地上传\',400,150);">本地上传</li>';
// $html.='<li onClick="iCMS.showDialog(\''.__ADMINCP__.'=dialog&do=file&click=file&type=gif,jpg,png,bmp,jpeg\',\'image_'.$id.'\',\'从网站选择\');">从网站选择</li>';
// $html.='<li onClick="viewPic(\'image_'.$id.'\');">查看缩略图</li>';
// $html.='<li onClick="crop(\'image_'.$id.'\');">剪裁图片</li>';
// $html.='</ul></div>';
// break;
case "upload":
$html = '<div id="' . $id . '1" style="display:' . ($val ? 'none' : 'block') . ';"><input id="' . $id . 'file" name="content_upload_' . $id . '" type="file" style="width:600px;" /><span id="c' . $id . '1" style="display:' . ($val ? '' : 'none') . '">[<a href="javascript:iCMS.SH(\'' . $id . '2\',\'' . $id . '1\');">取消</a>]</span></div>
<div id="' . $id . '2" style="display:' . ($val ? 'block' : 'none') . '"><a class="content_viewPic" ref="' . $id . '" href="javascript:void(0);" title="点击查看图片">' . $val . '</a><input name="content[' . $id . ']" type="text" value="' . $val . '" class="txt content_upload_' . $id . '" style="display:none;"/> [<a href="javascript:iCMS.SH(\'' . $id . '1\',\'' . $id . '2\');">重新上传</a>] [<a href="' . ($isUser ? __USERCP__ : __ADMINCP__) . '=content&do=delpic&mid=' . $mId . '&table=' . $mName . '&id=' . $rs['id'] . '&field=' . $id . '&fp=' . $val . '" target="iCMS_FRAME">删除</a>]</div><script type="text/javascript"> $(".content_viewPic").click(function(){
var path =$(\'.content_upload_\'+$(this).attr(\'ref\')).val();
iCMS.showDialog("' . ($isUser ? __USERCP__ : __ADMINCP__) . '=dialog&do=viewPic",path,\'查看图片\');
});</script>';
break;
}
}
if ($A['show'] || !$isUser) {
$FORM['general'] = array('id' => $id, 'label' => $A['name'], 'description' => $A['description'], 'html' => $html);
}
}
if (!model::isDefField($id)) {
$valal = '$("#' . $id . '").val()';
//验证
switch ($A['validate']) {
case "0":
//不能为空
if ($A['type'] == "editor") {
$js = 'var ' . $id . '_Editor = FCKeditorAPI.GetInstance(\'content[' . $id . ']\') ;
if(' . $id . '_Editor.GetXHTML( true )==""){
alert("' . $A['name'] . '不能为空!");
' . $id . '_Editor.focus();
return false;
}';
} else {
$js = 'if(' . $valal . '==""){
alert("' . $A['name'] . '不能为空!");
$("#' . $id . '").focus();
return false;}';
}
break;
case "2":
$js = 'var ' . $id . '_val = ' . $valal . ';
var pattern = /^\\d+(\\.\\d+)?$/;
chkFlag = pattern.test(' . $id . '_val);
if(!chkFlag){
alert("' . $A['name'] . '不是数字");
$("#' . $id . '").focus();
return false;}';
break;
case "4":
$js = 'var ' . $id . '_val = ' . $valal . ';
var pattern = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(\\.[a-zA-Z0-9_-])+/;
if(!pattern.test(' . $id . '_val)){
alert("邮箱地址的格式不正确!!");
$("#' . $id . '").focus();
return false;}';
break;
case "5":
$js = 'var ' . $id . '_val = ' . $valal . ';
var pattern = /^[a-zA-z]+:\\/\\/[^\\s]*/;
if(!pattern.test(' . $id . '_val)){
alert("[' . $A['name'] . ']网址格式不正确!!");
$("#' . $id . '").focus();
return false;}';
break;
}
}
if ($A['show'] || !$isUser) {
$FORM['js'] = $js;
}
// var_dump($FORM);
// var_dump($A);
return $FORM;
}
示例4: doEditField
function doEditField()
{
$fid = (int) $_POST['fid'];
$mid = (int) $_POST['mid'];
$name = dhtmlspecialchars($_POST['name']);
$field = dhtmlspecialchars($_POST['field']);
$ofield = dhtmlspecialchars($_POST['ofield']);
if (empty($field)) {
include iPATH . 'include/cn.class.php';
$field = CN::pinyin($name);
}
$type = $_POST['type'];
$show = $_POST['show'];
$default = dhtmlspecialchars($_POST['default']);
$validate = $_POST['validate'];
$description = dhtmlspecialchars($_POST['description']);
$option = addslashes(serialize($_POST['option']));
$hidden = isset($_POST['hidden']) ? 1 : 0;
!preg_match("/[a-zA-Z]/", $field[0]) && javascript::alert('字段只能以英文字母开头');
!preg_match("/[a-zA-Z0-9_\\-~]/", $field) && javascript::alert('字段只能由英文字母或数字组成');
model::isDefField($field) && javascript::alert('您所填写的字段是默认字段!请重新填写.');
$model = model::data($mid);
$oFieldA = explode(',', $model['field']);
$sql = "ALTER TABLE `#iCMS@__" . model::tbn($model['table']) . "`";
if ($fid) {
iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__field` where `field` = '{$field}' and `mid`='{$mid}' and `id`!='{$fid}'") && javascript::alert('该字段已经存在!请检查是否重复');
iCMS_DB::query("UPDATE `#iCMS@__field` SET `name` = '{$name}', `field` = '{$field}', `mid` = '{$mid}', `type` = '{$type}',`show` = '{$show}', `default` = '{$default}', `validate` = '{$validate}', `hidden` = '{$hidden}', `description` = '{$description}', `option` = '{$option}' WHERE `id` = '{$fid}';");
$sql .= " CHANGE COLUMN `{$ofield}` `{$field}`";
if ($field != $ofield) {
$fKey = array_search($ofield, $oFieldA);
unset($oFieldA[$fKey]);
}
} else {
iCMS_DB::getValue("SELECT `id` FROM `#iCMS@__field` where `field` = '{$field}' and `mid`='{$mid}'") && javascript::alert('该字段已经存在!请检查是否重复');
iCMS_DB::query("INSERT INTO `#iCMS@__field` (`name`, `field`, `mid`, `type`,`show`, `default`, `validate`, `hidden`, `description`, `option`) VALUES ('{$name}', '{$field}', '{$mid}', '{$type}', '{$show}', '{$default}', '{$validate}', '{$hidden}', '{$description}', '{$option}');");
$sql .= " ADD COLUMN `{$field}`";
//新增
$col = iCMS_DB::getCol("describe `#iCMS@__" . model::tbn($model['table']) . "`");
$AfterSql = ' after `' . end($col) . '`';
}
$SqlType = model::SqlType($type, $default);
iCMS_DB::query($sql . $SqlType . $AfterSql);
if ($field != $ofield) {
array_push($oFieldA, $field);
$mField = implode(',', array_unique($oFieldA));
iCMS_DB::query("update `#iCMS@__model` SET `field`='{$mField}' where id='{$mid}'");
}
model::cache();
javascript::dialog('字段添加完成!<br />10秒后返回字段管理', "url:" . __SELF__ . "?mo=models&do=managefield&id=" . $mid);
}
示例5: content
function content($id, $mId, $table = NULL, $tpl = true)
{
$model = $this->getCache('system/models.cache', $mId);
empty($table) && ($table = $model['tbn']);
$rs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__{$table}` WHERE id='" . (int) $id . "' AND `status` ='1'");
empty($rs) && $this->error('error:page');
$F = $this->getCache('system/forum.cache', $rs->fid);
if ($F['status'] == 0) {
return false;
}
if ($rs->url) {
if ($this->mode == "CreateHtml") {
return false;
} else {
$this->go($rs->url);
}
}
if ($this->mode == "CreateHtml" && (strstr($F['contentRule'], '{PHP}') || $F['url'] || $F['mode'] == 0)) {
return false;
}
$_iurlArray = array((array) $rs, $F, $model);
$rs->iurl = $this->iurl('content', $_iurlArray, $page);
$rs->url = $rs->iurl->href;
$tpl && $this->gotohtml($rs->iurl->path, $rs->iurl->href, $F['mode']);
$this->iList($rs->fid, false);
$rs->comment = array('url' => $this->config['publicURL'] . "/comment.php?indexId={$rs->id}&mId={$mId}&sortId={$rs->fid}", 'count' => $rs->comments);
if ($F['mode']) {
$rs->hits = "<script type=\"text/javascript\" src=\"" . $this->config['publicURL'] . "/action.php?do=hits&mid={$mId}&fid={$rs->fid}&id={$rs->id}&action=show\" language=\"javascript\"></script>";
$rs->digg = "<script type=\"text/javascript\" src=\"" . $this->config['publicURL'] . "/action.php?do=digg&mid={$mId}&id={$rs->id}&action=show\" language=\"javascript\"></script>";
$rs->comments = "<script type=\"text/javascript\" src=\"" . $this->config['publicURL'] . "/action.php?do=comment&mid={$mId}&id={$rs->id}&action=show\" language=\"javascript\"></script>";
} else {
$this->mode != 'CreateHtml' && iCMS_DB::query("UPDATE `#iCMS@__{$table}` SET hits=hits+1 WHERE `id` ='{$rs->id}' LIMIT 1");
}
if ($rs->tags) {
$tagarray = explode(',', $rs->tags);
foreach ($tagarray as $tk => $tag) {
$t = $this->getTag($tag);
if ($t) {
$rs->tag[$tk]['name'] = $tag;
$rs->tag[$tk]['url'] = $t['url']->href;
$rs->taglink .= '<a href="' . $rs->tag[$tk]['url'] . '" class="tag" target="_self" title="' . $t['count'] . $this->language('page:list') . '">' . $rs->tag[$tk]['name'] . '</a> ';
}
}
}
if ($fArray = explode(',', $model['field'])) {
include_once iPATH . 'include/model.class.php';
foreach ($fArray as $k => $field) {
if (!model::isDefField($field)) {
$FV = model::FieldValue($mId, $field, $rs->{$field});
$FV !== Null && ($rs->{$field} = $FV);
}
}
}
$rs->prev = $this->language('show:first');
$prers = iCMS_DB::getRow("SELECT * FROM `#iCMS@__{$table}` WHERE `id` < '{$rs->id}' AND `fid`='{$rs->fid}' AND `status`='1' order by id DESC Limit 1");
$prers && ($rs->prev = '<a href="' . $this->iurl('content', array((array) $prers, $F, $model))->href . '" class="prev" target="_self">' . $prers->title . '</a>');
$rs->next = $this->language('show:last');
$nextrs = iCMS_DB::getRow("SELECT * FROM `#iCMS@__{$table}` WHERE `id` > '{$rs->id}' and `fid`='{$rs->fid}' AND `status`='1' order by id ASC Limit 1");
$nextrs && ($rs->next = '<a href="' . $this->iurl('content', array((array) $nextrs, $F, $model))->href . '" class="next" target="_self">' . $nextrs->title . '</a>');
$rs->link = "<a href='{$rs->url}'>{$rs->title}</a>";
$rs->mid = $mId;
$rs->table = $table;
$this->Hook($rs);
$this->assign('content', (array) $rs);
if ($tpl) {
$tpl = empty($rs->tpl) ? $F['contentTPL'] : $rs->tpl;
return $this->iPrint($tpl, 'content');
}
}
示例6: iCMS_contents
//.........这里部分代码省略.........
$day = empty($iCMS->date['d']) ? '01' : $iCMS->date['d'];
$start = strtotime($iCMS->date['y'] . $iCMS->date['m'] . $day);
$end = empty($iCMS->date['d']) ? $start + 86400 * $iCMS->date['total'] : $start + 86400;
$whereSQL .= " AND `pubdate`<='{$end}' AND `pubdate`>='{$start}'";
} else {
isset($vars['startdate']) && ($whereSQL .= " AND `pubdate`>='" . strtotime($vars['startdate']) . "'");
isset($vars['enddate']) && ($whereSQL .= " AND `pubdate`<='" . strtotime($vars['enddate']) . "'");
}
isset($vars['where']) && ($whereSQL .= $vars['where']);
if ($vars['action'] == 'search') {
$whereSQL .= $iCMS->actionSQL;
} elseif ($vars['action'] == 'tag') {
if (empty($vars['tag'])) {
return false;
}
if (is_array($vars['tag'])) {
$_tCache = $vars['tag'];
} else {
$_tCache = $iCMS->getCache($iCMS->getTagKey($vars['tag']));
}
if ($_tCache['id']) {
$tidSQL = 'AND `tid`=\'' . $_tCache['id'] . '\'';
} else {
if ($_tCache) {
foreach ($_tCache as $_tag) {
if ($_tag) {
$_tids[] = $_tag['id'];
}
}
}
if (empty($_tids)) {
return false;
}
$tidSQL = 'AND `tid` in (' . implode(',', $_tids) . ')';
}
$countSQL = 'SELECT count(#iCMS@__' . $table . '.id) FROM `#iCMS@__' . $table . '`,`#iCMS@__taglist` WHERE #iCMS@__' . $table . '.id = `indexId` ' . $tidSQL . ' AND #iCMS@__taglist.modelId=' . $mId . ' AND';
$selectSQL = 'SELECT #iCMS@__' . $table . '.* FROM `#iCMS@__' . $table . '`,`#iCMS@__taglist` WHERE #iCMS@__' . $table . '.id = `indexId` ' . $tidSQL . ' AND #iCMS@__taglist.modelId=' . $mId . ' AND';
$orderSQL = " ORDER BY #iCMS@__taglist.indexId {$by}";
$vars['indexId!'] && ($whereSQL .= getSQL($vars['indexId!'], '#iCMS@__' . $table . '.id', 'not'));
}
$offset = 0;
if ($vars['page']) {
empty($countSQL) && ($countSQL = "SELECT count(*) FROM `#iCMS@__{$table}` WHERE");
$total = iCMS_DB::getValue($countSQL . " {$whereSQL}");
// echo iCMS_DB::last_query;
$pagenav = isset($vars['pagenav']) ? $vars['pagenav'] : "pagenav";
$pnstyle = isset($vars['pnstyle']) ? $vars['pnstyle'] : 0;
$offset = $iCMS->multi(array('total' => $total, 'perpage' => $maxperpage, 'unit' => $iCMS->language('page:list'), 'nowindex' => $GLOBALS['page'], 'pagenav' => $pagenav, 'pnstyle' => $pnstyle));
// $GLOBALS['cpn'] && $iCMS->_vars['pagenav'].='<span><a class="page_more" href="more.php?fid='.$ids.'" target="_self">'.$iCMS->language('page:more').'</a></span>';
//$iCMS->addto($pagenav,"----------------");
}
$iscache = true;
if ($vars['cache'] == false || isset($vars['page'])) {
$iscache = false;
$rs = array();
} else {
$cacheName = 'clist/' . md5($whereSQL . $orderSQL . $maxperpage);
$rs = $iCMS->getCache($cacheName);
}
if (empty($rs)) {
empty($selectSQL) && ($selectSQL = "SELECT * FROM `#iCMS@__{$table}` WHERE");
$rs = iCMS_DB::getArray($selectSQL . " {$whereSQL} {$orderSQL} LIMIT {$offset} , {$maxperpage}");
//echo iCMS_DB::$last_query;
//iCMS_DB::$last_query='explain '.iCMS_DB::$last_query;
//$explain=iCMS_DB::getRow(iCMS_DB::$last_query);
//print_r($explain);
$_count = count($rs);
for ($i = 0; $i < $_count; $i++) {
$F = $forum[$rs[$i]['fid']];
$rs[$i]['sort']['name'] = $F['name'];
$rs[$i]['sort']['url'] = $iCMS->iurl('forum', $F)->href;
$rs[$i]['sort']['link'] = "<a href='{$rs[$i]['sort']['url']}'>{$rs[$i]['sort']['name']}</a>";
$rs[$i]['url'] = $iCMS->iurl('content', array($rs[$i], $F, $model))->href;
$rs[$i]['commentUrl'] = $iCMS->config['publicURL'] . "/comment.php?indexId=" . $rs[$i]['id'] . "&mId=" . $mId . "&sortId=" . $rs[$i]['fid'];
$rs[$i]['link'] = "<a href='{$rs[$i]['url']}'>{$rs[$i]['title']}</a>";
if ($rs[$i]['tags'] && isset($vars['tag'])) {
$tagarray = explode(',', $rs[$i]['tags']);
foreach ($tagarray as $tk => $tag) {
$t = $iCMS->getTag($tag);
if ($t) {
$rs[$i]['tag'][$tk]['name'] = $tag;
$rs[$i]['tag'][$tk]['url'] = $t['url']->href;
$rs[$i]['taglink'] .= '<a href="' . $rs[$i]['tag'][$tk]['url'] . '" class="tag" target="_self">' . $tag . '</a> ';
}
}
}
if ($fArray = explode(',', $model['field'])) {
foreach ($fArray as $k => $field) {
if (!model::isDefField($field)) {
$FV = model::FieldValue($mId, $field, $rs[$i][$field]);
$FV !== Null && ($rs[$i][$field] = $FV);
}
}
}
}
$iscache && $iCMS->SetCache($cacheName, $rs, $cacheTime);
}
// var_dump($rs);
return $rs;
}