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") );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user