Пример #1
0
function xt_admin_ajax_catalog_update()
{
    $result = array('code' => 0, 'msg' => '', 'result' => array());
    if (!current_user_can('manage_options')) {
        exit('您无权操作此功能');
    }
    if (!isset($_POST['type']) || empty($_POST['type']) || !in_array($_POST['type'], array('share', 'album'))) {
        exit('未指定分类类型');
    }
    if (!isset($_POST['id']) || empty($_POST['id'])) {
        exit('未指定分类');
    }
    $id = absint($_POST['id']);
    if ($result['code'] == 0) {
        global $wpdb;
        $title = strip_tags(isset($_POST['title']) ? $_POST['title'] : '');
        $pic = isset($_POST['pic']) ? $_POST['pic'] : '';
        $sort = isset($_POST['sort']) ? absint($_POST['sort']) : '';
        $_cat = xt_get_catalog($id);
        if (empty($_cat)) {
            exit('要修改的分类不存在');
        }
        $data = array();
        if (!empty($title)) {
            if ($_cat->title != $title) {
                if (xt_catalog_exit(0, $title, $_cat->parent, $_cat->type)) {
                    exit('分类名称重复');
                }
            }
            $data['title'] = $title;
        }
        if (!empty($sort)) {
            $data['sort'] = $sort;
        }
        $data['pic'] = $pic;
        if (!empty($data)) {
            $wpdb->update(XT_TABLE_CATALOG, $data, array('id' => $id));
            if ($_cat->type == 'share') {
                xt_catalogs_share(true);
                //FORCE
            } elseif ($_cat->type == 'album') {
                xt_catalogs_album(true);
                //FORCE
            }
        }
        $cat = xt_get_catalog($id);
        exit(xt_row_catalog($cat, isset($_POST['alternate']) && $_POST['alternate'] ? 0 : 1));
    }
    exit('未知错误');
}
Пример #2
0
                    <th class="manage-column" style="width:50px"><span>编号</span></th>
                    <th class="manage-column"><span>名称</span></th>
                    <th class="manage-column" style="width:100px"><span>类型</span></th>
                    <th class="manage-column" style="width:100px"><span>排序</span></th>
                    <th class="manage-column" style="width:100px"><span>分享</span></th>
                </tr>
            </tfoot>
            <tbody id="the-list" class="list:catalog">
                <?php 
$_cat_count = 0;
foreach ($_catalogs as $cat) {
    $subs = isset($cat->child) ? $cat->child['catalogs'] : array();
    xt_row_catalog($cat, $_cat_count);
    foreach ($subs as $sub) {
        $_cat_count++;
        xt_row_catalog($sub, $_cat_count);
    }
    $_cat_count++;
}
?>
            </tbody>
        </table>
        <table style="display: none">
            <tbody>
                <tr id="inline-edit" class="inline-edit-row">
                    <td colspan="5" class="colspanchange">
                        <fieldset>
                            <div class="inline-edit-col">
                                <h4>快速编辑</h4>
                                <label> <span class="title">名称</span> <span class="input-text-wrap"><input type="text" name="title" class="ptitle" value="" /></span></label>
                                <label> <span class="title">图片</span> <span class="input-text-wrap"><input type="text" name="pic" class="ptitle" value="" /></span></label>