Added browse forums and categories.

このコミットが含まれているのは:
テクニカル諏訪子 2018-04-09 19:40:35 +09:00
コミット aafedc66bb
2個のファイルの変更142行の追加5行の削除

ファイルの表示

@ -43,9 +43,10 @@ class BoardController extends Controller {
->get();
}
public function getForums() { // /api/rpc/board/forum/getforums
public function getForums($id) { // /api/rpc/board/forum/getforums/id
$get = DB::table('for_forums')
->select('id', 'last_uid', 'cat_id', 'title', 'description', 'threads', 'posts', 'last_date')
->where('cat_id', $id)
->orderBy('order', 'asc')
->get();
@ -455,7 +456,139 @@ class BoardController extends Controller {
]);
}
public function browseTopicInfo($tp, $id, $to) {
public function browseCategories() { // /api/rpc/board/browse/browsecategories
$cats = $this->getCategories()->toArray();
$cols = $this->objUser->getGroupColours()->toArray();
$res = array();
$resC = array();
foreach($cats as $c) {
$cid = $c->id;
$ctitle = $c->title;
$fors = $this->getForumsInCategory($cid);
$resF = array();
foreach($fors as $f) {
$user = $this->objUser->getUser($f['last_uid'])->toArray();
$showName = "";
$showCol = "";
if ($user[0]->display_name !== '') {
$showName = $user[0]->display_name;
}
else {
$showName = $user[0]->username;
}
if ($user[0]->name_style !== '') {
$showCol = $user[0]->name_style;
}
else {
foreach($cols as $cl) {
if ($cl->id === $user[0]->perm_id) {
if ($user[0]->gender === 1) $showCol = $cl->colour_m;
else if ($user[0]->gender === 2) $showCol = $cl->colour_f;
else $showCol = $cl->colour_u;
}
}
}
// Compile.
$resF[] = array(
'c_id' => $c->id,
'c_name' => $c->title,
'f_id' => $f['id'],
'u_name' => $showName,
'u_col' => $showCol,
'f_cat' => $f['cat_id'],
'f_last_uid' => $f['last_uid'],
'f_name' => $f['title'],
'f_desc' => $f['description'],
'f_topics' => $f['threads'],
'f_posts' => $f['posts'],
'f_last' => $f['last_date']
);
}
$res[] = array(
// $c->id => $resF,
// $c->title => $c->title
'cats' => array(
'id' => $c->id,
'name' => $c->title
),
'fors' => $resF
);
}
return $res;
}
public function browseForums($id, $from, $to) { // /api/rpc/board/browse/browseforums/id/from/to
// $fors = $this->getForum($id)->toArray();
$fors = $this->getForums($id);
$cols = $this->objUser->getGroupColours()->toArray();
$res = array();
foreach($fors as $f) {
$user = $this->objUser->getUser($f['last_uid'])->toArray();
$showName = "";
$showCol = "";
if ($user[0]->display_name !== '') {
$showName = $user[0]->display_name;
}
else {
$showName = $user[0]->username;
}
if ($user[0]->name_style !== '') {
$showCol = $user[0]->name_style;
}
else {
foreach($cols as $cl) {
if ($cl->id === $user[0]->perm_id) {
if ($user[0]->gender === 1) $showCol = $cl->colour_m;
else if ($user[0]->gender === 2) $showCol = $cl->colour_f;
else $showCol = $cl->colour_u;
}
}
}
$catname = $this->getCategoryName($id);
// Compile.
$res[] = array(
'f_id' => $f['id'],
'f_last_uid' => $f['last_uid'],
'f_cat' => $f['cat_id'],
'f_name' => $f['title'],
'f_desc' => $f['description'],
'f_topics' => $f['threads'],
'f_posts' => $f['posts'],
'f_last' => $f['last_date'],
'c_name' => $catname[0]->title,
'u_name' => $showName,
'u_col' => $showCol
);
}
return $res;
}
public function browseForumInfo($id, $to) { // /api/rpc/board/browse/browseforuminfo/id/to
}
public function browseTopics($id, $from, $to) { // /api/rpc/board/browse/browsetopics/id/from/to
}
public function browseTopicInfo($tp, $id, $to) { // /api/rpc/board/browse/browsetopicinfo/tp/id/to
if ($tp == 'p') {
// Get information for the navigation.
$tid = $this->getTopicIdFromPost($id);
@ -598,7 +731,7 @@ class BoardController extends Controller {
return $string;
}
public function browseTopicPosts($tp, $id, $from, $to) {
public function browseTopicPosts($tp, $id, $from, $to) { // /api/rpc/board/browse/browsetopicposts/tp/id/from/to
// Load group colours.
$ucol = $this->objUser->getGroupColours();
@ -677,7 +810,7 @@ class BoardController extends Controller {
return $udat;
}
public function browsePermissions($uid) {
public function browsePermissions($uid) { // /api/rpc/board/browse/browsepermissions/uid
// Get user ID.
$perm = $this->objUser->getUser($uid);

ファイルの表示

@ -16,7 +16,7 @@ Route::get('/api/rpc/board/category/getcategoryname/{id}', 'BoardController@getC
// Forum
Route::get('/api/rpc/board/forum/getforumsincategory/{cat_id}', 'BoardController@getForumsInCategory');
Route::get('/api/rpc/board/forum/getforums', 'BoardController@getForums');
Route::get('/api/rpc/board/forum/getforums/{id}', 'BoardController@getForums');
Route::get('/api/rpc/board/forum/getforum/{id}', 'BoardController@getForum');
Route::get('/api/rpc/board/forum/getforumname/{id}', 'BoardController@getForumName');
Route::get('/api/rpc/board/forum/getpostcountfreeze/{id}', 'BoardController@getPostCountFreeze');
@ -53,6 +53,10 @@ Route::post('/api/rpc/board/post/deletepost', 'BoardController@deletePost');
Route::post('/api/rpc/board/post/undeletepost', 'BoardController@undeletePost');
// Compiled routes.
Route::get('/api/rpc/board/browse/browsecategories', 'BoardController@browseCategories');
Route::get('/api/rpc/board/browse/browseforums/{id}/{from}/{to}', 'BoardController@browseForums');
Route::get('/api/rpc/board/browse/browseforuminfo/{id}/{to}', 'BoardController@browseForumInfo');
Route::get('/api/rpc/board/browse/browsetopics/{id}/{from}/{to}', 'BoardController@browseTopics');
Route::get('/api/rpc/board/browse/browsetopicinfo/{tp}/{id}/{to}', 'BoardController@browseTopicInfo');
Route::get('/api/rpc/board/browse/browsetopicposts/{tp}/{id}/{from}/{to}', 'BoardController@browseTopicPosts');
Route::get('/api/rpc/board/browse/browsepermissions/{uid}', 'BoardController@browsePermissions');