Version 4.1.2
This commit is contained in:
1 parent
3ba79295ee
commit
28bd025b35
1131 files changed
+63658
-20579
No files matched your search
@@ -1,434 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* @brief Menu Model
|
||||
* @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\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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Menu Model
|
||||
*/
|
||||
class _Menu extends \IPS\Node\Model
|
||||
{
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Store
|
||||
*/
|
||||
protected static $multitons;
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Table
|
||||
*/
|
||||
public static $databaseTable = 'cms_page_menu';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database Prefix
|
||||
*/
|
||||
public static $databasePrefix = 'menu_';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] ID Database Column
|
||||
*/
|
||||
public static $databaseColumnId = 'id';
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Database ID Fields
|
||||
*/
|
||||
protected static $databaseIdFields = array();
|
||||
|
||||
/**
|
||||
* @brief [Node] Parent ID Database Column
|
||||
*/
|
||||
public static $databaseColumnParent = 'parent_id';
|
||||
|
||||
/**
|
||||
* @brief [Node] Parent ID Root Value
|
||||
* @note This normally doesn't need changing though some legacy areas use -1 to indicate a root node
|
||||
*/
|
||||
public static $databaseColumnParentRootValue = 0;
|
||||
|
||||
/**
|
||||
* @brief [Node] Order Database Column
|
||||
*/
|
||||
public static $databaseColumnOrder = 'position';
|
||||
|
||||
/**
|
||||
* @brief [Node] Node Title
|
||||
*/
|
||||
public static $nodeTitle = 'cms_menu';
|
||||
|
||||
/**
|
||||
* @brief [Node] Show forms modally?
|
||||
*/
|
||||
public static $modalForms = TRUE;
|
||||
|
||||
/**
|
||||
* @brief [Node] Title prefix. If specified, will look for a language key with "{$key}_title" as the key
|
||||
*/
|
||||
public static $titleLangPrefix = 'cms_menu_title_';
|
||||
|
||||
/**
|
||||
* @brief [Node] ACP Restrictions
|
||||
* @code
|
||||
array(
|
||||
'app' => 'core', // The application key which holds the restrictrions
|
||||
'module' => 'foo', // The module key which holds the restrictions
|
||||
'map' => array( // [Optional] The key for each restriction - can alternatively use "prefix"
|
||||
'add' => 'foo_add',
|
||||
'edit' => 'foo_edit',
|
||||
'permissions' => 'foo_perms',
|
||||
'delete' => 'foo_delete'
|
||||
),
|
||||
'all' => 'foo_manage', // [Optional] The key to use for any restriction not provided in the map (only needed if not providing all 4)
|
||||
'prefix' => 'foo_', // [Optional] Rather than specifying each key in the map, you can specify a prefix, and it will automatically look for restrictions with the key "[prefix]_add/edit/permissions/delete"
|
||||
* @endcode
|
||||
*/
|
||||
protected static $restrictions = array(
|
||||
'app' => 'cms',
|
||||
'module' => 'pages',
|
||||
'all' => 'page_manage',
|
||||
'prefix' => 'page_'
|
||||
);
|
||||
|
||||
/**
|
||||
* Form elements
|
||||
*
|
||||
* @param \IPS\cms\Pages\Menu|null $node Menu item
|
||||
* @return array
|
||||
*/
|
||||
public static function formElements( $node=NULL, $forceType=NULL )
|
||||
{
|
||||
$form = array();
|
||||
|
||||
if ( $forceType === NULL )
|
||||
{
|
||||
$form['menu_type'] = new \IPS\Helpers\Form\Select( 'menu_type', ( $node !== NULL ? $node->type : 'page' ), TRUE, array(
|
||||
'options' => array(
|
||||
'page' => 'cms_menu_form_type_page',
|
||||
'url' => 'cms_menu_form_type_url',
|
||||
'folder' => 'cms_menu_form_type_folder',
|
||||
#'separator' => 'cms_menu_form_type_separator'
|
||||
),
|
||||
'toggles' => array(
|
||||
'page' => array( 'menu_content_page', 'menu_title_page', 'menu_permission_from_page'),
|
||||
'url' => array( 'menu_content_url', 'menu_title_url', 'menu_permission' ),
|
||||
'folder' => array( 'menu_title_folder', 'menu_permission')
|
||||
)
|
||||
) );
|
||||
}
|
||||
|
||||
/* Page fields */
|
||||
if ( $forceType !== 'page' )
|
||||
{
|
||||
$pages = array();
|
||||
foreach( \IPS\cms\Pages\Page::roots() as $id => $page )
|
||||
{
|
||||
$pages[ $id ] = $page->_title . ' (' . $page->full_path . ')';
|
||||
}
|
||||
|
||||
$form['menu_content_page'] = new \IPS\Helpers\Form\Select( 'menu_content_page', $node !== NULL ? ( $node->type === 'page' ? $node->content : NULL ) : 0, FALSE, array(
|
||||
'options' => $pages
|
||||
), NULL, NULL, NULL, 'menu_content_page' );
|
||||
}
|
||||
|
||||
$form['menu_title_page'] = new \IPS\Helpers\Form\Translatable( 'menu_title_page', NULL, FALSE, array( 'app' => 'cms', 'key' => ( ( ! empty( $node ) and $node->type === 'page' ) ? "cms_menu_title_" . $node->id : NULL ), 'maxLength' => 64 ), NULL, NULL, NULL, 'menu_title_page' );
|
||||
|
||||
/* URL Fields */
|
||||
if ( $forceType === NULL or $forceType === 'url' )
|
||||
{
|
||||
$form['menu_content_url'] = new \IPS\Helpers\Form\Text( 'menu_content_url', $node !== NULL ? ( $node->type === 'url' ? $node->content : NULL ) : '', FALSE, array(), NULL, NULL, NULL, 'menu_content_url' );
|
||||
|
||||
$form['menu_title_url'] = new \IPS\Helpers\Form\Translatable( 'menu_title_url', NULL, FALSE, array( 'app' => 'cms', 'key' => ( ( ! empty( $node ) and $node->type === 'url' ) ? "cms_menu_title_" . $node->id : NULL ), 'maxLength' => 64 ), NULL, NULL, NULL, 'menu_title_url' );
|
||||
}
|
||||
|
||||
/* Folder fields */
|
||||
if ( $forceType === NULL or $forceType === 'folder' )
|
||||
{
|
||||
$form['menu_title_folder'] = new \IPS\Helpers\Form\Translatable( 'menu_title_folder', NULL, FALSE, array( 'app' => 'cms', 'key' => ( ( ! empty( $node ) and $node->type === 'folder' ) ? "cms_menu_title_" . $node->id : NULL ), 'maxLength' => 64 ), NULL, NULL, NULL, 'menu_title_folder' );
|
||||
}
|
||||
|
||||
/* Shared fields */
|
||||
$form['menu_parent_id'] = new \IPS\Helpers\Form\Node( 'menu_parent_id', $node !== NULL ? intval( $node->parent_id ) : 0, FALSE, array(
|
||||
'class' => '\IPS\cms\Pages\Menu',
|
||||
'zeroVal' => 'node_no_parent',
|
||||
'permissionCheck' => function( $node )
|
||||
{
|
||||
return $node->type === 'folder';
|
||||
}
|
||||
), NULL, NULL, NULL, 'menu_parent_id' );
|
||||
|
||||
$form['menu_permission_from_page'] = new \IPS\Helpers\Form\Radio( 'menu_permission_type', $node !== NULL ? ( $node->permission === 'page' ? 'page' : 'manual' ) : ( $forceType === 'page' ? 'page' : 'manual' ), FALSE, array(
|
||||
'options' => array(
|
||||
'page' => 'cms_menu_form_perm_page',
|
||||
'manual' => 'cms_menu_form_perm_manual'
|
||||
),
|
||||
'toggles' => array(
|
||||
'manual' => array( 'menu_permission' )
|
||||
)
|
||||
), NULL, NULL, NULL, 'menu_permission_from_page' );
|
||||
|
||||
$form['menu_permission'] = new \IPS\Helpers\Form\Select( 'menu_permission', ( $node !== NULL ) ? ( ( $node->permission === '*' ) ? '*' : explode( ',', $node->permission ) ) : NULL, FALSE, array(
|
||||
'options' => array_combine( array_keys( \IPS\Member\Group::groups() ), array_map( function( $_group ) { return (string) $_group; }, \IPS\Member\Group::groups() ) ),
|
||||
'multiple' => true,
|
||||
'unlimited' => '*',
|
||||
'unlimitedLang' => 'cms_menu_perm_any'
|
||||
), NULL, NULL, NULL, 'menu_permission' );
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear caches
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function clearCaches()
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->cms_menu );
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Set Title
|
||||
*
|
||||
* @param string $title Title
|
||||
* @return string|null
|
||||
*/
|
||||
protected function set__title( $title )
|
||||
{
|
||||
$this->title = $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get Title
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function get__title()
|
||||
{
|
||||
if ( ! $this->title AND $this->type === 'page' )
|
||||
{
|
||||
try
|
||||
{
|
||||
$this->title = \IPS\cms\Pages\Page::load( $this->content )->_title;
|
||||
}
|
||||
catch( \OutOfRangeException $ex )
|
||||
{
|
||||
$this->title = '';
|
||||
}
|
||||
}
|
||||
else if ( ! $this->title )
|
||||
{
|
||||
/* This is stored in a separate \Data\Store cache, so we can't return the hash */
|
||||
$this->title = \IPS\Member::loggedIn()->language()->get( 'cms_menu_title_' . $this->id );
|
||||
}
|
||||
|
||||
return $this->title;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get URL
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
protected function get__url()
|
||||
{
|
||||
if ( $this->type === 'page' )
|
||||
{
|
||||
try
|
||||
{
|
||||
return \IPS\cms\Pages\Page::load( $this->content )->url();
|
||||
}
|
||||
catch( \OutOfRangeException $ex )
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Return the custom badge for each row
|
||||
*
|
||||
* @return NULL|array Null for no badge, or an array of badge data (0 => CSS class type, 1 => language string, 2 => optional raw HTML to show instead of language string)
|
||||
*/
|
||||
protected function get__badge()
|
||||
{
|
||||
if ( ! $this->permission )
|
||||
{
|
||||
return array( 'ipsBadge ipsBadge_negative', 'cms_menu_no_item_perm' );
|
||||
}
|
||||
|
||||
return ( $this->type === 'folder' ) ? NULL : array( 'ipsBadge ipsBadge_intermediary ipsPos_right', 'cms_menu_form_type_' . $this->type );
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Get buttons to display in tree
|
||||
* Example code explains return value
|
||||
*
|
||||
* @code
|
||||
array(
|
||||
array(
|
||||
'icon' => 'plus-circle', // Name of FontAwesome icon to use
|
||||
'title' => 'foo', // Language key to use for button's title parameter
|
||||
'link' => \IPS\Http\Url::internal( 'app=foo...' ) // URI to link to
|
||||
'class' => 'modalLink' // CSS Class to use on link (Optional)
|
||||
),
|
||||
... // Additional buttons
|
||||
);
|
||||
* @endcode
|
||||
* @param string $url Base URL
|
||||
* @param bool $subnode Is this a subnode?
|
||||
* @return array
|
||||
*/
|
||||
public function getButtons( $url, $subnode=FALSE )
|
||||
{
|
||||
$buttons = parent::getButtons( $url, $subnode );
|
||||
|
||||
if ( isset( $buttons['copy'] ) and $this->type === 'folder' )
|
||||
{
|
||||
unset( $buttons['copy'] );
|
||||
}
|
||||
|
||||
return $buttons;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sortable name
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getSortableName()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Add/Edit Form
|
||||
*
|
||||
* @param \IPS\Helpers\Form $form The form
|
||||
* @return void
|
||||
*/
|
||||
public function form( &$form )
|
||||
{
|
||||
/* Build form */
|
||||
foreach( static::formElements( $this ) as $element )
|
||||
{
|
||||
$form->add( $element );
|
||||
}
|
||||
|
||||
if ( $this->id )
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cms_menu_edit', FALSE, array( 'sprintf' => array( $this->_title ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cms_menu_adding');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Format form values from add/edit form for save
|
||||
*
|
||||
* @param array $values Values from the form
|
||||
* @return array
|
||||
*/
|
||||
public function formatFormValues( $values )
|
||||
{
|
||||
if ( ! $this->id )
|
||||
{
|
||||
$this->parent_id = 0;
|
||||
$this->save();
|
||||
}
|
||||
|
||||
if( isset( $values['menu_type'] ) )
|
||||
{
|
||||
$title = '';
|
||||
$content = NULL;
|
||||
|
||||
switch ( $values['menu_type'] )
|
||||
{
|
||||
case 'page':
|
||||
$title = $values['menu_title_page'];
|
||||
$content = $values['menu_content_page'];
|
||||
break;
|
||||
case 'url':
|
||||
$title = $values['menu_title_url'];
|
||||
$content = $values['menu_content_url'];
|
||||
break;
|
||||
case 'folder':
|
||||
$title = $values['menu_title_folder'];
|
||||
break;
|
||||
}
|
||||
|
||||
/* We need to store something in menu_title field in the database as we can leave this blank to get the current page title. We can't examine an addToStack to see if any data was returned */
|
||||
$values['title'] = current( $title );
|
||||
$values['content'] = $content;
|
||||
|
||||
\IPS\Lang::saveCustom( 'cms', "cms_menu_title_" . $this->id, $title );
|
||||
|
||||
unset( $values['menu_title_folder'], $values['menu_title_url'], $values['menu_title_page'], $values['menu_content_page'], $values['menu_content_url'] );
|
||||
}
|
||||
|
||||
if( isset( $values['menu_permission'] ) )
|
||||
{
|
||||
$values['menu_permission'] = ( is_array( $values['menu_permission'] ) ) ? implode( ',', $values['menu_permission'] ) : $values['menu_permission'];
|
||||
}
|
||||
|
||||
if ( isset( $values['menu_type'] ) AND $values['menu_type'] === 'page' and $values['menu_permission_type'] === 'page' )
|
||||
{
|
||||
$values['menu_permission'] = 'page';
|
||||
}
|
||||
|
||||
if ( isset( $values['menu_parent_id'] ) AND ( ! empty( $values['menu_parent_id'] ) OR $values['menu_parent_id'] === 0 ) )
|
||||
{
|
||||
$values['menu_parent_id'] = ( $values['menu_parent_id'] === 0 ) ? 0 : $values['menu_parent_id']->id;
|
||||
}
|
||||
|
||||
if( isset( $values['menu_permission_type'] ) )
|
||||
{
|
||||
unset( $values['menu_permission_type'] );
|
||||
}
|
||||
|
||||
return $values;
|
||||
}
|
||||
|
||||
/**
|
||||
* [Node] Does the currently logged in user have permission to add a child node to this node?
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function canAdd()
|
||||
{
|
||||
if ( parent::canAdd() )
|
||||
{
|
||||
return $this->type === 'folder';
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
static::clearCaches();
|
||||
parent::save();
|
||||
}
|
||||
}
|
||||
@@ -51,7 +51,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
/**
|
||||
* @brief [Node] Parent ID Database Column
|
||||
*/
|
||||
public static $databaseColumnParent = null;
|
||||
public static $databaseColumnParent = 'folder_id';
|
||||
|
||||
/**
|
||||
* @brief [Node] Parent Node ID Database Column
|
||||
@@ -367,7 +367,6 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
$url->data['query'] = $queryString;
|
||||
}
|
||||
|
||||
return \IPS\Http\Url::createFromArray( $url->data );
|
||||
}
|
||||
|
||||
@@ -384,7 +383,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
/* Do we have a page with this path? */
|
||||
try
|
||||
{
|
||||
return static::load( $newPath, 'page_full_path' )->url();
|
||||
return static::load( $newPath, 'page_full_path' );
|
||||
}
|
||||
catch( \OutOfRangeException $ex )
|
||||
{
|
||||
@@ -499,6 +498,33 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Show a custom error page
|
||||
*
|
||||
* @param string $title Title of the page
|
||||
* @param string $message language key for error message
|
||||
* @param mixed $code Error code
|
||||
* @param int $httpStatusCode HTTP Status Code
|
||||
* @param array $httpHeaders Additional HTTP Headers
|
||||
* @return void
|
||||
*/
|
||||
static public function errorPage( $title, $message, $code, $httpStatusCode, $httpHeaders )
|
||||
{
|
||||
try
|
||||
{
|
||||
$page = static::load( \IPS\Settings::i()->cms_error_page );
|
||||
$page->content = str_replace( '{error_message}', $message, $page->content );
|
||||
$page->content = str_replace( '{error_code}', $code, $page->content );
|
||||
|
||||
$page->output( $title, $httpStatusCode, $httpHeaders );
|
||||
}
|
||||
catch( \Exception $ex )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['enabled'] = FALSE;
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->globalTemplate( $title, \IPS\Theme::i()->getTemplate( 'global', 'core' )->error( $title, $message, $code, NULL ), array( 'app' => \IPS\Dispatcher::i()->application ? \IPS\Dispatcher::i()->application->directory : NULL, 'module' => \IPS\Dispatcher::i()->module ? \IPS\Dispatcher::i()->module->key : NULL, 'controller' => \IPS\Dispatcher::i()->controller ) ), $httpStatusCode, 'text/html', $httpHeaders, FALSE, FALSE );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form elements
|
||||
*
|
||||
@@ -562,54 +588,50 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
'subnodes' => false
|
||||
), NULL, NULL, NULL, 'page_folder_id' );
|
||||
|
||||
if ( $pageType === 'html' )
|
||||
|
||||
$return['page_ipb_wrapper'] = new \IPS\Helpers\Form\YesNo( 'page_ipb_wrapper', $item AND $item->id ? $item->ipb_wrapper : 1, TRUE, array(
|
||||
'togglesOn' => array( 'page_show_sidebar' ),
|
||||
'togglesOff' => array( 'page_wrapper_template' )
|
||||
), NULL, NULL, NULL, 'page_ipb_wrapper' );
|
||||
|
||||
$return['page_show_sidebar'] = new \IPS\Helpers\Form\YesNo( 'page_show_sidebar', $item ? $item->show_sidebar : TRUE, FALSE, array(), NULL, NULL, NULL, 'page_show_sidebar' );
|
||||
|
||||
$wrapperTemplates = array( '_none_' => \IPS\Member::loggedIn()->language()->addToStack('cms_page_wrapper_template_none') );
|
||||
foreach( \IPS\cms\Templates::getTemplates( \IPS\cms\Templates::RETURN_PAGE + \IPS\cms\Templates::RETURN_DATABASE_AND_IN_DEV ) as $id => $obj )
|
||||
{
|
||||
$return['page_ipb_wrapper'] = new \IPS\Helpers\Form\YesNo( 'page_ipb_wrapper', $item AND $item->id ? $item->ipb_wrapper : 1, TRUE, array(
|
||||
'togglesOn' => array( 'page_show_sidebar' ),
|
||||
'togglesOff' => array( 'page_wrapper_template' )
|
||||
), NULL, NULL, NULL, 'page_ipb_wrapper' );
|
||||
|
||||
$return['page_show_sidebar'] = new \IPS\Helpers\Form\YesNo( 'page_show_sidebar', $item ? $item->show_sidebar : TRUE, FALSE, array(), NULL, NULL, NULL, 'page_show_sidebar' );
|
||||
|
||||
$wrapperTemplates = array( '_none_' => \IPS\Member::loggedIn()->language()->addToStack('cms_page_wrapper_template_none') );
|
||||
foreach( \IPS\cms\Templates::getTemplates( \IPS\cms\Templates::RETURN_PAGE + \IPS\cms\Templates::RETURN_DATABASE_AND_IN_DEV ) as $id => $obj )
|
||||
if ( $obj->isSuitableForCustomWrapper() )
|
||||
{
|
||||
if ( $obj->isSuitableForCustomWrapper() )
|
||||
{
|
||||
$wrapperTemplates[ \IPS\cms\Templates::readableGroupName( $obj->group ) ][ $obj->group . '__' . $obj->title . '__' . $obj->key ] = \IPS\cms\Templates::readableGroupName( $obj->title );
|
||||
}
|
||||
$wrapperTemplates[ \IPS\cms\Templates::readableGroupName( $obj->group ) ][ $obj->group . '__' . $obj->title . '__' . $obj->key ] = \IPS\cms\Templates::readableGroupName( $obj->title );
|
||||
}
|
||||
|
||||
/* List of templates */
|
||||
$return['page_wrapper_template'] = new \IPS\Helpers\Form\Select( 'page_wrapper_template', ( $item ? $item->wrapper_template : NULL ), FALSE, array(
|
||||
'options' => $wrapperTemplates
|
||||
), NULL, NULL, \IPS\Theme::i()->getTemplate( 'pages', 'cms', 'admin' )->previewTemplateLink(), 'page_wrapper_template' );
|
||||
}
|
||||
else
|
||||
|
||||
/* List of templates */
|
||||
$return['page_wrapper_template'] = new \IPS\Helpers\Form\Select( 'page_wrapper_template', ( $item ? $item->wrapper_template : NULL ), FALSE, array(
|
||||
'options' => $wrapperTemplates
|
||||
), NULL, NULL, \IPS\Theme::i()->getTemplate( 'pages', 'cms', 'admin' )->previewTemplateLink(), 'page_wrapper_template' );
|
||||
|
||||
if ( count( \IPS\Theme::themes() ) > 1 )
|
||||
{
|
||||
if ( count( \IPS\Theme::themes() ) > 1 )
|
||||
$themes = array( 0 => 'cms_page_theme_id_default' );
|
||||
foreach ( \IPS\Theme::themes() as $theme )
|
||||
{
|
||||
$themes = array( 0 => 'cms_page_theme_id_default' );
|
||||
foreach ( \IPS\Theme::themes() as $theme )
|
||||
{
|
||||
$themes[ $theme->id ] = $theme->_title;
|
||||
}
|
||||
|
||||
$return['page_theme'] = new \IPS\Helpers\Form\Select( 'page_theme', $item ? $item->theme : 0, FALSE, array( 'options' => $themes ), NULL, NULL, NULL, 'page_theme' );
|
||||
$themes[ $theme->id ] = $theme->_title;
|
||||
}
|
||||
|
||||
$builderTemplates = array();
|
||||
foreach( \IPS\cms\Templates::getTemplates( \IPS\cms\Templates::RETURN_PAGE + \IPS\cms\Templates::RETURN_DATABASE_AND_IN_DEV ) as $id => $obj )
|
||||
{
|
||||
if ( $obj->isSuitableForBuilderWrapper() )
|
||||
{
|
||||
$builderTemplates[ \IPS\cms\Templates::readableGroupName( $obj->group ) ][ $obj->group . '__' . $obj->title . '__' . $obj->key ] = \IPS\cms\Templates::readableGroupName( $obj->title );
|
||||
}
|
||||
}
|
||||
|
||||
$return['page_template'] = new \IPS\Helpers\Form\Select( 'page_template', $item->template ? $item->template : FALSE, FALSE, array( 'options' => $builderTemplates ), NULL, NULL, NULL, 'page_template' );
|
||||
$return['page_theme'] = new \IPS\Helpers\Form\Select( 'page_theme', $item ? $item->theme : 0, FALSE, array( 'options' => $themes ), NULL, NULL, NULL, 'page_theme' );
|
||||
}
|
||||
|
||||
$builderTemplates = array();
|
||||
foreach( \IPS\cms\Templates::getTemplates( \IPS\cms\Templates::RETURN_PAGE + \IPS\cms\Templates::RETURN_DATABASE_AND_IN_DEV ) as $id => $obj )
|
||||
{
|
||||
if ( $obj->isSuitableForBuilderWrapper() )
|
||||
{
|
||||
$builderTemplates[ \IPS\cms\Templates::readableGroupName( $obj->group ) ][ $obj->group . '__' . $obj->title . '__' . $obj->key ] = \IPS\cms\Templates::readableGroupName( $obj->title );
|
||||
}
|
||||
}
|
||||
|
||||
$return['page_template'] = new \IPS\Helpers\Form\Select( 'page_template', ( $item and $item->template ) ? $item->template : FALSE, FALSE, array( 'options' => $builderTemplates ), NULL, NULL, NULL, 'page_template' );
|
||||
|
||||
/* Page CSS and JS */
|
||||
$js = \IPS\cms\Templates::getTemplates( \IPS\cms\Templates::RETURN_ONLY_JS + \IPS\cms\Templates::RETURN_DATABASE_ONLY );
|
||||
$css = \IPS\cms\Templates::getTemplates( \IPS\cms\Templates::RETURN_ONLY_CSS + \IPS\cms\Templates::RETURN_DATABASE_ONLY );
|
||||
@@ -647,21 +669,32 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$return['tab_content'] = array( 'content_page_form_tab__content', NULL, NULL, 'ipsForm_vertical' );
|
||||
|
||||
$tags = array();
|
||||
|
||||
|
||||
if ( $item and $item->id == \IPS\Settings::i()->cms_error_page )
|
||||
{
|
||||
$tags['cms_error_page']['{error_message}'] = 'cms_error_page_message';
|
||||
$tags['cms_error_page']['{error_code}'] = 'cms_error_page_code';
|
||||
}
|
||||
|
||||
foreach( \IPS\cms\Databases::roots( NULL, NULL ) as $id => $db )
|
||||
{
|
||||
if ( ! $db->page_id )
|
||||
{
|
||||
$tags['{database="' . $db->_id . '" title="' . $db->_title . '"}'] = $db->_title;
|
||||
$tags['cms_tag_databases']['{database="' . $db->key . '"}'] = $db->_title;
|
||||
}
|
||||
}
|
||||
|
||||
foreach( \IPS\cms\Blocks\Block::roots( NULL, NULL ) as $id => $block )
|
||||
{
|
||||
$tags['{block="' . $block->_id . '" title="' . $block->_title . '"}'] = $block->_title;
|
||||
$tags['cms_tag_blocks']['{block="' . $block->key . '"}'] = $block->_title;
|
||||
}
|
||||
|
||||
$return['page_content'] = new \IPS\Helpers\Form\Codemirror( 'page_content', $item ? $item->content : NULL, FALSE, array( 'tags' => $tags ), function( $val )
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_pages', NULL, 'page_full_path ASC', array( 0, 50 ) ) as $page )
|
||||
{
|
||||
$tags['cms_tag_pages']['{pageurl="' . $page['page_full_path'] . '"}' ] = \IPS\Member::loggedIn()->language()->addToStack( static::$titleLangPrefix . $page['page_id'] );
|
||||
}
|
||||
|
||||
$return['page_content'] = new \IPS\Helpers\Form\Codemirror( 'page_content', $item ? htmlentities( $item->content, \IPS\HTMLENTITIES, 'UTF-8', TRUE ) : NULL, FALSE, array( 'tags' => $tags, 'height' => 600 ), function( $val )
|
||||
{
|
||||
/* Test */
|
||||
try
|
||||
@@ -702,12 +735,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$page->saveForm( $page->formatFormValues( $values ), $pageType );
|
||||
|
||||
/* Set permissions */
|
||||
\IPS\Db::i()->insert( 'core_permission_index', array(
|
||||
'app' => 'cms',
|
||||
'perm_type' => 'pages',
|
||||
'perm_type_id' => $page->id,
|
||||
'perm_view' => '*'
|
||||
) );
|
||||
\IPS\Db::i()->update( 'core_permission_index', array( 'perm_view' => '*' ), array( 'app=? and perm_type=? and perm_type_id=?', 'cms', 'pages', $page->id ) );
|
||||
|
||||
return $page;
|
||||
}
|
||||
@@ -778,7 +806,40 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
\IPS\Db::i()->update( 'cms_pages', array( 'page_js_css_objects' => NULL ) );
|
||||
\IPS\cms\Templates::deleteCompiledFiles();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a datastore object of page IDs and URLs.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function buildPageUrlStore()
|
||||
{
|
||||
$store = array();
|
||||
foreach( new \IPS\Patterns\ActiveRecordIterator( \IPS\Db::i()->select( '*', 'cms_pages' ), 'IPS\cms\Pages\Page' ) as $page )
|
||||
{
|
||||
$perms = $page->permissions();
|
||||
$store[ $page->id ] = array( 'url' => (string) $page->url(), 'perm' => $perms['perm_view'] );
|
||||
}
|
||||
|
||||
\IPS\Data\Store::i()->pages_page_urls = $store;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns (and builds if required) the pages id => url datastore
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public static function getPageUrlStore()
|
||||
{
|
||||
if ( ! isset( \IPS\Data\Store::i()->pages_page_urls ) )
|
||||
{
|
||||
static::buildPageUrlStore();
|
||||
}
|
||||
|
||||
return \IPS\Data\Store::i()->pages_page_urls;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set JS/CSS include keys
|
||||
*
|
||||
@@ -991,7 +1052,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$return = array();
|
||||
$dbWidgets = array();
|
||||
$areas = array();
|
||||
|
||||
|
||||
foreach( \IPS\Db::i()->select( '*', 'cms_page_widget_areas', array( 'area_page_id=?', $this->id ) ) as $k => $widgetMain )
|
||||
{
|
||||
$widgets[ $widgetMain['area_area'] ] = json_decode( $widgetMain['area_widgets'], TRUE );
|
||||
@@ -1000,7 +1061,8 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
/* We need to execute database widgets first as this sets up the Database dispatcher correctly */
|
||||
foreach( $widgets[ $widgetMain['area_area'] ] as $widget )
|
||||
{
|
||||
if ( $widget['key'] === 'Database' )
|
||||
/* Do not attempt to re-parse database widgets if we already have */
|
||||
if ( ! \IPS\cms\Databases\Dispatcher::i()->databaseId AND $widget['key'] === 'Database' )
|
||||
{
|
||||
$orientation = ( ( $widgetMain['area_area'] == 'sidebar' ) ? 'vertical' : ( ( $widgetMain['area_area'] === 'header' OR $widgetMain['area_area'] === 'footer' ) ? 'horizontal' : $widgetMain['area_orientation'] ) );
|
||||
$dbWidgets[ $widget['unique'] ] = \IPS\Widget::load( \IPS\Application::load( $widget['app'] ), $widget['key'], $widget['unique'], ( isset( $widget['configuration'] ) ) ? $widget['configuration'] : array(), ( isset( $widget['restrict'] ) ? $widget['restrict'] : null ), $orientation );
|
||||
@@ -1017,7 +1079,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
try
|
||||
{
|
||||
if ( $widget['key'] == 'Database' )
|
||||
if ( $widget['key'] == 'Database' and array_key_exists( $widget['unique'], $dbWidgets ) )
|
||||
{
|
||||
$_widget = $dbWidgets[ $widget['unique'] ];
|
||||
}
|
||||
@@ -1156,9 +1218,19 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
$pageType = $this->type;
|
||||
}
|
||||
|
||||
|
||||
foreach( static::formElements( $this ) as $name => $field )
|
||||
{
|
||||
if ( $pageType !== 'html' and in_array( $name, array( 'page_ipb_wrapper', 'page_show_sidebar', 'page_wrapper_template' ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( $pageType === 'html' and in_array( $name, array( 'page_template' ) ) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( is_array( $field ) )
|
||||
{
|
||||
if ( mb_substr( $name, 0, 4 ) === 'tab_' )
|
||||
@@ -1179,20 +1251,42 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
if ( ! $this->id )
|
||||
{
|
||||
$form->addTab( 'content_page_form_tab__menu' );
|
||||
$toggles = array();
|
||||
$toggles = array( 'menu_manager_access_type', 'menu_parent' );
|
||||
$formFields = array();
|
||||
|
||||
foreach( \IPS\cms\Pages\Menu::formElements( NULL, 'page' ) as $name => $field )
|
||||
|
||||
foreach( \IPS\cms\extensions\core\FrontNavigation\Pages::configuration( array() ) as $field )
|
||||
{
|
||||
$toggles[] = $name;
|
||||
$formFields[ $name ] = $field;
|
||||
if ( $field->name !== 'menu_content_page' )
|
||||
{
|
||||
$toggles[] = $field->name;
|
||||
$formFields[ $field->name ] = $field;
|
||||
}
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'page_add_to_menu', FALSE, FALSE, array( 'togglesOn' => $toggles ) ) );
|
||||
|
||||
$roots = array();
|
||||
foreach ( \IPS\core\FrontNavigation::i()->roots( FALSE ) as $item )
|
||||
{
|
||||
$roots[ $item->id ] = $item->title();
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'menu_parent', '*', NULL, array( 'options' => $roots ), NULL, NULL, NULL, 'menu_parent' ) );
|
||||
|
||||
|
||||
foreach( $formFields as $name => $field )
|
||||
{
|
||||
$form->add( $field );
|
||||
}
|
||||
|
||||
$groups = array();
|
||||
foreach ( \IPS\Member\Group::groups() as $group )
|
||||
{
|
||||
$groups[ $group->g_id ] = $group->name;
|
||||
}
|
||||
$form->add( new \IPS\Helpers\Form\Radio( 'menu_manager_access_type', 0, TRUE, array(
|
||||
'options' => array( 0 => 'menu_manager_access_type_inherit', 1 => 'menu_manager_access_type_override' ),
|
||||
'toggles' => array( 1 => array( 'menu_manager_access' ) )
|
||||
), NULL, NULL, NULL, 'menu_manager_access_type' ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'menu_manager_access', '*', NULL, array( 'multiple' => TRUE, 'options' => $groups, 'unlimited' => '*', 'unlimitedLang' => 'everyone' ), NULL, NULL, NULL, 'menu_manager_access' ) );
|
||||
}
|
||||
|
||||
if ( $pageType === 'builder' )
|
||||
@@ -1296,20 +1390,39 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
if( $values['page_add_to_menu'] )
|
||||
{
|
||||
$menuValues = array(
|
||||
'menu_type' => 'page',
|
||||
'menu_title_page' => $values['menu_title_page'],
|
||||
'menu_content_page' => $this->id,
|
||||
'menu_permission' => $values['menu_permission'],
|
||||
'menu_permission_type' => $values['menu_permission_type'],
|
||||
'menu_parent_id' => $values['menu_parent_id']
|
||||
$values = \IPS\cms\extensions\core\FrontNavigation\Pages::parseConfiguration( $values, $this->id );
|
||||
$config = array( 'menu_content_page' => $this->id );
|
||||
|
||||
foreach( array( 'menu_title_page_type', 'menu_title_page' ) as $field )
|
||||
{
|
||||
if ( isset( $values[ $field ] ) )
|
||||
{
|
||||
$config[ $field ] = $values[ $field ];
|
||||
}
|
||||
}
|
||||
|
||||
$save = array(
|
||||
'app' => 'cms',
|
||||
'extension' => 'Pages',
|
||||
'config' => json_encode( $config ),
|
||||
'parent' => $values['menu_parent'],
|
||||
'permissions' => $values['menu_manager_access'] == '*' ? '*' : implode( ',', $values['menu_manager_access'] )
|
||||
);
|
||||
|
||||
$menu = new \IPS\cms\Pages\Menu();
|
||||
$menu->saveForm( $menu->formatFormValues( $menuValues ) );
|
||||
|
||||
try
|
||||
{
|
||||
$save['position'] = \IPS\Db::i()->select( 'MAX(position)', 'core_menu', array( 'parent=?', \IPS\Request::i()->parent ) )->first() + 1;
|
||||
}
|
||||
catch ( \UnderflowException $e )
|
||||
{
|
||||
$save['position'] = 1;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->insert( 'core_menu', $save );
|
||||
unset( \IPS\Data\Store::i()->frontNavigation );
|
||||
}
|
||||
|
||||
unset( $values['page_add_to_menu'], $values['menu_title_page'], $values['menu_permission'], $values['menu_permission_type'], $values['menu_parent_id'] );
|
||||
unset( $values['page_add_to_menu'], $values['menu_title_page_type'], $values['menu_title_page'], $values['menu_parent'], $values['menu_manager_access'], $values['menu_manager_access_type'] );
|
||||
}
|
||||
|
||||
return $values;
|
||||
@@ -1683,13 +1796,42 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
\IPS\Db::i()->delete( 'cms_page_menu', array( 'menu_type=? AND menu_content=?', 'page', $this->id ) );
|
||||
unset( \IPS\Data\Store::i()->cms_menu );
|
||||
|
||||
$delete = $this->getMenuItemIds();
|
||||
|
||||
if ( count( $delete ) )
|
||||
{
|
||||
\IPS\Db::i()->delete( 'core_menu', \IPS\Db::i()->in( 'id', $delete ) );
|
||||
}
|
||||
|
||||
unset( \IPS\Data\Store::i()->frontNavigation );
|
||||
|
||||
return parent::delete();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns core_menu ids for all menu items associated with this page
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getMenuItemIds()
|
||||
{
|
||||
$items = array();
|
||||
foreach( \IPS\Db::i()->select( '*', 'core_menu', array( 'app=? AND extension=?', 'cms', 'Pages' ) ) as $item )
|
||||
{
|
||||
$json = json_decode( $item['config'], TRUE );
|
||||
|
||||
if ( isset( $json['menu_content_page'] ) )
|
||||
{
|
||||
if ( $json['menu_content_page'] == $this->id )
|
||||
{
|
||||
$items[] = $item['id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the permission index permissions
|
||||
@@ -1700,9 +1842,9 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
*/
|
||||
public function setPermissions( $insert, \IPS\Helpers\Form\Matrix $matrix )
|
||||
{
|
||||
\IPS\cms\Pages\Menu::clearCaches();
|
||||
parent::setPermissions( $insert, $matrix );
|
||||
|
||||
static::buildPageUrlStore();
|
||||
|
||||
/* Update perms if we have a child database */
|
||||
try
|
||||
{
|
||||
@@ -1732,10 +1874,10 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
{
|
||||
static::deleteCompiled( $this->id );
|
||||
}
|
||||
|
||||
\IPS\cms\Pages\Menu::clearCaches();
|
||||
|
||||
parent::save();
|
||||
|
||||
static::buildPageUrlStore();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1758,7 +1900,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
\IPS\DB::i()->update( 'cms_pages', array( 'page_default' => 0 ), array( 'page_folder_id=?', $this->folder_id ) );
|
||||
\IPS\DB::i()->update( 'cms_pages', array( 'page_default' => 1 ), array( 'page_id=?', $this->id ) );
|
||||
|
||||
\IPS\cms\Pages\Menu::clearCaches();
|
||||
static::buildPageUrlStore();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1772,4 +1914,140 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
|
||||
$this->full_path = trim( $path . '/' . $this->seo_name, '/' );
|
||||
$this->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Displays a page
|
||||
*
|
||||
* @param int $httpStatusCode HTTP Status Code
|
||||
* @param array $httpHeaders Additional HTTP Headers
|
||||
* @throws \ErrorException
|
||||
* @return void
|
||||
*/
|
||||
public function output( $title=NULL, $httpStatusCode=NULL, $httpHeaders=NULL )
|
||||
{
|
||||
$includes = $this->getIncludes();
|
||||
|
||||
if ( isset( $includes['js'] ) and is_array( $includes['js'] ) )
|
||||
{
|
||||
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, array_values( $includes['js'] ) );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
if ( $this->ipb_wrapper or $this->type === 'builder' )
|
||||
{
|
||||
$this->setTheme();
|
||||
$nav = array();
|
||||
|
||||
\IPS\Output::i()->title = $this->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 ( $this->type === 'builder' )
|
||||
{
|
||||
list( $group, $name, $key ) = explode( '__', $this->template );
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('pages')->globalWrap( $nav, \IPS\cms\Theme::i()->getTemplate($group, 'cms', 'page')->$name( $this, $this->getWidgets() ), $this );
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Populate \IPS\Output::i()->sidebar['widgets'] sidebar/header/footer widgets */
|
||||
$this->getWidgets();
|
||||
|
||||
\IPS\Output::i()->output = \IPS\Theme::i()->getTemplate('pages')->globalWrap( $nav, $this->getHtmlContent(), $this );
|
||||
}
|
||||
|
||||
\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 ( $this->meta_keywords AND ( !isset( \IPS\Output::i()->metaTags['keywords'] ) OR !\IPS\Output::i()->metaTags['keywords'] ) )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['keywords'] = $this->meta_keywords;
|
||||
}
|
||||
|
||||
if ( $this->meta_description AND ( !isset( \IPS\Output::i()->metaTags['description'] ) OR !\IPS\Output::i()->metaTags['description'] ) )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['description'] = $this->meta_description;
|
||||
}
|
||||
|
||||
/* Can only disable sidebar if HTML page */
|
||||
if ( ! $this->show_sidebar and $this->type === 'html' )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['enabled'] = false;
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Settings::i()->cms_error_page ) and \IPS\Settings::i()->cms_error_page and \IPS\Settings::i()->cms_error_page == $this->id )
|
||||
{
|
||||
\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\Application::load('cms')->default AND ! $this->folder_id AND $this->default ) )
|
||||
{
|
||||
\IPS\Output::i()->breadcrumb['module'] = array( $this->url(), $this->_title );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Settings::i()->cms_error_page ) and \IPS\Settings::i()->cms_error_page and \IPS\Settings::i()->cms_error_page == $this->id )
|
||||
{
|
||||
/* Set the title */
|
||||
\IPS\Output::i()->title = ( $title ) ? $title : $this->getHtmlTitle();
|
||||
\IPS\Output::i()->output = $this->getHtmlContent();
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( \IPS\Output::i()->title );
|
||||
|
||||
/* Send straight to the output engine */
|
||||
\IPS\Output::i()->sendOutput( \IPS\Theme::i()->getTemplate( 'global', 'core' )->globalTemplate( \IPS\Output::i()->title, \IPS\Output::i()->output, array( 'app' => \IPS\Dispatcher::i()->application->directory, 'module' => \IPS\Dispatcher::i()->module->key, 'controller' => \IPS\Dispatcher::i()->controller ) ), ( $httpStatusCode ? $httpStatusCode : 200 ), 'text/html', ( $httpHeaders ? $httpHeaders : \IPS\Output::i()->httpHeaders ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
\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 ( $this->meta_keywords AND ( !isset( \IPS\Output::i()->metaTags['keywords'] ) OR !\IPS\Output::i()->metaTags['keywords'] ) )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['keywords'] = $this->meta_keywords;
|
||||
}
|
||||
|
||||
if ( $this->meta_description AND ( !isset( \IPS\Output::i()->metaTags['description'] ) OR !\IPS\Output::i()->metaTags['description'] ) )
|
||||
{
|
||||
\IPS\Output::i()->metaTags['description'] = $this->meta_description;
|
||||
}
|
||||
|
||||
/* Meta tags */
|
||||
\IPS\Output::i()->buildMetaTags();
|
||||
|
||||
if ( $this->wrapper_template and $this->wrapper_template !== '_none_' and ! \IPS\Request::i()->isAjax() )
|
||||
{
|
||||
try
|
||||
{
|
||||
list( $group, $name, $key ) = explode( '__', $this->wrapper_template );
|
||||
\IPS\Output::i()->sendOutput( \IPS\cms\Theme::i()->getTemplate($group, 'cms', 'page')->$name( $this->getHtmlContent(), $this->getHtmlTitle() ), 200, $this->getContentType(), \IPS\Output::i()->httpHeaders );
|
||||
}
|
||||
catch( \OutOfRangeException $e )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* Set the title */
|
||||
\IPS\Output::i()->title = ( $title ) ? $title : $this->getHtmlTitle();
|
||||
\IPS\Member::loggedIn()->language()->parseOutputForDisplay( \IPS\Output::i()->title );
|
||||
|
||||
/* Send straight to the output engine */
|
||||
\IPS\Output::i()->sendOutput( $this->getHtmlContent(), ( $httpStatusCode ? $httpStatusCode : 200 ), $this->getContentType(), ( $httpHeaders ? $httpHeaders : \IPS\Output::i()->httpHeaders ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user