Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+46 -37
View File
@@ -11,36 +11,50 @@
namespace IPS\downloads;
use IPS\Application as SystemApplication;
use IPS\Content\Filter;
use IPS\DateTime;
use IPS\Http\Url;
use IPS\Login;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Settings;
use IPS\Theme;
use IPS\Xml\Rss;
use OutOfRangeException;
use function is_numeric;
/**
* Downloads Application Class
*/
class _Application extends \IPS\Application
class Application extends SystemApplication
{
/**
* Init
*
* @return void
*/
public function init()
public function init(): void
{
/* Handle RSS requests */
if ( \IPS\Request::i()->module == 'downloads' and \IPS\Request::i()->controller == 'browse' and \IPS\Request::i()->do == 'rss' )
if ( Request::i()->module == 'downloads' and Request::i()->controller == 'browse' and Request::i()->do == 'rss' )
{
$member = NULL;
if( \IPS\Request::i()->member AND \IPS\Request::i()->key )
if( Request::i()->member AND Request::i()->key )
{
$member = \IPS\Member::load( \IPS\Request::i()->member );
if( !\IPS\Login::compareHashes( $member->getUniqueMemberHash(), (string) \IPS\Request::i()->key ) )
$member = Member::load( Request::i()->member );
if( !Login::compareHashes( $member->getUniqueMemberHash(), (string) Request::i()->key ) )
{
$member = NULL;
}
}
$this->sendDownloadsRss( $member ?? new \IPS\Member );
$this->sendDownloadsRss( $member ?? new Member );
if( !\IPS\Member::loggedIn()->group['g_view_board'] )
if( !Member::loggedIn()->group['g_view_board'] )
{
\IPS\Output::i()->error( 'node_error', '2D220/1', 404, '' );
Output::i()->error( 'node_error', '2D220/1', 404, '' );
}
}
@@ -52,49 +66,44 @@ class _Application extends \IPS\Application
*
* @return void
*/
public static function outputCss()
public static function outputCss() : void
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'downloads.css', 'downloads', 'front' ) );
if ( \IPS\Theme::i()->settings['responsive'] )
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'downloads_responsive.css', 'downloads', 'front' ) );
}
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'downloads.css', 'downloads', 'front' ) );
}
/**
* Send the latest file RSS feed for the indicated member
*
* @param \IPS\Member $member Member
* @param Member $member Member
* @return void
*/
protected function sendDownloadsRss( $member )
protected function sendDownloadsRss( Member $member ) : void
{
if( !\IPS\Settings::i()->idm_rss )
if( !Settings::i()->idm_rss )
{
\IPS\Output::i()->error( 'rss_offline', '2D175/2', 403, 'rss_offline_admin' );
Output::i()->error( 'rss_offline', '2D175/2', 403, 'rss_offline_admin' );
}
$document = \IPS\Xml\Rss::newDocument( \IPS\Http\Url::internal( 'app=downloads&module=downloads&controller=browse', 'front', 'downloads' ), $member->language()->get('idm_rss_title'), $member->language()->get('idm_rss_title') );
$document = Rss::newDocument( Url::internal( 'app=downloads&module=downloads&controller=browse', 'front', 'downloads' ), $member->language()->get('idm_rss_title'), $member->language()->get('idm_rss_title') );
foreach ( \IPS\downloads\File::getItemsWithPermission( array(), NULL, 10, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, $member ) as $file )
foreach (File::getItemsWithPermission( array(), NULL, 10, 'read', Filter::FILTER_AUTOMATIC, 0, $member ) as $file )
{
$content = $file->desc;
\IPS\Output::i()->parseFileObjectUrls( $content );
$document->addItem( $file->name, $file->url(), $content, \IPS\DateTime::ts( $file->updated ), $file->id );
Output::i()->parseFileObjectUrls( $content );
$document->addItem( $file->name, $file->url(), $file->desc, DateTime::ts( $file->updated ), $file->id );
}
/* @note application/rss+xml is not a registered IANA mime-type so we need to stick with text/xml for RSS */
\IPS\Output::i()->sendOutput( $document->asXML(), 200, 'text/xml', array(), TRUE );
Output::i()->sendOutput( $document->asXML(), 200, 'text/xml' );
}
/**
* [Node] Get Icon for tree
*
* @note Return the class for the icon (e.g. 'globe')
* @return string|null
* @return string
*/
protected function get__icon()
protected function get__icon(): string
{
return 'download';
}
@@ -122,7 +131,7 @@ class _Application extends \IPS\Application
* @endcode
* @return array
*/
public function defaultFrontNavigation()
public function defaultFrontNavigation(): array
{
return array(
'rootTabs' => array(),
@@ -137,22 +146,22 @@ class _Application extends \IPS\Application
*
* @return void
*/
public function convertLegacyParameters()
public function convertLegacyParameters() : void
{
if ( isset( \IPS\Request::i()->showfile ) AND \is_numeric( \IPS\Request::i()->showfile ) )
if ( isset( Request::i()->showfile ) AND is_numeric( Request::i()->showfile ) )
{
try
{
$file = \IPS\downloads\File::loadAndCheckPerms( \IPS\Request::i()->showfile );
$file = File::loadAndCheckPerms( Request::i()->showfile );
\IPS\Output::i()->redirect( $file->url() );
Output::i()->redirect( $file->url() );
}
catch( \OutOfRangeException $e ) {}
catch( OutOfRangeException $e ) {}
}
if ( isset( \IPS\Request::i()->module ) AND \IPS\Request::i()->module == 'post' AND isset( \IPS\Request::i()->controller ) AND \IPS\Request::i()->controller == 'submit' )
if ( isset( Request::i()->module ) AND Request::i()->module == 'post' AND isset( Request::i()->controller ) AND Request::i()->controller == 'submit' )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=downloads&module=downloads&controller=submit", "front", "downloads_submit" ) );
Output::i()->redirect( Url::internal( "app=downloads&module=downloads&controller=submit", "front", "downloads_submit" ) );
}
}
@@ -161,7 +170,7 @@ class _Application extends \IPS\Application
*
* @return array
*/
public function uploadSettings()
public function uploadSettings(): array
{
/* Apps can overload this */
return array( 'idm_watermarkpath' );
@@ -174,7 +183,7 @@ class _Application extends \IPS\Application
*/
public function getWebhooks(): array
{
return array_merge( parent::getWebhooks(), [ 'downloads_new_version' => \IPS\downloads\File::class ] );
return array_merge( parent::getWebhooks(), [ 'downloads_new_version' => File::class ] );
}
}