Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -23,16 +23,95 @@ class _Application extends \IPS\Application
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
/* If the viewing member cannot view the board (ex: guests must login first), then send a 404 Not Found header here, before the Login page shows in the dispatcher */
|
||||
if ( \IPS\Dispatcher::hasInstance() AND \IPS\Dispatcher::i()->controllerLocation === 'front')
|
||||
/* Handle RSS requests */
|
||||
if ( \IPS\Request::i()->module == 'gallery' and \IPS\Request::i()->controller == 'browse' and \IPS\Request::i()->do == 'rss' )
|
||||
{
|
||||
if ( !\IPS\Member::loggedIn()->group['g_view_board'] and ( \IPS\Request::i()->module == 'gallery' and \IPS\Request::i()->controller == 'browse' and \IPS\Request::i()->do == 'rss' )
|
||||
or ( \IPS\Member::loggedIn()->members_bitoptions['remove_gallery_access'] )
|
||||
)
|
||||
$member = NULL;
|
||||
if( \IPS\Request::i()->member AND \IPS\Request::i()->key )
|
||||
{
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->member );
|
||||
if( !\IPS\Login::compareHashes( md5( ( $member->members_pass_hash ?: $member->email ) . $member->members_pass_salt ), (string) \IPS\Request::i()->key ) )
|
||||
{
|
||||
$member = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sendGalleryRss( $member ?? new \IPS\Member );
|
||||
|
||||
if( !\IPS\Member::loggedIn()->group['g_view_board'] )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G218/1', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
if( \IPS\Member::loggedIn()->members_bitoptions['remove_gallery_access'] )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G218/1', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send the gallery RSS feed for the indicated member
|
||||
*
|
||||
* @param \IPS\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 )
|
||||
{
|
||||
if( !\IPS\Settings::i()->gallery_rss_enabled )
|
||||
{
|
||||
\IPS\Output::i()->error( 'gallery_rss_offline', '2G189/3', 403, 'gallery_rss_offline_admin' );
|
||||
}
|
||||
|
||||
$where = array();
|
||||
|
||||
if( isset( \IPS\Request::i()->category ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$category = \IPS\gallery\Category::load( \IPS\Request::i()->category );
|
||||
|
||||
if( !$category->can( 'read', $member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
$where[] = array( 'image_category_id=?', $category->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G189/8', 404, '' );
|
||||
}
|
||||
}
|
||||
else if ( isset( \IPS\Request::i()->album ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$album = \IPS\gallery\Album::load( \IPS\Request::i()->album );
|
||||
|
||||
if( !$album->can( 'read', $member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
}
|
||||
|
||||
$where[] = array( 'image_album_id=?', $album->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\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') );
|
||||
|
||||
foreach ( \IPS\gallery\Image::getItemsWithPermission( $where, NULL, 10, 'read', \IPS\Content\Hideable::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 );
|
||||
}
|
||||
|
||||
/* @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 );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +218,7 @@ class _Application extends \IPS\Application
|
||||
*/
|
||||
public static function outputCss()
|
||||
{
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'gallery.css', 'gallery' ) );
|
||||
\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' ) );
|
||||
@@ -156,4 +235,17 @@ class _Application extends \IPS\Application
|
||||
/* Apps can overload this */
|
||||
return array( 'gallery_watermark_path' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of specific links to add to the sitemap
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function sitemapLinks()
|
||||
{
|
||||
return array(
|
||||
\IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse&do=categories', 'front', 'gallery_categories' ),
|
||||
\IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse', 'front', 'gallery' ),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user