array (
'name' => '文章栏目',
'require' => 1,
'tag' => 'select',
'option' => 'function:param_option_columnid',
),
'title' => array (
'name' => '标题',
'require' => 1,
'tag' => 'select',
'option' => 'function:param_option_fields',
),
'content' => array (
'name' => '内容',
'require' => 1,
'tag' => 'select',
'option' => 'function:param_option_fields',
),
'keywords' => array (
'name' => 'keywords',
'require' => 0,
'tag' => 'select',
'option' => 'function:param_option_fields',
),
'description' => array (
'name' => 'description',
'require' => 0,
'tag' => 'select',
'option' => 'function:param_option_fields',
),
'imgurl' => array (
'name' => '封面图',
'require' => 0,
'tag' => 'select',
'option' => 'function:param_option_fields',
),
);
/*
* 导入数据
* 必须以数组形式返回:
* id(必填)表示入库返回的自增id或状态
* target(可选)记录入库的数据位置(发布的网址等)
* desc(可选)记录入库的数据位置附加信息
* error(可选)记录入库失败的错误信息
* 入库的信息可在“已采集数据”中查看
* return array('id'=>0,'target'=>'','desc'=>'','error'=>'');
*/
public function runimport($params){
//设置栏目id
$class1=$class2=$class3=0;
$column1=$this->get_met_column($params['columnid']);
if($column1['bigclass']>0){
//有父栏
$column2=$this->get_met_column($column1['bigclass']);
if($column2['bigclass']>0){
//有父栏
$class1=$column2['bigclass'];
$class2=$column2['id'];
$class3=$column1['id'];
}else{
$class1=$column1['bigclass'];
$class2=$column1['id'];
}
}else{
//只有一栏
$class1=$column1['id'];
}
//新文章
$newarticle=array(
'title'=>$params['title'],
'content'=>$params['content'],
'keywords'=>$params['keywords'],
'description'=>$params['description'],
'class1'=>$class1,
'class2'=>$class2,
'class3'=>$class3,
'imgurl'=>$params['imgurl'],
'imgurls'=>$params['imgurl'],
'lang'=>$column1['lang'],
'hits'=>0,
'updatetime'=>date('y-m-d h:i:s'),
'addtime'=>date('y-m-d h:i:s'),
'issue'=>'admin',
'displaytype'=>1
);
$newsid=$this->db()->table('__news__')->insert($newarticle,false,true);
if($newsid>0){
//返回成功内容网址
$target=$this->get_met_web.$column1['foldername']."/shownews.php?lang={$column1['lang']}&id={$newsid}";
return array('id'=>$newsid,'target'=>$target);
}else{
return array('id'=>0,'error'=>'文章入库失败');
}
}
//获取栏目
public function get_met_column($columnid){
$column=null;
if($columnid>0){
$column=$this->db()->table('__column__')->where(array('id'=>$columnid))->find();
}
return $column;
}
//获取metinfo网站url
public function get_met_web{
$url=$this->db()->table('__config__')->where(array('name'=>'met_weburl','lang'=>$lang))->find();
return empty($url['value'])?'':$url['value'];
}
//栏目选项
public function param_option_columnid(){
static $slthtml=null;
if(!isset($slthtml)){
$slthtml='';
//获取文章栏目
$columnsdata=$this->db()->table('__column__')->where('module=2')->order('no_order asc')->select();
$columnlist=array();
foreach ($columnsdata as $column){
switch ($column['classtype']){
case 1:$columnlist[1][$column['id']]=$column;break;
case 2:$columnlist[2][$column['bigclass']][$column['id']]=$column;break;
case 3:$columnlist[3][$column['bigclass']][$column['id']]=$column;break;
}
}
$columnlist=$this->auto_convert2utf8($columnlist);//转码
//网站语言
$langlist=$this->db()->table('__lang__')->where("`lang`!='metinfo'")->order('no_order asc')->select();
//语言栏目分类
$langcolumn=array();
foreach($columnlist[1] as $colid=>$colval){
$langcolumn[$colval['lang']][$colval['id']]=$colval;
}
foreach($langlist as $lang){
if(!empty($langcolumn[$lang['lang']])){
$slthtml.="';
}
}
}
return $slthtml;
}
}
?>