<form class="layui-form ct-form" table="article">
	<fieldset class="layui-elem-field layui-field-title"><legend>文章标题设置</legend></fieldset>
	<div class="layui-form-item">
		<label class="layui-form-label">标题匹配规则</label>
		<div class="layui-input-block">
			<input type="text" lay-verify="required" lay-verType="tips" value="<?php echo CTspider_html('ctspider_task','article','title_select') ?>" name="title_select" placeholder="" autocomplete="off" class="layui-input">
			<div class="layui-form-mid layui-word-aux">CSS选择器 (例如: h1)</div>
		</div>
	</div>	

	
	<fieldset class="layui-elem-field layui-field-title"><legend>文章内容设置</legend></fieldset>
	<div class="layui-form-item content-rule-list">
		<label class="layui-form-label">匹配规则</label>
		<div class="layui-input-block" style="width: 42%;">
			<input type="text" lay-verify="required" lay-verType="tips" ct-filter="content_select" value="<?php echo @CTspider_html('ctspider_task','article','content_select')[0] ?>" name="content_select[a][0]" autocomplete="off" class="layui-input">
			<div class="layui-form-mid layui-word-aux">
				CSS选择器 (例如: #content)
				<div class="layui-inline layui-hide">
					<input type="button" class="layui-btn layui-bg-cyan layui-btn-disabled" value="规则选项">
				</div>
				<div class="layui-inline layui-hide">
					<select ct-filter="rule_select" name="rule_select[c][0]"  class="rule_select">
						<option value="0">请选择一个</option>
						<option value="1">文章内容</option>
						<option value="2">文章摘要</option>
						<option value="3">文章标签</option>
						<option value="4">特色图片</option>
						<option value="5">发布时间</option>
						<option value="6">自定义栏目</option>
					</select> 
				</div>
				<div class="layui-inline layui-hide" style="display:none;">
					<input type="text" ct-filter="content_custom" name="content_custom[d][0]" autocomplete="off" class="layui-input"> 
				</div>				
			</div>
		</div>

		<div class="layui-form-mid ct-index-select">
			&nbsp;&nbsp;<span>索引</span><span style="display:none1;"> : <a ct-filter="index-help" ct-title=" 0 : [ 提取所有匹配的内容 ], 1 : [ 提取第1个匹配的内容 ], -1 : [ 提取最后1个匹配的内容 ]">[?]</a></span>
		</div>
		<div class="layui-input-inline ct-index-input" style="width: 3%; display:none1;">
			<input type="text" value="<?php echo !empty(CTspider_html('ctspider_task','article','content_index')[0]) ? CTspider_html('ctspider_task','article','content_index')[0] : '0' ?>" name="content_index[b][0]" ct-filter="content_index" value="0" lay-verify="number" lay-verType="tips" autocomplete="off" class="layui-input">
		</div>
	</div>	
	
	<?php
    $content_select = is_array(CTspider_html('ctspider_task','article','content_select')) ? CTspider_html('ctspider_task','article','content_select') : array();
	if (count($content_select) >=2 ) :
		$rule_select = CTspider_html('ctspider_task','article','rule_select');
		for ($i=1; $i < count(CTspider_html('ctspider_task','article','content_select')); $i++) :
	?>
			<div class="layui-form-item content-rule-list">
				<hr>
				<label class="layui-form-label">匹配规则</label>
				<div class="layui-input-block" style="width: 42%;">
					<input type="text" ct-filter="content_select" value="<?php echo CTspider_html('ctspider_task','article','content_select')[$i] ?>" name="content_select[a][<?php echo $i ?>]" lay-verify="required" lay-vertype="tips" autocomplete="off" class="layui-input">
					<div class="layui-form-mid layui-word-aux">
						<div class="layui-inline">
							<input type="button" class="layui-btn layui-bg-cyan layui-btn-disabled" value="规则选项">
						</div>
						<div class="layui-inline">
							<select ct-filter="rule_select" name="rule_select[c][<?php echo $i ?>]" lay-verify="required" lay-filter="rule_select" lay-verType="tips" class="rule_select">
								<option value="0">请选择一个</option>
								<option value="1" <?php selected( 1,$rule_select[$i] ); ?> >文章内容</option>
								<option value="2" <?php selected( 2,$rule_select[$i] ); ?> >文章摘要</option>
								<option value="3" <?php selected( 3,$rule_select[$i] ); ?> >文章标签</option>
								<option value="4" <?php selected( 4,$rule_select[$i] ); ?> >特色图片</option>
								<option value="5" <?php selected( 5,$rule_select[$i] ); ?> >发布时间</option>
								<option value="6" <?php selected( 6,$rule_select[$i] ); ?> >自定义栏目</option>
							</select> 
						</div>
						<?php 
							if (selected( 6,$rule_select[$i], false )) {
								$content_custom = CTspider_html('ctspider_task','article','content_custom')[$i];
								$style = 'style="display:block;"';
							} else {
								$content_custom = '';
								$style = 'style="display:none;"';
							}
						?>							
						<div class="layui-inline" style="<?php $style; ?> ">
							<input type="text" ct-filter="content_custom" value="<?php echo $content_custom ?>" name="content_custom[d][<?php echo $i ?>]" autocomplete="off" class="layui-input"> 
						</div>
					</div>
				</div>
				<div class="layui-form-mid ct-index-select">
					&nbsp;&nbsp;<span>索引</span><span style="display:none1;"> : <a ct-filter="index-help" ct-title=" 0 : [ 提取所有匹配的内容 ], 1 : [ 提取第1个匹配的内容 ], -1 : [ 提取最后1个匹配的内容 ]">[?]</a></span>
				</div>
				<div class="layui-input-inline ct-index-input" style="width: 3%; display:none1;">
					<input type="text" value="<?php echo CTspider_html('ctspider_task','article','content_index')[$i] ?>" name="content_index[b][<?php echo $i ?>]" ct-filter="content_index" lay-verify="required|number" lay-vertype="tips" autocomplete="off" class="layui-input">
				</div>
				<div class="layui-input-inline" style="width: 3%;">
					<button type="button" ct-reset="content_rule" class="layui-btn layui-btn-danger rule-delete">删除</button>
				</div>
			</div>
	<?php endfor; endif; ?>


	<div class="layui-form-item">
		<a class="layui-btn layui-btn-sm layui-btn-warm add-rule" title="如果还需要抓取不同区域上的内容">增加规则</a>
	</div>
	<br>


    <fieldset class="layui-elem-field layui-field-title"><legend>分页采集</legend></fieldset>
    <div class="layui-form-item">
        <label class="layui-form-label">文章分页采集 </label>
        <div class="layui-input-inline">
            <input type="checkbox" value="<?php echo CTspider_html('ctspider_task','article','page_open') ?>" <?php checked(1,CTspider_html('ctspider_task','article','page_open')) ?> name="page_open" lay-skin="switch" lay-filter="page_open" lay-text="开启|关闭">
        </div>
    </div>
    <div class="ct-page-rule-group" <?php echo Ctdisplay(checked( 1, CTspider_html('ctspider_task','article','page_open') )) ?>>
        <div class="layui-form-item">
            <label class="layui-form-label">文章分页规则</label>
            <div class="layui-input-block">
                <input type="text" value="<?php echo CTspider_html('ctspider_task','article','page_rule') ?>" name="page_rule" autocomplete="off" class="layui-input">
                <div class="layui-form-mid layui-word-aux">
                    CSS选择器 (例如: #page a)
                </div>
            </div>
        </div>
    </div>
    <br>


	<fieldset class="layui-elem-field layui-field-title"><legend>自定义URL测试</legend></fieldset>	
	<div class="layui-form-item">
		<label class="layui-form-label">是否启用自定义测试URL </label>
		<div class="layui-input-inline">
			<input type="checkbox" value="<?php echo CTspider_html('ctspider_task','article','test_url') ?>" <?php checked(1,CTspider_html('ctspider_task','article','test_url')) ?> name="test_url" lay-skin="switch" lay-filter="test_url" lay-text="开启|关闭">
		</div>
	</div>
	<div class="ct-test-url-link-group" <?php echo Ctdisplay(checked( 1, CTspider_html('ctspider_task','article','test_url') )) ?>>
		<div class="layui-form-item">
			<label class="layui-form-label">自定义测试抓取的地址</label>
			<div class="layui-input-block">
				<input type="text" value="<?php echo CTspider_html('ctspider_task','article','test_url_link') ?>" name="test_url_link" autocomplete="off" class="layui-input">
			</div>
		</div>	
	</div>
    <br><br>
	<hr>


	<button type="button" class="layui-btn" lay-submit lay-filter="article" >保存更改</button>	
	<button type="button" class="layui-btn layui-btn-normal" lay-filter="contenttest">采集测试</button>
</form>
