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
@@ -11,116 +11,131 @@
|
||||
|
||||
namespace IPS\gallery;
|
||||
|
||||
use Exception;
|
||||
use IPS\Application as SystemApplication;
|
||||
use IPS\Content\Filter;
|
||||
use IPS\DateTime;
|
||||
use IPS\File;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Login;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use IPS\Xml\Rss;
|
||||
use OutOfRangeException;
|
||||
|
||||
/**
|
||||
* Gallery Application Class
|
||||
*/
|
||||
class _Application extends \IPS\Application
|
||||
class Application extends SystemApplication
|
||||
{
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
public function init(): void
|
||||
{
|
||||
/* Handle RSS requests */
|
||||
if ( \IPS\Request::i()->module == 'gallery' and \IPS\Request::i()->controller == 'browse' and \IPS\Request::i()->do == 'rss' )
|
||||
if ( Request::i()->module == 'gallery' and Request::i()->controller == 'browse' and Request::i()->do == 'rss' )
|
||||
{
|
||||
$member = NULL;
|
||||
if( \IPS\Request::i()->member AND \IPS\Request::i()->key )
|
||||
if( Request::i()->member AND Request::i()->key )
|
||||
{
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->member );
|
||||
if( !\IPS\Login::compareHashes( $member->getUniqueMemberHash(), (string) \IPS\Request::i()->key ) )
|
||||
$member = Member::load( Request::i()->member );
|
||||
if( !Login::compareHashes( $member->getUniqueMemberHash(), (string) Request::i()->key ) )
|
||||
{
|
||||
$member = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sendGalleryRss( $member ?? new \IPS\Member );
|
||||
$this->sendGalleryRss( $member ?? new Member );
|
||||
|
||||
if( !\IPS\Member::loggedIn()->group['g_view_board'] )
|
||||
if( !Member::loggedIn()->group['g_view_board'] )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G218/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2G218/1', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
if( \IPS\Member::loggedIn()->members_bitoptions['remove_gallery_access'] )
|
||||
if( Member::loggedIn()->members_bitoptions['remove_gallery_access'] )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G218/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2G218/1', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the gallery RSS feed for the indicated member
|
||||
*
|
||||
* @param \IPS\Member $member Member
|
||||
* @param Member $member Member
|
||||
* @return void
|
||||
* @note We use a template so that we can embed image directly into feed while still allowing it to be customized
|
||||
*/
|
||||
protected function sendGalleryRss( $member )
|
||||
protected function sendGalleryRss( Member $member ) : void
|
||||
{
|
||||
if( !\IPS\Settings::i()->gallery_rss_enabled )
|
||||
if( !Settings::i()->gallery_rss_enabled )
|
||||
{
|
||||
\IPS\Output::i()->error( 'gallery_rss_offline', '2G189/3', 403, 'gallery_rss_offline_admin' );
|
||||
Output::i()->error( 'gallery_rss_offline', '2G189/3', 403, 'gallery_rss_offline_admin' );
|
||||
}
|
||||
|
||||
$where = array();
|
||||
|
||||
if( isset( \IPS\Request::i()->category ) )
|
||||
if( isset( Request::i()->category ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$category = \IPS\gallery\Category::load( \IPS\Request::i()->category );
|
||||
$category = Category::load( Request::i()->category );
|
||||
|
||||
if( !$category->can( 'read', $member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
$where[] = array( 'image_category_id=?', $category->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G189/8', 404, '' );
|
||||
Output::i()->error( 'node_error', '2G189/8', 404, '' );
|
||||
}
|
||||
}
|
||||
else if ( isset( \IPS\Request::i()->album ) )
|
||||
else if ( isset( Request::i()->album ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$album = \IPS\gallery\Album::load( \IPS\Request::i()->album );
|
||||
$album = Album::load( Request::i()->album );
|
||||
|
||||
if( !$album->can( 'read', $member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
$where[] = array( 'image_album_id=?', $album->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G189/9', 404, '' );
|
||||
Output::i()->error( 'node_error', '2G189/9', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
$document = \IPS\Xml\Rss::newDocument( isset( $category ) ? $category->url() : ( isset( $album ) ? $album->url() : \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse', 'front', 'gallery' ) ), $member->language()->get('gallery_rss_title'), $member->language()->get('gallery_rss_title') );
|
||||
$document = Rss::newDocument( isset( $category ) ? $category->url() : ( isset( $album ) ? $album->url() : Url::internal( 'app=gallery&module=gallery&controller=browse', 'front', 'gallery' ) ), $member->language()->get('gallery_rss_title'), $member->language()->get('gallery_rss_title') );
|
||||
|
||||
foreach ( \IPS\gallery\Image::getItemsWithPermission( $where, NULL, 10, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, $member ) as $image )
|
||||
foreach (Image::getItemsWithPermission( $where, NULL, 10, 'read', Filter::FILTER_AUTOMATIC, 0, $member ) as $image )
|
||||
{
|
||||
$document->addItem( $image->caption, $image->url(), \IPS\Theme::i()->getTemplate( 'view' )->rssContent( $image ), \IPS\DateTime::ts( $image->updated ), $image->id );
|
||||
$document->addItem( $image->caption, $image->url(), Theme::i()->getTemplate( 'view' )->rssContent( $image ), DateTime::ts( $image->updated ), $image->id );
|
||||
}
|
||||
|
||||
/* @note application/rss+xml is not a registered IANA mime-type so we need to stick with text/xml for RSS */
|
||||
\IPS\Output::i()->sendOutput( $document->asXML(), 200, 'text/xml', array(), TRUE );
|
||||
Output::i()->sendOutput( $document->asXML(), 200, 'text/xml', array(), TRUE );
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get Icon for tree
|
||||
*
|
||||
* @note Return the class for the icon (e.g. 'globe')
|
||||
* @return string|null
|
||||
* @note Return the class for the icon (e.g. 'globe')
|
||||
* @return string
|
||||
*/
|
||||
protected function get__icon()
|
||||
protected function get__icon(): string
|
||||
{
|
||||
return 'camera';
|
||||
}
|
||||
@@ -148,7 +163,7 @@ class _Application extends \IPS\Application
|
||||
* @endcode
|
||||
* @return array
|
||||
*/
|
||||
public function defaultFrontNavigation()
|
||||
public function defaultFrontNavigation(): array
|
||||
{
|
||||
return array(
|
||||
'rootTabs' => array(),
|
||||
@@ -163,50 +178,50 @@ class _Application extends \IPS\Application
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function convertLegacyParameters()
|
||||
public function convertLegacyParameters() : void
|
||||
{
|
||||
/* convert ?module=images§ion=img_ctrl&img=100&file=medium */
|
||||
/* convert ?module=images§ion=img_ctrl&id=100&file=medium */
|
||||
if( isset( \IPS\Request::i()->section ) AND \IPS\Request::i()->section == 'img_ctrl' )
|
||||
if( isset( Request::i()->section ) AND Request::i()->section == 'img_ctrl' )
|
||||
{
|
||||
$id = ( isset( \IPS\Request::i()->img ) ) ? \IPS\Request::i()->img : \IPS\Request::i()->id;
|
||||
$id = ( isset( Request::i()->img ) ) ? Request::i()->img : Request::i()->id;
|
||||
|
||||
if( $id )
|
||||
{
|
||||
if( \IPS\Request::i()->file == 'med' )
|
||||
if( Request::i()->file == 'med' )
|
||||
{
|
||||
\IPS\Request::i()->file = 'medium';
|
||||
Request::i()->file = 'medium';
|
||||
}
|
||||
|
||||
$imageSize = ( ( \IPS\Request::i()->file == 'small' ) ? 'small' : 'masked' ) . '_file_name';
|
||||
$imageSize = ( ( Request::i()->file == 'small' ) ? 'small' : 'masked' ) . '_file_name';
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Output::i()->redirect( (string) \IPS\File::get( 'gallery_Images', \IPS\gallery\Image::load( $id )->$imageSize )->url );
|
||||
Output::i()->redirect( (string) File::get( 'gallery_Images', Image::load( $id )->$imageSize )->url );
|
||||
}
|
||||
catch ( \Exception $e ){}
|
||||
catch ( Exception ){}
|
||||
}
|
||||
}
|
||||
|
||||
/* convert ?app=gallery&module=images§ion=viewimage&img=14586 */
|
||||
if( isset( \IPS\Request::i()->section ) AND \IPS\Request::i()->section == 'viewimage' )
|
||||
if( isset( Request::i()->section ) AND Request::i()->section == 'viewimage' )
|
||||
{
|
||||
$id = ( isset( \IPS\Request::i()->img ) ) ? \IPS\Request::i()->img : \IPS\Request::i()->id;
|
||||
$id = ( isset( Request::i()->img ) ) ? Request::i()->img : Request::i()->id;
|
||||
|
||||
if( $id )
|
||||
{
|
||||
if( \IPS\Request::i()->file == 'med' )
|
||||
if( Request::i()->file == 'med' )
|
||||
{
|
||||
\IPS\Request::i()->file = 'medium';
|
||||
Request::i()->file = 'medium';
|
||||
}
|
||||
|
||||
$imageSize = ( ( \IPS\Request::i()->file == 'small' ) ? 'small' : 'masked' ) . '_file_name';
|
||||
$imageSize = ( ( Request::i()->file == 'small' ) ? 'small' : 'masked' ) . '_file_name';
|
||||
|
||||
try
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\gallery\Image::load( $id )->url() );
|
||||
Output::i()->redirect( Image::load( $id )->url() );
|
||||
}
|
||||
catch ( \Exception $e ){}
|
||||
catch ( Exception ){}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -216,13 +231,9 @@ class _Application extends \IPS\Application
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function outputCss()
|
||||
public static function outputCss() : void
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'gallery.css', 'gallery' ), \IPS\Theme::i()->css( 'global.css', 'gallery' ) );
|
||||
if ( \IPS\Theme::i()->settings['responsive'] )
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'gallery_responsive.css', 'gallery', 'front' ) );
|
||||
}
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'gallery.css', 'gallery' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -230,7 +241,7 @@ class _Application extends \IPS\Application
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function uploadSettings()
|
||||
public function uploadSettings(): array
|
||||
{
|
||||
/* Apps can overload this */
|
||||
return array( 'gallery_watermark_path' );
|
||||
@@ -244,7 +255,7 @@ class _Application extends \IPS\Application
|
||||
public function getWebhooks() : array
|
||||
{
|
||||
return array_merge( [
|
||||
'galleryAlbum_create' => \IPS\gallery\Album::class
|
||||
'galleryAlbum_create' => Album::class
|
||||
],parent::getWebhooks());
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user