Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -16,6 +16,7 @@ use IPS\cms\Categories;
|
||||
use IPS\cms\Pages\Folder;
|
||||
use IPS\cms\Pages\Page;
|
||||
use IPS\cms\Records;
|
||||
use IPS\Content\Filter;
|
||||
use IPS\Db;
|
||||
use IPS\Patterns\ActiveRecordIterator;
|
||||
use IPS\Theme;
|
||||
@@ -69,19 +70,21 @@ class ajax extends \IPS\cms\modules\admin\pages\ajax
|
||||
{
|
||||
/* @var Categories $containerClass */
|
||||
$containerClass = 'IPS\cms\Categories' . Request::i()->navId;
|
||||
|
||||
try
|
||||
{
|
||||
$container = $containerClass::load( Request::i()->container );
|
||||
$items = [];
|
||||
foreach( $container->getContentItems( null, null ) as $item )
|
||||
{
|
||||
/* Only show items that we can actually see, and if they're not pending deletion */
|
||||
/* @var Records $item */
|
||||
if( $item->canView() and $item->hidden() !== -2 )
|
||||
{
|
||||
$items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
/* @var Records $itemClass */
|
||||
$itemClass = $containerClass::$contentItemClass;
|
||||
|
||||
$sort = ( $container::database()->field_sort ? $itemClass::$databaseTable . '.' . $itemClass::$databasePrefix . $container::database()->field_sort : 'record_last_comment' ) . ' ' . ( $container::database()->field_direction ?? 'desc' );
|
||||
|
||||
$items = iterator_to_array(
|
||||
$itemClass::getItemsWithPermission( [
|
||||
[ $itemClass::$databaseTable . '.category_id=?', $container->_id ]
|
||||
], $sort, null )
|
||||
);
|
||||
|
||||
Output::i()->sendOutput( Theme::i()->getTemplate( 'widgets', 'cms', 'front' )->databaseNavigationItems( $items ) );
|
||||
}
|
||||
|
||||
@@ -168,15 +168,7 @@ class builder extends widgets
|
||||
try
|
||||
{
|
||||
$block = Block::load( Request::i()->id );
|
||||
|
||||
try
|
||||
{
|
||||
$widget = $block->widget();
|
||||
}
|
||||
catch ( OutOfRangeException )
|
||||
{
|
||||
$widget = new Blocks( "", ['cms_widget_custom_block' => $block->key] );
|
||||
}
|
||||
$widget = new Blocks( "", ['cms_widget_custom_block' => $block->key] );
|
||||
Output::i()->json( [ "content" => (string) $widget, "configuration" => $widget->dataAttributes(), 'block_key' => $block->key ], 200 );
|
||||
}
|
||||
catch ( UnderFlowException|OutOfRangeException $e )
|
||||
|
||||
@@ -13,8 +13,10 @@ namespace IPS\cms\modules\front\pages;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use IPS\Member;
|
||||
use IPS\cms\Databases\Dispatcher;
|
||||
use IPS\cms\Pages\Page as PageClass;
|
||||
use IPS\cms\Pages\Revision;
|
||||
use IPS\Dispatcher\Controller;
|
||||
use IPS\Http\Url;
|
||||
use IPS\IPS;
|
||||
@@ -46,9 +48,32 @@ class page extends Controller
|
||||
*/
|
||||
public function manage() : void
|
||||
{
|
||||
Output::i()->bodyAttributes['contentClass'] = PageClass::class;
|
||||
$this->view();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws Exception
|
||||
*/
|
||||
public function storeRevision(): void
|
||||
{
|
||||
if( ! Member::loggedIn()->modPermission('can_manage_sidebar') )
|
||||
{
|
||||
Output::i()->error( 'content_err_page_403', '2T187/5', 403 );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$page = static::getPage();
|
||||
Revision::store( $page, true );
|
||||
Output::i()->json( [ 'result' => 'ok' ] );
|
||||
}
|
||||
catch( OutOfRangeException $e )
|
||||
{
|
||||
Output::i()->error( 'content_err_page_404', '2T187/6', 404 );
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Display a page. Sounds simple doesn't it? Well it's not.
|
||||
*
|
||||
@@ -57,6 +82,11 @@ class page extends Controller
|
||||
protected function view() : void
|
||||
{
|
||||
$page = $this::getPage();
|
||||
|
||||
if( isset( Request::i()->version ) and Member::loggedIn()->modPermission('can_manage_sidebar') )
|
||||
{
|
||||
$page->setVersion( Request::i()->version );
|
||||
}
|
||||
|
||||
/* Database specific checks */
|
||||
if ( isset( Request::i()->advancedSearchForm ) AND isset( Request::i()->d ) )
|
||||
@@ -150,7 +180,7 @@ class page extends Controller
|
||||
else if ( isset( Request::i()->path ) AND Request::i()->path != '/' )
|
||||
{
|
||||
/* Sort out pagination for pages */
|
||||
list( $path, $pageNumber ) = PageClass::getStrippedPagePath( Request::i()->path );
|
||||
[ $path, $pageNumber ] = PageClass::getStrippedPagePath( Request::i()->path );
|
||||
if( $pageNumber AND !Request::i()->page )
|
||||
{
|
||||
Request::i()->page = $pageNumber;
|
||||
@@ -183,7 +213,7 @@ class page extends Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
$page = PageClass::getDefaultPage();
|
||||
$page = PageClass::getDefaultForMember();
|
||||
}
|
||||
catch ( OutOfRangeException $e )
|
||||
{
|
||||
@@ -211,6 +241,48 @@ class page extends Controller
|
||||
|
||||
return $page;
|
||||
}
|
||||
|
||||
/**
|
||||
* Revert a page to a specific version
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function revertToVersion() : void
|
||||
{
|
||||
Request::i()->confirmedDelete();
|
||||
|
||||
if( !\IPS\Dispatcher::i()->application->canManageWidgets() )
|
||||
{
|
||||
Output::i()->error( 'content_err_page_403', '2T187/8', 403 );
|
||||
}
|
||||
|
||||
$page = static::getPage();
|
||||
|
||||
$version = null;
|
||||
if( isset( Request::i()->version ) )
|
||||
{
|
||||
try
|
||||
{
|
||||
$version = Revision::load( Request::i()->version );
|
||||
}
|
||||
catch( OutOfRangeException )
|
||||
{
|
||||
Output::i()->error( 'content_err_page_404', '2T187/6', 404 );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$version = Revision::previousVersion( $page );
|
||||
if( $version === null )
|
||||
{
|
||||
Output::i()->error( 'content_err_page_404', '2T187/7', 404 );
|
||||
}
|
||||
}
|
||||
|
||||
$version->revert();
|
||||
|
||||
Output::i()->redirect( $page->url() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture database specific things
|
||||
|
||||
Reference in new issue
Block a user