蓝天采集器&pbootcms 自定义扩展字段 录入问题

当采集任务中,有扩展字段(自定义字段)时候需要对发布插件(\plugin\release\cms中那个)进行修改,参考代码片段如下

 

下面是完整代码

<?php
/**
 * 示例:pboot文章
 * 您可参考代码自行开发pboot cms的更多功能
 * 您可以使用 thinkphp5的函数
 */
namespace plugin\release\cms;
class PbootQikanSkypecaiji extends BaseCms{
	public function cms_db_pboot($cmsPath){
		$dbFile=realpath($cmsPath.'/config/database.php');
		$cmsDb=array();
		if(file_exists($dbFile)){
			$dbFile=include $dbFile;
			$dbFile=$dbFile['database'];
			if(is_array($dbFile)){
				//使用sqlite必须开启pdo_sqlite
				$cmsDb['db_type']=stripos($dbFile['type'], 'sqlite')!==false?'sqlite':'mysql';
				$cmsDb['db_name']=$cmsDb['db_type']=='sqlite'?($cmsPath.$dbFile['dbname']):$dbFile['dbname'];
				$cmsDb['db_host']=$dbFile['host'];
				$cmsDb['db_user']=$dbFile['user'];
				$cmsDb['db_pwd']=$dbFile['passwd'];
				$cmsDb['db_charset']='utf8';
				$cmsDb['db_port']=$dbFile['port'];
				$cmsDb['db_prefix']='ay_';//固定的前缀
			}
		}
		return $cmsDb;
	}
	//参数
	public $_params = array (
		'author' => array (
			'name' => '作者账号',
			'require' => 1,
			'tag' => 'select',
			'option' => 'function:param_option_author',
		),
		'category' => array (
			'name' => '分类',
			'require' => 1,
			'tag' => 'select',
			'option' => 'function:param_option_category',
		),
		'title' => array (
			'name' => '标题',
			'require' => 1,
			'tag' => 'select',
			'option' => 'function:param_option_fields',
		),
		'ico' => array (
			'name' => '缩略图',
			'require' => 0,
			'tag' => 'select',
			'option' => 'function:param_option_fields',
		),
		'zhouqi' => array (
			'name' => '期刊周期',
			'require' => 0,
			'tag' => 'select',
			'option' => 'function:param_option_fields',
		),
		'jibei' => array (
			'name' => '期刊级别',
			'require' => 0,
			'tag' => 'select',
			'option' => 'function:param_option_fields',
		),
		'guojikanhao' => array (
			'name' => '国际刊号',
			'require' => 0,
			'tag' => 'select',
			'option' => 'function:param_option_fields',
		),
		'guoneikanhao' => array (
			'name' => '国内刊号',
			'require' => 0,
			'tag' => 'select',
			'option' => 'function:param_option_fields',
		),
		'zhubandanwei' => array (
			'name' => '主办单位',
			'require' => 0,
			'tag' => 'select',
			'option' => 'function:param_option_fields',
		),
		'zhuguandanwei' => array (
			'name' => '主管单位',
			'require' => 0,
			'tag' => 'select',
			'option' => 'function:param_option_fields',
		),
		'jianjie' => array (
			'name' => '简介',
			'require' => 0,
			'tag' => 'select',
			'option' => 'function:param_option_fields',
		),
		'qikanzongzhi' => array (
			'name' => '期刊宗旨',
			'require' => 0,
			'tag' => 'select',
			'option' => 'function:param_option_fields',
		),
		'lanmu' => array (
			'name' => '栏目',
			'require' => 0,
			'tag' => 'select',
			'option' => 'function:param_option_fields',
		),
		'mulu' => 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){
		$newPost=array(
			'acode'=>'cn',
			'scode'=>$params['category'],
			'subscode'=>'',
			'title'=>$params['title'],
			'titlecolor'=>'#333333',
			'subtitle'=>'',
			'filename'=>'',
			'author'=>$params['author'],
			'source'=>'本站',
			'outlink'=>'',
			'date'=>date('Y-m-d H:i:s'),
			'ico'=>$params['ico'],
			'pics'=>'',
			'picstitle'=>'',
			'ext_zhouqi'=>$params['zhouqi'],
			'ext_jibei'=>$params['jibei'],
			'ext_guojikanhao'=>$params['guojikanhao'],
			'ext_guoneikanhao'=>$params['guoneikanhao'],
			'ext_zhubandanwei'=>$params['zhubandanwei'],
			'ext_zhuguandanwei'=>$params['zhuguandanwei'],
			'ext_jianjie'=>$params['jianjie'],
			'ext_qikanzongzhi'=>$params['qikanzongzhi'],
			'ext_lanmu'=>$params['lanmu'],
			'ext_mulu'=>$params['mulu'],
			'tags'=>'',
			'enclosure'=>'',
			'keywords'=>'',
			'description'=>'',
			'sorting'=>255,
			'status'=>1,
			'istop'=>0,
			'isrecommend'=>0,
			'isheadline'=>0,
			'visits'=>0,
			'likes'=>0,
			'oppose'=>0,
			'create_user'=>$params['author'],
			'update_user'=>$params['author'],
			'create_time'=>date('Y-m-d H:i:s'),
			'update_time'=>date('Y-m-d H:i:s')
		);
		
		$postId=$this->db()->table('__CONTENT__')->insert($newPost,false,true);//添加文章并返回id
		if($postId>0){
		
		      $newAddon=array(
			'contentid'=>$postId,
			'ext_zhouqi'=>$params['zhouqi'],
			'ext_jibei'=>$params['jibei'],
			'ext_guojikanhao'=>$params['guojikanhao'],
			'ext_guoneikanhao'=>$params['guoneikanhao'],
			'ext_zhubandanwei'=>$params['zhubandanwei'],
			'ext_zhuguandanwei'=>$params['zhuguandanwei'],
			'ext_jianjie'=>$params['jianjie'],
			'ext_qikanzongzhi'=>$params['qikanzongzhi'],
			'ext_lanmu'=>$params['lanmu'],
			'ext_mulu'=>$params['mulu'],				
			);
			
			
			$this->db()->table('__CONTENT_EXT__')->insert($newAddon);//添加文章附加
		       
			$target='新闻:'.$postId;
			return array('id'=>$postId,'target'=>$target);
		}else{
			return array('id'=>0,'error'=>'文章入库失败');
		}
	}
	/*
	 * 参数选项:作者
	 * 必须返回键值对形式的数组
	 */
	public function param_option_author(){
		$usersDb=$this->db()->table('__USER__')->limit(100)->select();
		$userList=array();
		foreach ($usersDb as $user){
			$userList[$user['username']]=$user['username'];
		}
		return $userList;
	}
	
	/*
	 * 参数选项:分类
	 * 必须返回键值对形式的数组
	 */
	public function param_option_category(){
		$catsDb=$this->db()->table('__CONTENT_SORT__')->where("contenttpl='qk.html'")->limit(100)->select();//文章分类
		$catList=array();
		foreach ($catsDb as $cat){
			$catList[$cat['scode']]=$cat['name'];
		}
		return $catList;
	}
}
?>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
TDX(通达信)是一种常用的股票交易软件,它具备丰富的数据分析功能。TDX自定义数据采集是指用户可以根据自己的需求,通过编程或设置规则,实现对特定数据的采集和整合。 TDX自定义数据采集的实现可以通过编写相应的脚本或插件来完成。用户可以利用TDX软件提供的API接口,编写脚本来自动采集他们关心的数据。这些数据可以是股票的行情数据、交易数据、财务数据等。用户可以根据自己的需求进行自定义,提取所需的数据并进行进一步的分析。 此外,TDX软件还支持用户通过设置规则实现数据采集。用户可以设置某个特定条件下,自动采集指定数据。例如,用户可以设置当某只股票的涨跌幅超过一定阈值时,自动采集该股票的相关数据。这样,用户可以方便地获取重要的市场信息,并据此做出相应的投资决策。 TDX自定义数据采集的好处在于能够满足用户个性化的需求。用户可以按照自己所关注的领域或特定策略,在TDX软件上自定义数据采集功能,快速获取所需的数据。用户可以针对自己的投资目标、风险偏好等进行数据筛选和整理,提高交易决策的准确性和效率。 总而言之,TDX自定义数据采集为用户提供了在股票交易中获取个性化数据的便利性。用户可以通过编写脚本或设置规则,实现对特定数据的采集和整合,提高投资决策的准确性和效率。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值