Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -12,7 +12,7 @@
|
||||
namespace IPS\blog\modules\front\blogs;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
|
||||
exit;
|
||||
@@ -30,6 +30,16 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function manage()
|
||||
{
|
||||
/* Category */
|
||||
try
|
||||
{
|
||||
$category = \IPS\blog\Category::loadAndCheckPerms( \IPS\Request::i()->id );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
$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 ) ) );
|
||||
@@ -45,6 +55,7 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
|
||||
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' ) ) );
|
||||
}
|
||||
|
||||
@@ -56,7 +67,7 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( \IPS\Request::i()->page )
|
||||
{
|
||||
$page = intval( \IPS\Request::i()->page );
|
||||
$page = \intval( \IPS\Request::i()->page );
|
||||
if ( !$page OR $page < 1 )
|
||||
{
|
||||
$page = 1;
|
||||
@@ -64,8 +75,20 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
|
||||
/* @note We cannot check individual member permissions here, so entries in draft status are excluded. */
|
||||
$count = \IPS\blog\Entry::getItemsWithPermission( array( array( "entry_status!=?", 'draft' ) ), 'entry_date desc', NULL, 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, FALSE, FALSE, FALSE, TRUE );
|
||||
$entries = \IPS\blog\Entry::getItemsWithPermission( array( array( "entry_status!=?", 'draft' ) ), 'entry_date desc', array( ( $perpage * ( $page - 1 ) ), $perpage ) );
|
||||
|
||||
$where = array();
|
||||
$where[] = array( "blog_entries.entry_status!=?", 'draft' );
|
||||
if ( !\IPS\Settings::i()->club_nodes_in_apps )
|
||||
{
|
||||
$where[] = array( "blog_blogs.blog_club_id IS NULL" );
|
||||
}
|
||||
if( $category )
|
||||
{
|
||||
$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 );
|
||||
|
||||
$pagination = array(
|
||||
'page' => $page,
|
||||
'pages' => ceil( $count / $perpage ),
|
||||
@@ -74,12 +97,16 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
);
|
||||
|
||||
\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 );
|
||||
\IPS\Output::i()->output = \IPS\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' ) );
|
||||
if( $category )
|
||||
{
|
||||
$table->where[] = array( 'blog_category_id=?', $category->_id );
|
||||
}
|
||||
$table->title = 'our_community_blogs';
|
||||
$table->classes = array( 'cBlogList', 'ipsAreaBackground', 'ipsDataList_large' );
|
||||
|
||||
@@ -89,12 +116,25 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
'blogs_with_content' => array( 'blog_count_entries>0' )
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->index( $table, $featured, $blogs, $viewMode );
|
||||
\IPS\Output::i()->output = \IPS\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' );
|
||||
|
||||
/* Display */
|
||||
if( \count( \IPS\blog\Category::roots() ) > 1 )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['contextual'] = \IPS\Theme::i()->getTemplate( 'browse' )->categories( $category );
|
||||
}
|
||||
|
||||
if( $category )
|
||||
{
|
||||
foreach( $category->parents() as $parent )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
|
||||
}
|
||||
\IPS\Output::i()->breadcrumb[] = array( $category->url(), $category->_title );
|
||||
}
|
||||
\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');
|
||||
|
||||
|
||||
Reference in new issue
Block a user