Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Categories
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Gallery
|
||||
* @since 04 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Settings
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Gallery
|
||||
* @since 04 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -42,8 +42,6 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'settings_manage' );
|
||||
|
||||
$form = new \IPS\Helpers\Form;
|
||||
|
||||
$form->addHeader( 'gallery_images' );
|
||||
@@ -57,7 +55,20 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
$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\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' ) ) );
|
||||
$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' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'gallery_watermark_images',
|
||||
\IPS\Settings::i()->gallery_watermark_images ? explode( ',', \IPS\Settings::i()->gallery_watermark_images ) : array(),
|
||||
FALSE,
|
||||
array(
|
||||
'multiple' => TRUE,
|
||||
'options' => array( 'large' => 'gallery_watermark_large', 'medium' => 'gallery_watermark_medium', 'small' => 'gallery_watermark_small', 'thumbnail' => 'gallery_watermark_thumb' ),
|
||||
),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
'gallery_watermark_images'
|
||||
) );
|
||||
|
||||
$form->addHeader( 'gallery_bandwidth' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_detailed_bandwidth', \IPS\Settings::i()->gallery_detailed_bandwidth ) );
|
||||
@@ -78,6 +89,8 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
'gallery_detailed_bandwidth' => $values['gallery_detailed_bandwidth'],
|
||||
'gallery_bandwidth_period' => $values['gallery_bandwidth_period'],
|
||||
'gallery_rss_enabled' => $values['gallery_rss_enabled'],
|
||||
'gallery_watermark_images' => implode( ',', $values['gallery_watermark_images'] ),
|
||||
'gallery_use_watermarks' => $values['gallery_use_watermarks'],
|
||||
) );
|
||||
\IPS\Session::i()->log( 'acplogs__gallery_settings' );
|
||||
}
|
||||
@@ -98,6 +111,8 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
\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 );
|
||||
|
||||
@@ -111,6 +126,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
try
|
||||
{
|
||||
$image = \IPS\gallery\Image::constructFromData( $row );
|
||||
$image->deleteThumbnails();
|
||||
$image->buildThumbnails();
|
||||
$image->save();
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Gallery bandwidth statistics
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Gallery
|
||||
* @since 04 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -42,7 +42,7 @@ class _bandwidth extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
$chart = new \IPS\Helpers\Chart\Dynamic( \IPS\Http\Url::internal( "app=gallery&module=stats&controller=bandwidth" ), 'gallery_bandwidth', 'bdate', '', array( 'vAxis' => array( 'title' => '(kB)' ) ), 'LineChart', 'daily', array( 'start' => 0, 'end' => 0 ), array( 'member_id', 'image_id', 'bdate', 'bsize' ) );
|
||||
$chart = new \IPS\Helpers\Chart\Dynamic( \IPS\Http\Url::internal( "app=gallery&module=stats&controller=bandwidth" ), 'gallery_bandwidth', 'bdate', '', array( 'vAxis' => array( 'title' => \IPS\Member::loggedIn()->language()->addToStack( 'filesize_raw_k' ) ) ), 'LineChart', 'daily', array( 'start' => 0, 'end' => 0 ), array( 'member_id', 'image_id', 'bdate', 'bsize' ) );
|
||||
|
||||
$chart->addSeries( \IPS\Member::loggedIn()->language()->addToStack('bandwidth'), 'number', 'ROUND((SUM(bsize)/1024),2)', FALSE );
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Top uploaders
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Gallery
|
||||
* @since 04 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -77,8 +77,18 @@ class _diskspace extends \IPS\Dispatcher\Controller
|
||||
$page = 1;
|
||||
}
|
||||
|
||||
$select = \IPS\Db::i()->select( 'image_member_id, COUNT(*) as images, core_members.*', 'gallery_images', $where, 'images DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'image_member_id', NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS )->join( 'core_members', 'core_members.member_id=gallery_images.image_member_id' );
|
||||
$select = \IPS\Db::i()->select( 'image_member_id, COUNT(*) as images', 'gallery_images', $where, 'images DESC', array( ( $page - 1 ) * static::PER_PAGE, static::PER_PAGE ), 'image_member_id', NULL, \IPS\Db::SELECT_SQL_CALC_FOUND_ROWS )->join( 'core_members', 'core_members.member_id=gallery_images.image_member_id' );
|
||||
$mids = array();
|
||||
|
||||
foreach( $select as $row )
|
||||
{
|
||||
$mids[] = $row['image_member_id'];
|
||||
}
|
||||
|
||||
if ( count( $mids ) )
|
||||
{
|
||||
$members = iterator_to_array( \IPS\Db::i()->select( '*', 'core_members', array( \IPS\Db::i()->in( 'member_id', $mids ) ) )->setKeyField('member_id') );
|
||||
}
|
||||
$pagination = \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
|
||||
\IPS\Http\Url::internal( 'app=gallery&module=stats&controller=diskspace' )->setQueryString( $values ),
|
||||
ceil( $select->count( TRUE ) / static::PER_PAGE ),
|
||||
@@ -96,7 +106,7 @@ class _diskspace extends \IPS\Dispatcher\Controller
|
||||
)
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('stats')->uploadersTable( $select, $pagination );
|
||||
\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');
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Member Stats
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Gallery
|
||||
* @since 26 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -87,7 +87,8 @@ class _member extends \IPS\Dispatcher\Controller
|
||||
break;
|
||||
|
||||
case 'bandwidth_use':
|
||||
$bandwidthChart = new \IPS\Helpers\Chart\Dynamic( \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' => '(kB)' ) ), 'LineChart', 'daily' );
|
||||
$bandwidthChart = new \IPS\Helpers\Chart\Dynamic( \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 );
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Browse the gallery
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Gallery
|
||||
* @since 04 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -41,6 +41,9 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
static::$contentModel = 'IPS\gallery\Album';
|
||||
}
|
||||
|
||||
/* Gallery uses caption for title */
|
||||
\IPS\Member::loggedIn()->language()->words[ "sort_title" ] = \IPS\Member::loggedIn()->language()->addToStack( "album_sort_caption", FALSE );
|
||||
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_browse.js', 'gallery' ) );
|
||||
parent::execute();
|
||||
}
|
||||
@@ -78,7 +81,17 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$category = \IPS\gallery\Category::loadAndCheckPerms( \IPS\Request::i()->category, 'view' );
|
||||
|
||||
\IPS\Output::i()->rssFeeds[ \IPS\Member::loggedIn()->language()->addToStack( 'gallery_rss_title_container', FALSE, array( 'sprintf' => array( $category->_title ) ) ) ] = \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse&do=rss&category=' . $category->id, 'front', 'gallery_rss' );
|
||||
/* If we cannot view images and there's a custom error, show it now */
|
||||
if( !$category->can( 'read' ) AND \IPS\Member::loggedIn()->language()->checkKeyExists( "gallery_category_{$category->id}_permerror" ) )
|
||||
{
|
||||
\IPS\Output::i()->error( "gallery_category_{$category->id}_permerror", '1G189/B', 403, '' );
|
||||
}
|
||||
|
||||
/* Add RSS feed */
|
||||
if ( \IPS\Settings::i()->gallery_rss_enabled )
|
||||
{
|
||||
\IPS\Output::i()->rssFeeds[ \IPS\Member::loggedIn()->language()->addToStack( 'gallery_rss_title_container', FALSE, array( 'sprintf' => array( $category->_title ) ) ) ] = \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse&do=rss&category=' . $category->id, 'front', 'gallery_rss' );
|
||||
}
|
||||
|
||||
$this->_category( $category );
|
||||
}
|
||||
@@ -93,8 +106,11 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$album = \IPS\gallery\Album::loadAndCheckPerms( \IPS\Request::i()->album, 'view' );
|
||||
|
||||
\IPS\Output::i()->rssFeeds[ \IPS\Member::loggedIn()->language()->addToStack( 'gallery_rss_title_container', FALSE, array( 'sprintf' => array( $album->_title ) ) ) ] = \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse&do=rss&album=' . $album->id, 'front', 'gallery_rss' );
|
||||
|
||||
/* Add RSS feed */
|
||||
if ( \IPS\Settings::i()->gallery_rss_enabled )
|
||||
{
|
||||
\IPS\Output::i()->rssFeeds[\IPS\Member::loggedIn()->language()->addToStack('gallery_rss_title_container', FALSE, array('sprintf' => array($album->_title)))] = \IPS\Http\Url::internal('app=gallery&module=gallery&controller=browse&do=rss&album=' . $album->id, 'front', 'gallery_rss');
|
||||
}
|
||||
$this->_album( $album );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
@@ -204,7 +220,7 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
}
|
||||
|
||||
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( 'category' ) ) ) ) ] = array( 'type' => 'gallery_image', 'nodes' => $category->_id );
|
||||
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item_categories' ) ] = array( 'type' => 'gallery_image', 'nodes' => $category->_id );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->category( $category, $albums, (string) $table );
|
||||
}
|
||||
|
||||
@@ -227,6 +243,13 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
$table = new \IPS\gallery\Image\Table( 'IPS\gallery\Image', $album->url(), array( array( 'image_album_id=?', $album->id ) ), $album->category() );
|
||||
$table->limit = 50;
|
||||
$table->sortBy = \IPS\Request::i()->sortby ? $table->sortBy : $album->_sortBy;
|
||||
|
||||
/* Make sure captions are sorted in the right order */
|
||||
if ( $table->sortBy == "title" )
|
||||
{
|
||||
$table->sortDirection = "asc";
|
||||
}
|
||||
|
||||
$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 ) );
|
||||
@@ -294,7 +317,15 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function getImages()
|
||||
{
|
||||
$startingPoint = \IPS\gallery\Image::load( \IPS\Request::i()->image );
|
||||
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' )
|
||||
@@ -397,8 +428,6 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->error( 'node_error', '2G189/4', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class .= 'ipsForm_vertical';
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Store and retrieve image notes
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Gallery
|
||||
* @since 21 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -83,6 +83,14 @@ class _notes extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function _deleteNote( $id )
|
||||
{
|
||||
/* Check permission */
|
||||
if( !$this->image->canEdit() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'notes_no_permission', '2G191/3', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$notes = $this->image->_notes;
|
||||
|
||||
foreach( $notes as $key => $note )
|
||||
@@ -109,6 +117,14 @@ class _notes extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function _addNote( $position, $note )
|
||||
{
|
||||
/* Check permission */
|
||||
if( !$this->image->canEdit() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'notes_no_permission', '2G191/4', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$notes = $this->image->_notes;
|
||||
$position = explode( ',', $position );
|
||||
|
||||
@@ -152,6 +168,14 @@ class _notes extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function _editNote( $id, $position='', $noteText='' )
|
||||
{
|
||||
/* Check permission */
|
||||
if( !$this->image->canEdit() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'notes_no_permission', '2G191/5', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$notes = $this->image->_notes;
|
||||
$position = explode( ',', $position );
|
||||
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Gallery Submission
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Gallery
|
||||
* @since 04 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -131,10 +131,10 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* Can we create an album in this category? */
|
||||
$canCreateAlbum = $category->allow_albums and \IPS\Member::loggedIn()->group['g_create_albums'];
|
||||
$canCreateAlbum = ( $category->allow_albums and \IPS\Member::loggedIn()->group['g_create_albums'] );
|
||||
$maximumAlbums = \IPS\Member::loggedIn()->group['g_album_limit'];
|
||||
$currentAlbumCount = count( \IPS\gallery\Album::loadByOwner() );
|
||||
|
||||
|
||||
/* If we can, build a form */
|
||||
$createAlbumForm = NULL;
|
||||
if ( $canCreateAlbum and ( !$maximumAlbums or $maximumAlbums > $currentAlbumCount ) )
|
||||
@@ -190,14 +190,7 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
/* If there's nothing we can do, we can just continue */
|
||||
if ( !$canCreateAlbum )
|
||||
{
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
\IPS\Output::i()->json('');
|
||||
}
|
||||
else
|
||||
{
|
||||
return array( 'category' => $category->_id, 'album' => 0 );
|
||||
}
|
||||
return array( 'category' => $category->_id, 'album' => 0 );
|
||||
}
|
||||
|
||||
/* Otherwise, ask the user what they want to do */
|
||||
@@ -264,7 +257,8 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
'image' => TRUE,
|
||||
'multiple' => TRUE,
|
||||
'minimize' => FALSE,
|
||||
'template' => "core.attachments.imageItem"
|
||||
'template' => "core.attachments.imageItem",
|
||||
'maxFiles' => 100 // @todo: Look for a better way of storing temporary gallery data so we can get rid of this arbitrary limit
|
||||
);
|
||||
if ( \IPS\Member::loggedIn()->group['g_max_upload'] )
|
||||
{
|
||||
@@ -286,9 +280,9 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
$form->add( new \IPS\Helpers\Form\Upload( 'images', $currentValue, TRUE, $options, function( $val ) use ( $maxNumberOfImages, $maxFileSizes ) {
|
||||
if ( $maxNumberOfImages !== NULL and count( $val ) > $maxNumberOfImages )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'gallery_images_too_many', FALSE, array( 'sprintf' => array( $maxNumberOfImages ) ) ) );
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'gallery_images_too_many', FALSE, array( 'pluralize' => array( $maxNumberOfImages ) ) ) );
|
||||
}
|
||||
if ( count( $val ) > 100 ) // Just to prevent the session data exceeding it's storage size
|
||||
if ( count( $val ) > 100 ) // @todo remove this limit: Just to prevent the session data exceeding it's storage size
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'gallery_images_too_many_at_once' ) );
|
||||
}
|
||||
@@ -297,14 +291,16 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
$ext = mb_substr( $file->filename, ( mb_strrpos( $file->filename, '.' ) + 1 ) );
|
||||
if ( in_array( $ext, \IPS\Image::$imageExtensions ) )
|
||||
{
|
||||
if ( count( $maxFileSizes ) == 2 and $file->filesize() > $maxFileSizes['image'] )
|
||||
/* The size was saved as kb, then divided by 1024 above to figure out how many MB to allow. So now we have '2' for 2MB for instance, so we need
|
||||
to multiply that by 1024*1024 in order to get the byte size again */
|
||||
if ( count( $maxFileSizes ) == 2 and $file->filesize() > ( $maxFileSizes['image'] * 1048576 ) )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'upload_image_too_big', FALSE, array( 'sprintf' => array( \IPS\Output\Plugin\Filesize::humanReadableFilesize( $maxFileSizes['image'] * 1024 ) ) ) ) );
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'upload_image_too_big', FALSE, array( 'sprintf' => array( \IPS\Output\Plugin\Filesize::humanReadableFilesize( $maxFileSizes['image'] * 1048576 ) ) ) ) );
|
||||
}
|
||||
}
|
||||
elseif ( count( $maxFileSizes ) == 2 and $file->filesize() > $maxFileSizes['movie'] )
|
||||
elseif ( count( $maxFileSizes ) == 2 and $file->filesize() > ( $maxFileSizes['movie'] * 1048576 ) )
|
||||
{
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'upload_movie_too_big', FALSE, array( 'sprintf' => array( \IPS\Output\Plugin\Filesize::humanReadableFilesize( $maxFileSizes['movie'] * 1024 ) ) ) ) );
|
||||
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'upload_movie_too_big', FALSE, array( 'sprintf' => array( \IPS\Output\Plugin\Filesize::humanReadableFilesize( $maxFileSizes['movie'] * 1048576 ) ) ) ) );
|
||||
}
|
||||
}
|
||||
} ) );
|
||||
@@ -313,7 +309,7 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
/* Get any records we had before in case we need to delete them */
|
||||
$existing = iterator_to_array( \IPS\Db::i()->select( '*', 'gallery_images_uploads', array( 'upload_session=?', \IPS\Request::i()->postKey ) )->setKeyField( 'upload_location' ) );
|
||||
$existing = iterator_to_array( \IPS\Db::i()->select( '*', 'gallery_images_uploads', array( 'upload_session=?', session_id() ) )->setKeyField( 'upload_location' ) );
|
||||
|
||||
/* Loop through the values we have */
|
||||
$images = array();
|
||||
@@ -394,6 +390,7 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
$image = \IPS\File::get( 'gallery_Images', $url );
|
||||
$image->done = ( isset( $existing[ $url ] ) and $existing[ $url ]['upload_data'] );
|
||||
$image->movie = !in_array( mb_strtolower( mb_substr( $image->filename, ( mb_strrpos( $image->filename, '.' ) + 1 ) ) ), \IPS\Image::$imageExtensions );
|
||||
$image->tempId = isset( $existing[ $url ] ) ? $existing[ $url ]['upload_unique_id'] : 0;
|
||||
$images[] = $image;
|
||||
}
|
||||
}
|
||||
@@ -424,7 +421,8 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Get the form for the image being edited */
|
||||
$form = $this->_editImageForm( $images, $currentlyEditing, $category );
|
||||
if ( $values = $form->values( TRUE ) )
|
||||
$values = $form->values( TRUE );
|
||||
if ( $values )
|
||||
{
|
||||
/* Save that data */
|
||||
\IPS\Db::i()->update( 'gallery_images_uploads', array( 'upload_data' => json_encode( $values ) ), array( 'upload_location=? AND upload_session=?', (string) $images[ $currentlyEditing ], session_id() ) );
|
||||
@@ -440,13 +438,17 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
$currentlyEditing = $wasEditing - 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
elseif ( isset( \IPS\Request::i()->submitButton ) and \IPS\Request::i()->submitButton == 'next' )
|
||||
{
|
||||
if( isset( $images[ $wasEditing + 1 ] ) )
|
||||
{
|
||||
$currentlyEditing = $wasEditing + 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$currentlyEditing = $wasEditing;
|
||||
}
|
||||
|
||||
/* If we couldn't find one, just grab any image which hasn't been done */
|
||||
if ( $currentlyEditing === NULL )
|
||||
@@ -463,7 +465,24 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
|
||||
/* Otherwise we'll display this form */
|
||||
$form = $this->_editImageForm( $images, $currentlyEditing, $category );
|
||||
|
||||
|
||||
/* Do we have existing information to add? */
|
||||
if ( isset( $images[ $currentlyEditing ] ) and isset( $existing[ (string) $images[ $currentlyEditing ] ] ) and $existing[ (string) $images[ $currentlyEditing ] ]['upload_data'] )
|
||||
{
|
||||
$data = json_decode( $existing[ (string) $images[ $currentlyEditing ] ]['upload_data'], TRUE );
|
||||
foreach( $form->elements[''] as $key => &$elem )
|
||||
{
|
||||
foreach( array( 'title', 'tags', 'description', 'credit_info', 'copyright' ) as $field )
|
||||
{
|
||||
$lookUp = 'filedata_' . $currentlyEditing . '_image_' . $field;
|
||||
if ( $key == $lookUp and $data[ $lookUp ] )
|
||||
{
|
||||
$elem->value = $data[ $lookUp ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
/* If we've done them all, tell the user they're ready to submit */
|
||||
@@ -481,7 +500,49 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
$output = array(
|
||||
'done' => ( $currentlyEditing === NULL ),
|
||||
'form' => $formHTML,
|
||||
'index' => ( $currentlyEditing === NULL ) ? -1 : $currentlyEditing
|
||||
'index' => ( $currentlyEditing === NULL ) ? -1 : $currentlyEditing,
|
||||
'success' => TRUE
|
||||
);
|
||||
|
||||
\IPS\Output::i()->sendOutput( json_encode( $output ), 200, 'application/json' );
|
||||
}
|
||||
}
|
||||
elseif( \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
/* If this form was submitted but didn't validate, we need to output JSON for the same image again */
|
||||
$formName = 'image_information_' . $currentlyEditing . '_submitted';
|
||||
|
||||
if ( $currentlyEditing !== NULL )
|
||||
{
|
||||
/* Do we have existing information to add? */
|
||||
if ( isset( $images[ $currentlyEditing ] ) and isset( $existing[ (string) $images[ $currentlyEditing ] ] ) and $existing[ (string) $images[ $currentlyEditing ] ]['upload_data'] )
|
||||
{
|
||||
$data = json_decode( $existing[ (string) $images[ $currentlyEditing ] ]['upload_data'], TRUE );
|
||||
foreach( $form->elements[''] as $key => &$elem )
|
||||
{
|
||||
foreach( array( 'title', 'tags', 'description', 'credit_info', 'copyright' ) as $field )
|
||||
{
|
||||
$lookUp = 'filedata_' . $currentlyEditing . '_image_' . $field;
|
||||
if ( $key == $lookUp and $data[ $lookUp ] )
|
||||
{
|
||||
$elem->value = $data[ $lookUp ];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( isset( \IPS\Request::i()->$formName ) and \IPS\Request::i()->csrfKey === \IPS\Session::i()->csrfKey )
|
||||
{
|
||||
$formHTML = \IPS\Theme::i()->getTemplate( 'submit' )->imageInformationWrapper( $form, count( $images ), $currentlyEditing );
|
||||
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $formHTML );
|
||||
|
||||
$output = array(
|
||||
'done' => ( $currentlyEditing === NULL ),
|
||||
'form' => $formHTML,
|
||||
'index' => ( $currentlyEditing === NULL ) ? -1 : $currentlyEditing,
|
||||
'success' => FALSE
|
||||
);
|
||||
|
||||
\IPS\Output::i()->sendOutput( json_encode( $output ), 200, 'application/json' );
|
||||
@@ -520,22 +581,22 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
$form = new \IPS\Helpers\Form( 'image_information_' . $currentlyEditing, 'continue_next_image', \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=submit&_step=image_information', 'front', 'gallery_submit' ) );
|
||||
$form->hiddenValues['edit'] = $currentlyEditing;
|
||||
$form->class = 'ipsForm_vertical';
|
||||
|
||||
|
||||
/* Get the standard elements */
|
||||
foreach ( \IPS\gallery\Image::formElements( NULL, $category ) as $input )
|
||||
foreach ( \IPS\gallery\Image::formElements( NULL, $category, $currentlyEditing, $images[ $currentlyEditing ]->tempId ) as $input )
|
||||
{
|
||||
/* Skip auto-follow for this individual image (shown for all uploads instead) */
|
||||
if ( $input->name == 'image_auto_follow' )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* Set a value */
|
||||
if ( !$input->value )
|
||||
{
|
||||
if ( $input->name === 'image_title' )
|
||||
{
|
||||
$input->value = str_replace( "_", "-", $images[ $currentlyEditing ]->originalFilename );
|
||||
$input->value = $images[ $currentlyEditing ]->originalFilename;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,6 +664,8 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
/* Function to process each image */
|
||||
function( $offset ) use ( $data, $category, $album )
|
||||
{
|
||||
$offset = intval( $offset );
|
||||
|
||||
$existing = \IPS\Db::i()->select( '*', 'gallery_images_uploads', array( 'upload_session=?', session_id() ), 'upload_location', array( 0, 1 ) )->setKeyField( 'upload_location' );
|
||||
foreach( $existing as $location => $file )
|
||||
{
|
||||
@@ -650,7 +713,7 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
$image->markRead();
|
||||
|
||||
/* Delete that file */
|
||||
\IPS\Db::i()->delete( 'gallery_images_uploads', array( 'upload_session=?', session_id() ), 'upload_location', 1 );
|
||||
\IPS\Db::i()->delete( 'gallery_images_uploads', array( 'upload_unique_id=?', $file['upload_unique_id'] ) );
|
||||
|
||||
/* Go to next */
|
||||
return array( ++$offset, \IPS\Member::loggedIn()->language()->addToStack('processing'), 100 / count( $data['images'] ) * $offset );
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief View image
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Gallery
|
||||
* @since 04 Mar 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -28,6 +28,12 @@ class _view extends \IPS\Content\Controller
|
||||
* [Content\Controller] Class
|
||||
*/
|
||||
protected static $contentModel = 'IPS\gallery\Image';
|
||||
|
||||
/**
|
||||
* @brief Should views and item markers be updated by AJAX requests?
|
||||
* @note For Gallery images, AJAX requests handle the next/previous links and using those needs to mark as read, etc.
|
||||
*/
|
||||
protected $updateViewsAndMarkersOnAjax = TRUE;
|
||||
|
||||
/**
|
||||
* Init
|
||||
@@ -44,7 +50,7 @@ class _view extends \IPS\Content\Controller
|
||||
|
||||
if ( !$this->image->canView( \IPS\Member::loggedIn() ) )
|
||||
{
|
||||
\IPS\Output::i()->error( $this->image->container()->errorMessage(), '2G188/1', 404, '' );
|
||||
\IPS\Output::i()->error( $this->image->container()->errorMessage(), '2G188/1', 403, '' );
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
@@ -95,7 +101,7 @@ class _view extends \IPS\Content\Controller
|
||||
/* Set some meta tags */
|
||||
if( $this->image->media )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['og:video'] = $this->image->original_file_name;
|
||||
\IPS\Output::i()->metaTags['og:video'] = \IPS\File::get( 'gallery_Images', $this->image->original_file_name )->url;
|
||||
\IPS\Output::i()->metaTags['og:video:type'] = $this->image->file_type;
|
||||
\IPS\Output::i()->metaTags['og:type'] = 'video';
|
||||
|
||||
@@ -183,7 +189,13 @@ class _view extends \IPS\Content\Controller
|
||||
/* Store bandwidth log */
|
||||
if( \IPS\Settings::i()->gallery_detailed_bandwidth )
|
||||
{
|
||||
if( $this->image->media AND ( \IPS\Request::i()->imageSize == 'medium' OR !\IPS\Request::i()->imageSize ) AND $this->image->medium_file_name )
|
||||
/* Media items should get the file size of the original file instead of a thumbnail */
|
||||
if( $this->image->media )
|
||||
{
|
||||
$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 );
|
||||
}
|
||||
@@ -220,7 +232,7 @@ class _view extends \IPS\Content\Controller
|
||||
elseif( \IPS\Request::i()->isAjax() && isset( \IPS\Request::i()->browse ) )
|
||||
{
|
||||
$return = array(
|
||||
'title' => $this->image->mapped('title'),
|
||||
'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 )
|
||||
@@ -234,7 +246,7 @@ class _view extends \IPS\Content\Controller
|
||||
\IPS\Output::i()->json( $return );
|
||||
}
|
||||
/* Switching comments only */
|
||||
elseif( \IPS\Request::i()->isAjax() )
|
||||
elseif( \IPS\Request::i()->isAjax() AND !isset( \IPS\Request::i()->rating_submitted ) )
|
||||
{
|
||||
\IPS\Output::i()->output = $activeTabContents;
|
||||
return;
|
||||
@@ -323,6 +335,8 @@ class _view extends \IPS\Content\Controller
|
||||
\IPS\Output::i()->error( 'node_error', '2G188/3', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Determine angle to rotate */
|
||||
if( \IPS\Request::i()->direction == 'right' )
|
||||
{
|
||||
@@ -450,12 +464,12 @@ class _view extends \IPS\Content\Controller
|
||||
{
|
||||
$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';
|
||||
|
||||
$extraFields = array();
|
||||
|
||||
foreach ( \IPS\gallery\Album::formFields( NULL, TRUE, \IPS\Request::i()->move_to === 'new_album' ) as $field )
|
||||
{
|
||||
if ( !$field->htmlId )
|
||||
@@ -538,7 +552,7 @@ class _view extends \IPS\Content\Controller
|
||||
}
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2S136/D', 403, '' );
|
||||
\IPS\Output::i()->error( 'node_error', '2G188/B', 403, '' );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user