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
@@ -1,34 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Bluesky share link
|
||||
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) Invision Power Services, Inc.
|
||||
* @license https://www.invisioncommunity.com/legal/standards/
|
||||
* @package Invision Community
|
||||
* @since 19 November 2024
|
||||
*/
|
||||
|
||||
namespace IPS\Content\ShareServices;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bluesky share link
|
||||
*/
|
||||
class _Bluesky extends \IPS\Content\ShareServices
|
||||
{
|
||||
/**
|
||||
* Return the HTML code to show the share link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'sharelinks', 'core' )->bluesky( urlencode( $this->url ), $this->title ? urlencode( $this->title ) : NULL );
|
||||
}
|
||||
}
|
||||
@@ -11,24 +11,29 @@
|
||||
namespace IPS\Content\ShareServices;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content\ShareServices;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Email share link
|
||||
*/
|
||||
class _Email extends \IPS\Content\ShareServices
|
||||
class Email extends ShareServices
|
||||
{
|
||||
/**
|
||||
* Return the HTML code to show the share link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'sharelinks', 'core' )->email( rawurlencode( $this->url ), rawurlencode( $this->title ) );
|
||||
return Theme::i()->getTemplate( 'sharelinks', 'core' )->email( rawurlencode( $this->url ), rawurlencode( $this->title ) );
|
||||
}
|
||||
}
|
||||
@@ -12,27 +12,37 @@
|
||||
namespace IPS\Content\ShareServices;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content\ShareServices;
|
||||
use IPS\core\ShareLinks\Service;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\Select;
|
||||
use IPS\Member\Group;
|
||||
use IPS\Settings;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Facebook share link
|
||||
*/
|
||||
class _Facebook extends \IPS\Content\ShareServices
|
||||
class Facebook extends ShareServices
|
||||
{
|
||||
/**
|
||||
* 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\Select( 'fbc_bot_group', \IPS\Settings::i()->fbc_bot_group, TRUE, array( 'options' => array_combine( array_keys( \IPS\Member\Group::groups() ), array_map( function( $_group ) { return (string) $_group; }, \IPS\Member\Group::groups() ) ) ) ) );
|
||||
$form->add( new Select( 'fbc_bot_group', Settings::i()->fbc_bot_group, TRUE, array( 'options' => array_combine( array_keys( Group::groups() ), array_map( function( $_group ) { return (string) $_group; }, Group::groups() ) ) ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,8 +50,8 @@ class _Facebook extends \IPS\Content\ShareServices
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'sharelinks', 'core' )->facebook( urlencode( $this->url ) );
|
||||
return Theme::i()->getTemplate( 'sharelinks', 'core' )->facebook( urlencode( $this->url ) );
|
||||
}
|
||||
}
|
||||
@@ -12,24 +12,29 @@
|
||||
namespace IPS\Content\ShareServices;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content\ShareServices;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Linked In share link
|
||||
*/
|
||||
class _Linkedin extends \IPS\Content\ShareServices
|
||||
class Linkedin extends ShareServices
|
||||
{
|
||||
/**
|
||||
* Return the HTML code to show the share link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'sharelinks', 'core' )->linkedin( urlencode( $this->url ), urlencode( $this->title ) );
|
||||
return Theme::i()->getTemplate( 'sharelinks', 'core' )->linkedin( urlencode( $this->url ), urlencode( $this->title ) );
|
||||
}
|
||||
}
|
||||
@@ -11,31 +11,38 @@
|
||||
namespace IPS\Content\ShareServices;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content;
|
||||
use IPS\Content\ShareServices;
|
||||
use IPS\Http\Url;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Pinterest share link
|
||||
*/
|
||||
class _Pinterest extends \IPS\Content\ShareServices
|
||||
class Pinterest extends ShareServices
|
||||
{
|
||||
/**
|
||||
* @brief Ccontent item
|
||||
*/
|
||||
protected $item = NULL;
|
||||
protected Content|null $item = NULL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Http\Url $url URL to the content [optional - if omitted, some services will figure out on their own]
|
||||
* @param string $title Default text for the content, usually the title [optional - if omitted, some services will figure out on their own]
|
||||
* @param \IPS\Content|NULL $item Content item (or comment) to share
|
||||
* @param Url|null $url URL to the content [optional - if omitted, some services will figure out on their own]
|
||||
* @param string|null $title Default text for the content, usually the title [optional - if omitted, some services will figure out on their own]
|
||||
* @param Content|NULL $item Content item (or comment) to share
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Http\Url $url=NULL, $title=NULL, $item=NULL )
|
||||
public function __construct( Url|null $url=NULL, string|null $title=NULL, Content|null $item=NULL )
|
||||
{
|
||||
$this->item = $item;
|
||||
|
||||
@@ -47,11 +54,11 @@ class _Pinterest extends \IPS\Content\ShareServices
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
if ( $this->item )
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'sharelinks', 'core' )->pinterest( \IPS\Http\Url::external( 'https://pinterest.com/pin/create/button/' )->setQueryString( 'url', (string) $this->url )->setQueryString( 'media', (string) $this->item->shareImage() ) );
|
||||
return Theme::i()->getTemplate( 'sharelinks', 'core' )->pinterest( Url::external( 'https://pinterest.com/pin/create/button/' )->setQueryString( 'url', (string) $this->url )->setQueryString( 'media', $this->item->shareImage() ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -12,9 +12,14 @@
|
||||
namespace IPS\Content\ShareServices;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use IPS\Content\ShareServices;
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -22,15 +27,15 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
* Reddit share link
|
||||
* @note Reddit does not provide any method to control the locale/language
|
||||
*/
|
||||
class _Reddit extends \IPS\Content\ShareServices
|
||||
class Reddit extends ShareServices
|
||||
{
|
||||
/**
|
||||
* Return the HTML code to show the share link
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function __toString()
|
||||
public function __toString(): string
|
||||
{
|
||||
return \IPS\Theme::i()->getTemplate( 'sharelinks', 'core' )->reddit( urlencode( $this->url ), $this->title ? str_replace( '"', '\\"', $this->title ) : NULL );
|
||||
return Theme::i()->getTemplate( 'sharelinks', 'core' )->reddit( urlencode( $this->url ), $this->title ? str_replace( '"', '\\"', $this->title ) : NULL );
|
||||
}
|
||||
}
|
||||
@@ -11,26 +11,32 @@
|
||||
namespace IPS\Content;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
use InvalidArgumentException;
|
||||
use IPS\core\ShareLinks\Service;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Http\Url;
|
||||
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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Share Services Abstract Class
|
||||
*/
|
||||
abstract class _ShareServices
|
||||
abstract class ShareServices
|
||||
{
|
||||
/**
|
||||
* Get services
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function services()
|
||||
public static function services(): array
|
||||
{
|
||||
return array(
|
||||
'Bluesky' => 'IPS\Content\ShareServices\Bluesky',
|
||||
'Facebook' => 'IPS\Content\ShareServices\Facebook',
|
||||
'Linkedin' => 'IPS\Content\ShareServices\Linkedin',
|
||||
'Pinterest' => 'IPS\Content\ShareServices\Pinterest',
|
||||
@@ -43,16 +49,16 @@ abstract class _ShareServices
|
||||
/**
|
||||
* @brief Cached services
|
||||
*/
|
||||
static $services = NULL;
|
||||
static array|null $services = NULL;
|
||||
|
||||
/**
|
||||
* Helper method to get the class based on the key
|
||||
*
|
||||
* @param string $key Service to load
|
||||
* @return mixed
|
||||
* @throws \InvalidArgumentException
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function getClassByKey( $key )
|
||||
public static function getClassByKey( string $key ): mixed
|
||||
{
|
||||
if ( static::$services == NULL )
|
||||
{
|
||||
@@ -61,7 +67,7 @@ abstract class _ShareServices
|
||||
|
||||
if ( !isset( static::$services[ ucwords($key) ] ) )
|
||||
{
|
||||
throw new \InvalidArgumentException;
|
||||
throw new InvalidArgumentException;
|
||||
}
|
||||
return static::$services[ ucwords($key) ];
|
||||
}
|
||||
@@ -71,7 +77,7 @@ abstract class _ShareServices
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public static function canAutoshare()
|
||||
public static function canAutoshare(): bool
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
@@ -79,11 +85,11 @@ abstract class _ShareServices
|
||||
/**
|
||||
* 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
|
||||
{
|
||||
// Do nothing by default
|
||||
}
|
||||
@@ -91,21 +97,21 @@ abstract class _ShareServices
|
||||
/**
|
||||
* @brief URL to the content item
|
||||
*/
|
||||
protected $url = NULL;
|
||||
protected Url|null $url = NULL;
|
||||
|
||||
/**
|
||||
* @brief Title of the content item
|
||||
*/
|
||||
protected $title = NULL;
|
||||
protected string|null $title = NULL;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param \IPS\Http\Url $url URL to the content [optional - if omitted, some services will figure out on their own]
|
||||
* @param string $title Default text for the content, usually the title [optional - if omitted, some services will figure out on their own]
|
||||
* @param Url|null $url URL to the content [optional - if omitted, some services will figure out on their own]
|
||||
* @param string|null $title Default text for the content, usually the title [optional - if omitted, some services will figure out on their own]
|
||||
* @return void
|
||||
*/
|
||||
public function __construct( \IPS\Http\Url $url=NULL, $title=NULL )
|
||||
public function __construct( Url|null $url=NULL, string|null $title=NULL )
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->title = $title;
|
||||
@@ -116,5 +122,5 @@ abstract class _ShareServices
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
abstract public function __toString();
|
||||
abstract public function __toString(): string;
|
||||
}
|
||||
@@ -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 '';
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user