?> " /></td> </tr> <tr> <td class='label'>修改时间:</td> <td class='attributeinput'><input type="text" name="modifytime" value="<?php echo date("Y-m-d H:i:s"); ?> " /></td> </tr> <!--自定义字段--> <tr> <td class='label'>属性:</td> <td class='attributeinput'> <?php $sdef_fields = getresult("select * from I_field where columnid=" . getChanelidByColumnid($columnid)); while ($row = getresultarray($sdef_fields)) { echo $row["info"] . ":<input type='text' name='" . $row["fieldname"] . "' value='" . getresultData($result, 0, $row["fieldname"]) . "'><br>"; } ?> </td> </tr> <!--自定义字段--> <tr> <td class='label'>简介:</td> <td class='attributeinput'><textarea name="notes"><?php echo $notes; ?> </textarea></td> </tr> <tr>
function translateSdefFeildlabel($template) { global $id; //文章id $id = $_GET["articleid"] != NULL ? $_GET["articleid"] : $id; $columnid = $_GET["columnid"] != NULL ? $_GET["columnid"] : getarticleinfo($_GET["articleid"], "columnid"); if ($columnid == NULL && $id != NULL) { $columnid = getarticleinfo($id, "columnid"); } if ($columnid != NULL && $columnid > 0 || $id != NULL && $id > 0) { //如果栏目id为空或者小于1,则不对模板进行处理 $sdef_fields = getresult("select * from I_field where columnid in (" . getChanelidByColumnid($columnid) . ")"); //echo "select * from I_field where columnid in (".getChanelidByColumnid($columnid).")"; $fieldname = ""; $fieldvalue = ""; while ($row = getresultarray($sdef_fields)) { $fieldname = $row["fieldname"]; $temparticle = getresult("select * from I_article where id={$id}"); if (!$temparticle) { continue; } $fieldvalue = getresultData($temparticle, 0, $fieldname); //如果值为空,则替换为空串 if ($fieldvalue == NULL) { $fieldvalue = ""; } $template = str_replace("【#" . $fieldname . "】", $fieldvalue, $template); } } return $template; }
function translateSearchlist($template) { global $pagesize; //如果指定页大小,则用用户参数填充$pagesize //匹配自定义文章列表标签正则 $flag = "/【searchlist(\\(\\d*,\\d*,\\d*,\\d*\\))】([\\s\\S]*?)【\\/searchlist】/"; preg_match_all($flag, $template, $matches, PREG_SET_ORDER); //替换所有articlelist标签 $html = $template; //echo $template; foreach ($matches as $matche) { //得到需要循环的部分 $str = $matche[2]; //得到标签参数参数 $parameter = substr($matche[1], 1, strlen($matche[1]) - 2); $parameter = split(',', $parameter); $articlenum = $parameter[0]; $titlelen = $parameter[1]; $timetype = $parameter[2]; $sorttype = $parameter[3]; //定义排序方式的字串 if ($sorttype == "0") { //id降序 $sortstr = "order by id desc"; } else { $sortstr = "order by id asc"; } //得到url参数 $pagesize = $articlenum; //($_GET["pagesize"]==NULL || $_GET["pagesize"]<=0)?10:$_GET["pagesize"]; $currentpage = $_GET["currentpage"] == NULL || $_GET["currentpage"] <= 0 ? 1 : $_GET["currentpage"]; //根据参数从数据库取得数据 $searchSql = "select *,left(title,{$titlelen}) as title from I_article where ifpass=1"; if ($_GET["title"] != NULL && $_GET["title"] != "") { $searchSql .= " and title like '%" . $_GET["title"] . "%'"; } if ($_GET["columnid"] != NULL && $_GET["columnid"] > 0) { $sdef_fields = getresult("select * from I_field where columnid=" . getChanelidByColumnid($_GET["columnid"])); while ($row = getresultarray($sdef_fields)) { if ($_GET[$row["fieldname"]] == NULL || $_GET[$row["fieldname"]] == "") { continue; } if ($row["datatype"] == "double") { $searchSql .= " and " . $row["fieldname"] . " " . $_GET[$row["fieldname"] . "ctype"] . $_GET[$row["fieldname"]]; //echo $_GET[$row["fieldname"]."ctype"]."测试"; } else { $searchSql .= " and " . $row["fieldname"] . " like '" . $_GET[$row["fieldname"]] . "'"; } } //在所有子栏目中搜索 $childcolumnStr = ""; getchildcolumnid($_GET["columnid"], $childcolumnStr); $searchSql .= " and columnid in (" . $childcolumnStr . ")"; //echo "Iron".$searchSql; } $searchSql .= " " . $sortstr . " limit " . ($currentpage - 1) * $pagesize . ",{$pagesize}"; //echo $searchSql; $result = getresult($searchSql); //匹配循环部分的标签 $tag_flag = "/【#[\\s\\S]*?】/"; preg_match_all($tag_flag, $str, $data_tag, PREG_SET_ORDER); $tag_index = null; //记录标签循环部分每中标签出现的次数,如果出现第二次,则视为要显示两列数据,依次类推... //将要输出的html代码; $temphtml = ""; while ($row = getresultArray($result)) { $str = $matche[2]; foreach ($data_tag as $temp) { //$tempindex = 0; for (;;) { if ($tag_index[$temp[0]] < 1) { //初始化一篇文章数据 initarticledata($row); //替换标签 $str = replace_once($temp[0], $str, getvalue($temp[0], $timetype)); //当前匹配标签计数器加1 if (isset($tag_index[$temp[0]])) { $tag_index[$temp[0]]++; } else { $tag_index[$temp[0]] = 1; } break; } else { //取新文章数据 $row = getresultArray($result); //第二次出现的标签都会引发取得新数据,故产生错误 //初始化数据 initarticledata($row); //当前匹配标签计数器加1 $tag_index = NULL; } } } $tag_index = NULL; $temphtml .= $str; } //echo $matche[0]."<br>";//.$temphtml; if (trim($temphtml) == "") { $html = str_replace($matche[0], gettext_r("haveNot") . gettext_r("search") . gettext_r("result"), $html); } else { $html = str_replace($matche[0], $temphtml, $html); } } //显示搜索表单 $html = str_replace("【#searchform】", getsearchform(), $html); //显示分页 $html = str_replace("【#showpage】", getsearchPage($pagesize), $html); return $html; }