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

@@ -12,54 +12,61 @@
namespace IPS\blog\modules\front\blogs;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DateInterval;
use IPS\blog\Blog;
use IPS\blog\Blog\Table;
use IPS\blog\Category;
use IPS\blog\Entry;
use IPS\Content\Filter;
use IPS\DateTime;
use IPS\Db;
use IPS\Dispatcher\Controller;
use IPS\Http\Url;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Settings;
use IPS\Theme;
use OutOfRangeException;
use function count;
use function defined;
use function intval;
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;
}
/**
* browse
*/
class _browse extends \IPS\Dispatcher\Controller
class browse extends Controller
{
/**
* Manage
*
* @return void
*/
protected function manage()
protected function manage() : void
{
/* Category */
try
{
$category = \IPS\blog\Category::loadAndCheckPerms( \IPS\Request::i()->id );
$category = Category::loadAndCheckPerms( Request::i()->id );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
$category = NULL;
}
/* Featured stuff */
$featured = iterator_to_array( \IPS\blog\Entry::featured( 5, '_rand' ) );
$blogs = \IPS\blog\Blog::loadByOwner( \IPS\Member::loggedIn(), array( array( 'blog_disabled=?', 0 ) ) );
if ( ! \IPS\Settings::i()->blog_allow_grid )
{
$viewMode = 'list';
}
else
{
$viewMode = ( isset( \IPS\Request::i()->view ) ) ? \IPS\Request::i()->view : ( isset( \IPS\Request::i()->cookie['blog_view'] ) ? \IPS\Request::i()->cookie['blog_view'] : \IPS\Settings::i()->blog_view_mode );
}
if ( isset( \IPS\Request::i()->view ) )
{
\IPS\Session::i()->csrfCheck();
\IPS\Request::i()->setCookie( 'blog_view', \IPS\Request::i()->view, ( new \IPS\DateTime )->add( new \DateInterval( 'P1Y' ) ) );
$featured = iterator_to_array( Entry::featured( 5, '_rand' ) );
$blogs = Blog::loadByOwner( Member::loggedIn(), array( array( 'blog_disabled=?', 0 ) ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=blog', 'front', 'blogs' ) );
}
$viewMode = Member::loggedIn()->getLayoutValue( 'blog_view' );
/* Grid view */
if ( $viewMode == 'grid' )
@@ -67,9 +74,9 @@ class _browse extends \IPS\Dispatcher\Controller
$perpage = 23;
$page = 1;
if ( \IPS\Request::i()->page )
if ( Request::i()->page )
{
$page = \intval( \IPS\Request::i()->page );
$page = intval( Request::i()->page );
if ( !$page OR $page < 1 )
{
$page = 1;
@@ -80,7 +87,7 @@ class _browse extends \IPS\Dispatcher\Controller
$where = array();
$where[] = array( "blog_entries.entry_status!=?", 'draft' );
if ( !\IPS\Settings::i()->club_nodes_in_apps )
if ( !Settings::i()->club_nodes_in_apps )
{
$where[] = array( "blog_blogs.blog_club_id IS NULL" );
}
@@ -88,8 +95,8 @@ class _browse extends \IPS\Dispatcher\Controller
{
$where[] = array( 'blog_blogs.blog_category_id=?', $category->_id );
}
$count = \IPS\blog\Entry::getItemsWithPermission( $where, 'entry_date desc', NULL, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE, FALSE, FALSE, TRUE );
$entries = \IPS\blog\Entry::getItemsWithPermission( $where, 'entry_date desc', array( ( $perpage * ( $page - 1 ) ), $perpage ), 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE );
$count = Entry::getItemsWithPermission( $where, 'entry_date desc', NULL, 'read', Filter::FILTER_AUTOMATIC, 0, NULL, TRUE, FALSE, FALSE, TRUE );
$entries = Entry::getItemsWithPermission( $where, 'entry_date desc', array( ( $perpage * ( $page - 1 ) ), $perpage ), 'read', Filter::FILTER_AUTOMATIC, 0, NULL, TRUE );
/* Validate Pagination */
$totalPages = ceil( $count / $perpage );
@@ -102,67 +109,68 @@ class _browse extends \IPS\Dispatcher\Controller
}
}
$queryString = 'app=blog&module=blogs&controller=browse';
$queryString = 'app=blog&module=blogs&controller=browse';
if( $category )
{
$queryString .= '&id=' . $category->_id;
}
$paginationUrl = \IPS\Http\Url::internal( $queryString, 'front', ( $category ) ? 'blog_category' : 'blogs' );
$paginationUrl = Url::internal( $queryString, 'front', ( $category ) ? 'blog_category' : 'blogs' );
if( $redirect )
{
\IPS\Output::i()->redirect( $paginationUrl->setPage('page', 1 ), NULL, 303 );
Output::i()->redirect( $paginationUrl->setPage('page', 1 ), NULL, 303 );
}
$pagination = array(
'page' => $page,
'pages' => $totalPages,
'perpage' => $perpage,
'url' => $paginationUrl
);
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'grid.css', 'blog', 'front' ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->indexGrid( $entries, $featured, $blogs, $pagination, $viewMode, $category );
Output::i()->output = Theme::i()->getTemplate( 'browse' )->indexGrid( $entries, $featured, $blogs, $pagination, $viewMode, $category );
}
else
{
/* Blogs table */
$table = new \IPS\blog\Blog\Table( \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=browse', 'front', 'blogs' ) );
$table = new Table( Url::internal( 'app=blog&module=blogs&controller=browse', 'front', 'blogs' ) );
if( $category )
{
$table->where[] = array( 'blog_category_id=?', $category->_id );
}
$table->title = 'our_community_blogs';
$table->classes = array( 'cBlogList', 'ipsAreaBackground', 'ipsDataList_large' );
$table->classes = array( 'cBlogList', 'ipsBlogData' );
/* Filters */
$table->filters = array(
'my_blogs' => array( '(' . \IPS\Db::i()->findInSet( 'blog_groupblog_ids', \IPS\Member::loggedIn()->groups ) . ' OR ' . 'blog_member_id=? )', \IPS\Member::loggedIn()->member_id ),
'my_blogs' => array( '(' . Db::i()->findInSet( 'blog_groupblog_ids', Member::loggedIn()->groups ) . ' OR ' . 'blog_member_id=? )', Member::loggedIn()->member_id ),
'blogs_with_content' => array( 'blog_count_entries>0' )
);
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->index( $table, $featured, $blogs, $viewMode, $category );
Output::i()->output = Theme::i()->getTemplate( 'browse' )->index( $table, $featured, $blogs, $viewMode, $category );
}
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=blog', 'front', 'blogs' ), array(), 'loc_blog_viewing_index' );
Session::i()->setLocation( Url::internal( 'app=blog', 'front', 'blogs' ), array(), 'loc_blog_viewing_index' );
/* Display */
if( \count( \IPS\blog\Category::roots() ) > 1 )
if( count( Category::roots() ) > 1 )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'browse' )->categories( $category );
Output::i()->sidebar['contextual'] = Theme::i()->getTemplate( 'browse' )->categories( $category );
}
if( $category )
{
foreach( $category->parents() as $parent )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
}
\IPS\Output::i()->breadcrumb[] = array( $category->url(), $category->_title );
Output::i()->breadcrumb[] = array( $category->url(), $category->_title );
/* Set default search option */
\IPS\Output::i()->defaultSearchOption = array( 'blog_entry', 'blog_entry_pl' );
Output::i()->defaultSearchOption = array( 'blog_entry', 'blog_entry_pl' );
}
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_browse.js', 'blog', 'front' ) );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('blogs');
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_browse.js', 'blog', 'front' ) );
Output::i()->title = Member::loggedIn()->language()->addToStack('blogs');
}
}
@@ -12,23 +12,35 @@
namespace IPS\blog\modules\front\blogs;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\blog\Blog;
use IPS\Dispatcher\Controller;
use IPS\Helpers\Form;
use IPS\Http\Url;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Session;
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;
}
/**
* Create Blog
*/
class _create extends \IPS\Dispatcher\Controller
class create extends Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
parent::execute();
}
@@ -38,18 +50,18 @@ class _create extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
if ( !\IPS\blog\Blog::canCreate() )
if ( !Blog::canCreate() )
{
\IPS\Output::i()->error( 'no_module_permission', '2B227/1', 403, '' );
Output::i()->error( 'no_module_permission', '2B227/1', 403, '' );
}
$form = new \IPS\Helpers\Form( 'select_blog', 'continue' );
$form->class = 'ipsForm_vertical';
$form = new Form( 'select_blog', 'continue' );
$form->class = 'ipsForm--vertical ipsForm--create-blog';
$blog = new \IPS\blog\Blog;
$blog->member_id = \IPS\Member::loggedIn()->member_id;
$blog = new Blog;
$blog->member_id = Member::loggedIn()->member_id;
$blog->form( $form, TRUE );
if ( $values = $form->values() )
@@ -57,21 +69,21 @@ class _create extends \IPS\Dispatcher\Controller
$blog->saveForm( $blog->formatFormValues( $values ) );
/* Redirect */
\IPS\Output::i()->redirect( $blog->url() );
Output::i()->redirect( $blog->url() );
}
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=blog', 'front', 'blogs' ), array(), 'loc_blog_creating' );
Session::i()->setLocation( Url::internal( 'app=blog', 'front', 'blogs' ), array(), 'loc_blog_creating' );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_view.js', 'blog', 'front' ) );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('create_blog');
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_view.js', 'blog', 'front' ) );
Output::i()->title = Member::loggedIn()->language()->addToStack('create_blog');
if( \IPS\Request::i()->isAjax() )
if( Request::i()->isAjax() )
{
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
Output::i()->output = $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->createBlog( $form );
Output::i()->output = Theme::i()->getTemplate( 'submit' )->createBlog( $form );
}
}
}
+148 -109
View File
@@ -12,52 +12,93 @@
namespace IPS\blog\modules\front\blogs;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use DomainException;
use Exception;
use InvalidArgumentException;
use IPS\blog\Blog;
use IPS\blog\Entry as EntryClass;
use IPS\blog\Entry\Category;
use IPS\Content\Controller;
use IPS\Content\ReadMarkers;
use IPS\core\FrontNavigation;
use IPS\DateTime;
use IPS\Db;
use IPS\File;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Node;
use IPS\Helpers\Form\Radio;
use IPS\Helpers\Form\Select;
use IPS\Helpers\Form\Text;
use IPS\Helpers\Wizard;
use IPS\Http\Url;
use IPS\Http\Url\Friendly;
use IPS\IPS;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Settings;
use IPS\Theme;
use OutOfBoundsException;
use OutOfRangeException;
use RuntimeException;
use UnderflowException;
use function count;
use function defined;
use function get_class;
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;
}
/**
* View Blog Entry Controller
*/
class _entry extends \IPS\Content\Controller
class entry extends Controller
{
/**
* [Content\Controller] Class
*/
protected static $contentModel = 'IPS\blog\Entry';
protected static string $contentModel = 'IPS\blog\Entry';
/**
* Entry object
*/
protected ?EntryClass $entry = NULL;
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
try
{
$this->entry = \IPS\blog\Entry::load( \IPS\Request::i()->id );
$this->entry = EntryClass::load( Request::i()->id );
if ( !$this->entry->canView( \IPS\Member::loggedIn() ) )
if ( !$this->entry->canView( Member::loggedIn() ) )
{
\IPS\Output::i()->error( 'node_error', '2B202/1', 403, '' );
Output::i()->error( 'node_error', '2B202/1', 403, '' );
}
if( $this->entry->cover_photo )
{
\IPS\Output::i()->metaTags['og:image'] = \IPS\File::get( 'blog_Entries', $this->entry->cover_photo )->url;
Output::i()->metaTags['og:image'] = File::get( 'blog_Entries', $this->entry->cover_photo )->url;
}
elseif ( $this->entry->container()->cover_photo )
{
\IPS\Output::i()->metaTags['og:image'] = \IPS\File::get( 'blog_Blogs', $this->entry->container()->cover_photo )->url;
Output::i()->metaTags['og:image'] = File::get( 'blog_Blogs', $this->entry->container()->cover_photo )->url;
}
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
if ( !isset( \IPS\Request::i()->do ) or \IPS\Request::i()->do !== 'embed' )
if ( !isset( Request::i()->do ) or Request::i()->do !== 'embed' )
{
\IPS\Output::i()->error( 'node_error', '2B202/2', 404, '' );
Output::i()->error( 'node_error', '2B202/2', 404, '' );
}
}
@@ -67,9 +108,9 @@ class _entry extends \IPS\Content\Controller
/**
* Manage
*
* @return void
* @return mixed
*/
protected function manage()
protected function manage() : mixed
{
parent::manage();
@@ -81,7 +122,7 @@ class _entry extends \IPS\Content\Controller
/* Prev */
try
{
$previous = \IPS\Db::i()->select(
$previous = Db::i()->select(
'*',
'blog_entries',
array( 'entry_blog_id=? AND entry_date<? AND entry_status=? AND entry_is_future_entry=0 AND entry_hidden=?', $this->entry->blog_id, $this->entry->date, "published", 1 ),
@@ -89,14 +130,14 @@ class _entry extends \IPS\Content\Controller
,1
)->first();
$previous = \IPS\blog\Entry::constructFromData( $previous );
$previous = EntryClass::constructFromData( $previous );
}
catch ( \UnderflowException $e ) {}
catch ( UnderflowException ) {}
/* Next */
try
{
$next = \IPS\Db::i()->select(
$next = Db::i()->select(
'*',
'blog_entries',
array( 'entry_blog_id=? AND entry_date>? AND entry_status=? AND entry_is_future_entry=0 AND entry_hidden=?', $this->entry->blog_id, $this->entry->date, "published", 1 ),
@@ -104,49 +145,49 @@ class _entry extends \IPS\Content\Controller
,1
)->first();
$next = \IPS\blog\Entry::constructFromData( $next );
$next = EntryClass::constructFromData( $next );
}
catch ( \UnderflowException $e ) {}
catch ( UnderflowException ) {}
/* Online User Location */
if( !$this->entry->container()->social_group )
{
\IPS\Session::i()->setLocation( $this->entry->url(), $this->entry->onlineListPermissions(), 'loc_blog_viewing_entry', array( $this->entry->name => FALSE ) );
Session::i()->setLocation( $this->entry->url(), $this->entry->onlineListPermissions(), 'loc_blog_viewing_entry', array( $this->entry->name => FALSE ) );
}
/* Add JSON-ld output */
\IPS\Output::i()->jsonLd['blog'] = array(
'@context' => "http://schema.org",
Output::i()->jsonLd['blog'] = array(
'@context' => "https://schema.org",
'@type' => "Blog",
'url' => (string) $this->entry->container()->url(),
'name' => $this->entry->container()->_title,
'description' => \IPS\Member::loggedIn()->language()->addToStack( \IPS\blog\Blog::$titleLangPrefix . $this->entry->container()->_id . \IPS\blog\Blog::$descriptionLangSuffix, TRUE, array( 'striptags' => TRUE, 'escape' => TRUE ) ),
'description' => Member::loggedIn()->language()->addToStack( Blog::$titleLangPrefix . $this->entry->container()->_id . Blog::$descriptionLangSuffix, TRUE, array( 'striptags' => TRUE, 'escape' => TRUE ) ),
'commentCount' => $this->entry->container()->_comments,
'interactionStatistic' => array(
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ViewAction",
'interactionType' => "https://schema.org/ViewAction",
'userInteractionCount' => $this->entry->container()->num_views
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/FollowAction",
'userInteractionCount' => \IPS\blog\Entry::containerFollowerCount( $this->entry->container() )
'interactionType' => "https://schema.org/FollowAction",
'userInteractionCount' => EntryClass::containerFollowerCount( $this->entry->container() )
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/CommentAction",
'interactionType' => "https://schema.org/CommentAction",
'userInteractionCount' => $this->entry->container()->_comments
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/WriteAction",
'interactionType' => "https://schema.org/WriteAction",
'userInteractionCount' => $this->entry->container()->_items
)
),
'blogPost' => array(
'@context' => "http://schema.org",
'@context' => "https://schema.org",
'@type' => "BlogPosting",
'url' => (string) $this->entry->url(),
'mainEntityOfPage' => (string) $this->entry->url(),
@@ -154,37 +195,37 @@ class _entry extends \IPS\Content\Controller
'headline' => $this->entry->mapped('title'),
'articleBody' => $this->entry->truncated( TRUE, NULL ),
'commentCount' => $this->entry->mapped('num_comments'),
'dateCreated' => \IPS\DateTime::ts( $this->entry->date )->format( \IPS\DateTime::ISO8601 ),
'datePublished' => \IPS\DateTime::ts( $this->entry->publish_date )->format( \IPS\DateTime::ISO8601 ),
'dateCreated' => DateTime::ts( $this->entry->date )->format( DateTime::ATOM ),
'datePublished' => DateTime::ts( $this->entry->publish_date )->format( DateTime::ATOM ),
'author' => array(
'@type' => 'Person',
'name' => \IPS\Member::load( $this->entry->mapped('author') )->name,
'url' => (string) \IPS\Member::load( $this->entry->mapped('author') )->url(),
'image' => \IPS\Member::load( $this->entry->mapped('author') )->get_photo( TRUE, TRUE )
'name' => Member::load( $this->entry->mapped('author') )->name,
'url' => (string) Member::load( $this->entry->mapped('author') )->url(),
'image' => Member::load( $this->entry->mapped('author') )->get_photo( TRUE, TRUE )
),
'publisher' => array(
'@id' => \IPS\Settings::i()->base_url . '#organization',
'@id' => Settings::i()->base_url . '#organization',
'member' => array(
'@type' => 'Person',
'name' => \IPS\Member::load( $this->entry->mapped('author') )->name,
'url' => (string) \IPS\Member::load( $this->entry->mapped('author') )->url(),
'image' => \IPS\Member::load( $this->entry->mapped('author') )->get_photo( TRUE, TRUE )
'name' => Member::load( $this->entry->mapped('author') )->name,
'url' => (string) Member::load( $this->entry->mapped('author') )->url(),
'image' => Member::load( $this->entry->mapped('author') )->get_photo( TRUE, TRUE )
)
),
'interactionStatistic' => array(
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ViewAction",
'interactionType' => "https://schema.org/ViewAction",
'userInteractionCount' => $this->entry->views
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/FollowAction",
'userInteractionCount' => \IPS\blog\Entry::containerFollowerCount( $this->entry->container() )
'interactionType' => "https://schema.org/FollowAction",
'userInteractionCount' => EntryClass::containerFollowerCount( $this->entry->container() )
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/CommentAction",
'interactionType' => "https://schema.org/CommentAction",
'userInteractionCount' => $this->entry->mapped('num_comments')
)
)
@@ -193,32 +234,32 @@ class _entry extends \IPS\Content\Controller
if( $this->entry->container()->coverPhoto()->file )
{
\IPS\Output::i()->jsonLd['blog']['image'] = (string) $this->entry->container()->coverPhoto()->file->url;
Output::i()->jsonLd['blog']['image'] = (string) $this->entry->container()->coverPhoto()->file->url;
}
if( $this->entry->container()->member_id )
{
\IPS\Output::i()->jsonLd['blog']['author'] = array(
Output::i()->jsonLd['blog']['author'] = array(
'@type' => 'Person',
'name' => \IPS\Member::load( $this->entry->container()->member_id )->name,
'url' => (string) \IPS\Member::load( $this->entry->container()->member_id )->url(),
'image' => \IPS\Member::load( $this->entry->container()->member_id )->get_photo( TRUE, TRUE )
'name' => Member::load( $this->entry->container()->member_id )->name,
'url' => (string) Member::load( $this->entry->container()->member_id )->url(),
'image' => Member::load( $this->entry->container()->member_id )->get_photo( TRUE, TRUE )
);
}
if( $this->entry->edit_time )
{
\IPS\Output::i()->jsonLd['blog']['blogPost']['dateModified'] = \IPS\DateTime::ts( $this->entry->edit_time )->format( \IPS\DateTime::ISO8601 );
Output::i()->jsonLd['blog']['blogPost']['dateModified'] = DateTime::ts( $this->entry->edit_time )->format( DateTime::ATOM );
}
else
{
\IPS\Output::i()->jsonLd['blog']['blogPost']['dateModified'] = \IPS\DateTime::ts( $this->entry->publish_date ?: $this->entry->date )->format( \IPS\DateTime::ISO8601 );
Output::i()->jsonLd['blog']['blogPost']['dateModified'] = DateTime::ts( $this->entry->publish_date ?: $this->entry->date )->format( DateTime::ATOM );
}
$file = NULL;
if( $this->entry->image )
{
$file = \IPS\File::get( 'blog_Blogs', $this->entry->image );
$file = File::get( 'blog_Blogs', $this->entry->image );
}
elseif( $this->entry->coverPhoto()->file )
{
@@ -235,39 +276,36 @@ class _entry extends \IPS\Content\Controller
{
$dimensions = $file->getImageDimensions();
\IPS\Output::i()->jsonLd['blog']['blogPost']['image'] = array(
Output::i()->jsonLd['blog']['blogPost']['image'] = array(
'@type' => 'ImageObject',
'url' => (string) $file->url,
'width' => $dimensions[0],
'height' => $dimensions[1]
);
}
/* File does not exist */
catch( \RuntimeException $e ) {}
/* Image is invalid */
catch( \InvalidArgumentException $e ){}
catch( \DomainException $e ) {}
/* File does not exist or image is invalid */
catch( RuntimeException | InvalidArgumentException | DomainException ){}
}
/* Display */
if( \IPS\Settings::i()->blog_enable_sidebar and $this->entry->container()->sidebar )
if( Settings::i()->blog_enable_sidebar and $this->entry->container()->sidebar )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate('view')->blogSidebar( $this->entry->container()->sidebar );
Output::i()->sidebar['contextual'] = Theme::i()->getTemplate('view')->blogSidebar( $this->entry->container()->sidebar );
}
/* Breadcrumb */
\IPS\Output::i()->breadcrumb = array();
Output::i()->breadcrumb = array();
if ( $club = $this->entry->container()->club() )
{
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
\IPS\Output::i()->breadcrumb = array();
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
FrontNavigation::$clubTabActive = TRUE;
Output::i()->breadcrumb = array();
Output::i()->breadcrumb[] = array( Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), Member::loggedIn()->language()->addToStack('module__core_clubs') );
Output::i()->breadcrumb[] = array( $club->url(), $club->name );
}
else
{
\IPS\Output::i()->breadcrumb['module'] = array( \IPS\Http\Url::internal( 'app=blog', 'front', 'blogs' ), \IPS\Member::loggedIn()->language()->addToStack( '__app_blog' ) );
Output::i()->breadcrumb['module'] = array( Url::internal( 'app=blog', 'front', 'blogs' ), Member::loggedIn()->language()->addToStack( '__app_blog' ) );
}
@@ -275,30 +313,31 @@ class _entry extends \IPS\Content\Controller
{
foreach( $this->entry->container()->category()->parents() as $parent )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
}
\IPS\Output::i()->breadcrumb[] = array( $this->entry->container()->category()->url(), $this->entry->container()->category()->_title );
Output::i()->breadcrumb[] = array( $this->entry->container()->category()->url(), $this->entry->container()->category()->_title );
}
catch ( \OutOfRangeException $e ) {}
catch ( OutOfRangeException ) {}
/* Set default search option */
\IPS\Output::i()->defaultSearchOption = array( 'blog_entry', 'blog_entry_pl' );
Output::i()->defaultSearchOption = array( 'blog_entry', 'blog_entry_pl' );
\IPS\Output::i()->breadcrumb[] = array( $this->entry->container()->url(), $this->entry->container()->_title );
\IPS\Output::i()->breadcrumb[] = array( NULL, $this->entry->name );
Output::i()->breadcrumb[] = array( $this->entry->container()->url(), $this->entry->container()->_title );
Output::i()->breadcrumb[] = array( NULL, $this->entry->name );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->entry( $this->entry, $previous, $next );
Output::i()->output = Theme::i()->getTemplate( 'view' )->entry( $this->entry, $previous, $next );
return null;
}
/**
* Return the form for editing. Abstracted so controllers can define a custom template if desired.
*
* @param \IPS\Helpers\Form $form The form
* @param Form $form The form
* @return string
*/
protected function getEditForm( $form )
protected function getEditForm( Form $form ): string
{
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'submit', 'blog' ), 'submitFormTemplate' ) );
return $form->customTemplate( array( Theme::i()->getTemplate( 'submit', 'blog' ), 'submitFormTemplate' ) );
}
/**
@@ -306,34 +345,34 @@ class _entry extends \IPS\Content\Controller
*
* @return void
*/
protected function move()
protected function move(): void
{
try
{
$item = \IPS\blog\Entry::loadAndCheckPerms( \IPS\Request::i()->id );
$item = EntryClass::loadAndCheckPerms( Request::i()->id );
if ( !$item->canMove() )
{
throw new \DomainException;
throw new DomainException;
}
$container = $item->container();
$wizard = new \IPS\Helpers\Wizard( array(
$wizard = new Wizard( array(
'blog' => function( $data ) use ( $container ) {
$data['item'] = \IPS\Request::i()->id;
$item = \IPS\blog\Entry::loadAndCheckPerms( $data['item'] );
$form = new \IPS\Helpers\Form;
$form->class = 'ipsForm_vertical';
$form->add( new \IPS\Helpers\Form\Node( 'move_to', NULL, TRUE, array(
'class' => \get_class( $item->container() ),
$data['item'] = Request::i()->id;
$item = EntryClass::loadAndCheckPerms( $data['item'] );
$form = new Form;
$form->class = 'ipsForm--vertical ipsForm--move-blog';
$form->add( new Node( 'move_to', NULL, TRUE, array(
'class' => get_class( $item->container() ),
'permissionCheck' => function( $node ) use ( $item )
{
try
{
/* If the item is in a club, only allow moving to other clubs that you moderate */
if ( \IPS\IPS::classUsesTrait( $item->container(), 'IPS\Content\ClubContainer' ) and $item->container()->club() )
if ( IPS::classUsesTrait( $item->container(), 'IPS\Content\ClubContainer' ) and $item->container()->club() )
{
return $item::modPermission( 'move', \IPS\Member::loggedIn(), $node ) and $node->can( 'add' ) ;
return $item::modPermission( 'move', Member::loggedIn(), $node ) and $node->can( 'add' ) ;
}
if ( $node->can( 'add' ) )
@@ -341,7 +380,7 @@ class _entry extends \IPS\Content\Controller
return true;
}
}
catch( \OutOfBoundsException $e ) { }
catch( OutOfBoundsException ) { }
return false;
},
@@ -357,27 +396,27 @@ class _entry extends \IPS\Content\Controller
return $form;
},
'category' => function( $data ) {
$item = \IPS\blog\Entry::loadAndCheckPerms( $data['item'] );
$item = EntryClass::loadAndCheckPerms( $data['item'] );
$newBlog = $data['blog'];
$form = new \IPS\Helpers\Form;
$form = new Form;
$categories = \IPS\blog\Entry\Category::roots( NULL, NULL, array( 'entry_category_blog_id=?', $newBlog->id ) );
$categories = Category::roots( NULL, NULL, array( 'entry_category_blog_id=?', $newBlog->id ) );
$choiceOptions = array( 0 => 'entry_category_choice_new' );
$choiceToggles = array( 0 => array( 'blog_entry_new_category' ) );
if( \count( $categories ) )
if( count( $categories ) )
{
$choiceOptions[1] = 'entry_category_choice_existing';
$choiceToggles[1] = array( 'entry_category_id' );
}
$form->add( new \IPS\Helpers\Form\Radio( 'entry_category_choice', 0, FALSE, array(
$form->add( new Radio( 'entry_category_choice', 0, FALSE, array(
'options' => $choiceOptions,
'toggles' => $choiceToggles
) ) );
if( \count( $categories ) )
if( count( $categories ) )
{
$options = array();
foreach ( $categories as $category )
@@ -385,20 +424,20 @@ class _entry extends \IPS\Content\Controller
$options[ $category->id ] = $category->name;
}
$form->add( new \IPS\Helpers\Form\Select( 'entry_category_id', NULL, FALSE, array( 'options' => $options, 'parse' => 'normal' ), NULL, NULL, NULL, "entry_category_id" ) );
$form->add( new Select( 'entry_category_id', NULL, FALSE, array( 'options' => $options, 'parse' => 'normal' ), NULL, NULL, NULL, "entry_category_id" ) );
}
$form->add( new \IPS\Helpers\Form\Text( 'blog_entry_new_category', NULL, TRUE, array(), NULL, NULL, NULL, "blog_entry_new_category" ) );
$form->add( new Text( 'blog_entry_new_category', NULL, TRUE, array(), NULL, NULL, NULL, "blog_entry_new_category" ) );
$this->moderationAlertField( $form, $item );
if ( $values = $form->values() )
{
if ( $data['blog'] === NULL OR !$data['blog']->can( 'add' ) )
{
\IPS\Output::i()->error( 'node_move_invalid', '1S136/L', 403, '' );
Output::i()->error( 'node_move_invalid', '1S136/L', 403, '' );
}
/* If this item is read, we need to re-mark it as such after moving */
if( $item instanceof \IPS\Content\ReadMarkers )
if( IPS::classUsesTrait( $item, ReadMarkers::class ) )
{
$unread = $item->unread();
}
@@ -412,9 +451,9 @@ class _entry extends \IPS\Content\Controller
}
else
{
$newCategory = new \IPS\blog\Entry\Category;
$newCategory = new Category;
$newCategory->name = $values['blog_entry_new_category'];
$newCategory->seo_name = \IPS\Http\Url\Friendly::seoTitle( $values['blog_entry_new_category'] );
$newCategory->seo_name = Friendly::seoTitle( $values['blog_entry_new_category'] );
$newCategory->blog_id = $item->blog_id;
$newCategory->save();
@@ -425,7 +464,7 @@ class _entry extends \IPS\Content\Controller
$item->save();
/* Mark it as read */
if( $item instanceof \IPS\Content\ReadMarkers and $unread == 0 )
if( IPS::classUsesTrait( $item, ReadMarkers::class ) and $unread == 0 )
{
$item->markRead( NULL, NULL, NULL, TRUE );
}
@@ -435,9 +474,9 @@ class _entry extends \IPS\Content\Controller
$this->sendModerationAlert($values, $item);
}
\IPS\Session::i()->modLog( 'modlog__action_move', array( $item::$title => TRUE, $item->url()->__toString() => FALSE, $item->mapped( 'title' ) ?: ( method_exists( $item, 'item' ) ? $item->item()->mapped( 'title' ) : NULL ) => FALSE ), $item );
Session::i()->modLog( 'modlog__action_move', array( $item::$title => TRUE, $item->url()->__toString() => FALSE, $item->mapped( 'title' ) ?: ( method_exists( $item, 'item' ) ? $item->item()->mapped( 'title' ) : NULL ) => FALSE ), $item );
\IPS\Output::i()->redirect( $item->url() );
Output::i()->redirect( $item->url() );
}
return $form;
@@ -445,12 +484,12 @@ class _entry extends \IPS\Content\Controller
), $item->url()->setQueryString( array( 'do' => 'move' ) ) );
$this->_setBreadcrumbAndTitle( $item );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'move_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( \IPS\blog\Entry::$title ) ) ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->box( $wizard, array( 'ipsPad' ) );
Output::i()->title = Member::loggedIn()->language()->addToStack( 'move_item', FALSE, array( 'sprintf' => array( Member::loggedIn()->language()->addToStack( EntryClass::$title ) ) ) );
Output::i()->output = Theme::i()->getTemplate( 'global', 'core' )->box( $wizard, array( 'i-padding_2' ) );
}
catch ( \Exception $e )
catch ( Exception )
{
\IPS\Output::i()->error( 'node_error', '2S136/D', 403, '' );
Output::i()->error( 'node_error', '2S136/D', 403, '' );
}
}
}
@@ -12,36 +12,53 @@
namespace IPS\blog\modules\front\blogs;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\blog\Blog;
use IPS\blog\Entry;
use IPS\core\FrontNavigation;
use IPS\Dispatcher\Controller;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Node;
use IPS\Http\Url;
use IPS\Member;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Settings;
use IPS\Theme;
use OutOfRangeException;
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;
}
/**
* Submit
*/
class _submit extends \IPS\Dispatcher\Controller
class submit extends Controller
{
/**
* @brief This blog
*/
protected $blog = NULL;
protected ?Blog $blog = NULL;
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
if ( isset( \IPS\Request::i()->id ) )
if ( isset( Request::i()->id ) )
{
try
{
$this->blog = \IPS\blog\Blog::load( \IPS\Request::i()->id );
$this->blog = Blog::load( Request::i()->id );
}
catch( \OutOfRangeException $e ) {}
\IPS\blog\Entry::canCreate( \IPS\Member::loggedIn(), $this->blog, TRUE );
catch( OutOfRangeException ) {}
Entry::canCreate( Member::loggedIn(), $this->blog, TRUE );
}
parent::execute();
@@ -52,9 +69,9 @@ class _submit extends \IPS\Dispatcher\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'submit_entry' );
Output::i()->title = Member::loggedIn()->language()->addToStack( 'submit_entry' );
/* Load Blog */
try
@@ -62,54 +79,54 @@ class _submit extends \IPS\Dispatcher\Controller
/* Can we add to this Blog? We load the blog in execute, so emulate an OutOfRangeException here if we don't actually have one. */
if ( $this->blog === NULL )
{
throw new \OutOfRangeException;
throw new OutOfRangeException;
}
\IPS\blog\Entry::canCreate( \IPS\Member::loggedIn(), $this->blog, TRUE );
Entry::canCreate( Member::loggedIn(), $this->blog, TRUE );
$form = \IPS\blog\Entry::create( $this->blog );
$formTemplate = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'submit', 'blog' ), 'submitFormTemplate' ) );
$form = Entry::create( $this->blog );
$formTemplate = $form->customTemplate( array( Theme::i()->getTemplate( 'submit', 'blog' ), 'submitFormTemplate' ) );
if ( $club = $this->blog->club() )
{
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
\IPS\Output::i()->breadcrumb = array();
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
FrontNavigation::$clubTabActive = TRUE;
Output::i()->breadcrumb = array();
Output::i()->breadcrumb[] = array( Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), Member::loggedIn()->language()->addToStack('module__core_clubs') );
Output::i()->breadcrumb[] = array( $club->url(), $club->name );
if ( \IPS\Settings::i()->clubs_header == 'sidebar' )
if ( Settings::i()->clubs_header == 'sidebar' )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $this->blog, 'sidebar' );
Output::i()->sidebar['contextual'] = Theme::i()->getTemplate( 'clubs', 'core' )->header( $club, $this->blog, 'sidebar' );
}
}
\IPS\Output::i()->breadcrumb[] = array( $this->blog->url(), $this->blog->_title );
Output::i()->breadcrumb[] = array( $this->blog->url(), $this->blog->_title );
if( !$this->blog->social_group )
{
\IPS\Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_adding_entry', array( $this->blog->_title => FALSE ) );
Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_adding_entry', array( $this->blog->_title => FALSE ) );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->submit( $formTemplate, $this->blog );
Output::i()->output = Theme::i()->getTemplate( 'submit' )->submit( $formTemplate, $this->blog );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
$form = new \IPS\Helpers\Form( 'select_blog', 'continue' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Node( 'blog_select', NULL, TRUE, array(
'url' => \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=submit', 'front', 'blog_submit' ),
$form = new Form( 'select_blog', 'continue' );
$form->class = 'ipsForm--vertical ipsForm--manage-blog ipsForm--noLabels';
$form->add( new Node( 'blog_select', NULL, TRUE, array(
'url' => Url::internal( 'app=blog&module=blogs&controller=submit', 'front', 'blog_submit' ),
'class' => 'IPS\blog\Blog',
'permissionCheck' => 'add',
'forceOwner' => \IPS\Member::loggedIn(),
'clubs' => \IPS\Settings::i()->club_nodes_in_apps
'forceOwner' => Member::loggedIn(),
'clubs' => Settings::i()->club_nodes_in_apps
) ) );
if ( $values = $form->values() )
{
$url = \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=submit', 'front', 'blog_submit' )->setQueryString( 'id', $values['blog_select']->_id );
\IPS\Output::i()->redirect( $url );
$url = Url::internal( 'app=blog&module=blogs&controller=submit', 'front', 'blog_submit' )->setQueryString( 'id', $values['blog_select']->_id );
Output::i()->redirect( $url );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'submit' )->blogSelector( $form );
Output::i()->output = Theme::i()->getTemplate( 'submit' )->blogSelector( $form );
}
}
}
+231 -233
View File
@@ -12,43 +12,80 @@
namespace IPS\blog\modules\front\blogs;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use Exception;
use IPS\blog\Blog;
use IPS\blog\Entry;
use IPS\blog\Entry\Category;
use IPS\core\FrontNavigation;
use IPS\core\Rss\Import;
use IPS\Db;
use IPS\File;
use IPS\Helpers\CoverPhoto;
use IPS\Helpers\CoverPhoto\Controller;
use IPS\Helpers\Form;
use IPS\Helpers\Form\Text;
use IPS\Helpers\Form\Url;
use IPS\Helpers\Form\YesNo;
use IPS\Helpers\Table\Content;
use IPS\Http\Url\Friendly;
use IPS\Member;
use IPS\Member\Club;
use IPS\Output;
use IPS\Request;
use IPS\Session;
use IPS\Settings;
use IPS\Task;
use IPS\Theme;
use IPS\Xml\Atom;
use IPS\Xml\Rss;
use OutOfRangeException;
use UnderflowException;
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;
}
/**
* View Blog Controller
*/
class _view extends \IPS\Helpers\CoverPhoto\Controller
class view extends Controller
{
/**
* [Content\Controller] Class
*/
protected static $contentModel = 'IPS\blog\Blog';
protected static string $contentModel = 'IPS\blog\Blog';
/**
* Blog object
*/
protected ?Blog $blog = NULL;
/**
* Execute
*
* @return void
*/
public function execute()
public function execute() : void
{
/* Load blog and check permissions */
try
{
$this->blog = \IPS\blog\Blog::loadAndCheckPerms( \IPS\Request::i()->id, 'read' );
$this->blog = Blog::loadAndCheckPerms( Request::i()->id, 'read' );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
\IPS\Output::i()->error( 'node_error', '2B201/1', 404, '' );
Output::i()->error( 'node_error', '2B201/1', 404, '' );
}
if ( $this->blog->cover_photo )
{
\IPS\Output::i()->metaTags['og:image'] = \IPS\File::get( $this->_coverPhotoStorageExtension(), $this->blog->cover_photo )->url;
Output::i()->metaTags['og:image'] = File::get( $this->_coverPhotoStorageExtension(), $this->blog->cover_photo )->url;
}
parent::execute();
@@ -59,16 +96,16 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
*
* @return void
*/
protected function manage()
protected function manage() : void
{
$this->blog->clubCheckRules();
/* Build table */
$tableUrl = $this->blog->url();
$where = array();
if ( !\in_array( $this->blog->id, array_keys( \IPS\blog\Blog::loadByOwner( \IPS\Member::loggedIn() ) ) ) AND !\IPS\blog\Entry::canViewHiddenItems( \IPS\Member::loggedIn(), $this->blog ) )
if ( !in_array( $this->blog->id, array_keys( Blog::loadByOwner( Member::loggedIn() ) ) ) AND !Entry::canViewHiddenItems( Member::loggedIn(), $this->blog ) )
{
if ( !( $club = $this->blog->club() AND \in_array( $club->memberStatus( \IPS\Member::loggedIn() ), array( \IPS\Member\Club::STATUS_LEADER, \IPS\Member\Club::STATUS_MODERATOR ) ) ) )
if ( !( $club = $this->blog->club() AND in_array( $club->memberStatus( Member::loggedIn() ), array( Club::STATUS_LEADER, Club::STATUS_MODERATOR ) ) ) )
{
$where[] = array( "entry_status!='draft'" );
}
@@ -77,10 +114,10 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
/* Are we limiting by category? */
try
{
$category = \IPS\blog\Entry\Category::load( \IPS\Request::i()->cat );
$category = Category::load( (int) Request::i()->cat );
$tableUrl = $tableUrl->setQueryString( [ 'cat' => $category->id ] );
}
catch( \OutOfRangeException $e )
catch( OutOfRangeException )
{
$category = NULL;
}
@@ -90,24 +127,27 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
$where[] = array( "entry_category_id=?", $category->id );
}
$table = new \IPS\Helpers\Table\Content( 'IPS\blog\Entry', $tableUrl, $where, $this->blog );
$table = new Content( 'IPS\blog\Entry', $tableUrl, $where, $this->blog );
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'view' ), 'blogTable' );
if ( \IPS\Settings::i()->blog_allow_grid )
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'grid.css', 'blog', 'front' ) );
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'view' ), 'rowsGrid' );
}
else
{
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'view' ), 'rows' );
}
$table->title = \IPS\Member::loggedIn()->language()->addToStack('entries_in_this_blog');
$table->sortBy = \IPS\Request::i()->sortby ?: 'date';
$table->tableTemplate = array( Theme::i()->getTemplate( 'view' ), 'blogTable' );
$viewMode = Member::loggedIn()->getLayoutValue( 'blog_view' );
$template = ( $viewMode == 'grid' ) ? 'rowsGrid' : 'rows';
$table->rowsTemplate = array( Theme::i()->getTemplate( 'view' ), $template );
$table->title = Member::loggedIn()->language()->addToStack('entries_in_this_blog');
$table->sortBy = Request::i()->sortby ?: 'date';
/* Update views */
if ( !\IPS\Request::i()->isAjax() )
Db::i()->update(
'blog_blogs',
"`blog_num_views`=`blog_num_views`+1",
array( "blog_id=?", $this->blog->id ),
array(),
NULL,
Db::LOW_PRIORITY
);
if ( ! Request::i()->isAjax() )
{
$this->blog->updateViews();
}
@@ -115,48 +155,48 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
/* Online User Location */
if( !$this->blog->social_group )
{
\IPS\Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_viewing_blog', array( "blogs_blog_{$this->blog->id}" => TRUE ) );
Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_viewing_blog', array( "blogs_blog_{$this->blog->id}" => TRUE ) );
}
if( \IPS\Settings::i()->blog_allow_rss and $this->blog->settings['allowrss'] )
if( Settings::i()->blog_allow_rss and $this->blog->settings['allowrss'] )
{
\IPS\Output::i()->rssFeeds['blog_rss_title'] = \IPS\Http\Url::internal( "app=blog&module=blogs&controller=view&id={$this->blog->_id}", 'front', 'blogs_rss', array( $this->blog->seo_name ) );
Output::i()->rssFeeds['blog_rss_title'] = \IPS\Http\Url::internal( "app=blog&module=blogs&controller=view&id={$this->blog->_id}", 'front', 'blogs_rss', array( $this->blog->seo_name ) );
if ( \IPS\Member::loggedIn()->member_id )
if ( Member::loggedIn()->member_id )
{
$key = \IPS\Member::loggedIn()->getUniqueMemberHash();
$key = Member::loggedIn()->getUniqueMemberHash();
\IPS\Output::i()->rssFeeds['blog_rss_title'] = \IPS\Output::i()->rssFeeds['blog_rss_title']->setQueryString( array( 'member' => \IPS\Member::loggedIn()->member_id , 'key' => $key ) );
Output::i()->rssFeeds['blog_rss_title'] = Output::i()->rssFeeds['blog_rss_title']->setQueryString( array( 'member' => Member::loggedIn()->member_id , 'key' => $key ) );
}
}
/* Add JSON-ld */
\IPS\Output::i()->jsonLd['blog'] = array(
'@context' => "http://schema.org",
Output::i()->jsonLd['blog'] = array(
'@context' => "https://schema.org",
'@type' => "Blog",
'url' => (string) $this->blog->url(),
'name' => $this->blog->_title,
'description' => $this->blog->member_id ? $this->blog->desc : \IPS\Member::loggedIn()->language()->addToStack( \IPS\blog\Blog::$titleLangPrefix . $this->blog->_id . \IPS\blog\Blog::$descriptionLangSuffix, TRUE, array( 'striptags' => TRUE, 'escape' => TRUE ) ),
'description' => $this->blog->member_id ? $this->blog->desc : Member::loggedIn()->language()->addToStack( Blog::$titleLangPrefix . $this->blog->_id . Blog::$descriptionLangSuffix, TRUE, array( 'striptags' => TRUE, 'escape' => TRUE ) ),
'commentCount' => $this->blog->_comments,
'interactionStatistic' => array(
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ViewAction",
'interactionType' => "https://schema.org/ViewAction",
'userInteractionCount' => $this->blog->num_views
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/FollowAction",
'userInteractionCount' => \IPS\blog\Entry::containerFollowerCount( $this->blog )
'interactionType' => "https://schema.org/FollowAction",
'userInteractionCount' => Entry::containerFollowerCount( $this->blog )
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/CommentAction",
'interactionType' => "https://schema.org/CommentAction",
'userInteractionCount' => $this->blog->_comments
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/WriteAction",
'interactionType' => "https://schema.org/WriteAction",
'userInteractionCount' => $this->blog->_items
)
)
@@ -164,36 +204,36 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
if( $this->blog->coverPhoto()->file )
{
\IPS\Output::i()->jsonLd['blog']['image'] = (string) $this->blog->coverPhoto()->file->url;
Output::i()->jsonLd['blog']['image'] = (string) $this->blog->coverPhoto()->file->url;
}
if( $this->blog->member_id )
{
\IPS\Output::i()->jsonLd['blog']['author'] = array(
Output::i()->jsonLd['blog']['author'] = array(
'@type' => 'Person',
'name' => \IPS\Member::load( $this->blog->member_id )->name,
'url' => (string) \IPS\Member::load( $this->blog->member_id )->url(),
'image' => \IPS\Member::load( $this->blog->member_id )->get_photo( TRUE, TRUE )
'name' => Member::load( $this->blog->member_id )->name,
'url' => (string) Member::load( $this->blog->member_id )->url(),
'image' => Member::load( $this->blog->member_id )->get_photo( TRUE, TRUE )
);
}
if( \IPS\Settings::i()->blog_enable_sidebar and $this->blog->sidebar )
if( Settings::i()->blog_enable_sidebar and $this->blog->sidebar )
{
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate('view')->blogSidebar( $this->blog->sidebar );
Output::i()->sidebar['contextual'] = Theme::i()->getTemplate('view')->blogSidebar( $this->blog->sidebar );
}
\IPS\Output::i()->breadcrumb = array();
Output::i()->breadcrumb = array();
if ( $club = $this->blog->club() )
{
\IPS\core\FrontNavigation::$clubTabActive = TRUE;
\IPS\Output::i()->breadcrumb = array();
\IPS\Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), \IPS\Member::loggedIn()->language()->addToStack('module__core_clubs') );
\IPS\Output::i()->breadcrumb[] = array( $club->url(), $club->name );
FrontNavigation::$clubTabActive = TRUE;
Output::i()->breadcrumb = array();
Output::i()->breadcrumb[] = array( \IPS\Http\Url::internal( 'app=core&module=clubs&controller=directory', 'front', 'clubs_list' ), Member::loggedIn()->language()->addToStack('module__core_clubs') );
Output::i()->breadcrumb[] = array( $club->url(), $club->name );
}
else
{
\IPS\Output::i()->breadcrumb['module'] = array( \IPS\Http\Url::internal( 'app=blog', 'front', 'blogs' ), \IPS\Member::loggedIn()->language()->addToStack( '__app_blog' ) );
Output::i()->breadcrumb['module'] = array( \IPS\Http\Url::internal( 'app=blog', 'front', 'blogs' ), Member::loggedIn()->language()->addToStack( '__app_blog' ) );
}
@@ -201,23 +241,23 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
{
foreach( $this->blog->category()->parents() as $parent )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
}
\IPS\Output::i()->breadcrumb[] = array( $this->blog->category()->url(), $this->blog->category()->_title );
Output::i()->breadcrumb[] = array( $this->blog->category()->url(), $this->blog->category()->_title );
}
catch (\OutOfRangeException $e) {}
catch (OutOfRangeException ) {}
\IPS\Output::i()->breadcrumb[] = array( $this->blog->url(), $this->blog->_title );
Output::i()->breadcrumb[] = array( $this->blog->url(), $this->blog->_title );
/* Categories */
$categories = \IPS\blog\Entry\Category::roots( NULL, NULL, array( 'entry_category_blog_id=?', $this->blog->id ) );
$categories = Category::roots( NULL, NULL, array( 'entry_category_blog_id=?', $this->blog->id ) );
/* Set default search option */
\IPS\Output::i()->defaultSearchOption = array( 'blog_entry', 'blog_entry_pl' );
Output::i()->defaultSearchOption = array( 'blog_entry', 'blog_entry_pl' );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_browse.js', 'blog', 'front' ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'view' )->view( $this->blog, (string) $table, $category );
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item_blogs' ) ] = array( 'type' => 'blog_entry', 'nodes' => $this->blog->_id );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_browse.js', 'blog', 'front' ) );
Output::i()->output = Theme::i()->getTemplate( 'view' )->view( $this->blog, (string) $table, $category );
Output::i()->contextualSearchOptions[ Member::loggedIn()->language()->addToStack( 'search_contextual_item_blogs' ) ] = array( 'type' => 'blog_entry', 'nodes' => $this->blog->_id );
}
/**
@@ -225,18 +265,18 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
*
* @return void
*/
protected function editBlog()
protected function editBlog() : void
{
if( !$this->blog->canEdit() OR $this->blog->groupblog_ids or $this->blog->club_id )
{
\IPS\Output::i()->error( 'no_module_permission', '2B201/2', 403, '' );
Output::i()->error( 'no_module_permission', '2B201/2', 403, '' );
}
\IPS\Session::i()->csrfCheck();
Session::i()->csrfCheck();
/* Build form */
$form = new \IPS\Helpers\Form( 'form', 'save', $this->blog->url()->setQueryString( array( 'do' => 'editBlog' ) )->csrf() );
$form->class .= 'ipsForm_vertical';
$form = new Form( 'form', 'save', $this->blog->url()->setQueryString( array( 'do' => 'editBlog' ) )->csrf() );
$form->class .= 'ipsForm--vertical ipsForm--edit-blog';
$this->blog->form( $form, TRUE );
@@ -245,22 +285,22 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
{
if( !$values['blog_name'] )
{
$form->elements['']['blog_name']->error = \IPS\Member::loggedIn()->language()->addToStack('form_required');
$form->elements['']['blog_name']->error = Member::loggedIn()->language()->addToStack('form_required');
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
Output::i()->output = $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
return;
}
$this->blog->saveForm( $this->blog->formatFormValues( $values ) );
\IPS\Output::i()->redirect( $this->blog->url() );
Output::i()->redirect( $this->blog->url() );
}
/* Display form */
\IPS\Output::i()->title = $this->blog->_title;
\IPS\Output::i()->breadcrumb[] = array( $this->blog->url(), $this->blog->_title );
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_view.js', 'blog', 'front' ) );
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
Output::i()->title = $this->blog->_title;
Output::i()->breadcrumb[] = array( $this->blog->url(), $this->blog->_title );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_view.js', 'blog', 'front' ) );
Output::i()->output = $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
}
/**
@@ -268,26 +308,26 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
*
* @return void
*/
protected function deleteBlog()
protected function deleteBlog() : void
{
\IPS\Session::i()->csrfCheck();
Session::i()->csrfCheck();
if( !$this->blog->canDelete() or $this->blog->club_id )
{
\IPS\Output::i()->error( 'no_module_permission', '2B201/3', 403, '' );
Output::i()->error( 'no_module_permission', '2B201/3', 403, '' );
}
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
Request::i()->confirmedDelete();
$this->blog->disabled = TRUE;
$this->blog->save();
/* Log */
\IPS\Session::i()->modLog( 'modlog__action_delete_blog', array( $this->blog->name => FALSE ) );
Session::i()->modLog( 'modlog__action_delete_blog', array( $this->blog->name => FALSE ) );
\IPS\Task::queue( 'core', 'DeleteOrMoveContent', array( 'class' => 'IPS\blog\Blog', 'id' => $this->blog->id, 'deleteWhenDone' => TRUE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=browse', 'front', 'blogs' ) );
Task::queue( 'core', 'DeleteOrMoveContent', array( 'class' => 'IPS\blog\Blog', 'id' => $this->blog->id, 'deleteWhenDone' => TRUE ) );
Output::i()->redirect( \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=browse', 'front', 'blogs' ) );
}
/**
@@ -295,27 +335,27 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
*
* @return void
*/
protected function changePin()
protected function changePin() : void
{
\IPS\Session::i()->csrfCheck();
Session::i()->csrfCheck();
/* Do we have permission */
if ( ( $this->blog->pinned and !\IPS\Member::loggedIn()->modPermission('can_unpin_content') ) or ( !$this->blog->pinned and !\IPS\Member::loggedIn()->modPermission('can_pin_content') ) or $this->blog->club_id )
if ( ( $this->blog->pinned and !Member::loggedIn()->modPermission('can_unpin_content') ) or ( !$this->blog->pinned and !Member::loggedIn()->modPermission('can_pin_content') ) or $this->blog->club_id )
{
\IPS\Output::i()->error( 'no_module_permission', '2B201/4', 403, '' );
Output::i()->error( 'no_module_permission', '2B201/4', 403, '' );
}
$this->blog->pinned = $this->blog->pinned ? FALSE : TRUE;
$this->blog->pinned = !$this->blog->pinned;
$this->blog->save();
/* Respond or redirect */
if ( \IPS\Request::i()->isAjax() )
if ( Request::i()->isAjax() )
{
\IPS\Output::i()->json( 'OK' );
Output::i()->json( 'OK' );
}
else
{
\IPS\Output::i()->redirect( $this->blog->url() );
Output::i()->redirect( $this->blog->url() );
}
}
@@ -324,107 +364,65 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
*
* @return void
*/
protected function rssImport()
protected function rssImport() : void
{
if( !\IPS\Settings::i()->blog_allow_rssimport )
if( !Settings::i()->blog_allow_rssimport )
{
\IPS\Output::i()->error( 'rss_import_disabled', '2B201/7', 403, '' );
Output::i()->error( 'rss_import_disabled', '2B201/7', 403, '' );
}
if( !$this->blog->canEdit() )
{
\IPS\Output::i()->error( 'no_module_permission', '2B201/6', 403, '' );
Output::i()->error( 'no_module_permission', '2B201/6', 403, '' );
}
/* Check for existing feed */
try
{
$existing = \IPS\Db::i()->select( '*', 'core_rss_import', array( 'rss_import_class=? AND rss_import_node_id=?', 'IPS\\blog\\Entry', $this->blog->id ) )->first();
$feed = \IPS\core\Rss\Import::constructFromData( $existing );
$existing = Db::i()->select( '*', 'core_rss_import', array( 'rss_import_class=? AND rss_import_node_id=?', 'IPS\\blog\\Entry', $this->blog->id ) )->first();
$feed = Import::constructFromData( $existing );
}
catch ( \UnderflowException $e )
catch ( UnderflowException )
{
$feed = new \IPS\core\Rss\Import;
$feed = new Import;
$feed->class = 'IPS\\blog\\Entry';
}
$form = new \IPS\Helpers\Form;
$form = new Form;
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_enable_rss_import', $feed->url ? TRUE : FALSE, FALSE, array( 'togglesOn' => array( 'blog_rss_import_url', 'blog_rss_import_auth_user', 'blog_rss_import_auth_pass', 'blog_rss_import_show_link', 'blog_rss_import_tags' ) ) ) );
$form->add( new YesNo( 'blog_enable_rss_import', (bool)$feed->url, FALSE, array( 'togglesOn' => array( 'blog_rss_import_url', 'blog_rss_import_auth_user', 'blog_rss_import_auth_pass', 'blog_rss_import_show_link', 'blog_rss_import_tags' ) ) ) );
$form->add( new \IPS\Helpers\Form\Url( 'blog_rss_import_url', $feed ? $feed->url : NULL, TRUE, array(), NULL, NULL, NULL, 'blog_rss_import_url' ) );
$form->add( new \IPS\Helpers\Form\Text( 'blog_rss_import_auth_user', $feed ? $feed->auth_user : NULL, FALSE, array(), NULL, NULL, NULL, 'blog_rss_import_auth_user' ) );
$form->add( new \IPS\Helpers\Form\Text( 'blog_rss_import_auth_pass', $feed ? $feed->auth_pass : NULL, FALSE, array(), NULL, NULL, NULL, 'blog_rss_import_auth_pass' ) );
$form->add( new \IPS\Helpers\Form\Text( 'blog_rss_import_show_link', $feed->showlink ?: \IPS\Member::loggedIn()->language()->addToStack('blog_rss_import_show_link_default' ), FALSE, array(), NULL, NULL, NULL, 'blog_rss_import_show_link' ) );
$form->add( new Url( 'blog_rss_import_url', $feed->url, TRUE, array(), NULL, NULL, NULL, 'blog_rss_import_url' ) );
$form->add( new Text( 'blog_rss_import_auth_user', $feed->auth_user ?: null, FALSE, array(), NULL, NULL, NULL, 'blog_rss_import_auth_user' ) );
$form->add( new Text( 'blog_rss_import_auth_pass', $feed->auth_pass ?: null, FALSE, array(), NULL, NULL, NULL, 'blog_rss_import_auth_pass' ) );
$form->add( new Text( 'blog_rss_import_show_link', $feed->showlink ?: Member::loggedIn()->language()->addToStack('blog_rss_import_show_link_default' ), FALSE, array(), NULL, NULL, NULL, 'blog_rss_import_show_link' ) );
$options = array( 'autocomplete' => array( 'unique' => TRUE, 'minimized' => FALSE, 'source' => \IPS\Content\Item::definedTags( $this->blog ), 'freeChoice' => ( \IPS\Settings::i()->tags_open_system ? TRUE : FALSE ) ) );
if ( \IPS\Settings::i()->tags_force_lower )
$options = array(
'autocomplete' => array(
'unique' => TRUE,
'minimized' => FALSE,
'source' => Entry::definedTags(),
'freeChoice' => false
)
);
if ( Settings::i()->tags_force_lower )
{
$options['autocomplete']['forceLower'] = TRUE;
}
if ( \IPS\Settings::i()->tags_min )
if ( Settings::i()->tags_min )
{
$options['autocomplete']['minItems'] = \IPS\Settings::i()->tags_min;
$options['autocomplete']['minItems'] = Settings::i()->tags_min;
}
if ( \IPS\Settings::i()->tags_max )
if ( Settings::i()->tags_max )
{
$options['autocomplete']['maxItems'] = \IPS\Settings::i()->tags_max;
$options['autocomplete']['maxItems'] = Settings::i()->tags_max;
}
if ( \IPS\Settings::i()->tags_len_min )
{
$options['autocomplete']['minLength'] = \IPS\Settings::i()->tags_len_min;
}
if ( \IPS\Settings::i()->tags_len_max )
{
$options['autocomplete']['maxLength'] = \IPS\Settings::i()->tags_len_max;
}
if ( \IPS\Settings::i()->tags_clean )
{
$options['autocomplete']['filterProfanity'] = TRUE;
}
if ( \IPS\Settings::i()->tags_alphabetical )
{
$options['autocomplete']['alphabetical'] = TRUE;
}
$options['autocomplete']['prefix'] = \IPS\Content\Item::canPrefix( NULL, $this->blog );
$options['autocomplete']['prefix'] = Entry::canPrefix( NULL, $this->blog );
$options['autocomplete']['disallowedCharacters'] = array( '#' ); // @todo Pending \IPS\Http\Url rework, hashes cannot be used in URLs
/* Language strings for tags description */
if ( \IPS\Settings::i()->tags_open_system )
{
$extralang = array();
if ( \IPS\Settings::i()->tags_min && \IPS\Settings::i()->tags_max )
{
$extralang[] = \IPS\Member::loggedIn()->language()->addToStack( 'tags_desc_min_max', FALSE, array( 'sprintf' => array( \IPS\Settings::i()->tags_max ), 'pluralize' => array( \IPS\Settings::i()->tags_min ) ) );
}
else if( \IPS\Settings::i()->tags_min )
{
$extralang[] = \IPS\Member::loggedIn()->language()->addToStack( 'tags_desc_min', FALSE, array( 'pluralize' => array( \IPS\Settings::i()->tags_min ) ) );
}
else if( \IPS\Settings::i()->tags_min )
{
$extralang[] = \IPS\Member::loggedIn()->language()->addToStack( 'tags_desc_max', FALSE, array( 'pluralize' => array( \IPS\Settings::i()->tags_max ) ) );
}
if( \IPS\Settings::i()->tags_len_min && \IPS\Settings::i()->tags_len_max )
{
$extralang[] = \IPS\Member::loggedIn()->language()->addToStack( 'tags_desc_len_min_max', FALSE, array( 'sprintf' => array( \IPS\Settings::i()->tags_len_min, \IPS\Settings::i()->tags_len_max ) ) );
}
else if( \IPS\Settings::i()->tags_len_min )
{
$extralang[] = \IPS\Member::loggedIn()->language()->addToStack( 'tags_desc_len_min', FALSE, array( 'pluralize' => array( \IPS\Settings::i()->tags_len_min ) ) );
}
else if( \IPS\Settings::i()->tags_len_max )
{
$extralang[] = \IPS\Member::loggedIn()->language()->addToStack( 'tags_desc_len_max', FALSE, array( 'sprintf' => array( \IPS\Settings::i()->tags_len_max ) ) );
}
$options['autocomplete']['desc'] = \IPS\Member::loggedIn()->language()->addToStack('tags_desc') . ( ( \count( $extralang ) ) ? '<br>' . implode( ' ', $extralang ) : '' );
}
$form->add( new \IPS\Helpers\Form\Text( 'blog_rss_import_tags', $feed ? json_decode( $feed->tags, TRUE ) : array(), \IPS\Settings::i()->tags_min and \IPS\Settings::i()->tags_min_req, $options, NULL, NULL, NULL, 'blog_rss_import_tags' ) );
$form->add( new Text( 'blog_rss_import_tags', $feed->tags ? json_decode( $feed->tags, TRUE ) : array(), Settings::i()->tags_min and Settings::i()->tags_min_req, $options, NULL, NULL, NULL, 'blog_rss_import_tags' ) );
if ( $values = $form->values() )
{
@@ -443,14 +441,14 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
if ( $response->httpResponseCode == 401 )
{
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'rss_import_auth' );
$form->error = Member::loggedIn()->language()->addToStack( 'rss_import_auth' );
}
$response = $response->decodeXml();
if ( !( $response instanceof \IPS\Xml\Rss ) and !( $response instanceof \IPS\Xml\Atom ) )
if ( !( $response instanceof Rss ) and !( $response instanceof Atom ) )
{
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'rss_import_invalid' );
$form->error = Member::loggedIn()->language()->addToStack( 'rss_import_invalid' );
}
if( !$form->error )
@@ -460,7 +458,7 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
$feed->showlink = $values['blog_rss_import_show_link'];
$feed->auth_user = $values['blog_rss_import_auth_user'];
$feed->auth_pass = $values['blog_rss_import_auth_pass'];
$feed->member = $this->blog->owner() ? $this->blog->owner()->member_id : \IPS\Member::loggedIn()->member_id;
$feed->member = $this->blog->owner() ? $this->blog->owner()->member_id : Member::loggedIn()->member_id;
$feed->settings = json_encode( array( 'tags' => $values['blog_rss_import_tags'] ) );
$feed->save();
@@ -468,33 +466,33 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
{
$feed->run();
}
catch ( \Exception $e ) { }
catch ( Exception ) { }
/* Redirect */
\IPS\Output::i()->redirect( $this->blog->url() );
Output::i()->redirect( $this->blog->url() );
}
}
catch ( \IPS\Http\Request\Exception $e )
catch ( \IPS\Http\Request\Exception )
{
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'form_url_bad' );
$form->error = Member::loggedIn()->language()->addToStack( 'form_url_bad' );
}
catch ( \Exception $e )
catch ( Exception )
{
$form->error = \IPS\Member::loggedIn()->language()->addToStack( 'rss_import_invalid' );
$form->error = Member::loggedIn()->language()->addToStack( 'rss_import_invalid' );
}
}
else
{
\IPS\Db::i()->delete( 'core_rss_import', array( 'rss_import_class=? AND rss_import_node_id=?', 'IPS\\blog\\Entry', $this->blog->id ) );
Db::i()->delete( 'core_rss_import', array( 'rss_import_class=? AND rss_import_node_id=?', 'IPS\\blog\\Entry', $this->blog->id ) );
/* Redirect */
\IPS\Output::i()->redirect( $this->blog->url() );
Output::i()->redirect( $this->blog->url() );
}
}
/* Display */
\IPS\Output::i()->output = $form->error ? $form : \IPS\Theme::i()->getTemplate( 'view', 'blog', 'front' )->rssImport( $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) ) );
Output::i()->output = $form->error ? $form : Theme::i()->getTemplate( 'view', 'blog', 'front' )->rssImport( $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) ) );
}
/**
@@ -502,7 +500,7 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
*
* @return string
*/
protected function _coverPhotoStorageExtension()
protected function _coverPhotoStorageExtension(): string
{
return 'blog_Blogs';
}
@@ -510,22 +508,22 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
/**
* Set Cover Photo
*
* @param \IPS\Helpers\CoverPhoto $photo New Photo
* @param CoverPhoto $photo New Photo
* @return void
*/
protected function _coverPhotoSet( \IPS\Helpers\CoverPhoto $photo )
protected function _coverPhotoSet( CoverPhoto $photo ) : void
{
$this->blog->cover_photo = (string) $photo->file;
$this->blog->cover_photo_offset = (int) $photo->offset;
$this->blog->cover_photo_offset = $photo->offset;
$this->blog->save();
}
/**
* Get Cover Photo
*
* @return \IPS\Helpers\CoverPhoto
* @return CoverPhoto
*/
protected function _coverPhotoGet()
protected function _coverPhotoGet(): CoverPhoto
{
return $this->blog->coverPhoto();
}
@@ -535,10 +533,10 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
*
* @return void
*/
protected function categoriesJson()
protected function categoriesJson() : void
{
$cats = array();
foreach( \IPS\blog\Entry\Category::roots( NULL, NULL, array( 'entry_category_blog_id=?', $this->blog->id ) ) as $meow )
foreach( Category::roots( NULL, NULL, array( 'entry_category_blog_id=?', $this->blog->id ) ) as $meow )
{
$cats[] = array(
'id' => $meow->id,
@@ -546,7 +544,7 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
);
}
\IPS\Output::i()->json( array( 'categories' => $cats ) );
Output::i()->json( array( 'categories' => $cats ) );
}
/**
@@ -554,54 +552,54 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
*
* @return void
*/
protected function manageCategories()
protected function manageCategories() : void
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'front_view.js', 'blog', 'front' ) );
Output::i()->jsFiles = array_merge( Output::i()->jsFiles, Output::i()->js( 'front_view.js', 'blog', 'front' ) );
if( !$this->blog->canEdit() )
{
\IPS\Output::i()->error( 'no_module_permission', '2B201/A', 403, '' );
Output::i()->error( 'no_module_permission', '2B201/A', 403, '' );
}
$form = new \IPS\Helpers\Form;
$form->addHtml( \IPS\Theme::i()->getTemplate( 'view', 'blog', 'front' )->manageCategories( $this->blog ) );
$form = new Form;
$form->addHtml( Theme::i()->getTemplate( 'view', 'blog', 'front' )->manageCategories( $this->blog ) );
$form->hiddenValues['submitted'] = 1;
if( $values = $form->values() )
{
\IPS\Output::i()->redirect( $this->blog->url() );
Output::i()->redirect( $this->blog->url() );
}
/* Display */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('blog_manage_entry_categories');
\IPS\Output::i()->output = $form->error ? $form : \IPS\Theme::i()->getTemplate( 'view', 'blog', 'front' )->rssImport( $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) ) );
Output::i()->title = Member::loggedIn()->language()->addToStack('blog_manage_entry_categories');
Output::i()->output = $form->error ? $form : Theme::i()->getTemplate( 'view', 'blog', 'front' )->rssImport( $form->customTemplate( array( Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) ) );
}
/**
* Edit a category name
*
* @return string
* @return void
*/
protected function editCategoryName()
protected function editCategoryName(): void
{
\IPS\Session::i()->csrfCheck();
Session::i()->csrfCheck();
if( !$this->blog->canEdit() )
{
\IPS\Output::i()->error( 'no_module_permission', '2B201/C', 403, '' );
Output::i()->error( 'no_module_permission', '2B201/C', 403, '' );
}
if( ! \IPS\Request::i()->name )
if( ! Request::i()->name )
{
\IPS\Output::i()->error( 'blog_error_missing_name', '1B201/B', 403, '' );
Output::i()->error( 'blog_error_missing_name', '1B201/B', 403, '' );
}
/* New category? */
if ( \IPS\Request::i()->cat === 'new' )
if ( Request::i()->cat === 'new' )
{
$newCategory = new \IPS\blog\Entry\Category;
$newCategory->name = \IPS\Request::i()->name;
$newCategory->seo_name = \IPS\Http\Url\Friendly::seoTitle( \IPS\Request::i()->name );
$newCategory = new Category;
$newCategory->name = Request::i()->name;
$newCategory->seo_name = Friendly::seoTitle( Request::i()->name );
$newCategory->blog_id = $this->blog->id;
$newCategory->save();
@@ -610,23 +608,23 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
{
try
{
$category = \IPS\blog\Entry\Category::load( \IPS\Request::i()->cat );
$category = Category::load( Request::i()->cat );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
\IPS\Output::i()->error( 'blog_error_not_find_category', '2B201/D', 403, '' );
Output::i()->error( 'blog_error_not_find_category', '2B201/D', 403, '' );
}
if( $category->blog_id !== $this->blog->id )
{
\IPS\Output::i()->error( 'blog_error_not_find_category', '2B201/E', 403, '' );
Output::i()->error( 'blog_error_not_find_category', '2B201/E', 403, '' );
}
$category->name = \IPS\Request::i()->name;
$category->name = Request::i()->name;
$category->save();
}
\IPS\Output::i()->json( 'OK' );
Output::i()->json( 'OK' );
}
/**
@@ -634,42 +632,42 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
*
* @return void
*/
protected function deleteCategory()
protected function deleteCategory() : void
{
\IPS\Session::i()->csrfCheck();
Session::i()->csrfCheck();
if( !$this->blog->canEdit() )
{
\IPS\Output::i()->error( 'no_module_permission', '2B201/8', 403, '' );
Output::i()->error( 'no_module_permission', '2B201/8', 403, '' );
}
try
{
$category = \IPS\blog\Entry\Category::load( \IPS\Request::i()->cat );
$category = Category::load( Request::i()->cat );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
\IPS\Output::i()->redirect( $this->blog->url() );
Output::i()->redirect( $this->blog->url() );
}
if( $category->blog_id !== $this->blog->id )
{
\IPS\Output::i()->error( 'no_module_permission', '2B201/9', 403, '' );
Output::i()->error( 'no_module_permission', '2B201/9', 403, '' );
}
/* Update Entries */
\IPS\Db::i()->update( 'blog_entries', array( 'entry_category_id' => NULL ), array( 'entry_category_id=?', $category->id ) );
Db::i()->update( 'blog_entries', array( 'entry_category_id' => NULL ), array( 'entry_category_id=?', $category->id ) );
$category->delete();
/* Redirect */
if ( \IPS\Request::i()->isAjax() )
if ( Request::i()->isAjax() )
{
\IPS\Output::i()->json( 'OK' );
Output::i()->json( 'OK' );
}
else
{
\IPS\Output::i()->redirect( $this->blog->url(), 'deleted' );
Output::i()->redirect( $this->blog->url(), 'deleted' );
}
}
@@ -678,26 +676,26 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
*
* @return void
*/
public function categoriesReorder()
public function categoriesReorder() : void
{
\IPS\Session::i()->csrfCheck();
Session::i()->csrfCheck();
if( !$this->blog->canEdit() )
{
\IPS\Output::i()->error( 'no_module_permission', '2B201/F', 403, '' );
Output::i()->error( 'no_module_permission', '2B201/F', 403, '' );
}
/* Set order */
$position = 1;
if( !\IPS\Request::i()->isAjax() )
if( !Request::i()->isAjax() )
{
\IPS\Request::i()->ajax_order = explode( ',', \IPS\Request::i()->ajax_order );
Request::i()->ajax_order = explode( ',', Request::i()->ajax_order );
}
foreach( \IPS\Request::i()->ajax_order as $category )
foreach( Request::i()->ajax_order as $category )
{
$node = \IPS\blog\Entry\Category::load( $category );
$node = Category::load( $category );
/* No funny business trying to reorder another blog's categories */
if( $node->blog_id !== $this->blog->id )
@@ -711,13 +709,13 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
$position++;
}
if( \IPS\Request::i()->isAjax() )
if( Request::i()->isAjax() )
{
\IPS\Output::i()->json( 'ok' );
Output::i()->json( 'ok' );
}
else
{
\IPS\Output::i()->redirect( $this->blog->url(), 'saved' );
Output::i()->redirect( $this->blog->url(), 'saved' );
}
}
}