db()->table('__sysconfig__')->where("`varname` in ('cfg_basehost','cfg_cmspath')")->column('value','varname');
$this->siteurl=rtrim($siteurls['cfg_basehost'].$siteurls['cfg_cmspath'],'\/\\');
}
//参数
public $_params = array (
'typeid' => array (
'name' => '栏目id',
'require' => 1,
'tag' => 'select',
'option' => 'function:param_option_typeid',
),
'title' => array (
'name' => '文章标题',
'require' => 1,
'tag' => 'select',
'option' => 'function:param_option_fields',
),
'content' => array (
'name' => '文章内容',
'require' => 1,
'tag' => 'select',
'option' => 'function:param_option_fields',
),
'author' => array (
'name' => '作者',
'require' => 0,
'tag' => 'select',
'option' => array (
'admin' => 'admin',
'网络' => '网络',
'佚名' => '佚名',
),
),
'desc' => array (
'name' => '自动摘要',
'require' => 0,
'tag' => 'radio',
),
'cover' => array (
'name' => '自动封面',
'require' => 0,
'tag' => 'radio',
),
);
/*
* 导入数据
* 必须以数组形式返回:
* id(必填)表示入库返回的自增id或状态
* target(可选)记录入库的数据位置(发布的网址等)
* desc(可选)记录入库的数据位置附加信息
* error(可选)记录入库失败的错误信息
* 入库的信息可在“已采集数据”中查看
* return array('id'=>0,'target'=>'','desc'=>'','error'=>'');
*/
public function runimport($params){
$newarticle=array(
'typeid'=>$params['typeid'],
'typeid2'=>0,
'arcrank'=>0,
'channel'=>1,
'senddate'=>time(),
'sortrank'=>time(),
'mid'=>1,
);
$articleid=$this->db()->table('__arctiny__')->insert($newarticle,false,true);//返回文章id
if($articleid>0){
$newarticle['id']=$articleid;
$newarticle['title']=$params['title'];
$newarticle['writer']=$params['author'];
$newarticle['pubdate']=time();
$newarticle['flag']='';
$newarticle['ismake']=-1;
$newarticle['litpic']='';
$newarticle['description']='';
if($params['desc']){
//自动摘要
$newarticle['description']=mb_substr(trim(preg_replace('/\s /',' ',strip_tags($params['content']))),0,200,'utf-8');
}
if($params['cover']){
//生成封面
if(preg_match('/
]*src=[\'\"]([^\"\'<>] )[\'\"]/i',$params['content'],$mcover)){
$newarticle['litpic']=$mcover[1];
}
}
$this->db()->table('__archives__')->insert($newarticle);//添加文章
$newaddon=array(
'aid'=>$articleid,
'typeid'=>$newarticle['typeid'],
'body'=>$params['content'],
);
$this->db()->table('__addonarticle__')->insert($newaddon);//添加文章附加
$target=$this->siteurl.'/plus/view.php?aid='.$articleid;
return array('id'=>$articleid,'target'=>$target);
}else{
$error='文章入库失败';
return array('id'=>0,'error'=>'文章入库失败');
}
}
/*
* 文章主栏目选项
* 必须返回键值对形式的数组
*/
public function param_option_typeid(){
$typedb=$this->db()->table('__arctype__')->where('topid=1')->order('sortrank asc')->select();
$typelist=array();
foreach ($typedb as $v){
$typelist[$v['id']]=auto_convert2utf8($v['typename']);
}
return $typelist;
}
}
?>