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
@@ -11,36 +11,52 @@
|
||||
|
||||
namespace IPS\blog;
|
||||
|
||||
use IPS\Application as SystemApplication;
|
||||
use IPS\Content\Filter;
|
||||
use IPS\DateTime;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Lang;
|
||||
use IPS\Login;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Group;
|
||||
use IPS\Output;
|
||||
use IPS\Request;
|
||||
use IPS\Settings;
|
||||
use IPS\Theme;
|
||||
use IPS\Xml\Rss;
|
||||
use OutOfRangeException;
|
||||
use function array_merge;
|
||||
|
||||
/**
|
||||
* Blog Application Class
|
||||
*/
|
||||
class _Application extends \IPS\Application
|
||||
class Application extends SystemApplication
|
||||
{
|
||||
/**
|
||||
* Init
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function init()
|
||||
public function init() : void
|
||||
{
|
||||
/* Handle RSS requests */
|
||||
if ( \IPS\Request::i()->module == 'blogs' and \IPS\Request::i()->controller == 'view' and \IPS\Request::i()->do == 'rss' )
|
||||
if ( Request::i()->module == 'blogs' and Request::i()->controller == 'view' and Request::i()->do == 'rss' )
|
||||
{
|
||||
$member = NULL;
|
||||
if( \IPS\Request::i()->member AND \IPS\Request::i()->key )
|
||||
if( Request::i()->member AND Request::i()->key )
|
||||
{
|
||||
$member = \IPS\Member::load( \IPS\Request::i()->member );
|
||||
if( !\IPS\Login::compareHashes( $member->getUniqueMemberHash(), (string) \IPS\Request::i()->key ) )
|
||||
$member = Member::load( Request::i()->member );
|
||||
if( !Login::compareHashes( $member->getUniqueMemberHash(), (string) Request::i()->key ) )
|
||||
{
|
||||
$member = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
$this->sendBlogRss( $member ?? new \IPS\Member );
|
||||
$this->sendBlogRss( $member ?? new Member );
|
||||
|
||||
if( !\IPS\Member::loggedIn()->group['g_view_board'] )
|
||||
if( !Member::loggedIn()->group['g_view_board'] )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2B221/1', 404, '' );
|
||||
Output::i()->error( 'node_error', '2B221/1', 404, '' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -48,45 +64,47 @@ class _Application extends \IPS\Application
|
||||
/**
|
||||
* Send the blog's RSS feed for the indicated member
|
||||
*
|
||||
* @param \IPS\Member $member Member
|
||||
* @param Member $member Member
|
||||
* @return void
|
||||
*/
|
||||
protected function sendBlogRss( $member )
|
||||
protected function sendBlogRss( Member $member ) : void
|
||||
{
|
||||
try
|
||||
{
|
||||
$blog = \IPS\blog\Blog::load( \IPS\Request::i()->id );
|
||||
$blog = Blog::load( Request::i()->id );
|
||||
|
||||
if( !$blog->can( 'view', $member ) )
|
||||
{
|
||||
throw new \OutOfRangeException;
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
/* We'll let the regular controller handle the error */
|
||||
return;
|
||||
}
|
||||
|
||||
if( !\IPS\Settings::i()->blog_allow_rss or !$blog->settings['allowrss'] )
|
||||
if( !Settings::i()->blog_allow_rss or !$blog->settings['allowrss'] )
|
||||
{
|
||||
\IPS\Output::i()->error( 'blog_rss_offline', '2B201/5', 403, 'blog_rss_offline_admin' );
|
||||
Output::i()->error( 'blog_rss_offline', '2B201/5', 403, 'blog_rss_offline_admin' );
|
||||
}
|
||||
|
||||
/* We have to use get() to ensure CDATA tags wrap the blog title properly */
|
||||
$title = $blog->member_id ? $blog->name : $member->language()->get( "blogs_blog_{$blog->id}" );
|
||||
|
||||
$document = \IPS\Xml\Rss::newDocument( $blog->url(), $title, $blog->description );
|
||||
$document = Rss::newDocument( $blog->url(), $title, $blog->description );
|
||||
|
||||
foreach ( \IPS\blog\Entry::getItemsWithPermission( array( array( 'entry_blog_id=?', $blog->id ), array( 'entry_status!=?', 'draft' ) ), 'entry_date DESC', 25, 'read', \IPS\Content\Hideable::FILTER_PUBLIC_ONLY, 0, $member, FALSE, FALSE, FALSE, FALSE, NULL, $blog ) as $entry )
|
||||
foreach (Entry::getItemsWithPermission( array( array( 'entry_blog_id=?', $blog->id ), array( 'entry_status!=?', 'draft' ) ), 'entry_date DESC', 25, 'read', Filter::FILTER_PUBLIC_ONLY, 0, $member, FALSE, FALSE, FALSE, FALSE, NULL, $blog ) as $entry )
|
||||
{
|
||||
/* @var Entry $entry */
|
||||
$content = $entry->content;
|
||||
\IPS\Output::i()->parseFileObjectUrls( $content );
|
||||
$document->addItem( $entry->name, $entry->url(), $content, \IPS\DateTime::ts( $entry->date ), $entry->id );
|
||||
Output::i()->parseFileObjectUrls( $content );
|
||||
|
||||
$document->addItem( $entry->name, $entry->url(), $entry->content, DateTime::ts( $entry->date ), $entry->id );
|
||||
}
|
||||
|
||||
/* @note application/rss+xml is not a registered IANA mime-type so we need to stick with text/xml for RSS */
|
||||
\IPS\Output::i()->sendOutput( $document->asXML(), 200, 'text/xml', array(), TRUE, parseFileObjects: FALSE );
|
||||
Output::i()->sendOutput( $document->asXML(), 200, 'text/xml', array(), TRUE, parseFileObjects: FALSE );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,10 +112,10 @@ class _Application extends \IPS\Application
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function installOther()
|
||||
public function installOther() : void
|
||||
{
|
||||
/* Allow non guests to create and comment on Blogs */
|
||||
foreach( \IPS\Member\Group::groups( TRUE, FALSE ) as $group )
|
||||
foreach( Group::groups( TRUE, FALSE ) as $group )
|
||||
{
|
||||
$group->g_blog_allowlocal = TRUE;
|
||||
$group->g_blog_allowcomment = TRUE;
|
||||
@@ -105,20 +123,20 @@ class _Application extends \IPS\Application
|
||||
}
|
||||
|
||||
/* Create new default category */
|
||||
$category = new \IPS\blog\Category;
|
||||
$category = new Category;
|
||||
$category->seo_name = 'general';
|
||||
$category->save();
|
||||
|
||||
\IPS\Lang::saveCustom( 'blog', "blog_category_{$category->id}", "General" );
|
||||
Lang::saveCustom( 'blog', "blog_category_{$category->id}", "General" );
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get Icon for tree
|
||||
*
|
||||
* @note Return the class for the icon (e.g. 'globe')
|
||||
* @return string|null
|
||||
* @return string
|
||||
*/
|
||||
protected function get__icon()
|
||||
protected function get__icon(): string
|
||||
{
|
||||
return 'file-text';
|
||||
}
|
||||
@@ -146,7 +164,7 @@ class _Application extends \IPS\Application
|
||||
* @endcode
|
||||
* @return array
|
||||
*/
|
||||
public function defaultFrontNavigation()
|
||||
public function defaultFrontNavigation(): array
|
||||
{
|
||||
return array(
|
||||
'rootTabs' => array(),
|
||||
@@ -164,7 +182,20 @@ class _Application extends \IPS\Application
|
||||
public function getWebhooks() : array
|
||||
{
|
||||
return array_merge( [
|
||||
'blogBlog_create' => \IPS\blog\Blog::class
|
||||
'blogBlog_create' => Blog::class
|
||||
], parent::getWebhooks());
|
||||
}
|
||||
|
||||
/**
|
||||
* Output CSS files
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function outputCss() : void
|
||||
{
|
||||
if ( Dispatcher::hasInstance() and Dispatcher::i()->controllerLocation === 'front' )
|
||||
{
|
||||
Output::i()->cssFiles = array_merge( Output::i()->cssFiles, Theme::i()->css( 'blog.css', 'blog', 'front' ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user