| @@ -44,43 +44,44 @@ function obtainimgs($string, $num) | |||
| preg_match_all("/<img([^>]*)\s*src=('|\")([^'\"]+)('|\")/", $string, $matches); | |||
| $imgsrc_arr = array_unique($matches[3]); | |||
| $i = 0; | |||
| $result = ''; | |||
| $newimg = ''; | |||
| foreach ($imgsrc_arr as $imgsrc) | |||
| { | |||
| if ($i == $num) break; | |||
| $result .= "<img src=\"{$imgsrc}\">"; | |||
| $newimg .= "<img src=\"{$imgsrc}\">"; | |||
| $i++; | |||
| } | |||
| return $result; | |||
| return $newimg; | |||
| } | |||
| //文档图片注释自动为标题{dede:field.body function='obtainalt(@me)'/} | |||
| function obtainalt($newalt) | |||
| { | |||
| global $dsql, $id; | |||
| $row = $dsql->GetOne("SELECT title FROM `#@__archives` WHERE id='$id'"); | |||
| //检查$row是否为有效的数组并且包含title | |||
| if (is_array($row) && isset($row['title'])) { | |||
| //图片注释自动为标题 | |||
| $newalt = str_ireplace(array('alt=""', "alt=''", 'title=""', "title=''"), "", $newalt); | |||
| $newalt = str_ireplace("<img", "<img alt=\"".$row['title']."\" title=\"".$row['title']."\"", $newalt); | |||
| //去掉图片宽度和高度 | |||
| $newalt = preg_replace("/style=\"width\:(.*)\"/", "", $newalt); | |||
| //去掉结尾多余的空格和斜杠 | |||
| $newalt = str_ireplace(" ", " ", $newalt); | |||
| $newalt = str_ireplace(" /", "", $newalt); | |||
| } | |||
| global $dsql, $id, $aid; | |||
| $imgid = isset($id) ? $id : $aid; | |||
| $row = $dsql->GetOne("SELECT title FROM `#@__archives` WHERE id='$imgid'"); | |||
| //检查$row是否有效 | |||
| $title = isset($row['title']) ? $row['title'] : ''; | |||
| //图片注释自动为标题 | |||
| $newalt = str_ireplace(array('alt=""', 'alt=\'\'', 'title=""', 'title=\'\''), "", $newalt); | |||
| $newalt = str_ireplace("<img", "<img alt=\"{$title}\" title=\"{$title}\"", $newalt); | |||
| //去掉图片宽度和高度 | |||
| $newalt = preg_replace("/style=\"width\:(.*)\"/", "", $newalt); | |||
| //去掉结尾多余的空格和斜杠 | |||
| $newalt = str_ireplace(" ", " ", $newalt); | |||
| $newalt = str_ireplace(" /", "", $newalt); | |||
| return $newalt; | |||
| } | |||
| //联动单筛选{dede:php}obtainfilter(模型id,类型,'字段1,字段2');{/dede:php}类型表示前台展现方式,对应case值,例如:文档模型style字段radio选项卡类型,列表附加字段类别添加style,标签调用{dede:php}obtainfilter(1,1,'style');{/dede:php} | |||
| function obtainfilter($channelid, $type = 1, $fieldsnamef = '', $defaulttid = 0, $toptid = 0, $loadtype = 'autofield') | |||
| { | |||
| global $tid, $dsql, $id; | |||
| global $dsql, $tid, $id, $aid; | |||
| $tid = $defaulttid ? $defaulttid : $tid; | |||
| if ($id != "") { | |||
| $tidsq = $dsql->GetOne("SELECT * FROM `#@__archives` WHERE id='$id'"); | |||
| if ($id != "" || $aid != "") { | |||
| $arcid = $id != "" ? $id : $aid; | |||
| $tidsq = $dsql->GetOne("SELECT * FROM `#@__archives` WHERE id='$arcid'"); | |||
| $tid = $toptid == 0 ? $tidsq["typeid"] : $tidsq["topid"]; | |||
| } | |||
| $nofilter = (isset($_REQUEST['TotalResult']) ? "&TotalResult=".$_REQUEST['TotalResult'] : '').(isset($_REQUEST['PageNo']) ? "&PageNo=".$_REQUEST['PageNo'] : ''); | |||
| $nofilter = (isset($_REQUEST['Totalnewimg']) ? "&Totalnewimg=".$_REQUEST['Totalnewimg'] : '').(isset($_REQUEST['PageNo']) ? "&PageNo=".$_REQUEST['PageNo'] : ''); | |||
| $filterarr = stripos($_SERVER['REQUEST_URI'], "list.php?tid=") ? str_replace($nofilter, '', $_SERVER['REQUEST_URI']) : $GLOBALS['cfg_cmsurl']."apps/list.php?tid=".$tid; | |||
| $cInfos = $dsql->GetOne("SELECT * FROM `#@__channeltype` WHERE id='$channelid'"); | |||
| $fieldset=$cInfos['fieldset']; | |||