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

@@ -1,71 +0,0 @@
<?php
/**
* @brief BBCode Tag
* @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
* @subpackage Blogs
* @since 05 Feb 2016
*/
namespace IPS\blog\extensions\core\BBCode;
/* 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;
}
/**
* BBCode Tag
*/
class _blog
{
/**
* Permission Check
*
* @param \IPS\Member $member The member
* @param string $area The Editor area
* @return bool
*/
public function permissionCheck( \IPS\Member $member, $area )
{
return \IPS\Text\Parser::canUse( $member, 'ipsLink', $area );
}
/**
* Get Configuration
*
* @code
return array(
'tag' => 'span', // The HTML tag to use
'attributes' => array( ... ) // Key/Value pairs of attributes to use (optional) - can use {option} to get the [tag=option] value
'callback' => function( $node, $matches, $document ) // A callback to modify the DOMNode object
{
...
},
'block' => FALSE, // If this is a block-level tag (optional, default false)
'single' => FALSE, // If this is a single tag, with no content (optional, default false)
)
* @endcode
* @return array
*/
public function getConfiguration()
{
return array(
'tag' => 'a',
'callback' => function( \DOMElement $node, $matches, \DOMDocument $document )
{
try
{
$node->setAttribute( 'href', (string) \IPS\blog\Blog::load( \intval( $matches[2] ) )->url() );
}
catch ( \Exception $e ) {}
return $node;
},
);
}
}
@@ -1,71 +0,0 @@
<?php
/**
* @brief BBCode Tag
* @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
* @subpackage Blogs
* @since 08 Feb 2016
*/
namespace IPS\blog\extensions\core\BBCode;
/* 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;
}
/**
* BBCode Tag
*/
class _entry
{
/**
* Permission Check
*
* @param \IPS\Member $member The member
* @param string $area The Editor area
* @return bool
*/
public function permissionCheck( \IPS\Member $member, $area )
{
return \IPS\Text\Parser::canUse( $member, 'ipsLink', $area );
}
/**
* Get Configuration
*
* @code
return array(
'tag' => 'span', // The HTML tag to use
'attributes' => array( ... ) // Key/Value pairs of attributes to use (optional) - can use {option} to get the [tag=option] value
'callback' => function( $node, $matches, $document ) // A callback to modify the DOMNode object
{
...
},
'block' => FALSE, // If this is a block-level tag (optional, default false)
'single' => FALSE, // If this is a single tag, with no content (optional, default false)
)
* @endcode
* @return array
*/
public function getConfiguration()
{
return array(
'tag' => 'a',
'callback' => function( \DOMElement $node, $matches, \DOMDocument $document )
{
try
{
$node->setAttribute( 'href', (string) \IPS\blog\Entry::load( \intval( $matches[2] ) )->url() );
}
catch ( \Exception $e ) {}
return $node;
},
);
}
}
Whitespace-only changes.
@@ -12,41 +12,43 @@
namespace IPS\blog\extensions\core\ContentRouter;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Application\Module;
use IPS\Extensions\ContentRouterAbstract;
use IPS\Member;
use IPS\Member\Group;
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;
}
/**
* @brief Content Router extension: Entries
*/
class _Blog
class Blog extends ContentRouterAbstract
{
/**
* @brief Owned Node Classes
*/
public $ownedNodes = array( 'IPS\blog\Blog' );
/**
* @brief Content Item Classes
*/
public $classes = array();
public array $ownedNodes = array( 'IPS\blog\Blog' );
/**
* @brief Can be shown in similar content
*/
public $similarContent = TRUE;
public bool $similarContent = TRUE;
/**
* Constructor
*
* @param \IPS\Member|\IPS\Member\Group|NULL $member If checking access, the member/group to check for, or NULL to not check access
* @param Group|Member|null $member If checking access, the member/group to check for, or NULL to not check access
* @return void
*/
public function __construct( $member = NULL )
public function __construct( Group|Member $member = NULL )
{
if ( $member === NULL or $member->canAccessModule( \IPS\Application\Module::get( 'blog', 'blogs', 'front' ) ) )
if ( $member === NULL or $member->canAccessModule( Module::get( 'blog', 'blogs', 'front' ) ) )
{
$this->classes[] = 'IPS\blog\Entry';
}
@@ -1,70 +0,0 @@
<?php
/**
* @brief Create Menu Extension : Entry
* @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
* @subpackage Blog
* @since 10 Mar 2014
*/
namespace IPS\blog\extensions\core\CreateMenu;
/* 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;
}
/**
* Create Menu Extension: Entry
*/
class _Entry
{
/**
* Get Items
*
* @return array
*/
public function getItems()
{
/* Posting limits */
if ( \IPS\Member::loggedIn()->checkPostsPerDay() === FALSE )
{
return array();
}
$blogs = \IPS\blog\Blog::loadByOwner( \IPS\Member::loggedIn(), array( array( 'blog_disabled=?', 0 ) ) );
if (
\count( $blogs )
or
( \IPS\Settings::i()->club_nodes_in_apps and \count( \IPS\blog\Blog::clubNodes( 'add' ) ) )
) {
if ( !\IPS\Settings::i()->club_nodes_in_apps AND \count( $blogs ) === 1 )
{
$ourBlog = array_shift( $blogs );
return array(
'blog_entry' => array(
'link' => \IPS\Http\Url::internal( "app=blog&module=blogs&controller=submit&id=" . $ourBlog->_id, 'front', 'blog_submit' ),
)
);
}
else
{
return array(
'blog_entry' => array(
'link' => \IPS\Http\Url::internal( "app=blog&module=blogs&controller=submit", 'front', 'blog_submit' ),
'extraData' => array( 'data-ipsDialog' => true, 'data-ipsDialog-size' => "narrow", ),
'title' => 'select_blog'
)
);
}
}
else
{
return array();
}
}
}
Whitespace-only changes.
@@ -12,23 +12,29 @@
namespace IPS\blog\extensions\core\Dashboard;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Db;
use IPS\Extensions\DashboardAbstract;
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;
}
/**
* @brief Dashboard extension: Overview
*/
class _Overview
class Overview extends DashboardAbstract
{
/**
* Can the current user view this dashboard item?
*
* @return bool
*/
public function canView()
public function canView(): bool
{
return TRUE;
}
@@ -38,26 +44,16 @@ class _Overview
*
* @return string
*/
public function getBlock()
public function getBlock(): string
{
/* Basic stats */
$data = array(
'total_blogs' => (int) \IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs' )->first(),
'total_entries' => (int) \IPS\Db::i()->select( 'COUNT(*)', 'blog_entries' )->first(),
'total_comments' => (int) \IPS\Db::i()->select( 'COUNT(*)', 'blog_comments' )->first(),
'total_blogs' => (int) Db::i()->select( 'COUNT(*)', 'blog_blogs' )->first(),
'total_entries' => (int) Db::i()->select( 'COUNT(*)', 'blog_entries' )->first(),
'total_comments' => (int) Db::i()->select( 'COUNT(*)', 'blog_comments' )->first(),
);
/* Display */
return \IPS\Theme::i()->getTemplate( 'dashboard', 'blog' )->overview( $data );
}
/**
* Return the block information
*
* @return array array( 'name' => 'Block title', 'key' => 'unique_key', 'size' => [1,2,3], 'by' => 'Author name' )
*/
public function getInfo()
{
return array();
return Theme::i()->getTemplate( 'dashboard', 'blog' )->overview( $data );
}
}
@@ -12,36 +12,41 @@
namespace IPS\blog\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use InvalidArgumentException;
use IPS\blog\Blog;
use IPS\blog\Entry\Comment;
use IPS\Content;
use IPS\Db;
use IPS\Extensions\EditorLocationsAbstract;
use IPS\Helpers\Form\Editor;
use IPS\Http\Url;
use IPS\Member;
use IPS\Node\Model;
use IPS\Text\Parser;
use LogicException;
use RuntimeException;
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;
}
/**
* Editor Extension: Blogs
*/
class _Blogs
class Blogs extends EditorLocationsAbstract
{
/**
* Can we use HTML in this editor?
*
* @param \IPS\Member $member The member
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
*/
public function canUseHtml( $member )
{
return NULL;
}
/**
* Can we use attachments in this editor?
*
* @param \IPS\Member $member The member
* @param \IPS\Helpers\Form\Editor $field The editor field
* @param Member $member The member
* @param Editor $field The editor field
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
*/
public function canAttach( $member, $field )
public function canAttach( Member $member, Editor $field ): ?bool
{
return NULL;
}
@@ -50,11 +55,11 @@ class _Blogs
* Can whatever is posted in this editor be moderated?
* If this returns TRUE, we must ensure the content is ran through word, link and image filters
*
* @param \IPS\Member $member The member
* @param \IPS\Helpers\Form\Editor $field The editor field
* @param Member $member The member
* @param Editor $field The editor field
* @return bool
*/
public function canBeModerated( $member, $field )
public function canBeModerated( Member $member, Editor $field ): bool
{
if ( preg_match( '/^blogs\-(?:new-blog|blog|new-blog-sidebar|new-blog-group\d+)$/', $field->options['autoSaveKey'] ) )
{
@@ -80,89 +85,72 @@ class _Blogs
{
if ( \IPS\IN_DEV )
{
throw new \RuntimeException( 'Unknown canBeModerated: ' . $field->options['autoSaveKey'] );
throw new RuntimeException( 'Unknown canBeModerated: ' . $field->options['autoSaveKey'] );
}
return FALSE;
return parent::canBeModerated( $member, $field );
}
}
/**
* Permission check for attachments
*
* @param \IPS\Member $member The member
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
* @param Member $member The member
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
* @return bool
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
public function attachmentPermissionCheck( Member $member, ?int $id1, ?int $id2, ?string $id3, array $attachment, bool $viewOnly=FALSE ): bool
{
/* The attachment is attached to a comment */
if ( $id2 )
{
return \IPS\blog\Entry\Comment::load( $id2 )->canView( $member );
return Comment::load( $id2 )->canView( $member );
}
else
{
return \IPS\blog\Blog::load( $id1 )->can( 'view', $member );
return Blog::load( $id1 )->can( 'view', $member );
}
}
/**
* Attachment lookup
*
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @return \IPS\blog\Blog
* @throws \LogicException
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @return Content|Member|Model|Url|null
* @throws LogicException
*/
public function attachmentLookup( $id1, $id2, $id3 )
public function attachmentLookup( ?int $id1=null, ?int $id2=null, ?string $id3=null ): Model|Content|Url|Member|null
{
/* The attachment is attached to a comment */
if ( $id2 )
{
return \IPS\blog\Entry\Comment::load( $id2 );
return Comment::load( $id2 );
}
else
{
return \IPS\blog\Blog::load( $id1 );
return Blog::load( $id1 );
}
}
/**
* Rebuild attachment images in non-content item areas
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildAttachmentImages( $offset, $max )
{
return $this->performRebuild( $offset, $max, array( 'IPS\Text\Parser', 'rebuildAttachmentUrls' ) );
}
/**
* Rebuild content post-upgrade
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildContent( $offset, $max )
public function rebuildContent( ?int $offset, ?int $max ): int
{
return $this->performRebuild( $offset, $max, array( 'IPS\Text\LegacyParser', 'parseStatic' ) );
}
/**
* @brief Use the cached image URL instead of the original URL
*/
protected $proxyUrl = FALSE;
/**
* Rebuild content to add or remove image proxy
*
@@ -172,66 +160,53 @@ class _Blogs
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
public function rebuildImageProxy( ?int $offset, ?int $max, bool $proxyUrl = FALSE ): int
{
$this->proxyUrl = $proxyUrl;
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
$callback = function( $value ) use ( $proxyUrl ) {
return Parser::removeImageProxy( $value, $proxyUrl );
};
return $this->performRebuild( $offset, $max, $callback );
}
/**
* @brief Store lazy loading status ( true = enabled )
*/
protected $_lazyLoadStatus = null;
/**
* Rebuild content to add or remove lazy loading
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable lazy loading
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
public function rebuildLazyLoad( ?int $offset, ?int $max ): int
{
$this->_lazyLoadStatus = $status;
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
return $this->performRebuild( $offset, $max, [ 'IPS\Text\Parser', 'parseLazyLoad' ] );
}
/**
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param callable $callback Method to call to rebuild content
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param callable $callback Method to call to rebuild content
* @return int Number completed
*/
protected function performRebuild( $offset, $max, $callback )
protected function performRebuild( ?int $offset, ?int $max, callable $callback ): int
{
$did = 0;
/* Language bits */
foreach( \IPS\Db::i()->select( '*', 'core_sys_lang_words', "word_key LIKE 'blogs_blog_%_desc'", 'word_id ASC', array( $offset, $max ) ) as $word )
foreach( Db::i()->select( '*', 'core_sys_lang_words', "word_key LIKE 'blogs_blog_%_desc'", 'word_id ASC', array( $offset, $max ) ) as $word )
{
$did++;
$rebuilt = FALSE;
try
{
if( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::removeImageProxy( $word['word_custom'], $this->proxyUrl );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $word['word_custom'], $this->_lazyLoadStatus );
}
else
if( !empty( $word['word_custom'] ) )
{
$rebuilt = $callback( $word['word_custom'] );
}
}
catch( \InvalidArgumentException $e )
catch( InvalidArgumentException $e )
{
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
{
@@ -245,7 +220,7 @@ class _Blogs
if( $rebuilt !== FALSE )
{
\IPS\Db::i()->update( 'core_sys_lang_words', array( 'word_custom' => $rebuilt ), 'word_id=' . $word['word_id'] );
Db::i()->update( 'core_sys_lang_words', array( 'word_custom' => $rebuilt ), 'word_id=' . $word['word_id'] );
}
}
@@ -257,8 +232,8 @@ class _Blogs
*
* @return int Total Count
*/
public function contentCount()
public function contentCount(): int
{
return \IPS\Db::i()->select( 'COUNT(*) as count', 'core_sys_lang_words', "word_key LIKE 'blogs_blog_%_desc'" )->first();
return Db::i()->select( 'COUNT(*) as count', 'core_sys_lang_words', "word_key LIKE 'blogs_blog_%_desc'" )->first();
}
}
@@ -12,36 +12,38 @@
namespace IPS\blog\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use InvalidArgumentException;
use IPS\Content;
use IPS\Db;
use IPS\Extensions\EditorLocationsAbstract;
use IPS\Helpers\Form\Editor;
use IPS\Http\Url;
use IPS\Member;
use IPS\Node\Model;
use IPS\Text\Parser;
use LogicException;
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;
}
/**
* Editor Extension: Categories
*/
class _Categories
class Categories extends EditorLocationsAbstract
{
/**
* Can we use HTML in this editor?
*
* @param \IPS\Member $member The member
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
*/
public function canUseHtml( $member )
{
return NULL;
}
/**
* Can we use attachments in this editor?
*
* @param \IPS\Member $member The member
* @param \IPS\Helpers\Form\Editor $field The editor field
* @param Member $member The member
* @param Editor $field The editor field
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
*/
public function canAttach( $member, $field )
public function canAttach( Member $member, Editor $field ): ?bool
{
return NULL;
}
@@ -49,15 +51,15 @@ class _Categories
/**
* Permission check for attachments
*
* @param \IPS\Member $member The member
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
* @param Member $member The member
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
* @return bool
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
public function attachmentPermissionCheck( Member $member, ?int $id1, ?int $id2, ?string $id3, array $attachment, bool $viewOnly=FALSE ): bool
{
return TRUE;
}
@@ -65,108 +67,80 @@ class _Categories
/**
* Attachment lookup
*
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @return \IPS\Http\Url|\IPS\Content|\IPS\Node\Model
* @throws \LogicException
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @return Content|Member|Model|Url|NULL
* @throws LogicException
*/
public function attachmentLookup( $id1, $id2, $id3 )
public function attachmentLookup( ?int $id1=null, ?int $id2=null, ?string $id3=null ): Model|Content|Url|Member|null
{
switch ( $id3 )
{
case 'bcategory':
return \IPS\Http\Url::internal( "app=blog&module=blogs&controller=categories&do=form&id={$id1}", 'admin' );
break;
};
}
return Url::internal( "app=blog&module=blogs&controller=categories&do=form&id={$id1}", 'admin' );
}
/**
* Rebuild attachment images in non-content item areas
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildAttachmentImages( $offset, $max )
{
return $this->performRebuild( $offset, $max, array( 'IPS\Text\Parser', 'rebuildAttachmentUrls' ) );
return NULL;
}
/**
* @brief Use the cached image URL instead of the original URL
*/
protected $proxyUrl = FALSE;
/**
* Rebuild content to add or remove image proxy
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $proxyUrl Use the cached image URL instead of the original URL
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $proxyUrl Use the cached image URL instead of the original URL
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildImageProxy( $offset, $max, $proxyUrl = FALSE )
public function rebuildImageProxy( ?int $offset, ?int $max, bool $proxyUrl=FALSE ): int
{
$this->proxyUrl = $proxyUrl;
return $this->performRebuild( $offset, $max, 'parseImageProxy' );
$callback = function( $value ) use ( $proxyUrl ) {
return Parser::removeImageProxy( $value, $proxyUrl );
};
return $this->performRebuild( $offset, $max, $callback );
}
/**
* @brief Store lazy loading status ( true = enabled )
*/
protected $_lazyLoadStatus = null;
/**
* Rebuild content to add or remove lazy loading
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param bool $status Enable/Disable lazy loading
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @return int Number completed
* @note This method is optional and will only be called if it exists
*/
public function rebuildLazyLoad( $offset, $max, $status=TRUE )
public function rebuildLazyLoad( ?int $offset, ?int $max ): int
{
$this->_lazyLoadStatus = $status;
return $this->performRebuild( $offset, $max, 'parseLazyLoad' );
return $this->performRebuild( $offset, $max, [ 'IPS\Text\Parser', 'parseLazyLoad' ] );
}
/**
* Perform rebuild - abstracted as the call for rebuildContent() and rebuildAttachmentImages() is nearly identical
*
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param callable $callback Method to call to rebuild content
* @return int Number completed
* @param int|null $offset Offset to start from
* @param int|null $max Maximum to parse
* @param callable $callback Method to call to rebuild content
* @return int
*/
protected function performRebuild( $offset, $max, $callback )
protected function performRebuild( ?int $offset, ?int $max, callable $callback ): int
{
/* We will do everything except pages first */
$did = 0;
if( !$offset )
{
/* Language bits */
foreach( \IPS\Db::i()->select( '*', 'core_sys_lang_words', "word_key LIKE 'blog_category_%_desc'", 'word_id ASC', array( $offset, $max ) ) as $word )
foreach( Db::i()->select( '*', 'core_sys_lang_words', "word_key LIKE 'blog_category_%_desc'", 'word_id ASC', array( $offset, $max ) ) as $word )
{
$did++;
$rebuilt = FALSE;
try
{
if( $callback == 'parseImageProxy' )
{
$rebuilt = \IPS\Text\Parser::removeImageProxy( $word['word_custom'], $this->proxyUrl );
}
elseif( $callback == 'parseLazyLoad' )
{
$rebuilt = \IPS\Text\Parser::parseLazyLoad( $word['word_custom'], $this->_lazyLoadStatus );
}
else
if( !empty( $word['word_custom'] ) )
{
$rebuilt = $callback( $word['word_custom'] );
}
}
catch( \InvalidArgumentException $e )
catch( InvalidArgumentException $e )
{
if( $callback[1] == 'parseStatic' AND $e->getcode() == 103014 )
{
@@ -180,11 +154,12 @@ class _Categories
if( $rebuilt !== FALSE )
{
\IPS\Db::i()->update( 'core_sys_lang_words', array( 'word_custom' => $rebuilt ), 'word_id=' . $word['word_id'] );
Db::i()->update( 'core_sys_lang_words', array( 'word_custom' => $rebuilt ), 'word_id=' . $word['word_id'] );
}
}
}
return $did;
}
/**
@@ -192,8 +167,8 @@ class _Categories
*
* @return int Total Count
*/
public function contentCount()
public function contentCount(): int
{
return \IPS\Db::i()->select( 'COUNT(*) as count', 'core_sys_lang_words', "word_key LIKE 'blog_category_%_desc'" )->first();
return Db::i()->select( 'COUNT(*) as count', 'core_sys_lang_words', "word_key LIKE 'blog_category_%_desc'" )->first();
}
}
@@ -12,36 +12,37 @@
namespace IPS\blog\extensions\core\EditorLocations;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\blog\Entry;
use IPS\Content;
use IPS\Extensions\EditorLocationsAbstract;
use IPS\Helpers\Form\Editor;
use IPS\Http\Url;
use IPS\Member;
use IPS\Node\Model;
use LogicException;
use RuntimeException;
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;
}
/**
* Editor Extension: Blogs
*/
class _Entries
class Entries extends EditorLocationsAbstract
{
/**
* Can we use HTML in this editor?
*
* @param \IPS\Member $member The member
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
*/
public function canUseHtml( $member )
{
return NULL;
}
/**
* Can we use attachments in this editor?
*
* @param \IPS\Member $member The member
* @param \IPS\Helpers\Form\Editor $field The editor field
* @param Member $member The member
* @param Editor $field The editor field
* @return bool|null NULL will cause the default value (based on the member's permissions) to be used, and is recommended in most cases. A boolean value will override that.
*/
public function canAttach( $member, $field )
public function canAttach( Member $member, Editor $field ): ?bool
{
return NULL;
}
@@ -50,11 +51,11 @@ class _Entries
* Can whatever is posted in this editor be moderated?
* If this returns TRUE, we must ensure the content is ran through word, link and image filters
*
* @param \IPS\Member $member The member
* @param \IPS\Helpers\Form\Editor $field The editor field
* @param Member $member The member
* @param Editor $field The editor field
* @return bool
*/
public function canBeModerated( $member, $field )
public function canBeModerated( Member $member, Editor $field ): bool
{
if ( preg_match( '/^blog\-(?:entry|edit)\-\d+$/', $field->options['autoSaveKey'] ) )
{
@@ -64,40 +65,41 @@ class _Entries
{
if ( \IPS\IN_DEV )
{
throw new \RuntimeException( 'Unknown canBeModerated: ' . $field->options['autoSaveKey'] );
throw new RuntimeException( 'Unknown canBeModerated: ' . $field->options['autoSaveKey'] );
}
return FALSE;
return parent::canBeModerated( $member, $field );
}
}
/**
* Permission check for attachments
*
* @param \IPS\Member $member The member
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
* @param Member $member The member
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @param array $attachment The attachment data
* @param bool $viewOnly If true, just check if the user can see the attachment rather than download it
* @return bool
*/
public function attachmentPermissionCheck( $member, $id1, $id2, $id3, $attachment, $viewOnly=FALSE )
public function attachmentPermissionCheck( Member $member, ?int $id1, ?int $id2, ?string $id3, array $attachment, bool $viewOnly=FALSE ): bool
{
return \IPS\blog\Entry::load( $id1 )->canView( $member );
return Entry::load( $id1 )->canView( $member );
}
/**
* Attachment lookup
*
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @return \IPS\blog\Blog
* @throws \LogicException
* @param int|null $id1 Primary ID
* @param int|null $id2 Secondary ID
* @param string|null $id3 Arbitrary data
* @return Content|Member|Model|Url|null
* @throws LogicException
*/
public function attachmentLookup( $id1, $id2, $id3 )
public function attachmentLookup( ?int $id1=null, ?int $id2=null, ?string $id3=null ): Model|Content|Url|Member|null
{
return \IPS\blog\Entry::load( $id1 );
return Entry::load( $id1 );
}
}
@@ -12,86 +12,78 @@
namespace IPS\blog\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\Db;
use IPS\Extensions\FileStorageAbstract;
use IPS\File;
use UnderflowException;
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;
}
/**
* File Storage Extension: Blogs (cover photos)
*/
class _Blogs
class Blogs extends FileStorageAbstract
{
/**
* Count stored files
*
* @return int
*/
public function count()
public function count(): int
{
return \IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs', 'blog_cover_photo IS NOT NULL' )->first();
return Db::i()->select( 'COUNT(*)', 'blog_blogs', 'blog_cover_photo IS NOT NULL' )->first();
}
/**
* Move stored files
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|NULL $oldConfiguration Old storage configuration ID
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|null $oldConfiguration Old storage configuration ID
* @return void
*@throws UnderflowException When file record doesn't exist. Indicating there are no more files to move
*/
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
{
$record = \IPS\Db::i()->select( '*', 'blog_blogs', 'blog_cover_photo IS NOT NULL', 'blog_id', array( $offset, 1 ) )->first();
$record = Db::i()->select( '*', 'blog_blogs', 'blog_cover_photo IS NOT NULL', 'blog_id', array( $offset, 1 ) )->first();
try
{
$file = \IPS\File::get( $oldConfiguration ?: 'blog_Blogs', $record['blog_cover_photo'] )->move( $storageConfiguration );
$file = File::get( $oldConfiguration ?: 'blog_Blogs', $record['blog_cover_photo'] )->move( $storageConfiguration );
if ( (string) $file != $record['blog_cover_photo'] )
{
\IPS\Db::i()->update( 'blog_blogs', array( 'blog_cover_photo' => (string) $file ), array( 'blog_id=?', $record['blog_id'] ) );
Db::i()->update( 'blog_blogs', array( 'blog_cover_photo' => (string) $file ), array( 'blog_id=?', $record['blog_id'] ) );
}
}
catch( \Exception $e )
catch( Exception )
{
/* Any issues are logged and the \IPS\Db::i()->update not run as the exception is thrown */
}
}
/**
* Fix all URLs
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @return void
*/
public function fixUrls( $offset )
{
$record = \IPS\Db::i()->select( '*', 'blog_blogs', 'blog_cover_photo IS NOT NULL', 'blog_id', array( $offset, 1 ) )->first();
if ( $new = \IPS\File::repairUrl( $record['blog_cover_photo'] ) )
{
\IPS\Db::i()->update( 'blog_blogs', array( 'blog_cover_photo' => $new ), array( 'blog_id=?', $record['blog_id'] ) );
}
}
/**
* Check if a file is valid
*
* @param string $file The file path to check
* @param File|string $file The file path to check
* @return bool
*/
public function isValidFile( $file )
public function isValidFile( File|string $file ): bool
{
try
{
$record = \IPS\Db::i()->select( '*', 'blog_blogs', array( 'blog_cover_photo=?', (string) $file ) )->first();
$record = Db::i()->select( '*', 'blog_blogs', array( 'blog_cover_photo=?', (string) $file ) )->first();
return TRUE;
}
catch ( \UnderflowException $e )
catch ( UnderflowException )
{
return FALSE;
}
@@ -102,15 +94,15 @@ class _Blogs
*
* @return void
*/
public function delete()
public function delete() : void
{
foreach( \IPS\Db::i()->select( '*', 'blog_blogs', 'blog_cover_photo IS NOT NULL' ) as $blog )
foreach( Db::i()->select( '*', 'blog_blogs', 'blog_cover_photo IS NOT NULL' ) as $blog )
{
try
{
\IPS\File::get( 'blog_Blogs', $blog['blog_cover_photo'] )->delete();
File::get( 'blog_Blogs', $blog['blog_cover_photo'] )->delete();
}
catch( \Exception $e ){}
catch( Exception ){}
}
}
}
@@ -12,86 +12,78 @@
namespace IPS\blog\extensions\core\FileStorage;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\Db;
use IPS\Extensions\FileStorageAbstract;
use IPS\File;
use UnderflowException;
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;
}
/**
* File Storage Extension: Blog Entries (cover photos)
*/
class _Entries
class Entries extends FileStorageAbstract
{
/**
* Count stored files
*
* @return int
*/
public function count()
public function count(): int
{
return \IPS\Db::i()->select( 'COUNT(*)', 'blog_entries', 'entry_cover_photo IS NOT NULL' )->first();
return Db::i()->select( 'COUNT(*)', 'blog_entries', 'entry_cover_photo IS NOT NULL' )->first();
}
/**
* Move stored files
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|NULL $oldConfiguration Old storage configuration ID
* @throws \Underflowexception When file record doesn't exist. Indicating there are no more files to move
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @param int $storageConfiguration New storage configuration ID
* @param int|null $oldConfiguration Old storage configuration ID
* @return void
*@throws UnderflowException When file record doesn't exist. Indicating there are no more files to move
*/
public function move( $offset, $storageConfiguration, $oldConfiguration=NULL )
public function move( int $offset, int $storageConfiguration, int $oldConfiguration=NULL ) : void
{
$record = \IPS\Db::i()->select( '*', 'blog_entries', 'entry_cover_photo IS NOT NULL', 'entry_id', array( $offset, 1 ) )->first();
$record = Db::i()->select( '*', 'blog_entries', 'entry_cover_photo IS NOT NULL', 'entry_id', array( $offset, 1 ) )->first();
try
{
$file = \IPS\File::get( $oldConfiguration ?: 'blog_Entries', $record['entry_cover_photo'] )->move( $storageConfiguration );
$file = File::get( $oldConfiguration ?: 'blog_Entries', $record['entry_cover_photo'] )->move( $storageConfiguration );
if ( (string) $file != $record['entry_cover_photo'] )
{
\IPS\Db::i()->update( 'blog_entries', array( 'entry_cover_photo' => (string) $file ), array( 'entry_id=?', $record['entry_id'] ) );
Db::i()->update( 'blog_entries', array( 'entry_cover_photo' => (string) $file ), array( 'entry_id=?', $record['entry_id'] ) );
}
}
catch( \Exception $e )
catch( Exception )
{
/* Any issues are logged and the \IPS\Db::i()->update not run as the exception is thrown */
}
}
/**
* Fix all URLs
*
* @param int $offset This will be sent starting with 0, increasing to get all files stored by this extension
* @return void
*/
public function fixUrls( $offset )
{
$record = \IPS\Db::i()->select( '*', 'blog_entries', 'entry_cover_photo IS NOT NULL', 'entry_id', array( $offset, 1 ) )->first();
if ( $new = \IPS\File::repairUrl( $record['blog_cover_photo'] ) )
{
\IPS\Db::i()->update( 'blog_entries', array( 'blog_cover_photo' => $new ), array( 'entry_id=?', $record['entry_id'] ) );
}
}
/**
* Check if a file is valid
*
* @param string $file The file path to check
* @param File|string $file The file path to check
* @return bool
*/
public function isValidFile( $file )
public function isValidFile( File|string $file ): bool
{
try
{
$record = \IPS\Db::i()->select( '*', 'blog_entries', array( 'entry_cover_photo=?', (string) $file ) )->first();
$record = Db::i()->select( '*', 'blog_entries', array( 'entry_cover_photo=?', (string) $file ) )->first();
return TRUE;
}
catch ( \UnderflowException $e )
catch ( UnderflowException )
{
return FALSE;
}
@@ -102,15 +94,15 @@ class _Entries
*
* @return void
*/
public function delete()
public function delete() : void
{
foreach( \IPS\Db::i()->select( '*', 'blog_entries', 'entry_cover_photo IS NOT NULL' ) as $blog )
foreach( Db::i()->select( '*', 'blog_entries', 'entry_cover_photo IS NOT NULL' ) as $blog )
{
try
{
\IPS\File::get( 'blog_Entries', $blog['entry_cover_photo'] )->delete();
File::get( 'blog_Entries', $blog['entry_cover_photo'] )->delete();
}
catch( \Exception $e ){}
catch( Exception ){}
}
}
}
@@ -12,64 +12,78 @@
namespace IPS\blog\extensions\core\FrontNavigation;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Application\Module;
use IPS\core\FrontNavigation;
use IPS\core\FrontNavigation\FrontNavigationAbstract;
use IPS\Dispatcher;
use IPS\Http\Url;
use IPS\Member;
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;
}
/**
* Front Navigation Extension: Blogs
*/
class _Blogs extends \IPS\core\FrontNavigation\FrontNavigationAbstract
class Blogs extends FrontNavigationAbstract
{
/**
* @var string Default icon
*/
public string $defaultIcon = '\f044';
/**
* Get Type Title which will display in the AdminCP Menu Manager
*
* @return string
*/
public static function typeTitle()
public static function typeTitle(): string
{
return \IPS\Member::loggedIn()->language()->addToStack('frontnavigation_blogs');
return Member::loggedIn()->language()->addToStack('frontnavigation_blogs');
}
/**
* Can the currently logged in user access the content this item links to?
*
* @return bool
* @return bool
*/
public function canAccessContent()
public function canAccessContent(): bool
{
return \IPS\Member::loggedIn()->canAccessModule( \IPS\Application\Module::get( 'blog', 'blogs' ) );
return Member::loggedIn()->canAccessModule( Module::get( 'blog', 'blogs' ) );
}
/**
* Get Title
*
* @return string
* @return string
*/
public function title()
public function title(): string
{
return \IPS\Member::loggedIn()->language()->addToStack('frontnavigation_blogs');
return Member::loggedIn()->language()->addToStack('frontnavigation_blogs');
}
/**
* Get Link
*
* @return \IPS\Http\Url
* @return string|Url|null
*/
public function link()
public function link(): Url|string|null
{
return \IPS\Http\Url::internal( "app=blog&module=blogs&controller=browse", 'front', 'blogs' );
return Url::internal( "app=blog&module=blogs&controller=browse", 'front', 'blogs' );
}
/**
* Is Active?
*
* @return bool
* @return bool
*/
public function active()
public function active(): bool
{
return !\IPS\core\FrontNavigation::$clubTabActive and \IPS\Dispatcher::i()->application->directory === 'blog';
return !FrontNavigation::$clubTabActive and !FrontNavigation::nodeExtensionIsActive( 'blog' ) and Dispatcher::i()->application->directory === 'blog';
}
}
@@ -11,53 +11,61 @@
namespace IPS\blog\extensions\core\GroupForm;
use IPS\Settings;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Extensions\GroupFormAbstract;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Number;
use IPS\Helpers\Form\YesNo;
use IPS\Member;
use IPS\Member\Group;
use IPS\Settings;
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;
}
/**
* Admin CP Group Form
*/
class _Blog
class Blog extends GroupFormAbstract
{
/**
* Process Form
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\Member\Group $group Existing Group
* @param Form $form The form
* @param Group $group Existing Group
* @return void
*/
public function process( &$form, $group )
public function process( Form $form, Group $group ) : void
{
if( $group->g_id != Settings::i()->guest_group )
{
$form->add(new \IPS\Helpers\Form\YesNo('g_blog_allowlocal', $group->g_blog_allowlocal, FALSE, array('togglesOn' => array('g_blog_maxblogs', 'g_blog_allowprivate', 'g_blog_preventpublish', 'g_blog_allowownmod', 'g_blog_allowdelete'))));
$form->add(new \IPS\Helpers\Form\Number('g_blog_maxblogs', $group->g_blog_maxblogs, FALSE, array('unlimited' => 0), NULL, NULL, NULL, 'g_blog_maxblogs'));
$form->add(new \IPS\Helpers\Form\YesNo('g_blog_allowprivate', $group->g_blog_allowprivate, FALSE, array(), NULL, NULL, NULL, 'g_blog_allowprivate'));
$form->add(new \IPS\Helpers\Form\YesNo('g_blog_allowownmod', $group->g_blog_allowownmod, FALSE, array(), NULL, NULL, NULL, 'g_blog_allowownmod'));
$form->add(new \IPS\Helpers\Form\YesNo('g_blog_allowdelete', $group->g_blog_allowdelete, FALSE, array(), NULL, NULL, NULL, 'g_blog_allowdelete'));
$form->add(new YesNo('g_blog_allowlocal', $group->g_blog_allowlocal, FALSE, array('togglesOn' => array('g_blog_maxblogs', 'g_blog_allowprivate', 'g_blog_preventpublish', 'g_blog_allowownmod', 'g_blog_allowdelete'))));
$form->add(new Number('g_blog_maxblogs', $group->g_blog_maxblogs, FALSE, array('unlimited' => 0), NULL, NULL, NULL, 'g_blog_maxblogs'));
$form->add(new YesNo('g_blog_allowprivate', $group->g_blog_allowprivate, FALSE, array(), NULL, NULL, NULL, 'g_blog_allowprivate'));
$form->add(new YesNo('g_blog_allowownmod', $group->g_blog_allowownmod, FALSE, array(), NULL, NULL, NULL, 'g_blog_allowownmod'));
$form->add(new YesNo('g_blog_allowdelete', $group->g_blog_allowdelete, FALSE, array(), NULL, NULL, NULL, 'g_blog_allowdelete'));
}
$form->add(new \IPS\Helpers\Form\YesNo('g_blog_allowcomment', $group->g_blog_allowcomment));
if( $group->g_id == Settings::i()->guest_group AND Settings::i()->post_before_registering and Settings::i()->bot_antispam_type !== 'none' )
$form->add(new YesNo('g_blog_allowcomment', $group->g_blog_allowcomment));
if( $group->g_id == Settings::i()->guest_group AND Settings::i()->post_before_registering )
{
\IPS\Member::loggedIn()->language()->words['g_blog_allowcomment_desc'] = \IPS\Member::loggedIn()->language()->addToStack('g_blog_allowcomment_guestreg');
Member::loggedIn()->language()->words['g_blog_allowcomment_desc'] = Member::loggedIn()->language()->addToStack('g_blog_allowcomment_guestreg');
}
}
/**
* Save
*
* @param array $values Values from form
* @param \IPS\Member\Group $group The group
* @param array $values Values from form
* @param Group $group The group
* @return void
*/
public function save( $values, &$group )
public function save( array $values, Group $group ) : void
{
if( $group->g_id != Settings::i()->guest_group )
{
@@ -12,35 +12,44 @@
namespace IPS\blog\extensions\core\LiveSearch;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\blog\Blog;
use IPS\Db;
use IPS\Dispatcher;
use IPS\Extensions\LiveSearchAbstract;
use IPS\Member;
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;
}
/**
* @brief ACP Live Search Extension
*/
class _Blogs
class Blogs extends LiveSearchAbstract
{
/**
* Check we have access
*
* @return bool
*/
public function hasAccess()
public function hasAccess(): bool
{
/* Check Permissions */
return \IPS\Member::loggedIn()->hasAcpRestriction( 'blog', 'blog', 'blogs_manage' );
return Member::loggedIn()->hasAcpRestriction( 'blog', 'blog', 'blogs_manage' );
}
/**
* Get the search results
*
* @param string $searchTerm Search Term
* @param string $searchTerm Search Term
* @return array Array of results
*/
public function getResults( $searchTerm )
public function getResults( string $searchTerm ): array
{
/* Init */
$results = array();
@@ -50,10 +59,10 @@ class _Blogs
if( $this->hasAccess() )
{
/* Perform the search */
$blogs = \IPS\Db::i()->select(
$blogs = Db::i()->select(
"*",
'blog_blogs',
array( "blog_club_id IS NULL AND ( word_custom LIKE CONCAT( '%', ?, '%' ) AND lang_id=? )", $searchTerm, \IPS\Member::loggedIn()->language()->id ),
array( "blog_club_id IS NULL AND ( word_custom LIKE CONCAT( '%', ?, '%' ) AND lang_id=? )", $searchTerm, Member::loggedIn()->language()->id ),
NULL,
array( 0, 500 )
)->join(
@@ -64,9 +73,9 @@ class _Blogs
/* Format results */
foreach ( $blogs as $blog )
{
$blog = \IPS\blog\Blog::constructFromData( $blog );
$blog = Blog::constructFromData( $blog );
$results[] = \IPS\Theme::i()->getTemplate( 'livesearch', 'blog', 'admin' )->blog( $blog );
$results[] = Theme::i()->getTemplate( 'livesearch', 'blog', 'admin' )->blog( $blog );
}
}
@@ -78,8 +87,8 @@ class _Blogs
*
* @return bool
*/
public function isDefault()
public function isDefault(): bool
{
return \IPS\Dispatcher::i()->application->directory == 'blog';
return Dispatcher::i()->application->directory == 'blog';
}
}
@@ -12,53 +12,63 @@
namespace IPS\blog\extensions\core\MemberFilter;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Db;
use IPS\Db\Select;
use IPS\Extensions\MemberFilterAbstract;
use IPS\Helpers\Form\Radio;
use IPS\Member;
use LogicException;
use function defined;
use function in_array;
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 Filter Extension
*/
class _Blog
class Blog extends MemberFilterAbstract
{
/**
* Determine if the filter is available in a given area
*
* @param string $area Area to check
* @param string $area Area to check (bulkmail, group_permissions, automatic_moderation, passwordreset)
* @return bool
*/
public function availableIn( $area )
public function availableIn( string $area ): bool
{
return \in_array( $area, array( 'bulkmail', 'group_promotions' ) );
return in_array( $area, array( 'bulkmail', 'group_promotions' ) );
}
/**
* Get Setting Field
*
* @param mixed $criteria Value returned from the save() method
* @param array $criteria Value returned from the save() method
* @return array Array of form elements
*/
public function getSettingField( $criteria )
public function getSettingField( array $criteria ): array
{
$options = array( 'any' => 'any', 'yes' => 'yes', 'no' => 'no' );
return array(
new \IPS\Helpers\Form\Radio( 'mf_has_blog', isset( $criteria['has_blog'] ) ? $criteria['has_blog'] : 'any', FALSE, array( 'options' => $options ) ),
new Radio( 'mf_has_blog', $criteria['has_blog'] ?? 'any', FALSE, array( 'options' => $options ) ),
);
}
/**
* Save the filter data
*
* @param array $post Form values
* @return mixed False, or an array of data to use later when filtering the members
* @throws \LogicException
* @param array $post Form values
* @return bool|array False, or an array of data to use later when filtering the members
* @throws LogicException
*/
public function save( $post )
public function save( array $post ): bool|array
{
if( isset( $post['mf_has_blog'] ) and \in_array( $post['mf_has_blog'], array( 'yes', 'no' ) ) )
if( isset( $post['mf_has_blog'] ) and in_array( $post['mf_has_blog'], array( 'yes', 'no' ) ) )
{
return array( 'has_blog' => $post['mf_has_blog'] );
}
@@ -69,10 +79,10 @@ class _Blog
/**
* Get where clause to add to the member retrieval database query
*
* @param mixed $data The array returned from the save() method
* @param array $data The array returned from the save() method
* @return array|NULL Where clause - must be a single array( "clause" )
*/
public function getQueryWhereClause( $data )
public function getQueryWhereClause( array $data ): ?array
{
if( isset( $data['has_blog'] ) )
{
@@ -86,29 +96,28 @@ class _Blog
* Callback for member retrieval database query
* Can be used to set joins
*
* @param mixed $data The array returned from the save() method
* @param \IPS\Db\Query $query The query
* @return void
* @param array $data The array returned from the save() method
* @param Select $query The query
* @return void
*/
public function queryCallback( $data, &$query )
public function queryCallback( array $data, Select $query ) : void
{
if( isset( $data['has_blog'] ) )
{
$query->join( 'blog_blogs', "core_members.member_id=blog_blogs.blog_member_id" );
}
return NULL;
}
/**
* Determine if a member matches specified filters
*
* @param Member $member
* @param array $filters
* @param object|null $object
* @note This is only necessary if availableIn() includes group_promotions
* @param \IPS\Member $member Member object to check
* @param array $filters Previously defined filters
* @return bool
*/
public function matches( \IPS\Member $member, $filters )
public function matches( Member $member, array $filters, ?object $object = NULL ): bool
{
/* If we aren't filtering by this, then any member matches */
if( !isset( $filters['has_blog'] ) OR !$filters['has_blog'] )
@@ -116,7 +125,7 @@ class _Blog
return TRUE;
}
$result = (bool) \IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs', array( 'blog_member_id=?', $member->member_id ) )->first();
$result = (bool) Db::i()->select( 'COUNT(*)', 'blog_blogs', array( 'blog_member_id=?', $member->member_id ) )->first();
return ( $filters['has_blog'] == 'no' ) ? !$result : $result;
}
@@ -1,95 +0,0 @@
<?php
/**
* @brief Member Sync
* @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
* @subpackage Blog
* @since 20 Mar 2014
*/
namespace IPS\blog\extensions\core\MemberSync;
/* 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;
}
/**
* Member Sync
*/
class _Blog
{
/**
* Member is merged with another member
*
* @param \IPS\Member $member Member being kept
* @param \IPS\Member $member2 Member being removed
* @return void
*/
public function onMerge( $member, $member2 )
{
\IPS\Db::i()->update( 'blog_blogs', array( 'blog_member_id' => $member->member_id ), array( 'blog_member_id=?', $member2->member_id ) );
foreach( \IPS\blog\Blog::loadByOwner( $member2 ) as $blog )
{
/* Only do this if the blog is not a group blog */
if ( !$blog->groupblog_ids )
{
$blog->member_id = $member->member_id;
$blog->save();
}
}
}
/**
* Member is deleted
*
* @param $member \IPS\Member The member
* @return void
*/
public function onDelete( $member )
{
foreach( \IPS\blog\Blog::loadByOwner( $member ) as $blog )
{
/* We only want to do this if the blog is owned by the member - loadByOwner() also returns Blogs that are assigned to member groups */
if ( !$blog->groupblog_ids )
{
/* Delete blog entries & blog */
\IPS\Task::queue( 'core', 'DeleteOrMoveContent', array( 'class' => 'IPS\blog\Blog', 'id' => $blog->id, 'deleteWhenDone' => TRUE ) );
}
}
}
/**
* Member is flagged as spammer
*
* @param $member \IPS\Member The member
* @return void
*/
public function onSetAsSpammer( $member )
{
$actions = explode( ',', \IPS\Settings::i()->spm_option );
/* Hide or delete */
if ( \in_array( 'unapprove', $actions ) or \in_array( 'delete', $actions ) )
{
foreach( \IPS\blog\Blog::loadByOwner( $member ) as $blog )
{
if( !$blog->groupblog_ids )
{
$blog->disabled = TRUE;
$blog->save();
if( \in_array( 'delete', $actions ) )
{
\IPS\Task::queue( 'core', 'DeleteOrMoveContent', array( 'class' => 'IPS\blog\Blog', 'id' => $blog->id, 'deleteWhenDone' => TRUE ), 3 );
}
}
}
}
}
}
Whitespace-only changes.
@@ -12,16 +12,20 @@
namespace IPS\blog\extensions\core\ModeratorPermissions;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Extensions\ModeratorPermissionsAbstract;
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;
}
/**
* Moderator Permissions
*/
class _Blogs
class Blogs extends ModeratorPermissionsAbstract
{
/**
* Get Permissions
@@ -38,33 +42,11 @@ class _Blogs
...
);
* @endcode
* @param array $toggles
* @return array
*/
public function getPermissions()
public function getPermissions( array $toggles ): array
{
return array( 'can_mod_blogs' => 'YesNo' );
}
/**
* After change
*
* @param array $moderator The moderator
* @param array $changed Values that were changed
* @return void
*/
public function onChange( $moderator, $changed )
{
}
/**
* After delete
*
* @param array $moderator The moderator
* @return void
*/
public function onDelete( $moderator )
{
}
}
@@ -12,21 +12,28 @@
namespace IPS\blog\extensions\core\OverviewStatistics;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Db;
use IPS\Extensions\OverviewStatisticsAbstract;
use IPS\Member;
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;
}
/**
* @brief Overview statistics extension: Blogs
*/
class _Blogs
class Blogs extends OverviewStatisticsAbstract
{
/**
* @brief Which statistics page (activity or user)
*/
public $page = 'activity';
public string $page = 'activity';
/**
* Return the sub-block keys
@@ -34,7 +41,7 @@ class _Blogs
* @note This is designed to allow one class to support multiple blocks, for instance using the ContentRouter to generate blocks.
* @return array
*/
public function getBlocks()
public function getBlocks(): array
{
return array( 'blogs' );
}
@@ -42,26 +49,26 @@ class _Blogs
/**
* Return block details (title and description)
*
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
* @param string|null $subBlock The subblock we are loading as returned by getBlocks()
* @return array
*/
public function getBlockDetails( $subBlock = NULL )
public function getBlockDetails( string $subBlock = NULL ): array
{
/* Description can be null and will not be shown if so */
return array( 'app' => 'blog', 'title' => 'stats_overview_blogs', 'description' => \IPS\Member::loggedIn()->language()->addToStack( 'stats_overview_blogs_desc' ), 'refresh' => 120 );
return array( 'app' => 'blog', 'title' => 'stats_overview_blogs', 'description' => Member::loggedIn()->language()->addToStack( 'stats_overview_blogs_desc' ), 'refresh' => 120 );
}
/**
* Return the block HTML to show
*
* @param array|NULL $dateRange NULL for all time, or an array with 'start' and 'end' \IPS\DateTime objects to restrict to
* @param string|NULL $subBlock The subblock we are loading as returned by getBlocks()
* @param array|string|null $dateRange NULL for all time, or an array with 'start' and 'end' \IPS\DateTime objects to restrict to
* @param string|null $subBlock The subblock we are loading as returned by getBlocks()
* @return string
*/
public function getBlock( $dateRange = NULL, $subBlock = NULL )
public function getBlock( array|string|null $dateRange = NULL, string $subBlock = NULL ): string
{
$total = \IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs' )->first();
$total = Db::i()->select( 'COUNT(*)', 'blog_blogs' )->first();
return \IPS\Theme::i()->getTemplate( 'stats' )->overviewComparisonCount( $total, NULL, NULL );
return Theme::i()->getTemplate( 'stats' )->overviewComparisonCount( $total, NULL, NULL );
}
}
@@ -12,55 +12,47 @@
namespace IPS\blog\extensions\core\Profile;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\blog\Blog\ProfileTable;
use IPS\Db;
use IPS\Extensions\ProfileAbstract;
use IPS\Member;
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;
}
/**
* @brief Profile extension: Blogs
*/
class _Blog
class Blog extends ProfileAbstract
{
/**
* Member
*/
protected $member;
/**
* Constructor
*
* @param \IPS\Member $member Member whose profile we are viewing
* @return void
*/
public function __construct( \IPS\Member $member )
{
$this->member = $member;
}
/**
* Is there content to display?
*
* @return bool
*/
public function showTab()
public function showTab(): bool
{
$where = array(
array( '(' . \IPS\Db::i()->findInSet( 'blog_groupblog_ids', $this->member->groups ) . ' OR ' . 'blog_member_id=? )', $this->member->member_id ),
array( '(' . Db::i()->findInSet( 'blog_groupblog_ids', $this->member->groups ) . ' OR ' . 'blog_member_id=? )', $this->member->member_id ),
array( 'blog_disabled=0' )
);
if ( \IPS\Member::loggedIn()->member_id )
if ( Member::loggedIn()->member_id )
{
$where[] = array( '( blog_social_group IS NULL OR blog_member_id=? OR blog_social_group IN(?) )', \IPS\Member::loggedIn()->member_id, \IPS\Db::i()->select( 'group_id', 'core_sys_social_group_members', array( 'member_id=?', \IPS\Member::loggedIn()->member_id ) ) );
$where[] = array( '( blog_social_group IS NULL OR blog_member_id=? OR blog_social_group IN(?) )', Member::loggedIn()->member_id, Db::i()->select( 'group_id', 'core_sys_social_group_members', array( 'member_id=?', Member::loggedIn()->member_id ) ) );
}
else
{
$where[] = array( 'blog_social_group IS NULL' );
}
return (bool) \IPS\Db::i()->select( 'COUNT(*)', 'blog_blogs', $where )->first();
return (bool) Db::i()->select( 'COUNT(*)', 'blog_blogs', $where )->first();
}
/**
@@ -68,14 +60,12 @@ class _Blog
*
* @return string
*/
public function render()
public function render(): string
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'profile.css', 'blog', 'front' ) );
$table = new \IPS\blog\Blog\ProfileTable( $this->member->url() );
$table = new ProfileTable( $this->member->url() );
$table->setOwner( $this->member );
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'global', 'blog' ), 'profileBlogTable' );
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'global', 'blog' ), 'profileBlogRows' );
$table->tableTemplate = array( Theme::i()->getTemplate( 'global', 'blog' ), 'profileBlogTable' );
$table->rowsTemplate = array( Theme::i()->getTemplate( 'global', 'blog' ), 'profileBlogRows' );
return (string) $table;
}
@@ -1,130 +0,0 @@
<?php
/**
* @brief Background Task
* @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
* @subpackage Blogs
* @since 12 Apr 2016
*/
namespace IPS\blog\extensions\core\Queue;
/* 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;
}
/**
* Background Task
*/
class _RebuildEntryImages
{
/**
* @brief Number of entry images to rebuild per cycle
*/
public $rebuild = \IPS\REBUILD_SLOW;
/**
* Parse data before queuing
*
* @param array $data
* @return array
*/
public function preQueueData( $data )
{
$data['count'] = (int) \IPS\Db::i()->select( 'count(*)', 'blog_entries', "entry_image<>''" )->first();
if( $data['count'] == 0 )
{
return NULL;
}
return $data;
}
/**
* Run Background Task
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return int New offset
* @throws \IPS\Task\Queue\OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function run( $data, $offset )
{
$select = \IPS\Db::i()->select( '*', 'blog_entries', array( "entry_image<>? AND entry_id > ?", '', $offset ), 'entry_id ASC', array( 0, $this->rebuild ) );
$last = NULL;
foreach ( $select as $entry )
{
try
{
$filePath = \IPS\ROOT_PATH . '/uploads/' . $entry['entry_image'];
if ( ! file_exists( $filePath ) )
{
continue;
}
/* Have we processed this before? It's a bit crude but it is accurate */
if ( mb_substr( trim( $entry['entry_content'] ), 0, 37 ) === '<a href="<fileStore.core_Attachment>/' and mb_stristr( $entry['entry_content'], '/' . $entry['entry_image'] . '.' ) and mb_stristr( $entry['entry_content'], 'data-fileid="' ) )
{
continue;
}
$file = \IPS\File::create( 'core_Attachment', $entry['entry_image'], NULL, NULL, FALSE, $filePath );
$attachment = $file->makeAttachment('', \IPS\Member::load( $entry['entry_author_id'] ) );
$fileName = htmlspecialchars( $attachment['attach_file'], ENT_DISALLOWED, 'UTF-8', TRUE );
$image = <<<IMAGE
<a href="<fileStore.core_Attachment>/{$file}" class="ipsAttachLink ipsAttachLink_image" style="float:left;"><img data-fileid="{$attachment['attach_id']}" src="<fileStore.core_Attachment>/{$file}" class="ipsImage ipsImage_thumbnailed" style="margin:10px;" alt="{$fileName}"></a>
IMAGE;
\IPS\Db::i()->update( 'blog_entries', array( 'entry_content' => $image . $entry['entry_content'] ), array( 'entry_id=?', $entry['entry_id'] ) );
$map = array(
'attachment_id' => $attachment['attach_id'],
'location_key' => 'blog_Entries',
'id1' => $entry['entry_id'],
'id2' => NULL,
'id3' => NULL,
'temp' => NULL,
);
\IPS\Db::i()->replace( 'core_attachments_map', $map );
}
catch ( \Exception $e ) {}
$last = $entry['entry_id'];
}
if( $last === NULL )
{
throw new \IPS\Task\Queue\OutOfRangeException;
}
return $last;
}
/**
* Get Progress
*
* @param mixed $data Data as it was passed to \IPS\Task::queue()
* @param int $offset Offset
* @return array( 'text' => 'Doing something...', 'complete' => 50 ) Text explaining task and percentage complete
* @throws \OutOfRangeException Indicates offset doesn't exist and thus task is complete
*/
public function getProgress( $data, $offset )
{
return array(
'text' => \IPS\Member::loggedIn()->language()->addToStack( 'rebuilding_blog_entry_images', FALSE ),
'complete' => ( isset( $data['count'] ) AND $data['count'] )
? ( round( 100 / $data['count'] * $offset, 2 ) )
: 100
);
}
}
Whitespace-only changes.
@@ -12,23 +12,28 @@
namespace IPS\blog\extensions\core\RssImport;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Content;
use IPS\Content\Search\Index;
use IPS\core\Rss\Import;
use IPS\Extensions\RssImportAbstract;
use IPS\Helpers\Form;
use IPS\Member;
use IPS\Node\Model;
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;
}
/**
* @brief RSS Import extension: RssImport
*/
class _RssImport
class RssImport extends RssImportAbstract
{
/**
* @brief RSSImport Class
*/
public $classes = array();
public $fileStorage = 'blog_Blogs';
public string $fileStorage = 'blog_Blogs';
/**
* Constructor
@@ -45,7 +50,7 @@ class _RssImport
*
* @return array
*/
public function availableOptions()
public function availableOptions(): array
{
/* We don't want to set up Blog feeds in the ACP */
return array();
@@ -54,10 +59,9 @@ class _RssImport
/**
* Show in the Admin CP?
*
* @param Object $class The class to check
* @return boolean
*/
public function showInAdminCp( $class ): bool
public function showInAdminCp(): bool
{
return false;
}
@@ -65,26 +69,26 @@ class _RssImport
/**
* Node selector options
*
* @param \IPS\core\Rss\Import|null $rss Existing RSS object if editing|NULL if not
* @param Import|null $rss Existing RSS object if editing|null if not
* @return array
*/
public function nodeSelectorOptions( $rss )
public function nodeSelectorOptions( ?Import $rss ): array
{
return array( 'class' => 'IPS\blog\Blog', 'permissionCheck' => 'view' );
}
/**
* @param \IPS\core\Rss\Import $rss RSS object
* @param array $article RSS feed article importing
* @param \IPS\Node\Model $container Container object
* @param string $content Post content with read more link if set
* @return \IPS\Content
* @param Import $rss RSS object
* @param array $article RSS feed article importing
* @param Model $container Container object
* @param string $content Post content with read more link if set
* @return Content
*/
public function create( \IPS\core\Rss\Import $rss, $article, \IPS\Node\Model $container, $content )
public function create( Import $rss, array $article, Model $container, string $content ): Content
{
$settings = $rss->settings;
$class = $rss->_class;
$member = \IPS\Member::load( $rss->member );
$member = Member::load( $rss->member );
$entry = $class::createItem( $member, NULL, $article['date'], $container );
$entry->name = $article['title'];
$entry->content = $content;
@@ -92,7 +96,7 @@ class _RssImport
$entry->save();
/* Add to search index */
\IPS\Content\Search\Index::i()->index( $entry );
Index::i()->index( $entry );
/* Send notifications */
$entry->sendNotifications();
@@ -105,11 +109,11 @@ class _RssImport
/**
* Addition Form elements
*
* @param \IPS\Helpers\Form $form The form
* @param \IPS\core\Rss\Import|null $rss Existing RSS object if editing|NULL if not
* @param Form $form The form
* @param Import|null $rss Existing RSS object if editing|null if not
* @return void
*/
public function form( &$form, $rss=NULL )
public function form( Form $form, ?Import $rss=NULL ): void
{
/* Blogs has it's own front end controller */
}
@@ -117,11 +121,11 @@ class _RssImport
/**
* Process additional fields unique to this extension
*
* @param array $values Values from form
* @param \IPS\core\Rss\Import $rss Existing RSS object
* @param array $values Values from form
* @param Import $rss Existing RSS object
* @return array
*/
public function saveForm( &$values, $rss )
public function saveForm( array &$values, Import $rss ): array
{
/* Blogs has it's own front end controller */
return array( $values );
@@ -0,0 +1,62 @@
<?php
/**
* @brief SearchContent extension: Entries
* @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
* @subpackage Blogs
* @since 10 Jul 2023
*/
namespace IPS\blog\extensions\core\SearchContent;
/* To prevent PHP errors (extending class does not exist) revealing path */
use IPS\blog\Entry;
use IPS\Content\Search\SearchContentAbstract;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* @brief SearchContent extension: Entries
*/
class Entries extends SearchContentAbstract
{
/**
* Return all searchable classes in your application,
* including comments and/or reviews
*
* @return array
*/
public static function supportedClasses() : array
{
return array(
Entry::class,
Entry\Comment::class
);
}
/**
* Search Index Permissions
*
* @return string Comma-delimited values or '*'
* @li Number indicates a group
* @li Number prepended by "m" indicates a member
* @li Number prepended by "s" indicates a social group
*/
public function searchIndexPermissions(): string
{
if( $this->object instanceof Entry AND $this->object->status == 'draft' )
{
return '0';
}
return parent::searchIndexPermissions();
}
}