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

@@ -2,9 +2,10 @@
/**
* @brief Fields Model
* @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 8 April 2014
* @version SVN_VERSION_NUMBER
*/
@@ -45,7 +46,7 @@ class _categories extends \IPS\Node\Controller
$nodeClass = $this->nodeClass;
$childLang = \IPS\Member::loggedIn()->language()->addToStack( $nodeClass::$nodeTitle . '_add_child' );
$nodeClass::$nodeTitle = \IPS\Member::loggedIn()->language()->addToStack('content_cat_db_title', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( \IPS\Request::i()->database_id)->_title ) ) );
$nodeClass::$nodeTitle = \IPS\Member::loggedIn()->language()->addToStack('content_cat_db_title', FALSE, array( 'sprintf' => array( \IPS\cms\Databases::load( \IPS\Request::i()->database_id )->_title ) ) );
\IPS\Member::loggedIn()->language()->words[ $nodeClass::$nodeTitle . '_add_child' ] = $childLang;
parent::execute();
}
@@ -70,4 +71,26 @@ class _categories extends \IPS\Node\Controller
return $rows;
}
/**
* Function to execute after nodes are reordered. Do nothing by default but plugins can extend.
*
* @param array $order The new ordering that was saved
* @return void
* @note Pages needs to readjust category_full_path values when a category is moved to a different category
*/
protected function _afterReorder( $order )
{
$categoryClass = $this->nodeClass;
foreach( $order as $parent => $nodes )
{
foreach ( $nodes as $id => $position )
{
$categoryClass::resetPath( $id );
}
}
return parent::_afterReorder( $order );
}
}
@@ -2,9 +2,10 @@
/**
* @brief Databases Model
* @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 31 March 2014
* @version SVN_VERSION_NUMBER
*/
@@ -176,7 +177,7 @@ class _databases extends \IPS\Node\Controller
);
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'fields', 'fields_manage' ) )
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'fields', 'cms_fields_manage' ) )
{
$return['fields'] = array(
'title' => 'content_database_manage_fields',
@@ -204,7 +205,7 @@ class _databases extends \IPS\Node\Controller
'title' => 'delete',
'icon' => 'times-circle',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=delete&id=' . $row['database_id'] ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('delete') )
'data' => array( 'delete' => '' )
);
}
@@ -242,7 +243,7 @@ class _databases extends \IPS\Node\Controller
move_uploaded_file( $values['cms_database_import'], $tempFile );
/* Initate a redirector */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=import&file=' . urlencode( $tempFile ) . '&key=' . md5_file( $tempFile ) ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=import' )->setQueryString( array( 'file' => $tempFile, 'key' => md5_file( $tempFile ) ) ) );
}
else
{
@@ -266,15 +267,16 @@ class _databases extends \IPS\Node\Controller
}
\IPS\Output::i()->output = new \IPS\Helpers\MultipleRedirect(
\IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=import&file=' . urlencode( \IPS\Request::i()->file ) . '&key=' . \IPS\Request::i()->key ),
\IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=import' )->setQueryString( array( 'file' => \IPS\Request::i()->file, 'key' => \IPS\Request::i()->key ) ),
function( $data )
{
/* Open XML file */
$xml = new \XMLReader;
$xml = new \IPS\Xml\XMLReader;
$xml->open( \IPS\Request::i()->file );
if ( ! @$xml->read() )
{
@unlink( \IPS\Request::i()->file );
\IPS\Output::i()->error( 'xml_upload_invalid', '2C163/1', 403, '' );
}
@@ -371,8 +373,8 @@ class _databases extends \IPS\Node\Controller
\IPS\Lang::saveCustom( 'cms', "content_db_" . $database->id, $name );
\IPS\Lang::saveCustom( 'cms', "content_db_" . $database->id . '_desc', $desc );
\IPS\Lang::saveCustom( 'cms', "digest_area_records" . $database->id, $langs['content_db_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_categories" . $database->id, $langs['content_db_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_cms_records" . $database->id, $langs['content_db_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_cms_categories" . $database->id, $langs['content_db_lang_pu'] );
$menu = array();
@@ -420,29 +422,36 @@ class _databases extends \IPS\Node\Controller
$xml->read();
$next = NULL;
$areas = array( 'field', 'category', 'template' );
if ( $data['next'] )
{
while ( $xml->read() )
{
if( ! in_array( $xml->name, $areas ) OR $xml->nodeType != \XMLReader::ELEMENT )
{
continue;
}
$i++;
if ( $data['done'] )
{
if ( $i - 1 < $data['done'] )
{
$xml->next();
continue;
}
}
$doneSomething = false;
if ( $xml->name == $data['next'] )
{
$i++;
if ( $data['done'] )
{
if ( $i - 1 < $data['done'] )
{
$xml->next();
continue;
}
}
$data['done']++;
$areaName = $xml->name;
$node = new \SimpleXMLElement( $xml->readOuterXML() );
/* Import */
switch ( $areaName )
{
@@ -481,6 +490,8 @@ class _databases extends \IPS\Node\Controller
$attrs[ $k ] = ( $tryJson ) ? $tryJson : (string) $v;
}
$attrs['_skip_formatting'] = TRUE;
$originalFieldId = $attrs['field_id'];
unset( $attrs['field_id'] );
@@ -529,6 +540,7 @@ class _databases extends \IPS\Node\Controller
\IPS\Lang::saveCustom( 'cms', "content_field_" . $obj->id . '_validation_error', $attrs['field_validator_error'] );
}
$next = 'category';
$doneSomething = true;
break;
case 'category':
@@ -603,6 +615,7 @@ class _databases extends \IPS\Node\Controller
\IPS\Db::i()->update( 'core_permission_index', array_merge( $perms, array( 'perm_id' => $existingPerms['perm_id'], 'perm_type_id' => $category->id ) ), array( 'perm_id=?', $existingPerms['perm_id'] ) );
$next = 'template';
$doneSomething = true;
break;
case 'template':
@@ -621,84 +634,44 @@ class _databases extends \IPS\Node\Controller
$attrs[ $k ] = ( $tryJson ) ? $tryJson : (string) $v;
}
$add = FALSE;
$updateDb = FALSE;
if ( isset( $attrs['template_title'] ) and isset( $attrs['template_location'] ) and isset( $attrs['template_group'] ) )
$obj = new \IPS\cms\Templates;
$obj->location = $attrs['template_location'];
$obj->group = $attrs['template_group'];
$obj->title = $attrs['template_title'];
$obj->params = $attrs['template_params'];
$obj->content = $attrs['template_content'];
$obj->original_group = $attrs['template_original_group'];
$obj->user_created = 1;
$obj->user_edited = 1;
$obj->desc = '';
if ( $attrs['template_group'] !== 'template_form' )
{
/* Got this template? */
if ( isset( $templates['cms']['database'][ $attrs['template_location'] ][ $attrs['template_group'] ] ) )
$obj->group .= '_' . $database->id;
foreach( array( 'template_listing', 'template_display', 'template_categories', 'template_form', 'template_featured' ) as $name )
{
/* Compare with version stored in DB and don't bother importing unless we need to */
if ( $templates['cms']['database'][ $attrs['template_location'] ][ $attrs['template_group'] ]['template_content'] != $attrs['template_content'] )
if ( $database->$name == $attrs['template_group'] )
{
$updateDb = TRUE;
$add = TRUE;
}
}
else
{
$add = TRUE;
$updateDb = TRUE;
}
if ( $add )
{
$obj = new \IPS\cms\Templates;
$obj->location = $attrs['template_location'];
$obj->group = $attrs['template_group'];
$obj->title = $attrs['template_title'];
$obj->params = $attrs['template_params'];
$obj->content = $attrs['template_content'];
$obj->original_group = $attrs['template_original_group'];
$obj->user_created = 1;
$obj->user_edited = 1;
$obj->desc = '';
$obj->save();
$obj->key = 'database_' . \IPS\Http\Url::seoTitle( $obj->group ) . '_' . \IPS\Http\Url::seoTitle( $obj->title ) . '_' . $obj->id;
$obj->save();
$templateArea = NULL;
if ( $updateDb )
{
if ( $obj->group !== 'template_form' )
{
foreach( array( 'template_listing', 'template_display', 'template_categories', 'template_form', 'template_featured' ) as $name )
{
if ( $database->$name == $obj->group )
{
$templateArea = $name;
}
}
if ( $templateArea )
{
/* Template group has same name as existing */
$obj->group .= '_' . $database->_id;
$obj->save();
$database->$templateArea = $obj->group;
$database->save();
}
}
else if ( $database->template_form === $obj->title )
{
$templateArea = $obj->title;
if ( $templateArea )
{
/* Template group has same name as existing */
$obj->title .= '_' . $database->_id;
$obj->save();
$database->$templateArea = $obj->title;
$database->save();
}
}
$database->$name = $obj->group;
$database->save();
}
}
}
else
{
$obj->title .= '_' . $database->_id;
$database->template_form = $obj->title;
$database->save();
}
$obj->save();
$obj->key = 'database_' . \IPS\Http\Url\Friendly::seoTitle( $obj->group ) . '_' . \IPS\Http\Url\Friendly::seoTitle( $obj->title ) . '_' . $obj->id;
$obj->save();
$doneSomething = true;
$next = NULL;
break;
}
@@ -712,13 +685,35 @@ class _databases extends \IPS\Node\Controller
}
else
{
/* Did we do anything? if not, skip to the next section */
if ( ! $doneSomething )
{
switch ( $data['next'] )
{
case 'field':
$data['next'] = 'category';
break;
case 'category':
$data['next'] = 'template';
break;
case 'template':
$data['next'] = null;
break;
}
if ( $data['next'] )
{
return array( $data, \IPS\Member::loggedIn()->language()->addToStack('cms_db_import_progress', FALSE, array( 'sprintf' => array( \ucfirst( $data['next'] ) ) ) ) );
}
}
$xml->next();
}
}
/* Done */
$data['next'] = $next;
$data['done'] = 0;
return array( $data, \IPS\Member::loggedIn()->language()->addToStack('cms_db_import_progress', FALSE, array( 'sprintf' => array( \ucfirst( $data['next'] ) ) ) ) );
}
else
@@ -752,7 +747,16 @@ class _databases extends \IPS\Node\Controller
$databaseId = \IPS\Data\Store::i()->db_import_db_id;
unset( \IPS\Data\Store::i()->db_import_db_id );
$database = \IPS\cms\Databases::load( $databaseId );
foreach( array( 'template_listing', 'template_display', 'template_categories', 'template_form', 'template_featured' ) as $name )
{
\IPS\cms\Templates::fixTemplateTags( $database->$name );
}
@unlink( \IPS\Request::i()->file );
/* Done */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=permissions&id=' . $databaseId ) );
}
@@ -784,6 +788,9 @@ class _databases extends \IPS\Node\Controller
}
else
{
/* We need to know the database schema to prevent non-standard columns from add-ons being added to the XML (which then causes the import to fail) */
$schema = json_decode( \file_get_contents( \IPS\ROOT_PATH . '/applications/cms/data/schema.json' ), TRUE );
/* Init */
$xml = new \XMLWriter;
$xml->openMemory();
@@ -857,8 +864,9 @@ class _databases extends \IPS\Node\Controller
$xml->endElement();
/* Custom fields */
$textFields = array( 'field_extra', 'field_default_value', 'field_name', 'field_description', 'field_display_json', 'field_validator_error' );
$removeFields = array( 'field_database_id' );
$textFields = array( 'field_extra', 'field_default_value', 'field_name', 'field_description', 'field_display_json', 'field_validator_error' );
$removeFields = array( 'field_database_id' );
$fieldSchema = $schema['cms_database_fields'];
foreach ( \IPS\Db::i()->select( 'f.*, w.word_custom as field_name, w2.word_custom as field_description, w3.word_custom as field_validator_error, p.*', array('cms_database_fields', 'f'), array( 'field_database_id=?', $database->id ) )
->join( array( 'core_sys_lang_words', 'w' ), "w.word_key=CONCAT( 'content_field_', f.field_id ) and w.lang_id=" . \IPS\Lang::defaultLanguage() )
->join( array( 'core_sys_lang_words', 'w2' ), "w2.word_key=CONCAT( 'content_field_', f.field_id, '_desc' ) and w2.lang_id=" . \IPS\Lang::defaultLanguage() )
@@ -871,7 +879,7 @@ class _databases extends \IPS\Node\Controller
foreach( $row as $k => $v )
{
if ( ! in_array( $k, $removeFields ) AND ! in_array( $k, $textFields ) )
if ( array_key_exists( $k, $fieldSchema['columns'] ) AND ! in_array( $k, $removeFields ) AND ! in_array( $k, $textFields ) )
{
$xml->startAttribute( $k );
$xml->text( $v );
@@ -906,6 +914,7 @@ class _databases extends \IPS\Node\Controller
$removeFields = array( 'category_database_id', 'category_last_record_id', 'category_last_record_date', 'category_last_record_member', 'category_last_record_name', 'category_last_record_seo_name', 'category_records', 'category_record_comments',
'category_record_comments_queued', 'category_rss_cache', 'category_rss_cached', 'category_rss_exclude', 'category_forum_override', 'category_forum_record', 'category_forum_comments', 'category_forum_delete', 'category_forum_suffix', 'category_forum_prefix',
'category_forum_forum', 'category_full_path', 'category_last_title', 'category_last_seo_title');
$categorySchema = $schema['cms_database_categories'];
foreach ( \IPS\Db::i()->select( 'c.*, w.word_custom as category_name, w2.word_custom as category_description, p.*', array('cms_database_categories', 'c'), array( 'category_database_id=?', $database->id ) )
->join( array( 'core_sys_lang_words', 'w' ), "w.word_key=CONCAT( 'content_cat_name_', c.category_id ) and w.lang_id=" . \IPS\Lang::defaultLanguage() )
->join( array( 'core_sys_lang_words', 'w2' ), "w2.word_key=CONCAT( 'content_cat_name_', c.category_id, '_desc' ) and w2.lang_id=" . \IPS\Lang::defaultLanguage() )
@@ -917,7 +926,7 @@ class _databases extends \IPS\Node\Controller
foreach( $row as $k => $v )
{
if ( ! in_array( $k, $removeFields ) AND ! in_array( $k, $textFields ) )
if ( array_key_exists( $k, $categorySchema['columns'] ) AND ! in_array( $k, $removeFields ) AND ! in_array( $k, $textFields ) )
{
$xml->startAttribute( $k );
$xml->text( $v );
@@ -1035,6 +1044,10 @@ class _databases extends \IPS\Node\Controller
{
\IPS\Dispatcher::i()->checkAcpPermission( 'databases_delete' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
/* Load the database */
try
{
$database = \IPS\cms\Databases::load( \IPS\Request::i()->id );
@@ -1043,27 +1056,16 @@ class _databases extends \IPS\Node\Controller
{
\IPS\Output::i()->error( 'cms_database_not_exist', '3T259/2', 403, '' );
}
$form = new \IPS\Helpers\Form( 'form', 'delete' );
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack('content_delete_db_confirm'), 'ipsMessage ipsMessage_warning' );
$form->add( new \IPS\Helpers\Form\YesNo( 'content_delete_db', 0, FALSE, array(), NULL, NULL, NULL, 'content_delete_db' ) );
if ( $values = $form->values() )
{
if ( $values['content_delete_db'] == 1 )
{
\IPS\Session::i()->log( 'acplogs__cms_deleted_database', array( 'content_db_' . $database->id => TRUE ) );
$database->delete();
/* Delete the database and clear the 'create' menu cache */
$database->delete();
\IPS\Member::clearCreateMenu();
\IPS\Member::clearCreateMenu();
}
/* Log the deletion */
\IPS\Session::i()->log( 'acplogs__cms_deleted_database', array( 'content_db_' . $database->id => TRUE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases' ), 'deleted' );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'delete', $form, FALSE );
/* Send the user back to the list */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases' ), 'deleted' );
}
/**
@@ -1104,6 +1106,24 @@ class _databases extends \IPS\Node\Controller
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cms_pages_settings');
}
/**
* Resynchronise topic content dialog
*
* @return void
*/
public function rebuildTopicContent()
{
if ( isset( \IPS\Request::i()->process ) )
{
\IPS\Task::queue( 'cms', 'ResyncTopicContent', array( 'databaseId' => \IPS\Request::i()->id ), 3, array( 'databaseId' ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=form&id=' . \IPS\Request::i()->id ), 'database_rebuild_added' );
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'databases', 'cms', 'admin' )->rebuildTopics( \IPS\Request::i()->id );
}
}
/**
* Add/Edit
*
@@ -1135,7 +1155,13 @@ class _databases extends \IPS\Node\Controller
'key' => ( $current ? "content_db_" . $current->id . "_desc" : NULL ),
'textArea' => true
) ) );
$disabled = FALSE;
if ( $current and $current->use_categories and $current->numberOfCategories() > 1 )
{
$disabled = TRUE;
}
$form->add( new \IPS\Helpers\Form\Radio( 'database_use_categories' , $current ? $current->use_categories : 1, FALSE, array(
'options' => array(
1 => 'database_use_categories_yes',
@@ -1143,11 +1169,27 @@ class _databases extends \IPS\Node\Controller
),
'toggles' => array(
1 => array( 'database_template_categories' ),
0 => array( 'category_allow_rating' )
0 => array( 'category_allow_rating', 'category_can_view_others' )
),
'disabled' => $disabled
) ) );
if ( $disabled === TRUE )
{
$form->hiddenValues['database_use_categories_impossible'] = TRUE;
\IPS\Member::loggedIn()->language()->words['database_use_categories_warning'] = \IPS\Member::loggedIn()->language()->addToStack( 'database_use_categories_impossible', NULL, array( 'sprintf' => array( $current->numberOfCategories() ) ) );
}
$form->add( new \IPS\Helpers\Form\Radio( 'database_use_as_page_title' , $current ? $current->use_as_page_title : 1, FALSE, array(
'options' => array(
1 => 'database_use_as_page_title_yes',
0 => 'database_use_as_page_title_no'
)
) ) );
\IPS\Member::loggedIn()->language()->words['category_can_view_others_desc'] = \IPS\Member::loggedIn()->language()->addToStack('category_can_view_others_database_desc');
$form->add( new \IPS\Helpers\Form\YesNo( 'category_allow_rating', ( $category !== NULL and $category->allow_rating ) ? TRUE : FALSE, FALSE, array(), NULL, NULL, NULL, 'category_allow_rating' ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'category_can_view_others', ( $category !== NULL ) ? $category->can_view_others : TRUE, FALSE, array(), NULL, NULL, NULL, 'category_can_view_others' ) );
$templatesCat = NULL;
$templatesList = NULL;
@@ -1198,8 +1240,8 @@ class _databases extends \IPS\Node\Controller
'primary_id_field' => 'database_field__id',
'member_id' => 'database_field__member',
'record_publish_date' => 'database_field__saved',
'record_last_comment' => 'database_field__updated',
'rating_real' => 'database_field__rating'
'record_last_comment' => ( $current and $current->_comment_bump === \IPS\cms\Databases::BUMP_ON_EDIT ) ? 'database_field__edited' : 'database_field__updated',
'record_rating' => 'database_field__rating'
);
if ( $current )
@@ -1412,7 +1454,17 @@ class _databases extends \IPS\Node\Controller
{
$form->addMessage( 'cms_no_db_page_no_forum_link', 'ipsMessage ipsMessage_info' );
}
if ( $current )
{
$rebuildUrl = \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&id=' . $current->id . '&do=rebuildTopicContent' );
\IPS\Member::loggedIn()->language()->words['database_forum_record_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__desc' ) . ' ' . \IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__rebuild', NULL, array( 'sprintf' => array( $rebuildUrl ) ) );
}
else
{
\IPS\Member::loggedIn()->language()->words['database_forum_record_desc'] = \IPS\Member::loggedIn()->language()->addToStack( 'database_forum_record__desc' );
}
$form->add( new \IPS\Helpers\Form\YesNo( 'database_forum_record', $current ? $current->forum_record : FALSE, FALSE, array( 'togglesOn' => array(
'database_forum_comments',
'database_forum_forum',
@@ -1457,7 +1509,7 @@ class _databases extends \IPS\Node\Controller
if ( $name === 'page_name' )
{
/* Overwrite field */
$field = new \IPS\Helpers\Form\Text( 'page_name', FALSE, NULL, array( 'maxLength' => 64 ), function( $val )
$field = new \IPS\Helpers\Form\Translatable( 'page_name', FALSE, NULL, array( 'app' => 'cms', 'key' => NULL, 'maxLength' => 64 ), function( $val )
{
if ( empty( $val ) AND \IPS\Request::i()->database_create_page === 'new' )
{
@@ -1551,11 +1603,21 @@ class _databases extends \IPS\Node\Controller
{
if ( is_array( $values['database_name'] ) )
{
$current->key = \IPS\Http\Url::seoTitle( $values['database_name'][ key( $values['database_name'] ) ] );
$keyToUse = uniqid();
foreach( $values['database_name'] as $langId => $word )
{
if ( ! empty( $word ) )
{
$keyToUse = $word;
break;
}
}
$current->key = \IPS\Http\Url\Friendly::seoTitle( $keyToUse );
}
else
{
$current->key = \IPS\Http\Url::seoTitle( $values['database_name'] );
$current->key = \IPS\Http\Url\Friendly::seoTitle( $values['database_name'] );
}
/* Now test it */
@@ -1597,12 +1659,11 @@ class _databases extends \IPS\Node\Controller
\IPS\Lang::saveCustom( 'cms', "content_db_lang_pu_" . $current->id, $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "content_db_lang_ia_" . $current->id, $values['database_lang_ia'] );
\IPS\Lang::saveCustom( 'cms', "content_db_lang_sl_" . $current->id . '_pl', $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_records" . $current->id, $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_categories" . $current->id, $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_cms_records" . $current->id, $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "digest_area_cms_categories" . $current->id, $values['database_lang_pu'] );
$menu = array();
foreach( \IPS\Lang::languages() as $id => $lang )
foreach( \IPS\Lang::getEnabledLanguages() as $id => $lang )
{
$menu[ $lang->_id ] = \sprintf( $lang->get('cms_create_menu_records_x'), $values['database_lang_su'][ $lang->_id ], $values['database_name'][ $lang->_id ] );
}
@@ -1619,17 +1680,7 @@ class _databases extends \IPS\Node\Controller
$current->template_form = $values['database_template_form'];
$current->template_featured = $values['database_template_featured'];
$current->cat_index_type = $values['database_cat_index_type'];
/* Make sure we have a default category */
$current->default_category = $current->_default_category;
if ( ! $current->use_categories )
{
$class = '\IPS\cms\Categories' . $current->id;
$category = $class::load( $current->get__default_category() );
$category->allow_rating = $values['category_allow_rating'];
$category->save();
}
$current->use_as_page_title = $values['database_use_as_page_title'];
$current->all_editable = (int) $values['database_all_editable'];
$current->revisions = (int) $values['database_revisions'];
@@ -1721,8 +1772,21 @@ class _databases extends \IPS\Node\Controller
}
$current->fixed_field_perms = $fixedFields;
$current->use_categories = $values['database_use_categories'];
$current->save();
/* Make sure we have a default category */
$current->default_category = $current->_default_category;
if ( ! $current->use_categories )
{
$class = '\IPS\cms\Categories' . $current->id;
$category = $class::load( $current->get__default_category() );
$category->allow_rating = $values['category_allow_rating'];
$category->can_view_others = $values['category_can_view_others'];
$category->save();
}
if ( $new )
{
@@ -1743,6 +1807,7 @@ class _databases extends \IPS\Node\Controller
$pageValues['page_content'] = '{database="' . $current->id . '"}';
$pageValues['page_template'] = '';
}
$pageValues['page_folder_id'] = $pageValues['page_folder_id'] ?: 0;
$newPage = \IPS\cms\Pages\Page::createFromForm( $pageValues, 'html' );
@@ -1755,6 +1820,9 @@ class _databases extends \IPS\Node\Controller
'area_orientation' => 'horizontal'
) );
}
$current->page_id = $newPage->id;
$current->save();
}
}
else
@@ -2,9 +2,10 @@
/**
* @brief Fields Model
* @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 31 March 2014
* @version SVN_VERSION_NUMBER
*/
@@ -39,7 +40,7 @@ class _fields extends \IPS\Node\Controller
$this->nodeClass = '\IPS\cms\Fields' . \IPS\Request::i()->database_id;
\IPS\Dispatcher::i()->checkAcpPermission( 'fields_manage' );
\IPS\Dispatcher::i()->checkAcpPermission( 'cms_fields_manage' );
parent::execute();
}
@@ -50,6 +51,12 @@ class _fields extends \IPS\Node\Controller
*/
protected function manage()
{
/* If we lose the database id because of a log in, do something more useful than an uncaught exception */
if ( ! isset( \IPS\Request::i()->database_id ) )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=databases" ) );
}
parent::manage();
$url = \IPS\Http\Url::internal( "app=cms&module=databases&controller=fields&database_id=" . \IPS\Request::i()->database_id );
@@ -66,9 +73,10 @@ class _fields extends \IPS\Node\Controller
function() use ( $fixed, $url )
{
$rows = array();
foreach( $fixed as $field => $data )
{
$description = ( $field === 'record_publish_date' ) ? \IPS\Member::loggedIn()->language()->addToStack( 'content_fields_fixed_record_publish_date_desc' ) : NULL;
$rows[ $field ] = \IPS\Theme::i()->getTemplate( 'trees', 'core' )->row( $url, $field, \IPS\Member::loggedIn()->language()->addToStack( 'content_fields_fixed_'. $field ), FALSE, array(
'permission' => array(
'icon' => 'lock',
@@ -76,7 +84,7 @@ class _fields extends \IPS\Node\Controller
'link' => $url->setQueryString( array( 'field' => $field, 'do' => 'fixedPermissions' ) ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack( 'content_fields_fixed_'. $field ) )
)
), NULL, NULL, NULL, NULL, ( empty( $data['visible'] ) ? FALSE : TRUE ) );
), $description, NULL, NULL, NULL, ( empty( $data['visible'] ) ? FALSE : TRUE ) );
}
return $rows;
@@ -2,9 +2,10 @@
/**
* @brief Records Model
* @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 8 April 2014
* @version SVN_VERSION_NUMBER
*/
@@ -183,7 +184,8 @@ class _records extends \IPS\Dispatcher\Controller
try
{
$class = '\IPS\cms\Categories' . $database->id;
return $class::load( $val )->_title;
return \IPS\Theme::i()->getTemplate( 'records', 'cms', 'admin' )->category( $class::load( $val ) );
}
catch( \OutOfRangeException $e )
{
@@ -210,6 +212,13 @@ class _records extends \IPS\Dispatcher\Controller
);
}
\IPS\Output::i()->sidebar['actions']['databasepermissions'] = array(
'title' => 'cms_database_permissions',
'icon' => 'lock',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=permissions&id=' . $database->_id ),
'data' => NULL
);
/* Reset languages */
\IPS\Member::loggedIn()->language()->words[ $table->langPrefix . $database->field_title ] = \IPS\Member::loggedIn()->language()->addToStack($table->langPrefix . 'title');
@@ -226,7 +235,10 @@ class _records extends \IPS\Dispatcher\Controller
public function delete()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'records_delete' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
$recordClass = '\IPS\cms\Records' . \IPS\Request::i()->database_id;
try
@@ -270,7 +282,7 @@ class _records extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form( 'select_category', 'continue' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Node( 'category', $category, TRUE, array(
'url' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&do=select&database_id=' . \IPS\Request::i()->database_id . ( $move ) ? '&move=' . $move : '' ),
'url' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&do=select&database_id=' . \IPS\Request::i()->database_id . ( ( $move ) ? '&move=' . $move : '' ) ),
'class' => $catClass,
'multiple' => false,
'permissionCheck' => function( $node )
@@ -293,8 +305,7 @@ class _records extends \IPS\Dispatcher\Controller
{
if ( $move and $record )
{
$record->category_id = $values['category']->id;
$record->save();
$record->move( $values['category'] );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&database_id=' . \IPS\Request::i()->database_id ), 'completed' );
}
@@ -332,7 +343,7 @@ class _records extends \IPS\Dispatcher\Controller
$fieldsClass = 'IPS\cms\Fields' . \IPS\Request::i()->database_id;
$catClass = 'IPS\cms\Categories' . \IPS\Request::i()->database_id;
$container = ( $current ) ? $catClass::load( $current->category_id ) : ( isset( \IPS\Request::i()->category_id ) ? $catClass::load( \IPS\Request::i()->category_id ) : NULL );
$customFields = $fieldsClass::fields( $customValues, 'view', $container );
$customFields = $fieldsClass::fields( $customValues, 'view', $container, 0, $current );
$manuallyHandledFields = array( 'record_publish_date', 'record_expiry_date', 'record_allow_comments', 'record_comment_cutoff', 'record_meta_keywords', 'record_meta_description' );
$form = new \IPS\Helpers\Form();
@@ -452,7 +463,7 @@ class _records extends \IPS\Dispatcher\Controller
/* Other data */
$current->record_meta_keywords = $values['record_meta_keywords'];
$current->record_meta_description = $values['record_meta_description'];
$changeAuthor = FALSE;
if ( ! empty( \IPS\Request::i()->id ) )
{
@@ -469,6 +480,11 @@ class _records extends \IPS\Dispatcher\Controller
$values['record_member_id'] = \IPS\Member::loggedIn();
$changeAuthor = TRUE;
}
else if ( $values['record_author_choice'] === 'me' )
{
$values['record_member_id'] = \IPS\Member::loggedIn();
$changeAuthor = TRUE;
}
else if ( $values['record_author_choice'] === 'notme' and ! empty( $values['record_member_id'] ) )
{
$changeAuthor = TRUE;
@@ -526,4 +542,27 @@ class _records extends \IPS\Dispatcher\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( $current ? $title : 'add', $form, FALSE );
\IPS\Output::i()->title = $title;
}
/**
* Display the category tree
*
* @return void
*/
public function categoryTree()
{
$class = '\IPS\cms\Categories' . \IPS\Request::i()->database_id;
try
{
$category = $class::load( \IPS\Request::i()->id );
$parents = iterator_to_array( $category->parents() );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack('content_tree_title'), \IPS\Theme::i()->getTemplate( 'records', 'cms', 'admin' )->categoryTree( $category, $parents ), FALSE );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('content_tree_title');
}
catch( \Exception $ex )
{
}
}
}
+11 -3
View File
@@ -2,9 +2,10 @@
/**
* @brief Customization AJAX actions
* @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 07 May 2013
* @version SVN_VERSION_NUMBER
*/
@@ -83,7 +84,14 @@ class _ajax extends \IPS\Dispatcher\Controller
if ( $t_location === 'block' and $t_key === '_default_' and isset( \IPS\Request::i()->block_key ) )
{
/* Find it from the normal template system */
$plugin = \IPS\Widget::load( \IPS\Application::load( \IPS\Request::i()->block_app ), \IPS\Request::i()->block_key, uniqid() );
if ( isset( \IPS\Request::i()->block_app ) )
{
$plugin = \IPS\Widget::load( \IPS\Application::load( \IPS\Request::i()->block_app ), \IPS\Request::i()->block_key, uniqid() );
}
else
{
$plugin = \IPS\Widget::load( \IPS\Plugin::load( \IPS\Request::i()->block_plugin ), \IPS\Request::i()->block_key, uniqid() );
}
$location = $plugin->getTemplateLocation();
@@ -2,9 +2,10 @@
/**
* @brief Block 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 19 Feb 2013
* @version SVN_VERSION_NUMBER
*/
@@ -196,7 +197,7 @@ class _blocks extends \IPS\Node\Controller
$block = \IPS\cms\Blocks\Block::load( \IPS\Request::i()->id );
$embedKey = md5( $block->key . time() );
/* Output */
\IPS\Output::i()->title = "External Embed"; // @todo
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('block_embed_title');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( '', \IPS\Theme::i()->getTemplate( 'blocks', 'cms', 'admin' )->embedCode( $block, $embedKey ) );;
}
}
+12 -5
View File
@@ -2,10 +2,10 @@
/**
* @brief Pages Media Management
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2015 Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Pages
* @package IPS Community Suite
* @subpackage Content
* @since 07 Jul 2015
* @version SVN_VERSION_NUMBER
*/
@@ -207,7 +207,7 @@ class _media extends \IPS\Node\Controller
$form = new \IPS\Helpers\Form( 'form', 'upload' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Upload( 'media_filename', NULL, FALSE, array( 'allowedFileTypes' => \IPS\File::$safeFileExtensions, 'obscure' => FALSE, 'maxFileSize' => 5, 'storageExtension' => 'core_Theme', 'storageContainer' => 'pages_media', 'multiple' => true, 'minimize' => FALSE ), NULL, NULL, NULL, 'media_filename' ) );
$form->add( new \IPS\Helpers\Form\Upload( 'media_filename', NULL, FALSE, array( 'allowedFileTypes' => array_merge( \IPS\File::$safeFileExtensions, array( 'pdf' ) ), 'obscure' => FALSE, 'maxFileSize' => 5, 'storageExtension' => 'core_Theme', 'storageContainer' => 'pages_media', 'multiple' => true, 'minimize' => FALSE ), NULL, NULL, NULL, 'media_filename' ) );
if ( ! isset( \IPS\Request::i()->media_parent ) and ! \IPS\Request::i()->media_parent )
{
@@ -260,7 +260,14 @@ class _media extends \IPS\Node\Controller
$new->setFullPath( ( $parent ? \IPS\cms\Media\Folder::load( $parent )->path : '' ) );
$new->save();
/* Remove the original as we created a copy with a slightly altered filename */
try
{
$media->delete();
}
catch( \Exception $ex ) { }
$count++;
}
+34 -35
View File
@@ -2,9 +2,10 @@
/**
* @brief Pages 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 15 Jan 2013
* @version SVN_VERSION_NUMBER
*/
@@ -27,7 +28,12 @@ class _pages extends \IPS\Node\Controller
* Node Class
*/
protected $nodeClass = '\IPS\cms\Pages\Folder';
/**
* Store the database page map to prevent many queries
*/
protected static $pageToDatabaseMap = NULL;
/**
* Execute
*
@@ -77,6 +83,7 @@ class _pages extends \IPS\Node\Controller
protected function manage()
{
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=pages" );
static::$pageToDatabaseMap = iterator_to_array( \IPS\Db::i()->select( 'database_id, database_page_id', 'cms_databases', array( 'database_page_id > 0' ) )->setKeyField('database_page_id')->setValueField('database_id') );
/* Display the table */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__cms_pages_pages');
@@ -197,7 +204,7 @@ class _pages extends \IPS\Node\Controller
$page = \IPS\cms\Pages\Page::getDefaultPage();
$response = \IPS\Http\Url::external( ( \IPS\Settings::i()->htaccess_mod_rewrite ? $val . $page->full_path : $val . 'index.php?/' . $page->full_path ) )->request( 5, '1.1', FALSE )->get();
$response = \IPS\Http\Url::external( ( \IPS\Settings::i()->htaccess_mod_rewrite ? $val . $page->full_path : $val . 'index.php?/' . $page->full_path ) )->request( NULL, NULL, FALSE )->get();
if ( $response->httpResponseCode != 200 and $response->httpResponseCode != 303 and ( \IPS\Settings::i()->site_online OR $response->httpResponseCode != 503 ) )
{
@@ -247,14 +254,28 @@ class _pages extends \IPS\Node\Controller
protected function htaccess()
{
$dir = str_replace( \IPS\CP_DIRECTORY . '/index.php', '', $_SERVER['PHP_SELF'] );
$dirs = explode( '/', trim( $dir, '/' ) );
if ( count( $dirs ) )
{
array_pop( $dirs );
$dir = implode( '/', $dirs );
if ( ! $dir )
{
$dir = '/';
}
}
$path = $dir . 'index.php';
if( \strpos( $dir, ' ' ) !== FALSE )
{
$dir = '"' . $dir . '"';
$path = '"' . $path . '"';
}
$htaccess = <<<FILE
<IfModule mod_rewrite.c>
Options -MultiViews
@@ -319,7 +340,7 @@ FILE;
\IPS\cms\Pages\Page::deleteCompiled( \IPS\Request::i()->id );
}
parent::delete();
return parent::delete();
}
/**
@@ -367,7 +388,13 @@ FILE;
*/
public static function getPageRow( $page, $url )
{
return \IPS\Theme::i()->getTemplate( 'trees', 'core' )->row( $url, $page->id, $page->seo_name, false, $page->getButtons( \IPS\Http\url::internal('app=cms&module=pages&controller=pages'), true ), "", 'file-text-o', NULL, FALSE, NULL, NULL, NULL, FALSE, FALSE, FALSE );
$badge = NULL;
if ( isset( static::$pageToDatabaseMap[ $page->id ] ) )
{
$badge = array( 0 => 'style7', 1 => \IPS\Member::loggedIn()->language()->addToStack( 'page_database_display', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack('content_db_' . static::$pageToDatabaseMap[ $page->id ] ) ) ) ) );
}
return \IPS\Theme::i()->getTemplate( 'trees', 'core' )->row( $url, $page->id, $page->seo_name, false, $page->getButtons( \IPS\Http\url::internal('app=cms&module=pages&controller=pages'), true ), "", 'file-text-o', NULL, FALSE, NULL, NULL, $badge, FALSE, FALSE, FALSE );
}
/**
@@ -409,32 +436,4 @@ FILE;
return \IPS\cms\Pages\Folder::munge( $folders, $pages );
}
/**
* Redirect after save
*
* @param \IPS\Node\Model $old A clone of the node as it was before or NULL if this is a creation
* @param \IPS\Node\Model $node The node now
* @return void
*/
protected function _afterSave( \IPS\Node\Model $old = NULL, \IPS\Node\Model $new )
{
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( array() );
}
else
{
if( isset( \IPS\Request::i()->save_and_reload ) )
{
$buttons = $new->getButtons( $this->url, !( $new instanceof $this->nodeClass ) );
\IPS\Output::i()->redirect( $buttons['edit']['link'], 'saved' );
}
else
{
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $new->parent() ? $new->parent()->_id : '' ) ) ), 'saved' );
}
}
}
}
@@ -2,9 +2,10 @@
/**
* @brief Templates 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 25 Feb 2013
* @version SVN_VERSION_NUMBER
*/
@@ -67,7 +68,7 @@ class _templates extends \IPS\Dispatcher\Controller
move_uploaded_file( $values['cms_templates_import'], $tempFile );
/* Initate a redirector */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&do=importProcess&file=' . urlencode( $tempFile ) . '&key=' . md5_file( $tempFile ) ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&do=importProcess' )->setQueryString( array( 'file' => $tempFile, 'key' => md5_file( $tempFile ) ) ) );
}
else
{
@@ -87,16 +88,18 @@ class _templates extends \IPS\Dispatcher\Controller
{
if ( !file_exists( \IPS\Request::i()->file ) or md5_file( \IPS\Request::i()->file ) !== \IPS\Request::i()->key )
{
\IPS\Output::i()->error( 'generic_error', '3T259/3', 403, '' );
\IPS\Output::i()->error( 'generic_error', '3T285/3', 403, '' );
}
/* Open XML file */
$xml = new \XMLReader;
$xml = new \IPS\Xml\XMLReader;
$xml->open( \IPS\Request::i()->file );
$prefix = date('m') . '.' . date('d') . '.' . date('y') . '_';
$prefix = date('m') . '_' . date('d') . '_' . date('y') . '_';
$templates = \IPS\cms\Theme::i()->getRawTemplates( 'cms', NULL, NULL, \IPS\cms\Theme::RETURN_ALL );
if ( ! @$xml->read() )
{
@unlink( \IPS\Request::i()->file );
\IPS\Output::i()->error( 'xml_upload_invalid', '2C163/1', 403, '' );
}
$xml->read();
@@ -104,7 +107,6 @@ class _templates extends \IPS\Dispatcher\Controller
{
if ( $xml->name === 'template' )
{
$templates = \IPS\cms\Theme::i()->getRawTemplates( 'cms', NULL, NULL, \IPS\cms\Theme::RETURN_ALL );
$node = new \SimpleXMLElement( $xml->readOuterXML() );
$attrs = array();
@@ -166,7 +168,7 @@ class _templates extends \IPS\Dispatcher\Controller
$obj->desc = '';
$obj->save();
$obj->key = $obj->location . \IPS\Http\Url::seoTitle( $obj->group ) . '_' . \IPS\Http\Url::seoTitle( $obj->title ) . '_' . $obj->id;
$obj->key = $obj->location . \IPS\Http\Url\Friendly::seoTitle( $obj->group ) . '_' . \IPS\Http\Url\Friendly::seoTitle( $obj->title ) . '_' . $obj->id;
$obj->save();
}
}
@@ -174,6 +176,8 @@ class _templates extends \IPS\Dispatcher\Controller
$xml->next();
}
@unlink( \IPS\Request::i()->file );
/* Done */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&do=manage' ), 'cms_templates_imported' );
}
@@ -505,7 +509,7 @@ class _templates extends \IPS\Dispatcher\Controller
public function addTemplate()
{
/* Check permission */
\IPS\Dispatcher::i()->checkAcpPermission( 'template_add' );
\IPS\Dispatcher::i()->checkAcpPermission( 'template_add_edit' );
$type = \IPS\Request::i()->type;
@@ -513,7 +517,7 @@ class _templates extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form();
$form->hiddenValues['type'] = $type;
$form->add( new \IPS\Helpers\Form\Text( 'template_title', NULL, TRUE, array( 'regex' => '/^([A-Z0-9_]+?)$/i' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'template_title', NULL, TRUE, array( 'regex' => '/^([A-Z_][A-Z0-9_]+?)$/i' ) ) );
/* Very specific */
if ( $type === 'database' )
@@ -601,7 +605,7 @@ class _templates extends \IPS\Dispatcher\Controller
'new' => array( 'group_new' ) )
) ) );
$form->add( new \IPS\Helpers\Form\Text( 'template_group_new', NULL, FALSE, array( 'regex' => '/^([a-z0-9_]+?)?$/' ), NULL, NULL, NULL, 'group_new' ) );
$form->add( new \IPS\Helpers\Form\Text( 'template_group_new', NULL, FALSE, array( 'regex' => '/^([a-z_][a-z0-9_]+?)?$/' ), NULL, NULL, NULL, 'group_new' ) );
$form->add( new \IPS\Helpers\Form\Select( 'template_group_existing', NULL, FALSE, array( 'options' => $groups ), NULL, NULL, NULL, 'group_existing' ) );
}
@@ -624,7 +628,7 @@ class _templates extends \IPS\Dispatcher\Controller
{
unset( $template['template_id'] );
$template['template_original_group'] = $template['template_group'];
$template['template_group'] = str_replace( '-', '_', \IPS\Http\Url::seoTitle( $values['template_title'] ) );
$template['template_group'] = str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['template_title'] ) );
$save = array();
foreach( $template as $k => $v )
@@ -684,7 +688,7 @@ class _templates extends \IPS\Dispatcher\Controller
else if ( $type === 'block' )
{
$save = array(
'title' => str_replace( '-', '_', \IPS\Http\Url::seoTitle( $values['template_title'] ) ),
'title' => str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['template_title'] ) ),
'params' => isset( $values['template_params'] ) ? $values['template_params'] : null,
'location' => $type
);
@@ -779,7 +783,10 @@ class _templates extends \IPS\Dispatcher\Controller
{
/* Check permission */
\IPS\Dispatcher::i()->checkAcpPermission( 'template_delete' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
$key = \IPS\Request::i()->t_key;
$return = array(
'template_content' => NULL,
@@ -807,7 +814,7 @@ class _templates extends \IPS\Dispatcher\Controller
}
catch( \OutOfRangeException $ex )
{
\IPS\Output::i()->error( 'node_error', '3S121/1', 500, '' );
\IPS\Output::i()->error( 'node_error', '3T285/4', 500, '' );
}
/* Clear guest page caches */
@@ -864,6 +871,19 @@ class _templates extends \IPS\Dispatcher\Controller
\IPS\Output::i()->json( array( 'msg' => $ex->getMessage() ) );
}
if ( isset( \IPS\Request::i()->t_type ) and \IPS\Request::i()->t_type !== 'js' )
{
/* Test */
try
{
\IPS\Theme::checkTemplateSyntax( $content, $variables );
}
catch( \Exception $e )
{
\IPS\Output::i()->json( array( 'msg' => \IPS\Member::loggedIn()->language()->get('cms_page_error_bad_syntax') ) );
}
}
/* reload to return new item Id */
$obj = \IPS\cms\Templates::load( $key );
@@ -882,4 +902,74 @@ class _templates extends \IPS\Dispatcher\Controller
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&' . implode( '&', $url ) ), 'completed' );
}
}
/**
* Display template options for a database template group
*
* @return string
*/
public function databaseTemplateGroupOptions()
{
$form = new \IPS\Helpers\Form();
$databases = array();
foreach( \IPS\Db::i()->select( '*', 'cms_databases', array( 'database_template_featured=? or database_template_listing=? or database_template_display=? or database_template_categories=? or database_template_form=?', \IPS\Request::i()->group, \IPS\Request::i()->group, \IPS\Request::i()->group, \IPS\Request::i()->group, \IPS\Request::i()->group ) ) as $database )
{
$databases[ $database['database_id'] ] = \IPS\cms\Databases::constructFromData( $database );
}
if ( count( $databases ) )
{
$names = array();
foreach( $databases as $db )
{
$names[] = $db->_title;
}
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack( 'cms_database_template_used_in', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $names ) ) ) ), 'ipsMessage ipsMessage_info' );
}
$form->add( new \IPS\Helpers\Form\Text( 'cms_database_group_name', \IPS\cms\Templates::readableGroupName( \IPS\Request::i()->group ), NULL, array( 'regex' => '/^([A-Z_][A-Z0-9_\.\s]+?)$/i' ) ) );
$form->addButton( "delete", "link", \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&do=deleteTemplateGroup&group=' . \IPS\Request::i()->group . '&t_location=' . \IPS\Request::i()->t_location ), 'ipsButton ipsButton_negative', array( 'data-confirm' => 'true' ) );
if ( $values = $form->values() )
{
$new = str_replace( ' ', '_', $values['cms_database_group_name'] );
if ( $new != \IPS\Request::i()->group )
{
\IPS\Db::i()->update( 'cms_templates', array( 'template_group' => $new ), array( 'template_location=? and template_group=?', 'database', \IPS\Request::i()->group ) );
foreach( \IPS\cms\Templates::$databaseDefaults as $field => $template )
{
\IPS\Db::i()->update( 'cms_databases', array( 'database_template_' . $field => $new ), array( 'database_template_' . $field . ' =?', \IPS\Request::i()->group ) );
}
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates' . ( isset( \IPS\Request::i()->t_location ) ? '&t_location=' . \IPS\Request::i()->t_location : '' ) ), 'deleted' );
}
/* Display */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack('cms_template_database_options'), $form, FALSE, '', NULL, TRUE );
}
/**
* Delete the template group! OH NOES
*
* @return void
*/
public function deleteTemplateGroup()
{
foreach( \IPS\cms\Templates::$databaseDefaults as $field => $template )
{
\IPS\Db::i()->update( 'cms_databases', array( 'database_template_' . $field => $template ), array( 'database_template_' . $field . ' =?', \IPS\Request::i()->group ) );
}
\IPS\Db::i()->delete( 'cms_templates', array( 'template_location=? and template_group=?', 'database', \IPS\Request::i()->group ) );
unset( \IPS\Data\Store::i()->cms_databases );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates' . ( isset( \IPS\Request::i()->t_location ) ? '&t_location=' . \IPS\Request::i()->t_location : '' ) ), 'deleted' );
}
}
Whitespace-only changes.
@@ -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 );
@@ -2,9 +2,10 @@
/**
* @brief [Front] Page 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 25 Feb 2014
* @version SVN_VERSION_NUMBER
*/
@@ -41,13 +42,24 @@ class _builder extends \IPS\core\modules\front\system\widgets
$block->plugin_plugin = \IPS\Request::i()->block_plugin_plugin;
$block->key = md5( uniqid() );
$params = array();
$params = array();
$block->content = NULL;
if ( isset( \IPS\Request::i()->_sending ) )
{
foreach( explode( ",", \IPS\Request::i()->_sending ) as $field )
{
/* Multi-Selects will pass their parameters through as an array, so we need to make sure we check those properly to include all options. */
if ( mb_strstr( $field, '[]' ) !== FALSE )
{
$field = str_replace( '[]', '', $field );
$isArray = TRUE;
}
else
{
$isArray = FALSE;
}
if ( $field and isset( \IPS\Request::i()->$field ) )
{
if ( $field == 'block_content' )
@@ -67,7 +79,24 @@ class _builder extends \IPS\core\modules\front\system\widgets
$params[ 'widget_feed_container'] = \IPS\Request::i()->$field == 'on' ? 0 : \IPS\Request::i()->$field;
continue;
}
/* We need to handle tags special */
if( $field == 'widget_feed_tags' )
{
$params[ $field ] = explode( ',', \IPS\Request::i()->$field );
continue;
}
/* Is it an array? */
if ( $isArray )
{
foreach( \IPS\Request::i()->$field AS $multi )
{
$params[ $field ][] = $multi;
}
continue;
}
$params[ $field ] = \IPS\Request::i()->$field;
}
}
@@ -234,6 +263,8 @@ class _builder extends \IPS\core\modules\front\system\widgets
$newOrder = array();
$seen = array();
\IPS\Session::i()->csrfCheck();
try
{
$currentConfig = \IPS\Db::i()->select( '*', 'cms_page_widget_areas', array( 'area_page_id=? AND area_area=?', \IPS\Request::i()->pageID, \IPS\Request::i()->area ) )->first();
@@ -243,7 +274,7 @@ class _builder extends \IPS\core\modules\front\system\widgets
{
$widgets = array();
}
/* Loop over the new order and merge in current blocks so we don't lose config */
if ( isset ( \IPS\Request::i()->order ) )
{
@@ -301,7 +332,14 @@ class _builder extends \IPS\core\modules\front\system\widgets
}
}
}
/* Check core_widget_areas to ensure that the block wasn't added there */
if ( isset( \IPS\Request::i()->exclude ) and ! empty( \IPS\Request::i()->exclude ) )
{
$bits = explode( "_", \IPS\Request::i()->exclude );
$this->_checkAndDeleteFromCoreWidgets( $bits[3], $seen );
}
/* Expire Caches so up to date information displays */
\IPS\Widget::deleteCaches();
@@ -311,4 +349,53 @@ class _builder extends \IPS\core\modules\front\system\widgets
\IPS\cms\Pages\Page::load( \IPS\Request::i()->pageID )->postWidgetOrderSave();
}
/**
* Sometimes the widgets end up in the core table. We haven't really found out why this happens. It happens very rarely.
* It may be that the CMS JS mixin doesn't load so the core ajax URLs are used (system/widgets.php) and not the cms widget (page/builder.php).
* This method ensures that any widgets in the core table are removed
*
* @param string $uniqueId The unique key of the widget (eg: wzsj1233)
* @param array $widgets Current widgets (eg from core_widget_areas.widgets (json decoded))
* @return boolen True if something removed, false if not
*/
protected function _checkAndDeleteFromCoreWidgets( $uniqueId, $widgets )
{
if ( ! in_array( $uniqueId, $widgets ) )
{
/* This widget hasn't been seen, so it isn't in the cms table */
try
{
$cmsWidget = \IPS\Db::i()->select( '*', 'core_widget_areas', array( 'app=? and module=? and controller=? and area=?', 'cms', 'pages', 'page', \IPS\Request::i()->area ) )->first();
$cmsWidgets = json_decode( $cmsWidget['widgets'], TRUE );
$newWidgets = array();
foreach( $cmsWidgets as $item )
{
if ( $item['unique'] !== $uniqueId )
{
$newWidgets[] = $item;
}
}
/* Anything to save? */
if ( count( $newWidgets ) )
{
\IPS\Db::i()->replace( 'core_widget_areas', array( 'app' => 'cms', 'module' => 'pages', 'controller' => 'page', 'widgets' => json_encode( $newWidgets ), 'area' => \IPS\Request::i()->area ) );
}
else
{
/* Just remove the entire row */
\IPS\Db::i()->delete( 'core_widget_areas', array( 'app=? and module=? and controller=? and area=?', 'cms', 'pages', 'page', \IPS\Request::i()->area ) );
}
return TRUE;
}
catch( \UnderFlowException $ex )
{
/* Well, it isn't there either... */
return FALSE;
}
}
}
}
+13 -18
View File
@@ -2,9 +2,10 @@
/**
* @brief [Front] Page 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 25 Feb 2014
* @version SVN_VERSION_NUMBER
*/
@@ -40,19 +41,6 @@ class _page extends \IPS\Dispatcher\Controller
*/
public function manage()
{
/* As we bypass the normal URL checks, we need to perform this here */
if ( \IPS\Settings::i()->use_friendly_urls and ! empty( \IPS\Request::i()->url()->data['query'] ) and ( mb_stripos( \IPS\Request::i()->url()->data['query'], 'app=cms&module=pages&controller=page&path=' ) !== FALSE ) )
{
try
{
$url = \IPS\Request::i()->url();
$url->makeFriendly( 'content_page_path', \IPS\Request::i()->url()->queryString['path'] );
\IPS\Output::i()->redirect( $url );
}
catch( \Exception $ex ) { }
}
$this->view();
}
@@ -113,7 +101,14 @@ class _page extends \IPS\Dispatcher\Controller
{
try
{
\IPS\Output::i()->redirect( \IPS\cms\Pages\Page::getUrlFromHistory( \IPS\Request::i()->path, ( isset( \IPS\Request::i()->url()->data['query'] ) ? \IPS\Request::i()->url()->data['query'] : NULL ) ), NULL, 301 );
$page = \IPS\cms\Pages\Page::getUrlFromHistory( \IPS\Request::i()->path, ( isset( \IPS\Request::i()->url()->data['query'] ) ? \IPS\Request::i()->url()->data['query'] : NULL ) );
if( (string) $page == (string) \IPS\Request::i()->url() )
{
\IPS\Output::i()->error( 'content_err_page_404', '2T187/3', 404, '' );
}
\IPS\Output::i()->redirect( $page, NULL, 301 );
}
catch( \OutOfRangeException $e )
{
@@ -159,9 +154,9 @@ class _page extends \IPS\Dispatcher\Controller
public function __call( $method, $args )
{
$page = $this->getPage();
$page->setTheme();
$databaseId = ( isset( \IPS\Request::i()->d ) ) ? \IPS\Request::i()->d : $page->getDatabase()->_id;
if ( $databaseId !== NULL )
{
try