Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

@@ -43,16 +43,16 @@ class _settings extends \IPS\Dispatcher\Controller
{
$form = new \IPS\Helpers\Form;
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_settings.js', 'gallery', 'admin' ) );
$form->attributes['data-controller'] = 'gallery.admin.settings.settings';
$form->hiddenValues['rebuildWatermarkScreenshots'] = \IPS\Request::i()->rebuildWatermarkScreenshots ?: 0;
$form->addHeader( 'gallery_images' );
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack('gallery_dims_explanation'), '', FALSE );
$large = ( isset( \IPS\Settings::i()->gallery_large_dims ) ) ? explode( 'x', \IPS\Settings::i()->gallery_large_dims ) : array( 1600, 1200 );
$medium = ( isset( \IPS\Settings::i()->gallery_medium_dims ) ) ? explode( 'x', \IPS\Settings::i()->gallery_medium_dims ) : array( 640, 480 );
$small = ( isset( \IPS\Settings::i()->gallery_small_dims ) ) ? explode( 'x', \IPS\Settings::i()->gallery_small_dims ) : array( 240, 240 );
$thumb = ( isset( \IPS\Settings::i()->gallery_thumb_dims ) ) ? explode( 'x', \IPS\Settings::i()->gallery_thumb_dims ) : array( 100, 100 );
$form->add( new \IPS\Helpers\Form\WidthHeight( 'gallery_large_dims', $large, TRUE, array( 'resizableDiv' => FALSE ) ) );
$form->add( new \IPS\Helpers\Form\WidthHeight( 'gallery_medium_dims', $medium, TRUE, array( 'resizableDiv' => FALSE ) ) );
$form->add( new \IPS\Helpers\Form\WidthHeight( 'gallery_small_dims', $small, TRUE, array( 'resizableDiv' => FALSE ) ) );
$form->add( new \IPS\Helpers\Form\WidthHeight( 'gallery_thumb_dims', $thumb, TRUE, array( 'resizableDiv' => FALSE ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_use_square_thumbnails', \IPS\Settings::i()->gallery_use_square_thumbnails ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_use_watermarks', \IPS\Settings::i()->gallery_use_watermarks, FALSE, array( 'togglesOn' => array( 'gallery_watermark_path', 'gallery_watermark_images' ) ) ) );
$form->add( new \IPS\Helpers\Form\Upload( 'gallery_watermark_path', \IPS\Settings::i()->gallery_watermark_path ? \IPS\File::get( 'core_Theme', \IPS\Settings::i()->gallery_watermark_path ) : NULL, FALSE, array( 'image' => TRUE, 'storageExtension' => 'core_Theme' ), NULL, NULL, NULL, 'gallery_watermark_path' ) );
@@ -61,7 +61,7 @@ class _settings extends \IPS\Dispatcher\Controller
FALSE,
array(
'multiple' => TRUE,
'options' => array( 'large' => 'gallery_watermark_large', 'medium' => 'gallery_watermark_medium', 'small' => 'gallery_watermark_small', 'thumbnail' => 'gallery_watermark_thumb' ),
'options' => array( 'large' => 'gallery_watermark_large', 'small' => 'gallery_watermark_small' ),
),
NULL,
NULL,
@@ -80,11 +80,9 @@ class _settings extends \IPS\Dispatcher\Controller
{
$form->saveAsSettings( array(
'gallery_large_dims' => implode( 'x', $values['gallery_large_dims'] ),
'gallery_medium_dims' => implode( 'x', $values['gallery_medium_dims'] ),
'gallery_small_dims' => implode( 'x', $values['gallery_small_dims'] ),
'gallery_thumb_dims' => implode( 'x', $values['gallery_thumb_dims'] ),
'gallery_use_square_thumbnails' => $values['gallery_use_square_thumbnails'],
'gallery_watermark_path' => $values['gallery_watermark_path'],
'gallery_watermark_path' => (string) $values['gallery_watermark_path'],
'gallery_detailed_bandwidth' => $values['gallery_detailed_bandwidth'],
'gallery_bandwidth_period' => $values['gallery_bandwidth_period'],
'gallery_rss_enabled' => $values['gallery_rss_enabled'],
@@ -92,53 +90,15 @@ class _settings extends \IPS\Dispatcher\Controller
'gallery_use_watermarks' => $values['gallery_use_watermarks'],
) );
\IPS\Session::i()->log( 'acplogs__gallery_settings' );
if( $values['rebuildWatermarkScreenshots'] )
{
\IPS\Db::i()->delete( 'core_queue', array( '`app`=? OR `key`=?', 'gallery', 'RebuildGalleryImages' ) );
\IPS\Task::queue( 'gallery', 'RebuildGalleryImages', array( ), 2 );
}
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('settings');
\IPS\Output::i()->output = $form;
}
/**
* Rebuild gallery images
*
* @return void
*/
protected function rebuildImages()
{
$perGo = 5;
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('gallery_rebuildimages');
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=settings&do=rebuildImages' ), function( $doneSoFar ) use( $perGo )
{
$doneSoFar = intval( $doneSoFar );
$select = \IPS\Db::i()->select( '*', 'gallery_images', array( 'image_media=?', 0 ), 'image_id', array( $doneSoFar, $perGo ), NULL, NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS );
$total = $select->count( TRUE );
if ( !$select->count() )
{
return NULL;
}
foreach ( $select as $row )
{
try
{
$image = \IPS\gallery\Image::constructFromData( $row );
$image->deleteThumbnails();
$image->buildThumbnails();
$image->save();
}
catch ( \Exception $e ) {}
}
$doneSoFar += $perGo;
return array( $doneSoFar, \IPS\Member::loggedIn()->language()->addToStack('rebuilding'), ( 100 * $doneSoFar ) / $total );
}, function()
{
\IPS\Session::i()->log( 'acplogs__gallery_rebuilt' );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=settings' ), 'completed' );
} );
}
}
@@ -58,12 +58,14 @@ class _bandwidth extends \IPS\Dispatcher\Controller
$chart->tableParsers = array(
'member_id' => function( $val )
{
try
$member = \IPS\Member::load( $val );
if( $member->member_id )
{
$member = \IPS\Member::load( $val );
return "<a href='" . \IPS\Http\Url::internal( "app=gallery&module=stats&controller=member&do=images&id={$member->member_id}" ) . "'>{$member->name}</a>";
$url = \IPS\Http\Url::internal( "app=gallery&module=stats&controller=member&do=images&id={$member->member_id}" );
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $url, FALSE, $member->name );
}
catch ( \OutOfRangeException $e )
else
{
return \IPS\Member::loggedIn()->language()->addToStack('deleted_member');
}
@@ -73,7 +75,7 @@ class _bandwidth extends \IPS\Dispatcher\Controller
try
{
$image = \IPS\gallery\Image::load( $val );
return "<a href='{$image->url()}' target='_blank'>{$image->caption}</a>";
return \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->basicUrl( $image->url(), TRUE, $image->caption );
}
catch ( \OutOfRangeException $e )
{
@@ -104,8 +104,8 @@ class _diskspace extends \IPS\Dispatcher\Controller
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('stats_date_range') )
)
);
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('stats')->uploadersTable( $select, $pagination, $members );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->message( \IPS\Member::loggedIn()->language()->addToStack( 'stats_include_hidden_content' ), 'info' );
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate('stats')->uploadersTable( $select, $pagination, $members );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__gallery_stats_diskspace');
}
}
@@ -30,80 +30,6 @@ class _member extends \IPS\Dispatcher\Controller
*/
protected function images()
{
/* Get member */
try
{
$member = \IPS\Member::load( \IPS\Request::i()->id );
}
catch ( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2G192/1', 404, '' );
}
/* Build chart */
$tabs = array( 'information' => 'information', 'bandwidth_use' => 'bandwidth_use' );
$activeTab = \IPS\Request::i()->tab ?: 'information';
switch ( $activeTab )
{
case 'information':
$imageCount = \IPS\Db::i()->select( 'COUNT(*)', 'gallery_images', array( 'image_member_id=?', $member->member_id ) )->first();
$diskspaceUsed = \IPS\Db::i()->select( 'SUM(image_file_size)', 'gallery_images', array( 'image_member_id=?', $member->member_id ) )->first();
$numberOfViews = \IPS\Db::i()->select( 'COUNT(*)', 'gallery_bandwidth', array( 'member_id=?', $member->member_id ) )->first();
$bandwidthUsed = \IPS\Db::i()->select( 'SUM(bsize)', 'gallery_bandwidth', array( 'member_id=?', $member->member_id ) )->first();
$allImages = \IPS\Db::i()->select( 'COUNT(*)', 'gallery_images' )->first();
$totalFilesize = \IPS\Db::i()->select( 'SUM(image_file_size)', 'gallery_images' )->first();
$allBandwidth = \IPS\Db::i()->select( 'COUNT(*)', 'gallery_bandwidth' )->first();
$totalBandwidth = \IPS\Db::i()->select( 'SUM(bsize)', 'gallery_bandwidth' )->first();
$activeTabContents = \IPS\Theme::i()->getTemplate( 'stats' )->information( \IPS\Theme::i()->getTemplate( 'global', 'core' )->definitionTable( array(
'images_submitted' =>
\IPS\Member::loggedIn()->language()->addToStack( 'images_stat_of_total', FALSE, array( 'sprintf' => array(
\IPS\Member::loggedIn()->language()->formatNumber( $imageCount ),
\IPS\Member::loggedIn()->language()->formatNumber( ( ( $allImages ? ( 100 / $allImages ) : 0 ) * $imageCount ), 2 ) ) )
),
'gdiskspace_used' =>
\IPS\Member::loggedIn()->language()->addToStack( 'images_stat_of_total', FALSE, array( 'sprintf' => array(
\IPS\Output\Plugin\Filesize::humanReadableFilesize( $diskspaceUsed ),
\IPS\Member::loggedIn()->language()->formatNumber( ( ( $totalFilesize ? ( 100 / $totalFilesize ) : 0 ) * $diskspaceUsed ), 2 ) ) )
),
'gaverage_filesize' =>
\IPS\Member::loggedIn()->language()->addToStack( 'images_stat_average' , FALSE, array( 'sprintf' => array(
\IPS\Output\Plugin\Filesize::humanReadableFilesize( \IPS\Db::i()->select( 'AVG(image_file_size)', 'gallery_images', array( 'image_member_id=?', $member->member_id ) )->first() ),
\IPS\Output\Plugin\Filesize::humanReadableFilesize( \IPS\Db::i()->select( 'AVG(image_file_size)', 'gallery_images' )->first() ) ) )
),
'number_of_views' =>
\IPS\Member::loggedIn()->language()->addToStack( 'images_stat_of_total', FALSE, array( 'sprintf' => array(
\IPS\Member::loggedIn()->language()->formatNumber( $numberOfViews ),
\IPS\Member::loggedIn()->language()->formatNumber( ( ( $allBandwidth ? ( 100 / $allBandwidth ) : 0 ) * $imageCount ), 2 ) ))
),
'gallery_bandwidth_used' =>
\IPS\Member::loggedIn()->language()->addToStack( 'images_stat_of_total', FALSE, array( 'sprintf' => array(
\IPS\Output\Plugin\Filesize::humanReadableFilesize( $bandwidthUsed ),
\IPS\Member::loggedIn()->language()->formatNumber( ( ( $totalBandwidth ? ( 100 / $totalBandwidth ) : 0 ) * $bandwidthUsed ), 2 ) ) )
)
) ) );
break;
case 'bandwidth_use':
$bandwidthChart = new \IPS\Helpers\Chart\Database( \IPS\Http\Url::internal( "app=gallery&module=stats&controller=member&do=images&id={$member->member_id}&tab=bandwidth_use&_graph=1" ), 'gallery_bandwidth', 'bdate', '', array( 'vAxis' => array( 'title' => \IPS\Member::loggedIn()->language()->addToStack( 'filesize_raw_k' ) ) ), 'LineChart', 'daily' );
$bandwidthChart->groupBy = 'bdate';
$bandwidthChart->where[] = array( 'member_id=?', $member->member_id );
$bandwidthChart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('bandwidth_use'), 'number', 'ROUND((SUM(bsize)/1024),2)', FALSE );
$activeTabContents = ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->_graph ) ) ? (string) $bandwidthChart : \IPS\Theme::i()->getTemplate( 'stats' )->graphs( (string) $bandwidthChart );
break;
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('member_images_chart', FALSE, array( 'sprintf' => array( $member->name ) ) );
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->output = $activeTabContents;
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $activeTab, $activeTabContents, \IPS\Http\Url::internal( "app=gallery&module=stats&controller=member&do=images&id={$member->member_id}" ) );
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal("app=core&module=members&controller=members&do=view&id=" . \IPS\Request::i()->id . "&blockKey=core_ContentStatistics&block[core_ContentStatistics]=gallery_Gallery") );
}
}
@@ -132,8 +132,8 @@ class _browse extends \IPS\Content\Controller
protected function _index()
{
/* Get stuff */
$featured = iterator_to_array( \IPS\gallery\Image::featured( 20, '_rand' ) );
$new = iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( array(), NULL, 30 ) );
$featured = iterator_to_array( \IPS\gallery\Image::featured( 20, NULL ) );
$new = iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( ( \IPS\Settings::i()->club_nodes_in_apps ? array() : array( array( 'category_club_id IS NULL' ) ) ), NULL, 30, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, !\IPS\Settings::i()->club_nodes_in_apps ) );
/* Online User Location */
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=gallery', 'front', 'gallery' ), array(), 'loc_gallery_browsing' );
@@ -153,7 +153,7 @@ class _browse extends \IPS\Content\Controller
/* Online User Location */
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse&do=categories', 'front', 'gallery_categories' ), array(), 'loc_gallery_browsing_categories' );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('__app_gallery');
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('gallery_title');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->categories();
}
@@ -209,6 +209,14 @@ class _browse extends \IPS\Content\Controller
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'browse' ), $this->getTableRowsTemplate() );
$table->title = \IPS\Member::loggedIn()->language()->pluralize( \IPS\Member::loggedIn()->language()->get('num_images'), array( $category->count_imgs ) );
$table->sortBy = \IPS\Request::i()->sortby ? $table->sortBy : $category->sort_options_img;
/* Make sure captions are sorted in the right order */
if ( $table->sortBy == "title" )
{
$table->sortDirection = "asc";
}
if( !$category->allow_comments )
{
unset( $table->sortOptions['num_comments'] );
@@ -267,7 +275,7 @@ class _browse extends \IPS\Content\Controller
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'browse' ), 'imageTable' );
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'browse' ), $this->getTableRowsTemplate() );
$table->title = \IPS\Member::loggedIn()->language()->pluralize( \IPS\Member::loggedIn()->language()->get('num_images'), array( $album->count_imgs ) );
$table->title = \IPS\Member::loggedIn()->language()->addToStack( 'num_images', FALSE, array( 'pluralize' => array( $album->count_imgs ) ) );
if( !$album->allow_comments )
{
@@ -284,6 +292,11 @@ class _browse extends \IPS\Content\Controller
/* Load the item */
$asItem = $album->asItem();
/* Mark the album as read - we don't bother tracking page number because albums are sorted in all different manners so the
page parameter is unreliable for determining if the album is read. By default, typically, new images show at the beginning
of the album anyways */
$asItem->markRead();
/* Sort out comments and reviews */
$tabs = $asItem->commentReviewTabs();
$_tabs = array_keys( $tabs );
@@ -300,7 +313,7 @@ class _browse extends \IPS\Content\Controller
}
/* Fetching comments/reviews */
if( \IPS\Request::i()->isAjax() )
if( \IPS\Request::i()->isAjax() AND !isset( \IPS\Request::i()->listResort ) )
{
\IPS\Output::i()->output = $activeTabContents;
return;
@@ -341,10 +354,18 @@ class _browse extends \IPS\Content\Controller
\IPS\Output::i()->breadcrumb[] = array( $album->category()->url(), $album->category()->_title );
}
if( $album->coverPhoto('medium') )
if( $album->coverPhoto('masked') )
{
\IPS\Output::i()->metaTags['og:image'] = $album->coverPhoto('medium');
\IPS\Output::i()->metaTags['og:image'] = $album->coverPhoto('masked');
}
$albumItem = $album->asItem();
\IPS\core\Facebook\Pixel::i()->PageView = array(
'item_id' => $album->id,
'item_name' => $albumItem->mapped('title'),
'item_type' => isset( $albumItem::$contentType ) ? $albumItem::$contentType : $albumItem::$title,
'category_name' => $albumItem->container()->_title
);
\IPS\Output::i()->breadcrumb[] = array( NULL, $album->_title );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->album( $album, (string) $table, $commentsAndReviews );
@@ -371,51 +392,6 @@ class _browse extends \IPS\Content\Controller
}
}
/**
* Retrieve some images, used for the slider on the image view page
*
* @return void
*/
protected function getImages()
{
try
{
$startingPoint = \IPS\gallery\Image::load( \IPS\Request::i()->image );
}
catch ( \OutOfRangeException $e)
{
\IPS\Output::i()->error( 'node_error', '2G189/C', 404, '' );
}
$count = intval( \IPS\Request::i()->count );
if( \IPS\Request::i()->direction == 'next' )
{
$results = $startingPoint->nextImages( $count );
}
else
{
$results = $startingPoint->previousImages( $count );
}
$toSend = array();
foreach( $results as $result )
{
$toSend[] = \IPS\Theme::i()->getTemplate( 'view' )->imageThumbnail( $result );
}
/* Respond or redirect */
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( $toSend );
}
else
{
\IPS\Output::i()->redirect( $startingPoint->url() );
}
}
/**
* Latest images RSS
*
@@ -484,7 +460,7 @@ class _browse extends \IPS\Content\Controller
\IPS\Output::i()->error( 'node_error', '2G189/5', 404, '' );
}
if( !$album->canEdit() )
if( !$album->asItem()->canEdit() )
{
\IPS\Output::i()->error( 'node_error', '2G189/4', 403, '' );
}
@@ -597,7 +573,7 @@ class _browse extends \IPS\Content\Controller
$category->save();
/* Hide the album */
$album->type = 4;
$album->type = \IPS\gallery\Album::AUTH_TYPE_DELETED;
$album->save();
/* Are we moving the images? */
File diff suppressed because it is too large. Load diff
@@ -109,9 +109,9 @@ class _view extends \IPS\Content\Controller
\IPS\Output::i()->metaTags['og:video:tag'] = $this->image->tags();
}
if( $this->image->medium_file_name )
if( $this->image->masked_file_name )
{
\IPS\Output::i()->metaTags['og:image'] = \IPS\File::get( 'gallery_Images', $this->image->medium_file_name )->url;
\IPS\Output::i()->metaTags['og:image'] = \IPS\File::get( 'gallery_Images', $this->image->masked_file_name )->url;
}
}
else
@@ -125,15 +125,22 @@ class _view extends \IPS\Content\Controller
}
}
\IPS\Output::i()->linkTags[] = array(
'rel' => 'preload',
'href' => (string) \IPS\File::get( 'gallery_Images', $this->image->masked_file_name )->url,
'as' => $this->image->media ? 'video' : 'image',
'type' => $this->image->file_type
);
/* Sort out comments and reviews */
$tabs = $this->image->commentReviewTabs();
$_tabs = array_keys( $tabs );
$tab = isset( \IPS\Request::i()->tab ) ? \IPS\Request::i()->tab : array_shift( $_tabs );
$activeTabContents = $this->image->commentReviews( $tab );
$activeTabContents = $this->image->commentReviews( $tab, \IPS\Request::i()->lightbox );
if ( count( $tabs ) > 1 )
{
$commentsAndReviews = count( $tabs ) ? \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $tab, $activeTabContents, $this->image->url(), 'tab', FALSE, TRUE ) : NULL;
$commentsAndReviews = count( $tabs ) ? \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $tab, $activeTabContents, \IPS\Request::i()->lightbox ? $this->image->url()->setQueryString( 'lightbox', 1 ) : $this->image->url(), 'tab', FALSE, TRUE, \IPS\Request::i()->lightbox ? 'ipsTabs_small ipsTabs_stretch' : '' ) : NULL;
}
else
{
@@ -143,46 +150,6 @@ class _view extends \IPS\Content\Controller
/* Set the session location */
\IPS\Session::i()->setLocation( $this->image->url(), $this->image->onlineListPermissions(), 'loc_gallery_viewing_image', array( $this->image->caption => FALSE ) );
/* Get next 2 and previous 2 images in the container for slider */
$slider = array(
'previous' => $this->image->previousImages( 4 ),
'next' => $this->image->nextImages( 4 ),
);
$hasNext = TRUE;
$hasPrev = TRUE;
if( count( $slider['previous'] ) < 4 )
{
$hasPrev = FALSE;
}
else
{
$slider['previous'] = array_slice( $slider['previous'], 0, -1 );
}
if( count( $slider['next'] ) < 4 )
{
$hasNext = FALSE;
}
else
{
$slider['next'] = array_slice( $slider['next'], 0, -1 );
}
/* If this is a video, grab the necessary javascript */
if( $this->image->media )
{
if( \IPS\IN_DEV )
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'videojs/video.js', 'gallery', 'interface' ) );
}
else
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'videojs/video.min.js', 'gallery', 'interface' ) );
}
}
/* Store bandwidth log */
if( \IPS\Settings::i()->gallery_detailed_bandwidth )
{
@@ -192,30 +159,25 @@ class _view extends \IPS\Content\Controller
$displayedImage = \IPS\File::get( 'gallery_Images', $this->image->original_file_name );
}
/* Otherwise, fetch the thumbnails */
elseif( ( \IPS\Request::i()->imageSize == 'medium' OR !\IPS\Request::i()->imageSize ) AND $this->image->medium_file_name )
{
$displayedImage = \IPS\File::get( 'gallery_Images', $this->image->medium_file_name );
}
elseif( \IPS\Request::i()->imageSize == 'large' )
else
{
$displayedImage = \IPS\File::get( 'gallery_Images', $this->image->masked_file_name );
}
/* We hide the sidebar when displaying the large image */
\IPS\Output::i()->sidebar['enabled'] = FALSE;
}
elseif( \IPS\Request::i()->imageSize == 'small' )
/* Get filesize, but don't error out if there is a problem fetching it at this point */
try
{
$displayedImage = \IPS\File::get( 'gallery_Images', $this->image->small_file_name );
$filesize = ( ( isset( $displayedImage ) AND $displayedImage->filesize() ) ? $displayedImage->filesize() : $this->image->file_size );
}
elseif( \IPS\Request::i()->imageSize == 'thumb' )
catch( \Exception $e )
{
$displayedImage = \IPS\File::get( 'gallery_Images', $this->image->thumb_file_name );
$filesize = $this->image->file_size;
}
\IPS\Db::i()->insert( 'gallery_bandwidth', array(
'member_id' => (int) \IPS\Member::loggedIn()->member_id,
'bdate' => time(),
'bsize' => (int) ( ( isset( $displayedImage ) AND $displayedImage->filesize() ) ? $displayedImage->filesize() : $this->image->file_size ),
'bsize' => (int) $filesize,
'image_id' => $this->image->id
) );
}
@@ -226,15 +188,14 @@ class _view extends \IPS\Content\Controller
'@type' => $this->image->media ? "VideoObject" : "VisualArtwork",
'@id' => (string) $this->image->url(),
'url' => (string) $this->image->url(),
'name' => htmlspecialchars( $this->image->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'name' => $this->image->mapped('title'),
'description' => strip_tags( $this->image->truncated() ),
'dateCreated' => \IPS\DateTime::ts( $this->image->date )->format( \IPS\DateTime::ISO8601 ),
'fileFormat' => $this->image->file_type,
'keywords' => $this->image->tags(),
'author' => array(
'@type' => 'Person',
'name' => htmlspecialchars( \IPS\Member::load( $this->image->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'url' => (string) \IPS\Member::load( $this->image->member_id )->url(),
'name' => \IPS\Member::load( $this->image->member_id )->name,
'image' => \IPS\Member::load( $this->image->member_id )->get_photo()
),
'interactionStatistic' => array(
@@ -246,6 +207,12 @@ class _view extends \IPS\Content\Controller
)
);
/* Do we have a real author? */
if( $this->image->member_id )
{
\IPS\Output::i()->jsonLd['gallery']['author']['url'] = (string) \IPS\Member::load( $this->image->member_id )->url();
}
if ( $this->image->container()->allow_comments AND $this->image->directContainer()->allow_comments )
{
\IPS\Output::i()->jsonLd['gallery']['interactionStatistic'][] = array(
@@ -275,61 +242,59 @@ class _view extends \IPS\Content\Controller
if( $this->image->media )
{
if( $this->image->medium_file_name )
if( $this->image->masked_file_name )
{
\IPS\Output::i()->jsonLd['gallery']['thumbnail'] = (string) \IPS\File::get( 'gallery_Images', $this->image->medium_file_name )->url;
\IPS\Output::i()->jsonLd['gallery']['thumbnailUrl'] = (string) \IPS\File::get( 'gallery_Images', $this->image->medium_file_name )->url;
\IPS\Output::i()->jsonLd['gallery']['thumbnail'] = (string) \IPS\File::get( 'gallery_Images', $this->image->masked_file_name )->url;
\IPS\Output::i()->jsonLd['gallery']['thumbnailUrl'] = (string) \IPS\File::get( 'gallery_Images', $this->image->masked_file_name )->url;
}
\IPS\Output::i()->jsonLd['gallery']['contentSize'] = (string) \IPS\File::get( 'gallery_Images', $this->image->original_file_name )->filesize();
\IPS\Output::i()->jsonLd['gallery']['contentSize'] = htmlspecialchars( $this->image->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
}
else
{
$mediumFile = \IPS\File::get( 'gallery_Images', $this->image->medium_file_name );
$dimensions = $mediumFile->getImageDimensions();
\IPS\Output::i()->jsonLd['gallery']['artMedium'] = 'Digital';
\IPS\Output::i()->jsonLd['gallery']['width'] = $dimensions[0];
\IPS\Output::i()->jsonLd['gallery']['height'] = $dimensions[1];
\IPS\Output::i()->jsonLd['gallery']['image'] = array(
'@type' => 'ImageObject',
'url' => (string) $mediumFile->url,
'caption' => htmlspecialchars( $this->image->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'thumbnail' => (string) \IPS\File::get( 'gallery_Images', $this->image->thumb_file_name )->url,
'width' => $dimensions[0],
'height' => $dimensions[1],
);
if( count( $this->image->metadata ) )
try
{
\IPS\Output::i()->jsonLd['gallery']['image']['exifData'] = array();
$largeFile = \IPS\File::get( 'gallery_Images', $this->image->masked_file_name );
$dimensions = $this->image->_dimensions;
foreach( $this->image->metadata as $k => $v )
\IPS\Output::i()->jsonLd['gallery']['artMedium'] = 'Digital';
\IPS\Output::i()->jsonLd['gallery']['width'] = $dimensions['large'][0];
\IPS\Output::i()->jsonLd['gallery']['height'] = $dimensions['large'][1];
\IPS\Output::i()->jsonLd['gallery']['image'] = array(
'@type' => 'ImageObject',
'url' => (string) $largeFile->url,
'caption' => $this->image->mapped('title'),
'thumbnail' => (string) \IPS\File::get( 'gallery_Images', $this->image->small_file_name )->url,
'width' => $dimensions['large'][0],
'height' => $dimensions['large'][1],
);
if( count( $this->image->metadata ) )
{
\IPS\Output::i()->jsonLd['gallery']['image']['exifData'][] = array(
'@type' => 'PropertyValue',
'name' => $k,
'value' => $v
);
\IPS\Output::i()->jsonLd['gallery']['image']['exifData'] = array();
foreach( $this->image->metadata as $k => $v )
{
\IPS\Output::i()->jsonLd['gallery']['image']['exifData'][] = array(
'@type' => 'PropertyValue',
'name' => $k,
'value' => $v
);
}
}
\IPS\Output::i()->jsonLd['gallery']['thumbnailUrl'] = (string) \IPS\File::get( 'gallery_Images', $this->image->small_file_name )->url;
}
\IPS\Output::i()->jsonLd['gallery']['thumbnailUrl'] = (string) \IPS\File::get( 'gallery_Images', $this->image->thumb_file_name )->url;
/* File doesn't exist */
catch ( \RuntimeException $e ){}
}
/* Display */
if( isset( \IPS\Request::i()->imageSize ) )
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_view.js', 'gallery' ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->imageSizes( $this->image, $this->image->sizes() );
}
elseif( \IPS\Request::i()->isAjax() && isset( \IPS\Request::i()->browse ) )
if( \IPS\Request::i()->isAjax() && isset( \IPS\Request::i()->browse ) )
{
$return = array(
'title' => htmlspecialchars( $this->image->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'image' => \IPS\Theme::i()->getTemplate( 'view' )->imageFrame( $this->image, $slider, $this->image->nextItem(), $this->image->prevItem() ),
'info' => \IPS\Theme::i()->getTemplate( 'view' )->imageInfo( $this->image, $slider, $this->image->nextItem(), $this->image->prevItem() ),
'slider' => \IPS\Theme::i()->getTemplate( 'view' )->imageSlider( $this->image, $slider, $this->image->nextItem(), $this->image->prevItem(), $hasNext, $hasPrev )
'title' => htmlspecialchars( $this->image->mapped('title'), ENT_DISALLOWED | ENT_QUOTES, 'UTF-8', FALSE ),
'image' => \IPS\Request::i()->lightbox ? \IPS\Theme::i()->getTemplate( 'view' )->imageLightboxFrame( $this->image ) : \IPS\Theme::i()->getTemplate( 'view' )->imageFrame( $this->image ),
'info' => \IPS\Request::i()->lightbox ? \IPS\Theme::i()->getTemplate( 'view' )->imageLightboxInfo( $this->image, $commentsAndReviews ) : \IPS\Theme::i()->getTemplate( 'view' )->imageInfo( $this->image )
);
if( $this->image->directContainer()->allow_comments )
@@ -340,16 +305,26 @@ class _view extends \IPS\Content\Controller
\IPS\Output::i()->json( $return );
}
/* Switching comments only */
elseif( \IPS\Request::i()->isAjax() AND !isset( \IPS\Request::i()->rating_submitted ) )
elseif( \IPS\Request::i()->isAjax() AND !isset( \IPS\Request::i()->rating_submitted ) AND \IPS\Request::i()->tab )
{
\IPS\Output::i()->output = $activeTabContents;
return;
}
else
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, array( \IPS\Http\Url::internal( 'applications/gallery/interface/videojs/video-js.min.css', 'none' ) ) );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_view.js', 'gallery' ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->image( $this->image, $slider, $this->image->nextItem(), $this->image->prevItem(), $hasNext, $hasPrev, $commentsAndReviews );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_browse.js', 'gallery' ) );
if( \IPS\Request::i()->lightbox )
{
\IPS\Output::i()->sidebar['enabled'] = FALSE;
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->imageLightbox( $this->image, $commentsAndReviews );
return;
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->image( $this->image, $commentsAndReviews );
}
}
}
@@ -363,10 +338,8 @@ class _view extends \IPS\Content\Controller
try
{
/* Get file and data */
$size = ( isset( \IPS\Request::i()->imageSize ) AND \IPS\Request::i()->imageSize AND \IPS\Request::i()->imageSize != 'large' ) ? \IPS\Request::i()->imageSize . "_file_name" : "masked_file_name";
$file = \IPS\File::get( 'gallery_Images', $this->image->$size );
$headers = array_merge( \IPS\Output::getCacheHeaders( time(), 360 ), array( "Content-Disposition" => \IPS\Output::getContentDisposition( 'download', $file->originalFilename ), "X-Content-Type-Options" => "nosniff" ) );
$file = \IPS\File::get( 'gallery_Images', $this->image->original_file_name ?: $this->image->masked_file_name );
$headers = array_merge( \IPS\Output::getCacheHeaders( time(), 360 ), array( "Content-Disposition" => \IPS\Output::getContentDisposition( 'attachment', $file->originalFilename ), "X-Content-Type-Options" => "nosniff" ) );
/* Send headers and print file */
\IPS\Output::i()->sendStatusCodeHeader( 200 );
@@ -376,6 +349,7 @@ class _view extends \IPS\Content\Controller
{
\IPS\Output::i()->sendHeader( $key . ': ' . $header );
}
\IPS\Output::i()->sendHeader( "Content-Length: " . $file->filesize() );
$file->printFile();
@@ -408,7 +382,22 @@ class _view extends \IPS\Content\Controller
*/
protected function cover()
{
if( ( !$this->image->album_id OR !$this->image->canEdit() ) AND !\IPS\gallery\Image::modPermission( 'edit', NULL, $this->image->container() ) )
switch( \IPS\Request::i()->set )
{
case 'album':
$check = $this->image->canSetAsAlbumCover();
break;
case 'category':
$check = $this->image->canSetAsCategoryCover();
break;
case 'both':
$check = ( $this->image->canSetAsAlbumCover() AND $this->image->canSetAsCategoryCover() );
break;
}
if ( !$check )
{
\IPS\Output::i()->error( 'node_error', '2G188/5', 403, '' );
}
@@ -416,7 +405,7 @@ class _view extends \IPS\Content\Controller
\IPS\Session::i()->csrfCheck();
$lang = '';
if( ( $this->image->album_id AND $this->image->canEdit() ) && ( \IPS\Request::i()->set == 'album' or \IPS\Request::i()->set == 'both' ) )
if( $this->image->canSetAsAlbumCover() && ( \IPS\Request::i()->set == 'album' or \IPS\Request::i()->set == 'both' ) )
{
$this->image->directContainer()->cover_img_id = $this->image->id;
$this->image->directContainer()->save();
@@ -424,7 +413,7 @@ class _view extends \IPS\Content\Controller
$lang = \IPS\Member::loggedIn()->language()->addToStack('set_as_album_done');
}
if( ( \IPS\gallery\Image::modPermission( 'edit', NULL, $this->image->container() ) ) && ( \IPS\Request::i()->set == 'category' or \IPS\Request::i()->set == 'both' ) )
if( $this->image->canSetAsCategoryCover() && ( \IPS\Request::i()->set == 'category' or \IPS\Request::i()->set == 'both' ) )
{
$this->image->container()->cover_img_id = $this->image->id;
$this->image->container()->save();
@@ -468,11 +457,11 @@ class _view extends \IPS\Content\Controller
/* Determine angle to rotate */
if( \IPS\Request::i()->direction == 'right' )
{
$angle = 90;
$angle = ( \IPS\Settings::i()->image_suite == 'imagemagick' and class_exists( 'Imagick', FALSE ) ) ? 90 : -90;
}
else
{
$angle = 270;
$angle = ( \IPS\Settings::i()->image_suite == 'imagemagick' and class_exists( 'Imagick', FALSE ) ) ? -90 : 90;
}
/* Rotate the image and rebuild thumbnails */
@@ -487,7 +476,12 @@ class _view extends \IPS\Content\Controller
/* Respond or redirect */
if ( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( 'OK' );
\IPS\Output::i()->json( array(
'src' => (string) \IPS\File::get( 'gallery_Images', $this->image->masked_file_name )->url,
'message' => \IPS\Member::loggedIn()->language()->addToStack('gallery_image_rotated'),
'width' => $this->image->_dimensions['large'][0],
'height' => $this->image->_dimensions['large'][1],
) );
}
else
{
@@ -516,7 +510,7 @@ class _view extends \IPS\Content\Controller
/* Handle submissions */
if ( $values = $form->values() )
{
$this->image->member_id = $values['author']->member_id;
$this->image->changeAuthor( $values['author'] );
$this->image->save();
\IPS\Output::i()->redirect( $this->image->url() );
@@ -548,15 +542,16 @@ class _view extends \IPS\Content\Controller
\IPS\Session::i()->csrfCheck();
/* Update profile photo */
$file = \IPS\File::get( 'gallery_Images', $this->image->medium_file_name );
$image = \IPS\Image::create( $file->contents() );
$photo = \IPS\File::create( 'core_Profile', $file->filename, (string) $image );
$file = \IPS\File::get( 'gallery_Images', $this->image->masked_file_name );
$image = \IPS\Image::create( $file->contents() );
$photo = \IPS\File::create( 'core_Profile', $file->filename, (string) $image );
\IPS\Member::loggedIn()->pp_main_photo = (string) $photo;
\IPS\Member::loggedIn()->pp_thumb_photo = (string) $photo->thumbnail( 'core_Profile', \IPS\PHOTO_THUMBNAIL_SIZE, \IPS\PHOTO_THUMBNAIL_SIZE );
\IPS\Member::loggedIn()->pp_photo_type = "custom";
\IPS\Member::loggedIn()->photo_last_update = time();
\IPS\Member::loggedIn()->save();
\IPS\Member::loggedIn()->logHistory( 'core', 'photo', array( 'action' => 'new', 'type' => 'gallery', 'id' => $this->image->id ) );
/* Redirect back to image */
if( \IPS\Request::i()->isAjax() )
@@ -586,68 +581,8 @@ class _view extends \IPS\Content\Controller
throw new \DomainException;
}
$form = new \IPS\Helpers\Form( 'form', 'move' );
$form->class = 'ipsForm_vertical';
if ( \IPS\gallery\Category::canOnAny('add') and \IPS\gallery\Album::canOnAny('add') )
{
$options = array( 'category' => 'image_category', 'album' => 'image_album' );
$toggles = array( 'category' => array( 'move_to_category' ), 'album' => array( 'move_to_album' ) );
$extraFields = array();
if ( \IPS\gallery\Image::modPermission( 'edit', NULL, NULL ) and \IPS\Db::i()->select( 'COUNT(*)', 'gallery_categories', array( array( 'category_allow_albums=1' ), array( '(' . \IPS\Db::i()->findInSet( 'core_permission_index.perm_' . \IPS\gallery\Category::$permissionMap['add'], \IPS\Member::loggedIn()->groups ) . ' OR ' . 'core_permission_index.perm_' . \IPS\gallery\Category::$permissionMap['add'] . '=? )', '*' ) ) )->join( 'core_permission_index', array( "core_permission_index.app=? AND core_permission_index.perm_type=? AND core_permission_index.perm_type_id=" . \IPS\gallery\Category::$databaseTable . "." . \IPS\gallery\Category::$databasePrefix . \IPS\gallery\Category::$databaseColumnId, \IPS\gallery\Category::$permApp, \IPS\gallery\Category::$permType ) )->first() )
{
$options['new_album'] = 'move_to_new_album';
$form = \IPS\gallery\Image\Table::buildMoveForm( $item->container(), 'IPS\\gallery\\Image', array( 'forceOwner' => $item->author() ) );
foreach ( \IPS\gallery\Album::formFields( NULL, TRUE, \IPS\Request::i()->move_to === 'new_album' ) as $field )
{
if ( !$field->htmlId )
{
$field->htmlId = $field->name . '_id';
}
$toggles['new_album'][] = $field->htmlId;
$extraFields[] = $field;
}
}
$form->add( new \IPS\Helpers\Form\Radio( 'move_to', NULL, TRUE, array( 'options' => $options, 'toggles' => $toggles ) ) );
foreach ( $extraFields as $field )
{
$form->add( $field );
}
}
$form->add( new \IPS\Helpers\Form\Node( 'move_to_category', NULL, NULL, array( 'clubs' => true, 'class' => 'IPS\\gallery\\Category', 'permissionCheck' => 'add' ), function( $val ) {
if ( !$val and isset( \IPS\Request::i()->move_to ) and \IPS\Request::i()->move_to == 'category' )
{
throw new \DomainException('form_required');
}
}, NULL, NULL, 'move_to_category' ) );
$form->add( new \IPS\Helpers\Form\Node( 'move_to_album', NULL, NULL, array(
'class' => 'IPS\\gallery\\Album',
'permissionCheck' => function( $node )
{
/* Do we have permission to add? */
if( !$node->can( 'add' ) )
{
return false;
}
/* Have we hit an images per album limit? */
if( $node->owner()->group['g_img_album_limit'] AND ( $node->count_imgs + $node->count_imgs_hidden ) >= $node->owner()->group['g_img_album_limit'] )
{
return false;
}
return true;
},
'forceOwner' => $item->author()
), function( $val ) {
if ( !$val and isset( \IPS\Request::i()->move_to ) and \IPS\Request::i()->move_to == 'album' )
{
throw new \DomainException('form_required');
}
}, NULL, NULL, 'move_to_album' ) );
if ( $values = $form->values() )
{
if ( isset( $values['move_to'] ) )