Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Ajax only methods
|
||||
* @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
|
||||
* @subpackage Content
|
||||
* @since 01 Oct 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -31,7 +31,7 @@ class _ajax extends \IPS\Dispatcher\Controller
|
||||
*/
|
||||
protected function makeFurl()
|
||||
{
|
||||
return \IPS\Output::i()->json( array( 'slug' => \IPS\Http\Url::seoTitle( \IPS\Request::i()->slug ) ) );
|
||||
return \IPS\Output::i()->json( array( 'slug' => \IPS\Http\Url\Friendly::seoTitle( \IPS\Request::i()->slug ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
/**
|
||||
* @brief [Database] Category Controller
|
||||
* @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 Content
|
||||
* @since 16 April 2014
|
||||
@@ -48,6 +48,8 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
*/
|
||||
public function clearFilters()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
$catClass = 'IPS\cms\Categories' . \IPS\cms\Databases\Dispatcher::i()->databaseId;
|
||||
|
||||
try
|
||||
@@ -78,7 +80,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
|
||||
try
|
||||
{
|
||||
$category = $catClass::loadAndCheckPerms( \IPS\cms\Databases\Dispatcher::i()->categoryId );
|
||||
$category = $catClass::loadAndCheckPerms( \IPS\cms\Databases\Dispatcher::i()->categoryId, 'read' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
@@ -91,10 +93,13 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
{
|
||||
$breadcrumbs = \IPS\Output::i()->breadcrumb;
|
||||
}
|
||||
|
||||
$RecordsClass = $category::$contentItemClass;
|
||||
|
||||
/* Check cookie */
|
||||
$where = array();
|
||||
$cookie = $category->getFilterCookie();
|
||||
|
||||
if ( $cookie !== NULL )
|
||||
{
|
||||
foreach( $cookie as $f => $v )
|
||||
@@ -104,26 +109,54 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
{
|
||||
if ( is_array( $v ) )
|
||||
{
|
||||
$like = array();
|
||||
foreach( $v as $val )
|
||||
if ( array_key_exists( 'start', $v ) or array_key_exists( 'end', $v ) )
|
||||
{
|
||||
if ( $val === 0 or ! empty( $val ) )
|
||||
$start = ( $v['start'] instanceof \IPS\DateTime ) ? $v['start']->getTimestamp() : intval( $v['start'] );
|
||||
$end = ( $v['end'] instanceof \IPS\DateTime ) ? $v['end']->getTimestamp() : intval( $v['end'] );
|
||||
|
||||
if ( $start or $end )
|
||||
{
|
||||
$like[] = "CONCAT( ',', " . mb_substr( $k, 8 ) . ", ',') LIKE '%," . \IPS\Db::i()->real_escape_string( $val ) . ",%'";
|
||||
$where[] = array( '( ' . mb_substr( $k, 8 ) . ' BETWEEN ' . $start . ' AND ' . $end . ' )' );
|
||||
}
|
||||
}
|
||||
|
||||
$where[] = array( '( ' . \IPS\Db::i()->in( mb_substr( $k, 8 ), $v ) . ( count( $like ) ? " OR (" . implode( ' OR ', $like ) . ') )' : ')' ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $v !== 0 and ! $v )
|
||||
{
|
||||
$where[] = array( mb_substr( $k, 8 ) . " IS NULL" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( mb_substr( $k, 8 ) . "=?", $v );
|
||||
$like = array();
|
||||
foreach( $v as $val )
|
||||
{
|
||||
if ( $val === 0 or ! empty( $val ) )
|
||||
{
|
||||
$like[] = "CONCAT( ',', " . mb_substr( $k, 8 ) . ", ',') LIKE '%," . \IPS\Db::i()->real_escape_string( $val ) . ",%'";
|
||||
}
|
||||
}
|
||||
|
||||
$where[] = array( '( ' . \IPS\Db::i()->in( mb_substr( $k, 8 ), $v ) . ( count( $like ) ? " OR (" . implode( ' OR ', $like ) . ') )' : ')' ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( is_bool( $v ) )
|
||||
{
|
||||
/* YesNo fields are false or true */
|
||||
if ( $v === false )
|
||||
{
|
||||
$where[] = array( '(' . mb_substr( $k, 8 ) . ' IS NULL or ' . mb_substr( $k, 8 ) . '=0)' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( mb_substr( $k, 8 ) . "=1" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $v !== 0 and ! $v )
|
||||
{
|
||||
$where[] = array( mb_substr( $k, 8 ) . " IS NULL" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$where[] = array( mb_substr( $k, 8 ) . "=?", $v );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,8 +178,25 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
$table->sortBy = ( isset( \IPS\Request::i()->sortby ) ) ? \IPS\Request::i()->sortby : ( $database->field_sort ? $database->field_sort : 'record_last_comment' );
|
||||
$table->sortDirection = ( isset( \IPS\Request::i()->sortdirection ) ) ? \IPS\Request::i()->sortdirection : ( $database->field_direction ? $database->field_direction : 'desc' );
|
||||
$table->limit = $database->field_perpage ? $database->field_perpage : 25;
|
||||
$table->title = \IPS\Member::loggedIn()->language()->addToStack( $database->use_categories ? 'x_records_in_this_category' : 'x_records' , FALSE, array( 'sprintf' => array( $category->records, $database->recordWord( $category->records ) ) ) );
|
||||
|
||||
$table->title = \IPS\Member::loggedIn()->language()->addToStack( $database->use_categories ? 'x_records_in_this_category' : 'x_records' , FALSE, array( 'sprintf' => array( $RecordsClass::contentCount( $category, FALSE ), $database->recordWord( $RecordsClass::contentCount( $category, FALSE ) ) ) ) );
|
||||
|
||||
foreach( $customFields as $id => $obj )
|
||||
{
|
||||
if ( $table->sortBy == 'field_' . $id )
|
||||
{
|
||||
if ( $obj->type == 'Number' )
|
||||
{
|
||||
$table->sortOptions['field_' . $id ] = 'LENGTH(`field_' . $id . '`) ' . $table->sortDirection . ',`field_' . $id . '`';
|
||||
break;
|
||||
}
|
||||
elseif( $obj->type == 'Date' )
|
||||
{
|
||||
$table->sortOptions['field_' . $id ] = 'CAST(`field_' . $id . '` AS UNSIGNED)';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure table doesn't add breadcrumbs if we're not using categories */
|
||||
if ( ! $database->use_categories )
|
||||
{
|
||||
@@ -185,6 +235,10 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
'field_' . $database->field_title => 'content_record_title',
|
||||
'record_publish_date' => 'content_record_publish_date'
|
||||
);
|
||||
|
||||
/* Ensure we have all sort options available */
|
||||
$table->sortOptions = array_unique( array_merge( $table->sortOptions, array_combine( array_keys( $sortBy ), array_keys( $sortBy ) ) ) );
|
||||
|
||||
if ( !isset( $sortBy[ $database->field_sort ] ) )
|
||||
{
|
||||
switch ( $database->field_sort )
|
||||
@@ -199,7 +253,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
$table->sortOptions['database_field__member'] = $database->field_sort;
|
||||
\IPS\Member::loggedIn()->language()->words['sort_database_field__member'] = \IPS\Member::loggedIn()->language()->addToStack('database_field__member');
|
||||
break;
|
||||
case 'rating_real':
|
||||
case 'record_rating':
|
||||
$sortBy[ $database->field_sort ] = 'database_field__rating';
|
||||
$table->sortOptions['database_field__rating'] = $database->field_sort;
|
||||
\IPS\Member::loggedIn()->language()->words['sort_database_field__rating'] = \IPS\Member::loggedIn()->language()->addToStack('database_field__rating');
|
||||
@@ -216,11 +270,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
unset ( $table->sortOptions['last_comment'] );
|
||||
unset ( $table->sortOptions['num_comments'] );
|
||||
}
|
||||
else
|
||||
{
|
||||
unset( $table->sortOptions['updated'] );
|
||||
}
|
||||
|
||||
|
||||
if ( !$database->options['reviews'] )
|
||||
{
|
||||
unset ( $table->sortOptions['num_reviews'] );
|
||||
@@ -233,6 +283,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
if ( $database->field_title !== mb_substr( $database->field_sort, 6 ) )
|
||||
{
|
||||
$sortBy[ $database->field_sort ] = \IPS\Member::loggedIn()->language()->addToStack( 'content_field_' . mb_substr( $database->field_sort, 6 ) );
|
||||
$table->sortOptions[ $database->field_sort ] = $database->field_sort;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,11 +303,27 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
if ( $obj->filter )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['content_field_' . $obj->id ] = $obj->_title;
|
||||
$table->advancedSearch[ 'content_field_' . $obj->id ] = array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => $obj->extra, 'multiple' => TRUE, 'noDefault' => true ) );
|
||||
if ( $obj->type == 'DateRange' )
|
||||
{
|
||||
$table->advancedSearch[ 'content_field_' . $obj->id ] = array( \IPS\Helpers\Table\SEARCH_DATE_RANGE, array( 'noDefault' => true ) );
|
||||
}
|
||||
if ( $obj->type == 'Number' )
|
||||
{
|
||||
$table->advancedSearch[ 'content_field_' . $obj->id ] = array( \IPS\Helpers\Table\SEARCH_NUMERIC_TEXT, array( 'noDefault' => true ) );
|
||||
}
|
||||
else if ( $obj->type == 'YesNo' )
|
||||
{
|
||||
$table->advancedSearch[ 'content_field_' . $obj->id ] = array( \IPS\Helpers\Table\SEARCH_BOOL, array( 'noDefault' => true ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->advancedSearch[ 'content_field_' . $obj->id ] = array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => $obj->extra, 'multiple' => TRUE, 'noDefault' => true ) );
|
||||
}
|
||||
|
||||
$table->advancedSearch['sort_by'][1]['options']['field_' . $obj->id ] = 'content_field_' . $obj->id;
|
||||
}
|
||||
|
||||
$table->sortOptions[ 'field_' . $obj->id ] = 'field_' . $obj->id;
|
||||
$table->sortOptions[ 'field_' . $obj->id ] = isset( $table->sortOptions[ 'field_' . $obj->id ] ) ? $table->sortOptions[ 'field_' . $obj->id ] : 'field_' . $obj->id;
|
||||
}
|
||||
|
||||
$table->advancedSearchCallback = function( $table, $values ) use ( $database, $sortBy, $customFields )
|
||||
@@ -268,32 +335,60 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
{
|
||||
if ( is_array( $v ) )
|
||||
{
|
||||
$like = array();
|
||||
foreach( $v as $val )
|
||||
if ( array_key_exists( 'start', $v ) or array_key_exists( 'end', $v ) )
|
||||
{
|
||||
if ( $val === 0 or ! empty( $val ) )
|
||||
$start = ( $v['start'] instanceof \IPS\DateTime ) ? $v['start']->getTimestamp() : intval( $v['start'] );
|
||||
$end = ( $v['end'] instanceof \IPS\DateTime ) ? $v['end']->getTimestamp() : intval( $v['end'] );
|
||||
|
||||
if ( $start or $end )
|
||||
{
|
||||
$like[] = "CONCAT( ',', " . mb_substr( $k, 8 ) . ", ',') LIKE '%," . \IPS\Db::i()->real_escape_string( $val ) . ",%'";
|
||||
$table->where[] = array( '( ' . mb_substr( $k, 8 ) . ' BETWEEN ' . $start . ' AND ' . $end . ' )' );
|
||||
}
|
||||
}
|
||||
|
||||
$table->where[] = array( '( ' . \IPS\Db::i()->in( mb_substr( $k, 8 ), $v ) . ( count( $like ) ? " OR (" . implode( ' OR ', $like ) . ') )' : ')' ) );
|
||||
else
|
||||
{
|
||||
$like = array();
|
||||
foreach( $v as $val )
|
||||
{
|
||||
if ( $val === 0 or ! empty( $val ) )
|
||||
{
|
||||
$like[] = "CONCAT( ',', " . mb_substr( $k, 8 ) . ", ',') LIKE '%," . \IPS\Db::i()->real_escape_string( $val ) . ",%'";
|
||||
}
|
||||
}
|
||||
|
||||
$table->where[] = array( '( ' . \IPS\Db::i()->in( mb_substr( $k, 8 ), $v ) . ( count( $like ) ? " OR (" . implode( ' OR ', $like ) . ') )' : ')' ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( $v !== '___any___' )
|
||||
{
|
||||
if ( $v !== 0 and ! $v )
|
||||
{
|
||||
if ( is_bool( $v ) )
|
||||
{
|
||||
$table->where[] = array( mb_substr( $k, 8 ) . " IS NULL" );
|
||||
/* YesNo fields are false or true */
|
||||
if ( $v === false )
|
||||
{
|
||||
$table->where[] = array( '(' . mb_substr( $k, 8 ) . ' IS NULL or ' . mb_substr( $k, 8 ) . '=0)' );
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->where[] = array( mb_substr( $k, 8 ) . "=1" );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->where[] = array( mb_substr( $k, 8 ) . "=?", $v );
|
||||
if ( $v !== 0 and ! $v )
|
||||
{
|
||||
$table->where[] = array( mb_substr( $k, 8 ) . " IS NULL" );
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->where[] = array( mb_substr( $k, 8 ) . "=?", $v );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$key = mb_substr( $k, 14 );
|
||||
\IPS\cms\modules\front\database\category::$activeFilters[ $key ] = array( 'field' => $customFields[ $key ], 'value' => $customFields[ $key ]->displayValue( $v ) );
|
||||
}
|
||||
@@ -315,7 +410,19 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
/* Sort */
|
||||
if ( isset( $values['sort_by'] ) and isset( $sortBy[ $values['sort_by'] ] ) )
|
||||
{
|
||||
$table->sortBy = $values['sort_by'];
|
||||
if ( isset( $customFields[ mb_substr( $values['sort_by'], 6 ) ] ) and $customFields[ mb_substr( $values['sort_by'], 6 ) ]->type == 'Number' )
|
||||
{
|
||||
$table->sortBy = 'LENGTH(`' . $values['sort_by'] . '`) ' . $table->sortDirection . ',`' . $values['sort_by'] . '`';
|
||||
}
|
||||
elseif( isset( $customFields[ mb_substr( $values['sort_by'], 6 ) ] ) and $customFields[ mb_substr( $values['sort_by'], 6 ) ]->type == 'Date' )
|
||||
{
|
||||
$table->sortBy = 'CAST(`' . $values['sort_by'] . '` AS UNSIGNED)';
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->sortBy = $values['sort_by'];
|
||||
}
|
||||
|
||||
$table->sortDirection = $values['sort_direction'];
|
||||
}
|
||||
|
||||
@@ -361,7 +468,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
}
|
||||
if ( $days !== NULL )
|
||||
{
|
||||
$table->where[] = array( 'record_last_comment>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $days . 'D' ) ) );
|
||||
$table->where[] = array( 'record_last_comment>?', \IPS\DateTime::create()->sub( new \DateInterval( 'P' . $days . 'D' ) )->getTimestamp() );
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -370,13 +477,13 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
if ( $database->rss )
|
||||
{
|
||||
$rssUrl = $table->baseUrl->setQueryString('rss', 1 );
|
||||
$rssName = $database->_title . ': ' . $category->_title;
|
||||
$rssName = $database->_title . ': ' . $category->metaTitle();
|
||||
\IPS\Output::i()->rssFeeds[ $rssName ] = $rssUrl;
|
||||
|
||||
/* Show RSS feed */
|
||||
if ( isset( \IPS\Request::i()->rss ) )
|
||||
{
|
||||
$rssName = \IPS\Member::loggedIn()->language()->get('content_db_' . $database->id ) . ': ' . \IPS\Member::loggedIn()->language()->get('content_cat_name_' . $category->id );
|
||||
$rssName = \IPS\Member::loggedIn()->language()->get('content_db_' . $database->id ) . ': ' . $category->metaTitle();
|
||||
$document = \IPS\Xml\Rss::newDocument( $table->baseUrl, $rssName, $rssName );
|
||||
$contentField = 'field_' . $database->field_content;
|
||||
|
||||
@@ -390,8 +497,8 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
{
|
||||
$content = \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' )->rssItemWithImage( $content, $record->record_image );
|
||||
}
|
||||
|
||||
$document->addItem( $record->_title, $record->url(), $content, \IPS\DateTime::ts( $record->record_last_comment ), $record->_id );
|
||||
|
||||
$document->addItem( $record->_title, $record->url(), $content, \IPS\DateTime::ts( ( $record->record_last_comment > $record->record_publish_date ) ? $record->record_publish_date : $record->record_last_comment ), $record->_id );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,14 +513,17 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'records/list.css', 'cms', 'front' ) );
|
||||
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' )->categoryHeader( $category, (string) $table, static::$activeFilters );
|
||||
$stringTable = (string) $table;
|
||||
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' )->categoryHeader( $category, $stringTable, static::$activeFilters );
|
||||
|
||||
if ( ( $category->hasChildren() AND $category->show_records ) OR ! $category->hasChildren() )
|
||||
{
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= (string) $table;
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= $stringTable;
|
||||
}
|
||||
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' )->categoryFooter( $category, (string) $table, static::$activeFilters );
|
||||
\IPS\Output::i()->title = ( $table->page > 1 ) ? \IPS\Member::loggedIn()->language()->addToStack( 'title_with_page_number', FALSE, array( 'sprintf' => array( $category->pageTitle(), $table->page ) ) ) : $category->pageTitle();
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' )->categoryFooter( $category, $stringTable, static::$activeFilters );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -440,7 +550,11 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
if ( $recordClass::modPermission( 'lock', NULL, $category ) or
|
||||
$recordClass::modPermission( 'pin', NULL, $category ) or
|
||||
$recordClass::modPermission( 'hide', NULL, $category ) or
|
||||
$recordClass::modPermission( 'feature', NULL, $category ) )
|
||||
$recordClass::modPermission( 'feature', NULL, $category ) or
|
||||
$fieldsClass::fixedFieldFormShow( 'record_allow_comments' ) or
|
||||
$fieldsClass::fixedFieldFormShow( 'record_expiry_date' ) or
|
||||
$fieldsClass::fixedFieldFormShow( 'record_comment_cutoff' ) or
|
||||
\IPS\Member::loggedIn()->modPermission('can_content_edit_meta_tags') )
|
||||
{
|
||||
$hasModOptions = TRUE;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,10 @@
|
||||
/**
|
||||
* @brief [Database] Category List Controller
|
||||
* @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
|
||||
* @subpackage Content
|
||||
* @since 16 April 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -68,7 +69,14 @@ class _index extends \IPS\cms\Databases\Controller
|
||||
|
||||
foreach ( $recordClass::getItemsWithPermission( array(), $database->field_sort . ' ' . $database->field_direction, $database->rss, 'read' ) as $record )
|
||||
{
|
||||
$document->addItem( $record->_title, $record->url(), $record->$contentField, \IPS\DateTime::ts( $record->_publishDate ), $record->_id );
|
||||
$content = $record->$contentField;
|
||||
|
||||
if ( $record->record_image )
|
||||
{
|
||||
$content = \IPS\cms\Theme::i()->getTemplate( 'listing', 'cms', 'database' )->rssItemWithImage( $content, $record->record_image );
|
||||
}
|
||||
|
||||
$document->addItem( $record->_title, $record->url(), $content, \IPS\DateTime::ts( $record->_publishDate ), $record->_id );
|
||||
}
|
||||
|
||||
/* @note application/rss+xml is not a registered IANA mime-type so we need to stick with text/xml for RSS */
|
||||
@@ -95,12 +103,18 @@ class _index extends \IPS\cms\Databases\Controller
|
||||
}
|
||||
|
||||
$where = ( $database->featured_settings['featured'] ) ? array( array( 'record_featured=?', 1 ) ) : NULL;
|
||||
|
||||
$articles = $recordClass::getItemsWithPermission( $where, 'record_pinned DESC, ' . $database->featured_settings['sort'] . ' ' . $database->featured_settings['direction'], array( $limit, $database->featured_settings['perpage'] ), 'read', NULL, 0, NULL, FALSE, FALSE, FALSE, FALSE );
|
||||
|
||||
if ( isset( $database->featured_settings['categories'] ) and count( $database->featured_settings['categories'] ) AND is_array( $database->featured_settings['categories'] ) )
|
||||
{
|
||||
$categoryField = "`cms_custom_database_{$database->_id}`.`category_id`";
|
||||
$where[] = array( \IPS\Db::i()->in( $categoryField, array_values( $database->featured_settings['categories'] ) ) );
|
||||
}
|
||||
|
||||
$articles = $recordClass::getItemsWithPermission( $where, 'record_pinned DESC, ' . $database->featured_settings['sort'] . ' ' . $database->featured_settings['direction'], array( $limit, $database->featured_settings['perpage'] ), 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, TRUE, FALSE, FALSE, FALSE );
|
||||
|
||||
if ( $database->featured_settings['pagination'] )
|
||||
{
|
||||
$count = $recordClass::getItemsWithPermission( $where, 'record_pinned DESC, ' . $database->featured_settings['sort'] . ' ' . $database->featured_settings['direction'], $database->featured_settings['perpage'], 'read', NULL, 0, NULL, FALSE, FALSE, FALSE, TRUE );
|
||||
$count = $recordClass::getItemsWithPermission( $where, 'record_pinned DESC, ' . $database->featured_settings['sort'] . ' ' . $database->featured_settings['direction'], $database->featured_settings['perpage'], 'read', \IPS\Content\Hideable::FILTER_AUTOMATIC, 0, NULL, FALSE, FALSE, FALSE, TRUE );
|
||||
}
|
||||
|
||||
/* Pagination */
|
||||
@@ -108,8 +122,15 @@ class _index extends \IPS\cms\Databases\Controller
|
||||
'page' => $page,
|
||||
'pages' => ( $count > 0 ) ? ceil( $count / $database->featured_settings['perpage'] ) : 1
|
||||
);
|
||||
|
||||
|
||||
/* Make sure we are viewing a real page */
|
||||
if ( $page > $pagination['pages'] )
|
||||
{
|
||||
\IPS\Output::i()->redirect( \IPS\Request::i()->url()->setQueryString( 'page', 1 ), NULL, 303 );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'database_index/featured.css', 'cms', 'front' ) );
|
||||
\IPS\Output::i()->title = ( $page > 1 ) ? \IPS\Member::loggedIn()->language()->addToStack( 'title_with_page_number', FALSE, array( 'sprintf' => array( $database->pageTitle(), $page ) ) ) : $database->pageTitle();
|
||||
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= \IPS\Output::i()->output = \IPS\cms\Theme::i()->getTemplate( $database->template_featured, 'cms', 'database' )->index( $database, $articles, $url, $pagination );
|
||||
}
|
||||
@@ -117,10 +138,13 @@ class _index extends \IPS\cms\Databases\Controller
|
||||
{
|
||||
/* Category view */
|
||||
$class = '\IPS\cms\Categories' . $database->id;
|
||||
|
||||
/* Load into memory */
|
||||
$class::loadIntoMemory();
|
||||
$categories = $class::roots('view', \IPS\Member::loggedIn(), null, $database->_id );
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'records/index.css', 'cms', 'front' ) );
|
||||
|
||||
\IPS\Output::i()->title = $database->pageTitle();
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= \IPS\Output::i()->output = \IPS\cms\Theme::i()->getTemplate( $database->template_categories, 'cms', 'database' )->index( $database, $categories, $url );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
/**
|
||||
* @brief Record View
|
||||
* @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
|
||||
* @subpackage Content
|
||||
* @since 17 Apr 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
@@ -76,7 +76,7 @@ class _record extends \IPS\Content\Controller
|
||||
$activeTabContents = $record->commentReviews( $tab );
|
||||
$comments = count( $tabs ) ? \IPS\cms\Theme::i()->getTemplate( $record->container()->_template_display, 'cms', 'database' )->commentsAndReviewsTabs( \IPS\Theme::i()->getTemplate( 'global', 'core' )->tabs( $tabs, $tab, $activeTabContents, $record->url(), 'tab', FALSE, TRUE ), md5( $record->url() ) ) : NULL;
|
||||
|
||||
if ( \IPS\Request::i()->isAjax() and isset( \IPS\Request::i()->tab ) )
|
||||
if ( \IPS\Request::i()->isAjax() and ( isset( \IPS\Request::i()->page ) OR isset( \IPS\Request::i()->tab ) ) )
|
||||
{
|
||||
\IPS\Output::i()->sendOutput( $activeTabContents, 200, 'text/html', \IPS\Output::i()->httpHeaders );
|
||||
}
|
||||
@@ -121,7 +121,7 @@ class _record extends \IPS\Content\Controller
|
||||
$record->addCommentWhenFiltersChanged( $values );
|
||||
}
|
||||
|
||||
foreach( $fieldsClass::fields( $customValues, 'edit', $record->category_id ? $category : NULL, $FieldsClass::FIELD_SKIP_TITLE_CONTENT | $FieldsClass::FIELD_DISPLAY_COMMENTFORM) as $key => $field )
|
||||
foreach( $fieldsClass::fields( $customValues, 'edit', $record->category_id ? $category : NULL, $FieldsClass::FIELD_SKIP_TITLE_CONTENT | $FieldsClass::FIELD_DISPLAY_COMMENTFORM ) as $key => $field )
|
||||
{
|
||||
$key = 'field_' . $key;
|
||||
$record->$key = $field::stringValue( isset( $values[ $field->name ] ) ? $values[ $field->name ] : NULL );
|
||||
@@ -172,7 +172,8 @@ class _record extends \IPS\Content\Controller
|
||||
{
|
||||
\IPS\Output::i()->metaTags['og:image'] = (string) \IPS\File::get( 'cms_Records', $record->record_image )->url;
|
||||
}
|
||||
|
||||
\IPS\Output::i()->contextualSearchOptions = array();
|
||||
\IPS\Output::i()->contextualSearchOptions[ \IPS\Member::loggedIn()->language()->addToStack( 'search_contextual_item', FALSE, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack( $record::$title ) ) ) ) ] = array( 'type' => mb_strtolower( str_replace( '\\', '_', mb_substr( $class, 4 ) ) ), 'nodes' => $record->_id );
|
||||
\IPS\cms\Databases\Dispatcher::i()->output .= \IPS\cms\Theme::i()->getTemplate( $record->container()->_template_display, 'cms', 'database' )->record( $record, $comments, $form, $nextUnread );
|
||||
}
|
||||
|
||||
@@ -185,7 +186,8 @@ class _record extends \IPS\Content\Controller
|
||||
*/
|
||||
protected function _setBreadcrumbAndTitle( $item, $link=TRUE )
|
||||
{
|
||||
if ( \IPS\cms\Databases::load( \IPS\cms\Databases\Dispatcher::i()->databaseId )->use_categories )
|
||||
$database = \IPS\cms\Databases::load( \IPS\cms\Databases\Dispatcher::i()->databaseId );
|
||||
if ( $database->use_categories )
|
||||
{
|
||||
parent::_setBreadcrumbAndTitle( $item, $link );
|
||||
}
|
||||
@@ -193,7 +195,7 @@ class _record extends \IPS\Content\Controller
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( $link ? $item->url() : NULL, $item->mapped('title') );
|
||||
|
||||
$title = ( isset( \IPS\Request::i()->page ) and \IPS\Request::i()->page > 1 ) ? \IPS\Member::loggedIn()->language()->addToStack( 'title_with_page_number', FALSE, array( 'sprintf' => array( $item->mapped('title'), \IPS\Request::i()->page ) ) ) : $item->mapped('title');
|
||||
$title = ( isset( \IPS\Request::i()->page ) and \IPS\Request::i()->page > 1 ) ? \IPS\Member::loggedIn()->language()->addToStack( 'title_with_page_number', FALSE, array( 'sprintf' => array( $item->mapped('title') . ' - ' . $database->pageTitle(), \IPS\Request::i()->page ) ) ) : $item->mapped('title') . ' - ' . $database->pageTitle();
|
||||
\IPS\Output::i()->title = $title;
|
||||
}
|
||||
}
|
||||
@@ -279,6 +281,9 @@ class _record extends \IPS\Content\Controller
|
||||
);
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'system/diff.css', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'codemirror/diff_match_patch.js', 'core', 'interface' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'codemirror/codemirror.js', 'core', 'interface' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'codemirror/codemirror.css', 'core', 'interface' ) );
|
||||
|
||||
/* Output */
|
||||
if ( \IPS\Request::i()->isAjax() )
|
||||
@@ -313,6 +318,9 @@ class _record extends \IPS\Content\Controller
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
|
||||
/* Make sure the user confirmed the deletion */
|
||||
\IPS\Request::i()->confirmedDelete();
|
||||
|
||||
$recordClass = '\IPS\cms\Records' . \IPS\cms\Databases\Dispatcher::i()->databaseId;
|
||||
|
||||
try
|
||||
@@ -389,28 +397,13 @@ class _record extends \IPS\Content\Controller
|
||||
$customFields = $fieldsClass::data( 'view', $category );
|
||||
$conflicts = array();
|
||||
$form = new \IPS\Helpers\Form( 'form', 'content_revision_restore' );
|
||||
|
||||
require_once \IPS\ROOT_PATH . "/system/3rd_party/Diff/class.Diff.php";
|
||||
|
||||
|
||||
/* Build up our data set */
|
||||
foreach( $customFields as $id => $field )
|
||||
$conflicts = $revision->getDiffHtmlTables( $record::$customDatabaseId, $record, true );
|
||||
|
||||
foreach( $conflicts as $conflict )
|
||||
{
|
||||
$key = 'field_' . $field->id;
|
||||
|
||||
if ( $record->$key AND $revision->get( $key ) )
|
||||
{
|
||||
if ( md5( $record->$key ) != md5( $revision->get( $key ) ) )
|
||||
{
|
||||
$conflicts[ $key ] = array(
|
||||
'revision' => $revision->get( $key ),
|
||||
'record' => $record->$key,
|
||||
'field' => $field,
|
||||
'diff' => \Diff::toTable( \Diff::compare( $revision->get( $key ), $record->$key ) )
|
||||
);
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'conflict_' . $field->id, 'no', false, array( 'options' => array( 'old' => '', 'new' => '' ) ) ) );
|
||||
}
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'conflict_' . $conflict['field']->id, 'no', false, array( 'options' => array( 'old' => '', 'new' => '' ) ) ) );
|
||||
}
|
||||
|
||||
if ( $values = $form->values() )
|
||||
@@ -449,6 +442,9 @@ class _record extends \IPS\Content\Controller
|
||||
\IPS\Output::i()->title = $title;
|
||||
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'system/diff.css', 'core', 'admin' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'codemirror/diff_match_patch.js', 'core', 'interface' ) );
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'codemirror/codemirror.js', 'core', 'interface' ) );
|
||||
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'codemirror/codemirror.css', 'core', 'interface' ) );
|
||||
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'revisions', 'cms' ), 'view' ), $record, $revision, $conflicts );
|
||||
}
|
||||
@@ -463,6 +459,7 @@ class _record extends \IPS\Content\Controller
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_records.js', 'cms' ) );
|
||||
|
||||
$recordClass = '\IPS\cms\Records' . \IPS\cms\Databases\Dispatcher::i()->databaseId;
|
||||
$fieldsClass = '\IPS\cms\Fields' . \IPS\cms\Databases\Dispatcher::i()->databaseId;
|
||||
$database = \IPS\cms\Databases::load( \IPS\cms\Databases\Dispatcher::i()->databaseId );
|
||||
try
|
||||
{
|
||||
@@ -494,9 +491,13 @@ class _record extends \IPS\Content\Controller
|
||||
$hasModOptions = FALSE;
|
||||
|
||||
if ( $recordClass::modPermission( 'lock', NULL, $category ) or
|
||||
$recordClass::modPermission( 'pin', NULL, $category ) or
|
||||
$recordClass::modPermission( 'hide', NULL, $category ) or
|
||||
$recordClass::modPermission( 'feature', NULL, $category ) )
|
||||
$recordClass::modPermission( 'pin', NULL, $category ) or
|
||||
$recordClass::modPermission( 'hide', NULL, $category ) or
|
||||
$recordClass::modPermission( 'feature', NULL, $category ) or
|
||||
$fieldsClass::fixedFieldFormShow( 'record_allow_comments' ) or
|
||||
$fieldsClass::fixedFieldFormShow( 'record_expiry_date' ) or
|
||||
$fieldsClass::fixedFieldFormShow( 'record_comment_cutoff' ) or
|
||||
\IPS\Member::loggedIn()->modPermission('can_content_edit_meta_tags') )
|
||||
{
|
||||
$hasModOptions = TRUE;
|
||||
}
|
||||
@@ -514,14 +515,12 @@ class _record extends \IPS\Content\Controller
|
||||
{
|
||||
$record->$column = $values[ $recordClass::$formLangPrefix . 'date' ]->getTimestamp();
|
||||
}
|
||||
else
|
||||
{
|
||||
$record->$column = time();
|
||||
}
|
||||
}
|
||||
|
||||
$record->save();
|
||||
|
||||
|
||||
\IPS\Session::i()->modLog( 'modlog__item_edit', array( $record::$title => FALSE, $record->url()->__toString() => FALSE, $record::$title => TRUE, $record->mapped( 'title' ) => FALSE ), $record );
|
||||
|
||||
\IPS\Output::i()->redirect( $record->url() );
|
||||
}
|
||||
|
||||
@@ -738,7 +737,7 @@ class _record extends \IPS\Content\Controller
|
||||
$comment = $commentClass::load( \IPS\Request::i()->comment );
|
||||
$item = $record;
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
return parent::$method( $commentClass, $comment, $item );
|
||||
|
||||
Reference in new issue
Block a user