Version 4.1.19

This commit is contained in:
Neo committed 2025-12-19 05:38:56 -08:00
1 parent 28bd025b35
commit 2bd5025018
2674 files changed
+233518 -77766

No files matched your search

+11 -3
View File
@@ -2,9 +2,10 @@
/**
* @brief Customization AJAX actions
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 07 May 2013
* @version SVN_VERSION_NUMBER
*/
@@ -83,7 +84,14 @@ class _ajax extends \IPS\Dispatcher\Controller
if ( $t_location === 'block' and $t_key === '_default_' and isset( \IPS\Request::i()->block_key ) )
{
/* Find it from the normal template system */
$plugin = \IPS\Widget::load( \IPS\Application::load( \IPS\Request::i()->block_app ), \IPS\Request::i()->block_key, uniqid() );
if ( isset( \IPS\Request::i()->block_app ) )
{
$plugin = \IPS\Widget::load( \IPS\Application::load( \IPS\Request::i()->block_app ), \IPS\Request::i()->block_key, uniqid() );
}
else
{
$plugin = \IPS\Widget::load( \IPS\Plugin::load( \IPS\Request::i()->block_plugin ), \IPS\Request::i()->block_key, uniqid() );
}
$location = $plugin->getTemplateLocation();
@@ -2,9 +2,10 @@
/**
* @brief Block Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 19 Feb 2013
* @version SVN_VERSION_NUMBER
*/
@@ -196,7 +197,7 @@ class _blocks extends \IPS\Node\Controller
$block = \IPS\cms\Blocks\Block::load( \IPS\Request::i()->id );
$embedKey = md5( $block->key . time() );
/* Output */
\IPS\Output::i()->title = "External Embed"; // @todo
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('block_embed_title');
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( '', \IPS\Theme::i()->getTemplate( 'blocks', 'cms', 'admin' )->embedCode( $block, $embedKey ) );;
}
}
+12 -5
View File
@@ -2,10 +2,10 @@
/**
* @brief Pages Media Management
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - 2015 Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @subpackage Pages
* @package IPS Community Suite
* @subpackage Content
* @since 07 Jul 2015
* @version SVN_VERSION_NUMBER
*/
@@ -207,7 +207,7 @@ class _media extends \IPS\Node\Controller
$form = new \IPS\Helpers\Form( 'form', 'upload' );
$form->class = 'ipsForm_vertical ipsForm_noLabels';
$form->add( new \IPS\Helpers\Form\Upload( 'media_filename', NULL, FALSE, array( 'allowedFileTypes' => \IPS\File::$safeFileExtensions, 'obscure' => FALSE, 'maxFileSize' => 5, 'storageExtension' => 'core_Theme', 'storageContainer' => 'pages_media', 'multiple' => true, 'minimize' => FALSE ), NULL, NULL, NULL, 'media_filename' ) );
$form->add( new \IPS\Helpers\Form\Upload( 'media_filename', NULL, FALSE, array( 'allowedFileTypes' => array_merge( \IPS\File::$safeFileExtensions, array( 'pdf' ) ), 'obscure' => FALSE, 'maxFileSize' => 5, 'storageExtension' => 'core_Theme', 'storageContainer' => 'pages_media', 'multiple' => true, 'minimize' => FALSE ), NULL, NULL, NULL, 'media_filename' ) );
if ( ! isset( \IPS\Request::i()->media_parent ) and ! \IPS\Request::i()->media_parent )
{
@@ -260,7 +260,14 @@ class _media extends \IPS\Node\Controller
$new->setFullPath( ( $parent ? \IPS\cms\Media\Folder::load( $parent )->path : '' ) );
$new->save();
/* Remove the original as we created a copy with a slightly altered filename */
try
{
$media->delete();
}
catch( \Exception $ex ) { }
$count++;
}
+34 -35
View File
@@ -2,9 +2,10 @@
/**
* @brief Pages Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 15 Jan 2013
* @version SVN_VERSION_NUMBER
*/
@@ -27,7 +28,12 @@ class _pages extends \IPS\Node\Controller
* Node Class
*/
protected $nodeClass = '\IPS\cms\Pages\Folder';
/**
* Store the database page map to prevent many queries
*/
protected static $pageToDatabaseMap = NULL;
/**
* Execute
*
@@ -77,6 +83,7 @@ class _pages extends \IPS\Node\Controller
protected function manage()
{
$url = \IPS\Http\Url::internal( "app=cms&module=pages&controller=pages" );
static::$pageToDatabaseMap = iterator_to_array( \IPS\Db::i()->select( 'database_id, database_page_id', 'cms_databases', array( 'database_page_id > 0' ) )->setKeyField('database_page_id')->setValueField('database_id') );
/* Display the table */
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('menu__cms_pages_pages');
@@ -197,7 +204,7 @@ class _pages extends \IPS\Node\Controller
$page = \IPS\cms\Pages\Page::getDefaultPage();
$response = \IPS\Http\Url::external( ( \IPS\Settings::i()->htaccess_mod_rewrite ? $val . $page->full_path : $val . 'index.php?/' . $page->full_path ) )->request( 5, '1.1', FALSE )->get();
$response = \IPS\Http\Url::external( ( \IPS\Settings::i()->htaccess_mod_rewrite ? $val . $page->full_path : $val . 'index.php?/' . $page->full_path ) )->request( NULL, NULL, FALSE )->get();
if ( $response->httpResponseCode != 200 and $response->httpResponseCode != 303 and ( \IPS\Settings::i()->site_online OR $response->httpResponseCode != 503 ) )
{
@@ -247,14 +254,28 @@ class _pages extends \IPS\Node\Controller
protected function htaccess()
{
$dir = str_replace( \IPS\CP_DIRECTORY . '/index.php', '', $_SERVER['PHP_SELF'] );
$dirs = explode( '/', trim( $dir, '/' ) );
if ( count( $dirs ) )
{
array_pop( $dirs );
$dir = implode( '/', $dirs );
if ( ! $dir )
{
$dir = '/';
}
}
$path = $dir . 'index.php';
if( \strpos( $dir, ' ' ) !== FALSE )
{
$dir = '"' . $dir . '"';
$path = '"' . $path . '"';
}
$htaccess = <<<FILE
<IfModule mod_rewrite.c>
Options -MultiViews
@@ -319,7 +340,7 @@ FILE;
\IPS\cms\Pages\Page::deleteCompiled( \IPS\Request::i()->id );
}
parent::delete();
return parent::delete();
}
/**
@@ -367,7 +388,13 @@ FILE;
*/
public static function getPageRow( $page, $url )
{
return \IPS\Theme::i()->getTemplate( 'trees', 'core' )->row( $url, $page->id, $page->seo_name, false, $page->getButtons( \IPS\Http\url::internal('app=cms&module=pages&controller=pages'), true ), "", 'file-text-o', NULL, FALSE, NULL, NULL, NULL, FALSE, FALSE, FALSE );
$badge = NULL;
if ( isset( static::$pageToDatabaseMap[ $page->id ] ) )
{
$badge = array( 0 => 'style7', 1 => \IPS\Member::loggedIn()->language()->addToStack( 'page_database_display', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->addToStack('content_db_' . static::$pageToDatabaseMap[ $page->id ] ) ) ) ) );
}
return \IPS\Theme::i()->getTemplate( 'trees', 'core' )->row( $url, $page->id, $page->seo_name, false, $page->getButtons( \IPS\Http\url::internal('app=cms&module=pages&controller=pages'), true ), "", 'file-text-o', NULL, FALSE, NULL, NULL, $badge, FALSE, FALSE, FALSE );
}
/**
@@ -409,32 +436,4 @@ FILE;
return \IPS\cms\Pages\Folder::munge( $folders, $pages );
}
/**
* Redirect after save
*
* @param \IPS\Node\Model $old A clone of the node as it was before or NULL if this is a creation
* @param \IPS\Node\Model $node The node now
* @return void
*/
protected function _afterSave( \IPS\Node\Model $old = NULL, \IPS\Node\Model $new )
{
if( \IPS\Request::i()->isAjax() )
{
\IPS\Output::i()->json( array() );
}
else
{
if( isset( \IPS\Request::i()->save_and_reload ) )
{
$buttons = $new->getButtons( $this->url, !( $new instanceof $this->nodeClass ) );
\IPS\Output::i()->redirect( $buttons['edit']['link'], 'saved' );
}
else
{
\IPS\Output::i()->redirect( $this->url->setQueryString( array( 'root' => ( $new->parent() ? $new->parent()->_id : '' ) ) ), 'saved' );
}
}
}
}
@@ -2,9 +2,10 @@
/**
* @brief Templates Controller
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
* @license http://www.invisionpower.com/legal/standards/
* @package IPS Social Suite
* @package IPS Community Suite
* @subpackage Content
* @since 25 Feb 2013
* @version SVN_VERSION_NUMBER
*/
@@ -67,7 +68,7 @@ class _templates extends \IPS\Dispatcher\Controller
move_uploaded_file( $values['cms_templates_import'], $tempFile );
/* Initate a redirector */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&do=importProcess&file=' . urlencode( $tempFile ) . '&key=' . md5_file( $tempFile ) ) );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&do=importProcess' )->setQueryString( array( 'file' => $tempFile, 'key' => md5_file( $tempFile ) ) ) );
}
else
{
@@ -87,16 +88,18 @@ class _templates extends \IPS\Dispatcher\Controller
{
if ( !file_exists( \IPS\Request::i()->file ) or md5_file( \IPS\Request::i()->file ) !== \IPS\Request::i()->key )
{
\IPS\Output::i()->error( 'generic_error', '3T259/3', 403, '' );
\IPS\Output::i()->error( 'generic_error', '3T285/3', 403, '' );
}
/* Open XML file */
$xml = new \XMLReader;
$xml = new \IPS\Xml\XMLReader;
$xml->open( \IPS\Request::i()->file );
$prefix = date('m') . '.' . date('d') . '.' . date('y') . '_';
$prefix = date('m') . '_' . date('d') . '_' . date('y') . '_';
$templates = \IPS\cms\Theme::i()->getRawTemplates( 'cms', NULL, NULL, \IPS\cms\Theme::RETURN_ALL );
if ( ! @$xml->read() )
{
@unlink( \IPS\Request::i()->file );
\IPS\Output::i()->error( 'xml_upload_invalid', '2C163/1', 403, '' );
}
$xml->read();
@@ -104,7 +107,6 @@ class _templates extends \IPS\Dispatcher\Controller
{
if ( $xml->name === 'template' )
{
$templates = \IPS\cms\Theme::i()->getRawTemplates( 'cms', NULL, NULL, \IPS\cms\Theme::RETURN_ALL );
$node = new \SimpleXMLElement( $xml->readOuterXML() );
$attrs = array();
@@ -166,7 +168,7 @@ class _templates extends \IPS\Dispatcher\Controller
$obj->desc = '';
$obj->save();
$obj->key = $obj->location . \IPS\Http\Url::seoTitle( $obj->group ) . '_' . \IPS\Http\Url::seoTitle( $obj->title ) . '_' . $obj->id;
$obj->key = $obj->location . \IPS\Http\Url\Friendly::seoTitle( $obj->group ) . '_' . \IPS\Http\Url\Friendly::seoTitle( $obj->title ) . '_' . $obj->id;
$obj->save();
}
}
@@ -174,6 +176,8 @@ class _templates extends \IPS\Dispatcher\Controller
$xml->next();
}
@unlink( \IPS\Request::i()->file );
/* Done */
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&do=manage' ), 'cms_templates_imported' );
}
@@ -505,7 +509,7 @@ class _templates extends \IPS\Dispatcher\Controller
public function addTemplate()
{
/* Check permission */
\IPS\Dispatcher::i()->checkAcpPermission( 'template_add' );
\IPS\Dispatcher::i()->checkAcpPermission( 'template_add_edit' );
$type = \IPS\Request::i()->type;
@@ -513,7 +517,7 @@ class _templates extends \IPS\Dispatcher\Controller
$form = new \IPS\Helpers\Form();
$form->hiddenValues['type'] = $type;
$form->add( new \IPS\Helpers\Form\Text( 'template_title', NULL, TRUE, array( 'regex' => '/^([A-Z0-9_]+?)$/i' ) ) );
$form->add( new \IPS\Helpers\Form\Text( 'template_title', NULL, TRUE, array( 'regex' => '/^([A-Z_][A-Z0-9_]+?)$/i' ) ) );
/* Very specific */
if ( $type === 'database' )
@@ -601,7 +605,7 @@ class _templates extends \IPS\Dispatcher\Controller
'new' => array( 'group_new' ) )
) ) );
$form->add( new \IPS\Helpers\Form\Text( 'template_group_new', NULL, FALSE, array( 'regex' => '/^([a-z0-9_]+?)?$/' ), NULL, NULL, NULL, 'group_new' ) );
$form->add( new \IPS\Helpers\Form\Text( 'template_group_new', NULL, FALSE, array( 'regex' => '/^([a-z_][a-z0-9_]+?)?$/' ), NULL, NULL, NULL, 'group_new' ) );
$form->add( new \IPS\Helpers\Form\Select( 'template_group_existing', NULL, FALSE, array( 'options' => $groups ), NULL, NULL, NULL, 'group_existing' ) );
}
@@ -624,7 +628,7 @@ class _templates extends \IPS\Dispatcher\Controller
{
unset( $template['template_id'] );
$template['template_original_group'] = $template['template_group'];
$template['template_group'] = str_replace( '-', '_', \IPS\Http\Url::seoTitle( $values['template_title'] ) );
$template['template_group'] = str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['template_title'] ) );
$save = array();
foreach( $template as $k => $v )
@@ -684,7 +688,7 @@ class _templates extends \IPS\Dispatcher\Controller
else if ( $type === 'block' )
{
$save = array(
'title' => str_replace( '-', '_', \IPS\Http\Url::seoTitle( $values['template_title'] ) ),
'title' => str_replace( '-', '_', \IPS\Http\Url\Friendly::seoTitle( $values['template_title'] ) ),
'params' => isset( $values['template_params'] ) ? $values['template_params'] : null,
'location' => $type
);
@@ -779,7 +783,10 @@ class _templates extends \IPS\Dispatcher\Controller
{
/* Check permission */
\IPS\Dispatcher::i()->checkAcpPermission( 'template_delete' );
/* Make sure the user confirmed the deletion */
\IPS\Request::i()->confirmedDelete();
$key = \IPS\Request::i()->t_key;
$return = array(
'template_content' => NULL,
@@ -807,7 +814,7 @@ class _templates extends \IPS\Dispatcher\Controller
}
catch( \OutOfRangeException $ex )
{
\IPS\Output::i()->error( 'node_error', '3S121/1', 500, '' );
\IPS\Output::i()->error( 'node_error', '3T285/4', 500, '' );
}
/* Clear guest page caches */
@@ -864,6 +871,19 @@ class _templates extends \IPS\Dispatcher\Controller
\IPS\Output::i()->json( array( 'msg' => $ex->getMessage() ) );
}
if ( isset( \IPS\Request::i()->t_type ) and \IPS\Request::i()->t_type !== 'js' )
{
/* Test */
try
{
\IPS\Theme::checkTemplateSyntax( $content, $variables );
}
catch( \Exception $e )
{
\IPS\Output::i()->json( array( 'msg' => \IPS\Member::loggedIn()->language()->get('cms_page_error_bad_syntax') ) );
}
}
/* reload to return new item Id */
$obj = \IPS\cms\Templates::load( $key );
@@ -882,4 +902,74 @@ class _templates extends \IPS\Dispatcher\Controller
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&' . implode( '&', $url ) ), 'completed' );
}
}
/**
* Display template options for a database template group
*
* @return string
*/
public function databaseTemplateGroupOptions()
{
$form = new \IPS\Helpers\Form();
$databases = array();
foreach( \IPS\Db::i()->select( '*', 'cms_databases', array( 'database_template_featured=? or database_template_listing=? or database_template_display=? or database_template_categories=? or database_template_form=?', \IPS\Request::i()->group, \IPS\Request::i()->group, \IPS\Request::i()->group, \IPS\Request::i()->group, \IPS\Request::i()->group ) ) as $database )
{
$databases[ $database['database_id'] ] = \IPS\cms\Databases::constructFromData( $database );
}
if ( count( $databases ) )
{
$names = array();
foreach( $databases as $db )
{
$names[] = $db->_title;
}
$form->addMessage( \IPS\Member::loggedIn()->language()->addToStack( 'cms_database_template_used_in', NULL, array( 'sprintf' => array( \IPS\Member::loggedIn()->language()->formatList( $names ) ) ) ), 'ipsMessage ipsMessage_info' );
}
$form->add( new \IPS\Helpers\Form\Text( 'cms_database_group_name', \IPS\cms\Templates::readableGroupName( \IPS\Request::i()->group ), NULL, array( 'regex' => '/^([A-Z_][A-Z0-9_\.\s]+?)$/i' ) ) );
$form->addButton( "delete", "link", \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates&do=deleteTemplateGroup&group=' . \IPS\Request::i()->group . '&t_location=' . \IPS\Request::i()->t_location ), 'ipsButton ipsButton_negative', array( 'data-confirm' => 'true' ) );
if ( $values = $form->values() )
{
$new = str_replace( ' ', '_', $values['cms_database_group_name'] );
if ( $new != \IPS\Request::i()->group )
{
\IPS\Db::i()->update( 'cms_templates', array( 'template_group' => $new ), array( 'template_location=? and template_group=?', 'database', \IPS\Request::i()->group ) );
foreach( \IPS\cms\Templates::$databaseDefaults as $field => $template )
{
\IPS\Db::i()->update( 'cms_databases', array( 'database_template_' . $field => $new ), array( 'database_template_' . $field . ' =?', \IPS\Request::i()->group ) );
}
}
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates' . ( isset( \IPS\Request::i()->t_location ) ? '&t_location=' . \IPS\Request::i()->t_location : '' ) ), 'deleted' );
}
/* Display */
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate( 'global', 'core' )->block( \IPS\Member::loggedIn()->language()->addToStack('cms_template_database_options'), $form, FALSE, '', NULL, TRUE );
}
/**
* Delete the template group! OH NOES
*
* @return void
*/
public function deleteTemplateGroup()
{
foreach( \IPS\cms\Templates::$databaseDefaults as $field => $template )
{
\IPS\Db::i()->update( 'cms_databases', array( 'database_template_' . $field => $template ), array( 'database_template_' . $field . ' =?', \IPS\Request::i()->group ) );
}
\IPS\Db::i()->delete( 'cms_templates', array( 'template_location=? and template_group=?', 'database', \IPS\Request::i()->group ) );
unset( \IPS\Data\Store::i()->cms_databases );
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( 'app=cms&module=pages&controller=templates' . ( isset( \IPS\Request::i()->t_location ) ? '&t_location=' . \IPS\Request::i()->t_location : '' ) ), 'deleted' );
}
}