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');
|
||||
}
|
||||
|
||||
}
|
||||
493
application/controllers/adm/content.php
Executable file
493
application/controllers/adm/content.php
Executable file
@@ -0,0 +1,493 @@
|
||||
<?php
|
||||
|
||||
class Content extends MY_Controller
|
||||
{
|
||||
|
||||
private $parentCategoryName = 'grace-category';
|
||||
|
||||
private $lifeCategories = array('ids' => array());
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('pagination');
|
||||
$this->load->library('post');
|
||||
$this->load->model('category_model');
|
||||
$this->load->model('editor_model');
|
||||
$this->load->model('life_model');
|
||||
$this->load->model('member_model');
|
||||
$this->load->library('awsfileuploader');
|
||||
$this->lifeCategories['result'] = $this->category_model->findById()->result();
|
||||
foreach ($this->lifeCategories['result'] as $c) {
|
||||
array_push($this->lifeCategories['ids'], $c->idx);
|
||||
}
|
||||
$this->editors = $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->order_by('partner_name')->get()->result();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$table = $this->table();
|
||||
// print_r($table['rows']);die;
|
||||
$page = $this->input->get('page') ? $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);
|
||||
|
||||
if ($this->input->get('pageset')) {
|
||||
foreach ($table['rows'] as $k => $r) {
|
||||
$table['rows'][$k]->title = html_entity_decode(convertEmoji($table['rows'][$k]->title));
|
||||
$table['rows'][$k]->mainImg = imgSrc($table['rows'][$k]->mainImg);
|
||||
}
|
||||
$this->response($table);
|
||||
} else {
|
||||
$data = array(
|
||||
'lifeCategories' => $this->lifeCategories['result'],
|
||||
'graceEditors' => $this->editors,
|
||||
'paging' => $this->pagination->create_links(),
|
||||
'table' => $table,
|
||||
'page' => $page,
|
||||
);
|
||||
$this->load->view('adm/content', $data);
|
||||
}
|
||||
}
|
||||
|
||||
private function tableClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.title', $this->param('term'));
|
||||
}
|
||||
if ($this->param('category')) {
|
||||
$ccc = $this->param('category');
|
||||
if ($this->input->get('pageset') && strpos($this->param('category'), '-')) {
|
||||
$ccc = explode('-', $this->param('category'));
|
||||
}
|
||||
$this->db->where_in('l.category_idx', $ccc);
|
||||
}
|
||||
if ($this->param('editor')) {
|
||||
$this->db->like('l.partner_idx', $this->param('editor'));
|
||||
}
|
||||
$this->db->where('l.is_display !=', null);
|
||||
if ($this->input->get('pageset')) {$this->db->where('l.is_del', 'N');
|
||||
$this->db->where('l.is_display', 'Y');}
|
||||
}
|
||||
|
||||
private function getTableRows()
|
||||
{
|
||||
$sort = $this->param('sort');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
$this->tableClause();
|
||||
$this->life_model->findByCategoryId($this->lifeCategories['ids'])
|
||||
->order_by('l.' . $sortColumns['reg_date'], $this->param('order'))
|
||||
->select('l.display_date, l.is_display, l.is_del')
|
||||
->limit($this->param('limit'))
|
||||
->offset($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0));
|
||||
$graces = $this->db->get()->result();
|
||||
foreach ($graces as $k => $g) {
|
||||
if (strtotime($g->display_date) > time() && $g->is_display == 'N') {
|
||||
$graces[$k]->isSetDptime = 1;
|
||||
}
|
||||
}
|
||||
return $graces;
|
||||
}
|
||||
|
||||
private function getTableCount()
|
||||
{
|
||||
$this->tableClause();
|
||||
$this->life_model->findByCategoryId($this->lifeCategories['ids']);
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
$graces = $this->getTableRows();
|
||||
$graceTotalCount = $this->getTableCount();
|
||||
$this->addCategoryNameToTableResponse($graces);
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
private function addCategoryNameToTableResponse(&$graces)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getContentImages()
|
||||
{
|
||||
preg_match_all('/(..\/..\/..\/uploads\/[a-z0-9A-Z._]+)/',
|
||||
$this->input->post('content'), $matches);
|
||||
$contentImages = array(array(), array());
|
||||
foreach ($matches[0] as $match) {
|
||||
$contentImages[0][] = $match;
|
||||
$contentImages[1][] = FCPATH . 'uploads' . DIRECTORY_SEPARATOR . basename($match);
|
||||
}
|
||||
return $contentImages;
|
||||
}
|
||||
|
||||
private function uploadContentImage($insertId = 0)
|
||||
{
|
||||
if (!$insertId) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$contentImages = $this->getContentImages();
|
||||
if ($this->input->post('contentId')) {
|
||||
$contentUploadedImages = $this->db->where('content_idx', $this->input->post('contentId'))->get('cm_content_image')->result();
|
||||
if (count($contentUploadedImages)) {
|
||||
foreach ($contentUploadedImages as $img) {
|
||||
$this->awsfileuploader->delete($img->url);
|
||||
}
|
||||
$this->db->where('content_idx', $this->input->post('contentId'))->delete('cm_content_image');
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($contentImages[1] as $k => $img) {
|
||||
$url = '/files/life/' . date('Y/m/') . basename($img);
|
||||
$this->awsfileuploader->upload($img, 'files/life/' . date('Y/m/') . basename($img));
|
||||
$this->db->insert('cm_content_image', array(
|
||||
'content_idx' => $insertId,
|
||||
'url' => substr($url, 1),
|
||||
));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function write()
|
||||
{ini_set('display_errors', 1);
|
||||
if ($this->input->post('title')) {
|
||||
$categoryId = $this->input->post('category');
|
||||
$editorId = $this->input->post('editor');
|
||||
$title = str_replace('"', '\"', addslashes(convertEmoji($this->input->post('title'), 'ENCODE')));
|
||||
$mainImg = $this->input->post('main_img');
|
||||
|
||||
$contentImages = $this->getContentImages();
|
||||
$content = $this->input->post('content');
|
||||
if(isset($contentImages[1]) && count($contentImages[1])) {
|
||||
foreach ($contentImages[1] as $k => $img) {
|
||||
$url = '/files/life/' . date('Y/m/') . basename($img);
|
||||
$content = str_replace($contentImages[0][$k], $url, $content);
|
||||
}
|
||||
}
|
||||
|
||||
$content = str_replace('"', '\"', addslashes(convertEmoji($content, 'ENCODE')));
|
||||
$isDisplay = $this->input->post('is_display');
|
||||
$isDisplay = $isDisplay == 'R' ? 'N' : $isDisplay;
|
||||
$displayTime = $this->input->post('display_time');
|
||||
$now = date('Y-m-d H:i:s');
|
||||
|
||||
if (isset($_FILES['uploadfile']) && is_uploaded_file($_FILES['uploadfile']['tmp_name'])) {
|
||||
$upload = $this->post->upload('uploadfile');
|
||||
$filePath = FCPATH . 'uploads/' . explode('uploads/', $upload['full_path'])[1];
|
||||
$keyPath = 'files/life/' . date('Y/m/') . basename($filePath);
|
||||
$mainImg = $this->awsfileuploader->upload($filePath, $keyPath);
|
||||
}
|
||||
if ($this->input->post('contentId')) {
|
||||
$sql = "UPDATE life
|
||||
SET
|
||||
category_idx = $categoryId,
|
||||
partner_idx = $editorId,
|
||||
title = '$title',
|
||||
main_img = '$mainImg',
|
||||
content = '$content',
|
||||
update_date = '$now',
|
||||
display_date = '$displayTime',
|
||||
is_display = '$isDisplay'
|
||||
WHERE
|
||||
idx = " . $this->input->post('contentId');
|
||||
} else {
|
||||
$sql = "insert into
|
||||
life(category_idx, partner_idx, title, main_img, content, reg_date, display_date, is_display)
|
||||
values($categoryId, $editorId,'$title', '$mainImg', '$content', '$now', '$displayTime', '$isDisplay')";
|
||||
}
|
||||
if ($this->db->query($sql)) {
|
||||
if(isset($contentImages[1]) && count($contentImages[1])) {
|
||||
$this->uploadContentImage($this->input->post('contentId') ? $this->input->post('contentId') : $this->db->insert_id());
|
||||
}
|
||||
go($this->input->server('HTTP_REFERER'), '등록성공.');
|
||||
} else {
|
||||
echo 'error' . $this->db->last_query();
|
||||
}
|
||||
} else if ($this->uri->segment(4)) {
|
||||
$contentId = $this->uri->segment(4);
|
||||
|
||||
$query = $this->db->query("SELECT
|
||||
`p`.`idx` `editorId`,
|
||||
`p`.`partner_img` `editorImg`,
|
||||
`p`.`main_img` `editorMainImg`,
|
||||
`p`.`partner_name` `editorName`,
|
||||
`p`.`partner_intro` `editorIntro`,
|
||||
`l`.`title`,
|
||||
`l`.`head_title`,
|
||||
`l`.`sub_title`,
|
||||
`l`.`content`,
|
||||
`l`.`category_idx` `categoryId`,
|
||||
`l`.`idx`,
|
||||
`l`.`main_img` `mainImg`,
|
||||
`l`.`hit_count` `views`,
|
||||
`l`.`like_count` `likes`,
|
||||
`l`.`comment_count` `comments`,
|
||||
`l`.*
|
||||
FROM
|
||||
`life` `l`
|
||||
LEFT JOIN
|
||||
`partner` `p` ON `l`.`partner_idx` = `p`.`idx`
|
||||
WHERE
|
||||
`l`.`idx` IN ($contentId)");
|
||||
|
||||
$post = $query->row();
|
||||
$data = array(
|
||||
'post' => $post,
|
||||
'lifeCategories' => $this->lifeCategories['result'],
|
||||
'graceEditors' => $this->editors,
|
||||
);
|
||||
$this->load->view('adm/contentwrite', $data);
|
||||
} else {
|
||||
$data = array(
|
||||
'lifeCategories' => $this->category_model->getCategories($this->lifeCategories['ids']),
|
||||
'graceEditors' => $this->editors,
|
||||
);
|
||||
$this->load->view('adm/contentwrite', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$this->db->where_in('idx', explode('-', $this->input->get('list')))->update('life', array('is_del' => 'Y', 'is_display' => 'N'));
|
||||
go($this->input->server('HTTP_REFERER'), '삭제되었습니다.');
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->db->where('idx', $this->input->post('postid'))->update('life', array('is_display' => $this->input->post('is_display'), 'is_del' => 'N'));
|
||||
}
|
||||
|
||||
public function reserve()
|
||||
{
|
||||
$configType = 'dptime';
|
||||
$this->load->model('config_model');
|
||||
if ($this->input->post('title')) {
|
||||
$this->load->model('life_model');
|
||||
$this->db->where('idx', $this->input->post('postid'))->update($this->life_model->table, array('is_display' => 'N', 'display_date' => $this->input->post('dptime')));
|
||||
$config = $this->config_model->findByTypeAndPostId($configType, $this->input->post)->get()->row();
|
||||
if ($config) {
|
||||
if ($this->db->where('Id', $config->Id)->update($this->config_model->table, array(
|
||||
'PostId' => $this->input->post('postid'),
|
||||
'Type' => $configType,
|
||||
'DpTime' => $this->input->post('dptime'),
|
||||
))) {
|
||||
go($this->input->post('redirect'), '예약설정 변경성공');
|
||||
} else {
|
||||
go($this->input->post('redirect'), '예약설정 실패');
|
||||
}
|
||||
} else {
|
||||
if ($this->db->insert($this->config_model->table, array(
|
||||
'PostId' => $this->input->post('postid'),
|
||||
'Type' => $configType,
|
||||
'DpTime' => $this->input->post('dptime'),
|
||||
))) {
|
||||
go($this->input->post('redirect'), '예약설정 등록성공');
|
||||
} else {
|
||||
go($this->input->post('redirect'), '예약설정 실패');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$contentId = $this->input->get('list');
|
||||
$query = $this->db->query("SELECT
|
||||
`l`.*
|
||||
FROM
|
||||
`life` `l`
|
||||
WHERE
|
||||
`l`.`idx` IN ($contentId)");
|
||||
|
||||
$post = $query->row();
|
||||
$post->reserve_time = date('Y-m-d H:i:s', time() + 3600 * 24);
|
||||
if ($config = $this->config_model->findByTypeAndPostId($configType, $contentId)->get()->row()) {
|
||||
$post->reserve_time = $config->DpTime;
|
||||
}
|
||||
$data = array(
|
||||
'post' => $post,
|
||||
);
|
||||
|
||||
$this->load->view('adm/reserve', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function config()
|
||||
{
|
||||
$this->load->model('config_model');
|
||||
if ($this->input->method() == 'post') {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////// category lsit /////////////////////
|
||||
|
||||
public function category()
|
||||
{
|
||||
$table = $this->tableCategory();
|
||||
// print_r($table['rows']);die;
|
||||
$page = $this->input->get('page') ? $this->input->get('page') : 1;
|
||||
|
||||
$config['base_url'] = '/adm/' . strtolower(__CLASS__) . '/category';
|
||||
$config['total_rows'] = $table['total'];
|
||||
$config['per_page'] = $this->param('limit');
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
foreach ($table['rows'] as $k => $v) {
|
||||
$table['rows'][$k]->category_fullpath = array('<a href="/adm/content/categoryedit/' . $v->idx . '">' . $v->category_name . '</a>');
|
||||
foreach ($this->categoryall as $c) {
|
||||
if ($v->parent == $c->idx) {
|
||||
$table['rows'][$k]->category_fullpath[] = '<a href="/adm/content/categoryedit/' . $c->idx . '">' . $c->category_name . '</a>';
|
||||
}
|
||||
}
|
||||
$table['rows'][$k]->category_fullpath = implode(' > ', array_reverse($table['rows'][$k]->category_fullpath));
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'paging' => $this->pagination->create_links(),
|
||||
'table' => $table,
|
||||
'page' => $page,
|
||||
);
|
||||
|
||||
$this->load->view('adm/contentcategory', $data);
|
||||
}
|
||||
|
||||
public function tableCategory()
|
||||
{
|
||||
$graces = $this->getTableCategoryRows();
|
||||
$graceTotalCount = $this->getTableCategoryCount();
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
private function getTableCategoryCount()
|
||||
{
|
||||
$this->tableCategoryClause();
|
||||
$this->category_model->findAll();
|
||||
$cnt = $this->db->count_all_results();
|
||||
|
||||
$this->category_model->findAll();
|
||||
$query = $this->db->get();
|
||||
$this->categoryall = $query->result();
|
||||
return $cnt;
|
||||
}
|
||||
|
||||
private function tableCategoryClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.category_name', $this->param('term'));
|
||||
}
|
||||
$this->db->where('l.is_del', 'N');
|
||||
}
|
||||
|
||||
private function getTableCategoryRows()
|
||||
{
|
||||
$sort = $this->param('sort');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'parent');
|
||||
|
||||
$this->tableCategoryClause();
|
||||
$this->category_model->findAll()
|
||||
->order_by('l.parent desc, reg_date desc')
|
||||
->limit($this->param('limit'))
|
||||
->offset($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0));
|
||||
$graces = $this->db->get()->result();
|
||||
return $graces;
|
||||
}
|
||||
|
||||
public function categoryedit()
|
||||
{
|
||||
if ($this->input->post('idx')) {
|
||||
$data = array('parent' => $this->input->post('parent'), 'category_name' => $this->input->post('category_name'), 'update_date' => date('Y-m-d H:i:s'), 'description' => $this->input->post('description'));
|
||||
$this->db->where('idx', $this->input->post('idx'))->update('category', $data);
|
||||
go($this->input->post('redirect'), 'Success');
|
||||
} else if ($this->input->post('category_name')) {
|
||||
$data = array('parent' => $this->input->post('parent'), 'category_name' => $this->input->post('category_name'), 'reg_date' => date('Y-m-d H:i:s'), 'description' => $this->input->post('description'));
|
||||
$this->db->insert('category', $data);
|
||||
go($this->input->post('redirect'), 'Success');
|
||||
} else {
|
||||
$category = null;
|
||||
if ($this->uri->segment(4)) {
|
||||
$category = $this->category_model->findById($this->uri->segment(4))->row();
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'lifeCategories' => $this->lifeCategories['result'],
|
||||
'category' => $category,
|
||||
);
|
||||
$this->load->view('adm/contentcategoryedit', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function categorydelete()
|
||||
{
|
||||
if ($this->input->get('list')) {
|
||||
$this->db->where_in('idx', explode('-', $this->input->get('list')))->update('category', array('is_del' => 'Y'));
|
||||
go($this->input->server('HTTP_REFERER'), 'Success');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
288
application/controllers/adm/dataman.php
Executable file
288
application/controllers/adm/dataman.php
Executable file
@@ -0,0 +1,288 @@
|
||||
<?php
|
||||
|
||||
class Dataman extends MY_Controller
|
||||
{
|
||||
|
||||
private $parentCategoryName = 'grace-category';
|
||||
|
||||
private $lifeCategories = array('ids' => array());
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('pagination');
|
||||
$this->load->model('category_model');
|
||||
$this->load->model('editor_model');
|
||||
$this->load->model('member_model');
|
||||
$this->lifeCategories['result'] = $this->category_model->findById()->result();
|
||||
foreach ($this->lifeCategories['result'] as $c) {
|
||||
array_push($this->lifeCategories['ids'], $c->idx);
|
||||
}
|
||||
}
|
||||
|
||||
public function ytchannel()
|
||||
{
|
||||
$table = $this->table();
|
||||
$page = $this->input->get('page') ? $this->input->get('page') : 1;
|
||||
|
||||
$config['base_url'] = '/adm/' . strtolower(__CLASS__) . '/ytchannel';
|
||||
$config['total_rows'] = $table['total'];
|
||||
$config['per_page'] = $this->param('limit');
|
||||
$this->pagination->initialize($config);
|
||||
$data = array(
|
||||
'paging' => $this->pagination->create_links(),
|
||||
'table' => $table,
|
||||
'page' => $page,
|
||||
);
|
||||
|
||||
$this->load->view('adm/ytchannel', $data);
|
||||
}
|
||||
|
||||
private function getTableRows()
|
||||
{
|
||||
// $sort = $this->param('sort');
|
||||
// $sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
// $this->tableClause();
|
||||
// $this->member_model->findAll()
|
||||
// ->order_by('l.' . $sortColumns['reg_date'], $this->param('order'))
|
||||
// ->limit($this->param('limit'))
|
||||
// ->offset($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0));
|
||||
// $graces = $this->db->get()->result();
|
||||
$sql = "SELECT yt.*, l.sync_date, l.contentCount FROM cm_ytchannel yt inner join (select count(idx) contentCount, max(reg_date) sync_date, category_idx, partner_idx from life l group by category_idx, partner_idx) as l on yt.CategoryId = l.category_idx and yt.editorId = l.partner_idx limit " . ($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0)) . ", " . $this->param('limit');
|
||||
return $this->db->query($sql)->result();
|
||||
}
|
||||
|
||||
private function getTableCount()
|
||||
{
|
||||
// $this->tableClause();
|
||||
// $this->member_model->findAll();
|
||||
// return $this->db->count_all_results();
|
||||
|
||||
$sql = "SELECT count(*) cnt FROM cm_ytchannel";
|
||||
|
||||
return $this->db->query($sql)->row()->cnt;
|
||||
}
|
||||
|
||||
private function tableClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.member_name', $this->param('term'));
|
||||
}
|
||||
$this->db->where('l.member_status !=', 2);
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
$graces = $this->getTableRows();
|
||||
$graceTotalCount = $this->getTableCount();
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
public function reg()
|
||||
{
|
||||
if ($this->input->post('title')) {
|
||||
$categoryId = $this->input->post('category');
|
||||
$editorId = $this->input->post('editor');
|
||||
$title = str_replace('"', '\"', addslashes($this->input->post('title')));
|
||||
$mainImg = $this->input->post('main_img');
|
||||
$content = str_replace('"', '\"', addslashes($this->input->post('content')));
|
||||
$now = date('Y-m-d H:i:s');
|
||||
if (isset($_FILES['uploadfile']) && is_uploaded_file($_FILES['uploadfile']['tmp_name'])) {
|
||||
$upload = $this->post->upload('uploadfile');
|
||||
$this->load->library('awsfileuploader');
|
||||
$mainImg = $this->awsfileuploader->upload('uploads/' . explode('uploads/', $upload['full_path'])[1]);
|
||||
}
|
||||
if ($this->input->post('contentId')) {
|
||||
$sql = "UPDATE life
|
||||
SET
|
||||
is_display = 'N',
|
||||
category_idx = $categoryId,
|
||||
partner_idx = $editorId,
|
||||
title = '$title',
|
||||
main_img = '$mainImg',
|
||||
content = '$content',
|
||||
update_date = '$now'
|
||||
WHERE
|
||||
idx = " . $this->input->post('contentId');
|
||||
} else {
|
||||
$sql = "insert into
|
||||
life(is_display, category_idx, partner_idx, title, main_img, content, reg_date)
|
||||
values('N', $categoryId, $editorId,'$title', '$mainImg', '$content', '$now')";
|
||||
}
|
||||
if ($this->db->query($sql)) {
|
||||
header('location:' . $this->input->server('HTTP_REFERER'));
|
||||
} else {
|
||||
echo 'error' . $this->db->last_query();
|
||||
}
|
||||
} else if ($this->uri->segment(4)) {
|
||||
$contentId = $this->uri->segment(4);
|
||||
|
||||
$query = $this->db->query("SELECT
|
||||
`p`.`idx` `editorId`,
|
||||
`p`.`partner_img` `editorImg`,
|
||||
`p`.`main_img` `editorMainImg`,
|
||||
`p`.`partner_name` `editorName`,
|
||||
`p`.`partner_intro` `editorIntro`,
|
||||
`l`.`title`,
|
||||
`l`.`head_title`,
|
||||
`l`.`sub_title`,
|
||||
`l`.`content`,
|
||||
`l`.`category_idx` `categoryId`,
|
||||
`l`.`idx`,
|
||||
`l`.`main_img` `mainImg`,
|
||||
`l`.`hit_count` `views`,
|
||||
`l`.`like_count` `likes`,
|
||||
`l`.`comment_count` `comments`,
|
||||
`l`.*
|
||||
FROM
|
||||
`life` `l`
|
||||
LEFT JOIN
|
||||
`partner` `p` ON `l`.`partner_idx` = `p`.`idx`
|
||||
WHERE
|
||||
`l`.`idx` IN ($contentId)");
|
||||
|
||||
$post = $query->row();
|
||||
$data = array(
|
||||
'post' => $post,
|
||||
'lifeCategories' => $this->lifeCategories['result'],
|
||||
'graceEditors' => $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result(),
|
||||
);
|
||||
$this->load->view('adm/content_write', $data);
|
||||
} else {
|
||||
$data = array(
|
||||
'lifeCategories' => $this->lifeCategories['result'],
|
||||
'graceEditors' => $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result(),
|
||||
);
|
||||
$this->load->view('adm/content_write', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
go($this->input->server('HTTP_REFERER'), '삭제되었습니다.');
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->db->where('idx', $this->input->post('postid'))->update('life', array('is_display' => $this->input->post('is_display')));
|
||||
}
|
||||
|
||||
public function podbbang()
|
||||
{
|
||||
$table = $this->tablePodbbang();
|
||||
// print_r($table['rows']);die;
|
||||
$page = $this->input->get('page') ? $this->input->get('page') : 1;
|
||||
|
||||
$config['base_url'] = '/adm/' . strtolower(__CLASS__) . '/podbbang';
|
||||
$config['total_rows'] = $table['total'];
|
||||
$config['per_page'] = $this->param('limit');
|
||||
$this->pagination->initialize($config);
|
||||
$data = array(
|
||||
'paging' => $this->pagination->create_links(),
|
||||
'table' => $table,
|
||||
'page' => $page,
|
||||
);
|
||||
|
||||
$this->load->view('adm/podbbang', $data);
|
||||
}
|
||||
|
||||
public function tablePodbbang()
|
||||
{
|
||||
$graces = $this->gettablePodbbangRows();
|
||||
$graceTotalCount = $this->gettablePodbbangCount();
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
private function tablePodbbangClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.partner_name', $this->param('term'));
|
||||
}
|
||||
}
|
||||
|
||||
private function gettablePodbbangRows()
|
||||
{
|
||||
// $sort = $this->param('sort');
|
||||
// $sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
// $this->tablePodbbangClause();
|
||||
// $this->editor_model->findAll()
|
||||
// ->order_by('l.' . $sortColumns['reg_date'], $this->param('order'))
|
||||
// ->limit($this->param('limit'))
|
||||
// ->offset($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0));
|
||||
// $graces = $this->db->get()->result();
|
||||
$sql = "SELECT * FROM cm_station limit " . ($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0)) . ", " . $this->param('limit');
|
||||
return $this->db->query($sql)->result();
|
||||
}
|
||||
|
||||
private function gettablePodbbangCount()
|
||||
{
|
||||
// $this->tablePodbbangClause();
|
||||
// $this->editor_model->findAll();
|
||||
// return $this->db->count_all_results();
|
||||
$sql = "SELECT count(*) cnt FROM cm_station";
|
||||
|
||||
return $this->db->query($sql)->row()->cnt;
|
||||
}
|
||||
|
||||
public function church()
|
||||
{
|
||||
$table = $this->tableChurch();
|
||||
$page = $this->input->get('page') ? $this->input->get('page') : 1;
|
||||
|
||||
$config['base_url'] = '/adm/' . strtolower(__CLASS__) . '/church';
|
||||
$config['total_rows'] = $table['total'];
|
||||
$config['per_page'] = $this->param('limit');
|
||||
$this->pagination->initialize($config);
|
||||
$data = array(
|
||||
'paging' => $this->pagination->create_links(),
|
||||
'table' => $table,
|
||||
'page' => $page,
|
||||
);
|
||||
|
||||
$this->load->view('adm/church', $data);
|
||||
}
|
||||
|
||||
private function getTableChurchRows()
|
||||
{
|
||||
// $sort = $this->param('sort');
|
||||
// $sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
// $this->tableClause();
|
||||
// $this->member_model->findAll()
|
||||
// ->order_by('l.' . $sortColumns['reg_date'], $this->param('order'))
|
||||
// ->limit($this->param('limit'))
|
||||
// ->offset($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0));
|
||||
// $graces = $this->db->get()->result();
|
||||
$sql = "SELECT * FROM cm_naver_place limit " . ($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0)) . ", " . $this->param('limit');
|
||||
return $this->db->query($sql)->result();
|
||||
}
|
||||
|
||||
private function getTableChurchCount()
|
||||
{
|
||||
// $this->tableClause();
|
||||
// $this->member_model->findAll();
|
||||
// return $this->db->count_all_results();
|
||||
|
||||
$sql = "SELECT count(*) cnt FROM cm_naver_place";
|
||||
|
||||
return $this->db->query($sql)->row()->cnt;
|
||||
}
|
||||
|
||||
private function tableChurchClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.member_name', $this->param('term'));
|
||||
}
|
||||
$this->db->where('l.member_status !=', 2);
|
||||
}
|
||||
|
||||
public function tableChurch()
|
||||
{
|
||||
$graces = $this->getTableChurchRows();
|
||||
$graceTotalCount = $this->getTableChurchCount();
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
}
|
||||
400
application/controllers/adm/member.php
Executable file
400
application/controllers/adm/member.php
Executable file
@@ -0,0 +1,400 @@
|
||||
<?php
|
||||
|
||||
class Member extends MY_Controller
|
||||
{
|
||||
|
||||
private $parentCategoryName = 'grace-category';
|
||||
|
||||
private $lifeCategories = array('ids' => array());
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('pagination');
|
||||
$this->load->library('post');
|
||||
$this->load->model('category_model');
|
||||
$this->load->model('editor_model');
|
||||
$this->load->model('member_model');
|
||||
$this->load->model('life_model');
|
||||
$this->load->model('comment_model');
|
||||
$this->load->library('awsfileuploader');
|
||||
$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 = $this->input->get('page') ? $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(
|
||||
'paging' => $this->pagination->create_links(),
|
||||
'table' => $table,
|
||||
'page' => $page,
|
||||
);
|
||||
|
||||
$this->load->view('adm/member', $data);
|
||||
}
|
||||
|
||||
public function active()
|
||||
{
|
||||
$this->db->where('idx', $this->input->post('postid'))->update('member', array('member_status' => $this->input->post('is_display')));
|
||||
}
|
||||
|
||||
public function editor()
|
||||
{
|
||||
$table = $this->tableEditor();
|
||||
// print_r($table['rows']);die;
|
||||
$page = $this->input->get('page') ? $this->input->get('page') : 1;
|
||||
|
||||
$config['base_url'] = '/adm/' . strtolower(__CLASS__) . '/editor';
|
||||
$config['total_rows'] = $table['total'];
|
||||
$config['per_page'] = $this->param('limit');
|
||||
|
||||
$this->pagination->initialize($config);
|
||||
$data = array(
|
||||
'paging' => $this->pagination->create_links(),
|
||||
'table' => $table,
|
||||
'page' => $page,
|
||||
);
|
||||
|
||||
$this->load->view('adm/editor', $data);
|
||||
}
|
||||
|
||||
public function editoredit()
|
||||
{
|
||||
if ($this->input->post('partner_name')) {
|
||||
$mainImg = $this->input->post('main_img');
|
||||
$partner_img = $this->input->post('partner_img');
|
||||
$is_del = $this->input->post('is_del');
|
||||
$partner_id = $this->input->post('partner_id');
|
||||
$partner_real_name = $this->input->post('partner_real_name');
|
||||
$partner_name = $this->input->post('partner_name');
|
||||
$partner_intro = $this->input->post('partner_intro');
|
||||
$partner_homepage = $this->input->post('partner_homepage');
|
||||
|
||||
if (isset($_FILES['uploadfile']) && is_uploaded_file($_FILES['uploadfile']['tmp_name'])) {
|
||||
if ($mainImg) {
|
||||
$this->awsfileuploader->upload(substr($mainImg, 1));
|
||||
}
|
||||
$upload = $this->post->upload('uploadfile');
|
||||
$filePath = FCPATH . 'uploads/' . explode('uploads/', $upload['full_path'])[1];
|
||||
$keyPath = 'files/life/' . date('Y/m/') . basename($filePath);
|
||||
$mainImg = $this->awsfileuploader->upload($filePath, $keyPath);
|
||||
}
|
||||
|
||||
if (isset($_FILES['uploadfile2']) && is_uploaded_file($_FILES['uploadfile2']['tmp_name'])) {
|
||||
if ($partner_img) {
|
||||
$this->awsfileuploader->upload(substr($partner_img, 1));
|
||||
}
|
||||
$upload = $this->post->upload('uploadfile2');
|
||||
$filePath = FCPATH . 'uploads/' . explode('uploads/', $upload['full_path'])[1];
|
||||
$keyPath = 'files/life/' . date('Y/m/') . basename($filePath);
|
||||
$partner_img = $this->awsfileuploader->upload($filePath, $keyPath);
|
||||
}
|
||||
|
||||
$now = date('Y-m-d H:i:s');
|
||||
if ($this->input->post('contentId')) {
|
||||
$sql = "UPDATE partner
|
||||
SET
|
||||
partner_real_name = '$partner_real_name',
|
||||
partner_id = '$partner_id',
|
||||
partner_name = '$partner_name',
|
||||
main_img = '$mainImg',
|
||||
partner_img = '$partner_img',
|
||||
update_date = '$now',
|
||||
is_del = '$is_del',
|
||||
partner_intro='$partner_intro',
|
||||
partner_homepage='$partner_homepage'
|
||||
WHERE
|
||||
idx = " . $this->input->post('contentId');
|
||||
} else {
|
||||
$sql = "insert into
|
||||
partner(partner_id, partner_name, partner_real_name, main_img, partner_img, reg_date, is_del,partner_intro,partner_homepage)
|
||||
values('$partner_id', '$partner_name','$partner_real_name', '$mainImg', '$partner_img', '$now', '$is_del', '$partner_intro','$partner_homepage')";
|
||||
}
|
||||
if ($this->db->query($sql)) {
|
||||
go($this->input->server('HTTP_REFERER'), '등록성공.');
|
||||
} else {
|
||||
echo 'error' . $this->db->last_query();
|
||||
}
|
||||
} else if ($this->uri->segment(4)) {
|
||||
|
||||
$this->load->view('adm/membereditoredit', array('post' => $this->db->where('idx', $this->uri->segment(4))->get('partner')->row()));
|
||||
} else {
|
||||
|
||||
$this->load->view('adm/membereditoredit');
|
||||
}
|
||||
}
|
||||
|
||||
public function editordelete()
|
||||
{
|
||||
$this->db->where_in('idx', explode('-', $this->input->get('list')))->update('partner', array('is_del' => 'Y'));
|
||||
go($this->input->server('HTTP_REFERER'), '삭제되었습니다.');
|
||||
}
|
||||
|
||||
public function editoractive()
|
||||
{
|
||||
$this->db->where('idx', $this->input->post('postid'))->update('partner', array('is_del' => $this->input->post('is_display')));
|
||||
}
|
||||
|
||||
public function comment()
|
||||
{
|
||||
$table = $this->tableComment();
|
||||
// print_r($table['rows']);die;
|
||||
$page = $this->input->get('page') ? $this->input->get('page') : 1;
|
||||
|
||||
$config['base_url'] = '/adm/' . strtolower(__CLASS__) . '/comment';
|
||||
$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/comment', $data);
|
||||
}
|
||||
|
||||
private function tableCommentClause()
|
||||
{
|
||||
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('l.partner_idx', $this->param('editor'));
|
||||
}
|
||||
$this->db->where('l.is_display !=', null);
|
||||
}
|
||||
|
||||
private function getTableCommentRows()
|
||||
{
|
||||
$sort = $this->param('sort');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
$this->tableCommentClause();
|
||||
$this->life_model->findByCategoryId($this->lifeCategories['ids'])
|
||||
->order_by('l.' . $sortColumns['reg_date'], $this->param('order'))
|
||||
->select('l.display_date, l.is_display, c.comment, c.idx commentId')
|
||||
->join('comment c', 'c.content_idx=l.idx', 'inner')
|
||||
->limit($this->param('limit'))
|
||||
->offset($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0));
|
||||
$graces = $this->db->get()->result();
|
||||
foreach ($graces as $k => $g) {
|
||||
if (strtotime($g->display_date) > time() && $g->is_display == 'N') {
|
||||
$graces[$k]->isSetDptime = 1;
|
||||
}
|
||||
}
|
||||
return $graces;
|
||||
}
|
||||
|
||||
private function getTableCommentCount()
|
||||
{
|
||||
$this->tableCommentClause();
|
||||
$this->life_model->findByCategoryId($this->lifeCategories['ids'])->join('comment c', 'c.content_idx=l.idx', 'inner');
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
public function tableComment()
|
||||
{
|
||||
$graces = $this->getTableCommentRows();
|
||||
$graceTotalCount = $this->getTableCommentCount();
|
||||
$this->addCategoryNameToTableResponse($graces);
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
private function addCategoryNameToTableResponse(&$graces)
|
||||
{
|
||||
$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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function tableClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.member_name', $this->param('term'));
|
||||
$this->db->or_like('l.member_id', $this->param('term'));
|
||||
}
|
||||
// $this->db->where('l.member_status !=', 2);
|
||||
}
|
||||
|
||||
private function tableEditorClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.partner_name', $this->param('term'));
|
||||
$this->db->or_like('l.partner_id', $this->param('term'));
|
||||
}
|
||||
}
|
||||
|
||||
private function getTableRows()
|
||||
{
|
||||
$sort = $this->param('sort');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
$this->tableClause();
|
||||
$this->member_model->findAll()
|
||||
->order_by('l.' . $sortColumns['reg_date'], $this->param('order'))
|
||||
->limit($this->param('limit'))
|
||||
->offset($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0));
|
||||
$graces = $this->db->get()->result();
|
||||
return $graces;
|
||||
}
|
||||
|
||||
private function getTableEditorRows()
|
||||
{
|
||||
$sort = $this->param('sort');
|
||||
$sortColumns = array('comments' => 'comment_count', 'reg_date' => 'reg_date');
|
||||
|
||||
$this->tableEditorClause();
|
||||
$this->editor_model->findAll()
|
||||
->order_by('l.' . $sortColumns['reg_date'], $this->param('order'))
|
||||
->limit($this->param('limit'))
|
||||
->offset($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0));
|
||||
$graces = $this->db->get()->result();
|
||||
return $graces;
|
||||
}
|
||||
|
||||
private function getTableCount()
|
||||
{
|
||||
$this->tableClause();
|
||||
$this->member_model->findAll();
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
private function getTableEditorCount()
|
||||
{
|
||||
$this->tableEditorClause();
|
||||
$this->editor_model->findAll();
|
||||
return $this->db->count_all_results();
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
$graces = $this->getTableRows();
|
||||
$graceTotalCount = $this->getTableCount();
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
public function tableEditor()
|
||||
{
|
||||
$graces = $this->getTableEditorRows();
|
||||
$graceTotalCount = $this->getTableEditorCount();
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
public function reg()
|
||||
{
|
||||
if ($this->input->post('title')) {
|
||||
$categoryId = $this->input->post('category');
|
||||
$editorId = $this->input->post('editor');
|
||||
$title = str_replace('"', '\"', addslashes($this->input->post('title')));
|
||||
$mainImg = $this->input->post('main_img');
|
||||
$content = str_replace('"', '\"', addslashes($this->input->post('content')));
|
||||
$now = date('Y-m-d H:i:s');
|
||||
if (isset($_FILES['uploadfile']) && is_uploaded_file($_FILES['uploadfile']['tmp_name'])) {
|
||||
$upload = $this->post->upload('uploadfile');
|
||||
$this->load->library('awsfileuploader');
|
||||
$mainImg = $this->awsfileuploader->upload('uploads/' . explode('uploads/', $upload['full_path'])[1]);
|
||||
}
|
||||
if ($this->input->post('contentId')) {
|
||||
$sql = "UPDATE life
|
||||
SET
|
||||
is_display = 'N',
|
||||
category_idx = $categoryId,
|
||||
partner_idx = $editorId,
|
||||
title = '$title',
|
||||
main_img = '$mainImg',
|
||||
content = '$content',
|
||||
update_date = '$now'
|
||||
WHERE
|
||||
idx = " . $this->input->post('contentId');
|
||||
} else {
|
||||
$sql = "insert into
|
||||
life(is_display, category_idx, partner_idx, title, main_img, content, reg_date)
|
||||
values('N', $categoryId, $editorId,'$title', '$mainImg', '$content', '$now')";
|
||||
}
|
||||
if ($this->db->query($sql)) {
|
||||
header('location:' . $this->input->server('HTTP_REFERER'));
|
||||
} else {
|
||||
echo 'error' . $this->db->last_query();
|
||||
}
|
||||
} else if ($this->uri->segment(4)) {
|
||||
$contentId = $this->uri->segment(4);
|
||||
|
||||
$query = $this->db->query("SELECT
|
||||
`p`.`idx` `editorId`,
|
||||
`p`.`partner_img` `editorImg`,
|
||||
`p`.`main_img` `editorMainImg`,
|
||||
`p`.`partner_name` `editorName`,
|
||||
`p`.`partner_intro` `editorIntro`,
|
||||
`l`.`title`,
|
||||
`l`.`head_title`,
|
||||
`l`.`sub_title`,
|
||||
`l`.`content`,
|
||||
`l`.`category_idx` `categoryId`,
|
||||
`l`.`idx`,
|
||||
`l`.`main_img` `mainImg`,
|
||||
`l`.`hit_count` `views`,
|
||||
`l`.`like_count` `likes`,
|
||||
`l`.`comment_count` `comments`,
|
||||
`l`.*
|
||||
FROM
|
||||
`life` `l`
|
||||
LEFT JOIN
|
||||
`partner` `p` ON `l`.`partner_idx` = `p`.`idx`
|
||||
WHERE
|
||||
`l`.`idx` IN ($contentId)");
|
||||
|
||||
$post = $query->row();
|
||||
$data = array(
|
||||
'post' => $post,
|
||||
'lifeCategories' => $this->lifeCategories['result'],
|
||||
'graceEditors' => $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result(),
|
||||
);
|
||||
$this->load->view('adm/content_write', $data);
|
||||
} else {
|
||||
$data = array(
|
||||
'lifeCategories' => $this->lifeCategories['result'],
|
||||
'graceEditors' => $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result(),
|
||||
);
|
||||
$this->load->view('adm/content_write', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
go($this->input->server('HTTP_REFERER'), '삭제되었습니다.');
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->db->where('idx', $this->input->post('postid'))->update('life', array('is_display' => $this->input->post('is_display')));
|
||||
}
|
||||
|
||||
}
|
||||
235
application/controllers/adm/news.php
Executable file
235
application/controllers/adm/news.php
Executable file
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
|
||||
class News extends MY_Controller
|
||||
{
|
||||
|
||||
private $parentCategoryName = 'grace-category';
|
||||
|
||||
private $lifeCategories = array('ids' => array());
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('pagination');
|
||||
$this->load->library('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 = $this->input->get('page') ? $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);
|
||||
|
||||
if ($this->input->get('pageset')) {
|
||||
foreach ($table['rows'] as $k => $r) {
|
||||
$table['rows'][$k]->title = html_entity_decode(convertEmoji($table['rows'][$k]->title));
|
||||
$table['rows'][$k]->main_img = imgSrc($table['rows'][$k]->main_img);
|
||||
}
|
||||
$this->response($table);
|
||||
} else {
|
||||
$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/news', $data);
|
||||
}
|
||||
}
|
||||
|
||||
private function gettableRows()
|
||||
{
|
||||
$sql = "SELECT * FROM news where reg_date > '2019-12-01'";
|
||||
$sql .= $this->param('category') ? ' and category_code = '. $this->param('category') : '';
|
||||
$sql .= $this->param('term') ? ' and title like \'%'. $this->param('term'). '%\'' : '';
|
||||
$sql .= " order by reg_date desc limit " . ($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0)) . ", " . $this->param('limit');
|
||||
return $this->db->query($sql)->result();
|
||||
}
|
||||
|
||||
private function getTableCount()
|
||||
{
|
||||
$sql = "SELECT count(*) cnt FROM news where reg_date > '2019-12-01'";
|
||||
$sql .= $this->param('category') ? ' and category_code = '. $this->param('category') : '';
|
||||
$sql .= $this->param('term') ? ' and title like \'%'. $this->param('term'). '%\'' : '';
|
||||
|
||||
return $this->db->query($sql)->row()->cnt;
|
||||
}
|
||||
|
||||
public function table()
|
||||
{
|
||||
$graces = $this->getTableRows();
|
||||
$graceTotalCount = $this->getTableCount();
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
public function display()
|
||||
{
|
||||
$this->db->where('idx', $this->input->post('postid'))->update('news', array('is_display' => $this->input->post('is_display'), 'is_del' => 'N'));
|
||||
}
|
||||
|
||||
public function delete()
|
||||
{
|
||||
$this->db->where_in('idx', explode('-', $this->input->get('list')))->update('news', array('is_del' => 'Y', 'is_display' => 'N'));
|
||||
go($this->input->server('HTTP_REFERER'), '삭제되었습니다.');
|
||||
}
|
||||
|
||||
public function company()
|
||||
{
|
||||
$table = $this->tableCompany();
|
||||
$page = $this->input->get('page') ? $this->input->get('page') : 1;
|
||||
|
||||
$config['base_url'] = '/adm/' . strtolower(__CLASS__) . '/company';
|
||||
$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/newscompany', $data);
|
||||
}
|
||||
|
||||
private function getTableCompanyRows()
|
||||
{
|
||||
$sql = "SELECT * FROM press order by reg_date desc limit " . ($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0)) . ", " . $this->param('limit');
|
||||
return $this->db->query($sql)->result();
|
||||
}
|
||||
|
||||
private function gettableCompanyCount()
|
||||
{
|
||||
$sql = "SELECT count(*) cnt FROM press";
|
||||
return $this->db->query($sql)->row()->cnt;
|
||||
}
|
||||
|
||||
public function tableCompany()
|
||||
{
|
||||
$graces = $this->getTableCompanyRows();
|
||||
$graceTotalCount = $this->getTableCompanyCount();
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
/////////////////// category lsit /////////////////////
|
||||
|
||||
public function category()
|
||||
{
|
||||
$table = $this->tableCategory();
|
||||
// print_r($table['rows']);die;
|
||||
$page = $this->input->get('page') ? $this->input->get('page') : 1;
|
||||
|
||||
$config['base_url'] = '/adm/' . strtolower(__CLASS__) . '/category';
|
||||
$config['total_rows'] = $table['total'];
|
||||
$config['per_page'] = $this->param('limit');
|
||||
$this->pagination->initialize($config);
|
||||
|
||||
foreach ($table['rows'] as $k => $v) {
|
||||
$table['rows'][$k]->category_fullpath = array('<a href="/adm/news/categoryedit/' . $v->idx . '">' . $v->category_name . '</a>');
|
||||
foreach ($this->categoryall as $c) {
|
||||
if ($v->p_category_code == $c->category_code && $v->category_code != $c->category_code) {
|
||||
$table['rows'][$k]->category_fullpath[] = '<a href="/adm/news/categoryedit/' . $c->idx . '">' . $c->category_name . '</a>';
|
||||
}
|
||||
}
|
||||
$table['rows'][$k]->category_fullpath = implode(' > ', array_reverse($table['rows'][$k]->category_fullpath));
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'paging' => $this->pagination->create_links(),
|
||||
'table' => $table,
|
||||
'page' => $page,
|
||||
);
|
||||
|
||||
$this->load->view('adm/newscategory', $data);
|
||||
}
|
||||
|
||||
public function tableCategory()
|
||||
{
|
||||
$graces = $this->getTableCategoryRows();
|
||||
$graceTotalCount = $this->getTableCategoryCount();
|
||||
return array('total' => $graceTotalCount, 'rows' => $graces);
|
||||
}
|
||||
|
||||
private function getTableCategoryCount()
|
||||
{
|
||||
$this->tableCategoryClause();
|
||||
$this->db->from('news_section l');
|
||||
$cnt = $this->db->count_all_results();
|
||||
|
||||
$this->db->from('news_section l');
|
||||
$query = $this->db->where('l.is_del', 'N')->get();
|
||||
$this->categoryall = $query->result();
|
||||
return $cnt;
|
||||
}
|
||||
|
||||
private function tableCategoryClause()
|
||||
{
|
||||
if ($this->param('term')) {
|
||||
$this->db->like('l.category_name', $this->param('term'));
|
||||
}
|
||||
$this->db->where('l.is_del', 'N');
|
||||
}
|
||||
|
||||
private function getTableCategoryRows()
|
||||
{
|
||||
$this->tableCategoryClause();
|
||||
$this->db->from('news_section l')
|
||||
->order_by('l.category_code')
|
||||
->limit($this->param('limit'))
|
||||
->offset($this->param('limit') * ($this->param('page') ? $this->param('page') - 1 : 0));
|
||||
$graces = $this->db->get()->result();
|
||||
return $graces;
|
||||
}
|
||||
|
||||
public function categoryedit()
|
||||
{
|
||||
if ($this->input->post('idx')) {
|
||||
$data = array('p_category_code' => $this->input->post('parent'), 'category_code' => $this->input->post('parent').$this->input->post('idx'), 'category_name' => $this->input->post('category_name'));
|
||||
$this->db->where('idx', $this->input->post('idx'))->update('news_section', $data);
|
||||
go($this->input->post('redirect'), 'Success');
|
||||
} else if ($this->input->post('category_name')) {
|
||||
$data = array('p_category_code' => $this->input->post('parent'), 'category_name' => $this->input->post('category_name'));
|
||||
$this->db->insert('news_section', $data);
|
||||
$insertid = $this->db->insert_id();
|
||||
$data = array('category_code' => $this->input->post('parent').$insertid);
|
||||
$this->db->where('idx', $insertid)->update('news_section', $data);
|
||||
|
||||
go($this->input->post('redirect'), 'Success');
|
||||
} else {
|
||||
$category = null;
|
||||
if ($this->uri->segment(4)) {
|
||||
$category = $this->db->where('idx', $this->uri->segment(4))->get('news_section')->row();
|
||||
}
|
||||
|
||||
$data = array(
|
||||
'newsCategories' => $this->db->where('is_del', 'N')->where('idx !=', $category ? $category->idx : 0)->get('news_section')->result(),
|
||||
'category' => $category,
|
||||
);
|
||||
$this->load->view('adm/newscategoryedit', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function categorydelete()
|
||||
{
|
||||
if ($this->input->get('list')) {
|
||||
$this->db->where_in('idx', explode('-', $this->input->get('list')))->update('news_section', array('is_del' => 'Y'));
|
||||
go($this->input->server('HTTP_REFERER'), 'Success');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
198
application/controllers/adm/setcmtv.php
Executable file
198
application/controllers/adm/setcmtv.php
Executable file
@@ -0,0 +1,198 @@
|
||||
<?php
|
||||
|
||||
class Setcmtv extends MY_Controller
|
||||
{
|
||||
|
||||
private $parentCategoryName = 'grace-category';
|
||||
|
||||
private $lifeCategories = array('ids' => array());
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('pagination');
|
||||
$this->load->library('post');
|
||||
$this->load->model('category_model');
|
||||
$this->load->model('editor_model');
|
||||
$this->load->model('life_model');
|
||||
$this->lifeCategories['result'] = $this->category_model->findByParentId(36)->result();
|
||||
foreach ($this->lifeCategories['result'] as $c) {
|
||||
array_push($this->lifeCategories['ids'], $c->idx);
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
public function homehot()
|
||||
{
|
||||
$configType = 'cmtv';
|
||||
$configPage = 'cmtvhomehot';
|
||||
$this->load->model('config_model');
|
||||
if ($this->input->post('title')) {
|
||||
$this->db->where('Page', $configPage)->delete('cm_config');
|
||||
foreach ($this->input->post('title') as $k => $title) {
|
||||
$this->db->insert($this->config_model->table, array(
|
||||
'PostId' => $this->input->post('postid')[$k],
|
||||
'Type' => $configType,
|
||||
'Page' => $configPage,
|
||||
'OrderNum' => $this->input->post('display_sort')[$k],
|
||||
));
|
||||
}
|
||||
go($this->input->post('redirect'), 'Success');
|
||||
} else {
|
||||
|
||||
$config = $this->config_model->findByTypeAndPage($configType, $configPage)->order_by('OrderNum')->get()->result();
|
||||
$data = array($configPage => null, 'posts' => array(null));
|
||||
if ($config) {
|
||||
$postIds = array();
|
||||
foreach ($config as $c) {
|
||||
$postIds[] = $c->PostId;
|
||||
}
|
||||
$postIds = implode(',', $postIds);
|
||||
$query = $this->db->query("SELECT
|
||||
`l`.*
|
||||
FROM
|
||||
`life` `l`
|
||||
WHERE
|
||||
`l`.`idx` IN ($postIds)");
|
||||
|
||||
$post = $query->result();
|
||||
foreach ($post as $k => $p) {
|
||||
foreach ($config as $c) {
|
||||
if ($p->idx == $c->PostId) {
|
||||
$post[$k]->display_sort = $c->OrderNum;
|
||||
if (!$c->OrderNum) {
|
||||
$post[$k]->display_sort = $k + 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = array($configPage => $config, 'posts' => $post);
|
||||
}
|
||||
|
||||
$data['lifeCategories'] = $this->lifeCategories['result'];
|
||||
$data['graceEditors'] = $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result();
|
||||
|
||||
$this->load->view('adm/pageset/cmtv/homehot', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function categorylatest($categoryNo = 40)
|
||||
{
|
||||
$configType = 'cmtv';
|
||||
$configPage = 'categorylatest';
|
||||
$this->load->model('config_model');
|
||||
if ($this->input->post('title')) {
|
||||
$this->db->where('Page', $configPage)->where('CategoryId', $categoryNo)->delete('cm_config');
|
||||
foreach ($this->input->post('title') as $k => $title) {
|
||||
$this->db->insert($this->config_model->table, array(
|
||||
'PostId' => $this->input->post('postid')[$k],
|
||||
'Type' => $configType,
|
||||
'Page' => $configPage,
|
||||
'CategoryId' => $categoryNo,
|
||||
'OrderNum' => $this->input->post('display_sort')[$k],
|
||||
));
|
||||
}
|
||||
go($this->input->post('redirect'), 'Success');
|
||||
} else {
|
||||
|
||||
$config = $this->config_model->findByTypeAndPage($configType, $configPage)
|
||||
->where('CategoryId', $categoryNo)->order_by('OrderNum')->get()->result();
|
||||
$data = array($configPage => null, 'posts' => array(null));
|
||||
if ($config) {
|
||||
$postIds = array();
|
||||
foreach ($config as $c) {
|
||||
$postIds[] = $c->PostId;
|
||||
}
|
||||
$postIds = implode(',', $postIds);
|
||||
$query = $this->db->query("SELECT
|
||||
`l`.*
|
||||
FROM
|
||||
`life` `l`
|
||||
WHERE
|
||||
`l`.`idx` IN ($postIds)");
|
||||
|
||||
$post = $query->result();
|
||||
foreach ($post as $k => $p) {
|
||||
foreach ($config as $c) {
|
||||
if ($p->idx == $c->PostId) {
|
||||
$post[$k]->display_sort = $c->OrderNum;
|
||||
if (!$c->OrderNum) {
|
||||
$post[$k]->display_sort = $k + 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = array($configPage => $config, 'posts' => $post);
|
||||
}
|
||||
|
||||
$data['lifeCategories'] = $this->lifeCategories['result'];
|
||||
$data['categoryNo'] = $categoryNo;
|
||||
$data['graceEditors'] = $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result();
|
||||
|
||||
$this->load->view('adm/pageset/cmtv/categorylatest', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function channellatest($categoryNo = 80) {
|
||||
$configType = 'cmtv';
|
||||
$configPage = 'channellatest';
|
||||
$this->load->model('config_model');
|
||||
if ($this->input->post('title')) {
|
||||
$this->db->where('Page', $configPage)->where('CategoryId', $categoryNo)->delete('cm_config');
|
||||
foreach ($this->input->post('title') as $k => $title) {
|
||||
$this->db->insert($this->config_model->table, array(
|
||||
'PostId' => $this->input->post('postid')[$k],
|
||||
'Type' => $configType,
|
||||
'Page' => $configPage,
|
||||
'CategoryId' => $categoryNo,
|
||||
'OrderNum' => $this->input->post('display_sort')[$k],
|
||||
));
|
||||
}
|
||||
go($this->input->post('redirect'), 'Success');
|
||||
} else {
|
||||
|
||||
$config = $this->config_model->findByTypeAndPage($configType, $configPage)
|
||||
->where('CategoryId', $categoryNo)->order_by('OrderNum')->get()->result();
|
||||
$data = array($configPage => null, 'posts' => array(null));
|
||||
if ($config) {
|
||||
$postIds = array();
|
||||
foreach ($config as $c) {
|
||||
$postIds[] = $c->PostId;
|
||||
}
|
||||
$postIds = implode(',', $postIds);
|
||||
$query = $this->db->query("SELECT
|
||||
`l`.*
|
||||
FROM
|
||||
`life` `l`
|
||||
WHERE
|
||||
`l`.`idx` IN ($postIds)");
|
||||
|
||||
$post = $query->result();
|
||||
foreach ($post as $k => $p) {
|
||||
foreach ($config as $c) {
|
||||
if ($p->idx == $c->PostId) {
|
||||
$post[$k]->display_sort = $c->OrderNum;
|
||||
if (!$c->OrderNum) {
|
||||
$post[$k]->display_sort = $k + 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = array($configPage => $config, 'posts' => $post);
|
||||
}
|
||||
|
||||
$data['lifeCategories'] = $this->lifeCategories['result'];
|
||||
$data['categoryNo'] = $categoryNo;
|
||||
$data['graceEditors'] = $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result();
|
||||
|
||||
$this->load->view('adm/pageset/cmtv/channellatest', $data);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
104
application/controllers/adm/setgrace.php
Executable file
104
application/controllers/adm/setgrace.php
Executable file
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
class Setgrace extends MY_Controller
|
||||
{
|
||||
|
||||
private $parentCategoryName = 'grace-category';
|
||||
|
||||
private $lifeCategories = array('ids' => array());
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('pagination');
|
||||
$this->load->library('post');
|
||||
$this->load->model('category_model');
|
||||
$this->load->model('editor_model');
|
||||
$this->load->model('life_model');
|
||||
$this->lifeCategories['result'] = $this->category_model->findByParentId(35)->result();
|
||||
foreach ($this->lifeCategories['result'] as $c) {
|
||||
array_push($this->lifeCategories['ids'], $c->idx);
|
||||
}
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
}
|
||||
|
||||
public function hometop()
|
||||
{
|
||||
$configType = 'grace';
|
||||
$configPage = 'gracehometop';
|
||||
$this->load->model('config_model');
|
||||
if ($this->input->post('title')) {
|
||||
$this->db->where('Page', $configPage)->delete('cm_config');
|
||||
foreach ($this->input->post('title') as $k => $title) {
|
||||
$this->db->insert($this->config_model->table, array(
|
||||
'PostId' => $this->input->post('postid')[$k],
|
||||
'Type' => $configType,
|
||||
'Page' => $configPage,
|
||||
'OrderNum' => $this->input->post('display_sort')[$k]
|
||||
));
|
||||
}
|
||||
go($this->input->post('redirect'), 'Success');
|
||||
} else {
|
||||
|
||||
$config = $this->config_model->findByTypeAndPage($configType, $configPage)->order_by('OrderNum')->get()->result();
|
||||
$data = array($configPage => null, 'posts' => array(null));
|
||||
if ($config) {
|
||||
$postIds = array();
|
||||
foreach($config as $c) {
|
||||
$postIds[] = $c->PostId;
|
||||
}
|
||||
$postIds = implode(',', $postIds);
|
||||
$query = $this->db->query("SELECT
|
||||
`l`.*
|
||||
FROM
|
||||
`life` `l`
|
||||
WHERE
|
||||
`l`.`idx` IN ($postIds)");
|
||||
|
||||
$post = $query->result();
|
||||
foreach($post as $k => $p) {
|
||||
foreach($config as $c) {
|
||||
if($p->idx == $c->PostId) {
|
||||
$post[$k]->display_sort = $c->OrderNum;
|
||||
if(!$c->OrderNum) $post[$k]->display_sort = $k+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = array($configPage => $config, 'posts' => $post);
|
||||
}
|
||||
|
||||
$data['lifeCategories'] = $this->lifeCategories['result'];
|
||||
$data['graceEditors'] = $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result();
|
||||
|
||||
$this->load->view('adm/pageset/grace/hometop', $data);
|
||||
}
|
||||
}
|
||||
|
||||
public function homekeyword()
|
||||
{
|
||||
$configType = 'dailyqt';
|
||||
$configPage = 'home-dailyqt';
|
||||
$this->load->model('config_model');
|
||||
$config = $this->config_model->findByTypeAndPage($configType, $configPage)->order_by('OrderNum')->get()->row();
|
||||
$data = array('dailyqt' => null, 'post' => null);
|
||||
if($config) {
|
||||
$query = $this->db->query("SELECT
|
||||
`l`.*
|
||||
FROM
|
||||
`life` `l`
|
||||
WHERE
|
||||
`l`.`idx` IN ($config->PostId)");
|
||||
|
||||
$post = $query->row();
|
||||
$data = array('dailyqt' => $config, 'post' => $post);
|
||||
}
|
||||
|
||||
$data['lifeCategories'] = $this->lifeCategories['result'];
|
||||
$data['graceEditors'] = $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result();
|
||||
|
||||
$this->load->view('adm/pageset/grace/homekeyword', $data);
|
||||
}
|
||||
}
|
||||
163
application/controllers/adm/setmain.php
Executable file
163
application/controllers/adm/setmain.php
Executable file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
class Setmain extends MY_Controller
|
||||
{
|
||||
|
||||
private $parentCategoryName = 'grace-category';
|
||||
|
||||
private $lifeCategories = array('ids' => array());
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->library('pagination');
|
||||
$this->load->library('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()
|
||||
{
|
||||
}
|
||||
|
||||
public function homenews()
|
||||
{
|
||||
$configType = 'home';
|
||||
$configPage = 'hometopnews';
|
||||
$this->load->model('config_model');
|
||||
if ($this->input->post('title')) {
|
||||
$this->db->where('Page', $configPage)->delete('cm_config');
|
||||
foreach ($this->input->post('title') as $k => $title) {
|
||||
$this->db->insert($this->config_model->table, array(
|
||||
'PostId' => $this->input->post('postid')[$k],
|
||||
'Type' => $configType,
|
||||
'Page' => $configPage,
|
||||
'OrderNum' => $this->input->post('display_sort')[$k],
|
||||
));
|
||||
}
|
||||
go($this->input->post('redirect'), 'Success');
|
||||
} else {
|
||||
|
||||
$config = $this->config_model->findByTypeAndPage($configType, $configPage)->order_by('OrderNum')->get()->result();
|
||||
$data = array($configPage => null, 'posts' => array(null));
|
||||
if ($config) {
|
||||
$postIds = array();
|
||||
foreach ($config as $c) {
|
||||
$postIds[] = $c->PostId;
|
||||
}
|
||||
$postIds = implode(',', $postIds);
|
||||
$query = $this->db->query("SELECT
|
||||
`l`.*
|
||||
FROM
|
||||
`news` `l`
|
||||
WHERE
|
||||
`l`.`idx` IN ($postIds)");
|
||||
|
||||
$post = $query->result();
|
||||
foreach ($post as $k => $p) {
|
||||
foreach ($config as $c) {
|
||||
if ($p->idx == $c->PostId) {
|
||||
$post[$k]->display_sort = $c->OrderNum;
|
||||
if (!$c->OrderNum) {
|
||||
$post[$k]->display_sort = $k + 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
$data = array($configPage => $config, 'posts' => $post);
|
||||
}
|
||||
|
||||
$data['newsCategories'] = $this->db->where('is_del', 'N')->get('news_section')->result();
|
||||
|
||||
$this->load->view('adm/pageset/main/topnews', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function dailyqt()
|
||||
{
|
||||
$configType = 'home';
|
||||
$configPage = 'homedailyqt';
|
||||
$this->load->model('config_model');
|
||||
if ($this->input->post('title')) {
|
||||
$this->db->where('Page', $configPage)->delete('cm_config');
|
||||
foreach ($this->input->post('title') as $k => $title) {
|
||||
$this->db->insert($this->config_model->table, array(
|
||||
'PostId' => $this->input->post('postid')[$k],
|
||||
'Type' => $configType,
|
||||
'Page' => $configPage,
|
||||
'DpTime' => $this->input->post('dptime')[$k],
|
||||
));
|
||||
}
|
||||
go($this->input->post('redirect'), 'Success');
|
||||
} else {
|
||||
$config = $this->config_model->findByTypeAndPage($configType, $configPage)->order_by('OrderNum')->get()->row();
|
||||
$data = array('dailyqt' => null, 'posts' => array(null));
|
||||
if ($config) {
|
||||
$query = $this->db->query("SELECT
|
||||
`l`.*, c.DpTime
|
||||
FROM
|
||||
`life` `l` inner join cm_config c on l.idx = c.PostId
|
||||
WHERE c.Type='$configType' and c.Page='$configPage'");
|
||||
|
||||
$post = $query->result();
|
||||
$data = array('dailyqt' => $config, 'posts' => $post);
|
||||
}
|
||||
|
||||
$data['lifeCategories'] = $this->lifeCategories['result'];
|
||||
$data['graceEditors'] = $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result();
|
||||
|
||||
$this->load->view('adm/pageset/main/dailyqt', $data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function todayword()
|
||||
{
|
||||
$configType = 'home';
|
||||
$configPage = 'hometodayword';
|
||||
$this->load->model('config_model');
|
||||
if ($this->input->post('title')) {
|
||||
$this->db->where('Page', $configPage)->delete('cm_config');
|
||||
foreach ($this->input->post('title') as $k => $title) {
|
||||
$this->db->insert($this->config_model->table, array(
|
||||
'PostId' => 0,
|
||||
'Type' => $configType,
|
||||
'Page' => $configPage,
|
||||
'Title' => $this->input->post('title')[$k],
|
||||
'Headline' => $this->input->post('headline')[$k],
|
||||
'DpTime' => $this->input->post('dptime')[$k],
|
||||
));
|
||||
}
|
||||
go($this->input->post('redirect'), 'Success');
|
||||
} else {
|
||||
$config = $this->config_model->findByTypeAndPage($configType, $configPage)->order_by('OrderNum')->get()->result();
|
||||
$data = array('posts' => array(null));
|
||||
if ($config) {
|
||||
// $ccc = array();
|
||||
// foreach($config as $c) $ccc[] = $c->PostId;
|
||||
// $query = $this->db->query("SELECT
|
||||
// `l`.*
|
||||
// FROM
|
||||
// `life` `l`
|
||||
// WHERE
|
||||
// `l`.`idx` IN (".implode(',', $ccc).")");
|
||||
|
||||
// $post = $query->result();
|
||||
$data = array('posts' => $config);
|
||||
}
|
||||
|
||||
$data['lifeCategories'] = $this->lifeCategories['result'];
|
||||
$data['graceEditors'] = $this->editor_model->findByCategoryId($this->lifeCategories['ids'])->get()->result();
|
||||
|
||||
$this->load->view('adm/pageset/main/todayword', $data);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user