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,35 +12,44 @@
|
||||
namespace IPS\blog\extensions\core\LiveSearch;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\blog\Blog;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Extensions\LiveSearchAbstract;
|
||||
use IPS\Member;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
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 ACP Live Search Extension
|
||||
*/
|
||||
class _Blogs
|
||||
class Blogs extends LiveSearchAbstract
|
||||
{
|
||||
/**
|
||||
* Check we have access
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasAccess()
|
||||
public function hasAccess(): bool
|
||||
{
|
||||
/* Check Permissions */
|
||||
return \IPS\Member::loggedIn()->hasAcpRestriction( 'blog', 'blog', 'blogs_manage' );
|
||||
return Member::loggedIn()->hasAcpRestriction( 'blog', 'blog', 'blogs_manage' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the search results
|
||||
*
|
||||
* @param string $searchTerm Search Term
|
||||
* @param string $searchTerm Search Term
|
||||
* @return array Array of results
|
||||
*/
|
||||
public function getResults( $searchTerm )
|
||||
public function getResults( string $searchTerm ): array
|
||||
{
|
||||
/* Init */
|
||||
$results = array();
|
||||
@@ -50,10 +59,10 @@ class _Blogs
|
||||
if( $this->hasAccess() )
|
||||
{
|
||||
/* Perform the search */
|
||||
$blogs = \IPS\Db::i()->select(
|
||||
$blogs = Db::i()->select(
|
||||
"*",
|
||||
'blog_blogs',
|
||||
array( "blog_club_id IS NULL AND ( word_custom LIKE CONCAT( '%', ?, '%' ) AND lang_id=? )", $searchTerm, \IPS\Member::loggedIn()->language()->id ),
|
||||
array( "blog_club_id IS NULL AND ( word_custom LIKE CONCAT( '%', ?, '%' ) AND lang_id=? )", $searchTerm, Member::loggedIn()->language()->id ),
|
||||
NULL,
|
||||
array( 0, 500 )
|
||||
)->join(
|
||||
@@ -64,9 +73,9 @@ class _Blogs
|
||||
/* Format results */
|
||||
foreach ( $blogs as $blog )
|
||||
{
|
||||
$blog = \IPS\blog\Blog::constructFromData( $blog );
|
||||
$blog = Blog::constructFromData( $blog );
|
||||
|
||||
$results[] = \IPS\Theme::i()->getTemplate( 'livesearch', 'blog', 'admin' )->blog( $blog );
|
||||
$results[] = Theme::i()->getTemplate( 'livesearch', 'blog', 'admin' )->blog( $blog );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,8 +87,8 @@ class _Blogs
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function isDefault()
|
||||
public function isDefault(): bool
|
||||
{
|
||||
return \IPS\Dispatcher::i()->application->directory == 'blog';
|
||||
return Dispatcher::i()->application->directory == 'blog';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user