Browse Source

优化文档列表属性标识

tags/6.0.4^2
xushubieli 3 years ago
parent
commit
f6e045c852
2 changed files with 119 additions and 187 deletions
  1. +7
    -61
      src/dede/inc/inc_archives_functions.php
  2. +112
    -126
      src/dede/inc/inc_list_functions.php

+ 7
- 61
src/dede/inc/inc_archives_functions.php View File

@@ -1,5 +1,4 @@
<?php

/**
* 文档操作相关函数
*
@@ -18,7 +17,6 @@ $backurl = preg_match("#content_#", $backurl) ? "<a href='$backurl' class='btn b
if (!isset($_NOT_ARCHIVES)) {
require_once(DEDEINC.'/customfields.func.php');
}

/**
* 获得HTML里的外部资源,针对图集
*
@@ -58,10 +56,8 @@ function GetCurContentAlbum($body, $rfurl, &$firstdd)
}
$itype = substr($value, -4, 4);
if (!preg_match("#\.(gif|jpg|png)#", $itype)) $itype = ".jpg";

$rndFileName = $imgPath.'/'.$milliSecond.'-'.$key.$itype;
$iurl = $imgUrl.'/'.$milliSecond.'-'.$key.$itype;

//下载并保存文件
$rs = DownImageKeep($value, $rfurl, $rndFileName, '', 0, 30);
if ($rs) {
@@ -92,7 +88,6 @@ function GetCurContentAlbum($body, $rfurl, &$firstdd)
}
return $rsimg;
}

/**
* 获得文章body里的外部资源
*
@@ -108,7 +103,6 @@ function GetCurContent($body)
$basehost = "http://".$_SERVER["HTTP_HOST"];
$img_array = array();
preg_match_all("/src=[\"|'|\s]([^\"|^\'|^\s]*?)/isU", $body, $img_array);

$img_array = array_unique($img_array[1]);
$imgUrl = $cfg_uploaddir.'/'.MyDate("ymd", time());
$imgPath = $cfg_basedir.$imgUrl;
@@ -144,7 +138,6 @@ function GetCurContent($body)
$value = trim($value);
$rndFileName = $imgPath.'/'.$milliSecondN.'-'.$key.$itype;
$fileurl = $imgUrl.'/'.$milliSecondN.'-'.$key.$itype;

$rs = $htd->SaveToBin($rndFileName);
if ($rs) {
$info = '';
@@ -166,7 +159,6 @@ function GetCurContent($body)
$htd->Close();
return $body;
}

/**
* 获取一个远程图片
*
@@ -215,7 +207,6 @@ function GetRemoteImage($url, $uid = 0)
$htd->Close();
return ($ok ? $revalues : '');
}

/**
* 获取远程flash
*
@@ -250,7 +241,6 @@ function GetRemoteFlash($url, $uid = 0)
$htd->Close();
return $revalues;
}

/**
* 检测频道ID
*
@@ -263,12 +253,10 @@ function CheckChannel($typeid, $channelid)
{
global $dsql;
if ($typeid == 0) return TRUE;

$row = $dsql->GetOne("SELECT ispart,channeltype FROM `#@__arctype` WHERE id='$typeid' ");
if ($row['ispart'] != 0 || $row['channeltype'] != $channelid) return FALSE;
else return TRUE;
}

/**
* 检测档案权限
*
@@ -284,7 +272,6 @@ function CheckArcAdmin($aid, $adminid)
if ($row['mid'] != $adminid) return FALSE;
else return TRUE;
}

/**
* 文档自动分页
*
@@ -336,7 +323,6 @@ function SpLongBody($mybody, $spsize, $sptag)
}
return addslashes($mybody);
}

/**
* 创建指定ID的文档
*
@@ -355,7 +341,6 @@ function MakeArt($aid, $mkindex = FALSE, $ismakesign = FALSE, $isremote = 0)
$reurl = $arc->MakeHtml($isremote);
return $reurl;
}

/**
* 取第一个图片为缩略图
*
@@ -375,7 +360,6 @@ function GetDDImgFromBody(&$body)
}
return $litpic;
}

/**
* 获得缩略图
*
@@ -389,8 +373,7 @@ function GetDDImage($litpic, $picname, $isremote)
{
global $cuserLogin, $cfg_ddimg_width, $cfg_ddimg_height, $cfg_basedir, $ddcfg_image_dir, $cfg_addon_savetype;
$ntime = time();
if (($litpic != 'none' || $litpic != 'ddfirst') &&
!empty($_FILES[$litpic]['tmp_name']) && is_uploaded_file($_FILES[$litpic]['tmp_name'])
if (($litpic != 'none' || $litpic != 'ddfirst') && !empty($_FILES[$litpic]['tmp_name']) && is_uploaded_file($_FILES[$litpic]['tmp_name'])
) {
//如果用户自行上传缩略图
$istype = 0;
@@ -401,7 +384,6 @@ function GetDDImage($litpic, $picname, $isremote)
exit();
}
$savepath = $ddcfg_image_dir.'/'.MyDate($cfg_addon_savetype, $ntime);

CreateDir($savepath);
$fullUrl = $savepath.'/'.dd2char(MyDate('mdHis', $ntime).$cuserLogin->getUserID().mt_rand(1000, 9999));
if (strtolower($_FILES[$litpic]['type']) == "image/gif") {
@@ -411,21 +393,16 @@ function GetDDImage($litpic, $picname, $isremote)
} else {
$fullUrl = $fullUrl.".jpg";
}

@move_uploaded_file($_FILES[$litpic]['tmp_name'], $cfg_basedir.$fullUrl);
$litpic = $fullUrl;

if ($GLOBALS['cfg_ddimg_full'] == 'Y') @ImageResizeNew($cfg_basedir.$fullUrl, $cfg_ddimg_width, $cfg_ddimg_height);
else @ImageResize($cfg_basedir.$fullUrl, $cfg_ddimg_width, $cfg_ddimg_height);

$img = $cfg_basedir.$litpic;
} else {

$picname = trim($picname);
if ($isremote == 1 && preg_match("#^http:\/\/#i", $picname)) {
$litpic = $picname;
$ddinfos = GetRemoteImage($litpic, $cuserLogin->getUserID());

if (!is_array($ddinfos)) {
$litpic = '';
} else {
@@ -451,7 +428,6 @@ function GetDDImage($litpic, $picname, $isremote)
if ($litpic == 'litpic' || $litpic == 'ddfirst') $litpic = '';
return $litpic;
}

/**
* 获得一个附加表单
*
@@ -463,7 +439,6 @@ function GetFormItemA($ctag)
{
return GetFormItem($ctag, 'admin');
}

/**
* 处理不同类型的数据
*
@@ -479,7 +454,6 @@ function GetFieldValueA($dvalue, $dtype, $aid = 0, $job = 'add', $addvar = '')
{
return GetFieldValue($dvalue, $dtype, $aid, $job, $addvar, 'admin');
}

/**
* 获得带值的表单(编辑时用)
*
@@ -492,7 +466,6 @@ function GetFormItemValueA($ctag, $fvalue)
{
return GetFormItemValue($ctag, $fvalue, 'admin');
}

/**
* 载入自定义表单(用于发布)
*
@@ -510,8 +483,7 @@ function PrintAutoFieldsAdd($fieldset, $loadtype = 'all')
if (is_array($dtp->CTags)) {
foreach ($dtp->CTags as $tid => $ctag) {
if (
$loadtype != 'autofield'
|| ($loadtype == 'autofield' && $ctag->GetAtt('autofield') == 1)
$loadtype != 'autofield' || ($loadtype == 'autofield' && $ctag->GetAtt('autofield') == 1)
) {
$dede_addonfields .= ($dede_addonfields == "" ? $ctag->GetName().",".$ctag->GetAtt('type') : ";".$ctag->GetName().",".$ctag->GetAtt('type'));
echo GetFormItemA($ctag);
@@ -520,7 +492,6 @@ function PrintAutoFieldsAdd($fieldset, $loadtype = 'all')
}
echo "<input type='hidden' name='dede_addonfields' value=\"".$dede_addonfields."\">\r\n";
}

/**
* 载入自定义表单(用于编辑)
*
@@ -539,8 +510,7 @@ function PrintAutoFieldsEdit(&$fieldset, &$fieldValues, $loadtype = 'all')
if (is_array($dtp->CTags)) {
foreach ($dtp->CTags as $tid => $ctag) {
if (
$loadtype != 'autofield'
|| ($loadtype == 'autofield' && $ctag->GetAtt('autofield') == 1)
$loadtype != 'autofield' || ($loadtype == 'autofield' && $ctag->GetAtt('autofield') == 1)
) {
$dede_addonfields .= ($dede_addonfields == '' ? $ctag->GetName().",".$ctag->GetAtt('type') : ";".$ctag->GetName().",".$ctag->GetAtt('type'));
echo GetFormItemValueA($ctag, $fieldValues[$ctag->GetName()]);
@@ -549,8 +519,6 @@ function PrintAutoFieldsEdit(&$fieldset, &$fieldValues, $loadtype = 'all')
}
echo "<input type='hidden' name='dede_addonfields' value=\"".$dede_addonfields."\">\r\n";
}


/**
* 处理HTML文本
* 删除非站外链接、自动摘要、自动获取缩略图
@@ -569,12 +537,10 @@ function AnalyseHtmlBody($body, &$description, &$litpic, &$keywords, $dtype = ''
global $cfg_bizcore_appid, $cfg_bizcore_key, $cfg_bizcore_hostname, $cfg_bizcore_port;
$autolitpic = (empty($autolitpic) ? '' : $autolitpic);
$body = stripslashes($body);

//远程图片本地化
if ($remote == 1) {
$body = GetCurContent($body);
}

//删除非站内链接
if ($dellink == 1) {
$allow_urls = array($_SERVER['HTTP_HOST']);
@@ -584,21 +550,18 @@ function AnalyseHtmlBody($body, &$description, &$litpic, &$keywords, $dtype = ''
}
$body = Replace_Links($body, $allow_urls);
}

//自动摘要
if ($description == '' && $cfg_auot_description > 0) {
$description = cn_substr(html2text($body), $cfg_auot_description);
$description = trim(preg_replace('/#p#|#e#/', '', $description));
$description = addslashes($description);
}

//自动获取缩略图
if ($autolitpic == 1 && $litpic == '') {
$litpic = GetDDImgFromBody($body);
}

//自动获取关键字
if ($autokey == 1 && $keywords == '') {
if ($autokey == 2 && $keywords == '') {
$subject = $title;
$message = $body;
// 采用DedeBIZ Core分词组件分词
@@ -620,7 +583,6 @@ function AnalyseHtmlBody($body, &$description, &$litpic, &$keywords, $dtype = ''
$sp->SetSource(Html2Text($message), $cfg_soft_lang, $cfg_soft_lang);
$sp->StartAnalysis();
$allindexs = preg_replace("/#p#|#e#/", '', $sp->GetFinallyIndex());

if (is_array($allindexs) && is_array($titleindexs)) {
foreach ($titleindexs as $k => $v) {
if (strlen($keywords.$k) >= 60) {
@@ -646,7 +608,6 @@ function AnalyseHtmlBody($body, &$description, &$litpic, &$keywords, $dtype = ''
$body = addslashes($body);
return $body;
}

/**
* 删除非站内链接
*
@@ -681,7 +642,6 @@ function Replace_Links(&$body, $allow_urls = array())
$arr = $rparr = $tgarr = '';
return $body;
}

/**
* 图集里大图的小图
*
@@ -696,24 +656,19 @@ function GetImageMapDD($filename, $maxwidth)
$ddn = substr($filename, -3);
$ddpicok = preg_replace("#\.".$ddn."$#", "-lp.".$ddn, $filename);
$toFile = $GLOBALS['cfg_basedir'].$ddpicok;

if ($cfg_ddimg_full == 'Y') ImageResizeNew($GLOBALS['cfg_basedir'].$filename, $maxwidth, $cfg_ddimg_height, $toFile);
else ImageResize($GLOBALS['cfg_basedir'].$filename, $maxwidth, $cfg_ddimg_height, $toFile);

//保存图片附件信息
$fsize = filesize($toFile);
$ddpicoks = explode('/', $ddpicok);
$filename = $ddpicoks[count($ddpicoks) - 1];
$inquery = "INSERT INTO `#@__uploads`(arcid,title,url,mediatype,width,height,playtime,filesize,uptime,mid)
VALUES ('0','$filename','$ddpicok','1','0','0','0','$fsize','".time()."','".$cuserLogin->getUserID()."'); ";
VALUES ('0','$filename','$ddpicok','1','0','0','0','$fsize','".time()."','".$cuserLogin->getUserID()."'); ";
$dsql->ExecuteNoneQuery($inquery);
$fid = $dsql->GetLastID();
AddMyAddon($fid, $ddpicok);

return $ddpicok;
}


/**
* 上传一个未经处理的图片
*
@@ -734,7 +689,6 @@ function UploadOneImage($upname, $handurl = '', $isremote = 1, $ntitle = '')
$filename = '';
$isrm_up = FALSE;
$handurl = trim($handurl);

//如果用户自行上传了图片
if (!empty($_FILES[$upname]['tmp_name']) && is_uploaded_file($_FILES[$upname]['tmp_name'])) {
$istype = 0;
@@ -762,22 +716,18 @@ function UploadOneImage($upname, $handurl = '', $isremote = 1, $ntitle = '')
} else {
$fullUrl = $fullUrl.".jpg";
}

//保存
@move_uploaded_file($_FILES[$upname]['tmp_name'], $cfg_basedir.$fullUrl);
$filename = $fullUrl;

//水印
@WaterImg($cfg_basedir.$fullUrl, 'up');
$isrm_up = TRUE;
}

//远程或选择本地图片
else {
if ($handurl == '') {
return '';
}

//远程图片并要求本地化
if ($isremote == 1 && preg_match("#^http[s]?:\/\/#i", $handurl)) {
$ddinfos = GetRemoteImage($handurl, $cuserLogin->getUserID());
@@ -787,7 +737,6 @@ function UploadOneImage($upname, $handurl = '', $isremote = 1, $ntitle = '')
$filename = $ddinfos[0];
}
$isrm_up = TRUE;

//本地图片或远程不要求本地化
} else {
$filename = $handurl;
@@ -797,17 +746,14 @@ function UploadOneImage($upname, $handurl = '', $isremote = 1, $ntitle = '')
if (is_file($imgfile) && $isrm_up && $filename != '') {
$info = "";
$imginfos = GetImageSize($imgfile, $info);

//把新上传的图片信息保存到媒体文档管理档案中
$inquery = "
INSERT INTO `#@__uploads`(title,url,mediatype,width,height,playtime,filesize,uptime,mid)
VALUES ('$title','$filename','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".time()."','".$cuserLogin->getUserID()."');
";
VALUES ('$title','$filename','1','".$imginfos[0]."','".$imginfos[1]."','0','".filesize($imgfile)."','".time()."','".$cuserLogin->getUserID()."');";
$dsql->ExecuteNoneQuery($inquery);
}
return $filename;
}

/**
* 获取更新测试信息
*
@@ -831,4 +777,4 @@ function GetUpdateTest()
$revalue = '';
}
return $revalue;
}
}

+ 112
- 126
src/dede/inc/inc_list_functions.php View File

@@ -1,126 +1,112 @@
<?php
/**
* 列表对应函数
*
* @version $Id: inc_list_functions.php 1 10:32 2010年7月21日Z tianya $
* @package DedeBIZ.Administrator
* @copyright Copyright (c) 2021, DedeBIZ.COM
* @license https://www.dedebiz.com/license
* @link https://www.dedebiz.com
*/
if (!isset($registerGlobals)) {
require_once(dirname(__FILE__)."/../../include/common.inc.php");
}
// 获取栏目名称
function GetTypename($tid)
{
global $dsql;
if (empty($tid)) return '';
if (file_exists(DEDEDATA.'/cache/inc_catalog_base.inc')) {
require_once(DEDEDATA.'/cache/inc_catalog_base.inc');
global $cfg_Cs;
if (isset($cfg_Cs[$tid])) {
return base64_decode($cfg_Cs[$tid][3]);
}
} else {
$row = $dsql->GetOne("SELECT typename FROM #@__arctype WHERE id = '{$tid}'");
unset($dsql);
unset($cfg_Cs);
return isset($row['typename']) ? $row['typename'] : '';
}
return '';
}
//获得是否推荐的表述
$arcatts = array();
$dsql->Execute('n', 'SELECT * FROM `#@__arcatt` ');
while ($arr = $dsql->GetArray('n')) {
$arcatts[$arr['att']] = $arr['attname'];
}
function IsCommendArchives($iscommend)
{
global $arcatts;
$sn = '';
foreach ($arcatts as $k => $v) {
$v = cn_substr($v, 2);
$sn .= (preg_match("#".$k."#", $iscommend) ? ' '.$v : '');
}
$sn = trim($sn);
if ($sn == '') return '';
else return "[<font color='red'>$sn</font>]";
}
//获得推荐的标题
function GetCommendTitle($title, $iscommend)
{
/*if(preg_match('#c#i',$iscommend))
{
$title = "$title<font color='red'>(推荐)</font>";
}*/
return $title;
}
//更换颜色
$GLOBALS['RndTrunID'] = 1;
function GetColor($color1, $color2)
{
$GLOBALS['RndTrunID']++;
if ($GLOBALS['RndTrunID'] % 2 == 0) {
return $color1;
} else {
return $color2;
}
}
//检查图片是否存在
function CheckPic($picname)
{
if ($picname != "") {
return $picname;
} else {
return "images/dfpic.gif";
}
}
//判断内容是否生成HTML
function IsHtmlArchives($ismake)
{
if ($ismake == 1) {
return "已生成";
} else if ($ismake == -1) {
return "仅动态";
} else {
return "<font color='red'>未生成</font>";
}
}
//获得内容的限定级别名称
function GetRankName($arcrank)
{
global $arcArray, $dsql;
if (!is_array($arcArray)) {
$dsql->SetQuery("SELECT * FROM `#@__arcrank` ");
$dsql->Execute();
while ($row = $dsql->GetObject()) {
$arcArray[$row->rank] = $row->membername;
}
}
if (isset($arcArray[$arcrank])) {
return $arcArray[$arcrank];
} else {
return "不限";
}
}
//判断内容是否为图片文章
function IsPicArchives($picname)
{
if ($picname != '') {
return '<font color=\'red\'>(图)</font>';
} else {
return '';
}
}
<?php
/**
* 列表对应函数
*
* @version $Id: inc_list_functions.php 1 10:32 2010年7月21日Z tianya $
* @package DedeBIZ.Administrator
* @copyright Copyright (c) 2021, DedeBIZ.COM
* @license https://www.dedebiz.com/license
* @link https://www.dedebiz.com
*/
if (!isset($registerGlobals)) {
require_once(dirname(__FILE__)."/../../include/common.inc.php");
}
// 获取栏目名称
function GetTypename($tid)
{
global $dsql;
if (empty($tid)) return '';
if (file_exists(DEDEDATA.'/cache/inc_catalog_base.inc')) {
require_once(DEDEDATA.'/cache/inc_catalog_base.inc');
global $cfg_Cs;
if (isset($cfg_Cs[$tid])) {
return base64_decode($cfg_Cs[$tid][3]);
}
} else {
$row = $dsql->GetOne("SELECT typename FROM #@__arctype WHERE id = '{$tid}'");
unset($dsql);
unset($cfg_Cs);
return isset($row['typename']) ? $row['typename'] : '';
}
return '';
}
//获得是否推荐的表述
$arcatts = array();
$dsql->Execute('n', 'SELECT * FROM `#@__arcatt` ');
while ($arr = $dsql->GetArray('n')) {
$arcatts[$arr['att']] = $arr['attname'];
}
function IsCommendArchives($iscommend)
{
global $arcatts;
$sn = '';
foreach ($arcatts as $k => $v) {
$v = cn_substr($v, 2);
$sn .= (preg_match("#".$k."#", $iscommend) ? ' '.$v : '');
}
$sn = trim($sn);
if ($sn == '') return '';
else return "<span style='color:#ff5722'>[$sn]</span>";
}
//获得推荐的标题
function GetCommendTitle($title, $iscommend)
{
return $title;
}
//更换颜色
$GLOBALS['RndTrunID'] = 1;
function GetColor($color1, $color2)
{
$GLOBALS['RndTrunID']++;
if ($GLOBALS['RndTrunID'] % 2 == 0) {
return $color1;
} else {
return $color2;
}
}
//检查图片是否存在
function CheckPic($picname)
{
if ($picname != "") {
return $picname;
} else {
return "images/dfpic.gif";
}
}
//判断内容是否生成HTML
function IsHtmlArchives($ismake)
{
if ($ismake == 1) {
return "已生成";
} else if ($ismake == -1) {
return "仅动态";
} else {
return "<span style='color:#ff5722'>未生成</span>";
}
}
//获得内容的限定级别名称
function GetRankName($arcrank)
{
global $arcArray, $dsql;
if (!is_array($arcArray)) {
$dsql->SetQuery("SELECT * FROM `#@__arcrank` ");
$dsql->Execute();
while ($row = $dsql->GetObject()) {
$arcArray[$row->rank] = $row->membername;
}
}
if (isset($arcArray[$arcrank])) {
return $arcArray[$arcrank];
} else {
return "不限";
}
}
//判断内容是否为图片文章
function IsPicArchives($picname)
{
if ($picname != '') {
return "<span style='color:#ff5722'>[图]</span>";
} else {
return '';
}
}

Loading…
Cancel
Save