<?php
function post_categroy($categroy = array()) {
    if (empty($categroy['post_category'])) {
        $selected_cats = array();
    }else{
        $selected_cats = $categroy['post_category'];
    }
    $taxonomy_names = get_object_taxonomies( 'post','objects');
    foreach($taxonomy_names as $taxonomy){
            if($taxonomy->name=='post_tag' || $taxonomy->name =='post_format')continue;
            $args = array(
            'descendants_and_self'  => 0,
            'selected_cats'         => $selected_cats,
            'popular_cats'          => false,
            'taxonomy'              => $taxonomy->name,
            'checked_ontop'         => true,
            );
        echo '<ul id="categorychecklist" class="list:category categorychecklist form-no-clear">';
        //echo '<strong>'.$taxonomy->label.'</strong>';
        wp_terms_checklist( 0, $args );
        echo '</ul>';
    }
}
?>

<style>
	.layui-form ul.categorychecklist input[type=checkbox] {display: inline-block; height: 25px; width: 25px; line-height: 23px; border-color: #5FB878;}
	ul.categorychecklist input[type=checkbox]:checked:before {font-size: 22px; margin:1px 0 0 0px; color: #5FB878;}
	ul.categorychecklist  .layui-form-checkbox {display: none;}
	ul.categorychecklist li .selectit {font-size: 15px; color: #666;}
	ul.categorychecklist li {margin:8px 27px;}
</style>

<form class="layui-form ct-form" table="post">
	<fieldset class="layui-elem-field layui-field-title"><legend>分类选择</legend></fieldset>
	<div class="layui-form-item catlist">
		<label class="layui-form-label">分类目录</label>
		<div class="layui-input-block">
			<?php post_categroy(CTspider_html('ctspider_task','post'));?>
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">作者</label>
		<div class="layui-input-inline">
			<select name="author" lay-verify="required" lay-verType="tips">
				<option value="">作者选择</option>
				<?php 
					$user = Ctget_users();
					foreach ($user as $key => $value) {
						echo '<option '.selected( $value->ID, CTspider_html('ctspider_task','post','author') ).' value="'.$value->ID.'">'.$value->user_login.'</option>';
					}
				?>
			</select>
		</div>
	</div>

	<div class="layui-form-item">
		<label class="layui-form-label">发布状态</label>
		<div class="layui-input-inline">
			<select name="state" lay-verify="required" lay-verType="tips">
				<option value="">状态选择</option>
				<option value="publish" <?php selected( 'publish',CTspider_html('ctspider_task','post','state') ); ?> >已发布</option>
				<option value="pending" <?php selected( 'pending',CTspider_html('ctspider_task','post','state') ); ?> >等待复审</option>
                <option value="draft" <?php selected( 'draft',CTspider_html('ctspider_task','post','state') ); ?> >草稿</option>
			</select>
		</div>
	</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">
            <select name="attachments" lay-verify="required" lay-verType="tips">
                <option value="notdownload" <?php selected( 'notdownload',CTspider_html('ctspider_task','post','attachments') ); ?> >不下载</option>
                <option value="download" <?php selected( 'download',CTspider_html('ctspider_task','post','attachments') ); ?> >下载本地</option>
            </select>
        </div>
    </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','post','auto_tags',0) ?>" <?php checked(1,CTspider_html('ctspider_task','post','auto_tags') ) ?> name="auto_tags" lay-skin="switch" lay-filter="auto_tags" lay-text="开启|关闭">
		</div>
		<div class="layui-form-mid layui-word-aux"></div>
	</div>
	
	<div class="wp_tags" <?php echo Ctdisplay(checked( 1,CTspider_html('ctspider_task','post','auto_tags') )) ?> >
		<div class="layui-form-item layui-form-text">
			<label class="layui-form-label">自定义标签</label>
			<div class="layui-input-block">
				<div class="layui-form-mid layui-word-aux"><strong>当文章内容包含下面标签关键词时, 自动添加对应标签</strong></div>
				<textarea name="tags_custom" class="layui-textarea"><?php echo CTspider_html('ctspider_task','post','tags_custom') ?></textarea>
				<div class="layui-form-mid layui-word-aux">自定义标签: (多个Tag 英文逗号隔开)</div>
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label">标签数量限制</label>
			<div class="layui-input-inline">
				<input type="text" lay-verify="required" value="3" name="tags_num" autocomplete="off" class="layui-input">
			</div>	
			<div class="layui-form-mid layui-word-aux">默认显示3个 0表示无限制</div>
		</div>
        <div class="layui-form-item">
            <label class="layui-form-label">使用Wordpress标签库</label>
            <div class="layui-input-inline">
                <input type="checkbox" value="<?php echo CTspider_html('ctspider_task','post','wp_tags',0) ?>" <?php checked(1,CTspider_html('ctspider_task','post','wp_tags')) ?> name="wp_tags" lay-skin="switch" lay-filter="wp_tags" lay-text="启用|关闭">
            </div>
            <div class="layui-form-mid layui-word-aux">启用WordPress标签库，系统将会自动采用WP标签库内容，自定义标签会失效。</div>
        </div>
	</div>

	<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','post','auto_excerpt',0) ?>" <?php checked(1, CTspider_html('ctspider_task','post','auto_excerpt') ) ?> name="auto_excerpt" lay-skin="switch" lay-filter="auto_excerpt" lay-text="开启|关闭">
		</div>
		<div class="layui-form-mid layui-word-aux"></div>
	</div>
	<div class="layui-form-item auto_excerpt_index" <?php echo Ctdisplay(checked( 1,CTspider_html('ctspider_task','post','auto_excerpt') )) ?>>
		<label class="layui-form-label">摘要索引</label>
		<div class="layui-input-inline">
			<input type="text" value="<?php echo CTspider_html('ctspider_task','post','auto_excerpt_index',1) ?>" name="auto_excerpt_index" autocomplete="off" class="layui-input">
		</div>	
		<div class="layui-form-mid layui-word-aux">1:从第1段开始; 2:从第2段开始</div>
	</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','post','auto_thumb',0) ?>" <?php checked(1,CTspider_html('ctspider_task','post','auto_thumb')) ?> name="auto_thumb" lay-skin="switch" lay-filter="auto_thumb" lay-text="开启|关闭">
		</div>
		<div class="layui-form-mid layui-word-aux"></div>
	</div>
	<div class="layui-form-item auto_thumb_index" <?php echo Ctdisplay(checked( 1,CTspider_html('ctspider_task','post','auto_thumb') )) ?>>
		<label class="layui-form-label">图片索引</label>
		<div class="layui-input-inline">
			<input type="text" value="<?php echo CTspider_html('ctspider_task','post','auto_thumb_index',1) ?>" name="auto_thumb_index" autocomplete="off" class="layui-input">
		</div>	
		<div class="layui-form-mid layui-word-aux">1:获取第一张图; 2:获取第二张图;</div>
	</div>	
	<br><br> 
    <hr>


	<button type="button" class="layui-btn" lay-submit lay-filter="post" >保存更改</button>	
</form>
