2018-03-13 22:28:14 +09:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use Illuminate\Support\Facades\DB;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Contracts\Routing\ResponseFactory;
|
|
|
|
use Illuminate\Support\Facades\Log;
|
|
|
|
|
|
|
|
use App\Http\Controllers\AuthController;
|
|
|
|
use App\Http\Controllers\UserController;
|
|
|
|
use App\Http\Controllers\PermissionController;
|
|
|
|
|
|
|
|
class SiteController extends Controller {
|
|
|
|
private $objAuth;
|
|
|
|
private $objUser;
|
|
|
|
private $objPermission;
|
|
|
|
|
|
|
|
public function __contruct() {
|
|
|
|
$this->objAuth = new AuthController();
|
|
|
|
$this->objUser = new UserController();
|
|
|
|
$this->objPermission = new PermissionController();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPosts() { // /api/rpc/site/post/getposts
|
|
|
|
$get = DB::table('blg_content')
|
|
|
|
->select('id', 'user_id', 'title', 'slug', 'post_date', 'publish_date', 'message')
|
|
|
|
->where('public_status', 1)
|
|
|
|
->where('isPost', 1)
|
|
|
|
->orderBy('publish_date', 'desc')
|
|
|
|
->get();
|
|
|
|
|
|
|
|
$res = array();
|
|
|
|
$key = 0;
|
|
|
|
|
|
|
|
setlocale(LC_ALL, 'ja_JP.utf8');
|
|
|
|
|
|
|
|
foreach ($get as $i) {
|
|
|
|
array_push($res, [
|
|
|
|
'key' => $key,
|
|
|
|
'id' => $i->id,
|
|
|
|
'user_id' => $i->user_id,
|
|
|
|
'title' => $i->title,
|
|
|
|
'slug' => $i->slug,
|
|
|
|
'post_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->post_date),
|
|
|
|
'publish_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->publish_date),
|
|
|
|
'message' => $i->message
|
|
|
|
]);
|
|
|
|
$key++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPost($slug) { // /api/rpc/site/post/getpost/slug
|
|
|
|
$get = DB::table('blg_content')
|
|
|
|
->select('id', 'user_id', 'title', 'slug', 'post_date', 'publish_date', 'message')
|
|
|
|
->where('public_status', 1)
|
|
|
|
->where('isPost', 1)
|
|
|
|
->where('slug', $slug)
|
|
|
|
->orderBy('publish_date', 'desc')
|
|
|
|
->get();
|
|
|
|
|
|
|
|
$res = array();
|
|
|
|
|
|
|
|
setlocale(LC_ALL, 'ja_JP.utf8');
|
|
|
|
|
|
|
|
foreach ($get as $i) {
|
|
|
|
array_push($res, [
|
|
|
|
'id' => $i->id,
|
|
|
|
'user_id' => $i->user_id,
|
|
|
|
'title' => $i->title,
|
|
|
|
'slug' => $i->slug,
|
|
|
|
'post_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->post_date),
|
|
|
|
'publish_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->publish_date),
|
|
|
|
'message' => $i->message
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPages() { // /api/rpc/site/page/getpages
|
|
|
|
$get = DB::table('blg_content')
|
|
|
|
->select('id', 'user_id', 'title', 'slug', 'message')
|
|
|
|
->where('public_status', 1)
|
|
|
|
->where('isPost', 0)
|
|
|
|
->orderBy('sortorder', 'asc')
|
|
|
|
->get();
|
|
|
|
|
|
|
|
$res = array();
|
|
|
|
$key = 0;
|
|
|
|
|
|
|
|
foreach ($get as $i) {
|
|
|
|
array_push($res, [
|
|
|
|
'key' => $key,
|
|
|
|
'id' => $i->id,
|
|
|
|
'user_id' => $i->user_id,
|
|
|
|
'title' => $i->title,
|
|
|
|
'slug' => $i->slug,
|
|
|
|
'message' => $i->message
|
|
|
|
]);
|
|
|
|
$key++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPage($slug) { // /api/rpc/site/page/getpage/slug
|
|
|
|
$get = DB::table('blg_content')
|
|
|
|
->select('id', 'user_id', 'title', 'slug', 'message')
|
|
|
|
->where('public_status', 1)
|
|
|
|
->where('isPost', 0)
|
|
|
|
->where('slug', $slug)
|
|
|
|
->orderBy('sortorder', 'asc')
|
|
|
|
->get();
|
|
|
|
|
|
|
|
$res = array();
|
|
|
|
|
|
|
|
foreach ($get as $i) {
|
|
|
|
array_push($res, [
|
|
|
|
'id' => $i->id,
|
|
|
|
'user_id' => $i->user_id,
|
|
|
|
'title' => $i->title,
|
|
|
|
'slug' => $i->slug,
|
|
|
|
'message' => $i->message
|
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getComments($id) { // /api/rpc/site/post/getcomments/id
|
|
|
|
$get = DB::table('blg_comments')
|
|
|
|
->select('id', 'user_id', 'content_id', 'votes', 'post_date', 'last_date', 'isDeleted', 'message', 'ip_address')
|
|
|
|
->where('content_id', $id)
|
|
|
|
->orderBy('post_date', 'asc')
|
|
|
|
->get();
|
|
|
|
|
|
|
|
$res = array();
|
|
|
|
$key = 0;
|
|
|
|
|
|
|
|
foreach ($get as $i) {
|
|
|
|
array_push($res, [
|
|
|
|
'key' => $key,
|
|
|
|
'id' => $i->id,
|
|
|
|
'user_id' => $i->user_id,
|
|
|
|
'content_id' => $i->content_id,
|
|
|
|
'votes' => $i->votes,
|
|
|
|
'post_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->post_date),
|
|
|
|
'last_date' => strftime('%Y/%m/%d(%a) %H:%M:%S %Z', $i->last_date),
|
|
|
|
'isDeleted' => $i->isDeleted,
|
|
|
|
'message' => $i->message,
|
|
|
|
'ip_address' => $i->ip_address
|
|
|
|
]);
|
|
|
|
$key++;
|
|
|
|
}
|
|
|
|
|
|
|
|
return $res;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getSettings() { // /api/rpc/site/admin/getsettings
|
|
|
|
return DB::table('blg_settings')
|
|
|
|
->select('sitename', 'description', 'tags', 'blog_status', 'announcement', 'theme', 'locale')
|
|
|
|
->get();
|
|
|
|
}
|
2018-03-13 22:51:42 +09:00
|
|
|
|
|
|
|
public function getContactFields() { // /api/rpc/site/page/getcontactfields
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPortfolioCategories() { // /api/rpc/site/page/getportfoliocategories
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPortfolioCategory($id) { // /api/rpc/site/page/getportfoliocategory/id
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getPortfolioItems($cat_id) { // /api/rpc/site/page/getportfolioitems/cat_id
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function newPost(Request $request) { // /api/rpc/site/post/newpost
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function editPost(Request $request) { // /api/rpc/site/post/editpost
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function removePost(Request $request) { // /api/rpc/site/post/removepost
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deletePost(Request $request) { // /api/rpc/site/post/deletepost
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function newPage(Request $request) { // /api/rpc/site/page/newpage
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function editPage(Request $request) { // /api/rpc/site/page/editpage
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function removePage(Request $request) { // /api/rpc/site/page/removepage
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function deletePage(Request $request) { // /api/rpc/site/page/deletepage
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setSettings(Request $request) { // /api/rpc/site/admin/setsettings
|
|
|
|
return false;
|
|
|
|
}
|
2018-03-13 22:28:14 +09:00
|
|
|
}
|