Version 4.1.2

This commit is contained in:
Neo committed 2025-12-19 05:32:19 -08:00
1 parent 3ba79295ee
commit 28bd025b35
1131 files changed
+63658 -20579

No files matched your search

@@ -131,6 +131,16 @@ class _databases extends \IPS\Node\Controller
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_database_add') )
),
);
/*if ( \IPS\Application::appIsEnabled('forums') )
{
\IPS\Output::i()->sidebar['actions']['promote'] = array(
'title' => 'cms_database_promote',
'icon' => 'comments',
'link' => \IPS\Http\Url::internal( 'app=cms&module=databases&controller=databases&do=promote' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_database_promote') )
);
}*/
$table->rowButtons = function( $row )
{
@@ -243,7 +253,7 @@ class _databases extends \IPS\Node\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( 'cms_database_add', $form, FALSE );
}
/**
/**
* Import from upload
*
* @return void
@@ -1055,7 +1065,45 @@ class _databases extends \IPS\Node\Controller
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( 'delete', $form, FALSE );
}
/**
* Promote
*
* @return void
*/
protected function promote()
{
$form = new \IPS\Helpers\Form( 'form', 'save' );
$form->add( new \IPS\Helpers\Form\YesNo( 'cms_promote_enabled', \IPS\Settings::i()->cms_promote_enabled, FALSE, array( 'togglesOn' => array( 'cms_promote_cat', 'cms_promote_groups' ) ) ) );
$form->add( new \IPS\Helpers\Form\Node( 'cms_promote_cat', \IPS\Settings::i()->cms_promote_cat ? \IPS\Settings::i()->cms_promote_cat : 0, FALSE, array(
'class' => '\IPS\cms\Selector\Databases',
'subnodes' => true,
), NULL, NULL, NULL, 'cms_promote_cat' ) );
$form->add( new \IPS\Helpers\Form\Select(
'cms_promote_groups',
\IPS\Settings::i()->cms_promote_groups != '' ? ( \IPS\Settings::i()->cms_promote_groups === '*' ? '*' : explode( ",", \IPS\Settings::i()->cms_promote_groups ) ) : '*',
FALSE,
array( 'options' => \IPS\Member\Group::groups(), 'multiple' => TRUE, 'parse' => 'normal', 'unlimited' => '*', 'unlimitedLang' => 'all' ),
NULL,
NULL,
NULL,
'cms_promote_groups'
) );
if ( $values = $form->values() )
{
$form->saveAsSettings();
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=databases&controller=databases" ), 'saved' );
}
/* Display */
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( \IPS\Member::loggedIn()->language()->addToStack('cms_pages_settings'), $form, FALSE );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cms_pages_settings');
}
/**
* Add/Edit
*
@@ -1078,7 +1126,7 @@ class _databases extends \IPS\Node\Controller
$form = new \IPS\Helpers\Form( 'form', 'save', NULL, array( 'data-controller' => 'cms.admin.databases.form' ) );
$form->addtab( 'content_database_form_details' );
$form->addTab( 'content_database_form_details' );
$form->add( new \IPS\Helpers\Form\Translatable( 'database_name', NULL, TRUE, array( 'app' => 'cms', 'key' => ( ! empty( $current ) ? "content_db_" . $current->id : NULL ) ) ) );
@@ -1126,13 +1174,15 @@ class _databases extends \IPS\Node\Controller
$templatesForm[ $template->group ] = $title;
break;
case 'category_articles':
case 'category_2_column_first_featured':
case 'category_2_column_image_feature':
case 'category_3_column_image_feature':
case 'category_3_column_first_featured':
$templatesFeatured[ $template->group ] = $title;
break;
}
}
$form->addSeparator();
$form->add( new \IPS\Helpers\Form\Radio( 'database_cat_index_type' , $current ? $current->cat_index_type : 0, FALSE, array(
'options' => array(
0 => 'database_display_index_as_categories',
@@ -1140,7 +1190,7 @@ class _databases extends \IPS\Node\Controller
),
'toggles' => array(
'0' => array( 'database_template_categories' ),
'1' => array( 'database_template_featured', 'database_featured_featured', 'database_featured_categories', 'database_featured_perpage', 'database_featured_pagination', 'database_featured_sort', 'database_featured_direction' )
'1' => array( $form->id . '_header_cms_articles_homepage_form', 'database_template_featured', 'database_featured_featured', 'database_featured_categories', 'database_featured_perpage', 'database_featured_pagination', 'database_featured_sort', 'database_featured_direction' )
)
), NULL, NULL, NULL, 'database_cat_index_type' ) );
@@ -1167,7 +1217,8 @@ class _databases extends \IPS\Node\Controller
}
}
$form->add( new \IPS\Helpers\Form\Select( 'database_template_categories', ! empty( $current ) ? $current->template_categories : NULL, FALSE, array( 'options' => $templatesCat ), NULL, NULL, NULL, 'database_template_categories' ) );
$form->addHeader("cms_articles_homepage_form");
$form->add( new \IPS\Helpers\Form\Select( 'database_template_featured', ! empty( $current ) ? $current->template_featured : NULL, FALSE, array( 'options' => $templatesFeatured ), NULL, NULL, NULL, 'database_template_featured' ) );
/* Featured settings */
@@ -1194,14 +1245,13 @@ class _databases extends \IPS\Node\Controller
)
), NULL, NULL, NULL, 'database_featured_direction' ) );
$form->addSeparator();
$form->addHeader( 'cms_database_form_display' );
$form->add( new \IPS\Helpers\Form\Select( 'database_template_categories', ! empty( $current ) ? $current->template_categories : NULL, FALSE, array( 'options' => $templatesCat ), NULL, NULL, NULL, 'database_template_categories' ) );
$form->add( new \IPS\Helpers\Form\Select( 'database_template_listing' , ! empty( $current ) ? $current->template_listing : NULL, FALSE, array( 'options' => $templatesList ) ) );
$form->add( new \IPS\Helpers\Form\Select( 'database_template_display' , ! empty( $current ) ? $current->template_display : NULL, FALSE, array( 'options' => $templatesDisplay ) ) );
$form->add( new \IPS\Helpers\Form\Select( 'database_template_form' , ! empty( $current ) ? $current->template_form : NULL, FALSE, array( 'options' => $templatesForm ) ) );
$form->addHeader( 'cms_database_form_display' );
$form->add( new \IPS\Helpers\Form\Text( 'database_key', ! empty( $current ) ? $current->key : FALSE, FALSE, array(), function( $val )
{
try
@@ -1240,7 +1290,7 @@ class _databases extends \IPS\Node\Controller
return true;
} ) );
$form->addtab( 'content_database_form_lang' );
$form->addTab( 'content_database_form_lang' );
$sl_Default = null;
$pl_Default = null;
@@ -1266,7 +1316,7 @@ class _databases extends \IPS\Node\Controller
$form->add( new \IPS\Helpers\Form\Translatable( 'database_lang_pu', $pu_Default, FALSE, array( 'app' => 'cms', 'key' => ( ! empty( $current ) ? "content_db_lang_pu_" . $current->id : NULL ) ) ) );
$form->add( new \IPS\Helpers\Form\Translatable( 'database_lang_ia', $ia_Default, FALSE, array( 'app' => 'cms', 'key' => ( ! empty( $current ) ? "content_db_lang_ia_" . $current->id : NULL ) ) ) );
$form->addtab( 'content_database_form_options' );
$form->addTab( 'content_database_form_options' );
$form->add( new \IPS\Helpers\Form\YesNo( 'database_all_editable' , $current ? $current->all_editable : FALSE, FALSE, array( 'togglesOff' => array( 'cms_bitoptions_indefinite_own_edit' ) ) ) );
$form->add( new \IPS\Helpers\Form\YesNo( 'cms_bitoptions_indefinite_own_edit' , $current ? $current->options['indefinite_own_edit'] : FALSE, FALSE, array(), NULL, NULL, NULL, 'cms_bitoptions_indefinite_own_edit' ) );
@@ -1335,6 +1385,10 @@ class _databases extends \IPS\Node\Controller
$thumbWidthHeight = $ffsettings['record_image']['thumb_dims'];
}
}
else
{
$recordImagesOn = TRUE;
}
$form->add( new \IPS\Helpers\Form\YesNo( 'database_record_image' , $recordImagesOn, FALSE, array( 'togglesOn' => array( 'fixed_field_setting__record_image__image_dims', 'fixed_field_setting__record_image__thumb_dims' ) ), NULL, NULL, NULL, 'database_record_image' ) );
$form->add( new \IPS\Helpers\Form\WidthHeight( 'fixed_field_setting__record_image__image_dims', ( $current AND $widthHeight !== NULL ) ? $widthHeight : array( 0, 0 ), FALSE, array( 'resizableDiv' => FALSE, 'unlimited' => array( 0, 0 ) ), NULL, NULL, NULL, 'fixed_field_setting__record_image__image_dims' ) );
@@ -1411,12 +1465,34 @@ class _databases extends \IPS\Node\Controller
}
}, NULL, NULL, 'page_name' );
}
if ( $name !== 'page_content' AND $name !== 'tab_content' )
{
$pageToggles[] = $name;
$pageFormFields[ $name ] = $field;
}
if ( $name === 'page_folder_id' )
{
$pageFormFields['page_type'] = new \IPS\Helpers\Form\Radio(
'page_type', 'builder', FALSE, array(
'options' => array(
'builder' => 'page_type_builder',
'html' => 'page_type_manual'
),
'descriptions' => array(
'builder' => 'page_type_builder_desc',
'html' => 'page_type_manual_custom_desc'
),
'toggles' => array(
'builder' => array( 'page_template' ),
'html' => array( 'page_show_sidebar', 'page_wrapper_template', 'page_ipb_wrapper' )
)
), NULL, NULL, NULL, 'page_type'
);
$pageToggles[] = 'page_type';
}
}
$form->add( new \IPS\Helpers\Form\Radio( 'database_create_page', 'existing', FALSE, array(
@@ -1652,8 +1728,6 @@ class _databases extends \IPS\Node\Controller
{
if ( $values['database_create_page'] === 'new' )
{
$values['page_content'] = '{database="' . $current->id . '"}';
$pageValues = array();
foreach( $values as $k => $v )
@@ -1664,7 +1738,23 @@ class _databases extends \IPS\Node\Controller
}
}
$pageId = \IPS\cms\Pages\Page::createFromForm( $pageValues, 'html' );
if ( $values['page_type'] === 'html' )
{
$pageValues['page_content'] = '{database="' . $current->id . '"}';
$pageValues['page_template'] = '';
}
$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'
) );
}
}
}
else
@@ -43,6 +43,15 @@ class _records extends \IPS\Dispatcher\Controller
*/
protected function manage()
{
/* There may be no database ID if the admin only has permission to view records and not the database list itself */
if ( !\IPS\Request::i()->database_id )
{
foreach ( \IPS\cms\Databases::databases() as $database )
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=databases&controller=records&do=manage&database_id=' . $database->_id ) );
}
}
$database = \IPS\cms\Databases::load( \IPS\Request::i()->database_id );
$title = \IPS\Member::loggedIn()->language()->addToStack('content_record_db_title', TRUE, array( 'sprintf' => array( $database->_title ) ) );
@@ -328,7 +337,7 @@ class _records extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form();
$form->addtab( 'content_database_record_tab_content' );
$form->addTab( 'content_database_record_tab_content' );
$formElements = $class::formElements( $current, $container );
@@ -353,7 +362,7 @@ class _records extends \IPS\Dispatcher\Controller
$form->add( $obj );
}
$form->addtab( 'content_database_record_tab_publish' );
$form->addTab( 'content_database_record_tab_publish' );
if ( isset( $formElements['record_publish_date'] ) )
{
@@ -364,18 +373,26 @@ class _records extends \IPS\Dispatcher\Controller
{
$form->add( $formElements['record_expiry_date'] );
}
$form->add( new \IPS\Helpers\Form\Radio( 'record_author_choice', $current ? ( $current->member_id === \IPS\Member::loggedIn()->member_id ? 'me' : 'notme' ) : 'me', FALSE, array(
'options' => array(
'me' => 'record_author_choice_me',
'notme' => 'record_author_choice_notme'
),
$currentMember = ( $current ? \IPS\Member::load( $current->member_id ) : NULL );
$options = array(
'me' => 'record_author_choice_me',
'notme' => 'record_author_choice_notme'
);
if ( $currentMember and ! $current->member_id )
{
$options['guest'] = 'record_author_choice_guest';
}
$form->add( new \IPS\Helpers\Form\Radio( 'record_author_choice', $currentMember ? ( $currentMember->member_id === \IPS\Member::loggedIn()->member_id ? 'me' : ( $currentMember->member_id ? 'notme' : 'guest' ) ) : 'me', FALSE, array(
'options' => $options,
'toggles' => array(
'notme' => array( 'record_member_id' )
)
), NULL, NULL, NULL, 'record_author_choice' ) );
$form->add( new \IPS\Helpers\Form\Member( 'record_member_id', ( $current ? \IPS\Member::load( $current->member_id ) : NULL ), FALSE, array(), NULL, NULL, NULL, 'record_member_id' ) );
$form->add( new \IPS\Helpers\Form\Member( 'record_member_id', ( $currentMember and $currentMember->member_id ) ? $currentMember : NULL, FALSE, array(), NULL, NULL, NULL, 'record_member_id' ) );
if ( isset( $formElements['record_allow_comments'] ) )
{
@@ -391,7 +408,7 @@ class _records extends \IPS\Dispatcher\Controller
if ( \IPS\Member::loggedIn()->modPermission('can_content_edit_meta_tags') )
{
$form->addtab( 'content_database_record_tab_meta' );
$form->addTab( 'content_database_record_tab_meta' );
$form->add( $formElements['record_meta_keywords'] );
$form->add( $formElements['record_meta_description'] );
}
@@ -435,13 +452,36 @@ 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 ) and $values['record_author_choice'] === 'notme' and ! empty( $values['record_member_id'] ) )
{
$changeAuthor = TRUE;
}
$changeAuthor = FALSE;
if ( ! empty( \IPS\Request::i()->id ) )
{
if ( $values['record_author_choice'] === 'guest' )
{
if ( $current->member_id )
{
$values['record_member_id'] = new \IPS\Member;
$changeAuthor = TRUE;
}
}
else if ( ! $current->member_id and $values['record_author_choice'] !== 'guest' )
{
$values['record_member_id'] = \IPS\Member::loggedIn();
$changeAuthor = TRUE;
}
else if ( $values['record_author_choice'] === 'notme' and ! empty( $values['record_member_id'] ) )
{
$changeAuthor = TRUE;
}
}
else
{
if ( $values['record_author_choice'] === 'notme' and ! empty( $values['record_member_id'] ) )
{
$changeAuthor = TRUE;
}
}
/* Just editing, thanks */
if ( ! $new )
{
@@ -90,7 +90,10 @@ class _ajax extends \IPS\Dispatcher\Controller
$templateBits = \IPS\Theme::master()->getRawTemplates( $location['app'], $location['location'], $location['group'], \IPS\Theme::RETURN_ALL );
$templateBit = $templateBits[ $location['app'] ][ $location['location'] ][ $location['group'] ][ $location['name'] ];
$templateBit['template_content'] = htmlentities( $templateBit['template_content'], \IPS\HTMLENTITIES, 'UTF-8', TRUE );
if ( ! isset( \IPS\Request::i()->noencode ) OR ! \IPS\Request::i()->noencode )
{
$templateBit['template_content'] = htmlentities( $templateBit['template_content'], \IPS\HTMLENTITIES, 'UTF-8', TRUE );
}
$templateArray = array(
'template_id' => $templateBit['template_id'],
@@ -132,7 +135,7 @@ class _ajax extends \IPS\Dispatcher\Controller
'template_key' => $template->key,
'template_title' => $template->title,
'template_desc' => $template->desc,
'template_content' => htmlentities( $template->content, \IPS\HTMLENTITIES, 'UTF-8', TRUE ),
'template_content' => ( isset( \IPS\Request::i()->noencode ) AND \IPS\Request::i()->noencode ) ? $template->content : htmlentities( $template->content, \IPS\HTMLENTITIES, 'UTF-8', TRUE ),
'template_location' => $template->location,
'template_group' => $template->group,
'template_container' => $template->container,
@@ -138,17 +138,22 @@ class _blocks extends \IPS\Node\Controller
}
catch ( \OutOfRangeException $e ) { }
}
$disabled = array();
foreach( \IPS\cms\Databases::databases() as $db )
{
if ( $db->page_id )
{
$plugins[ \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_title' ) ][ 'db_feed_' . $db->id ] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_block_with_name', NULL, array( 'sprintf' => array( $db->_title ) ) );
}
else
{
$disabled[] = 'db_feed_' . $db->id;
$plugins[ \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_title' ) ][ 'db_feed_' . $db->id ] = \IPS\Member::loggedIn()->language()->addToStack( 'cms_db_feed_block_with_name_disabled', NULL, array( 'sprintf' => array( $db->_title ) ) );
}
}
$form->add( new \IPS\Helpers\Form\Select( 'content_block_add_type_plugin', null, false, array( 'options' => $plugins ), NULL, NULL, NULL, 'content_block_add_type_plugin' ) );
$form->add( new \IPS\Helpers\Form\Select( 'content_block_add_type_plugin', null, false, array( 'options' => $plugins, 'disabled' => $disabled ), NULL, NULL, NULL, 'content_block_add_type_plugin' ) );
$form->add( new \IPS\Helpers\Form\Radio( 'content_block_add_custom_type', 'editor', TRUE, array(
'options' => array( 'editor' => 'content_block_add_custom_type_wysiwyg',
@@ -180,4 +185,18 @@ class _blocks extends \IPS\Node\Controller
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( \IPS\Member::loggedIn()->language()->addToStack('content_block_block_add'), $form, FALSE );
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('content_block_block_add');
}
/**
* View external embed options
*
* @return void
*/
public function embedOptions()
{
$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()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( '', \IPS\Theme::i()->getTemplate( 'blocks', 'cms', 'admin' )->embedCode( $block, $embedKey ) );;
}
}
@@ -0,0 +1,410 @@
<?php
/**
* @brief Pages Media Management
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2015 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Pages
* @since 07 Jul 2015
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\admin\pages;
/* 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;
}
/**
* media
*/
class _media extends \IPS\Node\Controller
{
/**
* Node Class
*/
protected $nodeClass = '\IPS\cms\Media\Folder';
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'media_manage' );
parent::execute();
}
/**
* Get Root Buttons
*
* @return array
*/
public function _getRootButtons()
{
$buttons = array();
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'pages', 'page_add' ) )
{
$buttons['add_folder'] = array(
'icon' => 'folder-open',
'title' => 'cms_add_media_folder',
'link' => \IPS\Http\Url::internal( 'app=cms&module=pages&controller=media&do=form' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_add_media_folder') )
);
$buttons['add_page'] = array(
'icon' => 'plus-circle',
'title' => 'cms_add_media',
'link' => \IPS\Http\Url::internal( 'app=cms&module=pages&controller=media&subnode=1&do=form' ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_add_media') )
);
}
return $buttons;
}
/**
* Delete many at once
*
* @return void
*/
public function deleteByFileIds()
{
if ( isset( \IPS\Request::i()->fileIds ) )
{
$ids = \IPS\Request::i()->fileIds;
if ( ! is_array( $ids ) )
{
$try = json_decode( $ids, TRUE );
if ( ! is_array( $try ) )
{
$ids = array( $ids );
}
else
{
$ids = $try;
}
}
if ( count( $ids ) )
{
\IPS\cms\Media::deleteByFileIds( $ids );
}
}
}
/**
* Show the pages tree
*
* @return string
*/
protected function manage()
{
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=media" );
/* Display the table */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__cms_pages_media');
$output = new \IPS\Helpers\Tree\Tree( $url, 'menu__cms_pages_media',
/* Get Roots */
function () use ( $url )
{
$data = \IPS\cms\modules\admin\pages\media::getRowsForTree( 0 );
$rows = array();
foreach ( $data as $id => $row )
{
if( ( \IPS\Request::i()->isAjax() && $row instanceof \IPS\cms\Media ) || !\IPS\Request::i()->isAjax() )
{
$rows[ $id ] = ( $row instanceof \IPS\cms\Media) ? \IPS\cms\modules\admin\pages\media::getItemRow( $row, $url ) : \IPS\cms\modules\admin\pages\media::getFolderRow( $row, $url );
}
}
if( \IPS\Request::i()->isAjax() ){
\IPS\Output::i()->sendOutput( json_encode( $rows ), 200, 'application/json', \IPS\Output::i()->httpHeaders );
}
return $data;
},
/* Get Row */
function ( $id, $root ) use ( $url )
{
if ( $root )
{
return \IPS\cms\modules\admin\pages\media::getFolderRow( \IPS\cms\Media\Folder::load( $id ), $url );
}
else
{
return \IPS\cms\modules\admin\pages\media::getItemRow( \IPS\cms\Media::load( $id ), $url );
}
},
/* Get Row Parent ID*/
function ()
{
return NULL;
},
/* Get Children */
function ( $id ) use ( $url )
{
$rows = array();
$data = \IPS\cms\modules\admin\pages\media::getRowsForTree( $id );
if ( ! isset( \IPS\Request::i()->subnode ) )
{
foreach ( $data as $id => $row )
{
if( \IPS\Request::i()->get == 'folders' && !( $row instanceof \IPS\cms\Media ) )
{
$rows[ $id ] = \IPS\cms\modules\admin\pages\media::getFolderRow( $row, $url );
}
elseif ( \IPS\Request::i()->get == 'files' && $row instanceof \IPS\cms\Media )
{
$rows[ $id ] = \IPS\cms\modules\admin\pages\media::getItemRow( $row, $url );
}
}
}
if( \IPS\Request::i()->isAjax() ){
\IPS\Output::i()->sendOutput( json_encode( $rows ), 200, 'application/json', \IPS\Output::i()->httpHeaders );
}
return $rows;
},
array( $this, '_getRootButtons' ),
TRUE,
FALSE,
FALSE
);
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, \IPS\Output::i()->js( 'admin_media.js', 'cms' ) );
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'media/media.css', 'cms', 'admin' ) );
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( $output, 200, 'text/html', \IPS\Output::i()->httpHeaders );
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'media', 'cms', 'admin' )->media( $output );
}
}
/**
* Upload items
*
* @return void
*/
public function upload()
{
$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' ) );
if ( ! isset( \IPS\Request::i()->media_parent ) and ! \IPS\Request::i()->media_parent )
{
$form->add( new \IPS\Helpers\Form\Node( 'media_parent', 0, FALSE, array(
'class' => '\IPS\cms\Media\Folder',
'zeroVal' => 'node_no_parent'
) ) );
}
else
{
$form->hiddenValues['media_parent_inline'] = \IPS\Request::i()->media_parent;
}
if ( $values = $form->values() )
{
$parent = 0;
$count = 0;
if ( isset( $values['media_parent_inline'] ) AND $values['media_parent_inline'] )
{
$parent = $values['media_parent_inline'];
}
else
{
if ( isset( $values['media_parent'] ) AND ( ! empty( $values['media_parent'] ) OR $values['media_parent'] === 0 ) )
{
$parent = ( $values['media_parent'] === 0 ) ? 0 : $values['media_parent']->id;
}
}
foreach( $values['media_filename'] as $media )
{
$filename = $media->originalFilename;
$prefix = $parent . '_';
if ( mb_strstr( $filename, $prefix ) )
{
$filename = mb_substr( $filename, mb_strlen( $prefix ) );
}
$new = new \IPS\cms\Media;
$new->filename = $filename;
$new->filename_stored = $parent . '_' . $filename;
$new->is_image = $media->isImage();
$new->parent = $parent;
$new->added = time();
$new->file_object = (string) \IPS\File::create( 'cms_Media', $new->filename_stored, $media->contents(), 'pages_media', TRUE, NULL, FALSE );
$new->save();
$new->setFullPath( ( $parent ? \IPS\cms\Media\Folder::load( $parent )->path : '' ) );
$new->save();
$count++;
}
if ( \IPS\Request::i()->isAjax() )
{
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=media" );
$data = \IPS\cms\modules\admin\pages\media::getRowsForTree( $parent );
$rows = array();
foreach ( $data as $id => $row )
{
if ( $row instanceof \IPS\cms\Media )
{
$rows[ $id ] = \IPS\cms\modules\admin\pages\media::getItemRow( $row, $url );
}
}
\IPS\Output::i()->sendOutput( json_encode( array( 'count' => $count, 'folderID' => $parent, 'rows' => $rows ) ), 200, 'application/json', \IPS\Output::i()->httpHeaders );
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=media' ) );
}
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( 'upload', $form, FALSE );
}
/**
* Tree Search
*
* @return void
*/
protected function search()
{
$rows = array();
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=media" );
/* Get results */
$items = \IPS\cms\Media::search( 'media_filename', \IPS\Request::i()->input, 'media_filename' );
/* Convert to HTML */
foreach ( $items as $id => $result )
{
$rows[ $id ] = $this->getItemRow( $result, $url );
}
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->sendOutput( json_encode( $rows ), 200, 'application/json', \IPS\Output::i()->httpHeaders );
}
else
{
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'trees', 'core' )->rows( $rows, '' );
}
}
/**
* Returns a JSON object with some file information
*
* @return void
*/
protected function getFileInfo()
{
try
{
$row = \IPS\cms\Media::load( \IPS\Request::i()->id );
$fileObject = \IPS\File::get( 'cms_Media', $row->file_object );
}
catch( \OutOfRangeException $ex )
{
return;
}
/* Make a human-readable size */
$filesize = \IPS\Output\Plugin\Filesize::humanReadableFilesize( $fileObject->filesize() );
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( $filesize );
$output = array(
'fileSize' => $filesize,
'dimensions' => NULL
);
/* If this is an image we'll also show the dimensions */
if( $row->is_image )
{
$dimensions = $fileObject->getImageDimensions();
$output['dimensions'] = $dimensions[0] . ' x ' . $dimensions[1];
}
\IPS\Output::i()->sendOutput( json_encode( $output ), 200, 'application/json', \IPS\Output::i()->httpHeaders );
}
/**
* Return HTML for a page row
*
* @param array $row Row data
* @param object $url \IPS\Http\Url object
* @return string HTML
*/
public static function getItemRow( $item, $url )
{
return \IPS\Theme::i()->getTemplate( 'media', 'cms', 'admin' )->fileListing( $url, $item );
}
/**
* Return HTML for a folder row
*
* @param array $row Row data
* @param object $url \IPS\Http\Url object
* @return string HTML
*/
public static function getFolderRow( $folder, $url )
{
return \IPS\Theme::i()->getTemplate( 'media', 'cms', 'admin' )->folderRow( $url, $folder );
}
/**
* Fetch rows of folders/pages
*
* @param int $folderId Parent ID to fetch from
*/
public static function getRowsForTree( $folderId=0 )
{
try
{
if ( $folderId === 0 )
{
$folders = \IPS\cms\Media\Folder::roots();
}
else
{
$folders = \IPS\cms\Media\Folder::load( $folderId )->children( NULL, NULL, FALSE );
}
}
catch( \OutOfRangeException $ex )
{
$folders = array();
}
$media = \IPS\cms\Media::getChildren( $folderId );
return \IPS\cms\Media\Folder::munge( $folders, $media );
}
}
@@ -1,69 +0,0 @@
<?php
/**
* @brief Page menu Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @since 15 Sept 2014
* @version SVN_VERSION_NUMBER
*/
namespace IPS\cms\modules\admin\pages;
/* 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;
}
/**
* Page management
*/
class _menu extends \IPS\Node\Controller
{
/**
* Node Class
*/
protected $nodeClass = '\IPS\cms\Pages\Menu';
/**
* Execute
*
* @return void
*/
public function execute()
{
\IPS\Dispatcher::i()->checkAcpPermission( 'menu_manage' );
parent::execute();
}
/**
* Show the pages tree
*
* @return string
*/
protected function manage()
{
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__cms_pages_menu');
if ( ! \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'global' )->message( \IPS\Member::loggedIn()->language()->addToStack('cms_menu_information'), 'information', NULL, FALSE );
}
return parent::manage();
}
/**
* Delete
*
* @return void
*/
protected function delete()
{
unset( \IPS\Data\Store::i()->cms_menu );
parent::delete();
}
}
+14 -6
View File
@@ -153,7 +153,7 @@ class _pages extends \IPS\Node\Controller
$options = array();
$url['path'] = preg_replace( '#^/?(.+?)?/?$#', '\1', $url['path'] );
$disabled = ( $url['path'] ) ? FALSE : TRUE;
$disabled = ( \IPS\Settings::i()->cms_use_different_gateway or $url['path'] ) ? FALSE : TRUE;
$dirs = explode( '/', $url['path'] );
if ( count( $dirs ) )
@@ -213,13 +213,21 @@ class _pages extends \IPS\Node\Controller
}
}, NULL, NULL, 'cms_root_page_url' ) );
$form->add( new \IPS\Helpers\Form\Node( 'cms_error_page', \IPS\Settings::i()->cms_error_page ? \IPS\Settings::i()->cms_error_page : 0, FALSE,array(
'class' => '\IPS\cms\Pages\Page',
'zeroVal' => 'cms_error_page_none',
'subnodes' => true,
'permissionCheck' => function( $node )
{
return $node->type == 'html';
}
) ) );
if ( $values = $form->values() )
{
$form->saveAsSettings();
\IPS\Member::clearCreateMenu();
\IPS\cms\Pages\Menu::clearCaches();
/* Clear Sidebar Caches */
\IPS\Widget::deleteCaches();
@@ -231,7 +239,7 @@ class _pages extends \IPS\Node\Controller
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cms_pages_settings');
}
/**
/**
* Download .htaccess file
*
* @return void
@@ -344,7 +352,7 @@ FILE;
/* Convert to HTML */
foreach ( $results as $id => $result )
{
$rows[ $id ] = ( $result instanceof \IPS\cms\Pages\Page ) ? $this->_getPageRow( $result, $url ) : $this->_getFolderRow( $result, $url );
$rows[ $id ] = ( $result instanceof \IPS\cms\Pages\Page ) ? $this->getPageRow( $result, $url ) : $this->getFolderRow( $result, $url );
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'trees', 'core' )->rows( $rows, '' );
@@ -46,7 +46,292 @@ class _templates extends \IPS\Dispatcher\Controller
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates' ), 'completed' );
}
/**
* Import dialog
*
* @return void
*/
public function import()
{
$form = new \IPS\Helpers\Form( 'form', 'next' );
$form->add( new \IPS\Helpers\Form\Upload( 'cms_templates_import', NULL, FALSE, array( 'allowedFileTypes' => array( 'xml' ), 'temporary' => TRUE ), NULL, NULL, NULL, 'cms_templates_import' ) );
if ( $values = $form->values() )
{
if ( $values['cms_templates_import'] )
{
/* Move it to a temporary location */
$tempFile = tempnam( \IPS\TEMP_DIRECTORY, 'IPS' );
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 ) ) );
}
else
{
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&do=manage' ) );
}
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( 'cms_templates_import_title', $form, FALSE );
}
/**
* Import from upload
*
* @return void
*/
public function importProcess()
{
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, '' );
}
/* Open XML file */
$xml = new \XMLReader;
$xml->open( \IPS\Request::i()->file );
$prefix = date('m') . '.' . date('d') . '.' . date('y') . '_';
if ( ! @$xml->read() )
{
\IPS\Output::i()->error( 'xml_upload_invalid', '2C163/1', 403, '' );
}
$xml->read();
while ( $xml->read() )
{
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();
foreach( $node->attributes() as $k => $v )
{
$attrs[ $k ] = (string) $v;
}
/* Any kids of your own? */
foreach( $node->children() as $k => $v )
{
$tryJson = json_decode( $v, TRUE );
$attrs[ $k ] = ( $tryJson ) ? $tryJson : (string) $v;
}
if ( isset( $attrs['template_title'] ) and isset( $attrs['template_location'] ) and isset( $attrs['template_group'] ) )
{
/* Got this template? */
if ( $attrs['template_location'] === 'database' )
{
/* Database templates are really governed by the group as they are a collection of templates */
if ( isset( $templates['cms'][$attrs['template_location']][$attrs['template_group']] ) )
{
$attrs['template_group'] = $prefix . $attrs['template_group'];
}
}
else
{
/* But post and block templates are not */
if ( isset( $templates['cms'][$attrs['template_location']][$attrs['template_group']] ) )
{
$exists = FALSE;
foreach ( $templates['cms'][$attrs['template_location']][$attrs['template_group']] as $key => $template )
{
if ( $template['template_title'] === $attrs['template_title'] )
{
$exists = TRUE;
break;
}
}
if ( $exists )
{
$attrs['template_title'] = $prefix . $attrs['template_title'];
}
}
}
$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->type = 'template';
$obj->user_created = 1;
$obj->user_edited = 1;
$obj->desc = '';
$obj->save();
$obj->key = $obj->location . \IPS\Http\Url::seoTitle( $obj->group ) . '_' . \IPS\Http\Url::seoTitle( $obj->title ) . '_' . $obj->id;
$obj->save();
}
}
$xml->next();
}
/* Done */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&do=manage' ), 'cms_templates_imported' );
}
/**
* Export templates
*
* @return void
*/
public function export()
{
$form = new \IPS\Helpers\Form( 'form', 'next' );
$templates = array();
$form->addMessage( 'cms_templates_export_description', 'ipsMessage ipsMessage_information' );
foreach( \IPS\cms\Templates::getTemplates( \IPS\cms\Templates::RETURN_DATABASE_ONLY + \IPS\cms\Templates::RETURN_ALL ) as $template )
{
$title = \IPS\cms\Templates::readableGroupName( $template->group );
if ( $template->location === 'database' )
{
$templates['database'][ $template->group ] = $title;
}
else if ( $template->location === 'block' )
{
$templates['block'][ $template->key ] = $title . ' &gt; ' . $template->title;
}
else if ( $template->location === 'page' )
{
$templates['page'][ $template->key ] = $title . ' &gt; ' . $template->title;
}
}
foreach( $templates as $location => $data )
{
$form->add( new \IPS\Helpers\Form\CheckboxSet( 'templates_' . $location, FALSE, FALSE, array( 'options' => $data ) ) );
}
if ( $values = $form->values() )
{
$exportTemplates = array();
foreach( $templates as $location => $data )
{
if ( isset( $values[ 'templates_' . $location ] ) and count( $values[ 'templates_' . $location ] ) )
{
if ( $location === 'database' )
{
$tmp = \IPS\cms\Theme::i()->getRawTemplates( 'cms', array('database'), array_values( $values[ 'templates_' . $location ] ) );
foreach( $tmp['cms'] as $loc => $data )
{
if ( $loc === $location )
{
foreach ( $data as $key => $tdata )
{
foreach ( $tdata as $tkey => $tkdata )
{
$exportTemplates['cms'][ $location ][ $key ][ $tkey ] = $tkdata;
}
}
}
}
}
else
{
$tmp = \IPS\cms\Theme::i()->getRawTemplates( 'cms', array( $location ), NULL, \IPS\cms\Theme::RETURN_DATABASE_ONLY + \IPS\cms\Theme::RETURN_ALL );
foreach( $tmp['cms'] as $loc => $data )
{
if ( $loc === $location )
{
foreach( $data as $key => $tdata )
{
foreach( $tdata as $tkey => $tkdata )
{
if ( in_array( $tkey, $values[ 'templates_' . $location ] ) )
{
$exportTemplates['cms'][ $location ][ $key ][ $tkey ] = $tkdata;
}
}
}
}
}
}
}
}
if ( count( $exportTemplates ) )
{
/* Init */
$xml = new \XMLWriter;
$xml->openMemory();
$xml->setIndent( TRUE );
$xml->startDocument( '1.0', 'UTF-8' );
/* Root tag */
$xml->startElement('templates');
foreach ( $exportTemplates as $app => $location )
{
foreach ( $location as $key => $data )
{
foreach ( $data as $group => $template )
{
foreach( $template as $key => $templateData )
{
/* Initiate the <template> tag */
$xml->startElement( 'template' );
foreach ( $templateData as $k => $v )
{
if ( ! in_array( \substr( $k, 9 ), array( 'content', 'params' ) ) )
{
$xml->startAttribute( $k );
$xml->text( $v );
$xml->endAttribute();
}
}
/* Write (potential) HTML fields */
foreach( array( 'template_params', 'template_content' ) as $field )
{
if ( isset( $templateData[ $field ] ) )
{
$xml->startElement( $field );
if ( preg_match( '/<|>|&/', $templateData[ $field ] ) )
{
$xml->writeCData( str_replace( ']]>', ']]]]><![CDATA[>', $templateData[ $field ] ) );
}
else
{
$xml->text( $templateData[ $field ] );
}
$xml->endElement();
}
}
/* Close the <template> tag */
$xml->endElement();
}
}
}
}
/* Finish */
$xml->endDocument();
\IPS\Output::i()->sendOutput( $xml->outputMemory(), 200, 'application/xml', array( 'Content-Disposition' => \IPS\Output::getContentDisposition( 'attachment', "pages_templates.xml" ) ) );
}
else
{
\IPS\Output::i()->error( 'cms_no_templates_selected', '1T285/1', 403, '' );
}
}
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( 'cms_templates_export_title', $form, FALSE );
}
/**
* List templates
*
@@ -143,6 +428,20 @@ class _templates extends \IPS\Dispatcher\Controller
);
}
\IPS\Output::i()->sidebar['actions']['download'] = array(
'icon' => 'download',
'title' => 'cms_templates_export_title',
'link' => \IPS\Http\Url::internal( "app=cms&module=pages&controller=templates&do=export" ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_templates_export_title') )
);
\IPS\Output::i()->sidebar['actions']['upload'] = array(
'icon' => 'upload',
'title' => 'cms_templates_import_title',
'link' => \IPS\Http\Url::internal( "app=cms&module=pages&controller=templates&do=import" ),
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_templates_import_title') )
);
\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' ) );
@@ -214,7 +513,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 ) );
$form->add( new \IPS\Helpers\Form\Text( 'template_title', NULL, TRUE, array( 'regex' => '/^([A-Z0-9_]+?)$/i' ) ) );
/* Very specific */
if ( $type === 'database' )
@@ -570,7 +869,10 @@ class _templates extends \IPS\Dispatcher\Controller
/* Clear guest page caches */
\IPS\Data\Cache::i()->clearAll();
/* Clear block caches */
\IPS\cms\Blocks\Block::deleteCompiled();
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( array( 'template_id' => $obj->id, 'template_title' => $obj->title, 'template_container' => $obj->container, 'template_user_added' => $obj->user_created ) );
@@ -22,7 +22,7 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
/**
* Ajax only methods
*/
class _ajax extends \IPS\Content\Controller
class _ajax extends \IPS\Dispatcher\Controller
{
/**
* Return a FURL
@@ -33,5 +33,42 @@ class _ajax extends \IPS\Content\Controller
{
return \IPS\Output::i()->json( array( 'slug' => \IPS\Http\Url::seoTitle( \IPS\Request::i()->slug ) ) );
}
/**
* Find Record
*
* @retun void
*/
public function findRecord()
{
$results = array();
$database = \IPS\cms\Databases::load( \IPS\Request::i()->id );
$input = mb_strtolower( \IPS\Request::i()->input );
$field = "field_" . $database->field_title;
$class = '\IPS\cms\Records' . $database->id;
$category = '';
$where = array( $field . " LIKE CONCAT('%', ?, '%')" );
$binds = array( $input );
foreach ( \IPS\Db::i()->select( '*', 'cms_custom_database_' . $database->id, array_merge( array( implode( ' OR ', $where ) ), $binds ), 'LENGTH(' . $field . ') ASC', array( 0, 20 ) ) as $row )
{
$record = $class::constructFromData( $row );
if ( $database->use_categories )
{
$category = \IPS\Member::loggedIn()->language()->addToStack( 'cms_autocomplete_category', NULL, array( 'sprintf' => array( $record->container()->_title ) ) );
}
$results[] = array(
'id' => $record->_id,
'value' => $record->_title,
'category' => $category,
'date' => \IPS\DateTime::ts( $record->record_publish_date )->html(),
);
}
\IPS\Output::i()->json( $results );
}
}
@@ -24,6 +24,13 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
class _category extends \IPS\cms\Databases\Controller
{
/**
* Store any active filters for this view
*
* @param array
*/
static public $activeFilters = array();
/**
* Determine which method to load
*
@@ -86,7 +93,6 @@ class _category extends \IPS\cms\Databases\Controller
}
/* Check cookie */
$activeFilters = array();
$where = array();
$cookie = $category->getFilterCookie();
if ( $cookie !== NULL )
@@ -120,7 +126,8 @@ class _category extends \IPS\cms\Databases\Controller
$where[] = array( mb_substr( $k, 8 ) . "=?", $v );
}
}
$activeFilters[ $f ] = array( 'field' => $customFields[ $f ], 'value' => $customFields[ $f ]->displayValue( $v ) );
static::$activeFilters[ $f ] = array( 'field' => $customFields[ $f ], 'value' => $customFields[ $f ]->displayValue( $v ) );
}
}
}
@@ -130,7 +137,7 @@ class _category extends \IPS\cms\Databases\Controller
$where = NULL;
}
$table = new \IPS\Helpers\Table\Content( 'IPS\cms\Records' . \IPS\cms\Databases\Dispatcher::i()->databaseId, $category->url(), $where, $category, NULL );
$table = new \IPS\Helpers\Table\Content( 'IPS\cms\Records' . \IPS\cms\Databases\Dispatcher::i()->databaseId, $category->url(), $where, $category, NULL, 'view', isset( \IPS\Request::i()->rss ) ? FALSE : TRUE );
$table->tableTemplate = array( \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' ), 'categoryTable' );
$table->rowsTemplate = array( \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' ), 'recordRow' );
$table->baseUrl = $table->baseUrl->setQueryString( 'd', \IPS\cms\Databases\Dispatcher::i()->databaseId );
@@ -231,8 +238,8 @@ class _category extends \IPS\cms\Databases\Controller
$table->advancedSearch = array(
'record_type' => array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => $filterOptions ) ),
'sortby' => array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => $sortBy ) ),
'sortdirection' => array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => array(
'sort_by' => array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => $sortBy ) ),
'sort_direction' => array( \IPS\Helpers\Table\SEARCH_SELECT, array( 'options' => array(
'asc' => 'asc',
'desc' => 'desc',
) )
@@ -246,13 +253,13 @@ class _category extends \IPS\cms\Databases\Controller
{
\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 ) );
$table->advancedSearch['sortby'][1]['options']['field_' . $obj->id ] = 'content_field_' . $obj->id;
$table->advancedSearch['sort_by'][1]['options']['field_' . $obj->id ] = 'content_field_' . $obj->id;
}
$table->sortOptions[ 'field_' . $obj->id ] = 'field_' . $obj->id;
}
$table->advancedSearchCallback = function( $table, $values ) use ( $database, $sortBy )
$table->advancedSearchCallback = function( $table, $values ) use ( $database, $sortBy, $customFields )
{
/* Type */
foreach( $values as $k => $v )
@@ -286,6 +293,9 @@ class _category extends \IPS\cms\Databases\Controller
}
}
}
$key = mb_substr( $k, 14 );
\IPS\cms\modules\front\database\category::$activeFilters[ $key ] = array( 'field' => $customFields[ $key ], 'value' => $customFields[ $key ]->displayValue( $v ) );
}
}
@@ -303,10 +313,10 @@ class _category extends \IPS\cms\Databases\Controller
}
/* Sort */
if ( isset( $values['sortby'] ) and isset( $sortBy[ $values['sortby'] ] ) )
if ( isset( $values['sort_by'] ) and isset( $sortBy[ $values['sort_by'] ] ) )
{
$table->sortBy = $values['sortby'];
$table->sortDirection = $values['sortdirection'];
$table->sortBy = $values['sort_by'];
$table->sortDirection = $values['sort_direction'];
}
/* Cutoff */
@@ -374,7 +384,14 @@ class _category extends \IPS\cms\Databases\Controller
{
if ( ! $record->hidden() )
{
$document->addItem( $record->_title, $record->url(), $record->$contentField, \IPS\DateTime::ts( $record->record_last_comment ), $record->_id );
$content = $record->$contentField;
if ( $record->record_image )
{
$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 );
}
}
@@ -389,14 +406,14 @@ 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, $activeFilters );
\IPS\cms\Databases\Dispatcher::i()->output .= \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' )->categoryHeader( $category, (string) $table, 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 .= \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' )->categoryFooter( $category, (string) $table, $activeFilters );
\IPS\cms\Databases\Dispatcher::i()->output .= \IPS\cms\Theme::i()->getTemplate( $category->_template_listing, 'cms', 'database' )->categoryFooter( $category, (string) $table, static::$activeFilters );
}
/**
@@ -428,7 +445,9 @@ class _category extends \IPS\cms\Databases\Controller
$hasModOptions = TRUE;
}
\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\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' ) );
@@ -96,17 +96,17 @@ 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', FALSE, 0, NULL, FALSE, FALSE, FALSE, FALSE );
$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 ( $database->featured_settings['pagination'] )
{
$count = $recordClass::getItemsWithPermission( $where, 'record_pinned DESC, ' . $database->featured_settings['sort'] . ' ' . $database->featured_settings['direction'], $database->featured_settings['perpage'], 'read', FALSE, 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', NULL, 0, NULL, FALSE, FALSE, FALSE, TRUE );
}
/* Pagination */
$pagination = array(
'page' => $page,
'pages' => ( $count > 0 ) ? ceil( $count['cnt'] / $database->featured_settings['perpage'] ) : 1
'pages' => ( $count > 0 ) ? ceil( $count / $database->featured_settings['perpage'] ) : 1
);
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'database_index/featured.css', 'cms', 'front' ) );
@@ -56,12 +56,12 @@ class _record extends \IPS\Content\Controller
}
catch( \Exception $e )
{
\IPS\Output::i()->error( 'node_error', '3T252/1', 403, '' );
\IPS\Output::i()->error( 'node_error', '2T252/1', 403, '' );
}
if ( $record === NULL )
{
\IPS\Output::i()->error( 'node_error', '3T252/2', 403, '' );
\IPS\Output::i()->error( 'node_error', '2T252/2', 404, '' );
}
if ( \IPS\Request::i()->view )
@@ -86,8 +86,9 @@ class _record extends \IPS\Content\Controller
$FieldsClass = '\\IPS\\cms\\Fields' . $record::$customDatabaseId;
$updateFields = $FieldsClass::fields( $record->fieldValues(), 'edit', $record->container(), $FieldsClass::FIELD_SKIP_TITLE_CONTENT | $FieldsClass::FIELD_DISPLAY_COMMENTFORM );
$form = null;
if ( count( $updateFields ) )
/* We need edit permission to change the record */
if ( count( $updateFields ) and $record->canEdit() )
{
$form = new \IPS\Helpers\Form( 'update_record', 'update', $record->url()->setQueryString( array( 'd' => $record::$customDatabaseId ) ) );
$form->class = 'ipsForm_vertical';
@@ -101,11 +102,6 @@ class _record extends \IPS\Content\Controller
if ( $values = $form->values() )
{
if ( ! $record->canEdit() )
{
\IPS\Output::i()->error( 'module_no_permission', '2T252/3', 403, '' );
}
/* Custom fields */
$customValues = array();
$fieldsClass = 'IPS\cms\Fields' . $record::$customDatabaseId;
@@ -528,8 +524,10 @@ class _record extends \IPS\Content\Controller
\IPS\Output::i()->redirect( $record->url() );
}
\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\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' ) );
@@ -60,6 +60,13 @@ class _builder extends \IPS\core\modules\front\system\widgets
}
continue;
}
if( mb_strpos( $field, "widget_feed_container_" ) !== FALSE )
{
/* On means that the all checkbox is ticked */
$params[ 'widget_feed_container'] = \IPS\Request::i()->$field == 'on' ? 0 : \IPS\Request::i()->$field;
continue;
}
$params[ $field ] = \IPS\Request::i()->$field;
}
+18 -96
View File
@@ -40,6 +40,19 @@ 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();
}
@@ -61,105 +74,14 @@ class _page extends \IPS\Dispatcher\Controller
return;
}
$includes = $page->getIncludes();
if ( isset( $includes['js'] ) and is_array( $includes['js'] ) )
if ( \IPS\Request::i()->path == $page->full_path )
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, array_values( $includes['js'] ) );
/* Just viewing this page, no database categories or records */
$permissions = $page->permissions();
\IPS\Session::i()->setLocation( $page->url(), explode( ",", $permissions['perm_view'] ), 'loc_cms_viewing_page', array( 'cms_page_' . $page->_id => TRUE ) );
}
/* Display */
if ( $page->ipb_wrapper or $page->type === 'builder' )
{
$page->setTheme();
$nav = array();
\IPS\Output::i()->title = $page->getHtmlTitle();
/* This has to be done after setTheme(), otherwise \IPS\Theme::switchTheme() can wipe out CSS includes */
if ( isset( $includes['css'] ) and is_array( $includes['css'] ) )
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, array_values( $includes['css'] ) );
}
if ( $page->type === 'builder' )
{
list( $group, $name, $key ) = explode( '__', $page->template );
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('pages')->globalWrap( $nav, \IPS\cms\Theme::i()->getTemplate($group, 'cms', 'page')->$name( $page, $page->getWidgets() ), $page );
}
else
{
/* Populate \IPS\Output::i()->sidebar['widgets'] sidebar/header/footer widgets */
$page->getWidgets();
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('pages')->globalWrap( $nav, $page->getHtmlContent(), $page );
}
\IPS\Output::i()->sidebar['enabled'] = true;
/* Set the meta tags, but do not reset them if they are already set - articles can define custom meta tags and this code
overwrites the ones set by articles if we don't verify they aren't set first */
if ( $page->meta_keywords AND ( !isset( \IPS\Output::i()->metaTags['keywords'] ) OR !\IPS\Output::i()->metaTags['keywords'] ) )
{
\IPS\Output::i()->metaTags['keywords'] = $page->meta_keywords;
}
if ( $page->meta_description AND ( !isset( \IPS\Output::i()->metaTags['description'] ) OR !\IPS\Output::i()->metaTags['description'] ) )
{
\IPS\Output::i()->metaTags['description'] = $page->meta_description;
}
/* Can only disable sidebar if HTML page */
if ( ! $page->show_sidebar and $page->type === 'html' )
{
\IPS\Output::i()->sidebar['enabled'] = false;
}
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, \IPS\Theme::i()->css( 'pages/page.css', 'cms', 'front' ) );
if ( \IPS\Request::i()->path == $page->full_path )
{
/* Just viewing this page, no database categories or records */
$permissions = $page->permissions();
\IPS\Session::i()->setLocation( $page->url(), explode( ",", $permissions['perm_view'] ), 'loc_cms_viewing_page', array( 'cms_page_' . $page->_id => TRUE ) );
}
if ( ! ( \IPS\Application::load('cms')->default AND ! $page->folder_id AND $page->default ) )
{
\IPS\Output::i()->breadcrumb['module'] = array( $page->url(), $page->_title );
}
\IPS\Output::i()->allowDefaultWidgets = FALSE;
/* Let the dispatcher finish off and show page */
return;
}
else
{
if ( isset( $includes['css'] ) and is_array( $includes['css'] ) )
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, array_values( $includes['css'] ) );
}
if ( $page->wrapper_template and $page->wrapper_template !== '_none_' and ! \IPS\Request::i()->isAjax() )
{
try
{
list( $group, $name, $key ) = explode( '__', $page->wrapper_template );
\IPS\Output::i()->sendOutput( \IPS\cms\Theme::i()->getTemplate($group, 'cms', 'page')->$name( $page->getHtmlContent(), $page->getHtmlTitle() ), 200, $page->getContentType(), \IPS\Output::i()->httpHeaders );
}
catch( \OutOfRangeException $e )
{
}
}
/* Set the title */
\IPS\Output::i()->title = $page->getHtmlTitle();
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( \IPS\Output::i()->title );
/* Send straight to the output engine */
\IPS\Output::i()->sendOutput( $page->getHtmlContent(), 200, $page->getContentType(), \IPS\Output::i()->httpHeaders );
}
$page->output();
}
/**