Version 5.0.0 beta 1
This commit is contained in:
1 parent
25ddeb65d6
commit
15c7beabc5
6736 files changed
+627902
-497943
No files matched your search
@@ -12,68 +12,86 @@
|
||||
namespace IPS\gallery\modules\admin\gallery;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher;
|
||||
use IPS\gallery\Album;
|
||||
use IPS\gallery\Album\Item;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
use function get_class;
|
||||
use function is_object;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Categories
|
||||
*/
|
||||
class _categories extends \IPS\Node\Controller
|
||||
class categories extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
protected $nodeClass = 'IPS\gallery\Category';
|
||||
protected string $nodeClass = 'IPS\gallery\Category';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'categories_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'categories_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
|
||||
protected function form()
|
||||
protected function form() : void
|
||||
{
|
||||
parent::form();
|
||||
|
||||
if ( \IPS\Request::i()->id )
|
||||
if ( Request::i()->id )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('edit_category') . ': ' . \IPS\Output::i()->title;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('edit_category') . ': ' . Output::i()->title;
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('add_category');
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('add_category');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Build the form to mass move content
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form helper object
|
||||
* @param Form $form The form helper object
|
||||
* @param mixed $data Data from the wizard helper
|
||||
* @param string $nodeClass Node class
|
||||
* @param \IPS\Node\Model $node Node we are working with
|
||||
* @param Model $node Node we are working with
|
||||
* @param string $contentItemClass Content item class (if there is one)
|
||||
* @return \IPS\Helpers\Form
|
||||
* @return Form
|
||||
*/
|
||||
protected function _buildMassMoveForm( $form, $data, $nodeClass, $node, $contentItemClass )
|
||||
protected function _buildMassMoveForm(Form $form, mixed $data, string $nodeClass, Model $node, string $contentItemClass ): Form
|
||||
{
|
||||
/* Add an option to move or delete albums - we won't worry about filters */
|
||||
$form->addHeader('node_mass_move_delete_albums');
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'node_move_subalbums', isset( $data['moveToAlbums'] ) ? $data['moveToClassAlbums']::load( $data['moveToAlbums'] ) : 0, TRUE, array( 'class' => $nodeClass, 'disabled' => array( $node->_id ), 'disabledLang' => 'node_move_delete', 'clubs' => TRUE, 'zeroVal' => 'node_delete_content', 'subnodes' => FALSE, 'permissionCheck' => function( $node )
|
||||
$form->add( new Node( 'node_move_subalbums', isset( $data['moveToAlbums'] ) ? $data['moveToClassAlbums']::load( $data['moveToAlbums'] ) : 0, TRUE, array( 'class' => $nodeClass, 'disabled' => array( $node->_id ), 'disabledLang' => 'node_move_delete', 'clubs' => TRUE, 'zeroVal' => 'node_delete_content', 'subnodes' => FALSE, 'permissionCheck' => function( $node )
|
||||
{
|
||||
return $node->can('add');
|
||||
} ) ) );
|
||||
@@ -87,18 +105,18 @@ class _categories extends \IPS\Node\Controller
|
||||
* @param array $values Values from form submission
|
||||
* @param mixed $data Data from the wizard helper
|
||||
* @param string $nodeClass Node class
|
||||
* @param \IPS\Node\Model $node Node we are working with
|
||||
* @param Model $node Node we are working with
|
||||
* @param string $contentItemClass Content item class (if there is one)
|
||||
* @return array Wizard helper data
|
||||
*/
|
||||
protected function _processMassMoveForm( $values, $data, $nodeClass, $node, $contentItemClass )
|
||||
protected function _processMassMoveForm(array $values, mixed $data, string $nodeClass, Model $node, string $contentItemClass ): array
|
||||
{
|
||||
$data = parent::_processMassMoveForm( $values, $data, $nodeClass, $node, $contentItemClass );
|
||||
|
||||
/* What are we doing with the albums? */
|
||||
if ( \is_object( $values['node_move_subalbums'] ) )
|
||||
if ( is_object( $values['node_move_subalbums'] ) )
|
||||
{
|
||||
$data['moveToClassAlbums'] = \get_class( $values['node_move_subalbums'] );
|
||||
$data['moveToClassAlbums'] = get_class( $values['node_move_subalbums'] );
|
||||
$data['moveToAlbums'] = $values['node_move_subalbums']->_id;
|
||||
}
|
||||
else
|
||||
@@ -114,21 +132,22 @@ class _categories extends \IPS\Node\Controller
|
||||
* Actually perform the mass move operation (called from the wizard helper)
|
||||
*
|
||||
* @param mixed $data Data from the wizard helper
|
||||
* @param \IPS\Node\Model $node Node we are working with
|
||||
* @param Model $node Node we are working with
|
||||
* @param string $contentItemClass Content item class (if there is one)
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _performMassMove( $data, $node, $contentItemClass )
|
||||
protected function _performMassMove( mixed $data, Model $node, string $contentItemClass ): mixed
|
||||
{
|
||||
/* If we have confirmed the move, just handle albums now and then pass to the parent */
|
||||
if ( isset( \IPS\Request::i()->confirm ) )
|
||||
if ( isset( Request::i()->confirm ) )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
/* Loop over our albums */
|
||||
foreach( \IPS\gallery\Album\Item::getItemsWithPermission( array( array( 'album_category_id=?', $node->_id ) ), NULL, 1000, NULL, TRUE, 0, NULL, FALSE, FALSE, FALSE, FALSE, NULL, TRUE, FALSE, FALSE, FALSE ) as $album )
|
||||
foreach( Item::getItemsWithPermission( array( array( 'album_category_id=?', $node->_id ) ), NULL, 1000, NULL, TRUE, 0, NULL, FALSE, FALSE, FALSE, FALSE, NULL, TRUE, FALSE, FALSE, FALSE ) as $albumItem )
|
||||
{
|
||||
$album = $album->asNode();
|
||||
/* @var Album $album */
|
||||
$album = $albumItem->asNode();
|
||||
|
||||
/* Are we moving albums? */
|
||||
if ( isset( $data['moveToAlbums'] ) )
|
||||
@@ -138,18 +157,18 @@ class _categories extends \IPS\Node\Controller
|
||||
else
|
||||
{
|
||||
/* Store the task for deleting */
|
||||
\IPS\Task::queue( 'core', 'DeleteOrMoveContent', array( 'class' => 'IPS\gallery\Category', 'id' => $album->_id, 'deleteWhenDone' => FALSE ) );
|
||||
Task::queue( 'core', 'DeleteOrMoveContent', array( 'class' => 'IPS\gallery\Category', 'id' => $album->_id, 'deleteWhenDone' => FALSE ) );
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $data['moveToAlbums'] ) )
|
||||
{
|
||||
$newNode = $data['moveToClassAlbums']::load( $data['moveToAlbums'] );
|
||||
\IPS\Session::i()->log( 'acplog__catalbum_mass_move', array( $this->title => TRUE, $node->titleForLog() => FALSE, $newNode->titleForLog() => FALSE ) );
|
||||
Session::i()->log( 'acplog__catalbum_mass_move', array( $this->title => TRUE, $node->titleForLog() => FALSE, $newNode->titleForLog() => FALSE ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Session::i()->log( 'acplog__catalbum_mass_delete', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
Session::i()->log( 'acplog__catalbum_mass_delete', array( $this->title => TRUE, $node->titleForLog() => FALSE ) );
|
||||
}
|
||||
|
||||
/* Then let the parent take over */
|
||||
@@ -158,12 +177,12 @@ class _categories extends \IPS\Node\Controller
|
||||
/* Otherwise show a slightly more useful confirmation message */
|
||||
else
|
||||
{
|
||||
$albumCount = \IPS\gallery\Album\Item::getItemsWithPermission( array( array( 'album_category_id=?', $node->_id ) ), NULL, 1000, NULL, TRUE, 0, NULL, FALSE, FALSE, FALSE, TRUE, NULL, TRUE, FALSE, FALSE, FALSE );
|
||||
$albumCount = Item::getItemsWithPermission( array( array( 'album_category_id=?', $node->_id ) ), NULL, 1000, NULL, TRUE, 0, NULL, FALSE, FALSE, FALSE, TRUE, NULL, TRUE, FALSE, FALSE, FALSE );
|
||||
|
||||
$itemDeletionWhere = $node->massMoveorDeleteWhere( $data );
|
||||
$itemDeletionWhere[] = array( 'image_album_id=?', 0 );
|
||||
|
||||
return \IPS\Theme::i()->getTemplate( 'global', 'gallery' )->nodeMoveDeleteContent( $this->url->setQueryString( array( 'do' => 'massManageContent', 'id' => $node->_id ) )->csrf(), \IPS\Member::loggedIn()->language()->addToStack( $contentItemClass::$title . '_pl_lc' ), $node->getContentItems( NULL, NULL, $itemDeletionWhere, TRUE ), isset( $data['moveTo'] ) ? $data['moveToClass']::load( $data['moveTo'] ) : NULL, $albumCount, isset( $data['moveToAlbums'] ) ? $data['moveToClassAlbums']::load( $data['moveToAlbums'] ) : NULL );
|
||||
return Theme::i()->getTemplate( 'global', 'gallery' )->nodeMoveDeleteContent( $this->url->setQueryString( array( 'do' => 'massManageContent', 'id' => $node->_id ) )->csrf(), Member::loggedIn()->language()->addToStack( $contentItemClass::$title . '_pl_lc' ), $node->getContentItems( NULL, NULL, $itemDeletionWhere, TRUE ), isset( $data['moveTo'] ) ? $data['moveToClass']::load( $data['moveTo'] ) : NULL, $albumCount, isset( $data['moveToAlbums'] ) ? $data['moveToClassAlbums']::load( $data['moveToAlbums'] ) : NULL );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,30 +12,54 @@
|
||||
namespace IPS\gallery\modules\admin\gallery;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\File;
|
||||
use IPS\GeoLocation;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Helpers\Form\Interval;
|
||||
use IPS\Helpers\Form\Number;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Form\Upload;
|
||||
use IPS\Helpers\Form\WidthHeight;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings as SettingsClass;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* settings
|
||||
*/
|
||||
class _settings extends \IPS\Dispatcher\Controller
|
||||
class settings extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'settings_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'settings_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -44,7 +68,7 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$form = $this->_getForm();
|
||||
|
||||
@@ -52,39 +76,39 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
{
|
||||
$this->_saveSettingsForm( $form, $values );
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=settings' ), 'saved' );
|
||||
Output::i()->redirect( Url::internal( 'app=gallery&module=gallery&controller=settings' ), 'saved' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('settings');
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('settings');
|
||||
Output::i()->output = $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build and return the settings form
|
||||
*
|
||||
* @note Abstracted to allow third party devs to extend easier
|
||||
* @return \IPS\Helpers\Form
|
||||
* @return Form
|
||||
*/
|
||||
protected function _getForm()
|
||||
protected function _getForm(): Form
|
||||
{
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form = new Form;
|
||||
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_settings.js', 'gallery', 'admin' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, 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->hiddenValues['rebuildWatermarkScreenshots'] = Request::i()->rebuildWatermarkScreenshots ?: 0;
|
||||
|
||||
$form->addTab( 'basic_settings' );
|
||||
$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 );
|
||||
$small = ( isset( \IPS\Settings::i()->gallery_small_dims ) ) ? explode( 'x', \IPS\Settings::i()->gallery_small_dims ) : array( 240, 240 );
|
||||
$form->add( new \IPS\Helpers\Form\WidthHeight( 'gallery_large_dims', $large, 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\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' ) );
|
||||
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'gallery_watermark_images',
|
||||
\IPS\Settings::i()->gallery_watermark_images ? explode( ',', \IPS\Settings::i()->gallery_watermark_images ) : array(),
|
||||
$form->addHtml( Theme::i()->getTemplate( 'forms', 'core' )->blurb( 'gallery_dims_explanation', true, true )) ;
|
||||
$large = ( isset( SettingsClass::i()->gallery_large_dims ) ) ? explode( 'x', SettingsClass::i()->gallery_large_dims ) : array( 1600, 1200 );
|
||||
$small = ( isset( SettingsClass::i()->gallery_small_dims ) ) ? explode( 'x', SettingsClass::i()->gallery_small_dims ) : array( 240, 240 );
|
||||
$form->add( new WidthHeight( 'gallery_large_dims', $large, TRUE, array( 'resizableDiv' => FALSE ) ) );
|
||||
$form->add( new WidthHeight( 'gallery_small_dims', $small, TRUE, array( 'resizableDiv' => FALSE ) ) );
|
||||
$form->add( new YesNo( 'gallery_use_square_thumbnails', SettingsClass::i()->gallery_use_square_thumbnails ) );
|
||||
$form->add( new YesNo( 'gallery_use_watermarks', SettingsClass::i()->gallery_use_watermarks, FALSE, array( 'togglesOn' => array( 'gallery_watermark_path', 'gallery_watermark_images' ) ) ) );
|
||||
$form->add( new Upload( 'gallery_watermark_path', SettingsClass::i()->gallery_watermark_path ? File::get( 'core_Theme', SettingsClass::i()->gallery_watermark_path ) : NULL, FALSE, array( 'image' => TRUE, 'storageExtension' => 'core_Theme' ), NULL, NULL, NULL, 'gallery_watermark_path' ) );
|
||||
$form->add( new CheckboxSet( 'gallery_watermark_images',
|
||||
SettingsClass::i()->gallery_watermark_images ? explode( ',', SettingsClass::i()->gallery_watermark_images ) : array(),
|
||||
FALSE,
|
||||
array(
|
||||
'multiple' => TRUE,
|
||||
@@ -97,42 +121,42 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
) );
|
||||
|
||||
$form->addHeader( 'gallery_bandwidth' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_detailed_bandwidth', \IPS\Settings::i()->gallery_detailed_bandwidth ) );
|
||||
$form->add( new \IPS\Helpers\Form\Interval( 'gallery_bandwidth_period', \IPS\Settings::i()->gallery_bandwidth_period, FALSE, array( 'valueAs' => \IPS\Helpers\Form\Interval::HOURS, 'min' => NULL, 'unlimited' => -1 ), NULL, NULL, NULL, 'easypost_delivery_adjustment' ) );
|
||||
$form->add( new YesNo( 'gallery_detailed_bandwidth', SettingsClass::i()->gallery_detailed_bandwidth ) );
|
||||
$form->add( new Interval( 'gallery_bandwidth_period', SettingsClass::i()->gallery_bandwidth_period, FALSE, array( 'valueAs' => Interval::HOURS, 'min' => NULL, 'unlimited' => -1 ), NULL, NULL, NULL, 'gallery_bandwidth_period' ) );
|
||||
|
||||
$form->addHeader( 'gallery_options' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_rss_enabled', \IPS\Settings::i()->gallery_rss_enabled ) );
|
||||
$form->add( new YesNo( 'gallery_rss_enabled', SettingsClass::i()->gallery_rss_enabled ) );
|
||||
|
||||
if( \IPS\GeoLocation::enabled() )
|
||||
if( GeoLocation::enabled() )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_maps_default', \IPS\Settings::i()->gallery_maps_default ) );
|
||||
$form->add( new YesNo( 'gallery_maps_default', SettingsClass::i()->gallery_maps_default ) );
|
||||
}
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_nsfw', \IPS\Settings::i()->gallery_nsfw ) );
|
||||
$form->add( new YesNo( 'gallery_nsfw', SettingsClass::i()->gallery_nsfw ) );
|
||||
|
||||
$form->addTab( 'gallery_overview_settings' );
|
||||
$form->addHeader( 'gallery_featured_images' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_overview_show_carousel', \IPS\Settings::i()->gallery_overview_show_carousel, FALSE, array( 'togglesOn' => array( 'gallery_overview_carousel_count', 'gallery_overview_carousel_type' ) ) ) );
|
||||
$form->add( new YesNo( 'gallery_overview_show_carousel', SettingsClass::i()->gallery_overview_show_carousel, FALSE, array( 'togglesOn' => array( 'gallery_overview_carousel_count', 'gallery_overview_carousel_type' ) ) ) );
|
||||
$options = array(
|
||||
'featured' => 'gallery_overview_carousel_featured',
|
||||
'new' => 'gallery_overview_carousel_new'
|
||||
);
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'gallery_overview_carousel_type', \IPS\Settings::i()->gallery_overview_carousel_type, TRUE, array( 'options' => $options ), NULL, NULL, NULL, 'gallery_overview_carousel_type' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'gallery_overview_carousel_count', \IPS\Settings::i()->gallery_overview_carousel_count, FALSE, array(), NULL, NULL, NULL, 'gallery_overview_carousel_count' ) );
|
||||
$form->add( new Radio( 'gallery_overview_carousel_type', SettingsClass::i()->gallery_overview_carousel_type, TRUE, array( 'options' => $options ), NULL, NULL, NULL, 'gallery_overview_carousel_type' ) );
|
||||
$form->add( new Number( 'gallery_overview_carousel_count', SettingsClass::i()->gallery_overview_carousel_count, FALSE, array(), NULL, NULL, NULL, 'gallery_overview_carousel_count' ) );
|
||||
|
||||
$form->addHeader( 'gallery_overview_recent_comments' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_show_recent_comments', \IPS\Settings::i()->gallery_show_recent_comments, FALSE, array() ) );
|
||||
$form->add( new YesNo( 'gallery_show_recent_comments', SettingsClass::i()->gallery_show_recent_comments, FALSE, array() ) );
|
||||
|
||||
$form->addHeader('gallery_overview_categories');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_overview_show_categories', \IPS\Settings::i()->gallery_overview_show_categories, FALSE, array() ) );
|
||||
$form->add( new YesNo( 'gallery_overview_show_categories', SettingsClass::i()->gallery_overview_show_categories, FALSE, array() ) );
|
||||
|
||||
$form->addHeader( 'gallery_overview_recent_updated_albums' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_show_recent_updated_albums', \IPS\Settings::i()->gallery_show_recent_updated_albums, FALSE, array( 'togglesOn' => array( 'gallery_recent_updated_albums_count' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'gallery_recent_updated_albums_count', \IPS\Settings::i()->gallery_recent_updated_albums_count, FALSE, array(), NULL, NULL, NULL, 'gallery_recent_updated_albums_count' ) );
|
||||
$form->add( new YesNo( 'gallery_show_recent_updated_albums', SettingsClass::i()->gallery_show_recent_updated_albums, FALSE, array( 'togglesOn' => array( 'gallery_recent_updated_albums_count' ) ) ) );
|
||||
$form->add( new Number( 'gallery_recent_updated_albums_count', SettingsClass::i()->gallery_recent_updated_albums_count, FALSE, array(), NULL, NULL, NULL, 'gallery_recent_updated_albums_count' ) );
|
||||
|
||||
$form->addHeader( 'gallery_overview_new_images' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'gallery_show_new_images', \IPS\Settings::i()->gallery_show_new_images, FALSE, array( 'togglesOn' => array( 'gallery_new_images_count' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Number( 'gallery_new_images_count', \IPS\Settings::i()->gallery_new_images_count, FALSE, array(), NULL, NULL, NULL, 'gallery_new_images_count' ) );
|
||||
$form->add( new YesNo( 'gallery_show_new_images', SettingsClass::i()->gallery_show_new_images, FALSE, array( 'togglesOn' => array( 'gallery_new_images_count' ) ) ) );
|
||||
$form->add( new Number( 'gallery_new_images_count', SettingsClass::i()->gallery_new_images_count, FALSE, array(), NULL, NULL, NULL, 'gallery_new_images_count' ) );
|
||||
|
||||
return $form;
|
||||
}
|
||||
@@ -140,10 +164,10 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Save the settings form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The Form Object
|
||||
* @param Form $form The Form Object
|
||||
* @param array $values Values
|
||||
*/
|
||||
protected function _saveSettingsForm( \IPS\Helpers\Form $form, array $values )
|
||||
protected function _saveSettingsForm( Form $form, array $values ) : void
|
||||
{
|
||||
$form->saveAsSettings( array(
|
||||
'gallery_large_dims' => implode( 'x', $values['gallery_large_dims'] ),
|
||||
@@ -168,12 +192,12 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
'gallery_new_images_count' => $values['gallery_new_images_count'],
|
||||
) );
|
||||
|
||||
\IPS\Session::i()->log( 'acplogs__gallery_settings' );
|
||||
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 );
|
||||
Db::i()->delete( 'core_queue', array( '`app`=? OR `key`=?', 'gallery', 'RebuildGalleryImages' ) );
|
||||
Task::queue( 'gallery', 'RebuildGalleryImages', array( ), 2 );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,35 +12,44 @@
|
||||
namespace IPS\gallery\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\core\Statistics\Chart;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gallery bandwidth statistics
|
||||
*/
|
||||
class _bandwidth extends \IPS\Dispatcher\Controller
|
||||
class bandwidth extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'bandwidth_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'bandwidth_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -49,9 +58,9 @@ class _bandwidth extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('bandwidth_stats');
|
||||
\IPS\Output::i()->output = (string) \IPS\core\Statistics\Chart::loadFromExtension( 'gallery', 'Bandwidth' )->getChart( \IPS\Http\Url::internal( "app=gallery&module=stats&controller=bandwidth" ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('bandwidth_stats');
|
||||
Output::i()->output = (string) Chart::loadFromExtension( 'gallery', 'Bandwidth' )->getChart( Url::internal( "app=gallery&module=stats&controller=bandwidth" ) );
|
||||
}
|
||||
}
|
||||
@@ -12,37 +12,54 @@
|
||||
namespace IPS\gallery\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\DateRange;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Theme;
|
||||
use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function intval;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Top uploaders
|
||||
*/
|
||||
class _diskspace extends \IPS\Dispatcher\Controller
|
||||
class diskspace extends Controller
|
||||
{
|
||||
const PER_PAGE = 25;
|
||||
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
\IPS\Dispatcher::i()->checkAcpPermission( 'diskspace_manage' );
|
||||
Dispatcher::i()->checkAcpPermission( 'diskspace_manage' );
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
@@ -51,32 +68,32 @@ class _diskspace extends \IPS\Dispatcher\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
$where = array();
|
||||
|
||||
if ( isset( \IPS\Request::i()->form ) )
|
||||
if ( isset( Request::i()->form ) )
|
||||
{
|
||||
$form = new \IPS\Helpers\Form( 'form', 'go' );
|
||||
$form = new Form( 'form', 'go' );
|
||||
|
||||
$default = array(
|
||||
'start' => \IPS\Request::i()->start ? \IPS\DateTime::ts( \IPS\Request::i()->start ) : NULL,
|
||||
'end' => \IPS\Request::i()->end ? \IPS\DateTime::ts( \IPS\Request::i()->end ) : NULL
|
||||
'start' => Request::i()->start ? DateTime::ts( Request::i()->start ) : NULL,
|
||||
'end' => Request::i()->end ? DateTime::ts( Request::i()->end ) : NULL
|
||||
);
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => \IPS\DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
|
||||
$form->add( new DateRange( 'stats_date_range', $default, FALSE, array( 'start' => array( 'max' => DateTime::ts( time() )->setTime( 0, 0, 0 ), 'time' => FALSE ), 'end' => array( 'max' => DateTime::ts( time() )->setTime( 23, 59, 59 ), 'time' => FALSE ) ) ) );
|
||||
|
||||
if ( !$values = $form->values() )
|
||||
{
|
||||
\IPS\Output::i()->output = $form;
|
||||
Output::i()->output = $form;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/* Figure out start and end parameters for links */
|
||||
$params = array(
|
||||
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : \IPS\Request::i()->start,
|
||||
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : \IPS\Request::i()->end
|
||||
'start' => !empty( $values['stats_date_range']['start'] ) ? $values['stats_date_range']['start']->getTimestamp() : Request::i()->start,
|
||||
'end' => !empty( $values['stats_date_range']['end'] ) ? $values['stats_date_range']['end']->getTimestamp() : Request::i()->end
|
||||
);
|
||||
|
||||
if( $params['start'] )
|
||||
@@ -89,7 +106,7 @@ class _diskspace extends \IPS\Dispatcher\Controller
|
||||
$where[] = array( 'image_date<?', $params['end'] );
|
||||
}
|
||||
|
||||
$page = isset( \IPS\Request::i()->page ) ? \intval( \IPS\Request::i()->page ) : 1;
|
||||
$page = isset( Request::i()->page ) ? intval( Request::i()->page ) : 1;
|
||||
|
||||
if( $page < 1 )
|
||||
{
|
||||
@@ -97,16 +114,16 @@ class _diskspace extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
try
|
||||
{
|
||||
$total = \IPS\Db::i()->select( 'COUNT(DISTINCT(image_member_id))', 'gallery_images', $where )->first();
|
||||
$total = Db::i()->select( 'COUNT(DISTINCT(image_member_id))', 'gallery_images', $where )->first();
|
||||
}
|
||||
catch( \UnderflowException $e )
|
||||
catch( UnderflowException )
|
||||
{
|
||||
$total = 0;
|
||||
}
|
||||
|
||||
if( $total > 0 )
|
||||
{
|
||||
$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' )->join( 'core_members', 'core_members.member_id=gallery_images.image_member_id' );
|
||||
$select = 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' )->join( 'core_members', 'core_members.member_id=gallery_images.image_member_id' );
|
||||
$mids = array();
|
||||
|
||||
foreach( $select as $row )
|
||||
@@ -115,35 +132,35 @@ class _diskspace extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
$members = array();
|
||||
if ( \count( $mids ) )
|
||||
if ( count( $mids ) )
|
||||
{
|
||||
$members = iterator_to_array( \IPS\Db::i()->select( '*', 'core_members', array( \IPS\Db::i()->in( 'member_id', $mids ) ) )->setKeyField('member_id') );
|
||||
$members = iterator_to_array( Db::i()->select( '*', 'core_members', array( 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( $params ),
|
||||
$pagination = Theme::i()->getTemplate( 'global', 'core', 'global' )->pagination(
|
||||
Url::internal( 'app=gallery&module=stats&controller=diskspace' )->setQueryString( $params ),
|
||||
ceil( $total / static::PER_PAGE ),
|
||||
$page,
|
||||
static::PER_PAGE,
|
||||
FALSE
|
||||
);
|
||||
|
||||
\IPS\Output::i()->sidebar['actions'] = array(
|
||||
Output::i()->sidebar['actions'] = array(
|
||||
'settings' => array(
|
||||
'title' => 'stats_date_range',
|
||||
'icon' => 'calendar',
|
||||
'link' => \IPS\Http\Url::internal( 'app=gallery&module=stats&controller=diskspace&form=1' )->setQueryString( $params ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('stats_date_range') )
|
||||
'link' => Url::internal( 'app=gallery&module=stats&controller=diskspace&form=1' )->setQueryString( $params ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => Member::loggedIn()->language()->addToStack('stats_date_range') )
|
||||
)
|
||||
);
|
||||
\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, $total );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__gallery_stats_diskspace');
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->message( Member::loggedIn()->language()->addToStack( 'stats_include_hidden_content' ), 'info' );
|
||||
Output::i()->output .= Theme::i()->getTemplate('stats')->uploadersTable( $select, $pagination, $members, $total );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('menu__gallery_stats_diskspace');
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Return the no results message */
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack('menu__gallery_stats_diskspace'), \IPS\Member::loggedIn()->language()->addToStack('no_results'), FALSE , 'ipsPad', NULL, TRUE );
|
||||
Output::i()->output .= Theme::i()->getTemplate( 'global', 'core' )->block( Member::loggedIn()->language()->addToStack('menu__gallery_stats_diskspace'), Member::loggedIn()->language()->addToStack('no_results'), FALSE , 'i-padding_3', NULL, TRUE );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,34 +12,41 @@
|
||||
namespace IPS\gallery\modules\admin\stats;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Member Stats
|
||||
*/
|
||||
class _member extends \IPS\Dispatcher\Controller
|
||||
class member extends Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
public static bool $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* @brief Allow MySQL RW separation for efficiency
|
||||
*/
|
||||
public static $allowRWSeparation = TRUE;
|
||||
public static bool $allowRWSeparation = TRUE;
|
||||
|
||||
/**
|
||||
* Images
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function images()
|
||||
protected function images() : void
|
||||
{
|
||||
\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") );
|
||||
Output::i()->redirect( Url::internal("app=core&module=members&controller=members&do=view&id=" . Request::i()->id . "&blockKey=core_ContentStatistics&block[core_ContentStatistics]=gallery_Gallery") );
|
||||
}
|
||||
}
|
||||
@@ -12,150 +12,182 @@
|
||||
namespace IPS\gallery\modules\front\gallery;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content\Controller;
|
||||
use IPS\Content\Filter;
|
||||
use IPS\core\DataLayer;
|
||||
use IPS\core\Facebook\Pixel;
|
||||
use IPS\core\FrontNavigation;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\gallery\Album;
|
||||
use IPS\gallery\Album\Item;
|
||||
use IPS\gallery\Album\Table as AlbumTable;
|
||||
use IPS\gallery\Application;
|
||||
use IPS\gallery\Category;
|
||||
use IPS\gallery\Image;
|
||||
use IPS\gallery\Image\Table;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Node;
|
||||
use IPS\Helpers\Form\YesNo;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use IPS\Settings;
|
||||
use IPS\Task;
|
||||
use IPS\Theme;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Browse the gallery
|
||||
*/
|
||||
class _browse extends \IPS\Content\Controller
|
||||
class browse extends Controller
|
||||
{
|
||||
/**
|
||||
* [Content\Controller] Class
|
||||
*/
|
||||
protected static $contentModel = 'IPS\gallery\Category';
|
||||
protected static string $contentModel = 'IPS\gallery\Category';
|
||||
|
||||
/**
|
||||
* Execute
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function execute()
|
||||
public function execute() : void
|
||||
{
|
||||
if( isset( \IPS\Request::i()->album ) )
|
||||
if( isset( Request::i()->album ) )
|
||||
{
|
||||
\IPS\Request::i()->id = \IPS\Request::i()->album;
|
||||
static::$contentModel = ( isset( \IPS\Request::i()->do ) ) ? 'IPS\gallery\Album\Item' : 'IPS\gallery\Album';
|
||||
Request::i()->id = Request::i()->album;
|
||||
static::$contentModel = ( isset( Request::i()->do ) ) ? 'IPS\gallery\Album\Item' : 'IPS\gallery\Album';
|
||||
}
|
||||
|
||||
/* Gallery uses caption for title */
|
||||
\IPS\Member::loggedIn()->language()->words[ "sort_title" ] = \IPS\Member::loggedIn()->language()->addToStack( "album_sort_caption", FALSE );
|
||||
Member::loggedIn()->language()->words[ "sort_title" ] = 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' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_global.js', 'gallery' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js('front_submit.js', 'gallery' ) );
|
||||
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js('front_global.js', 'gallery' ) );
|
||||
|
||||
\IPS\gallery\Application::outputCss();
|
||||
Application::outputCss();
|
||||
parent::execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine what to show
|
||||
*
|
||||
* @return void
|
||||
* @return mixed
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : mixed
|
||||
{
|
||||
/* Legacy 3.x redirect */
|
||||
if ( isset( \IPS\Request::i()->image ) )
|
||||
if ( isset( Request::i()->image ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\gallery\Image::loadAndCheckPerms( \IPS\Request::i()->image )->url(), '', 301 );
|
||||
Output::i()->redirect( Image::loadAndCheckPerms( Request::i()->image )->url() );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G189/A', 404, '' );
|
||||
Output::i()->error( 'node_error', '2G189/A', 404, '' );
|
||||
}
|
||||
}
|
||||
|
||||
/* Add RSS feed */
|
||||
if ( \IPS\Settings::i()->gallery_rss_enabled )
|
||||
if ( Settings::i()->gallery_rss_enabled )
|
||||
{
|
||||
\IPS\Output::i()->rssFeeds['gallery_rss_title'] = \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse&do=rss', 'front', 'gallery_rss' );
|
||||
Output::i()->rssFeeds['gallery_rss_title'] = Url::internal( 'app=gallery&module=gallery&controller=browse&do=rss', 'front', 'gallery_rss' );
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
if ( Member::loggedIn()->member_id )
|
||||
{
|
||||
$key = \IPS\Member::loggedIn()->getUniqueMemberHash();
|
||||
$key = Member::loggedIn()->getUniqueMemberHash();
|
||||
|
||||
\IPS\Output::i()->rssFeeds['gallery_rss_title'] = \IPS\Output::i()->rssFeeds['gallery_rss_title']->setQueryString( array( 'member' => \IPS\Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
Output::i()->rssFeeds['gallery_rss_title'] = Output::i()->rssFeeds['gallery_rss_title']->setQueryString( array( 'member' => Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
}
|
||||
}
|
||||
|
||||
/* And load data and display */
|
||||
if ( isset( \IPS\Request::i()->category ) )
|
||||
if ( isset( Request::i()->category ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$category = \IPS\gallery\Category::loadAndCheckPerms( \IPS\Request::i()->category, 'view' );
|
||||
$category = Category::loadAndCheckPerms( Request::i()->category );
|
||||
|
||||
$category->clubCheckRules();
|
||||
|
||||
/* 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" ) )
|
||||
if( !$category->can( 'read' ) AND Member::loggedIn()->language()->checkKeyExists( "gallery_category_{$category->id}_permerror" ) )
|
||||
{
|
||||
\IPS\Output::i()->error( $category->errorMessage(), '1G189/B', 403, '' );
|
||||
Output::i()->error( $category->errorMessage(), '1G189/B', 403, '' );
|
||||
}
|
||||
|
||||
/* Add RSS feed */
|
||||
if ( \IPS\Settings::i()->gallery_rss_enabled )
|
||||
if ( Settings::i()->gallery_rss_enabled )
|
||||
{
|
||||
$rssUrl = \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse&do=rss&category=' . $category->id, 'front', 'gallery_rss' );
|
||||
$rssUrl = Url::internal( 'app=gallery&module=gallery&controller=browse&do=rss&category=' . $category->id, 'front', 'gallery_rss' );
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
if ( Member::loggedIn()->member_id )
|
||||
{
|
||||
$key = md5( ( \IPS\Member::loggedIn()->members_pass_hash ?: \IPS\Member::loggedIn()->email ) . \IPS\Member::loggedIn()->members_pass_salt );
|
||||
$key = md5( ( Member::loggedIn()->members_pass_hash ?: Member::loggedIn()->email ) . Member::loggedIn()->members_pass_salt );
|
||||
|
||||
$rssUrl = $rssUrl->setQueryString( array( 'member' => \IPS\Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
$rssUrl = $rssUrl->setQueryString( array( 'member' => Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->rssFeeds[ \IPS\Member::loggedIn()->language()->addToStack( 'gallery_rss_title_container', FALSE, array( 'sprintf' => array( $category->_title ) ) ) ] = $rssUrl;
|
||||
Output::i()->rssFeeds[ Member::loggedIn()->language()->addToStack( 'gallery_rss_title_container', FALSE, array( 'sprintf' => array( $category->_title ) ) ) ] = $rssUrl;
|
||||
}
|
||||
|
||||
$this->_category( $category );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G189/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2G189/1', 404, '' );
|
||||
}
|
||||
}
|
||||
else if ( isset( \IPS\Request::i()->album ) )
|
||||
else if ( isset( Request::i()->album ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$album = \IPS\gallery\Album::loadAndCheckPerms( \IPS\Request::i()->album, 'view' );
|
||||
$album = Album::loadAndCheckPerms( Request::i()->album );
|
||||
|
||||
$album->category()->clubCheckRules();
|
||||
|
||||
|
||||
$album->asItem()->updateViews();
|
||||
|
||||
/* Add RSS feed */
|
||||
if ( \IPS\Settings::i()->gallery_rss_enabled )
|
||||
if ( Settings::i()->gallery_rss_enabled )
|
||||
{
|
||||
$rssUrl = \IPS\Http\Url::internal('app=gallery&module=gallery&controller=browse&do=rss&album=' . $album->id, 'front', 'gallery_rss');
|
||||
$rssUrl = Url::internal('app=gallery&module=gallery&controller=browse&do=rss&album=' . $album->id, 'front', 'gallery_rss');
|
||||
|
||||
if ( \IPS\Member::loggedIn()->member_id )
|
||||
if ( Member::loggedIn()->member_id )
|
||||
{
|
||||
$key = md5( ( \IPS\Member::loggedIn()->members_pass_hash ?: \IPS\Member::loggedIn()->email ) . \IPS\Member::loggedIn()->members_pass_salt );
|
||||
$key = md5( ( Member::loggedIn()->members_pass_hash ?: Member::loggedIn()->email ) . Member::loggedIn()->members_pass_salt );
|
||||
|
||||
$rssUrl = $rssUrl->setQueryString( array( 'member' => \IPS\Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
$rssUrl = $rssUrl->setQueryString( array( 'member' => Member::loggedIn()->member_id , 'key' => $key ) );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->rssFeeds[ \IPS\Member::loggedIn()->language()->addToStack( 'gallery_rss_title_container', FALSE, array( 'sprintf' => array( $album->_title ) ) ) ] = $rssUrl;
|
||||
Output::i()->rssFeeds[ Member::loggedIn()->language()->addToStack( 'gallery_rss_title_container', FALSE, array( 'sprintf' => array( $album->_title ) ) ) ] = $rssUrl;
|
||||
}
|
||||
$this->_album( $album );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G189/2', 404, '' );
|
||||
Output::i()->error( 'node_error', '2G189/2', 404, '' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->_index();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -163,30 +195,31 @@ class _browse extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function unsetCoverPhoto()
|
||||
protected function unsetCoverPhoto() : void
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
if( \IPS\Request::i()->category )
|
||||
$container = null;
|
||||
if( Request::i()->category )
|
||||
{
|
||||
$container = \IPS\gallery\Category::loadAndCheckPerms( \IPS\Request::i()->category, 'view' );
|
||||
$container = Category::loadAndCheckPerms( Request::i()->category );
|
||||
}
|
||||
elseif( \IPS\Request::i()->album )
|
||||
elseif( Request::i()->album )
|
||||
{
|
||||
$container = \IPS\gallery\Album::loadAndCheckPerms( \IPS\Request::i()->album, 'view' );
|
||||
$container = Album::loadAndCheckPerms( Request::i()->album );
|
||||
}
|
||||
|
||||
if( \IPS\gallery\Image::modPermission( 'edit', \IPS\Member::loggedIn(), $container ) )
|
||||
if( $container AND Image::modPermission( 'edit', Member::loggedIn(), $container ) )
|
||||
{
|
||||
$container->cover_img_id = 0;
|
||||
$container->save();
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->error( 'gallery_unset_cover_error', '2G189/E', 403, '' );
|
||||
Output::i()->error( 'gallery_unset_cover_error', '2G189/E', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( $container->url(), 'gallery_cover_photo_isunset' );
|
||||
Output::i()->redirect( $container->url(), 'gallery_cover_photo_isunset' );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -194,53 +227,53 @@ class _browse extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function _index()
|
||||
protected function _index() : void
|
||||
{
|
||||
/* Get stuff */
|
||||
$featured = array();
|
||||
if( \IPS\Settings::i()->gallery_overview_show_carousel )
|
||||
if( Settings::i()->gallery_overview_show_carousel )
|
||||
{
|
||||
switch( \IPS\Settings::i()->gallery_overview_carousel_type )
|
||||
switch( Settings::i()->gallery_overview_carousel_type )
|
||||
{
|
||||
case 'featured':
|
||||
$featured = iterator_to_array( \IPS\gallery\Image::featured( \IPS\Settings::i()->gallery_overview_carousel_count, NULL ) );
|
||||
$featured = iterator_to_array( Image::featured( Settings::i()->gallery_overview_carousel_count, NULL ) );
|
||||
break;
|
||||
|
||||
case 'new':
|
||||
$featured = \IPS\gallery\Image::getItemsWithPermission( \IPS\gallery\Image::clubImageExclusion(), 'image_updated DESC', \IPS\Settings::i()->gallery_overview_carousel_count, 'view' );
|
||||
$featured = Image::getItemsWithPermission( Image::clubImageExclusion(), 'image_updated DESC', Settings::i()->gallery_overview_carousel_count, 'view' );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/* New images */
|
||||
$new = array();
|
||||
if( \IPS\Settings::i()->gallery_show_new_images )
|
||||
if( Settings::i()->gallery_show_new_images )
|
||||
{
|
||||
$new = iterator_to_array( \IPS\gallery\Image::getItemsWithPermission( \IPS\gallery\Image::clubImageExclusion(), NULL, \IPS\Settings::i()->gallery_new_images_count, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, !\IPS\Settings::i()->club_nodes_in_apps, false, false, false, null, false, false, false ) );
|
||||
$new = iterator_to_array( Image::getItemsWithPermission( Image::clubImageExclusion(), NULL, Settings::i()->gallery_new_images_count, 'read', Filter::FILTER_AUTOMATIC, 0, NULL, !Settings::i()->club_nodes_in_apps, false, false, false, null, false, false, false ) );
|
||||
}
|
||||
|
||||
/* Recently updated albums */
|
||||
$recentlyUpdatedAlbums = array();
|
||||
if( \IPS\Settings::i()->gallery_show_recent_updated_albums )
|
||||
if( Settings::i()->gallery_show_recent_updated_albums )
|
||||
{
|
||||
$recentlyUpdatedAlbums = \IPS\gallery\Album\Item::getItemsWithPermission( \IPS\gallery\Album\Item::clubAlbumExclusion(), 'album_last_img_date DESC', \IPS\Settings::i()->gallery_recent_updated_albums_count, 'view' );
|
||||
$recentlyUpdatedAlbums = Item::getItemsWithPermission( Item::clubAlbumExclusion(), 'album_last_img_date DESC', Settings::i()->gallery_recent_updated_albums_count, 'view' );
|
||||
}
|
||||
|
||||
/* Recently commented */
|
||||
$recentComments = array();
|
||||
if( \IPS\Settings::i()->gallery_show_recent_comments )
|
||||
if( Settings::i()->gallery_show_recent_comments )
|
||||
{
|
||||
$commentWhere = \IPS\gallery\Image::clubImageExclusion();
|
||||
$commentWhere = Image::clubImageExclusion();
|
||||
$commentWhere[] = array( 'image_comments > 0' );
|
||||
$recentComments = \IPS\gallery\Image::getItemsWithPermission( $commentWhere, 'image_last_comment DESC', 10, 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY, 0, NULL, !\IPS\Settings::i()->club_nodes_in_apps, false, false, false, null, false, false, false );
|
||||
$recentComments = Image::getItemsWithPermission( $commentWhere, 'image_last_comment DESC', 10, 'read', Filter::FILTER_PUBLIC_ONLY, 0, NULL, !Settings::i()->club_nodes_in_apps, false, false, false, null, false, false, false );
|
||||
}
|
||||
|
||||
/* Online User Location */
|
||||
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=gallery', 'front', 'gallery' ), array(), 'loc_gallery_browsing' );
|
||||
Session::i()->setLocation( Url::internal( 'app=gallery', 'front', 'gallery' ), array(), 'loc_gallery_browsing' );
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('gallery_title');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->index( $featured, $new, $recentlyUpdatedAlbums, $recentComments );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('gallery_title');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'browse' )->index( $featured, $new, $recentlyUpdatedAlbums, $recentComments );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -248,68 +281,68 @@ class _browse extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function categories()
|
||||
protected function categories() : void
|
||||
{
|
||||
/* 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' );
|
||||
Session::i()->setLocation( 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('gallery_title');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->categories();
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack('gallery_title');
|
||||
Output::i()->output = Theme::i()->getTemplate( 'browse' )->categories();
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Category
|
||||
*
|
||||
* @param \IPS\gallery\Category $category The category to show
|
||||
* @param Category $category The category to show
|
||||
* @return void
|
||||
*/
|
||||
protected function _category( $category )
|
||||
protected function _category( Category $category ) : void
|
||||
{
|
||||
/* Online User Location */
|
||||
$permissions = $category->permissions();
|
||||
\IPS\Session::i()->setLocation( $category->url(), explode( ",", $permissions['perm_view'] ), 'loc_gallery_viewing_category', array( "gallery_category_{$category->id}" => TRUE ) );
|
||||
Session::i()->setLocation( $category->url(), explode( ",", $permissions['perm_view'] ), 'loc_gallery_viewing_category', array( "gallery_category_{$category->id}" => TRUE ) );
|
||||
|
||||
/* Output */
|
||||
\IPS\Output::i()->title = $category->_title;
|
||||
Output::i()->title = $category->_title;
|
||||
|
||||
/* Need to show albums too */
|
||||
$albums = NULL;
|
||||
|
||||
if( $category->allow_albums )
|
||||
{
|
||||
$albums = new \IPS\gallery\Album\Table( NULL, $category );
|
||||
$albums = new AlbumTable( NULL, $category );
|
||||
$albums->title = 'albums';
|
||||
$albums->classes = array( 'ipsDataList_large' );
|
||||
$albums->classes = array( 'ipsData--category', 'ipsData--gallery-category' );
|
||||
$albums = ( $category->hasAlbums() ) ? (string) $albums : NULL;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->breadcrumb = array();
|
||||
\IPS\Output::i()->breadcrumb['module'] = array( \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse', 'front', 'gallery' ), \IPS\Dispatcher::i()->module->_title );
|
||||
Output::i()->breadcrumb = array();
|
||||
Output::i()->breadcrumb['module'] = array( Url::internal( 'app=gallery&module=gallery&controller=browse', 'front', 'gallery' ), Dispatcher::i()->module->_title );
|
||||
|
||||
if( !\count( \IPS\gallery\Image::getItemsWithPermission( array( array( 'image_category_id=? AND image_album_id=?', $category->_id, 0 ) ) ) ) )
|
||||
if( !count( Image::getItemsWithPermission( array( array( 'image_category_id=? AND image_album_id=?', $category->_id, 0 ) ) ) ) )
|
||||
{
|
||||
$table = ( $category->childrenCount() or $albums ) ? '' : \IPS\Theme::i()->getTemplate( 'browse' )->noImages( $category );
|
||||
$table = ( $category->childrenCount() or $albums ) ? '' : Theme::i()->getTemplate( 'browse' )->noImages( $category );
|
||||
|
||||
$parents = iterator_to_array( $category->parents() );
|
||||
if ( \count( $parents ) )
|
||||
if ( count( $parents ) )
|
||||
{
|
||||
foreach( $parents AS $parent )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
|
||||
Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
|
||||
}
|
||||
}
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, $category->_title );
|
||||
Output::i()->breadcrumb[] = array( NULL, $category->_title );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Build table */
|
||||
$table = new \IPS\gallery\Image\Table( 'IPS\gallery\Image', $category->url(), array( array( 'image_album_id=?', 0 ) ), $category );
|
||||
$table = new Table( 'IPS\gallery\Image', $category->url(), array( array( 'image_album_id=?', 0 ) ), $category );
|
||||
$table->limit = 50;
|
||||
$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( $category->count_imgs ) );
|
||||
$table->tableTemplate = array( Theme::i()->getTemplate( 'browse' ), 'imageTable' );
|
||||
$table->rowsTemplate = array( Theme::i()->getTemplate( 'browse' ), $this->getTableRowsTemplate() );
|
||||
$table->title = Member::loggedIn()->language()->pluralize( Member::loggedIn()->language()->get('num_images'), array( $category->count_imgs ) );
|
||||
|
||||
$table->sortBy = \IPS\Request::i()->sortby ? $table->sortBy : $category->sort_options_img;
|
||||
$table->sortBy = Request::i()->sortby ? $table->sortBy : $category->sort_options_img;
|
||||
|
||||
/* Make sure captions are sorted in the right order */
|
||||
if ( $table->sortBy == "title" )
|
||||
@@ -341,42 +374,42 @@ class _browse extends \IPS\Content\Controller
|
||||
}
|
||||
|
||||
/* Data Layer Page Context */
|
||||
if ( \IPS\Settings::i()->core_datalayer_enabled AND !\IPS\Request::i()->isAjax() )
|
||||
if ( Settings::i()->core_datalayer_enabled AND !Request::i()->isAjax() )
|
||||
{
|
||||
foreach ( $category->getDataLayerProperties() as $property => $value )
|
||||
{
|
||||
\IPS\core\DataLayer::i()->addContextProperty( $property, $value, true );
|
||||
DataLayer::i()->addContextProperty( $property, $value );
|
||||
}
|
||||
}
|
||||
|
||||
if ( !\IPS\Request::i()->isAjax() )
|
||||
|
||||
if ( !Request::i()->isAjax() )
|
||||
{
|
||||
$category->updateViews();
|
||||
}
|
||||
|
||||
\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 );
|
||||
|
||||
Output::i()->contextualSearchOptions[ Member::loggedIn()->language()->addToStack( 'search_contextual_item_categories' ) ] = array( 'type' => 'gallery_image', 'nodes' => $category->_id );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'browse' )->category( $category, $albums, (string) $table );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show Album
|
||||
*
|
||||
* @param \IPS\gallery\Album $album The album to show
|
||||
* @param Album $album The album to show
|
||||
* @return void
|
||||
*/
|
||||
protected function _album( $album )
|
||||
protected function _album( Album $album ) : void
|
||||
{
|
||||
if( !\count( \IPS\gallery\Image::getItemsWithPermission( array( array( 'image_album_id=?', $album->id ) ) ) ) )
|
||||
if( !count( Image::getItemsWithPermission( array( array( 'image_album_id=?', $album->id ) ) ) ) )
|
||||
{
|
||||
/* Show a 'no images' template if there's nothing to display */
|
||||
$table = \IPS\Theme::i()->getTemplate( 'browse' )->noImages( $album );
|
||||
$table = Theme::i()->getTemplate( 'browse' )->noImages( $album );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Build table */
|
||||
$table = new \IPS\gallery\Image\Table( 'IPS\gallery\Image', $album->url(), array( array( 'image_album_id=?', $album->id ) ), $album->category() );
|
||||
$table = new 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;
|
||||
$table->sortBy = Request::i()->sortby ? $table->sortBy : $album->_sortBy;
|
||||
|
||||
/* Make sure captions are sorted in the right order */
|
||||
if ( $table->sortBy == "title" )
|
||||
@@ -384,9 +417,9 @@ class _browse extends \IPS\Content\Controller
|
||||
$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()->addToStack( 'num_images', FALSE, array( 'pluralize' => array( $album->count_imgs ) ) );
|
||||
$table->tableTemplate = array( Theme::i()->getTemplate( 'browse' ), 'imageTable' );
|
||||
$table->rowsTemplate = array( Theme::i()->getTemplate( 'browse' ), $this->getTableRowsTemplate() );
|
||||
$table->title = Member::loggedIn()->language()->addToStack( 'num_images', FALSE, array( 'pluralize' => array( $album->count_imgs ) ) );
|
||||
|
||||
if( !$album->allow_comments )
|
||||
{
|
||||
@@ -416,12 +449,12 @@ class _browse extends \IPS\Content\Controller
|
||||
/* Sort out comments and reviews */
|
||||
$tabs = $asItem->commentReviewTabs();
|
||||
$_tabs = array_keys( $tabs );
|
||||
$tab = isset( \IPS\Request::i()->tab ) ? \IPS\Request::i()->tab : array_shift( $_tabs );
|
||||
$tab = isset( Request::i()->tab ) ? Request::i()->tab : array_shift( $_tabs );
|
||||
$activeTabContents = $asItem->commentReviews( $tab );
|
||||
|
||||
if ( \count( $tabs ) > 1 )
|
||||
if ( count( $tabs ) > 1 )
|
||||
{
|
||||
$commentsAndReviews = \count( $tabs ) ? \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $tab, $activeTabContents, $album->url(), 'tab', FALSE, TRUE ) : NULL;
|
||||
$commentsAndReviews = count( $tabs ) ? Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $tab, $activeTabContents, $album->url(), 'tab', FALSE, FALSE ) : NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -429,69 +462,69 @@ class _browse extends \IPS\Content\Controller
|
||||
}
|
||||
|
||||
/* Fetching comments/reviews */
|
||||
if( \IPS\Request::i()->isAjax() AND !isset( \IPS\Request::i()->listResort ) )
|
||||
if( Request::i()->isAjax() AND !isset( Request::i()->listResort ) )
|
||||
{
|
||||
\IPS\Output::i()->output = $activeTabContents;
|
||||
Output::i()->output = $activeTabContents;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Online User Location */
|
||||
$permissions = $album->category()->permissions();
|
||||
\IPS\Session::i()->setLocation( $album->url(), explode( ",", $permissions['perm_view'] ), 'loc_gallery_viewing_album', array( $album->_title => FALSE ) );
|
||||
Session::i()->setLocation( $album->url(), explode( ",", $permissions['perm_view'] ), 'loc_gallery_viewing_album', array( $album->_title => FALSE ) );
|
||||
|
||||
/* Output */
|
||||
\IPS\Output::i()->title = $album->_title;
|
||||
\IPS\Output::i()->breadcrumb = array();
|
||||
Output::i()->title = $album->_title;
|
||||
Output::i()->breadcrumb = array();
|
||||
|
||||
if ( $club = $album->category()->club() )
|
||||
{
|
||||
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
|
||||
\IPS\Output::i()->breadcrumb = array();
|
||||
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
|
||||
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
|
||||
\IPS\Output::i()->breadcrumb[] = array( $album->category()->url(), $album->category()->_title );
|
||||
FrontNavigation::$clubTabActive = TRUE;
|
||||
Output::i()->breadcrumb = array();
|
||||
Output::i()->breadcrumb[] = array( Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), Member::loggedIn()->language()->addToStack('module__core_clubs') );
|
||||
Output::i()->breadcrumb[] = array( $club->url(), $club->name );
|
||||
Output::i()->breadcrumb[] = array( $album->category()->url(), $album->category()->_title );
|
||||
|
||||
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
|
||||
if ( Settings::i()->clubs_header == 'sidebar' )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $album->category(), 'sidebar' );
|
||||
Output::i()->sidebar['contextual'] = Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $album->category(), 'sidebar' );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb['module'] = array( \IPS\Http\Url::internal( 'app=gallery&module=gallery&controller=browse', 'front', 'gallery' ), \IPS\Dispatcher::i()->module->_title );
|
||||
Output::i()->breadcrumb['module'] = array( Url::internal( 'app=gallery&module=gallery&controller=browse', 'front', 'gallery' ), Dispatcher::i()->module->_title );
|
||||
$parents = iterator_to_array( $album->category()->parents() );
|
||||
if ( \count( $parents ) )
|
||||
if ( count( $parents ) )
|
||||
{
|
||||
foreach( $parents AS $parent )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
|
||||
Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
|
||||
}
|
||||
}
|
||||
\IPS\Output::i()->breadcrumb[] = array( $album->category()->url(), $album->category()->_title );
|
||||
Output::i()->breadcrumb[] = array( $album->category()->url(), $album->category()->_title );
|
||||
}
|
||||
|
||||
if( $album->coverPhoto('masked') )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['og:image'] = $album->coverPhoto('masked');
|
||||
Output::i()->metaTags['og:image'] = $album->coverPhoto('masked');
|
||||
}
|
||||
|
||||
\IPS\Output::i()->metaTags['og:title'] = $album->_title;
|
||||
Output::i()->metaTags['og:title'] = $album->_title;
|
||||
|
||||
$albumItem = $album->asItem();
|
||||
\IPS\core\Facebook\Pixel::i()->PageView = array(
|
||||
Pixel::i()->PageView = array(
|
||||
'item_id' => $album->id,
|
||||
'item_name' => $albumItem->mapped('title'),
|
||||
'item_type' => isset( $albumItem::$contentType ) ? $albumItem::$contentType : $albumItem::$title,
|
||||
'item_type' => $albumItem::$contentType ?? $albumItem::$title,
|
||||
'category_name' => $albumItem->container()->_title
|
||||
);
|
||||
|
||||
if ( !\IPS\Request::i()->isAjax() )
|
||||
|
||||
if ( !Request::i()->isAjax() )
|
||||
{
|
||||
$albumItem->updateViews();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, $album->_title );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->album( $album, (string) $table, $commentsAndReviews );
|
||||
Output::i()->breadcrumb[] = array( NULL, $album->_title );
|
||||
Output::i()->output = Theme::i()->getTemplate( 'browse' )->album( $album, (string) $table, $commentsAndReviews );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -499,13 +532,13 @@ class _browse extends \IPS\Content\Controller
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
protected function getTableRowsTemplate()
|
||||
protected function getTableRowsTemplate(): string
|
||||
{
|
||||
if( isset( \IPS\Request::i()->cookie['thumbnailSize'] ) AND \IPS\Request::i()->cookie['thumbnailSize'] == 'large' AND \IPS\Request::i()->controller != 'search' )
|
||||
if( isset( Request::i()->cookie['thumbnailSize'] ) AND Request::i()->cookie['thumbnailSize'] == 'large' AND Request::i()->controller != 'search' )
|
||||
{
|
||||
return 'tableRowsLarge';
|
||||
}
|
||||
else if( isset( \IPS\Request::i()->cookie['thumbnailSize'] ) AND \IPS\Request::i()->cookie['thumbnailSize'] == 'rows' AND \IPS\Request::i()->controller != 'search' )
|
||||
else if( isset( Request::i()->cookie['thumbnailSize'] ) AND Request::i()->cookie['thumbnailSize'] == 'rows' AND Request::i()->controller != 'search' )
|
||||
{
|
||||
return 'tableRowsRows';
|
||||
}
|
||||
@@ -520,58 +553,58 @@ class _browse extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function editAlbum()
|
||||
protected function editAlbum() : void
|
||||
{
|
||||
/* Load album and check permissions */
|
||||
try
|
||||
{
|
||||
$album = \IPS\gallery\Album::loadAndCheckPerms( \IPS\Request::i()->album, 'read' );
|
||||
$album = Album::loadAndCheckPerms( Request::i()->album, 'read' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G189/5', 404, '' );
|
||||
Output::i()->error( 'node_error', '2G189/5', 404, '' );
|
||||
}
|
||||
|
||||
if( !$album->asItem()->canEdit() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G189/4', 403, '' );
|
||||
Output::i()->error( 'node_error', '2G189/4', 403, '' );
|
||||
}
|
||||
|
||||
/* Build form */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class .= 'ipsForm_vertical';
|
||||
$form = new Form;
|
||||
$form->class .= 'ipsForm--vertical ipsForm--edit-album';
|
||||
|
||||
$album->form( $form, TRUE );
|
||||
$album->form( $form );
|
||||
|
||||
/* Handle submissions */
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$values['album_owner'] = ( isset( $values['album_owner'] ) ) ? $values['album_owner'] : \IPS\Member::loggedIn();
|
||||
$values['album_owner'] = ( isset( $values['album_owner'] ) ) ? $values['album_owner'] : Member::loggedIn();
|
||||
|
||||
if( !$values['album_name'] OR !$values['album_category'] )
|
||||
{
|
||||
if( !$values['album_name'] )
|
||||
{
|
||||
$form->elements['']['album_name']->error = \IPS\Member::loggedIn()->language()->addToStack('form_required');
|
||||
$form->elements['']['album_name']->error = Member::loggedIn()->language()->addToStack('form_required');
|
||||
}
|
||||
|
||||
if( !$values['album_category'] )
|
||||
{
|
||||
$form->elements['']['album_category']->error = \IPS\Member::loggedIn()->language()->addToStack('form_required');
|
||||
$form->elements['']['album_category']->error = Member::loggedIn()->language()->addToStack('form_required');
|
||||
}
|
||||
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
Output::i()->output = $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
$album->saveForm( $album->formatFormValues( $values ) );
|
||||
|
||||
\IPS\Output::i()->redirect( $album->url() );
|
||||
Output::i()->redirect( $album->url() );
|
||||
}
|
||||
|
||||
/* Display form */
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'edit_album' );
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
Output::i()->title = Member::loggedIn()->language()->addToStack( 'edit_album' );
|
||||
Output::i()->output = $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -579,32 +612,32 @@ class _browse extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function deleteAlbum()
|
||||
protected function deleteAlbum() : void
|
||||
{
|
||||
/* Load album and check permissions */
|
||||
try
|
||||
{
|
||||
$album = \IPS\gallery\Album::loadAndCheckPerms( \IPS\Request::i()->album, 'read' );
|
||||
$album = Album::loadAndCheckPerms( Request::i()->album, 'read' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G189/6', 404, '' );
|
||||
Output::i()->error( 'node_error', '2G189/6', 404, '' );
|
||||
}
|
||||
|
||||
if( !$album->canDelete() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G189/7', 403, '' );
|
||||
Output::i()->error( 'node_error', '2G189/7', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
/* Build form to move or delete images */
|
||||
$form = new \IPS\Helpers\Form;
|
||||
$form->class .= 'ipsForm_vertical';
|
||||
$form = new Form;
|
||||
$form->class .= 'ipsForm--vertical ipsForm--delete-images';
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( "delete_images", TRUE, FALSE, array( 'togglesOff' => array( 'move_image_category', 'move_image_album' ) ) ) );
|
||||
$form->add( new YesNo( "delete_images", TRUE, FALSE, array( 'togglesOff' => array( 'move_image_category', 'move_image_album' ) ) ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'move_image_category', NULL, FALSE, array(
|
||||
$form->add( new Node( 'move_image_category', NULL, FALSE, array(
|
||||
'class' => 'IPS\gallery\Category',
|
||||
'permissionCheck' => function( $node ) {
|
||||
|
||||
@@ -624,7 +657,7 @@ class _browse extends \IPS\Content\Controller
|
||||
}
|
||||
), NULL, NULL, NULL, 'move_image_category' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'move_image_album', NULL, FALSE, array(
|
||||
$form->add( new Node( 'move_image_album', NULL, FALSE, array(
|
||||
'class' => 'IPS\gallery\Album',
|
||||
'permissionCheck' => function( $node ) use ( $album )
|
||||
{
|
||||
@@ -661,23 +694,23 @@ class _browse extends \IPS\Content\Controller
|
||||
$category->save();
|
||||
|
||||
/* Hide the album */
|
||||
$album->type = \IPS\gallery\Album::AUTH_TYPE_DELETED;
|
||||
$album->type = Album::AUTH_TYPE_DELETED;
|
||||
$album->save();
|
||||
|
||||
/* Are we moving the images? */
|
||||
if( !$values['delete_images'] )
|
||||
{
|
||||
if( ( !isset( $values['move_image_category'] ) OR !( $values['move_image_category'] instanceof \IPS\Node\Model ) ) AND
|
||||
( !isset( $values['move_image_album'] ) OR !( $values['move_image_album'] instanceof \IPS\Node\Model ) ) )
|
||||
if( ( !isset( $values['move_image_category'] ) OR !( $values['move_image_category'] instanceof Model ) ) AND
|
||||
( !isset( $values['move_image_album'] ) OR !( $values['move_image_album'] instanceof Model ) ) )
|
||||
{
|
||||
$form->error = \IPS\Member::loggedIn()->language()->addToStack('gallery_cat_or_album');
|
||||
$form->error = Member::loggedIn()->language()->addToStack('gallery_cat_or_album');
|
||||
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
Output::i()->output = $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
return;
|
||||
}
|
||||
|
||||
$moveData = array( 'class' => 'IPS\gallery\Album', 'id' => $album->_id, 'deleteWhenDone' => TRUE );
|
||||
if( isset( $values['move_image_category'] ) AND $values['move_image_category'] instanceof \IPS\Node\Model )
|
||||
if( isset( $values['move_image_category'] ) AND $values['move_image_category'] instanceof Model )
|
||||
{
|
||||
$moveData['moveToClass'] = 'IPS\gallery\Category';
|
||||
$moveData['moveTo'] = $values['move_image_category']->_id;
|
||||
@@ -688,27 +721,27 @@ class _browse extends \IPS\Content\Controller
|
||||
$moveData['moveTo'] = $values['move_image_album']->_id;
|
||||
}
|
||||
|
||||
\IPS\Task::queue( 'core', 'DeleteOrMoveContent', $moveData );
|
||||
Task::queue( 'core', 'DeleteOrMoveContent', $moveData );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Task::queue( 'core', 'DeleteOrMoveContent', array( 'class' => 'IPS\gallery\Album', 'id' => $album->_id, 'deleteWhenDone' => TRUE ) );
|
||||
Task::queue( 'core', 'DeleteOrMoveContent', array( 'class' => 'IPS\gallery\Album', 'id' => $album->_id, 'deleteWhenDone' => TRUE ) );
|
||||
}
|
||||
|
||||
/* And then redirect */
|
||||
if( isset( $moveData['moveTo'] ) )
|
||||
{
|
||||
$target = $moveData['moveToClass']::load($moveData['moveTo']);
|
||||
\IPS\Output::i()->redirect( $target->url() );
|
||||
Output::i()->redirect( $target->url() );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->redirect( $album->category()->url() );
|
||||
Output::i()->redirect( $album->category()->url() );
|
||||
}
|
||||
}
|
||||
|
||||
/* Display form */
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
Output::i()->output = $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -716,9 +749,9 @@ class _browse extends \IPS\Content\Controller
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function embed()
|
||||
protected function embed() : void
|
||||
{
|
||||
\IPS\Request::i()->id = \IPS\Request::i()->album;
|
||||
return parent::embed();
|
||||
Request::i()->id = Request::i()->album;
|
||||
parent::embed();
|
||||
}
|
||||
}
|
||||
@@ -15,80 +15,96 @@
|
||||
namespace IPS\gallery\modules\front\gallery;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\gallery\Image;
|
||||
use IPS\Member;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Session;
|
||||
use OutOfRangeException;
|
||||
use function count;
|
||||
use function defined;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Store and retrieve image notes
|
||||
*/
|
||||
class _notes extends \IPS\Dispatcher\Controller
|
||||
class notes extends Controller
|
||||
{
|
||||
/**
|
||||
* @var Image|null
|
||||
*/
|
||||
protected ?Image $image = null;
|
||||
|
||||
/**
|
||||
* Determine what to show
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function manage()
|
||||
protected function manage() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->image = \IPS\gallery\Image::load( \IPS\Request::i()->imageId );
|
||||
$this->image = Image::load( Request::i()->imageId );
|
||||
|
||||
if ( !$this->image->canView( \IPS\Member::loggedIn() ) )
|
||||
if ( !$this->image->canView( Member::loggedIn() ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G191/1', 403, '' );
|
||||
Output::i()->error( 'node_error', '2G191/1', 403, '' );
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2G191/2', 404, '' );
|
||||
Output::i()->error( 'node_error', '2G191/2', 404, '' );
|
||||
}
|
||||
|
||||
$response = NULL;
|
||||
|
||||
/* jQuery-Notes will send 'image' parameter which we can ignore */
|
||||
$noteId = \IPS\Request::i()->id;
|
||||
$position = \IPS\Request::i()->position;
|
||||
$note = strip_tags( \IPS\Request::i()->note );
|
||||
$noteId = Request::i()->id;
|
||||
$position = Request::i()->position;
|
||||
$note = strip_tags( Request::i()->note );
|
||||
|
||||
if( \IPS\Request::i()->get )
|
||||
if( Request::i()->get )
|
||||
{
|
||||
$response = $this->image->_notes;
|
||||
}
|
||||
else if( \IPS\Request::i()->add )
|
||||
else if( Request::i()->add )
|
||||
{
|
||||
$response = $this->_addNote( $position, $note );
|
||||
}
|
||||
else if( \IPS\Request::i()->delete )
|
||||
else if( Request::i()->delete )
|
||||
{
|
||||
$response = $this->_deleteNote( $noteId );
|
||||
}
|
||||
else if( \IPS\Request::i()->edit )
|
||||
else if( Request::i()->edit )
|
||||
{
|
||||
$response = $this->_editNote( $noteId, $position, $note );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->json( $response );
|
||||
Output::i()->json( $response );
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete an image note
|
||||
*
|
||||
* @param int $id Note ID to delete
|
||||
* @return bool
|
||||
* @param int $id Note ID to delete
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function _deleteNote( $id )
|
||||
protected function _deleteNote( int $id ): bool|string
|
||||
{
|
||||
/* Check permission */
|
||||
if( !$this->image->canEdit() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'notes_no_permission', '2G191/3', 403, '' );
|
||||
Output::i()->error( 'notes_no_permission', '2G191/3', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
$notes = $this->image->_notes;
|
||||
|
||||
@@ -111,23 +127,23 @@ class _notes extends \IPS\Dispatcher\Controller
|
||||
* Add an image note
|
||||
*
|
||||
* @param mixed $position Note position
|
||||
* @param string $note Note text
|
||||
* @return bool
|
||||
* @param string $note Note text
|
||||
* @return bool|array
|
||||
*/
|
||||
protected function _addNote( $position, $note )
|
||||
protected function _addNote( mixed $position, string $note ): array|bool
|
||||
{
|
||||
/* Check permission */
|
||||
if( !$this->image->canEdit() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'notes_no_permission', '2G191/4', 403, '' );
|
||||
Output::i()->error( 'notes_no_permission', '2G191/4', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
$notes = $this->image->_notes;
|
||||
$position = explode( ',', $position );
|
||||
|
||||
if( \count( $position ) != 4 )
|
||||
if( count( $position ) != 4 )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -160,20 +176,20 @@ class _notes extends \IPS\Dispatcher\Controller
|
||||
/**
|
||||
* Edit an image note
|
||||
*
|
||||
* @param int $id Note ID to edit
|
||||
* @param mixed $position Note position
|
||||
* @param string $note Note text
|
||||
* @return bool
|
||||
* @param int $id Note ID to edit
|
||||
* @param mixed $position Note position
|
||||
* @param string $noteText
|
||||
* @return bool|string
|
||||
*/
|
||||
protected function _editNote( $id, $position='', $noteText='' )
|
||||
protected function _editNote(int $id, mixed $position='', string $noteText='' ): bool|string
|
||||
{
|
||||
/* Check permission */
|
||||
if( !$this->image->canEdit() )
|
||||
{
|
||||
\IPS\Output::i()->error( 'notes_no_permission', '2G191/5', 403, '' );
|
||||
Output::i()->error( 'notes_no_permission', '2G191/5', 403, '' );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
Session::i()->csrfCheck();
|
||||
|
||||
$notes = $this->image->_notes;
|
||||
$position = explode( ',', $position );
|
||||
@@ -189,7 +205,7 @@ class _notes extends \IPS\Dispatcher\Controller
|
||||
$notes[ $key ]['NOTE'] = trim( str_replace( "\n", ' ', str_replace( ' ', ' ', $noteText ) ) );
|
||||
}
|
||||
|
||||
if( \count( $position ) == 4 )
|
||||
if( count( $position ) == 4 )
|
||||
{
|
||||
$notes[ $key ]['LEFT'] = round( $position[0], 5 );
|
||||
$notes[ $key ]['TOP'] = round( $position[1], 5 );
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
Reference in new issue
Block a user