Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -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