Version 4.5.0

This commit is contained in:
Neo committed 2025-12-19 05:51:58 -08:00
1 parent 1a0c7fd3c2
commit f79dcf067a
3791 files changed
+248032 -76372

No files matched your search

+199 -115
View File
@@ -12,7 +12,7 @@
namespace IPS\cms\Pages;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
@@ -27,7 +27,13 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
* @brief [ActiveRecord] Multiton Store
*/
protected static $multitons;
/**
* @brief [ActiveRecord] Caches
* @note Defined cache keys will be cleared automatically as needed
*/
protected $caches = array( 'frontNavigation' );
/**
* @brief [ActiveRecord] Database Table
*/
@@ -192,14 +198,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
if ( isset( $qs['id'] ) )
{
if ( method_exists( get_called_class(), 'loadAndCheckPerms' ) )
{
return static::loadAndCheckPerms( $qs['id'] );
}
else
{
return static::load( $qs['id'] );
}
return static::load( $qs['id'] );
}
else if ( isset( $qs['path'] ) )
{
@@ -264,7 +263,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
public static function getChildren( $folderId=0 )
{
$children = array();
foreach( \IPS\Db::i()->select( '*', static::$databaseTable, array( 'page_folder_id=?', intval( $folderId ) ), 'page_seo_name ASC' ) as $child )
foreach( \IPS\Db::i()->select( '*', static::$databaseTable, array( 'page_folder_id=?', \intval( $folderId ) ), 'page_seo_name ASC' ) as $child )
{
$children[ $child[ static::$databasePrefix . static::$databaseColumnId ] ] = static::load( $child[ static::$databasePrefix . static::$databaseColumnId ] );
}
@@ -316,7 +315,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
$bits = explode( '/', $path );
$pathsToTry = array();
while( count( $bits ) )
while( \count( $bits ) )
{
$pathsToTry[] = implode( '/', $bits );
@@ -370,7 +369,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
*
* @param string $slug Thing that lives in the garden and eats your plants
* @param string|NULL $queryString Any query string to add to the end
* @return \IPS\cms\Pages\Page
* @return \IPS\Http\Url
*/
public static function getUrlFromHistory( $slug, $queryString=NULL )
{
@@ -409,7 +408,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' );
return static::load( $newPath, 'page_full_path' )->url();
}
catch( \OutOfRangeException $ex )
{
@@ -441,7 +440,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
/* Try the easiest method first */
try
{
static::$defaultPage[ $folderId ] = \IPS\cms\Pages\Page::load( \IPS\Db::i()->select( 'page_id', static::$databaseTable, array( 'page_default=? AND page_folder_id=?', 1, intval( $folderId ) ) )->first() );
static::$defaultPage[ $folderId ] = \IPS\cms\Pages\Page::load( \IPS\Db::i()->select( 'page_id', static::$databaseTable, array( 'page_default=? AND page_folder_id=?', 1, \intval( $folderId ) ) )->first() );
}
catch( \Exception $ex )
{
@@ -477,7 +476,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public static function deleteCompiled( $ids )
{
if ( is_numeric( $ids ) )
if ( \is_numeric( $ids ) )
{
$ids = array( $ids );
}
@@ -595,7 +594,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
$testFolder = \IPS\cms\Pages\Folder::load( $val, 'folder_name' );
/* Ok, we have a folder, but is it on the same tree as us ?*/
if ( intval( \IPS\Request::i()->page_folder_id ) == $testFolder->parent_id )
if ( \intval( \IPS\Request::i()->page_folder_id ) == $testFolder->parent_id )
{
/* Yep, this will break designers' mode and may confuse the FURL engine so we cannot allow this */
throw new \InvalidArgumentException('content_folder_name_furl_collision_pages');
@@ -626,7 +625,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
}
/* Not us */
if ( intval( \IPS\Request::i()->page_folder_id ) == $test->folder_id )
if ( \intval( \IPS\Request::i()->page_folder_id ) == $test->folder_id )
{
throw new \InvalidArgumentException( 'content_page_file_name_in_use' );
}
@@ -638,7 +637,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
}
}, NULL, NULL, 'page_seo_name' );
$return['page_folder_id'] = new \IPS\Helpers\Form\Node( 'page_folder_id', ( $item ? intval( $item->folder_id ) : ( ( isset( \IPS\Request::i()->parent ) and \IPS\Request::i()->parent ) ? \IPS\Request::i()->parent : 0 ) ), FALSE, array(
$return['page_folder_id'] = new \IPS\Helpers\Form\Node( 'page_folder_id', ( $item ? \intval( $item->folder_id ) : ( ( isset( \IPS\Request::i()->parent ) and \IPS\Request::i()->parent ) ? \IPS\Request::i()->parent : 0 ) ), FALSE, array(
'class' => 'IPS\cms\Pages\Folder',
'zeroVal' => 'node_no_parent',
'subnodes' => false
@@ -666,7 +665,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
'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 )
@@ -692,12 +691,12 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
$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 );
if ( count( $js ) OR count( $css ) )
if ( \count( $js ) OR \count( $css ) )
{
$return['tab_js_css'] = array( 'content_page_form_tab__includes', NULL, NULL, 'ipsForm_horizontal' );
$return['msg_js_css'] = array( 'cms_page_includes_message', 'ipsMessage ipsMessage_info ipsCmsIncludesMessage' );
if ( count( $js ) )
if ( \count( $js ) )
{
$jsincludes = array();
foreach( $js as $obj )
@@ -709,7 +708,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
$return['page_includes_js'] = new \IPS\Helpers\Form\CheckboxSet( 'page_includes_js', $item ? $item->js_includes : FALSE, FALSE, array( 'options' => $jsincludes, 'multiple' => true ), NULL, NULL, NULL, 'page_includes_js' );
}
if ( count( $css ) )
if ( \count( $css ) )
{
$cssincludes = array();
foreach( $css as $obj )
@@ -725,34 +724,14 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
if ( $pageType === 'html' )
{
$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['cms_tag_databases']['{database="' . $db->key . '"}'] = $db->_title;
}
}
foreach( \IPS\cms\Blocks\Block::roots( NULL, NULL ) as $id => $block )
$tagSource = \IPS\Http\Url::internal( "app=cms&module=pages&controller=ajax&do=loadTags" );
if ( $item )
{
$tags['cms_tag_blocks']['{block="' . $block->key . '"}'] = $block->_title;
$tagSource = $tagSource->setQueryString( 'pageId', $item->id );
}
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, ENT_DISALLOWED, 'UTF-8', TRUE ) : NULL, FALSE, array( 'tags' => $tags, 'height' => 600 ), function( $val )
$return['page_content'] = new \IPS\Helpers\Form\Codemirror( 'page_content', $item ? htmlentities( $item->content, ENT_DISALLOWED, 'UTF-8', TRUE ) : NULL, FALSE, array( 'tagSource' => $tagSource, 'height' => 600 ), function( $val )
{
/* Test */
try
@@ -770,26 +749,34 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
preg_match( '#{database="([^"]+?)"#', $val, $matches );
if ( isset( $matches[1] ) )
{
try
$database = NULL;
if ( \is_numeric( $matches[1] ) )
{
if ( is_numeric( $matches[1] ) )
try
{
$database = \IPS\cms\Databases::load( intval( $matches[1] ) );
$database = \IPS\cms\Databases::load( \intval( $matches[1] ) );
}
else
catch( \OutOfRangeException $ex ){}
}
if( $database === NULL )
{
try
{
$database = \IPS\cms\Databases::load( $matches[1], 'database_key' );
}
if ( $database->page_id )
{
throw new \LogicException('cms_err_db_in_use_other_page');
}
catch( \OutOfRangeException $ex ){}
}
catch( \OutOfRangeException $ex )
if( $database === NULL )
{
throw new \LogicException('cms_err_db_does_not_exist');
}
elseif( $database->page_id )
{
throw new \LogicException('cms_err_db_in_use_other_page');
}
}
}
}, NULL, NULL, 'page_content' );
@@ -846,6 +833,12 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
return TRUE;
}
/* Cannot have /page/ as it confuses SEO pagination */
if ( mb_strstr( '/' . $path . '/', '/page/' ) )
{
return TRUE;
}
$defaultApplication = \IPS\Db::i()->select( 'app_directory', 'core_applications', 'app_default=1' )->first();
foreach( \IPS\Application::applications() as $key => $app )
@@ -942,6 +935,8 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
}
\IPS\Data\Store::i()->pages_page_urls = $store;
\IPS\Member::clearCreateMenu();
}
/**
@@ -949,7 +944,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
*
* @return array
*/
public static function getPageUrlStore()
public static function getStore()
{
if ( ! isset( \IPS\Data\Store::i()->pages_page_urls ) )
{
@@ -958,6 +953,53 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
return \IPS\Data\Store::i()->pages_page_urls;
}
/**
* Returns (and builds if required) the pages id => url datastore
*
* @return array
* @deprecated
*/
public static function getPageUrlStore()
{
return static::getStore();
}
/**
* Get page path, returning stripped path and current page number
*
* @param string $path Page path
* @return array Current path, Current page number
*/
public static function getStrippedPagePath( string $path ): array
{
/* Have a bash at pagination as it's not like we've much else to do */
$stripped = \IPS\Http\Url\Friendly::stripPageComponent( '/' . trim( $path, '/' ) . '/' );
if ( trim( $path, '/' ) != trim( $stripped, '/' ) )
{
if ( $stripped !== '/' )
{
$pageStuff = str_replace( ltrim( $stripped, '/' ), '', $path );
}
else
{
$pageStuff = $path;
}
}
else
{
return array( $path, NULL );
}
$bomb = explode( '/', $pageStuff );
if ( !empty( $bomb[1] ) )
{
return array( trim( $stripped, '/' ), $bomb[1] );
}
return array( $path, NULL );
}
/**
* Set JS/CSS include keys
@@ -967,7 +1009,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
public function set__js_css_ids( $value )
{
$this->_data['js_css_ids'] = ( is_array( $value ) ? json_encode( $value ) : $value );
$this->_data['js_css_ids'] = ( \is_array( $value ) ? json_encode( $value ) : $value );
}
/**
@@ -977,12 +1019,12 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
*/
protected function get__js_css_ids()
{
if ( ! is_array( $this->_data['js_css_ids'] ) )
if ( ! \is_array( $this->_data['js_css_ids'] ) )
{
$this->_data['js_css_ids'] = json_decode( $this->_data['js_css_ids'], true );
}
return ( is_array( $this->_data['js_css_ids'] ) ) ? $this->_data['js_css_ids'] : array();
return ( \is_array( $this->_data['js_css_ids'] ) ) ? $this->_data['js_css_ids'] : array();
}
/**
@@ -1035,7 +1077,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
foreach( array( 'js', 'css' ) as $thing )
{
$includeKey = $thing . '_includes';
if ( count( $this->$includeKey ) )
if ( \count( $this->$includeKey ) )
{
/* Build a file object for each thing */
foreach( $this->$includeKey as $key )
@@ -1069,7 +1111,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
\IPS\Theme::lock( "page_object_build" . $this->id );
if ( count( $this->js_includes ) )
if ( \count( $this->js_includes ) )
{
/* Build a file object for each JS */
foreach( $this->js_includes as $key )
@@ -1088,7 +1130,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
}
}
if ( count( $this->css_includes ) )
if ( \count( $this->css_includes ) )
{
/* Build a file object for each JS */
foreach( $this->css_includes as $key )
@@ -1123,7 +1165,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
foreach( $return as $type => $data )
{
if ( is_array( $data ) )
if ( \is_array( $data ) )
{
foreach( $data as $key => $object )
{
@@ -1154,7 +1196,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
$extension = mb_substr( $this->seo_name, ( mb_strrpos( $this->seo_name, '.' ) + 1 ) );
if ( in_array( $extension, array_keys( $map ) ) )
if ( \in_array( $extension, array_keys( $map ) ) )
{
return $map[ $extension ];
}
@@ -1215,7 +1257,8 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
\IPS\Theme::runProcessFunction( \IPS\Data\Store::i()->$functionName, $functionName );
}
return call_user_func( 'IPS\\Theme\\'. $functionName );
$themeFunction = 'IPS\\Theme\\'. $functionName;
return $themeFunction();
}
/**
@@ -1259,8 +1302,9 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
}
}
if( count( $widgets ) )
if( \count( $widgets ) )
{
$googleFonts = array();
foreach ( $widgets as $areaKey => $area )
{
foreach ( $area as $widget )
@@ -1285,9 +1329,25 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
}
$_widget = \IPS\Widget::load( $appOrPlugin, $widget['key'], $widget['unique'], ( isset( $widget['configuration'] ) ) ? $widget['configuration'] : array(), ( isset( $widget['restrict'] ) ? $widget['restrict'] : null ), $orientation );
if ( \in_array( 'IPS\Widget\Builder', class_implements( $_widget ) ) )
{
if ( ! empty( $_widget->configuration['widget_adv__font'] ) and $_widget->configuration['widget_adv__font'] !== 'inherit' )
{
$font = $_widget->configuration['widget_adv__font'];
if ( \mb_substr( $font, -6 ) === ' black' )
{
$fontWeight = 900;
$font = \mb_substr( $font, 0, -6 ) . ':400,900';
}
$googleFonts[ $font ] = $font;
}
}
}
if ( in_array( $areaKey, array('header', 'footer', 'sidebar' ) ) )
if ( \in_array( $areaKey, array('header', 'footer', 'sidebar' ) ) )
{
\IPS\Output::i()->sidebar['widgets'][ $areaKey ][] = $_widget;
}
@@ -1300,6 +1360,11 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
}
}
}
if ( \count( $googleFonts ) )
{
\IPS\Output::i()->linkTags['googlefonts'] = array('rel' => 'stylesheet', 'href' => "https://fonts.googleapis.com/css?family=" . implode( "|", array_values( $googleFonts ) ) . "&display=swap");
}
}
return $this->cachedWidgets;
@@ -1364,7 +1429,16 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
$return['default'] = array(
'icon' => $this->default ? 'star' : 'star-o',
'title' => 'content_default_page',
'link' => $url->setQueryString( array( 'id' => $this->id, 'subnode' => 1, 'do' => 'setAsDefault' ) )
'link' => $url->setQueryString( array( 'id' => $this->id, 'subnode' => 1, 'do' => 'setAsDefault' ) )->csrf()
);
}
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'pages', 'page_edit' ) and $this->type !== 'builder' )
{
$return['default_error'] = array(
'icon' => \IPS\Settings::i()->cms_error_page == $this->id ? 'exclamation-circle' : 'exclamation',
'title' => \IPS\Settings::i()->cms_error_page == $this->id ? 'content_remove_error_page' : 'content_default_error_page',
'link' => $url->setQueryString( array( 'id' => \IPS\Settings::i()->cms_error_page ? 0 : $this->id, 'subnode' => 1, 'do' => 'toggleDefaultError' ) )->csrf()
);
}
@@ -1411,25 +1485,25 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
foreach( static::formElements( $this ) as $name => $field )
{
if ( $pageType !== 'html' and in_array( $name, array( 'page_ipb_wrapper', 'page_show_sidebar', 'page_wrapper_template' ) ) )
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' ) ) )
if ( $pageType === 'html' and \in_array( $name, array( 'page_template' ) ) )
{
continue;
}
if ( is_array( $field ) )
if ( \is_array( $field ) )
{
if ( mb_substr( $name, 0, 4 ) === 'tab_' )
{
call_user_func_array( array( $form, 'addTab' ), $field );
$form->addTab( ...$field );
}
else if ( mb_substr( $name, 0, 4 ) === 'msg_' )
{
call_user_func_array( array( $form, 'addMessage' ), $field );
$form->addMessage( ...$field );
}
}
else
@@ -1440,7 +1514,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
if ( ! $this->id )
{
$form->addTab( 'content_page_form_tab__menu' );
$form->addTab( 'content_page_form_tab__menu', NULL, NULL, 'ipsForm_horizontal' );
$toggles = array( 'menu_manager_access_type', 'menu_parent' );
$formFields = array();
@@ -1523,7 +1597,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
if( isset( $values['page_name'] ) )
{
$_copied = $values['page_name'];
$values['page_seo_name'] = empty( $values['page_seo_name'] ) ? ( is_array( $_copied ) ? array_shift( $_copied ) : $_copied ) : $values['page_seo_name'];
$values['page_seo_name'] = empty( $values['page_seo_name'] ) ? ( \is_array( $_copied ) ? array_shift( $_copied ) : $_copied ) : $values['page_seo_name'];
$bits = explode( '.', $values['page_seo_name'] );
foreach( $bits as $i => $v )
@@ -1621,8 +1695,6 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
}
\IPS\Db::i()->update( 'core_menu', array( 'config' => json_encode( $config ) ), array( 'id=?', $id ) );
unset( \IPS\Data\Store::i()->frontNavigation );
}
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'] );
@@ -1700,9 +1772,9 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
if ( isset( $matches[1] ) )
{
if ( is_numeric( $matches[1] ) )
if ( \is_numeric( $matches[1] ) )
{
return intval( $matches[1] );
return \intval( $matches[1] );
}
else
{
@@ -1735,19 +1807,10 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
{
if( $this->_url === NULL )
{
if ( ( \IPS\Application::load('cms')->default OR \IPS\Settings::i()->cms_use_different_gateway ) AND $this->default AND ! $this->folder_id )
if ( \IPS\Application::load('cms')->default AND $this->default AND ! $this->folder_id )
{
/* Are we using the gateway file? */
if ( \IPS\Settings::i()->cms_use_different_gateway )
{
/* Yes, work out the proper URL. */
$this->_url = \IPS\Http\Url::createFromString( \IPS\Settings::i()->cms_root_page_url, TRUE );
}
else
{
/* No - that's easy */
$this->_url = \IPS\Http\Url::internal( '', 'front' );
}
/* No - that's easy */
$this->_url = \IPS\Http\Url::internal( '', 'front' );
}
else
{
@@ -1808,7 +1871,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
{
try
{
call_user_func( array( $pluginClass, $method ), $value, $options, $this );
$pluginClass::$method( $value, $options, $this );
}
catch( \Exception $ex )
{
@@ -1835,7 +1898,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
}
catch( \LogicException $e ) { }
$this->mapToDatabase( intval( $database->id ) );
$this->mapToDatabase( \intval( $database->id ) );
}
}
else
@@ -1912,7 +1975,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
if ( $databaseUsed !== NULL )
{
$this->mapToDatabase( intval( $databaseUsed ) );
$this->mapToDatabase( \intval( $databaseUsed ) );
}
else
{
@@ -1943,7 +2006,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
/* is this page already in use */
$database = \IPS\cms\Databases::load( $this->id, 'database_page_id' );
if ( $database->id === $databaseId )
if ( $database->id == $databaseId )
{
/* Nothing to update as this page is mapped to this database */
return TRUE;
@@ -1951,7 +2014,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
else
{
/* We're using another DB on this page */
throw new \LogicException('cms_err_db_already_on_page');
throw new \LogicException('cms_err_db_already_on_page' );
}
}
catch( \OutOfRangeException $e )
@@ -1972,6 +2035,10 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
/* Restore content in the search index */
\IPS\Task::queue( 'core', 'RebuildSearchIndex', array( 'class' => 'IPS\cms\Records' . $database->id ) );
/* Restore content in social promote table */
$class = 'IPS\cms\Records' . $database->id;
\IPS\core\Promote::changeHiddenByClass( new $class, FALSE );
}
return TRUE;
@@ -1993,6 +2060,10 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
/* Remove from search */
\IPS\Content\Search\Index::i()->removeClassFromSearchIndex( 'IPS\cms\Records' . $database->id );
/* Remove content in social promote table */
$class = 'IPS\cms\Records' . $database->id;
\IPS\core\Promote::changeHiddenByClass( new $class, TRUE );
}
catch( \OutOfRangeException $ex )
{
@@ -2019,13 +2090,11 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
$delete = $this->getMenuItemIds();
if ( count( $delete ) )
if ( \count( $delete ) )
{
\IPS\Db::i()->delete( 'core_menu', \IPS\Db::i()->in( 'id', $delete ) );
}
unset( \IPS\Data\Store::i()->frontNavigation );
/* Remove any widgets for this page */
\IPS\Db::i()->delete( 'cms_page_widget_areas', array( 'area_page_id=?', $this->id ) );
@@ -2067,12 +2136,11 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
* Set the permission index permissions
*
* @param array $insert Permission data to insert
* @param object \IPS\Helpers\Form\Matrix
* @return void
*/
public function setPermissions( $insert, \IPS\Helpers\Form\Matrix $matrix )
public function setPermissions( $insert )
{
parent::setPermissions( $insert, $matrix );
parent::setPermissions( $insert );
static::buildPageUrlStore();
/* Update perms if we have a child database */
@@ -2114,7 +2182,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
if ( $this->full_path and \IPS\Theme::designersModeEnabled() )
{
static::exportDesignersMode( $this->id );
}
}
}
/**
@@ -2166,7 +2234,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
{
$includes = $this->getIncludes();
if ( isset( $includes['js'] ) and is_array( $includes['js'] ) )
if ( isset( $includes['js'] ) and \is_array( $includes['js'] ) )
{
\IPS\Output::i()->jsFiles = array_merge( \IPS\Output::i()->jsFiles, array_values( $includes['js'] ) );
}
@@ -2180,7 +2248,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
\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'] ) )
if ( isset( $includes['css'] ) and \is_array( $includes['css'] ) )
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, array_values( $includes['css'] ) );
}
@@ -2208,15 +2276,31 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
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;
\IPS\Output::i()->metaTags['og:description'] = $this->meta_description;
}
/* If this is a default page, we may be accessing this from the folder only. The isset() check is to ensure canonical
tags for more specific things (like databases) are not overridden. */
if ( $this->default AND !isset( \IPS\Output::i()->linkTags['canonical'] ) )
if ( !isset( \IPS\Output::i()->linkTags['canonical'] ) )
{
\IPS\Output::i()->linkTags['canonical'] = (string) $this->url();
}
if ( !isset( \IPS\Output::i()->metaTags['og:url'] ) )
{
\IPS\Output::i()->metaTags['og:url'] = (string) $this->url();
}
if ( !isset( \IPS\Output::i()->metaTags['og:title'] ) )
{
\IPS\Output::i()->metaTags['og:title'] = \IPS\Output::i()->title;
}
if ( !isset( \IPS\Output::i()->metaTags['og:type'] ) )
{
\IPS\Output::i()->metaTags['og:type'] = 'website';
}
/* Can only disable sidebar if HTML page */
if ( ! $this->show_sidebar and $this->type === 'html' )
{
@@ -2243,7 +2327,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
\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 ) );
\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 : array() ) );
}
else
{
@@ -2257,7 +2341,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
{
$this->setTheme();
if ( isset( $includes['css'] ) and is_array( $includes['css'] ) )
if ( isset( $includes['css'] ) and \is_array( $includes['css'] ) )
{
\IPS\Output::i()->cssFiles = array_merge( \IPS\Output::i()->cssFiles, array_values( $includes['css'] ) );
}
@@ -2285,7 +2369,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
list( $group, $name, $key ) = explode( '__', $this->wrapper_template );
$content = $content ?: $this->getHtmlContent();
$content .= $mfa;
\IPS\Output::i()->sendOutput( \IPS\cms\Theme::i()->getTemplate($group, 'cms', 'page')->$name( $content, $this->getHtmlTitle() ), 200, $this->getContentType(), \IPS\Output::i()->httpHeaders );
\IPS\Output::i()->sendOutput( \IPS\cms\Theme::i()->getTemplate($group, 'cms', 'page')->$name( $content, $this->getHtmlTitle() ), 200, $this->getContentType() );
}
catch( \OutOfRangeException $e )
{
@@ -2300,7 +2384,7 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
/* Send straight to the output engine */
$content = $content ?: $this->getHtmlContent();
$content .= $mfa;
\IPS\Output::i()->sendOutput( $content, ( $httpStatusCode ? $httpStatusCode : 200 ), $this->getContentType(), ( $httpHeaders ? $httpHeaders : \IPS\Output::i()->httpHeaders ) );
\IPS\Output::i()->sendOutput( $content, ( $httpStatusCode ? $httpStatusCode : 200 ), $this->getContentType(), ( $httpHeaders ? $httpHeaders : array() ) );
}
}
@@ -2378,11 +2462,11 @@ class _Page extends \IPS\Node\Model implements \IPS\Node\Permissions
$databasePaths[] = $page['page_full_path'];
}
if ( count( $diskPaths ) )
if ( \count( $diskPaths ) )
{
foreach( $diskPaths as $path )
{
if ( ! in_array( $path, $databasePaths ) )
if ( ! \in_array( $path, $databasePaths ) )
{
@unlink( \IPS\ROOT_PATH . "/themes/cms/pages/" . $path );
}