Version 5.0.13
This commit is contained in:
1 parent
b89858b2ff
commit
5efe744c5f
1407 files changed
+69690
-30177
No files matched your search
@@ -41,6 +41,7 @@ use OutOfRangeException;
|
||||
use function defined;
|
||||
use function in_array;
|
||||
use const IPS\Helpers\Table\SEARCH_NODE;
|
||||
use const IPS\Helpers\Table\SEARCH_NUMERIC_TEXT;
|
||||
use const IPS\Helpers\Table\SEARCH_SELECT;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
@@ -139,18 +140,13 @@ class records extends Controller
|
||||
Member::loggedIn()->language()->words['content_db_table_field_' . $database->field_title ] = Member::loggedIn()->language()->addToStack( 'content_db_table_title' );
|
||||
|
||||
$table->advancedSearch = array(
|
||||
'category_id' => array( SEARCH_NODE, array(
|
||||
'category_id' => [SEARCH_NODE, [
|
||||
'class' => '\IPS\cms\Categories' . $database->id,
|
||||
'disabled' => false,
|
||||
'zeroVal' => 'content_db_table_as_no_cat'
|
||||
),
|
||||
),
|
||||
'record_comments'=> array( SEARCH_SELECT, array( 'options' => array(
|
||||
'null' => 'content_db_table_as_comments_null',
|
||||
1 => 'content_db_table_as_comments_yes',
|
||||
2 => 'content_db_table_as_comments_no'
|
||||
)
|
||||
) ),
|
||||
],
|
||||
],
|
||||
'record_comments'=> [SEARCH_NUMERIC_TEXT, [] ],
|
||||
);
|
||||
|
||||
/* Buttons */
|
||||
|
||||
@@ -14,16 +14,21 @@ namespace IPS\cms\modules\admin\pages;
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
|
||||
use DomainException;
|
||||
use IPS\cms\Pages\Folder;
|
||||
use IPS\cms\Pages\Page;
|
||||
use IPS\Data\Store;
|
||||
use IPS\DateTime;
|
||||
use IPS\Db;
|
||||
use IPS\Dispatcher;
|
||||
use IPS\Helpers\Form;
|
||||
use IPS\Helpers\Form\CheckboxSet;
|
||||
use IPS\Helpers\Form\Radio;
|
||||
use IPS\Helpers\Table\Db as TableDb;
|
||||
use IPS\Helpers\Tree\Tree;
|
||||
use IPS\Http\Url;
|
||||
use IPS\Member;
|
||||
use IPS\Member\Group;
|
||||
use IPS\Node\Controller;
|
||||
use IPS\Node\Model;
|
||||
use IPS\Output;
|
||||
@@ -36,6 +41,7 @@ use UnderflowException;
|
||||
use function count;
|
||||
use function defined;
|
||||
use function strpos;
|
||||
use const IPS\REBUILD_QUICK;
|
||||
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
@@ -260,7 +266,7 @@ FILE;
|
||||
protected function form() : void
|
||||
{
|
||||
/* If this is a database page, redirect to database form */
|
||||
if( isset( static::$pageToDatabaseMap[ Request::i()->id ] ) )
|
||||
if( isset( static::$pageToDatabaseMap[ Request::i()->id ] ) and isset( Request::i()->subnode ) and Request::i()->subnode )
|
||||
{
|
||||
Output::i()->redirect( Url::internal( "app=cms&module=databases&controller=databases&do=form&id=" . static::$pageToDatabaseMap[ Request::i()->id ] ) );
|
||||
}
|
||||
@@ -317,9 +323,77 @@ FILE;
|
||||
*/
|
||||
protected function setAsDefault() : void
|
||||
{
|
||||
Session::i()->csrfCheck();
|
||||
Page::load( Request::i()->id )->setAsDefault();
|
||||
Output::i()->redirect( Url::internal( "app=cms&module=pages&controller=pages" ), 'saved' );
|
||||
$page = Page::load( Request::i()->id );
|
||||
|
||||
$defaults = Page::loadDefaultsPerGroup()[ $page->folder_id ] ?? [];
|
||||
$options = [];
|
||||
$selected = [];
|
||||
$descriptions = [];
|
||||
foreach( Group::groups() as $group )
|
||||
{
|
||||
$options[ $group->g_id ] = $group->name;
|
||||
if( isset( $defaults[ $group->g_id ] ) )
|
||||
{
|
||||
if( $defaults[ $group->g_id ] == $page->id )
|
||||
{
|
||||
$selected[] = $group->g_id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$descriptions[ $group->g_id ] = Page::load( $defaults[ $group->g_id ] )->seo_name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$form = new Form;
|
||||
$form->addMessage( 'set_page_default_info', 'info' );
|
||||
$form->add( new Form\YesNo( 'set_page_default', $page->default == Page::PAGE_DEFAULT, false, [
|
||||
'togglesOff' => [ 'set_group_defaults' ]
|
||||
] ) );
|
||||
$form->add( new CheckboxSet( 'set_group_defaults', $selected, false, [
|
||||
'options' => $options,
|
||||
'descriptions' => $descriptions,
|
||||
'noDefault' => true
|
||||
], function( $val ) use ( $page, $defaults ) {
|
||||
/* If this was the default page, make sure we don't leave any groups stranded! */
|
||||
if( $page->default == Page::PAGE_DEFAULT )
|
||||
{
|
||||
foreach( $defaults as $groupId => $groupPage )
|
||||
{
|
||||
try
|
||||
{
|
||||
$group = Group::load( $groupId );
|
||||
}
|
||||
catch( OutOfRangeException )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if( $groupPage == $page->id and !in_array( $groupId, $val ) )
|
||||
{
|
||||
throw new DomainException( Member::loggedIn()->language()->addToStack( 'err__no_page_default', true, [ 'sprintf' => [ $group->name ] ] ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}, id: 'set_group_defaults' ) );
|
||||
|
||||
if( $values = $form->values() )
|
||||
{
|
||||
if( $values['set_page_default'] )
|
||||
{
|
||||
$page->setAsDefault();
|
||||
}
|
||||
else
|
||||
{
|
||||
$page->setAsDefaultForGroups( $values['set_group_defaults'] );
|
||||
}
|
||||
|
||||
Session::i()->log( 'acplogs__cms_page_set_default', [ 'cms_page_' . $page->id => TRUE, $page->parent()?->_title ?? 'root' => FALSE ] );
|
||||
|
||||
Output::i()->redirect( Url::internal( "app=cms&module=pages&controller=pages" ), 'saved' );
|
||||
}
|
||||
|
||||
Output::i()->output = (string) $form;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -334,6 +408,84 @@ FILE;
|
||||
Output::i()->redirect( Url::internal( "app=cms&module=pages&controller=pages" ), 'saved' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all page history
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function history() : void
|
||||
{
|
||||
try
|
||||
{
|
||||
if( !isset( Request::i()->subnode ) or !Request::i()->subnode )
|
||||
{
|
||||
throw new OutOfRangeException;
|
||||
}
|
||||
|
||||
$page = Page::load( Request::i()->id );
|
||||
}
|
||||
catch( OutOfRangeException )
|
||||
{
|
||||
Output::i()->error( 'node_error', '3T260/2', 404 );
|
||||
}
|
||||
|
||||
$table = new TableDb( 'cms_page_revisions', $this->url->setQueryString( [ 'id' => $page->id, 'do' => 'history', 'subnode' => Request::i()->subnode ] ), [ [ 'revision_page_id=?', $page->id ] ] );
|
||||
$table->joins[] = [ 'from' => 'core_members', 'where' => 'revision_member_id=member_id' ];
|
||||
$table->sortBy = $table->sortBy ?: 'revision_date';
|
||||
$table->sortDirection = $table->sortDirection ?: 'desc';
|
||||
$table->include = [ 'revision_date', 'revision_member_id' ];
|
||||
$table->noSort = [ 'revision_member_id' ];
|
||||
|
||||
/* Filters */
|
||||
$table->filters = [
|
||||
'revision_page_manual' => [ '( revision_manual_save=1 )' ]
|
||||
];
|
||||
|
||||
try
|
||||
{
|
||||
$previousManualSave = Db::i()->select( 'revision_id', 'cms_page_revisions', [ 'revision_page_id=? AND revision_manual_save=1', $page->id ], 'revision_id DESC', [ 1,1 ] )->first();
|
||||
|
||||
if ( $previousManualSave > 0 )
|
||||
{
|
||||
$table->filters['revision_page_last_session'] = ['( revision_id > ' . $previousManualSave . ' )'];
|
||||
}
|
||||
}
|
||||
catch( UnderflowException $e )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
$table->parsers = [
|
||||
'revision_date' => function( $val, $row )
|
||||
{
|
||||
return Theme::i()->getTemplate( 'pages', 'cms', 'admin' )->revisionDate( DateTime::ts( $val ), $row['revision_manual_save'] );
|
||||
},
|
||||
'revision_member_id' => function( $val, $row )
|
||||
{
|
||||
$member = Member::constructFromData( $row );
|
||||
return Theme::i()->getTemplate( 'global', 'core' )->userLink( $member );
|
||||
}
|
||||
];
|
||||
|
||||
$table->rowButtons = function( $row ) use ( $page )
|
||||
{
|
||||
return [
|
||||
'view' => [
|
||||
'icon' => 'search',
|
||||
'title' => 'view_page_revision',
|
||||
'link' => $page->url()->setQueryString( 'version', $row['revision_id'] ),
|
||||
'target' => '_blank'
|
||||
]
|
||||
];
|
||||
};
|
||||
|
||||
Output::i()->title = $page->_title;
|
||||
Output::i()->breadcrumb[] = [ $this->url, Member::loggedIn()->language()->addToStack( 'menu__cms_pages_pages' ) ];
|
||||
Output::i()->breadcrumb[] = [ Url::internal('app=cms&module=pages&controller=pages&do=form&subnode=' . Request::i()->subnode . '&id=' . $page->_id ), $page->_title ];
|
||||
Output::i()->breadcrumb[] = [ null, Member::loggedIn()->language()->addToStack( 'content_page_history' ) ];
|
||||
Output::i()->output = (string) $table;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tree Search
|
||||
*
|
||||
@@ -380,7 +532,21 @@ FILE;
|
||||
'sprintf' => array( Url::internal( "app=cms&module=databases&controller=databases&do=form&id=" . static::$pageToDatabaseMap[ $page->id ] ) )
|
||||
) );
|
||||
}
|
||||
return Theme::i()->getTemplate( 'trees', 'core' )->row( $url, $page->id, $page->seo_name, false, $page->getButtons( Url::internal('app=cms&module=pages&controller=pages'), true ), Member::loggedIn()->language()->addToStack( 'num_views_with_number', NULL, array( 'pluralize' => array( $page->views ) ) ), 'file-text-o', NULL, FALSE, NULL, NULL, $badge, FALSE, FALSE, FALSE );
|
||||
|
||||
$names = [];
|
||||
if( $page->default == Page::PAGE_DEFAULT_OVERRIDE and !empty( $page->group_defaults ) )
|
||||
{
|
||||
foreach( explode( ",", $page->group_defaults ) as $groupId )
|
||||
{
|
||||
try
|
||||
{
|
||||
$names[] = Group::load( $groupId )->name;
|
||||
}
|
||||
catch( OutOfRangeException ){}
|
||||
}
|
||||
}
|
||||
|
||||
return Theme::i()->getTemplate( 'trees', 'core' )->row( $url, $page->id, $page->seo_name, false, $page->getButtons( Url::internal('app=cms&module=pages&controller=pages'), true ), Member::loggedIn()->language()->addToStack( 'num_views_with_number', NULL, array( 'pluralize' => array( $page->views ) ) ), 'file-text-o', NULL, FALSE, NULL, NULL, $badge, FALSE, FALSE, FALSE, true, Theme::i()->getTemplate( 'pages' )->pageRowHtml( $page, implode( ", ", $names ) ) );
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ class templates extends Controller
|
||||
];
|
||||
foreach( Databases::$templateGroups as $key => $group )
|
||||
{
|
||||
$groups[ $key ] = Member::loggedIn()->language()->addToStack( 'cms_new_db_template_group_' . $key );
|
||||
$groups[ $group ] = Member::loggedIn()->language()->addToStack( 'cms_new_db_template_group_' . $key );
|
||||
}
|
||||
|
||||
/* Build a list of all custom directories */
|
||||
@@ -623,7 +623,7 @@ class templates extends Controller
|
||||
|
||||
try
|
||||
{
|
||||
$count = Db::i()->select( 'COUNT(*)', 'cms_templates', array( "LOWER(template_title)=?", mb_strtolower( str_replace( ' ', '_', $val ) ) ) )->first();
|
||||
$count = Db::i()->select( 'COUNT(*)', 'cms_templates', array( "LOWER(template_group)=?", mb_strtolower( str_replace( ' ', '_', $val ) ) ) )->first();
|
||||
|
||||
if ( $count )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user