Version 4.3.0
This commit is contained in:
1 parent
96997ddd8e
commit
fe1acf984a
1349 files changed
+116159
-67711
No files matched your search
@@ -47,7 +47,7 @@ class _blogs extends \IPS\Node\Controller
|
||||
protected function manage()
|
||||
{
|
||||
/* Create the table */
|
||||
$table = new \IPS\Helpers\Table\Db( 'blog_blogs', \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=blogs' ) );
|
||||
$table = new \IPS\Helpers\Table\Db( 'blog_blogs', \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=blogs' ), array( array( 'blog_club_id IS NULL' ) ) );
|
||||
$table->langPrefix = 'blog_';
|
||||
|
||||
/* Column stuff */
|
||||
@@ -55,7 +55,7 @@ class _blogs extends \IPS\Node\Controller
|
||||
$table->mainColumn = 'word_custom';
|
||||
|
||||
$table->joins = array(
|
||||
array( 'select' => 'CASE WHEN blog_blogs.blog_member_id THEN blog_blogs.blog_name ELSE w.word_custom END as word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'blogs_blog_', blog_blogs.blog_id ) AND w.lang_id=" . \IPS\Member::loggedIn()->language()->id )
|
||||
array( 'select' => 'w.word_custom', 'from' => array( 'core_sys_lang_words', 'w' ), 'where' => "w.word_key=CONCAT( 'blogs_blog_', blog_blogs.blog_id ) AND w.lang_id=" . \IPS\Member::loggedIn()->language()->id )
|
||||
);
|
||||
|
||||
/* Sort stuff */
|
||||
@@ -72,11 +72,13 @@ class _blogs extends \IPS\Node\Controller
|
||||
$table->parsers = array(
|
||||
'blog_member_id' => function( $val, $row )
|
||||
{
|
||||
try
|
||||
$member = \IPS\Member::load( $val );
|
||||
|
||||
if( $member->member_id )
|
||||
{
|
||||
return \IPS\Member::load( $val )->link();
|
||||
return $member->link();
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
@@ -88,12 +90,7 @@ class _blogs extends \IPS\Node\Controller
|
||||
return \IPS\Member::loggedIn()->language()->addToStack('blog_member_deleted');
|
||||
}
|
||||
|
||||
if( $row['blog_member_id'] )
|
||||
{
|
||||
$val = htmlspecialchars( $val, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE );
|
||||
}
|
||||
|
||||
return $val;
|
||||
return htmlspecialchars( $val, ENT_QUOTES | ENT_DISALLOWED, 'UTF-8', FALSE );
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
@@ -45,6 +45,11 @@ class _settings extends \IPS\Dispatcher\Controller
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_enable_rating', \IPS\Settings::i()->blog_enable_rating ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_enable_sidebar', \IPS\Settings::i()->blog_enable_sidebar ) );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_allow_grid', \IPS\Settings::i()->blog_allow_grid, FALSE, array( 'togglesOn' => array( 'blog_view_mode' ) ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'blog_view_mode', \IPS\Settings::i()->blog_view_mode, FALSE, array( 'options' => array(
|
||||
'grid' => 'blog_view_mode_grid',
|
||||
'list' => 'blog_view_mode_list'
|
||||
) ), NULL, NULL, NULL, 'blog_view_mode' ) );
|
||||
|
||||
$form->addHeader('blog_settings_rss');
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'blog_allow_rssimport', \IPS\Settings::i()->blog_allow_rssimport ) );
|
||||
|
||||
@@ -31,26 +31,72 @@ class _browse extends \IPS\Dispatcher\Controller
|
||||
protected function manage()
|
||||
{
|
||||
/* Featured stuff */
|
||||
$featured = iterator_to_array( \IPS\blog\Entry::featured( 5, '_rand' ) );
|
||||
|
||||
/* Blogs table */
|
||||
$table = new \IPS\blog\Blog\Table( \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=browse', 'front', 'blogs' ) );
|
||||
$table->title = 'our_community_blogs';
|
||||
$table->classes = array( 'cBlogList', 'ipsAreaBackground', 'ipsDataList_large' );
|
||||
|
||||
/* 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 ),
|
||||
'blogs_with_content' => array( 'blog_count_entries>0' )
|
||||
);
|
||||
|
||||
$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\Request::i()->setCookie( 'blog_view', \IPS\Request::i()->view, ( new \IPS\DateTime )->add( new \DateInterval( 'P1Y' ) ) );
|
||||
}
|
||||
|
||||
/* Grid view */
|
||||
if ( $viewMode == 'grid' )
|
||||
{
|
||||
$perpage = 23;
|
||||
$page = 1;
|
||||
|
||||
if ( \IPS\Request::i()->page )
|
||||
{
|
||||
$page = intval( \IPS\Request::i()->page );
|
||||
if ( !$page OR $page < 1 )
|
||||
{
|
||||
$page = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* @note We cannot check individual member permissions here, so entries in draft status are excluded. */
|
||||
$count = \IPS\blog\Entry::getItemsWithPermission( 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( "entry_status!=?", 'draft' ), 'entry_date desc', array( ( $perpage * ( $page - 1 ) ), $perpage ) );
|
||||
$pagination = array(
|
||||
'page' => $page,
|
||||
'pages' => ceil( $count / $perpage ),
|
||||
'perpage' => $perpage,
|
||||
'url' => \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=browse', 'front', 'blogs' )
|
||||
);
|
||||
|
||||
\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 );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Blogs table */
|
||||
$table = new \IPS\blog\Blog\Table( \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=browse', 'front', 'blogs' ) );
|
||||
$table->title = 'our_community_blogs';
|
||||
$table->classes = array( 'cBlogList', 'ipsAreaBackground', 'ipsDataList_large' );
|
||||
|
||||
/* 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 ),
|
||||
'blogs_with_content' => array( 'blog_count_entries>0' )
|
||||
);
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->index( $table, $featured, $blogs, $viewMode );
|
||||
}
|
||||
|
||||
\IPS\Session::i()->setLocation( \IPS\Http\Url::internal( 'app=blog', 'front', 'blogs' ), array(), 'loc_blog_viewing_index' );
|
||||
|
||||
/* Display */
|
||||
\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');
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'browse' )->index( $table, $featured, $blogs );
|
||||
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ class _entry extends \IPS\Content\Controller
|
||||
'@context' => "http://schema.org",
|
||||
'@type' => "Blog",
|
||||
'url' => (string) $this->entry->container()->url(),
|
||||
'name' => htmlspecialchars( $this->entry->container()->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'name' => $this->entry->container()->_title,
|
||||
'description' => strip_tags( $this->entry->container()->description ),
|
||||
'commentCount' => $this->entry->container()->_comments,
|
||||
'interactionStatistic' => array(
|
||||
@@ -140,21 +140,21 @@ class _entry extends \IPS\Content\Controller
|
||||
'@type' => "BlogPosting",
|
||||
'url' => (string) $this->entry->url(),
|
||||
'mainEntityOfPage' => (string) $this->entry->url(),
|
||||
'name' => htmlspecialchars( $this->entry->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'headline' => htmlspecialchars( $this->entry->mapped('title'), ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'name' => $this->entry->mapped('title'),
|
||||
'headline' => $this->entry->mapped('title'),
|
||||
'articleBody' => strip_tags( $this->entry->truncated() ),
|
||||
'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 ),
|
||||
'author' => array(
|
||||
'@type' => 'Person',
|
||||
'name' => htmlspecialchars( \IPS\Member::load( $this->entry->mapped('author') )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'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()
|
||||
),
|
||||
'publisher' => array(
|
||||
'@type' => 'Organization',
|
||||
'name' => htmlspecialchars( \IPS\Member::load( $this->entry->mapped('author') )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'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(),
|
||||
'logo' => array(
|
||||
@@ -182,6 +182,15 @@ class _entry extends \IPS\Content\Controller
|
||||
)
|
||||
);
|
||||
|
||||
if( $this->entry->averageRating() )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['blog']['blogPost']['aggregateRating'] = array(
|
||||
'@type' => 'AggregateRating',
|
||||
'ratingValue' => $this->entry->averageRating(),
|
||||
'ratingCount' => $this->entry->numberOfRatings(),
|
||||
);
|
||||
}
|
||||
|
||||
if( $this->entry->container()->coverPhoto()->file )
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['blog']['image'] = (string) $this->entry->container()->coverPhoto()->file->url;
|
||||
@@ -191,7 +200,7 @@ class _entry extends \IPS\Content\Controller
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['blog']['author'] = array(
|
||||
'@type' => 'Person',
|
||||
'name' => htmlspecialchars( \IPS\Member::load( $this->entry->container()->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'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()
|
||||
);
|
||||
@@ -235,6 +244,8 @@ class _entry extends \IPS\Content\Controller
|
||||
}
|
||||
/* File does not exist */
|
||||
catch( \RuntimeException $e ) {}
|
||||
/* Image is invalid */
|
||||
catch( \InvalidArgumentException $e ){}
|
||||
}
|
||||
|
||||
/* Display */
|
||||
|
||||
@@ -41,8 +41,8 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
$this->blog = \IPS\blog\Blog::load( \IPS\Request::i()->id );
|
||||
}
|
||||
catch( \OutOfRangeException $e ) {}
|
||||
\IPS\blog\Entry::canCreate( \IPS\Member::loggedIn(), $this->blog, TRUE );
|
||||
}
|
||||
\IPS\blog\Entry::canCreate( \IPS\Member::loggedIn(), $this->blog, TRUE );
|
||||
|
||||
parent::execute();
|
||||
}
|
||||
@@ -84,7 +84,7 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
}
|
||||
\IPS\Output::i()->breadcrumb[] = array( $this->blog->url(), $this->blog->_title );
|
||||
|
||||
\IPS\Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_adding_entry', $this->blog->member_id ? array( $this->blog->_title => FALSE ) : array( "blogs_blog_{$this->blog->id}" => TRUE ) );
|
||||
\IPS\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 );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
@@ -95,7 +95,8 @@ class _submit extends \IPS\Dispatcher\Controller
|
||||
'url' => \IPS\Http\Url::internal( 'app=blog&module=blogs&controller=submit', 'front', 'blog_submit' ),
|
||||
'class' => 'IPS\blog\Blog',
|
||||
'permissionCheck' => 'add',
|
||||
'forceOwner' => \IPS\Member::loggedIn(),
|
||||
'forceOwner' => \IPS\Member::loggedIn(),
|
||||
'clubs' => \IPS\Settings::i()->club_nodes_in_apps
|
||||
) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
|
||||
@@ -63,14 +63,24 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
/* Build table */
|
||||
$where = array();
|
||||
if ( !in_array( $this->blog->id, array_keys( \IPS\blog\Blog::loadByOwner( \IPS\Member::loggedIn() ) ) ) )
|
||||
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 ) )
|
||||
{
|
||||
$where[] = array( "entry_status!='draft'" );
|
||||
}
|
||||
|
||||
$table = new \IPS\Helpers\Table\Content( 'IPS\blog\Entry', $this->blog->url(), $where, $this->blog );
|
||||
|
||||
$table->tableTemplate = array( \IPS\Theme::i()->getTemplate( 'view' ), 'blogTable' );
|
||||
$table->rowsTemplate = array( \IPS\Theme::i()->getTemplate( 'view' ), 'rows' );
|
||||
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';
|
||||
|
||||
@@ -85,7 +95,7 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
|
||||
);
|
||||
|
||||
/* Online User Location */
|
||||
\IPS\Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_viewing_blog', $this->blog->member_id ? array( $this->blog->_title => FALSE ) : array( "blogs_blog_{$this->blog->id}" => TRUE ) );
|
||||
\IPS\Session::i()->setLocation( $this->blog->url(), array(), 'loc_blog_viewing_blog', array( "blogs_blog_{$this->blog->id}" => TRUE ) );
|
||||
|
||||
/* Output */
|
||||
\IPS\Output::i()->title = $this->blog->_title;
|
||||
@@ -100,7 +110,7 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
|
||||
'@context' => "http://schema.org",
|
||||
'@type' => "Blog",
|
||||
'url' => (string) $this->blog->url(),
|
||||
'name' => htmlspecialchars( $this->blog->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'name' => $this->blog->_title,
|
||||
'description' => strip_tags( $this->blog->description ),
|
||||
'commentCount' => $this->blog->_comments,
|
||||
'interactionStatistic' => array(
|
||||
@@ -136,7 +146,7 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
|
||||
{
|
||||
\IPS\Output::i()->jsonLd['blog']['author'] = array(
|
||||
'@type' => 'Person',
|
||||
'name' => htmlspecialchars( \IPS\Member::load( $this->blog->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
|
||||
'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()
|
||||
);
|
||||
@@ -313,7 +323,7 @@ class _view extends \IPS\Helpers\CoverPhoto\Controller
|
||||
$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->import_show_link ?: \IPS\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, 'source' => \IPS\Content\Item::definedTags( $this->blog ), 'freeChoice' => ( \IPS\Settings::i()->tags_open_system ? TRUE : FALSE ) ) );
|
||||
$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['autocomplete']['forceLower'] = TRUE;
|
||||
|
||||
Reference in new issue
Block a user