Version 4.2.0

This commit is contained in:
Neo committed 2025-12-19 05:44:59 -08:00
1 parent 0dc2aee5ed
commit 96997ddd8e
2074 files changed
+125454 -55780

No files matched your search

@@ -1,13 +1,12 @@
<?php
/**
* @brief Fields Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 8 April 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\admin\databases;
@@ -1,13 +1,12 @@
<?php
/**
* @brief Databases Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 31 March 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\admin\databases;
@@ -61,7 +60,7 @@ class _databases extends \IPS\Node\Controller
'database_name' => '50'
);
$table->mainColumn = 'word_custom';
$table->mainColumn = 'database_name';
$table->quickSearch = 'word_custom';
$table->sortBy = $table->sortBy ?: 'word_custom';
@@ -124,13 +123,12 @@ class _databases extends \IPS\Node\Controller
);
/* Buttons */
$table->rootButtons = array(
'add' => array(
'title' => 'add',
'icon' => 'plus',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=add' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_database_add') )
),
\IPS\Output::i()->sidebar['actions']['add'] = array(
'primary' => true,
'title' => 'add',
'icon' => 'plus',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=add' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_database_add') )
);
/*if ( \IPS\Application::appIsEnabled('forums') )
@@ -216,7 +214,7 @@ class _databases extends \IPS\Node\Controller
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_databases.js', 'cms', 'admin' ) );
/* Display */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack('menu__cms_databases_databases'), (string) $table );
\IPS\Output::i()->output = (string) $table;
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__cms_databases_databases');
}
@@ -289,6 +287,20 @@ class _databases extends \IPS\Node\Controller
$database->key = uniqid();
$database->save();
/* Set default perms, these will be editable post DB import */
\IPS\Db::i()->replace( 'core_permission_index', array(
'app' => 'cms',
'perm_type' => $database::$permType,
'perm_type_id' => $database->id,
'perm_view' => '*',
'perm_2' => '*', #read
'perm_3' => \IPS\Settings::i()->admin_group, #add
'perm_4' => \IPS\Settings::i()->admin_group, #edit
'perm_5' => \IPS\Settings::i()->admin_group, #reply
'perm_6' => \IPS\Settings::i()->admin_group, #rate
'perm_7' => \IPS\Settings::i()->admin_group, #review
) );
$json = json_decode( @file_get_contents( \IPS\ROOT_PATH . "/applications/cms/data/databaseschema.json" ), true );
$table = $json['cms_custom_database_1'];
@@ -394,19 +406,6 @@ class _databases extends \IPS\Node\Controller
$database->save();
/* Set default perms, these will be editable post DB import */
$perms = $database->permissions();
\IPS\Db::i()->update( 'core_permission_index', array(
'perm_view' => '*',
'perm_2' => '*', #read
'perm_3' => \IPS\Settings::i()->admin_group, #add
'perm_4' => \IPS\Settings::i()->admin_group, #edit
'perm_5' => \IPS\Settings::i()->admin_group, #reply
'perm_6' => \IPS\Settings::i()->admin_group, #rate
'perm_7' => \IPS\Settings::i()->admin_group, #review
), array( 'perm_id=?', $perms['perm_id'] ) );
/* set up some stores (and make sure they are clean from previous possibly broken imports */
\IPS\Data\Store::i()->db_import_cat_map = array();
\IPS\Data\Store::i()->db_import_cat_parent_map = array();
@@ -498,8 +497,15 @@ class _databases extends \IPS\Node\Controller
$fieldsClass = 'IPS\cms\Fields' . $database->id;
$obj = new $fieldsClass;
$obj->saveForm( $obj->formatFormValues( $attrs ) );
$values = $obj->formatFormValues( $attrs );
if ( isset( $attrs['field_extra'] ) )
{
/* The export format is always correct */
$values['field_extra'] = $attrs['field_extra'];
}
$obj->saveForm( $values );
if ( $displayJson )
{
@@ -524,9 +530,26 @@ class _databases extends \IPS\Node\Controller
\IPS\Data\Store::i()->db_import_field_map = $map;
$existingPerms = $obj->permissions();
$existingPerms = $obj->permissions();
$newPerms = array_merge( $perms, array( 'perm_id' => $existingPerms['perm_id'], 'perm_type_id' => $obj->id ) );
/* Set default permissions if not defined in export */
if( !isset( $perms['perm_view'] ) )
{
$newPerms['perm_view'] = '*';
}
if( !isset( $perms['perm_2'] ) )
{
$newPerms['perm_2'] = \IPS\Settings::i()->admin_group;
}
if( !isset( $perms['perm_3'] ) )
{
$newPerms['perm_3'] = \IPS\Settings::i()->admin_group;
}
\IPS\Db::i()->update( 'core_permission_index', array_merge( $perms, array( 'perm_id' => $existingPerms['perm_id'], 'perm_type_id' => $obj->id ) ), array( 'perm_id=?', $existingPerms['perm_id'] ) );
\IPS\Db::i()->update( 'core_permission_index', $newPerms, array( 'perm_id=?', $existingPerms['perm_id'] ) );
\IPS\Lang::saveCustom( 'cms', "content_field_" . $obj->id, $attrs['field_title'] );
@@ -1144,6 +1167,296 @@ class _databases extends \IPS\Node\Controller
}
}
/* Get the database form - abstracted so plugins can adjust easier */
$form = $this->_getDatabaseForm( $current, $category );
if ( $values = $form->values() )
{
$new = FALSE;
if ( empty( $current ) )
{
$new = TRUE;
$current = new \IPS\cms\Databases;
$current->key = uniqid(); # This is modified below to use a proper key
$current->featured_settings = NULL;
$current->fixed_field_perms = NULL;
$current->save();
/* Create a new database table */
try
{
\IPS\cms\Databases::createDatabase( $current );
$current->preLoadWords();
\IPS\Member::clearCreateMenu();
}
catch ( \Exception $ex )
{
$current->delete();
\IPS\Output::i()->error( \IPS\Member::loggedIn()->language()->addToStack('content_acp_err_db_creation_fail', FALSE, array( 'sprintf' => $ex->getMessage() ) ), '4T259/1', 403, '' );
}
}
if ( ! $values['database_key'] )
{
if ( is_array( $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\Friendly::seoTitle( $values['database_name'] );
}
/* Now test it */
try
{
$database = \IPS\cms\Databases::load( $current->key, 'database_key');
/* It's taken... */
if ( $current->id != $database->id )
{
$current->key .= '_' . uniqid();
}
}
catch( \OutOfRangeException $ex )
{
/* Doesn't exist? Good! */
}
}
else
{
$current->key = $values['database_key'];
}
/* Bit options */
foreach ( array( 'comments', 'comments_mod', 'reviews', 'reviews_mod', 'indefinite_own_edit' ) as $k )
{
if ( isset( $values[ "cms_bitoptions_{$k}" ] ) )
{
$current->options[ $k ] = $values["cms_bitoptions_{$k}"];
unset( $values["cms_bitoptions_{$k}"] );
}
}
\IPS\Lang::saveCustom( 'cms', "content_db_" . $current->id, $values['database_name'] );
\IPS\Lang::saveCustom( 'cms', "content_db_" . $current->id . '_desc', $values['database_description'] );
\IPS\Lang::saveCustom( 'cms', "content_db_lang_sl_" . $current->id, $values['database_lang_sl'] );
\IPS\Lang::saveCustom( 'cms', "content_db_lang_pl_" . $current->id, $values['database_lang_pl'] );
\IPS\Lang::saveCustom( 'cms', "content_db_lang_su_" . $current->id, $values['database_lang_su'] );
\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_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::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 ] );
}
/* Notification, search/followed/new content langs */
\IPS\Lang::saveCustom( 'cms', "cms_create_menu_records_" . $current->id, $menu );
\IPS\Lang::saveCustom( 'cms', "cms_records" . $current->id . '_pl', $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "module__cms_records" . $current->id, $values['database_name'] );
$current->use_categories = $values['database_use_categories'];
$current->template_categories = $values['database_template_categories'];
$current->template_listing = $values['database_template_listing'];
$current->template_display = $values['database_template_display'];
$current->template_form = $values['database_template_form'];
$current->template_featured = $values['database_template_featured'];
$current->cat_index_type = $values['database_cat_index_type'];
$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'];
$current->search = (int) $values['database_search'];
$current->comment_bump = $values['database_comment_bump'];
if ( $values['database_rss_enable'] )
{
$current->rss = $values['database_rss'];
}
else
{
$current->rss = 0;
}
$current->record_approve = $values['database_record_approve'];
if ( \IPS\Settings::i()->tags_enabled )
{
$current->tags_enabled = (int) $values['database_tags_enabled'];
$current->tags_noprefixes = !(bool) $values['database_tags_noprefixes'];
if ( ! \IPS\Settings::i()->tags_open_system )
{
$current->tags_predefined = ( is_array( $values['database_tags_predefined'] ) ) ? implode( ',', array_filter( array_map( 'trim', $values['database_tags_predefined'] ) ) ) : NULL;
}
}
$categories = 0;
if ( isset( $values['database_featured_categories'] ) )
{
if ( $values['database_featured_categories'] !== 0 )
{
$categories = array_keys( $values['database_featured_categories'] );
}
}
/* Featured settings */
$current->featured_settings = array(
'featured' => $values['database_featured_featured'],
'perpage' => $values['database_featured_perpage'],
'pagination' => $values['database_featured_pagination'],
'sort' => $values['database_featured_sort'],
'direction' => $values['database_featured_direction'],
'categories' => $categories
);
$current->field_sort = $values['database_field_sort'];
$current->field_direction = $values['database_field_direction'];
$current->field_perpage = $values['database_field_perpage'];
if ( \IPS\Application::appIsEnabled( 'forums' ) )
{
$current->forum_record = (int) $values['database_forum_record'];
$current->forum_comments = (int) $values['database_forum_comments'];
$current->forum_forum = ( ! $values['database_forum_forum'] ) ? 0 : $values['database_forum_forum']->id;
$current->forum_prefix = $values['database_forum_prefix'];
$current->forum_suffix = $values['database_forum_suffix'];
$current->forum_delete = (int) $values['database_forum_delete'];
}
else
{
$current->forum_record = 0;
$current->forum_comments = 0;
$current->forum_delete = 0;
}
$fieldSettingJson = array();
foreach( $values as $k => $v )
{
if ( mb_stristr( $k, 'fixed_field_setting__' ) )
{
$bits = explode( '__', $k );
$fieldSettingJson[ $bits[1] ][ $bits[2] ] = $v;
}
}
$current->fixed_field_settings = $fieldSettingJson;
$fixedFields = $current->fixed_field_perms;
$fixedFields['record_image']['visible'] = $values['database_record_image'];
foreach( array( 'perm_view', 'perm_2', 'perm_3' ) as $p )
{
if ( ! isset( $fixedFields['record_image'][ $p ] ) )
{
$fixedFields['record_image'][ $p ] = '*';
}
}
$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 )
{
if ( $values['database_create_page'] === 'new' )
{
$pageValues = array();
foreach( $values as $k => $v )
{
if( mb_strpos( $k, 'page_' ) === 0 )
{
$pageValues[ $k ] = $v;
}
}
if ( $values['page_type'] === 'html' )
{
$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' );
if ( $values['page_type'] !== 'html' )
{
\IPS\Db::i()->insert( 'cms_page_widget_areas', array(
'area_page_id' => $newPage->id,
'area_widgets' => json_encode( array( array( 'app' => 'cms', 'key' => 'Database', 'unique' => uniqid(), 'configuration' => array( 'database' => $current->id ) ) ) ),
'area_area' => 'col1',
'area_orientation' => 'horizontal'
) );
}
$current->page_id = $newPage->id;
$current->save();
}
}
else
{
/* Use categories setting may have changed */
$current->preLoadWords();
\IPS\Member::clearCreateMenu();
}
if ( $new )
{
\IPS\Session::i()->log( 'acplogs__cms_added_database', array( 'content_db_' . $current->id => TRUE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=permissions&id=' . $current->id ) );
}
\IPS\Session::i()->log( 'acplogs__cms_edited_database', array( 'content_db_' . $current->id => TRUE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases' ), 'saved' );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( $current ? "content_db_" . $current->id : 'add', $form, FALSE );
\IPS\Output::i()->title = ( $current ) ? \IPS\Member::loggedIn()->language()->addToStack('cms_editing_database', NULL, array( 'sprintf' => array( $current->_title ) ) ) : \IPS\Member::loggedIn()->language()->addToStack('cms_adding_database');
}
/**
* Generate the database form
*
* @param \IPS\cms\Databases $current The current database
* @param \IPS\cms\Categories $category The default catgory
* @return \IPS\Form
*/
protected function _getDatabaseForm( $current, $category )
{
$form = new \IPS\Helpers\Form( 'form', 'save', NULL, array( 'data-controller' => 'cms.admin.databases.form' ) );
$form->addTab( 'content_database_form_details' );
@@ -1569,282 +1882,7 @@ class _databases extends \IPS\Node\Controller
}
}
}
if ( $values = $form->values() )
{
$new = FALSE;
if ( empty( $current ) )
{
$new = TRUE;
$current = new \IPS\cms\Databases;
$current->key = uniqid(); # This is modified below to use a proper key
$current->featured_settings = NULL;
$current->fixed_field_perms = NULL;
$current->save();
/* Create a new database table */
try
{
\IPS\cms\Databases::createDatabase( $current );
$current->preLoadWords();
\IPS\Member::clearCreateMenu();
}
catch ( \Exception $ex )
{
$current->delete();
\IPS\Output::i()->error( \IPS\Member::loggedIn()->language()->addToStack('content_acp_err_db_creation_fail', FALSE, array( 'sprintf' => $ex->getMessage() ) ), '4T259/1', 403, '' );
}
}
if ( ! $values['database_key'] )
{
if ( is_array( $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\Friendly::seoTitle( $values['database_name'] );
}
/* Now test it */
try
{
$database = \IPS\cms\Databases::load( $current->key, 'database_key');
/* It's taken... */
if ( $current->id != $database->id )
{
$current->key .= '_' . uniqid();
}
}
catch( \OutOfRangeException $ex )
{
/* Doesn't exist? Good! */
}
}
else
{
$current->key = $values['database_key'];
}
/* Bit options */
foreach ( array( 'comments', 'comments_mod', 'reviews', 'reviews_mod', 'indefinite_own_edit' ) as $k )
{
if ( isset( $values[ "cms_bitoptions_{$k}" ] ) )
{
$current->options[ $k ] = $values["cms_bitoptions_{$k}"];
unset( $values["cms_bitoptions_{$k}"] );
}
}
\IPS\Lang::saveCustom( 'cms', "content_db_" . $current->id, $values['database_name'] );
\IPS\Lang::saveCustom( 'cms', "content_db_" . $current->id . '_desc', $values['database_description'] );
\IPS\Lang::saveCustom( 'cms', "content_db_lang_sl_" . $current->id, $values['database_lang_sl'] );
\IPS\Lang::saveCustom( 'cms', "content_db_lang_pl_" . $current->id, $values['database_lang_pl'] );
\IPS\Lang::saveCustom( 'cms', "content_db_lang_su_" . $current->id, $values['database_lang_su'] );
\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_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::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 ] );
}
/* Notification, search/followed/new content langs */
\IPS\Lang::saveCustom( 'cms', "cms_create_menu_records_" . $current->id, $menu );
\IPS\Lang::saveCustom( 'cms', "cms_records" . $current->id . '_pl', $values['database_lang_pu'] );
\IPS\Lang::saveCustom( 'cms', "module__cms_records" . $current->id, $values['database_name'] );
$current->use_categories = $values['database_use_categories'];
$current->template_categories = $values['database_template_categories'];
$current->template_listing = $values['database_template_listing'];
$current->template_display = $values['database_template_display'];
$current->template_form = $values['database_template_form'];
$current->template_featured = $values['database_template_featured'];
$current->cat_index_type = $values['database_cat_index_type'];
$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'];
$current->search = (int) $values['database_search'];
$current->comment_bump = $values['database_comment_bump'];
if ( $values['database_rss_enable'] )
{
$current->rss = $values['database_rss'];
}
else
{
$current->rss = 0;
}
$current->record_approve = $values['database_record_approve'];
if ( \IPS\Settings::i()->tags_enabled )
{
$current->tags_enabled = (int) $values['database_tags_enabled'];
$current->tags_noprefixes = !(bool) $values['database_tags_noprefixes'];
if ( ! \IPS\Settings::i()->tags_open_system )
{
$current->tags_predefined = ( is_array( $values['database_tags_predefined'] ) ) ? implode( ',', array_filter( array_map( 'trim', $values['database_tags_predefined'] ) ) ) : NULL;
}
}
$categories = 0;
if ( isset( $values['database_featured_categories'] ) )
{
if ( $values['database_featured_categories'] !== 0 )
{
$categories = array_keys( $values['database_featured_categories'] );
}
}
/* Featured settings */
$current->featured_settings = array(
'featured' => $values['database_featured_featured'],
'perpage' => $values['database_featured_perpage'],
'pagination' => $values['database_featured_pagination'],
'sort' => $values['database_featured_sort'],
'direction' => $values['database_featured_direction'],
'categories' => $categories
);
$current->field_sort = $values['database_field_sort'];
$current->field_direction = $values['database_field_direction'];
$current->field_perpage = $values['database_field_perpage'];
if ( \IPS\Application::appIsEnabled( 'forums' ) )
{
$current->forum_record = (int) $values['database_forum_record'];
$current->forum_comments = (int) $values['database_forum_comments'];
$current->forum_forum = ( ! $values['database_forum_forum'] ) ? 0 : $values['database_forum_forum']->id;
$current->forum_prefix = $values['database_forum_prefix'];
$current->forum_suffix = $values['database_forum_suffix'];
$current->forum_delete = (int) $values['database_forum_delete'];
}
else
{
$current->forum_record = 0;
$current->forum_comments = 0;
$current->forum_delete = 0;
}
$fieldSettingJson = array();
foreach( $values as $k => $v )
{
if ( mb_stristr( $k, 'fixed_field_setting__' ) )
{
$bits = explode( '__', $k );
$fieldSettingJson[ $bits[1] ][ $bits[2] ] = $v;
}
}
$current->fixed_field_settings = $fieldSettingJson;
$fixedFields = $current->fixed_field_perms;
$fixedFields['record_image']['visible'] = $values['database_record_image'];
foreach( array( 'perm_view', 'perm_2', 'perm_3' ) as $p )
{
if ( ! isset( $fixedFields['record_image'][ $p ] ) )
{
$fixedFields['record_image'][ $p ] = '*';
}
}
$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 )
{
if ( $values['database_create_page'] === 'new' )
{
$pageValues = array();
foreach( $values as $k => $v )
{
if( mb_strpos( $k, 'page_' ) === 0 )
{
$pageValues[ $k ] = $v;
}
}
if ( $values['page_type'] === 'html' )
{
$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' );
if ( $values['page_type'] !== 'html' )
{
\IPS\Db::i()->insert( 'cms_page_widget_areas', array(
'area_page_id' => $newPage->id,
'area_widgets' => json_encode( array( array( 'app' => 'cms', 'key' => 'Database', 'unique' => uniqid(), 'configuration' => array( 'database' => $current->id ) ) ) ),
'area_area' => 'col1',
'area_orientation' => 'horizontal'
) );
}
$current->page_id = $newPage->id;
$current->save();
}
}
else
{
/* Use categories setting may have changed */
$current->preLoadWords();
\IPS\Member::clearCreateMenu();
}
if ( $new )
{
\IPS\Session::i()->log( 'acplogs__cms_added_database', array( 'content_db_' . $current->id => TRUE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=permissions&id=' . $current->id ) );
}
\IPS\Session::i()->log( 'acplogs__cms_edited_database', array( 'content_db_' . $current->id => TRUE ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases' ), 'saved' );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( $current ? "content_db_" . $current->id : 'add', $form, FALSE );
\IPS\Output::i()->title = ( $current ) ? \IPS\Member::loggedIn()->language()->addToStack('cms_editing_database', NULL, array( 'sprintf' => array( $current->_title ) ) ) : \IPS\Member::loggedIn()->language()->addToStack('cms_adding_database');
return $form;
}
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief Fields Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 31 March 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\admin\databases;
@@ -1,13 +1,12 @@
<?php
/**
* @brief Records Model
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 8 April 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\admin\databases;
@@ -124,23 +123,21 @@ class _records extends \IPS\Dispatcher\Controller
/* Buttons */
if ( $database->use_categories )
{
$table->rootButtons = array(
'add' => array(
'title' => 'add',
'icon' => 'plus',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&do=select&database_id=' . \IPS\Request::i()->database_id ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('database_select_category' ) )
),
\IPS\Output::i()->sidebar['actions']['add'] = array(
'primary' => true,
'title' => 'add',
'icon' => 'plus',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&do=select&database_id=' . \IPS\Request::i()->database_id ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('database_select_category' ) )
);
}
else
{
$table->rootButtons = array(
'add' => array(
'title' => 'add',
'icon' => 'plus',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&do=form&database_id=' . \IPS\Request::i()->database_id )
),
\IPS\Output::i()->sidebar['actions']['add'] = array(
'primary' => true,
'title' => 'add',
'icon' => 'plus',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&do=form&database_id=' . \IPS\Request::i()->database_id )
);
}
@@ -223,7 +220,7 @@ class _records extends \IPS\Dispatcher\Controller
\IPS\Member::loggedIn()->language()->words[ $table->langPrefix . $database->field_title ] = \IPS\Member::loggedIn()->language()->addToStack($table->langPrefix . 'title');
/* Display */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( $title, (string) $table );
\IPS\Output::i()->output = (string) $table;
\IPS\Output::i()->title = $title;
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief Customization AJAX actions
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 07 May 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\admin\pages;
+38 -27
View File
@@ -1,13 +1,12 @@
<?php
/**
* @brief Block Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 19 Feb 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\admin\pages;
@@ -48,7 +47,29 @@ class _blocks extends \IPS\Node\Controller
public function manage()
{
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__cms_pages_blocks');
$nodeClass = $this->nodeClass;
if ( $nodeClass::canAddRoot() )
{
\IPS\Output::i()->sidebar['actions']['add_meow'] = array(
'primary' => true,
'icon' => 'plus',
'title' => 'content_block_cat_add',
'link' => $this->url->setQueryString( 'do', 'form' ),
'data' => ( $nodeClass::$modalForms ? array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('content_block_cat_add') ) : array() )
);
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'pages', 'block_add' ) )
{
\IPS\Output::i()->sidebar['actions']['add_block'] = array(
'primary' => true,
'icon' => 'puzzle-piece',
'title' => 'content_block_block_add',
'link' => $this->url->setQueryString( array( 'do' => 'addBlockType', 'subnode' => 1 ) ),
'data' => ( $nodeClass::$modalForms ? array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('content_block_block_add') ) : array() )
);
}
parent::manage();
}
@@ -77,26 +98,6 @@ class _blocks extends \IPS\Node\Controller
$nodeClass = $this->nodeClass;
$buttons = array();
if ( $nodeClass::canAddRoot() )
{
$buttons['add_meow'] = array(
'icon' => 'plus',
'title' => 'content_block_cat_add',
'link' => $this->url->setQueryString( 'do', 'form' ),
'data' => ( $nodeClass::$modalForms ? array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('content_block_cat_add') ) : array() )
);
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'pages', 'block_add' ) )
{
$buttons['add_block'] = array(
'icon' => 'puzzle-piece',
'title' => 'content_block_block_add',
'link' => $this->url->setQueryString( array( 'do' => 'addBlockType', 'subnode' => 1 ) ),
'data' => ( $nodeClass::$modalForms ? array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('content_block_block_add') ) : array() )
);
}
return $buttons;
}
@@ -130,13 +131,23 @@ class _blocks extends \IPS\Node\Controller
{
if ( $widget['app'] )
{
$plugins[ \IPS\Application::load( $widget['app'] )->_title ][ 'app__' . $widget['app'] . '__' . $widget['key'] ] = \IPS\Member::loggedIn()->language()->addToStack( 'block_' . $widget['key'] );
$app = \IPS\Application::load( $widget['app'] );
if ( $app->enabled )
{
$plugins[ $app->_title ][ 'app__' . $widget['app'] . '__' . $widget['key'] ] = \IPS\Member::loggedIn()->language()->addToStack( 'block_' . $widget['key'] );
}
}
else
{
$plugins[ \IPS\Plugin::load( $widget['plugin'] )->_title ][ 'plugin__' . $widget['plugin'] . '__' . $widget['key'] ] = \IPS\Member::loggedIn()->language()->addToStack( 'block_' . $widget['key'] );
$plugin = \IPS\Plugin::load( $widget['plugin'] );
if ( $plugin->enabled )
{
$plugins[ $plugin->_title ][ 'plugin__' . $widget['plugin'] . '__' . $widget['key'] ] = \IPS\Member::loggedIn()->language()->addToStack( 'block_' . $widget['key'] );
}
}
}
catch ( \UnexpectedValueException $e ) { }
catch ( \OutOfRangeException $e ) { }
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief Pages Media Management
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 07 Jul 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\admin\pages;
+55 -21
View File
@@ -1,10 +1,10 @@
<?php
/**
* @brief Pages Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 15 Jan 2013
* @version SVN_VERSION_NUMBER
@@ -55,23 +55,6 @@ class _pages extends \IPS\Node\Controller
$nodeClass = $this->nodeClass;
$buttons = array();
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'pages', 'page_add' ) )
{
$buttons['add_folder'] = array(
'icon' => 'folder-open',
'title' => 'content_add_folder',
'link' => \IPS\Http\Url::internal( 'app=cms&module=pages&controller=pages&do=form' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('content_add_folder') )
);
$buttons['add_page'] = array(
'icon' => 'plus-circle',
'title' => 'content_add_page',
'link' => \IPS\Http\Url::internal( 'app=cms&module=pages&controller=pages&subnode=1&do=add' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('content_add_page') )
);
}
return $buttons;
}
@@ -146,6 +129,25 @@ class _pages extends \IPS\Node\Controller
'link' => \IPS\Http\Url::internal( 'app=cms&module=pages&controller=pages&do=settings' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_pages_settings') )
);
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'pages', 'page_add' ) )
{
\IPS\Output::i()->sidebar['actions']['add_folder'] = array(
'primary' => true,
'icon' => 'folder-open',
'title' => 'content_add_folder',
'link' => \IPS\Http\Url::internal( 'app=cms&module=pages&controller=pages&do=form' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('content_add_folder') )
);
\IPS\Output::i()->sidebar['actions']['add_page'] = array(
'primary' => true,
'icon' => 'plus-circle',
'title' => 'content_add_page',
'link' => \IPS\Http\Url::internal( 'app=cms&module=pages&controller=pages&subnode=1&do=add' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('content_add_page') )
);
}
}
/**
@@ -436,4 +438,36 @@ 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 $new The node now
* @param string $lastUsedTab The tab last used in the form
* @return void
*/
protected function _afterSave( \IPS\Node\Model $old = NULL, \IPS\Node\Model $new, $lastUsedTab = FALSE )
{
/* If this page was the default in a folder, and it was moved to a new folder that already has a default, we need to unset the
default page flag or there will be two defaults in the destination folder */
if( $old !== NULL AND $old->folder_id != $new->folder_id AND $old->default )
{
/* Is there already a default page in the new folder? */
try
{
$existingDefault = \IPS\Db::i()->select( 'page_id', 'cms_pages', array( 'page_folder_id=? and page_default=?', $new->folder_id, 1 ) )->first();
\IPS\Db::i()->update( 'cms_pages', array( 'page_default' => 0 ), array( 'page_id=?', $new->id ) );
\IPS\cms\Pages\Page::buildPageUrlStore();
}
catch( \UnderflowException $e )
{
/* No default found in destination folder, do nothing */
}
}
parent::_afterSave( $old, $new, $lastUsedTab );
}
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief Templates Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 25 Feb 2013
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\admin\pages;
@@ -517,7 +516,15 @@ 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-Z_][A-Z0-9_]+?)$/i' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'template_title', NULL, TRUE, array( 'regex' => '/^([A-Z_][A-Z0-9_]+?)$/i' ), function ( $val ) {
/* PHP Keywords cannot be used as template names - so make sure the full template name is not in the list */
$keywords = array( 'abstract', 'and', 'array', 'as', 'break', 'callable', 'case', 'catch', 'class', 'clone', 'const', 'continue', 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 'eval', 'exit', 'extends', 'final', 'for', 'foreach', 'function', 'global', 'goto', 'if', 'implements', 'include', 'include_once', 'instanceof', 'insteadof', 'interface', 'isset', 'list', 'namespace', 'new', 'or', 'print', 'private', 'protected', 'public', 'require', 'require_once', 'return', 'static', 'switch', 'throw', 'trait', 'try', 'unset', 'use', 'var', 'while', 'xor' );
if ( in_array( $val, $keywords ) )
{
throw new \DomainException( \IPS\Member::loggedIn()->language()->addToStack( 'template_reserved_word', FALSE, array( 'htmlsprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $keywords ) ) ) ) );
}
} ) );
/* Very specific */
if ( $type === 'database' )
@@ -547,6 +554,12 @@ class _templates extends \IPS\Dispatcher\Controller
$plugins = array();
foreach ( \IPS\Db::i()->select( "*", 'core_widgets', array( 'embeddable=1') ) as $widget )
{
/* Skip disabled applications */
if ( !in_array( $widget['app'], array_keys( \IPS\Application::enabledApplications() ) ) )
{
continue;
}
try
{
$plugins[ \IPS\Application::load( $widget['app'] )->_title ][ $widget['app'] . '__' . $widget['key'] ] = \IPS\Member::loggedIn()->language()->addToStack( 'block_' . $widget['key'] );
@@ -1,13 +1,12 @@
<?php
/**
* @brief Ajax only methods
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 01 Oct 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\front\database;
@@ -1,12 +1,11 @@
<?php
/**
* @brief [Database] Category Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Content
* @since 16 April 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\front\database;
@@ -186,12 +185,12 @@ class _category extends \IPS\cms\Databases\Controller
{
if ( $obj->type == 'Number' )
{
$table->sortOptions['field_' . $id ] = 'LENGTH(`field_' . $id . '`) ' . $table->sortDirection . ',`field_' . $id . '`';
$table->sortBy = 'LENGTH(`field_' . $id . '`) ' . $table->sortDirection . ',`field_' . $id . '`';
break;
}
elseif( $obj->type == 'Date' )
{
$table->sortOptions['field_' . $id ] = 'CAST(`field_' . $id . '` AS UNSIGNED)';
$table->sortBy = 'CAST(`field_' . $id . '` AS UNSIGNED)';
break;
}
}
@@ -255,7 +254,7 @@ class _category extends \IPS\cms\Databases\Controller
break;
case 'record_rating':
$sortBy[ $database->field_sort ] = 'database_field__rating';
$table->sortOptions['database_field__rating'] = $database->field_sort;
$table->sortOptions['rating'] = $database->field_sort;
\IPS\Member::loggedIn()->language()->words['sort_database_field__rating'] = \IPS\Member::loggedIn()->language()->addToStack('database_field__rating');
break;
}
@@ -303,11 +302,11 @@ class _category extends \IPS\cms\Databases\Controller
if ( $obj->filter )
{
\IPS\Member::loggedIn()->language()->words['content_field_' . $obj->id ] = $obj->_title;
if ( $obj->type == 'DateRange' )
if ( in_array( $obj->type, array( 'Date', 'DateRange' ) ) )
{
$table->advancedSearch[ 'content_field_' . $obj->id ] = array( \IPS\Helpers\Table\SEARCH_DATE_RANGE, array( 'noDefault' => true ) );
}
if ( $obj->type == 'Number' )
else if ( $obj->type == 'Number' )
{
$table->advancedSearch[ 'content_field_' . $obj->id ] = array( \IPS\Helpers\Table\SEARCH_NUMERIC_TEXT, array( 'noDefault' => true ) );
}
@@ -562,7 +561,7 @@ class _category extends \IPS\cms\Databases\Controller
\IPS\Output::i()->allowDefaultWidgets = FALSE;
\IPS\Output::i()->sidebar['enabled'] = FALSE;
\IPS\cms\Pages\Page::$currentPage->getWidgets();
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::$currentPage, $title, $hasModOptions );
\IPS\cms\Databases\Dispatcher::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::$currentPage, $title, $hasModOptions );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( $title );
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'records/form.css', 'cms', 'front' ) );
@@ -1,13 +1,12 @@
<?php
/**
* @brief [Database] Category List Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 16 April 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\front\database;
@@ -141,7 +140,7 @@ class _index extends \IPS\cms\Databases\Controller
/* Load into memory */
$class::loadIntoMemory();
$categories = $class::roots('view', \IPS\Member::loggedIn(), null, $database->_id );
$categories = $class::roots();
\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();
@@ -182,8 +181,8 @@ class _index extends \IPS\cms\Databases\Controller
\IPS\Output::i()->redirect( $values['category']->url()->setQueryString( 'do', 'form' ) );
}
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'cms_select_category' );
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'cms_select_category' ) );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'records' )->categorySelector( $form );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'cms_select_category' );
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'cms_select_category' ) );
\IPS\cms\Databases\Dispatcher::i()->output = \IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'records' )->categorySelector( $form );
}
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief Record View
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 17 Apr 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\front\database;
@@ -146,6 +145,9 @@ class _record extends \IPS\Content\Controller
\IPS\Output::i()->metaTags['og:description'] = $record->record_meta_description;
}
/* Set record URL as canonical tag */
\IPS\Output::i()->linkTags['canonical'] = $record->url();
/* Update location */
if( $record->database()->use_categories )
{
@@ -172,6 +174,82 @@ class _record extends \IPS\Content\Controller
{
\IPS\Output::i()->metaTags['og:image'] = (string) \IPS\File::get( 'cms_Records', $record->record_image )->url;
}
/* Add Json-LD */
\IPS\Output::i()->jsonLd['article'] = array(
'@context' => "http://schema.org",
'@type' => "Article",
'url' => (string) $record->url(),
'discussionUrl' => (string) $record->url(),
'mainEntityOfPage' => (string) $record->url(),
'name' => htmlspecialchars( $record->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'headline' => htmlspecialchars( $record->_title, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'text' => strip_tags( $record->truncated() ),
'articleBody' => strip_tags( $record->truncated() ),
'dateCreated' => \IPS\DateTime::ts( $record->record_saved )->format( \IPS\DateTime::ISO8601 ),
'datePublished' => \IPS\DateTime::ts( $record->record_publish_date ?: $record->record_saved )->format( \IPS\DateTime::ISO8601 ),
'dateModified' => \IPS\DateTime::ts( $record->record_edit_time ?: ( $record->record_publish_date ?: $record->record_saved ) )->format( \IPS\DateTime::ISO8601 ),
'pageStart' => 1,
'pageEnd' => $record->commentPageCount(),
/* Image is required */
'image' => $record->record_image ? (string) \IPS\File::get( 'cms_Records', $record->record_image )->url : \IPS\Member::load( $record->member_id )->get_photo(),
'author' => array(
'@type' => 'Person',
'name' => htmlspecialchars( \IPS\Member::load( $record->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'url' => (string) \IPS\Member::load( $record->member_id )->url(),
'image' => \IPS\Member::load( $record->member_id )->get_photo()
),
'publisher' => array(
'@type' => 'Organization',
'name' => htmlspecialchars( \IPS\Member::load( $record->member_id )->name, ENT_QUOTES | \IPS\HTMLENTITIES, 'UTF-8', FALSE ),
'url' => (string) \IPS\Member::load( $record->member_id )->url(),
'image' => \IPS\Member::load( $record->member_id )->get_photo(),
'logo' => \IPS\Member::load( $record->member_id )->get_photo()
),
'interactionStatistic' => array(
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ViewAction",
'userInteractionCount' => $record->record_views
),
array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/FollowAction",
'userInteractionCount' => $record::containerFollowerCount( $record->container() )
),
),
);
if( $record->averageReviewRating() )
{
\IPS\Output::i()->jsonLd['article']['aggregateRating'] = array(
'@type' => 'AggregateRating',
'ratingValue' => $record->averageReviewRating(),
'ratingCount' => $record->rating_hits,
'reviewCount' => $record->record_reviews,
'bestRating' => \IPS\Settings::i()->reviews_rating_out_of
);
}
if( $record::database()->options['reviews'] )
{
\IPS\Output::i()->jsonLd['article']['interactionStatistic'][] = array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/ReviewAction",
'userInteractionCount' => $record->record_reviews
);
}
if( $record::database()->options['comments'] )
{
\IPS\Output::i()->jsonLd['article']['commentCount'] = $record->record_comments;
\IPS\Output::i()->jsonLd['article']['interactionStatistic'][] = array(
'@type' => 'InteractionCounter',
'interactionType' => "http://schema.org/CommentAction",
'userInteractionCount' => $record->record_comments
);
}
\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 );
@@ -304,8 +382,8 @@ class _record extends \IPS\Content\Controller
\IPS\Output::i()->breadcrumb[] = array( $record->url(), $record->_title );
\IPS\Output::i()->title = $title;
\IPS\Output::i()->output .= (string) $table;
\IPS\Output::i()->title = $title;
\IPS\cms\Databases\Dispatcher::i()->output .= (string) $table;
}
}
@@ -446,7 +524,7 @@ class _record extends \IPS\Content\Controller
\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 );
\IPS\cms\Databases\Dispatcher::i()->output = $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'revisions', 'cms' ), 'view' ), $record, $revision, $conflicts );
}
/**
@@ -527,7 +605,7 @@ class _record extends \IPS\Content\Controller
\IPS\Output::i()->allowDefaultWidgets = FALSE;
\IPS\Output::i()->sidebar['enabled'] = FALSE;
\IPS\cms\Pages\Page::$currentPage->getWidgets();
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::$currentPage, $title, $hasModOptions );
\IPS\cms\Databases\Dispatcher::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::$currentPage, $title, $hasModOptions );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( $title );
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'records/form.css', 'cms', 'front' ) );
@@ -698,9 +776,9 @@ class _record extends \IPS\Content\Controller
* @return void
* @throws \LogicException
*/
protected function _rep( $commentClass, $comment, $item )
protected function _react( $commentClass, $comment, $item )
{
return $this->_doSomething( '_rep', $commentClass, $comment, $item );
return $this->_doSomething( '_react', $commentClass, $comment, $item );
}
/**
@@ -712,9 +790,9 @@ class _record extends \IPS\Content\Controller
* @return void
* @throws \LogicException
*/
protected function _showRep( $commentClass, $comment, $item )
protected function _showReactions( $commentClass, $comment, $item )
{
return $this->_doSomething( '_showRep', $commentClass, $comment, $item );
return $this->_doSomething( '_showReactions', $commentClass, $comment, $item );
}
/**
@@ -747,4 +825,16 @@ class _record extends \IPS\Content\Controller
\IPS\Output::i()->error( 'node_error', '2T252/F', 403, '' );
}
}
/**
* Moderate
*
* @return void
*/
protected function moderate()
{
parent::moderate();
\IPS\cms\Databases\Dispatcher::i()->output = \IPS\Output::i()->output;
}
}
@@ -0,0 +1,315 @@
<?php
/**
* @brief topic
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Pages
* @since 03 Mar 2017
*/
namespace IPS\cms\modules\front\database;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* topic
*/
class _topic extends \IPS\Dispatcher\Controller
{
/**
* Execute
*
* @return void
*/
public function execute()
{
if ( !\IPS\Member::loggedIn()->modPermission( 'can_copy_topic_database' ) )
{
\IPS\Output::i()->error( 'node_error', '2T353/1', 403, '' );
}
try
{
$this->topic = \IPS\forums\Topic::load( \IPS\Request::i()->id );
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2T353/3', 404, '' );
}
parent::execute();
}
/**
* Manage
*
* @return void
*/
protected function manage()
{
$wizard = new \IPS\Helpers\Wizard( array(
'database' => array( $this, '_database' ),
'category' => array( $this, '_category' ),
), \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id, 'front', 'topic_copy', $this->topic->title_seo ), FALSE );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' );
\IPS\Output::i()->output = (string) $wizard;
}
/**
* Database
*
* @return void
*/
public function _database( $data )
{
$form = new \IPS\Helpers\Form( 'database', 'copy_select_database', \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id, 'front', 'topic_copy', $this->topic->title_seo ) );
$form->class = 'ipsForm_vertical';
$form->hiddenValues['topic_id'] = \IPS\Request::i()->id;
$form->add( new \IPS\Helpers\Form\Node( 'database', NULL, TRUE, array( 'class' => '\IPS\cms\Databases', 'permissionCheck' => function( $row )
{
if ( !$row->field_title OR !$row->field_content )
{
return FALSE;
}
return $row->can( 'add' );
} ) ) );
if ( $values = $form->values() )
{
return array(
'topic_id' => $values['topic_id'],
'database_id' => $values['database']->_id
);
}
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
}
/**
* Category
*
* @return void
*/
public function _category( $data )
{
/* Do we need to even bother? */
$database = \IPS\cms\Databases::load( $data['database_id'] );
if ( !$database->use_categories )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=form&id={$data['topic_id']}", 'front', 'topic_copy', $this->topic->title_seo )->csrf()->setQueryString( array( 'database_id' => $data['database_id'], 'category_id' => $database->default_category ) ) );
}
$catClass = 'IPS\cms\Categories' . $data['database_id'];
$form = new \IPS\Helpers\Form( 'category', 'copy_select_category', \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id, 'front', 'topic_copy', $this->topic->title_seo ) );
$form->class = 'ipsForm_vertical';
$form->hiddenValues['topic_id'] = $data['topic_id'];
$form->hiddenValues['database_id'] = $data['database_id'];
$form->add( new \IPS\Helpers\Form\Node( 'select_category', NULL, TRUE, array( 'class' => $catClass, 'permissionCheck' => 'add' ) ) );
if ( $values = $form->values() )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=form&id={$values['topic_id']}", 'front', 'topic_copy', $this->topic->title_seo )->csrf()->setQueryString( array( 'database_id' => $values['database_id'], 'category_id' => $values['select_category']->_id ) ) );
}
return $form->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'forms', 'core' ) ), 'popupTemplate' ) );
}
/**
* Form
*
* @return void
*/
protected function form()
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js('front_records.js', 'cms' ) );
try
{
$database = \IPS\cms\Databases::load( \IPS\Request::i()->database_id );
}
catch( \OutOfRangeException $e )
{
\IPS\Output::i()->error( 'node_error', '2T353/2', 404, '' );
}
$recordClass = 'IPS\cms\Records' . $database->_id;
$commentClass = 'IPS\cms\Comments' . $database->_id;
$fieldClass = 'IPS\cms\Fields' . $database->_id;
$catClass = 'IPS\cms\Categories' . $database->_id;
$category = $catClass::load( \IPS\Request::i()->category_id );
$titleField = "field_{$database->field_title}";
$contentField = "field_{$database->field_content}";
$fakeRecord = new $recordClass;
$fakeRecord->$titleField = $this->topic->mapped('title');
$fakeRecord->$contentField = $this->topic->content();
\IPS\Member::loggedIn()->language()->words['copy_comments_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_comments_desc' ), $recordClass::_definiteArticle() );
\IPS\Member::loggedIn()->language()->words['copy_author_desc'] = sprintf( \IPS\Member::loggedIn()->language()->get( 'copy_author_desc' ), $recordClass::_definiteArticle() );
$form = new \IPS\Helpers\Form;
$form->class = 'ipsForm_vertical';
$form->hiddenValues['record_category_id'] = $category->_id;
foreach( $recordClass::formElements( $fakeRecord, $category ) AS $key => $element )
{
/* Skip these */
if ( in_array( $key, array( 'record_edit_reason', 'record_edit_show' ) ) )
{
continue;
}
$form->add( $element );
}
if ( $database->options['comments'] )
{
$form->add( new \IPS\Helpers\Form\YesNo( 'copy_comments', FALSE ) );
}
$form->add( new \IPS\Helpers\Form\YesNo( 'copy_author', TRUE ) );
if ( $values = $form->values() )
{
$comments = FALSE;
if ( array_key_exists( 'copy_comments', $values ) )
{
$comments = $values['copy_comments'];
unset( $values['copy_comments'] );
}
$author = $values['copy_author'];
unset( $values['copy_author'] );
$record = $recordClass::createFromForm( $values, $category );
if ( $author )
{
$record->changeAuthor( $this->topic->author() );
}
if ( $comments )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&do=comments&id={$this->topic->tid}", 'front', 'topic_copy', $this->topic->title_seo )->setQueryString( array( 'record_id' => $record->primary_id_field, 'database_id' => $database->_id ) ) );
}
else
{
try
{
/* If the database is on a page, go to the record */
\IPS\Output::i()->redirect( $record->url() );
}
catch( \LogicException $e )
{
/* If it is NOT then go back to the topic */
\IPS\Output::i()->redirect( $this->topic->url() );
}
}
}
$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 ) or
$fieldClass::fixedFieldFormShow( 'record_allow_comments' ) or
$fieldClass::fixedFieldFormShow( 'record_expiry_date' ) or
$fieldClass::fixedFieldFormShow( 'record_comment_cutoff' ) or
\IPS\Member::loggedIn()->modPermission('can_content_edit_meta_tags') )
{
$hasModOptions = TRUE;
}
array_shift( \IPS\Output::i()->breadcrumb );
$container = NULL;
try
{
$container = $this->topic->container();
foreach ( $container->parents() as $parent )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
}
\IPS\Output::i()->breadcrumb[] = array( $container->url(), $container->_title );
}
catch ( \Exception $e ) { }
\IPS\Output::i()->breadcrumb[] = array( $this->topic->url(), $this->topic->mapped( 'title' ) );
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' ) );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' );
\IPS\Output::i()->output = $form->customTemplate( array( call_user_func_array( array( \IPS\cms\Theme::i(), 'getTemplate' ), array( $database->template_form, 'cms', 'database' ) ), 'recordForm' ), NULL, $category, $database, \IPS\cms\Pages\Page::load( $database->page_id ), \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' ), $hasModOptions );
}
/**
* Comments
*
* @return void
*/
protected function comments()
{
$mr = new \IPS\Helpers\MultipleRedirect( \IPS\Http\Url::internal( "app=cms&module=database&controller=topic&id=" . \IPS\Request::i()->id . "&do=comments", 'front', 'topic_copy', $this->topic->title_seo )->setQueryString( array( 'database_id' => \IPS\Request::i()->database_id, 'record_id' => \IPS\Request::i()->record_id ) ), function( $data ) {
$database = \IPS\cms\Databases::load( \IPS\Request::i()->database_id );
$recordClass = 'IPS\cms\Records' . \IPS\Request::i()->database_id;
$commentClass = $recordClass::$commentClass;
$record = $recordClass::load( \IPS\Request::i()->record_id );
$total = \IPS\Db::i()->select( 'COUNT(*)', 'forums_posts', array( "topic_id=? AND new_topic=? AND queued!=?", \IPS\Request::i()->id, 0, 2 ) )->first();
$done = 0;
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'forums_posts', array( "topic_id=? AND new_topic=? AND queued!=?", \IPS\Request::i()->id, 0, -2 ), "pid ASC", array( $data, 100 ) ), 'IPS\forums\Topic\Post' ) AS $post )
{
$commentClass::create( $record, $post->content(), FALSE, NULL, TRUE, $post->author(), \IPS\DateTime::create(), $post->ip_address, $post->hidden() );
$done++;
}
if ( !$done )
{
return NULL;
}
return array( $data + $done, \IPS\Member::loggedIn()->language()->addToStack( 'copying_comments' ), 100 / $total * ( $data + 100 ) );
}, function() {
$recordClass = 'IPS\cms\Records' . \IPS\Request::i()->database_id;
$record = $recordClass::load( \IPS\Request::i()->record_id );
try
{
\IPS\Output::i()->redirect( $record->url() );
}
catch( \LogicException $e )
{
\IPS\Output::i()->redirect( \IPS\forums\Topic::load( \IPS\Request::i()->id )->url() );
}
} );
$topic = \IPS\forums\Topic::load( \IPS\Request::i()->id );
array_shift( \IPS\Output::i()->breadcrumb );
$container = NULL;
try
{
$container = $topic->container();
foreach ( $container->parents() as $parent )
{
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
}
\IPS\Output::i()->breadcrumb[] = array( $container->url(), $container->_title );
}
catch ( \Exception $e ) { }
\IPS\Output::i()->breadcrumb[] = array( $topic->url(), $topic->mapped( 'title' ) );
\IPS\Output::i()->breadcrumb[] = array( NULL, \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' ) );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack( 'copying_comments' );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'front' )->genericBlock( (string) $mr, \IPS\Member::loggedIn()->language()->addToStack( 'copying_comments' ), 'ipsBox ipsPad' );
}
}
@@ -1,13 +1,12 @@
<?php
/**
* @brief [Front] Page Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 25 Feb 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\front\pages;
@@ -246,7 +245,7 @@ class _builder extends \IPS\core\modules\front\system\widgets
\IPS\Db::i()->insert( 'cms_page_widget_areas', array( 'area_page_id' => \IPS\Request::i()->pageID, 'area_area' => \IPS\Request::i()->pageArea, 'area_widgets' => json_encode( $blocks ) ), TRUE );
\IPS\Output::i()->json( 'OK' );
}
\IPS\Output::i()->sendOutput( $widget->configuration()->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'widgets', 'core' ) ), 'formTemplate' ), $widget ) );
\IPS\Output::i()->output = $widget->configuration()->customTemplate( array( call_user_func_array( array( \IPS\Theme::i(), 'getTemplate' ), array( 'widgets', 'core' ) ), 'formTemplate' ), $widget );
}
}
}
+22 -8
View File
@@ -1,13 +1,12 @@
<?php
/**
* @brief [Front] Page Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Community Suite
* @author <a href='https://www.invisioncommunity.com'>Invision Power Services, Inc.</a>
* @copyright (c) Invision Power Services, Inc.
* @license https://www.invisioncommunity.com/legal/standards/
* @package Invision Community
* @subpackage Content
* @since 25 Feb 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\front\pages;
@@ -68,8 +67,16 @@ class _page extends \IPS\Dispatcher\Controller
$permissions = $page->permissions();
\IPS\Session::i()->setLocation( $page->url(), explode( ",", $permissions['perm_view'] ), 'loc_cms_viewing_page', array( 'cms_page_' . $page->_id => TRUE ) );
}
$page->output();
try
{
$page->output();
}
catch ( \ParseError $e )
{
\IPS\Log::log( $e, 'page_error' );
\IPS\Output::i()->error( 'content_err_page_500', '2T187/4', 500, 'content_err_page_500_admin', array(), $e );
}
}
/**
@@ -161,7 +168,14 @@ class _page extends \IPS\Dispatcher\Controller
{
try
{
return \IPS\cms\Databases\Dispatcher::i()->setDatabase( $databaseId )->run();
if ( \IPS\Request::i()->isAjax() )
{
return \IPS\cms\Databases\Dispatcher::i()->setDatabase( $databaseId )->run();
}
else
{
$page->output();
}
}
catch( \OutOfRangeException $e )
{