Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -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' );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user