Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+64 -17
View File
@@ -2,9 +2,9 @@
/**
* @brief Table Builder using an \IPS\Content\Item class datasource
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @since 16 Jul 2013
* @version SVN_VERSION_NUMBER
*/
@@ -57,7 +57,12 @@ class _Content extends Table
* @brief Honor the pinned flag for sorting. Will be set to false in stream-like views
*/
protected $honorPinned = TRUE;
/**
* @brief Show moved links in the result set. This is desirable in controller generated views but not streams or widgets, etc.
*/
protected $showMovedLinks = FALSE;
/**
* Number of results
*/
@@ -107,9 +112,11 @@ class _Content extends Table
* @param \IPS\Node\Model|NULL $container The container
* @param bool|null $includeHidden Flag to pass to getItemsWithPermission() method for $includeHiddenContent, defaults to NULL
* @param string|NULL $permCheck Permission key to check
* @param bool $honorPinned Show pinned topics at the top of the table
* @param bool $showMovedLinks Show moved links in the result set.
* @return void
*/
public function __construct( $class, \IPS\Http\Url $baseUrl, $where=NULL, \IPS\Node\Model $container=NULL, $includeHidden=NULL, $permCheck='view', $honorPinned=TRUE )
public function __construct( $class, \IPS\Http\Url $baseUrl, $where=NULL, \IPS\Node\Model $container=NULL, $includeHidden=\IPS\Content\Hideable::FILTER_AUTOMATIC, $permCheck='view', $honorPinned=TRUE, $showMovedLinks=FALSE )
{
/* Init */
$this->include = array();
@@ -118,6 +125,7 @@ class _Content extends Table
$this->container = $container;
$this->includeHiddenContent = $includeHidden;
$this->honorPinned = $honorPinned;
$this->showMovedLinks = $showMovedLinks;
$this->permCheck = $permCheck;
/* Init */
@@ -133,14 +141,14 @@ class _Content extends Table
if ( !$this->sortBy and $container->_sortBy !== NULL )
{
$this->sortBy = $container->_sortBy;
$this->sortBy = $class::$databaseTable . '.' . $class::$databasePrefix . $container->_sortBy;
}
if ( !$this->filter )
{
$this->filter = $container->_filter;
}
if ( $this->includeHiddenContent === NULL )
if ( $this->includeHiddenContent === \IPS\Content\Hideable::FILTER_AUTOMATIC )
{
$this->includeHiddenContent = $class::canViewHiddenItems( \IPS\Member::loggedIn(), $container );
}
@@ -153,9 +161,11 @@ class _Content extends Table
\IPS\Output::i()->breadcrumb[] = array( NULL, $container->_title );
/* Meta tags */
\IPS\Output::i()->title = ( $this->page > 1 ) ? \IPS\Member::loggedIn()->language()->addToStack( 'title_with_page_number', FALSE, array( 'sprintf' => array( $container->_title, $this->page ) ) ) : $container->_title;
\IPS\Output::i()->metaTags['title'] = $container->_title;
\IPS\Output::i()->title = ( $this->page > 1 ) ? \IPS\Member::loggedIn()->language()->addToStack( 'title_with_page_number', FALSE, array( 'sprintf' => array( $container->metaTitle(), $this->page ) ) ) : $container->metaTitle();
\IPS\Output::i()->metaTags['title'] = $container->metaTitle();
\IPS\Output::i()->metaTags['description'] = $container->metaDescription();
\IPS\Output::i()->metaTags['og:title'] = $container->metaTitle();
\IPS\Output::i()->metaTags['og:description'] = $container->metaDescription();
\IPS\Output::i()->linkTags['canonical'] = (string) $baseUrl;
}
@@ -221,16 +231,28 @@ class _Content extends Table
break;
}
}
$this->sortBy = in_array( $this->sortBy, $this->sortOptions ) ? $this->sortBy :
( array_key_exists( $this->sortBy, $this->sortOptions) ? $this->sortOptions[ $this->sortBy ] : $defaultSort );
if ( ! mb_stristr( $this->sortBy, '`' ) )
{
$compareSortBy = $this->sortBy;
$lookFor = $class::$databaseTable . '.' . $class::$databasePrefix;
if ( mb_substr( $this->sortBy, 0, mb_strlen( $lookFor ) ) === $lookFor )
{
$compareSortBy = mb_substr( $this->sortBy, mb_strlen( $lookFor ) );
}
$this->sortBy = in_array( $compareSortBy, $this->sortOptions ) ? $this->sortBy :
( array_key_exists( $compareSortBy, $this->sortOptions ) ? $this->sortOptions[ $compareSortBy ] : $defaultSort );
}
/* Callback? */
if ( $this->advancedSearchCallback and !empty( $advancedSearchValues ) )
{
$obj = $this;
call_user_func( $this->advancedSearchCallback, $obj, $advancedSearchValues );
}
/* What are we sorting by? */
$sortBy = $this->sortBy . ' ' . ( mb_strtolower( $this->sortDirection ) == 'asc' ? 'asc' : 'desc' );
if ( in_array( 'IPS\Content\Pinnable', class_implements( $class ) ) and $this->honorPinned )
@@ -245,10 +267,10 @@ class _Content extends Table
{
$where[] = is_array( $this->filters[ $this->filter ] ) ? $this->filters[ $this->filter ] : array( $this->filters[ $this->filter ] );
}
/* Get results */
$this->count = $class::getItemsWithPermission( $where, $sortBy, NULL, $this->permCheck, $this->includeHiddenContent, 0, NULL, $this->joinContainer, $this->joinComments, $this->joinReviews, TRUE, $this->joins );
$it = $class::getItemsWithPermission( $where, $sortBy, array( ( $this->limit * ( $this->page - 1 ) ), $this->limit ), $this->permCheck, $this->includeHiddenContent, 0, NULL, $this->joinContainer, $this->joinComments, $this->joinReviews, FALSE, $this->joins );
$this->count = $class::getItemsWithPermission( $where, $sortBy, NULL, $this->permCheck, $this->includeHiddenContent, 0, NULL, $this->joinContainer, $this->joinComments, $this->joinReviews, TRUE, $this->joins, FALSE, TRUE, TRUE, TRUE, $this->showMovedLinks );
$it = $class::getItemsWithPermission( $where, $sortBy, array( ( $this->limit * ( $this->page - 1 ) ), $this->limit ), $this->permCheck, $this->includeHiddenContent, 0, NULL, $this->joinContainer, $this->joinComments, $this->joinReviews, FALSE, $this->joins, FALSE, TRUE, TRUE, TRUE, $this->showMovedLinks );
$this->pages = ceil( $this->count / $this->limit );
$rows = iterator_to_array( $it );
@@ -385,9 +407,17 @@ class _Content extends Table
{
$return[] = 'unhide';
}
elseif ( $item->hidden() === 1 and $item->canUnhide() )
elseif ( $item->hidden() === 1 )
{
$return[] = 'approve';
if( $item->canUnhide() )
{
$return[] = 'approve';
}
if( $item->canHide() )
{
$return[] = 'hide';
}
}
elseif ( $item->canHide() )
{
@@ -455,6 +485,14 @@ class _Content extends Table
*/
protected function multimod()
{
\IPS\Session::i()->csrfCheck();
/* Basic check that we selected something */
if( !isset( \IPS\Request::i()->moderate ) OR empty( \IPS\Request::i()->moderate ) )
{
\IPS\Output::i()->error( 'nothing_mm_selected', '1S330/1', 403, '' );
}
$class = $this->class;
$params = array();
@@ -568,6 +606,15 @@ class _Content extends Table
$form->hiddenValues['modaction'] = 'merge';
$form->hiddenValues['moderate'] = \IPS\Request::i()->moderate;
$form->add( new \IPS\Helpers\Form\Radio( 'merge_master', NULL, TRUE, array( 'options' => $options, 'descriptions' => $descriptions ) ) );
if ( isset( $class::$databaseColumnMap['moved_to'] ) )
{
$form->add( new \IPS\Helpers\Form\Checkbox( 'move_keep_link' ) );
if ( \IPS\Settings::i()->topic_redirect_prune )
{
\IPS\Member::loggedIn()->language()->words['move_keep_link_desc'] = \IPS\Member::loggedIn()->language()->addToStack( '_move_keep_link_desc', FALSE, array( 'pluralize' => array( \IPS\Settings::i()->topic_redirect_prune ) ) );
}
}
if ( $values = $form->values() )
{
$otherItems = array();
@@ -579,7 +626,7 @@ class _Content extends Table
}
}
$class::load( $values['merge_master'] )->mergeIn( $otherItems );
$class::load( $values['merge_master'] )->mergeIn( $otherItems, isset( $values['move_keep_link'] ) ? $values['move_keep_link'] : FALSE );
}
else
{