<?php
class article extends base
{
  function tabs()
  {
    $rows = db()->select_all("type", "title as name,id", "1=1 order by sort desc ,id desc");
    json(0, "", $rows);
  }
  function index()
  {

    $data = db()->select_all("article", "title,img,id,xcx_type,xcx_url", "tj=2");
    foreach ($data as $key => $value) {
      $data[$key]['image'] = xcx_img($value['img']);
    }

    $res['tj'] = $data;

    $res['news'] = db()->select_all("article", "title,id,xcx_type,xcx_url", "cid=555 and status=1 limit 0,4");

    json(0, "", $res);
  }
  function view()
  {

    $data = db()->get_table("article", $_POST['id']);
    $data['content'] = xcx_content($data['content']);
    json(0, "", $data);
  }
  function listwhere($where)
  {
    if ($_POST['cid']) {
      $where .= " and cid=" . $_POST['cid'];
    }
    if ($_POST['tj']) {
      $where .= " and tj=" . $_POST['tj'];
    }
    if ($_POST['status']) {
      $where .= " and status=" . $_POST['status'];
    }

    return $where;
  }

  function list($list)
  {
    foreach ($list as $key => $value) {
      $list[$key]['head'] = $value['title'];
      $list[$key]['body'] = strip_tags($value['content']);
    }
    return $list;
  }
}
