{include file="public/header" /}
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>推荐位</h3>
                <h5></h5>
            </div>
            {include file="public/admin_items" /}
        </div>
    </div>

    <form method="get" name="formSearch">
        <table class="search-form">
            <tbody>
            <tr>
                <th>{$Think.lang.rec_ps_type}</th>
                <td><select name='pic_type'><option value="">{$Think.lang.ds_please_choose}</option><option value="1">{$Think.lang.rec_ps_pic}</option><option value="0">{$Think.lang.rec_ps_txt}</option></select></td>
                <th>{$Think.lang.rec_ps_title}</th>
                <td><input type="text" value="" name="keywords" class="txt"></td>
                <td><a href="javascript:document.formSearch.submit();" class="btn-search " title="{$Think.lang.ds_query}"></a></td>
            </tr>
            </tbody>
        </table>
    </form>
    <div class="explanation" id="explanation">
        <div class="title" id="checkZoom">
            <h4 title="提示相关设置操作时应注意的要点">操作提示</h4>
            <span id="explanationZoom" title="收起提示" class="arrow"></span>
        </div>
        <ul>
            <li>{$Think.lang.rec_ps_help1}</li>
        </ul>
    </div>
    
    
    <form method='post' id="form_rec">
        <table class="ds-default-table">
            <thead>
            <tr class="thead">
                <th>&nbsp;</th>
                <th>{$Think.lang.rec_ps_title}</th>
                <th>{$Think.lang.rec_ps_type}</th>
                <th>{$Think.lang.rec_ps_content}</th>
                <th>{$Think.lang.rec_ps_gourl}</th>
                <th>{$Think.lang.rec_ps_target}</th>
                <th class="align-center">{$Think.lang.ds_handle}</th>
            </tr>
            </thead>
            <tbody>
            {notempty name="list"}
           {volist name="list" id="v"}
            <tr class="hover edit">
                <td class="w24"><input type="checkbox" name="rec_id[]" value="{$v.rec_id}" class="checkitem"></td>
                <td>{$v.title}</td>
                <td><?php echo str_replace(array(0,1,2),array(lang('rec_ps_txt'),lang('rec_ps_picb'),lang('rec_ps_picy')),$v['pic_type']);?>
                    <?php if ($v['pic_type'] != 0){echo count($v['content']['body']) == 1 ? lang('rec_ps_picdan') : lang('rec_ps_picduo');}?>
                </td>
                <td class="picture">
                    {if $v.pic_type == 0}
                    {$v.content.body.0.title}
                    {else /}
                    <a target='_blank' href="{$v.content.body.0.title}"><img height="31" src="{$v.content.body.0.title}" /></a>
                    {/if}
                   </td>
                <td>{$v.content.body.0.url}</td>
                <td><?php echo str_replace(array(1,2),array(lang('rec_ps_tg1'),lang('rec_ps_tg2')),$v['content']['target']);?></td>
                <td class="w180 align-center"><a href="{:url('recposition/rec_edit',['rec_id'=>$v.rec_id])}">{$Think.lang.ds_edit}</a> | <a onclick="if(confirm('{$Think.lang.ds_ensure_del}')){return true;}else{return false;}" href="{:url('recposition/rec_del',['rec_id'=>$v.rec_id])}">{$Think.lang.ds_del}</a> | <a nctype="jscode" rec_id="{$v.rec_id}" href="javascript:void(0)">{$Think.lang.rec_ps_code}</a> | <a target="_blank" href="{:url('recposition/rec_view',['rec_id'=>$v.rec_id])}">{$Think.lang.rec_ps_view}</a>
                </td>
            </tr>
            {/volist}
            {else}
            <tr class="no_data">
                <td colspan="10">{$Think.lang.ds_no_record}</td>
            </tr>
            {/notempty}
            </tbody>
            <tfoot>
            {notempty name="list"}
            <tr class="tfoot" id="dataFuncs">
                <td><input type="checkbox" class="checkall" id="checkallBottom"></td>
                <td colspan="16" id="batchAction"><label for="checkallBottom">{$Think.lang.ds_select_all}</label>
                    &nbsp;&nbsp; <a href="JavaScript:void(0);" class="btn" onclick="if(confirm('{$Think.lang.ds_ensure_del}')){$('#form_rec').submit();}"><span>{$Think.lang.ds_del}</span></a>
                    <div class="pagination"> {$page} </div></td>
            </tr>
            </tfoot>
            {/notempty}
        </table>
    </form>
</div>
<script src="{$Think.config.url_domain_root}static/plugins/js/dialog/dialog.js" id="dialog_js"
<script>
    $(function(){

        $('a [nctype="jscode"]').click(function(){
            alert(11);
            copyToClipBoard($(this).attr('rec_id'));return ;
        });
        function ajax_form(id, title, url, width, model)
        {
            if (!width)	width = 480;
            if (!model) model = 1;
            var d = DialogManager.create(id);
            d.setTitle(title);
            d.setContents('ajax', url);
            d.setWidth(width);
            d.show('center',model);
            return d;
        }
        function copyToClipBoard(id){
            if(window.clipboardData)
            {
                window.clipboardData.clearData();
                window.clipboardData.setData("Text", "{:rec("+id+")}");
                alert("{$Think.lang.rec_ps_clip_succ}!");
            }
            else if(navigator.userAgent.indexOf("Opera") != -1)
            {
                window.location = "{:rec("+id+")}";
                alert("{$Think.lang.rec_ps_clip_succ}!");
            }
            else
            {
                ajax_form('copy_rec', '{$Think.lang.rec_ps_code}', "{:url('recposition/rec_code',['rec_id'=>"+id"])}");
            }
        }
    });
</script>