Version 4.5.0
This commit is contained in:
1 parent
1a0c7fd3c2
commit
f79dcf067a
3791 files changed
+248032
-76372
No files matched your search
@@ -13,7 +13,7 @@
|
||||
namespace IPS\cms\modules\admin\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;
|
||||
@@ -24,6 +24,11 @@ exit;
|
||||
*/
|
||||
class _pages extends \IPS\Node\Controller
|
||||
{
|
||||
/**
|
||||
* @brief Has been CSRF-protected
|
||||
*/
|
||||
public static $csrfProtected = TRUE;
|
||||
|
||||
/**
|
||||
* Node Class
|
||||
*/
|
||||
@@ -122,14 +127,6 @@ class _pages extends \IPS\Node\Controller
|
||||
FALSE
|
||||
);
|
||||
|
||||
/* Add a button for managing DB settings */
|
||||
\IPS\Output::i()->sidebar['actions']['pagessettings'] = array(
|
||||
'title' => 'cms_pages_settings',
|
||||
'icon' => 'wrench',
|
||||
'link' => \IPS\Http\Url::internal( 'app=cms&module=pages&controller=pages&do=settings' ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('cms_pages_settings') )
|
||||
);
|
||||
|
||||
if ( \IPS\Member::loggedIn()->hasAcpRestriction( 'cms', 'pages', 'page_add' ) )
|
||||
{
|
||||
\IPS\Output::i()->sidebar['actions']['add_folder'] = array(
|
||||
@@ -150,115 +147,6 @@ class _pages extends \IPS\Node\Controller
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Page settings form
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function settings()
|
||||
{
|
||||
$url = parse_url( \IPS\Settings::i()->base_url );
|
||||
$disabled = FALSE;
|
||||
$options = array();
|
||||
$url['path'] = preg_replace( '#^/?(.+?)?/?$#', '\1', $url['path'] );
|
||||
|
||||
$disabled = ( \IPS\Settings::i()->cms_use_different_gateway or $url['path'] ) ? FALSE : TRUE;
|
||||
$dirs = explode( '/', $url['path'] );
|
||||
|
||||
if ( count( $dirs ) )
|
||||
{
|
||||
array_pop( $dirs );
|
||||
$base = $url['scheme'] . '://' . $url['host'];
|
||||
if ( isset( $url['port'] ) )
|
||||
{
|
||||
$base .= ':' .$url['port'];
|
||||
}
|
||||
|
||||
$base .= '/';
|
||||
$options[ $base ] = $base;
|
||||
foreach( $dirs as $dir )
|
||||
{
|
||||
$base .= $dir . '/';
|
||||
$options[ $base ] = $base;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $disabled )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['cms_use_different_gateway_warning'] = \IPS\Member::loggedIn()->language()->addToStack('cms_pages_different_gateway_impossible');
|
||||
}
|
||||
|
||||
if ( \IPS\Settings::i()->htaccess_mod_rewrite )
|
||||
{
|
||||
\IPS\Member::loggedIn()->language()->words['cms_root_page_url_desc'] = \IPS\Member::loggedIn()->language()->addToStack('cms_root_page_url_rewrite_desc');
|
||||
}
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'form', 'save' );
|
||||
$form->add( new \IPS\Helpers\Form\YesNo( 'cms_use_different_gateway', \IPS\Settings::i()->cms_use_different_gateway, FALSE, array( 'togglesOn' => array( 'cms_root_page_url' ), 'disabled' => $disabled ) ) );
|
||||
$form->add( new \IPS\Helpers\Form\Select( 'cms_root_page_url', \IPS\Settings::i()->cms_root_page_url, FALSE, array( 'options' => $options ), function( $val )
|
||||
{
|
||||
if ( $val and \IPS\Request::i()->cms_use_different_gateway )
|
||||
{
|
||||
if ( mb_substr( $val, -1 ) !== '/' )
|
||||
{
|
||||
$val .= '/';
|
||||
}
|
||||
|
||||
$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( NULL, NULL, FALSE )->get();
|
||||
|
||||
if ( $response->httpResponseCode != 200 and $response->httpResponseCode != 303 and ( \IPS\Settings::i()->site_online OR $response->httpResponseCode != 503 ) )
|
||||
{
|
||||
if ( \IPS\Settings::i()->htaccess_mod_rewrite )
|
||||
{
|
||||
throw new \LogicException( 'pages_different_gateway_load_error_rewrite' );
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new \LogicException( 'pages_different_gateway_load_error' );
|
||||
}
|
||||
}
|
||||
}
|
||||
}, NULL, NULL, 'cms_root_page_url' ) );
|
||||
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'cms_error_page', \IPS\Settings::i()->cms_error_page ? \IPS\Settings::i()->cms_error_page : 0, FALSE,array(
|
||||
'class' => '\IPS\cms\Pages\Page',
|
||||
'zeroVal' => 'cms_error_page_none',
|
||||
'subnodes' => true,
|
||||
'permissionCheck' => function( $node )
|
||||
{
|
||||
return $node->type == 'html';
|
||||
}
|
||||
) ) );
|
||||
|
||||
if ( $values = $form->values() )
|
||||
{
|
||||
$form->saveAsSettings();
|
||||
\IPS\Member::clearCreateMenu();
|
||||
|
||||
/* Clear Sidebar Caches */
|
||||
\IPS\Widget::deleteCaches();
|
||||
|
||||
/* Possible gateway choice changed and thusly menu and page_urls will change */
|
||||
if ( isset( \IPS\Data\Store::i()->pages_page_urls ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->pages_page_urls );
|
||||
}
|
||||
|
||||
if ( isset( \IPS\Data\Store::i()->frontNavigation ) )
|
||||
{
|
||||
unset( \IPS\Data\Store::i()->frontNavigation );
|
||||
}
|
||||
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=pages&controller=pages" ), 'saved' );
|
||||
}
|
||||
|
||||
/* Display */
|
||||
\IPS\Output::i()->output .= \IPS\Theme::i()->getTemplate( 'global', 'core', 'admin' )->block( \IPS\Member::loggedIn()->language()->addToStack('cms_pages_settings'), $form, FALSE );
|
||||
\IPS\Output::i()->title = \IPS\Member::loggedIn()->language()->addToStack('cms_pages_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Download .htaccess file
|
||||
*
|
||||
@@ -269,7 +157,7 @@ class _pages extends \IPS\Node\Controller
|
||||
$dir = str_replace( \IPS\CP_DIRECTORY . '/index.php', '', $_SERVER['PHP_SELF'] );
|
||||
$dirs = explode( '/', trim( $dir, '/' ) );
|
||||
|
||||
if ( count( $dirs ) )
|
||||
if ( \count( $dirs ) )
|
||||
{
|
||||
array_pop( $dirs );
|
||||
$dir = implode( '/', $dirs );
|
||||
@@ -350,6 +238,7 @@ FILE;
|
||||
{
|
||||
if ( isset( \IPS\Request::i()->id ) )
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\cms\Pages\Page::deleteCompiled( \IPS\Request::i()->id );
|
||||
}
|
||||
|
||||
@@ -363,10 +252,23 @@ FILE;
|
||||
*/
|
||||
protected function setAsDefault()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\cms\Pages\Page::load( \IPS\Request::i()->id )->setAsDefault();
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=pages&controller=pages" ), 'saved' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set as default error page
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function toggleDefaultError()
|
||||
{
|
||||
\IPS\Session::i()->csrfCheck();
|
||||
\IPS\Settings::i()->changeValues( array( 'cms_error_page' => \IPS\Request::i()->id ? \IPS\Request::i()->id : NULL ) );
|
||||
\IPS\Output::i()->redirect( \IPS\Http\Url::internal( "app=cms&module=pages&controller=pages" ), 'saved' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Tree Search
|
||||
*
|
||||
@@ -395,7 +297,7 @@ FILE;
|
||||
/**
|
||||
* Return HTML for a page row
|
||||
*
|
||||
* @param array $row Row data
|
||||
* @param array $page Row data
|
||||
* @param object $url \IPS\Http\Url object
|
||||
* @return string HTML
|
||||
*/
|
||||
@@ -413,7 +315,7 @@ FILE;
|
||||
/**
|
||||
* Return HTML for a folder row
|
||||
*
|
||||
* @param array $row Row data
|
||||
* @param array $folder Row data
|
||||
* @param object $url \IPS\Http\Url object
|
||||
* @return string HTML
|
||||
*/
|
||||
@@ -425,7 +327,7 @@ FILE;
|
||||
/**
|
||||
* Fetch rows of folders/pages
|
||||
*
|
||||
* @param int $folderId Parent ID to fetch from
|
||||
* @param int $folderId Parent ID to fetch from
|
||||
*/
|
||||
public static function getRowsForTree( $folderId=0 )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user