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,87 +12,98 @@
|
||||
namespace IPS\gallery\extensions\core\ContentRouter;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Application\Module;
|
||||
use IPS\Extensions\ContentRouterAbstract;
|
||||
use IPS\gallery\Album\Item;
|
||||
use IPS\gallery\Application;
|
||||
use IPS\gallery\Image;
|
||||
use IPS\gallery\Image\Table;
|
||||
use IPS\Helpers\Table\Content;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Group;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
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 Content Router extension: Gallery
|
||||
*/
|
||||
class _Gallery
|
||||
class Gallery extends ContentRouterAbstract
|
||||
{
|
||||
/**
|
||||
* @brief Content Item Classes
|
||||
*/
|
||||
public $classes = array();
|
||||
|
||||
/**
|
||||
* @brief Item Classes for embed only
|
||||
*/
|
||||
public $embeddableContent = array( 'IPS\gallery\Album\Item' );
|
||||
public array $embeddableContent = array( 'IPS\gallery\Album\Item' );
|
||||
|
||||
/**
|
||||
* @brief Can be shown in similar content
|
||||
*/
|
||||
public $similarContent = TRUE;
|
||||
|
||||
public bool $similarContent = TRUE;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Member|IPS\Member\Group|NULL $member If checking access, the member/group to check for, or NULL to not check access
|
||||
* @return void
|
||||
* @param Member|Group|null $member If checking access, the member/group to check for, or NULL to not check access
|
||||
*/
|
||||
public function __construct( $member = NULL )
|
||||
public function __construct( Member|Group $member = NULL )
|
||||
{
|
||||
if ( $member === NULL or $member->canAccessModule( \IPS\Application\Module::get( 'gallery', 'gallery', 'front' ) ) )
|
||||
if ( $member === NULL or $member->canAccessModule( Module::get( 'gallery', 'gallery', 'front' ) ) )
|
||||
{
|
||||
$this->classes[] = 'IPS\gallery\Image';
|
||||
$this->classes[] = 'IPS\gallery\Album\Item';
|
||||
$this->classes[] = Image::class;
|
||||
$this->classes[] = Item::class;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Owned Node Classes
|
||||
*/
|
||||
public $ownedNodes = array( 'IPS\gallery\Album' );
|
||||
public array $ownedNodes = array( 'IPS\gallery\Album' );
|
||||
|
||||
/**
|
||||
* Use a custom table helper when building content item tables
|
||||
*
|
||||
* @param string $className The content item class
|
||||
* @param \IPS\Http\Url $url The URL to use for the table
|
||||
* @param array $where Custom where clause to pass to the table helper
|
||||
* @return \IPS\Helpers\Table|void Custom table helper class to use
|
||||
* @param string $className The content item class
|
||||
* @param Url $url The URL to use for the table
|
||||
* @param array $where Custom where clause to pass to the table helper
|
||||
* @return Table|null Custom table helper class to use
|
||||
*/
|
||||
public function customTableHelper( $className, $url, $where=array() )
|
||||
public function customTableHelper( string $className, Url $url, array $where=array() ): ?Content
|
||||
{
|
||||
if( !\in_array( $className, $this->classes ) or $className == 'IPS\gallery\Album\Item' )
|
||||
if( !in_array( $className, $this->classes ) or $className == 'IPS\gallery\Album\Item' )
|
||||
{
|
||||
return new \IPS\Helpers\Table\Content( $className, $url, $where );
|
||||
return new Content( $className, $url, $where );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_browse.js', 'gallery' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_global.js', 'gallery' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js('front_browse.js', 'gallery' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js('front_global.js', 'gallery' ) );
|
||||
|
||||
\IPS\gallery\Application::outputCss();
|
||||
Application::outputCss();
|
||||
|
||||
$table = new \IPS\gallery\Image\Table( $className, $url, $where, NULL, FALSE );
|
||||
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'browse', 'gallery' ), 'imageTable' );
|
||||
$table = new Table( $className, $url, $where, NULL, FALSE );
|
||||
$table->tableTemplate = array( Theme::i()->getTemplate( 'browse', 'gallery' ), 'imageTable' );
|
||||
|
||||
/* Get rows template */
|
||||
if( isset( \IPS\Request::i()->cookie['thumbnailSize'] ) AND \IPS\Request::i()->cookie['thumbnailSize'] == 'large' AND \IPS\Request::i()->controller != 'search' )
|
||||
if( isset( Request::i()->cookie['thumbnailSize'] ) AND Request::i()->cookie['thumbnailSize'] == 'large' AND Request::i()->controller != 'search' )
|
||||
{
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'browse', 'gallery' ), 'tableRowsLarge' );
|
||||
$table->rowsTemplate = array( Theme::i()->getTemplate( 'browse', 'gallery' ), 'tableRowsLarge' );
|
||||
}
|
||||
else if( isset( \IPS\Request::i()->cookie['thumbnailSize'] ) AND \IPS\Request::i()->cookie['thumbnailSize'] == 'rows' AND \IPS\Request::i()->controller != 'search' )
|
||||
else if( isset( Request::i()->cookie['thumbnailSize'] ) AND Request::i()->cookie['thumbnailSize'] == 'rows' AND Request::i()->controller != 'search' )
|
||||
{
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'browse', 'gallery' ), 'tableRowsRows' );
|
||||
$table->rowsTemplate = array( Theme::i()->getTemplate( 'browse', 'gallery' ), 'tableRowsRows' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'browse', 'gallery' ), 'tableRowsThumbs' );
|
||||
$table->rowsTemplate = array( Theme::i()->getTemplate( 'browse', 'gallery' ), 'tableRowsThumbs' );
|
||||
}
|
||||
|
||||
return $table;
|
||||
|
||||
Reference in new issue
Block a user