Version 4.2.0
This commit is contained in:
1 parent
0dc2aee5ed
commit
96997ddd8e
2074 files changed
+125454
-55780
No files matched your search
@@ -8,6 +8,17 @@ if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
|
||||
class cms_hook_FriendlyUrl extends _HOOK_CLASS_
|
||||
{
|
||||
/**
|
||||
* Get FURL Definition
|
||||
*
|
||||
* @param bool $revert If TRUE, ignores all customisations and reloads from json
|
||||
* @return array
|
||||
*/
|
||||
public static function furlDefinition( $revert=FALSE )
|
||||
{
|
||||
return array_merge( parent::furlDefinition( $revert ), array( 'content_page_path' => static::buildFurlDefinition( 'app=cms&module=pages&controller=page', 'app=cms&module=pages&controller=page', NULL, FALSE, NULL, FALSE, 'IPS\cms\Pages\Router' ) ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a friendly URL from a full URL, working out friendly URL data
|
||||
*
|
||||
@@ -41,6 +52,16 @@ class cms_hook_FriendlyUrl extends _HOOK_CLASS_
|
||||
{
|
||||
return $return;
|
||||
}
|
||||
/* The table may not yet exist if we're using the parser in an upgrade */
|
||||
catch ( \Exception $e )
|
||||
{
|
||||
if( $e->getCode() == 1146 )
|
||||
{
|
||||
return $return;
|
||||
}
|
||||
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -19,13 +19,13 @@ class cms_hook_InternalUrl extends _HOOK_CLASS_
|
||||
$return = parent::correctFriendlyUrl();
|
||||
|
||||
/* If it it thinks it belongs to "pages", we might be able to be more accurate */
|
||||
if ( $return instanceof \IPS\Http\Url\Friendly and $return->seoTemplate === 'pages' and isset( $this->queryString['path'] ) )
|
||||
if ( $return instanceof \IPS\Http\Url\Friendly and $return->seoTemplate === 'content_page_path' and isset( $this->queryString['path'] ) )
|
||||
{
|
||||
/* Try to find a page */
|
||||
try
|
||||
{
|
||||
/* Create it */
|
||||
$correctUrl = \IPS\cms\Pages\Page::loadFromPath( $this->queryString['path'] )->url();
|
||||
$correctUrl = \IPS\cms\Pages\Router::loadFromUrl( $this )->url();
|
||||
|
||||
/* Set extra stuff in our query string */
|
||||
$paramsToSet = array();
|
||||
|
||||
@@ -29,7 +29,7 @@ class cms_hook_Output extends _HOOK_CLASS_
|
||||
/* If we just logged out, we don't want to show a "no permission" error */
|
||||
if ( isset( \IPS\Request::i()->_fromLogout ) )
|
||||
{
|
||||
$this->redirect( \IPS\Settings::i()->base_url );
|
||||
$this->redirect( \IPS\Http\Url::internal('')->stripQueryString()->setQueryString( '_fromLogout', 1 ) );
|
||||
}
|
||||
|
||||
/* If we're in an external script, just show a simple message */
|
||||
|
||||
@@ -14,10 +14,11 @@ class cms_hook_Topic extends _HOOK_CLASS_
|
||||
* @param string $action The action
|
||||
* @param \IPS\Member|NULL $member The member doing the action (NULL for currently logged in member)
|
||||
* @param string|NULL $reason Reason (for hides)
|
||||
* @param bool $immediately Delete immediately
|
||||
* @return void
|
||||
* @throws \OutOfRangeException|\InvalidArgumentException|\RuntimeException
|
||||
*/
|
||||
public function modAction( $action, \IPS\Member $member = NULL, $reason = NULL )
|
||||
public function modAction( $action, \IPS\Member $member = NULL, $reason = NULL, $immediately = FALSE )
|
||||
{
|
||||
if ( $action === 'delete' )
|
||||
{
|
||||
@@ -75,7 +76,7 @@ class cms_hook_Topic extends _HOOK_CLASS_
|
||||
|
||||
}
|
||||
|
||||
return parent::modAction( $action, $member, $reason );
|
||||
return parent::modAction( $action, $member, $reason, $immediately );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,84 +1,84 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class cms_hook_Url extends _HOOK_CLASS_
|
||||
{
|
||||
/**
|
||||
* Create from string
|
||||
*
|
||||
* This is overridden so that when we are examing a raw URL the "Gateway File" feature
|
||||
* can appropriately claim the URL as belonging to it
|
||||
*
|
||||
* @param string $url A valid URL as per our definition (see phpDoc on class)
|
||||
* @param bool $couldBeFriendly If the URL is known to not be friendly, FALSE can be passed here to save the performance implication of checking the URL
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class cms_hook_Url extends _HOOK_CLASS_
|
||||
{
|
||||
/**
|
||||
* Create from string
|
||||
*
|
||||
* This is overridden so that when we are examing a raw URL the "Gateway File" feature
|
||||
* can appropriately claim the URL as belonging to it
|
||||
*
|
||||
* @param string $url A valid URL as per our definition (see phpDoc on class)
|
||||
* @param bool $couldBeFriendly If the URL is known to not be friendly, FALSE can be passed here to save the performance implication of checking the URL
|
||||
* @param bool $autoEncode If true, any invalid components will be automatically encoded rather than an exception thrown - useful if the entire link is user-provided
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public static function createFromString( $url, $couldBeFriendly=TRUE, $autoEncode=FALSE )
|
||||
{
|
||||
/* See what normal handling makes of it... */
|
||||
$return = parent::createFromString( $url, $couldBeFriendly, $autoEncode );
|
||||
|
||||
/* If the normal handling doesn't recognise it as an internal URL and we
|
||||
have a gateway file, check that */
|
||||
if ( !( $return instanceof \IPS\Http\Url\Internal ) and \IPS\Settings::i()->cms_root_page_url )
|
||||
{
|
||||
/* Decode it */
|
||||
$components = static::componentsFromUrlString( $url, $autoEncode );
|
||||
|
||||
/* Is it underneath the gateway? */
|
||||
$gatewayUrlComponents = static::componentsFromUrlString( \IPS\Settings::i()->cms_root_page_url );
|
||||
if ( $components[ static::COMPONENT_HOST ] === $gatewayUrlComponents[ static::COMPONENT_HOST ] and
|
||||
$components[ static::COMPONENT_USERNAME ] === $gatewayUrlComponents[ static::COMPONENT_USERNAME ] and
|
||||
$components[ static::COMPONENT_PASSWORD ] === $gatewayUrlComponents[ static::COMPONENT_PASSWORD ] and
|
||||
$components[ static::COMPONENT_PORT ] === $gatewayUrlComponents[ static::COMPONENT_PORT ] and
|
||||
mb_substr( $components[ static::COMPONENT_PATH ], 0, mb_strlen( $gatewayUrlComponents[ static::COMPONENT_PATH ] ) ) === $gatewayUrlComponents[ static::COMPONENT_PATH ]
|
||||
)
|
||||
{
|
||||
$pathFromGatewayUrl = mb_substr( $components[ static::COMPONENT_PATH ], mb_strlen( $gatewayUrlComponents[ static::COMPONENT_PATH ] ) );
|
||||
$fallback = FALSE;
|
||||
if ( !$pathFromGatewayUrl or $pathFromGatewayUrl === 'index.php' )
|
||||
{
|
||||
if ( !$pathFromGatewayUrl )
|
||||
{
|
||||
$fallback = TRUE;
|
||||
}
|
||||
$queryString = \IPS\Http\Url::convertQueryAsArrayToString( $components[ static::COMPONENT_QUERY ] );
|
||||
$pathFromGatewayUrl = trim( mb_substr( $queryString, 0, mb_strpos( $queryString, '&' ) ?: NULL ), '/' );
|
||||
}
|
||||
|
||||
/* Try to find a page */
|
||||
$page = NULL;
|
||||
try
|
||||
{
|
||||
$page = \IPS\cms\Pages\Page::loadFromPath( $pathFromGatewayUrl );
|
||||
return \IPS\Http\Url\Friendly::createFromComponents( $components[ static::COMPONENT_HOST ], $components[ static::COMPONENT_SCHEME ], $components[ static::COMPONENT_PATH ], $components[ static::COMPONENT_QUERY ], $components[ static::COMPONENT_PORT ], $components[ static::COMPONENT_USERNAME ], $components[ static::COMPONENT_PASSWORD ], $components[ static::COMPONENT_FRAGMENT ] )
|
||||
->setFriendlyUrlData( 'content_page_path', array( $pathFromGatewayUrl ), array( 'path' => $pathFromGatewayUrl ), $pathFromGatewayUrl );
|
||||
}
|
||||
/* Couldn't find one? Don't accept responsibility, unless there was no $pathFromGatewayUrl and this is the gateway URL */
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
if ( $fallback and (string) $return->stripQueryString() === \IPS\Settings::i()->cms_root_page_url )
|
||||
{
|
||||
try
|
||||
{
|
||||
$page = \IPS\cms\Pages\Page::loadFromPath( '' );
|
||||
return \IPS\Http\Url\Friendly::createFromComponents( $components[ static::COMPONENT_HOST ], $components[ static::COMPONENT_SCHEME ], $components[ static::COMPONENT_PATH ], $components[ static::COMPONENT_QUERY ], $components[ static::COMPONENT_PORT ], $components[ static::COMPONENT_USERNAME ], $components[ static::COMPONENT_PASSWORD ], $components[ static::COMPONENT_FRAGMENT ] )
|
||||
->setFriendlyUrlData( 'content_page_path', array( '' ), array( 'path' => '' ), '' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return $return;
|
||||
}
|
||||
|
||||
* @return \IPS\Http\Url
|
||||
*/
|
||||
public static function createFromString( $url, $couldBeFriendly=TRUE, $autoEncode=FALSE )
|
||||
{
|
||||
/* See what normal handling makes of it... */
|
||||
$return = parent::createFromString( $url, $couldBeFriendly, $autoEncode );
|
||||
|
||||
/* If the normal handling doesn't recognise it as an internal URL and we
|
||||
have a gateway file, check that */
|
||||
if ( !( $return instanceof \IPS\Http\Url\Internal ) and \IPS\Settings::i()->cms_root_page_url )
|
||||
{
|
||||
/* Decode it */
|
||||
$components = static::componentsFromUrlString( $url, $autoEncode );
|
||||
|
||||
/* Is it underneath the gateway? */
|
||||
$gatewayUrlComponents = static::componentsFromUrlString( \IPS\Settings::i()->cms_root_page_url );
|
||||
if ( $components[ static::COMPONENT_HOST ] === $gatewayUrlComponents[ static::COMPONENT_HOST ] and
|
||||
$components[ static::COMPONENT_USERNAME ] === $gatewayUrlComponents[ static::COMPONENT_USERNAME ] and
|
||||
$components[ static::COMPONENT_PASSWORD ] === $gatewayUrlComponents[ static::COMPONENT_PASSWORD ] and
|
||||
$components[ static::COMPONENT_PORT ] === $gatewayUrlComponents[ static::COMPONENT_PORT ] and
|
||||
mb_substr( $components[ static::COMPONENT_PATH ], 0, mb_strlen( $gatewayUrlComponents[ static::COMPONENT_PATH ] ) ) === $gatewayUrlComponents[ static::COMPONENT_PATH ]
|
||||
)
|
||||
{
|
||||
$pathFromGatewayUrl = mb_substr( $components[ static::COMPONENT_PATH ], mb_strlen( $gatewayUrlComponents[ static::COMPONENT_PATH ] ) );
|
||||
$fallback = FALSE;
|
||||
if ( !$pathFromGatewayUrl or $pathFromGatewayUrl === 'index.php' )
|
||||
{
|
||||
if ( !$pathFromGatewayUrl )
|
||||
{
|
||||
$fallback = TRUE;
|
||||
}
|
||||
$queryString = \IPS\Http\Url::convertQueryAsArrayToString( $components[ static::COMPONENT_QUERY ] );
|
||||
$pathFromGatewayUrl = trim( mb_substr( $queryString, 0, mb_strpos( $queryString, '&' ) ?: NULL ), '/' );
|
||||
}
|
||||
|
||||
/* Try to find a page */
|
||||
$page = NULL;
|
||||
try
|
||||
{
|
||||
$page = \IPS\cms\Pages\Page::loadFromPath( $pathFromGatewayUrl );
|
||||
return \IPS\Http\Url\Friendly::createFromComponents( $components[ static::COMPONENT_HOST ], $components[ static::COMPONENT_SCHEME ], $components[ static::COMPONENT_PATH ], $components[ static::COMPONENT_QUERY ], $components[ static::COMPONENT_PORT ], $components[ static::COMPONENT_USERNAME ], $components[ static::COMPONENT_PASSWORD ], $components[ static::COMPONENT_FRAGMENT ] )
|
||||
->setFriendlyUrlData( 'content_page_path', array( $pathFromGatewayUrl ), array( 'path' => $pathFromGatewayUrl ), $pathFromGatewayUrl );
|
||||
}
|
||||
/* Couldn't find one? Don't accept responsibility, unless there was no $pathFromGatewayUrl and this is the gateway URL */
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
if ( $fallback and (string) $return->stripQueryString() === \IPS\Settings::i()->cms_root_page_url )
|
||||
{
|
||||
try
|
||||
{
|
||||
$page = \IPS\cms\Pages\Page::loadFromPath( '' );
|
||||
return \IPS\Http\Url\Friendly::createFromComponents( $components[ static::COMPONENT_HOST ], $components[ static::COMPONENT_SCHEME ], $components[ static::COMPONENT_PATH ], $components[ static::COMPONENT_QUERY ], $components[ static::COMPONENT_PORT ], $components[ static::COMPONENT_USERNAME ], $components[ static::COMPONENT_PASSWORD ], $components[ static::COMPONENT_FRAGMENT ] )
|
||||
->setFriendlyUrlData( 'content_page_path', array( '' ), array( 'path' => '' ), '' );
|
||||
}
|
||||
catch ( \OutOfRangeException $e ) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Return */
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class cms_hook_topics extends _HOOK_CLASS_
|
||||
{
|
||||
|
||||
/* !Hook Data - DO NOT REMOVE */
|
||||
public static function hookData() {
|
||||
return array_merge_recursive( array (
|
||||
'topic' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'selector' => '#elTopicActions_menu',
|
||||
'type' => 'add_inside_start',
|
||||
'content' => '{{if $topic->hidden() != -2 and \IPS\Member::loggedIn()->modPermission( \'can_copy_topic_database\' )}}
|
||||
<li class=\'ipsMenu_item\'>
|
||||
<a href=\'{url="app=cms&module=database&controller=topic&id=$topic->tid&_new=1" base="front" seoTemplate="topic_copy" seoTitle="$topic->title_seo"}\' data-ipsDialog data-ipsDialog-size=\'narrow\' data-ipsDialog-remoteVerify=\'false\' data-ipsDialog-title=\'{lang="copy_select_database"}\'>{lang="copy_topic_to_database"}</a>
|
||||
</li>
|
||||
{{endif}}',
|
||||
),
|
||||
),
|
||||
), parent::hookData() );
|
||||
}
|
||||
/* End Hook Data */
|
||||
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
//<?php
|
||||
|
||||
/* To prevent PHP errors (extending class does not exist) revealing path */
|
||||
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
class cms_hook_websiteUrl extends _HOOK_CLASS_
|
||||
{
|
||||
|
||||
/* !Hook Data - DO NOT REMOVE */
|
||||
public static function hookData() {
|
||||
return array_merge_recursive( array (
|
||||
'globalTemplate' =>
|
||||
array (
|
||||
0 =>
|
||||
array (
|
||||
'selector' => 'html > body > meta[itemprop=\'url\']',
|
||||
'type' => 'replace',
|
||||
'content' => '{{if \IPS\Settings::i()->cms_use_different_gateway AND \IPS\Settings::i()->cms_root_page_url}}
|
||||
<meta itemprop="url" content="{setting="cms_root_page_url"}">
|
||||
{{else}}
|
||||
<meta itemprop="url" content="{setting="base_url"}">
|
||||
{{endif}}',
|
||||
),
|
||||
),
|
||||
), parent::hookData() );
|
||||
}
|
||||
/* End Hook Data */
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user