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

@@ -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'] ) )