Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,22 +12,32 @@
|
||||
namespace IPS\gallery\api;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Api\PaginatedResponse;
|
||||
use IPS\Api\Response;
|
||||
use IPS\Db;
|
||||
use IPS\gallery\Category;
|
||||
use IPS\Node\Api\NodeController;
|
||||
use IPS\Request;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Gallery Categories API
|
||||
*/
|
||||
class _categories extends \IPS\Node\Api\NodeController
|
||||
class categories extends NodeController
|
||||
{
|
||||
|
||||
/**
|
||||
* Class
|
||||
*/
|
||||
protected $class = 'IPS\gallery\Category';
|
||||
protected string $class = 'IPS\gallery\Category';
|
||||
|
||||
/**
|
||||
* GET /gallery/categories
|
||||
@@ -37,33 +47,34 @@ class _categories extends \IPS\Node\Api\NodeController
|
||||
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
|
||||
* @apiparam int page Page number
|
||||
* @apiparam int perPage Number of results per page - defaults to 25
|
||||
* @return \IPS\Api\PaginatedResponse<IPS\blog\Entry>
|
||||
* @apireturn PaginatedResponse<IPS\gallery\Category>
|
||||
* @return PaginatedResponse<Category>
|
||||
*/
|
||||
public function GETindex()
|
||||
public function GETindex(): PaginatedResponse
|
||||
{
|
||||
/* Where clause */
|
||||
$where = array();
|
||||
|
||||
/* Sort */
|
||||
if ( isset( \IPS\Request::i()->sortBy ) and \in_array( \IPS\Request::i()->sortBy, array( 'count_imgs', 'last_img_date' ) ) )
|
||||
if ( isset( Request::i()->sortBy ) and in_array( Request::i()->sortBy, array( 'count_imgs', 'last_img_date' ) ) )
|
||||
{
|
||||
$sortBy = 'category_' . \IPS\Request::i()->sortBy;
|
||||
$sortBy = 'category_' . Request::i()->sortBy;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortBy = 'category_id';
|
||||
}
|
||||
$sortDir = ( isset( \IPS\Request::i()->sortDir ) and \in_array( mb_strtolower( \IPS\Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? \IPS\Request::i()->sortDir : 'asc';
|
||||
$sortDir = ( isset( Request::i()->sortDir ) and in_array( mb_strtolower( Request::i()->sortDir ), array( 'asc', 'desc' ) ) ) ? Request::i()->sortDir : 'asc';
|
||||
|
||||
/* Return */
|
||||
return new \IPS\Api\PaginatedResponse(
|
||||
return new PaginatedResponse(
|
||||
200,
|
||||
\IPS\Db::i()->select( '*', 'gallery_categories', $where, "{$sortBy} {$sortDir}" ),
|
||||
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
|
||||
Db::i()->select( '*', 'gallery_categories', $where, "{$sortBy} {$sortDir}" ),
|
||||
isset( Request::i()->page ) ? Request::i()->page : 1,
|
||||
'IPS\gallery\Category',
|
||||
\IPS\Db::i()->select( 'COUNT(*)', 'gallery_categories', $where )->first(),
|
||||
Db::i()->select( 'COUNT(*)', 'gallery_categories', $where )->first(),
|
||||
$this->member,
|
||||
isset( \IPS\Request::i()->perPage ) ? \IPS\Request::i()->perPage : NULL
|
||||
isset( Request::i()->perPage ) ? Request::i()->perPage : NULL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -72,9 +83,10 @@ class _categories extends \IPS\Node\Api\NodeController
|
||||
* Get information about a specific gallery category
|
||||
*
|
||||
* @param int $id ID Number
|
||||
* @return \IPS\blog\Blog
|
||||
* @apireturn \IPS\gallery\Category
|
||||
* @return Response
|
||||
*/
|
||||
public function GETitem( $id )
|
||||
public function GETitem( int $id ): Response
|
||||
{
|
||||
return $this->_view( $id );
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user