Version 4.7.0
This commit is contained in:
1 parent
517a5e1f70
commit
8ba7d43898
1933 files changed
+65613
-11332
No files matched your search
@@ -61,7 +61,7 @@ class _ajax extends \IPS\Dispatcher\Controller
|
||||
|
||||
if ( $database->use_categories )
|
||||
{
|
||||
$category = \IPS\Member::loggedIn()->language()->addToStack( 'cms_autocomplete_category', NULL, array( 'sprintf' => array( $record->container()->_title ) ) );
|
||||
$category = \IPS\Member::loggedIn()->language()->addToStack( 'cms_autocomplete_category', FALSE, array( 'sprintf' => array( $record->container()->_title ) ) );
|
||||
}
|
||||
|
||||
$results[] = array(
|
||||
|
||||
@@ -102,8 +102,8 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
}
|
||||
|
||||
/* we need this language later (and in Widgets\DatabaseFilters which is executed just before output) */
|
||||
\IPS\Member::loggedIn()->language()->words['cms_record_i_started'] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_record_i_started_sprintf', NULL, array( 'sprintf' => $database->recordWord() ) );
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words['cms_record_i_started'] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_record_i_started_sprintf', FALSE, array( 'sprintf' => $database->recordWord() ) );
|
||||
|
||||
/* Check cookie */
|
||||
$where = array();
|
||||
$cookie = $category->getFilterCookie();
|
||||
@@ -120,7 +120,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
$field = new \IPS\cms\Fields;
|
||||
$field->id = 'cms_record_i_started';
|
||||
|
||||
\IPS\Member::loggedIn()->language()->words['content_field_cms_record_i_started'] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_record_i_started_sprintf', NULL, array( 'sprintf' => $database->recordWord() ) );
|
||||
\IPS\Member::loggedIn()->language()->words['content_field_cms_record_i_started'] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_record_i_started_sprintf', FALSE, array( 'sprintf' => $database->recordWord() ) );
|
||||
|
||||
static::$activeFilters['cms_record_i_started'] = array( 'field' => $field, 'value' => \IPS\Member::loggedIn()->language()->addToStack('content_field_cms_record_i_started_on') );
|
||||
continue;
|
||||
@@ -277,7 +277,7 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
$table->sortBy = ( isset( \IPS\Request::i()->sortby ) ) ? \IPS\Request::i()->sortby : ( $database->field_sort ? $RecordsClass::$databaseTable . '.' . $RecordsClass::$databasePrefix . $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( $RecordsClass::contentCount( $category, FALSE ), $database->recordWord( $RecordsClass::contentCount( $category, FALSE ) ) ) ) );
|
||||
$table->title = \IPS\Member::loggedIn()->language()->addToStack( $database->use_categories ? 'x_records_in_this_category' : 'x_records' , FALSE, array( 'sprintf' => array( $category->_items, $database->recordWord( $category->_items ) ) ) );
|
||||
|
||||
/* Set up sort fields to allow sorting numerically or by date */
|
||||
$sortFields = $customFields;
|
||||
@@ -286,19 +286,20 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
{
|
||||
if ( $table->sortBy == $RecordsClass::$databaseTable . '.' . 'field_' . $id OR $table->sortBy == 'field_' . $id )
|
||||
{
|
||||
if ( $obj->type == 'Number' )
|
||||
if ( \in_array( $obj->type, array( 'Number', 'Date' ) ) )
|
||||
{
|
||||
$table->sortOptions[ $table->sortBy ] = 'LENGTH(`field_' . $id . '`) ' . $table->sortDirection . ',`field_' . $id . '`';
|
||||
break;
|
||||
}
|
||||
elseif( $obj->type == 'Date' )
|
||||
{
|
||||
$table->sortOptions[ $table->sortBy ] = 'CAST(`field_' . $id . '` AS UNSIGNED)';
|
||||
$fieldName = $table->sortBy;
|
||||
if ( mb_strstr( $table->sortBy, '.' ) )
|
||||
{
|
||||
list( $db, $fieldName ) = explode( '.', $table->sortBy );
|
||||
}
|
||||
|
||||
$table->sortOptions[ $fieldName ] = 'CAST(`field_' . $id . '` AS UNSIGNED)';
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Make sure table doesn't add breadcrumbs if we're not using categories */
|
||||
if ( ! $database->use_categories )
|
||||
{
|
||||
@@ -438,14 +439,10 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
$table->advancedSearch['sort_by'][1]['options']['field_' . $obj->id ] = 'content_field_' . $obj->id;
|
||||
}
|
||||
|
||||
if ( \in_array( $obj->type, array( 'Date', 'DateRange' ) ) )
|
||||
if ( \in_array( $obj->type, array( 'Date', 'DateRange', 'Number' ) ) )
|
||||
{
|
||||
$table->sortOptions[ 'field_' . $obj->id ] = 'CAST(`field_' . $obj->id . '` AS UNSIGNED)';
|
||||
}
|
||||
else if ( $obj->type == 'Number' )
|
||||
{
|
||||
$table->sortOptions[ 'field_' . $obj->id ] = 'LENGTH(`field_' . $obj->id . '`) ' . $table->sortDirection . ',`field_' . $obj->id . '`';
|
||||
}
|
||||
else
|
||||
{
|
||||
$table->sortOptions[ 'field_' . $obj->id ] = isset( $table->sortOptions[ 'field_' . $obj->id ] ) ? $table->sortOptions[ 'field_' . $obj->id ] : 'field_' . $obj->id;
|
||||
@@ -583,6 +580,9 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
{
|
||||
$table->sortOptions[ $values['sort_by'] ] = $values['sort_by'];
|
||||
}
|
||||
|
||||
/* Ensure we remove any duplicates added by the advanced sort form */
|
||||
$table->sortOptions = array_unique( $table->sortOptions );
|
||||
|
||||
$table->sortBy = $values['sort_by'];
|
||||
$table->sortDirection = $values['sort_direction'];
|
||||
@@ -686,13 +686,19 @@ class _category extends \IPS\cms\Databases\Controller
|
||||
{
|
||||
foreach ( $category->parents() as $parent )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb[] = array( $category->url(), $category->_title );
|
||||
\IPS\Output::i()->breadcrumb[] = array( $parent->url(), $parent->_title );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->breadcrumb[] = array( NULL, $category->_title );
|
||||
}
|
||||
}
|
||||
|
||||
/* Node handler does not support keywords, so we need to do it manually */
|
||||
if ( $category->meta_keywords )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['keywords'] = $category->meta_keywords;
|
||||
}
|
||||
|
||||
/* Update location */
|
||||
$permissions = $category->permissions();
|
||||
\IPS\Session::i()->setLocation( $category->url(), explode( ",", $permissions['perm_view'] ), 'loc_cms_viewing_db_cat', array( 'content_db_' . $database->id => TRUE, 'content_cat_name_' . $category->id => TRUE ) );
|
||||
|
||||
@@ -84,11 +84,18 @@ class _topic extends \IPS\Dispatcher\Controller
|
||||
$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 this database does not have a title or content field, we cannot copy. */
|
||||
if ( !$row->field_title OR !$row->field_content )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* If this database is not on a page, then we cannot copy. */
|
||||
if ( !$row->page_id )
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return $row->can( 'add' );
|
||||
} ) ) );
|
||||
if ( $values = $form->values() )
|
||||
@@ -115,7 +122,7 @@ class _topic extends \IPS\Dispatcher\Controller
|
||||
|
||||
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 ) ) );
|
||||
\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 )->setQueryString( array( 'database_id' => $data['database_id'], 'category_id' => $database->default_category ) ) );
|
||||
}
|
||||
|
||||
$catClass = 'IPS\cms\Categories' . $data['database_id'];
|
||||
@@ -128,7 +135,7 @@ class _topic extends \IPS\Dispatcher\Controller
|
||||
|
||||
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 ) ) );
|
||||
\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 )->setQueryString( array( 'database_id' => $values['database_id'], 'category_id' => $values['select_category']->_id ) ) );
|
||||
}
|
||||
|
||||
return $form->customTemplate( array( \IPS\Theme::i()->getTemplate( 'forms', 'core' ), 'popupTemplate' ) );
|
||||
@@ -152,6 +159,15 @@ class _topic extends \IPS\Dispatcher\Controller
|
||||
\IPS\Output::i()->error( 'node_error', '2T353/2', 404, '' );
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$page = \IPS\cms\Pages\Page::load( $database->page_id );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
\IPS\Output::i()->error( 'node_error', '2T353/4', 404, '' );
|
||||
}
|
||||
|
||||
$recordClass = 'IPS\cms\Records' . $database->_id;
|
||||
$commentClass = 'IPS\cms\Comments' . $database->_id;
|
||||
$fieldClass = 'IPS\cms\Fields' . $database->_id;
|
||||
@@ -323,7 +339,7 @@ class _topic extends \IPS\Dispatcher\Controller
|
||||
\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( \IPS\cms\Theme::i()->getTemplate( $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 );
|
||||
\IPS\Output::i()->output = $form->customTemplate( array( \IPS\cms\Theme::i()->getTemplate( $database->template_form, 'cms', 'database' ), 'recordForm' ), NULL, $category, $database, $page, \IPS\Member::loggedIn()->language()->addToStack( 'copy_topic_to_database' ), $hasModOptions );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -23,128 +23,6 @@ if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
*/
|
||||
class _builder extends \IPS\core\modules\front\system\widgets
|
||||
{
|
||||
/**
|
||||
* Preview a block (from the ACP or elsewhere dynamically)
|
||||
*
|
||||
* @return html
|
||||
*/
|
||||
public function previewBlock()
|
||||
{
|
||||
if ( !\IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'blocks', 'block_manage' ) )
|
||||
{
|
||||
\IPS\Output::i()->error( 'no_module_permission', '3T419/1', 403, '' );
|
||||
}
|
||||
|
||||
$output = "";
|
||||
|
||||
if ( \IPS\Request::i()->_key )
|
||||
{
|
||||
try
|
||||
{
|
||||
$key = \IPS\Request::i()->_key;
|
||||
$data = \IPS\Data\Store::i()->$key;
|
||||
unset( \IPS\Data\Store::i()->$key );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
$data = array();
|
||||
}
|
||||
}
|
||||
|
||||
if ( isset( $data['block_plugin'] ) )
|
||||
{
|
||||
$block = new \IPS\cms\Blocks\Block;
|
||||
$block->type = "plugin";
|
||||
$block->plugin = $data['block_plugin'];
|
||||
$block->plugin_app = ( isset( $data['block_plugin_app'] ) ) ? $data['block_plugin_app'] : $data['block_app'];
|
||||
|
||||
if( isset( $data['block_plugin_plugin'] ) )
|
||||
{
|
||||
$block->plugin_plugin = $data['block_plugin_plugin'];
|
||||
}
|
||||
|
||||
$block->key = md5( mt_rand() );
|
||||
|
||||
$params = array();
|
||||
$block->content = NULL;
|
||||
|
||||
if ( isset( $data['_sending'] ) )
|
||||
{
|
||||
foreach( explode( ",", $data['_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( $data[ $field ] ) )
|
||||
{
|
||||
if ( $field == 'block_content' )
|
||||
{
|
||||
$block->content = $data[ $field ];
|
||||
|
||||
if ( isset( $data['template_params'] ) )
|
||||
{
|
||||
$block->template_params = $data['template_params'];
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if( mb_strpos( $field, "widget_feed_container_" ) !== FALSE )
|
||||
{
|
||||
/* On means that the all checkbox is ticked */
|
||||
$params[ 'widget_feed_container'] = $data[ $field ] == 'on' ? 0 : ( \is_array( $data[ $field ] ) ? $data[ $field ] : explode( ',', $data[ $field ] ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
/* We need to handle tags special */
|
||||
if( $field == 'widget_feed_tags' )
|
||||
{
|
||||
$params[ $field ] = $data[ $field ] ? explode( ',', $data[ $field ] ) : array();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* We need to handle authors special */
|
||||
if( $field == 'widget_feed_author' )
|
||||
{
|
||||
$params[ $field ] = $data[ $field ] ? array( \IPS\Member::load( $data[ $field ], 'name' )->member_id ) : array();
|
||||
continue;
|
||||
}
|
||||
|
||||
/* Is it an array? */
|
||||
if ( $isArray )
|
||||
{
|
||||
foreach( $data[ $field ] AS $multi )
|
||||
{
|
||||
$params[ $field ][] = $multi;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
$params[ $field ] = $data[ $field ];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$block->plugin_config = json_encode( $params );
|
||||
|
||||
/* Template stuffs */
|
||||
if ( $data['block_template_use_how'] == 'copy' )
|
||||
{
|
||||
$block->widget()->template( array( $block, 'getTemplate' ) );
|
||||
}
|
||||
|
||||
$output = $block->widget()->render();
|
||||
}
|
||||
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->blankTemplate( $output ), 200, 'text/html' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Output For Adding A New Block
|
||||
|
||||
Reference in new issue
Block a user