first commit
This commit is contained in:
187
application/controllers/adm/bak/cmtv.php
Executable file
187
application/controllers/adm/bak/cmtv.php
Executable file
@@ -0,0 +1,187 @@
|
||||
<?php
|
||||
|
||||
class Cmtv extends MY_Controller
|
||||
{
|
||||
private $parentCategoryName = 'crossmaptv-category';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('Post', '', 'post');
|
||||
$this->load->model('category_model');
|
||||
$this->load->model('editor_model');
|
||||
$this->load->model('life_model');
|
||||
$this->cmtvCategories = $this->getSubCategoryId($this->parentCategoryName);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = array(
|
||||
'cmtvCategories' => $this->category_model->findById($this->cmtvCategories)->result(),
|
||||
'cmtvEditors' => $this->editor_model->findByCategoryId($this->cmtvCategories)->get()->result(),
|
||||
);
|
||||
$this->load->view($this->adminViewFolder . 'cmtv', $data);
|
||||
}
|
||||
|
||||
private function tableClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.title', $this->param('term'));
|
||||
}
|
||||
if ($this->param('category')) {
|
||||
$this->db->like('l.category_idx', $this->param('category'));
|
||||
}
|
||||
if ($this->param('editor')) {
|
||||
$this->db->like('p.idx', $this->param('editor'));
|
||||
}
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$sort = $this->param('sort');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
$this->life_model->findByCategoryId($this->cmtvCategories)
|
||||
->order_by('l.' . (empty($sortColumns[$sort]) ? $sortColumns['reg_date'] : $sortColumns[$sort]), $this->param('order'))
|
||||
->where('l.is_display !=', null)
|
||||
->select('l.display_date, l.is_display')
|
||||
->limit($this->param('limit'))
|
||||
->offset($this->param('offset'));
|
||||
$this->tableClause();
|
||||
$graces = $this->db->get()->result();
|
||||
|
||||
foreach($graces as $k => $g) {
|
||||
if(strtotime($g->display_date) > time() && $g->is_display == 'N') {
|
||||
$graces[$k]->isSetDptime = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$graceTotalCount = $this->life_model->findByCategoryId($this->cmtvCategories);
|
||||
$this->tableClause();
|
||||
$graceTotalCount = $this->db->count_all_results();
|
||||
$categories = array();
|
||||
foreach ($graces as $grace) {
|
||||
array_push($categories, $grace->categoryId);
|
||||
}
|
||||
$categories = $this->category_model->findById($categories)->result();
|
||||
foreach ($graces as $k => $g) {
|
||||
foreach ($categories as $c) {
|
||||
if ($g->categoryId == $c->idx) {
|
||||
$graces[$k]->categoryName = $c->category_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('total' => $graceTotalCount,
|
||||
'rows' => $graces)));
|
||||
}
|
||||
|
||||
public function content_delete()
|
||||
{
|
||||
$this->life_model->findById(1)->reset_query()->where('idx', $this->param('contentId'))->delete($this->life_model->table);
|
||||
if ($deleted = $this->db->affected_rows()) {
|
||||
$this->response(array('deleted' => $deleted));
|
||||
}
|
||||
}
|
||||
|
||||
public function content_category()
|
||||
{
|
||||
$data = array();
|
||||
if ($this->param('category')) {
|
||||
$data['category_idx'] = $this->param('category');
|
||||
}
|
||||
|
||||
if ($this->param('editor')) {
|
||||
$data['partner_idx'] = $this->param('editor');
|
||||
}
|
||||
|
||||
$this->life_model->findById($this->param('contentId'))->set($data)->update();
|
||||
$updated = $this->db->affected_rows();
|
||||
$this->response(array('updated' => $updated));
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
$this->load->view($this->adminViewFolder . 'cmtv-category');
|
||||
}
|
||||
|
||||
public function category_table()
|
||||
{
|
||||
$sort = $this->param('sort');
|
||||
$order = $this->param('order');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
$this->category_model->findById($this->cmtvCategories, true)
|
||||
->join($this->editor_model->table . ' p', 'category.idx = p.category_idx', 'left')
|
||||
->where('category.is_del', 'N')
|
||||
->group_by('category.idx')->select('count(category_idx) editorCount, category.category_name categoryName, category.display_sort displayOrder, category.reg_date, category.idx categoryId');
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('category.category_name', $this->param('term'));
|
||||
}
|
||||
$categoryEditors = $this->db->get()->result();
|
||||
$categories = array();
|
||||
foreach ($categoryEditors as $grace) {
|
||||
array_push($categories, $grace->categoryId);
|
||||
}
|
||||
|
||||
$posts = $this->life_model->findByCategoryId($this->cmtvCategories)->group_by('l.category_idx')
|
||||
->select('count(l.idx) postCount, sum(l.hit_count) views')->get()->result();
|
||||
foreach ($categoryEditors as $k => $g) {
|
||||
$categoryEditors[$k]->postCount = 0;
|
||||
$categoryEditors[$k]->views = 0;
|
||||
foreach ($posts as $p) {
|
||||
if ($g->categoryId == $p->categoryId) {
|
||||
$categoryEditors[$k]->postCount += $p->postCount;
|
||||
$categoryEditors[$k]->views += $p->views;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('total' => count($categoryEditors),
|
||||
'rows' => $categoryEditors)));
|
||||
}
|
||||
|
||||
public function category_save()
|
||||
{
|
||||
$parentId = $this->category_model->getSubCategoryId($this->parentCategoryName)['parent'];
|
||||
if (!empty($this->param('id'))) {
|
||||
$this->db->where('idx', $this->param('id'))->update($this->category_model->table, array(
|
||||
'category_name' => $this->param('name'),
|
||||
'display_sort' => $this->param('order'),
|
||||
'parent' => $parentId,
|
||||
'update_id' => $this->session->userdata('Adm_Id'),
|
||||
'update_date' => date('Y-m-d H:i:s'),
|
||||
));
|
||||
if ($updated = $this->db->affected_rows()) {
|
||||
$this->response(array('updated' => $updated));
|
||||
}
|
||||
} else {
|
||||
if ($inserted = $this->db->insert($this->category_model->table, array(
|
||||
'category_name' => $this->param('name'),
|
||||
'display_sort' => $this->param('order'),
|
||||
'parent' => $parentId,
|
||||
'reg_id' => $this->session->userdata('Adm_Id'),
|
||||
'reg_date' => date('Y-m-d H:i:s'),
|
||||
))) {
|
||||
$this->response(array('inserted' => $this->db->insert_id()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function category_delete()
|
||||
{
|
||||
if (!empty($this->param('id'))) {
|
||||
$this->db->where('idx', $this->param('id'))->update($this->category_model->table, array(
|
||||
'is_del' => 'Y',
|
||||
));
|
||||
if ($updated = $this->db->affected_rows()) {
|
||||
$this->response(array('updated' => $updated));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
102
application/controllers/adm/bak/comment.php
Executable file
102
application/controllers/adm/bak/comment.php
Executable file
@@ -0,0 +1,102 @@
|
||||
<?php
|
||||
|
||||
class Comment extends MY_Controller
|
||||
{
|
||||
private $menuCategories = array();
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('editor_model');
|
||||
$this->load->model('comment_model');
|
||||
$this->menuCategories['은혜충전'] = $this->getSubCategoryId('grace-category');
|
||||
$this->menuCategories['크로스맵TV'] = $this->getSubCategoryId('crossmaptv-category');
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = array(
|
||||
'menuCategories' => array_keys($this->menuCategories),
|
||||
'graceCategories' => $this->category_model->findById($this->categories['grace'])->result(),
|
||||
'graceEditors' => $this->editor_model->findByCategoryId($this->categories['grace'])->get()->result(),
|
||||
);
|
||||
$this->load->view($this->adminViewFolder . 'comment', $data);
|
||||
}
|
||||
|
||||
private function tableClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.title', $this->param('term'));
|
||||
}
|
||||
if ($this->param('category')) {
|
||||
$this->db->like('l.category_idx', $this->param('category'));
|
||||
}
|
||||
if ($this->param('editor')) {
|
||||
$this->db->like('p.idx', $this->param('editor'));
|
||||
}
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$sort = $this->param('sort');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
$this->comment_model->find()->limit($this->param('limit'))->offset($this->param('offset'))
|
||||
->join('life f', 'cmt.content_idx=f.idx', 'left')
|
||||
->join('category c', 'f.category_idx=c.idx', 'left')
|
||||
->join('partner p', 'f.partner_idx=p.idx', 'left')
|
||||
->where('cmt.content_type', '3')->where('f.is_del', 'N')->where('cmt.is_del', 'N');
|
||||
if($this->param('term')) {
|
||||
$this->db->group_start()->like('cmt.comment', $this->param('term'), 'both')
|
||||
->or_like('f.title', $this->param('term'), 'both')->group_end();
|
||||
}
|
||||
$comments = $this->db->select('cmt.idx commentId, f.title, c.category_name, p.partner_name, cmt.comment, f.idx, cmt.reg_date, 0 likes, 0 bads')
|
||||
->get()->result();
|
||||
$commentId = array();
|
||||
foreach($comments as $c) {
|
||||
array_push($commentId, $c->idx);
|
||||
}
|
||||
|
||||
if(count($comments)) {
|
||||
$likes = $this->db->where_in('comment_idx', $commentId)
|
||||
->select('count(idx) cnt, type_name, comment_idx')
|
||||
->group_by('comment_idx, type_name')->get('comment_like_log')->result();
|
||||
foreach($comments as $k => $c) {
|
||||
foreach($likes as $l) {
|
||||
if($c->idx == $l->comment_idx) {
|
||||
if($l->type_name == 'like_count') {
|
||||
$comments[$k]->likes += $l->cnt;
|
||||
}else {
|
||||
$comments[$k]->bads += $l->cnt;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($this->param('term')) {
|
||||
$this->db->group_start()->like('cmt.comment', $this->param('term'), 'both')
|
||||
->or_like('f.title', $this->param('term'), 'both')->group_end();
|
||||
}
|
||||
$commentTotalCount = $this->comment_model->find()
|
||||
->join('life f', 'cmt.content_idx=f.idx', 'left')
|
||||
->where('cmt.content_type', '3')->where('f.is_del', 'N')->where('cmt.is_del', 'N')
|
||||
->count_all_results();
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('total' => $commentTotalCount,
|
||||
'rows' => $comments)));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function content_delete() {
|
||||
$this->db->where('idx', $this->param('contentId'))->update($this->comment_model->table, array('is_del' => 'Y'));
|
||||
if ($deleted = $this->db->affected_rows()) {
|
||||
$this->response(array('deleted' => $deleted));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
114
application/controllers/adm/bak/cont.php
Executable file
114
application/controllers/adm/bak/cont.php
Executable file
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
class Content extends MY_Controller
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function upload()
|
||||
{
|
||||
$config['upload_path'] = FCPATH . '/uploads/';
|
||||
$config['allowed_types'] = 'gif|jpg|png';
|
||||
$config['max_size'] = 1024;
|
||||
$config['max_width'] = 1024;
|
||||
$config['max_height'] = 768;
|
||||
$this->load->library('upload', $config);
|
||||
if (!$this->upload->do_upload('userfile')) {
|
||||
$this->response(null, 500, $this->upload->display_errors('', ''));
|
||||
} else {
|
||||
$uploaded = $this->upload->data();
|
||||
$uploaded['url'] = $_SERVER['HTTP_ORIGIN'] . '/uploads/' . $uploaded['file_name'];
|
||||
$this->response($uploaded);
|
||||
}
|
||||
}
|
||||
|
||||
public function dptime()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function config()
|
||||
{
|
||||
$this->load->model('config_model');
|
||||
if ($this->input->method() == 'post') {
|
||||
if ($this->param('type') == 'dptime') {
|
||||
$this->load->model('life_model');
|
||||
$this->db->where('idx', $this->param('postid'))->update($this->life_model->table, array('is_display' => 'N', 'display_date' => $this->param('dptime')));
|
||||
$config = $this->config_model->findByTypeAndPostId($this->param('type'), $this->param('postid'))->get()->row();
|
||||
if($config) {
|
||||
if($this->db->where('Id', $config->Id)->update($this->config_model->table, array(
|
||||
'PostId' => $this->param('postid'),
|
||||
'Type' => $this->param('type'),
|
||||
'DpTime' => $this->param('dptime')
|
||||
))){
|
||||
$this->response(array('updated' => $this->db->affected_rows()));
|
||||
} else {
|
||||
$this->response(null, 402, 'failed to update');
|
||||
}
|
||||
}else {
|
||||
if($this->db->insert($this->config_model->table, array(
|
||||
'PostId' => $this->param('postid'),
|
||||
'Type' => $this->param('type'),
|
||||
'DpTime' => $this->param('dptime')
|
||||
))){
|
||||
$this->response(array('inserted' => $this->db->insert_id()));
|
||||
} else {
|
||||
$this->response(null, 402, 'failed to svae');
|
||||
}
|
||||
}
|
||||
} else if ($this->param('id')) {
|
||||
$config = $this->config_model->findByTypeAndNameAndPageAndOrderNum($this->param('type'),
|
||||
$this->param('name'), $this->param('page'), $this->param('order'))->get();
|
||||
if ($config->num_rows() && $config->row()->Id != $this->param('id')) {
|
||||
$this->response(null, 401, '삭제먼저');
|
||||
} else if ($this->db->where('Id', $this->param('id'))->update($this->config_model->table, array(
|
||||
'PostId' => $this->param('postid'),
|
||||
'Type' => $this->param('type'),
|
||||
'Name' => $this->param('name'),
|
||||
'Page' => $this->param('page'),
|
||||
'OrderNum' => $this->param('order'),
|
||||
'Headline' => $this->param('headline'),
|
||||
'Title' => $this->param('title'),
|
||||
'Thumbnail' => $this->param('thumbnail'),
|
||||
))) {
|
||||
$this->response(array('inserted' => $this->db->insert_id()));
|
||||
} else {
|
||||
$this->response(null, 402, 'failed to svae');
|
||||
}
|
||||
} else if ($this->config_model->findByTypeAndNameAndPageAndOrderNum($this->param('type'), $this->param('name'),
|
||||
$this->param('page'), $this->param('order'))->count_all_results()) {
|
||||
$this->response(null, 401, '삭제먼저');
|
||||
} else {
|
||||
if ($this->db->insert($this->config_model->table, array(
|
||||
'PostId' => $this->param('postid'),
|
||||
'Type' => $this->param('type'),
|
||||
'Name' => $this->param('name'),
|
||||
'Page' => $this->param('page'),
|
||||
'OrderNum' => $this->param('order'),
|
||||
'Headline' => $this->param('headline'),
|
||||
'Title' => $this->param('title'),
|
||||
'Thumbnail' => $this->param('thumbnail'),
|
||||
))) {
|
||||
$this->response(array('inserted' => $this->db->insert_id()));
|
||||
} else {
|
||||
$this->response(null, 402, 'failed to svae');
|
||||
}
|
||||
}
|
||||
} else if ($this->input->method() == 'delete') {
|
||||
$this->db->where('Id', $this->param('id'))->delete($this->config_model->table);
|
||||
if ($this->db->affected_rows()) {
|
||||
$this->response(null, 200, '삭제성공');
|
||||
} else {
|
||||
$this->response(null, 401, '삭제실패');
|
||||
}
|
||||
} else {
|
||||
if ($configQuery = $this->config_model->findByTypeAndNameAndPage($this->param('type'), $this->param('name'), $this->param('page'))->order_by('OrderNum')->get()->result()) {
|
||||
$this->response($configQuery);
|
||||
} else {
|
||||
$this->response(array(), 200);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
188
application/controllers/adm/bak/grace.php
Executable file
188
application/controllers/adm/bak/grace.php
Executable file
@@ -0,0 +1,188 @@
|
||||
<?php
|
||||
|
||||
class Grace extends MY_Controller
|
||||
{
|
||||
private $parentCategoryName = 'grace-category';
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('Post', '', 'post');
|
||||
$this->load->model('category_model');
|
||||
$this->load->model('editor_model');
|
||||
$this->load->model('life_model');
|
||||
$this->graceCategories = $this->getSubCategoryId($this->parentCategoryName);
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = array(
|
||||
'graceCategories' => $this->category_model->findById($this->graceCategories)->result(),
|
||||
'graceEditors' => $this->editor_model->findByCategoryId($this->graceCategories)->get()->result(),
|
||||
);
|
||||
$this->load->view($this->adminViewFolder . 'grace', $data);
|
||||
}
|
||||
|
||||
private function tableClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.title', $this->param('term'));
|
||||
}
|
||||
if ($this->param('category')) {
|
||||
$this->db->like('l.category_idx', $this->param('category'));
|
||||
}
|
||||
if ($this->param('editor')) {
|
||||
$this->db->like('p.idx', $this->param('editor'));
|
||||
}
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$sort = $this->param('sort');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
$this->life_model->findByCategoryId($this->graceCategories)
|
||||
->order_by('l.' . (empty($sortColumns[$sort]) ? $sortColumns['reg_date'] : $sortColumns[$sort]), $this->param('order'))
|
||||
->where('l.is_display !=', null)
|
||||
->select('l.display_date, l.is_display')
|
||||
->limit($this->param('limit'))
|
||||
->offset($this->param('offset'));
|
||||
$this->tableClause();
|
||||
$graces = $this->db->get()->result();
|
||||
|
||||
foreach($graces as $k => $g) {
|
||||
if(strtotime($g->display_date) > time() && $g->is_display == 'N') {
|
||||
$graces[$k]->isSetDptime = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$graceTotalCount = $this->life_model->findByCategoryId($this->graceCategories);
|
||||
$this->tableClause();
|
||||
$graceTotalCount = $this->db->count_all_results();
|
||||
$categories = array();
|
||||
foreach ($graces as $grace) {
|
||||
array_push($categories, $grace->categoryId);
|
||||
}
|
||||
$categories = $this->category_model->findById($categories)->result();
|
||||
foreach ($graces as $k => $g) {
|
||||
foreach ($categories as $c) {
|
||||
if ($g->categoryId == $c->idx) {
|
||||
$graces[$k]->categoryName = $c->category_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('total' => $graceTotalCount,
|
||||
'rows' => $graces)));
|
||||
}
|
||||
|
||||
public function content_delete()
|
||||
{
|
||||
$this->life_model->findById(1)->reset_query()->where('idx', $this->param('contentId'))->delete($this->life_model->table);
|
||||
if ($deleted = $this->db->affected_rows()) {
|
||||
$this->response(array('deleted' => $deleted));
|
||||
}
|
||||
}
|
||||
|
||||
public function content_category()
|
||||
{
|
||||
$data = array();
|
||||
if ($this->param('category')) {
|
||||
$data['category_idx'] = $this->param('category');
|
||||
}
|
||||
|
||||
if ($this->param('editor')) {
|
||||
$data['partner_idx'] = $this->param('editor');
|
||||
}
|
||||
|
||||
$this->life_model->findById($this->param('contentId'))->set($data)->update();
|
||||
$this->response(array('updated' => $updated));
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
$this->load->view($this->adminViewFolder . 'grace-category');
|
||||
}
|
||||
|
||||
public function category_table()
|
||||
{
|
||||
$sort = $this->param('sort');
|
||||
$order = $this->param('order');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
$this->category_model->findById($this->graceCategories, true)
|
||||
->join($this->editor_model->table . ' p', 'category.idx = p.category_idx', 'left')
|
||||
->where('category.is_del', 'N')
|
||||
->group_by('category.idx')->select('count(category_idx) editorCount, category.category_name categoryName, category.display_sort displayOrder, category.reg_date, category.idx categoryId');
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('category.category_name', $this->param('term'));
|
||||
}
|
||||
|
||||
$categoryEditors = $this->db->get()->result();
|
||||
$categories = array();
|
||||
foreach ($categoryEditors as $grace) {
|
||||
array_push($categories, $grace->categoryId);
|
||||
}
|
||||
|
||||
$posts = $this->life_model->findByCategoryId($this->graceCategories)->group_by('l.category_idx')
|
||||
->select('count(l.idx) postCount, sum(l.hit_count) views')->get()->result();
|
||||
foreach ($categoryEditors as $k => $g) {
|
||||
$categoryEditors[$k]->postCount = 0;
|
||||
$categoryEditors[$k]->views = 0;
|
||||
foreach ($posts as $p) {
|
||||
if ($g->categoryId == $p->categoryId) {
|
||||
$categoryEditors[$k]->postCount += $p->postCount;
|
||||
$categoryEditors[$k]->views += $p->views;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('total' => count($categoryEditors),
|
||||
'rows' => $categoryEditors)));
|
||||
}
|
||||
|
||||
public function category_save()
|
||||
{
|
||||
$parentId = $this->category_model->getSubCategoryId($this->parentCategoryName)['parent'];
|
||||
if (!empty($this->param('id'))) {
|
||||
$this->db->where('idx', $this->param('id'))->update($this->category_model->table, array(
|
||||
'category_name' => $this->param('name'),
|
||||
'display_sort' => $this->param('order'),
|
||||
'parent' => $parentId,
|
||||
'update_id' => $this->session->userdata('Adm_Id'),
|
||||
'update_date' => date('Y-m-d H:i:s'),
|
||||
));
|
||||
if ($updated = $this->db->affected_rows()) {
|
||||
$this->response(array('updated' => $updated));
|
||||
}
|
||||
} else {
|
||||
if ($inserted = $this->db->insert($this->category_model->table, array(
|
||||
'category_name' => $this->param('name'),
|
||||
'display_sort' => $this->param('order'),
|
||||
'parent' => $parentId,
|
||||
'reg_id' => $this->session->userdata('Adm_Id'),
|
||||
'reg_date' => date('Y-m-d H:i:s'),
|
||||
))) {
|
||||
$this->response(array('inserted' => $this->db->insert_id()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function category_delete()
|
||||
{
|
||||
if (!empty($this->param('id'))) {
|
||||
$this->db->where('idx', $this->param('id'))->update($this->category_model->table, array(
|
||||
'is_del' => 'Y',
|
||||
));
|
||||
if ($updated = $this->db->affected_rows()) {
|
||||
$this->response(array('updated' => $updated));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
116
application/controllers/adm/bak/korea.php
Executable file
116
application/controllers/adm/bak/korea.php
Executable file
@@ -0,0 +1,116 @@
|
||||
<?php
|
||||
|
||||
class Korea extends MY_Controller
|
||||
{
|
||||
|
||||
private $parentCategoryName = 'grace-category';
|
||||
|
||||
private $lifeCategories = array('ids' => array());
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library(array('pagination'));
|
||||
$this->load->library('Post', '', 'post');
|
||||
$this->load->model('category_model');
|
||||
$this->load->model('editor_model');
|
||||
$this->load->model('life_model');
|
||||
$this->lifeCategories['result'] = $this->category_model->findById()->result();
|
||||
foreach ($this->lifeCategories['result'] as $c) {
|
||||
array_push($this->lifeCategories['ids'], $c->idx);
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$table = $this->table();
|
||||
// print_r($table['rows']);die;
|
||||
$page = (((int) $this->input->get('page')) > 0) ? ((int) $this->input->get('page')) : 1;
|
||||
|
||||
$config['base_url'] = '/adm/' . strtolower(__CLASS__);
|
||||
$config['total_rows'] = $table['total'];
|
||||
$config['per_page'] = $this->param('limit');
|
||||
$this->pagination->initialize($config);
|
||||
$data = array(
|
||||
'lifeCategories' => $this->lifeCategories['result'],
|
||||
'graceEditors' => $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result(),
|
||||
'paging' => $this->pagination->create_links(),
|
||||
'table' => $table,
|
||||
'page' => $page
|
||||
);
|
||||
|
||||
$this->load->view('adm/template', $data);
|
||||
}
|
||||
|
||||
private function tableClause()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
$sort = $this->param('sort');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
$this->life_model->findByCategoryId($this->lifeCategories['ids'])
|
||||
->order_by('l.' . $sortColumns['reg_date'], $this->param('order'))
|
||||
->where('l.is_display !=', null)
|
||||
->select('l.display_date, l.is_display')
|
||||
->limit($this->param('limit'))
|
||||
->offset($this->param('limit') * $this->param('page'));
|
||||
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.title', $this->param('term'));
|
||||
}
|
||||
if ($this->param('category')) {
|
||||
$this->db->like('l.category_idx', $this->param('category'));
|
||||
}
|
||||
if ($this->param('editor')) {
|
||||
$this->db->like('p.idx', $this->param('editor'));
|
||||
}
|
||||
|
||||
$graces = $this->db->get()->result();
|
||||
|
||||
foreach ($graces as $k => $g) {
|
||||
if (strtotime($g->display_date) > time() && $g->is_display == 'N') {
|
||||
$graces[$k]->isSetDptime = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$graceTotalCount = $this->life_model->findByCategoryId($this->lifeCategories['ids']);
|
||||
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.title', $this->param('term'));
|
||||
}
|
||||
if ($this->param('category')) {
|
||||
$this->db->like('l.category_idx', $this->param('category'));
|
||||
}
|
||||
if ($this->param('editor')) {
|
||||
$this->db->like('p.idx', $this->param('editor'));
|
||||
}
|
||||
|
||||
$graceTotalCount = $this->db->count_all_results();
|
||||
$categories = array();
|
||||
foreach ($graces as $grace) {
|
||||
array_push($categories, $grace->categoryId);
|
||||
}
|
||||
if (count($categories)) {
|
||||
$categories = $this->category_model->findById(implode(',', $categories))->result();
|
||||
foreach ($graces as $k => $g) {
|
||||
foreach ($categories as $c) {
|
||||
if ($g->categoryId == $c->idx) {
|
||||
$graces[$k]->categoryName = $c->category_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
public function write() {
|
||||
$this->load->view('adm/write');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
197
application/controllers/adm/bak/life.php
Executable file
197
application/controllers/adm/bak/life.php
Executable file
@@ -0,0 +1,197 @@
|
||||
<?php
|
||||
|
||||
class Life extends MY_Controller
|
||||
{
|
||||
private $parentCategoryName = 'grace-category';
|
||||
|
||||
private $lifeCategories = array('ids' => array());
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('Post', '', 'post');
|
||||
$this->load->model('category_model');
|
||||
$this->load->model('editor_model');
|
||||
$this->load->model('life_model');
|
||||
$this->lifeCategories['result'] = $this->category_model->findById()->result();
|
||||
foreach ($this->lifeCategories['result'] as $c) {
|
||||
array_push($this->lifeCategories['ids'], $c->idx);
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$data = array(
|
||||
'lifeCategories' => $this->lifeCategories['result'],
|
||||
'graceEditors' => $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result(),
|
||||
);
|
||||
$this->load->view($this->adminViewFolder . 'life', $data);
|
||||
}
|
||||
|
||||
private function tableClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.title', $this->param('term'));
|
||||
}
|
||||
if ($this->param('category')) {
|
||||
$this->db->like('l.category_idx', $this->param('category'));
|
||||
}
|
||||
if ($this->param('editor')) {
|
||||
$this->db->like('p.idx', $this->param('editor'));
|
||||
}
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
$request = $this->getRequest();
|
||||
$sort = $this->param('sort');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
$this->life_model->findByCategoryId($this->lifeCategories['ids'])
|
||||
->order_by('l.' . (empty($sortColumns[$sort]) ? $sortColumns['reg_date'] : $sortColumns[$sort]), $this->param('order'))
|
||||
->where('l.is_display !=', null)
|
||||
->select('l.display_date, l.is_display')
|
||||
->limit($this->param('limit'))
|
||||
->offset($this->param('offset'));
|
||||
$this->tableClause();
|
||||
$graces = $this->db->get()->result();
|
||||
|
||||
foreach ($graces as $k => $g) {
|
||||
if (strtotime($g->display_date) > time() && $g->is_display == 'N') {
|
||||
$graces[$k]->isSetDptime = 1;
|
||||
}
|
||||
}
|
||||
|
||||
$graceTotalCount = $this->life_model->findByCategoryId($this->lifeCategories['ids']);
|
||||
$this->tableClause();
|
||||
$graceTotalCount = $this->db->count_all_results();
|
||||
$categories = array();
|
||||
foreach ($graces as $grace) {
|
||||
array_push($categories, $grace->categoryId);
|
||||
}
|
||||
if (count($categories)) {
|
||||
$categories = $this->category_model->findById($categories)->result();
|
||||
foreach ($graces as $k => $g) {
|
||||
foreach ($categories as $c) {
|
||||
if ($g->categoryId == $c->idx) {
|
||||
$graces[$k]->categoryName = $c->category_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('total' => $graceTotalCount,
|
||||
'rows' => $graces)));
|
||||
}
|
||||
|
||||
public function content_delete()
|
||||
{
|
||||
$this->life_model->findById(1)->reset_query()->where('idx', $this->param('contentId'))->delete($this->life_model->table);
|
||||
if ($deleted = $this->db->affected_rows()) {
|
||||
$this->response(array('deleted' => $deleted));
|
||||
}
|
||||
}
|
||||
|
||||
public function content_category()
|
||||
{
|
||||
$data = array();
|
||||
if ($this->param('category')) {
|
||||
$data['category_idx'] = $this->param('category');
|
||||
}
|
||||
|
||||
if ($this->param('editor')) {
|
||||
$data['partner_idx'] = $this->param('editor');
|
||||
}
|
||||
|
||||
$this->life_model->findById($this->param('contentId'))->set($data)->update();
|
||||
if ($updated = $this->db->affected_rows()) {
|
||||
$this->response(array('updated' => $updated));
|
||||
}
|
||||
}
|
||||
|
||||
public function category()
|
||||
{
|
||||
$this->load->view($this->adminViewFolder . 'life-category');
|
||||
}
|
||||
|
||||
public function category_table()
|
||||
{
|
||||
$sort = $this->param('sort');
|
||||
$order = $this->param('order');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
$this->editor_model->findByCategoryId(null)
|
||||
->join($this->category_model->table . ' c', 'p.category_idx=c.idx', 'right')
|
||||
->where_in('c.idx', $this->lifeCategories['ids'])
|
||||
->where('c.is_del', 'N')
|
||||
->group_by('c.idx')->select('count(category_idx) editorCount, c.category_name categoryName,
|
||||
c.display_sort displayOrder, c.reg_date, c.idx categoryId');
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('c.category_name', $this->param('term'));
|
||||
}
|
||||
$categoryEditors = $this->db->get()->result();
|
||||
$categories = array();
|
||||
foreach ($categoryEditors as $grace) {
|
||||
array_push($categories, $grace->categoryId);
|
||||
}
|
||||
|
||||
$posts = $this->life_model->findByCategoryId($this->lifeCategories['ids'])->group_by('p.category_idx')
|
||||
->select('count(p.idx) postCount, sum(hit_count) views')->get()->result();
|
||||
foreach ($categoryEditors as $k => $g) {
|
||||
$categoryEditors[$k]->postCount = 0;
|
||||
$categoryEditors[$k]->views = 0;
|
||||
foreach ($posts as $p) {
|
||||
if ($g->categoryId == $p->categoryId) {
|
||||
$categoryEditors[$k]->postCount += $p->postCount;
|
||||
$categoryEditors[$k]->views += $p->views;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->output
|
||||
->set_content_type('application/json')
|
||||
->set_output(json_encode(array('total' => count($categoryEditors),
|
||||
'rows' => $categoryEditors)));
|
||||
}
|
||||
|
||||
public function category_save()
|
||||
{
|
||||
$parentId = $this->category_model->getSubCategoryId($this->parentCategoryName)['parent'];
|
||||
if (!empty($this->param('id'))) {
|
||||
$this->db->where('idx', $this->param('id'))->update($this->category_model->table, array(
|
||||
'category_name' => $this->param('name'),
|
||||
'display_sort' => $this->param('order'),
|
||||
'parent' => $parentId,
|
||||
'update_id' => $this->session->userdata('Adm_Id'),
|
||||
'update_date' => date('Y-m-d H:i:s'),
|
||||
));
|
||||
if ($updated = $this->db->affected_rows()) {
|
||||
$this->response(array('updated' => $updated));
|
||||
}
|
||||
} else {
|
||||
if ($inserted = $this->db->insert($this->category_model->table, array(
|
||||
'category_name' => $this->param('name'),
|
||||
'display_sort' => $this->param('order'),
|
||||
'parent' => $parentId,
|
||||
'reg_id' => $this->session->userdata('Adm_Id'),
|
||||
'reg_date' => date('Y-m-d H:i:s'),
|
||||
))) {
|
||||
$this->response(array('inserted' => $this->db->insert_id()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function category_delete()
|
||||
{
|
||||
if (!empty($this->param('id'))) {
|
||||
$this->db->where('idx', $this->param('id'))->update($this->category_model->table, array(
|
||||
'is_del' => 'Y',
|
||||
));
|
||||
if ($updated = $this->db->affected_rows()) {
|
||||
$this->response(array('updated' => $updated));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
16
application/controllers/adm/bak/main.php
Executable file
16
application/controllers/adm/bak/main.php
Executable file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
class Main extends MY_Controller
|
||||
{
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$this->load->view($this->adminViewFolder . 'main');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user