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

+39 -22
View File
@@ -12,16 +12,32 @@
namespace IPS\Content\ShareServices;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use InvalidArgumentException;
use IPS\Content\ShareServices;
use IPS\core\ShareLinks\Service;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Text;
use IPS\IPS;
use IPS\Login\Handler;
use IPS\Member;
use IPS\Settings;
use IPS\Theme;
use Throwable;
use function defined;
use function ord;
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;
}
/**
* X share link
* Twitter share link
*/
class _X extends \IPS\Content\ShareServices
class X extends ShareServices
{
/**
* Determine whether the logged in user has the ability to autoshare
@@ -30,6 +46,10 @@ class _X extends \IPS\Content\ShareServices
*/
public static function canAutoshare(): bool
{
if ( $method = Handler::findMethod( 'IPS\Login\Handler\OAuth1\Twitter' ) and $method->canProcess( Member::loggedIn() ) )
{
return TRUE;
}
return FALSE;
}
@@ -37,24 +57,24 @@ class _X extends \IPS\Content\ShareServices
* Publish text or a URL to this service
*
* @param string $content Text to publish
* @param string $url [URL to publish]
* @param string|null $url [URL to publish]
* @return void
*/
public static function publish( $content, $url=null )
public static function publish( string $content, string|null $url=null ): void
{
throw new \InvalidArgumentException( \IPS\Member::loggedIn()->language()->addToStack('x_publish_no_user') );
throw new InvalidArgumentException( Member::loggedIn()->language()->addToStack('x_publish_no_user') );
}
/**
* Add any additional form elements to the configuration form. These must be setting keys that the service configuration form can save as a setting.
*
* @param \IPS\Helpers\Form $form Configuration form for this service
* @param \IPS\core\ShareLinks\Service $service The service
* @param Form $form Configuration form for this service
* @param Service $service The service
* @return void
*/
public static function modifyForm( \IPS\Helpers\Form &$form, $service )
public static function modifyForm( Form &$form, Service $service ): void
{
$form->add( new \IPS\Helpers\Form\Text( 'x_hashtag', \IPS\Settings::i()->x_hashtag, FALSE ) );
$form->add( new Text( 'x_hashtag', Settings::i()->x_hashtag, FALSE ) );
}
/**
@@ -62,31 +82,28 @@ class _X extends \IPS\Content\ShareServices
*
* @return string
*/
public function __toString()
public function __toString(): string
{
try
{
$url = preg_replace_callback( "{[^0-9a-z_.!~*'();,/?:@&=+$#-]}i",
function ( $m )
{
return sprintf( '%%%02X', \ord( $m[0] ) );
return sprintf( '%%%02X', ord( $m[0] ) );
},
$this->url) ;
$title = $this->title ?: NULL;
if ( \IPS\Settings::i()->x_hashtag !== '')
if ( Settings::i()->x_hashtag !== '')
{
$title .= ' ' . \IPS\Settings::i()->x_hashtag;
$title .= ' ' . Settings::i()->x_hashtag;
}
return \IPS\Theme::i()->getTemplate( 'sharelinks', 'core' )->x( urlencode( $url ), rawurlencode( $title ) );
return Theme::i()->getTemplate( 'sharelinks', 'core' )->x( urlencode( $url ), rawurlencode( $title ) );
}
catch ( \Exception $e )
catch ( Exception | Throwable $e )
{
\IPS\IPS::exceptionHandler( $e );
}
catch ( \Throwable $e )
{
\IPS\IPS::exceptionHandler( $e );
IPS::exceptionHandler( $e );
}
return '';
}
}