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

+1 -1
View File
@@ -11,7 +11,7 @@
namespace IPS\Http\Url;
/* 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;
+260 -49
View File
@@ -11,7 +11,7 @@
namespace IPS\Http\Url;
/* 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;
@@ -50,7 +50,7 @@ class _Friendly extends \IPS\Http\Url\Internal
* @param int $protocol Protocol (one of the PROTOCOL_* constants)
* @param string $friendlyUrlComponent The friendly URL component, which may be for the path or the query string (e.g. "topic/1-test")
* @param array $queryString Additional query string data
* @return \IPS\Http\Url\Friendly
* @return static
* @throws \IPS\Http\Url\Exception
*/
public static function friendlyUrlFromComponent( $protocol, $friendlyUrlComponent, $queryString )
@@ -80,7 +80,7 @@ class _Friendly extends \IPS\Http\Url\Internal
*
* @param array $components An array of components as returned by componentsFromUrlString()
* @param string $potentialFurl The potential FURL slug (e.g. "topic/1-test")
* @return \IPS\Http\Url\Friendly|NULL
* @return static|NULL
*/
public static function createFriendlyUrlFromComponents( $components, $potentialFurl )
{
@@ -115,12 +115,14 @@ class _Friendly extends \IPS\Http\Url\Internal
* @param string $seoTemplate The key for making this a friendly URL
* @param string|array $seoTitles The title(s) needed for the friendly URL
* @param int $protocol Protocol (one of the PROTOCOL_* constants)
* @return \IPS\Http\Url\Friendly
* @return static
* @throws \IPS\Http\Url\Exception
* @todo Currently this will silently return a non-friendly URL if $seoTemplate is not valid, for backwards compatibility. Remove this in a major update.
*/
public static function friendlyUrlFromQueryString( $queryString, $seoTemplate, $seoTitles, $protocol )
{
$_originalQueryString = $queryString;
/* Get the friendly URL component */
try
{
@@ -153,16 +155,14 @@ class _Friendly extends \IPS\Http\Url\Internal
{
if ( \IPS\IN_DEV )
{
throw new \IPS\Http\Url\Exception( 'SEO_TEMPLATE_IS_NOT_VALID_FOR_URL' );
throw new \IPS\Http\Url\Exception( 'SEO_TEMPLATE_IS_NOT_VALID_FOR_URL: ' . $_originalQueryString . ' - ' . $seoTemplate );
}
}
/* Return */
return static::friendlyUrlFromComponent( $protocol, $friendlyUrlComponent, $queryString )->setFriendlyUrlData( $seoTemplate, $seoTitles, $matchedParams, $friendlyUrlComponent );
}
/* !Instance */
/**
* Set friendly URL data
*
@@ -170,7 +170,7 @@ class _Friendly extends \IPS\Http\Url\Internal
* @param string|array $seoTitles The title(s) needed for the friendly URL
* @param array $matchedParams The values for hidden query string properties
* @param string $friendlyUrlComponent The friendly URL component, which may be for the path or the query string (e.g. "topic/1-test")
* @return \IPS\Http\Url\Friendly
* @return static
* @throws \IPS\Http\Url\Exception
*/
protected function setFriendlyUrlData( $seoTemplate, $seoTitles, $matchedParams=array(), $friendlyUrlComponent )
@@ -181,16 +181,17 @@ class _Friendly extends \IPS\Http\Url\Internal
{
throw new \IPS\Http\Url\Exception( 'INVALID_SEO_TEMPLATE' );
}
/* Set basic properties */
$this->seoTemplate = $seoTemplate;
$this->seoTitles = is_string( $seoTitles ) ? array( $seoTitles ) : $seoTitles;
$this->seoTitles = \is_string( $seoTitles ) ? array( $seoTitles ) : $seoTitles;
$this->friendlyUrlComponent = $friendlyUrlComponent;
$this->seoPagination = ! empty( $furlDefinition[ $seoTemplate ]['seoPagination'] ) ? true : false;
/* Set hidden query string */
parse_str( $furlDefinition[ $seoTemplate ]['real'], $hiddenQueryString );
$this->hiddenQueryString = $hiddenQueryString + $matchedParams;
/* Return */
return $this;
}
@@ -198,7 +199,7 @@ class _Friendly extends \IPS\Http\Url\Internal
/**
* Validate that the SEO title is correct
*
* @return mixed The correct URL if incorrect, TRUE is correct, or NULL if unknown
* @return mixed The correct URL if incorrect, TRUE if correct, or NULL if unknown
*/
public function correctFriendlyUrl()
{
@@ -220,10 +221,9 @@ class _Friendly extends \IPS\Http\Url\Internal
if( mb_strpos( (string) $this, '/page-' ) )
{
preg_match( "/\/page\-(\d+)/", (string) $this, $matches );
if( isset( $matches[1] ) )
{
$correctUrl = $correctUrl->setQueryString( 'page', $matches[1] );
$correctUrl = $correctUrl->setPage( 'page', $matches[1] );
}
}
@@ -231,12 +231,10 @@ class _Friendly extends \IPS\Http\Url\Internal
if( mb_strpos( (string) $this, '/page__' ) )
{
preg_match( "/\/page__([^\/$]+?)(?:$|\/)/", (string) $this, $matches );
if( isset( $matches[1] ) )
{
$params = explode( '__', $matches[1] );
$key = NULL;
foreach( $params as $param )
{
if( $key === NULL )
@@ -251,19 +249,7 @@ class _Friendly extends \IPS\Http\Url\Internal
}
}
}
/* And it also used to do index.php?/topic/123-example/?p=456 - with the double ? */
foreach ( $correctUrl->queryString as $k => $v )
{
if ( preg_match( '/^\/' . preg_quote( $correctUrl->friendlyUrlComponent, '/' ) . '\/\?(.+)$/', $k, $matches ) )
{
$correctUrl = $correctUrl->setQueryString( array(
$matches[0] => NULL,
$matches[1] => $v
) );
}
}
if ( (string) $correctUrl->normaliseForEqualityCheck() !== (string) $this->normaliseForEqualityCheck() )
{
return $correctUrl;
@@ -294,7 +280,10 @@ class _Friendly extends \IPS\Http\Url\Internal
/* Make it schema-relative */
$return = $return->setScheme( NULL );
/* Remove pagination attributes */
$return = $return->setPage();
/* Return */
return $return;
}
@@ -317,9 +306,205 @@ class _Friendly extends \IPS\Http\Url\Internal
return parent::stripQueryString( $keys );
}
/**
* Adds the page parameter to the URL
*
* @param string $param The page key, default is 'page'
* @param int|NULL $number The page number to use
* @return \IPS\Http\Url
*/
public function setPage( $param='page', $number=1 )
{
if ( $param === 'page' )
{
$potentialFurl = NULL;
$components = static::componentsFromUrlString( $this );
/* seoPagination is set usually in setFriendlyUrlData */
if ( $this->seoPagination === NULL )
{
/* Fallback */
$def = static::getFurlDefinitionFromPath( preg_replace( "/\/" . preg_quote( $param, '/' ) . "\/\d+?/", '', $this->getFriendlyComponent() ) );
if ( $def !== NULL and isset( $def['seoPagination'] ) )
{
$this->seoPagination = $def['seoPagination'];
}
}
if ( ! $this->seoPagination )
{
/* Ok, do the usual ?page=x param */
return parent::setPage( $param, $number );
}
/* If rewrite furls is disabled, or specifically if the request has index.php in the URL (it may be a cached URL from before the setting was toggled) */
if ( !\IPS\Settings::i()->htaccess_mod_rewrite OR static::fixComponentPath( $components[ static::COMPONENT_PATH ] ) === 'index.php' )
{
if ( \is_array( $components[ static::COMPONENT_QUERY ] ) and \count( $components[ static::COMPONENT_QUERY ] ) )
{
$new = NULL;
foreach( $components[ static::COMPONENT_QUERY ] as $k => $v )
{
if ( $new === NULL and mb_strstr( $k, '/' . $param . '/' ) )
{
$new = static::stripPageComponent( $k );
$potentialFurl = $new;
unset( $components[ static::COMPONENT_QUERY ][ $k ] );
}
}
if ( $new )
{
$components[ static::COMPONENT_QUERY ] = array_merge( array( '/' . ltrim( $new, '/' ) => NULL ), $components[ static::COMPONENT_QUERY ] );
}
}
if ( ! $potentialFurl )
{
$potentialFurl = $this->getFriendlyComponent();
}
}
else
{
$potentialFurl = static::stripPageComponent( static::fixComponentPath( $components[ static::COMPONENT_PATH ] ) );
$components[ static::COMPONENT_PATH ] = static::stripPageComponent( $components[ static::COMPONENT_PATH ] );
}
/* Add on the page itself */
if ( \intval( $number ) > 1 )
{
$potentialFurl = NULL;
if ( ! \IPS\Settings::i()->htaccess_mod_rewrite OR static::fixComponentPath( $components[ static::COMPONENT_PATH ] ) === 'index.php' )
{
foreach( $components[ static::COMPONENT_QUERY ] as $k => $v )
{
/* The FURL is always the first query string component */
if ( $potentialFurl === NULL )
{
$potentialFurl = $k . $param . '/' . $number . '/';
unset($components[ static::COMPONENT_QUERY ][ $k ] );
break;
}
}
if ( $potentialFurl )
{
$components[ static::COMPONENT_QUERY ] = array_merge( array( $potentialFurl => NULL ), $components[ static::COMPONENT_QUERY ] );
}
}
else
{
$components[ static::COMPONENT_PATH ] .= $param . '/' . $number . '/';
$potentialFurl = static::stripPageComponent( static::fixComponentPath( $components[ static::COMPONENT_PATH ] ) ) . $param . '/' . $number . '/';
}
}
return static::createFriendlyUrlFromComponents( $components, trim( $potentialFurl, '/' ) );
}
else
{
return parent::setPage( $param, $number );
}
}
/* !Utilities */
/**
* Returns the FURL string from the current URL
*
* @return string|NULL The furl part of the URL, eg /topic/1-foo/
*/
protected function getFriendlyComponent()
{
/* Are we lucky? */
if ( ! empty( $this->friendlyUrlComponent ) )
{
return trim( $this->friendlyUrlComponent, '/' );
}
/* Of course not... */
if ( ! \IPS\Settings::i()->htaccess_mod_rewrite )
{
if ( \is_array( $this->queryString ) and \count( $this->queryString ) )
{
foreach( $this->queryString as $k => $v )
{
if ( mb_strstr( $k, '/' ) )
{
$this->friendlyUrlComponent = trim( $k, '/' );
return $this->friendlyUrlComponent;
}
}
}
}
else
{
$this->friendlyUrlComponent = trim( static::fixComponentPath( $this->data[ static::COMPONENT_PATH ] ), '/' );
return $this->friendlyUrlComponent;
}
return NULL;
}
/**
* Ensure the path doesn't contain any 'real' path eg `site.com</forums/>`
*
* @param string $path The path from ->data['path'] eg forums/topic/1-foo
* @return string The furl part of the path, eg topic/1-foo
*/
public static function fixComponentPath( $path )
{
$baseUrl = parse_url( static::baseUrl() );
if ( ! empty( $baseUrl['path'] ) )
{
$pos = mb_stripos( $path, $baseUrl['path'] );
if( $pos !== FALSE )
{
$path = substr_replace( $path, '/', $pos, mb_strlen( $baseUrl['path'] ) );
}
}
return trim( $path, '/' );
}
/**
* Returns the matching FURL definition data for the FURL component eg /topic/1-foo/
*
* @param string $friendlyUrlComponent The furl part of the path, eg /topic/1-foo/
* @return array|NULL The FURL definition
*/
protected static function getFurlDefinitionFromPath( $friendlyUrlComponent )
{
foreach ( static::furlDefinition() as $seoTemplate => $furlDefinition )
{
foreach ( $furlDefinition['regex'] as $_regex )
{
if ( preg_match( '/^' . $_regex . '$/i', $friendlyUrlComponent ) )
{
return $furlDefinition;
}
}
}
return NULL;
}
/**
* Removes any inline page component from the FURL component eg /topic/1-foo/page/2/
*
* @param string $friendlyUrlComponent The furl part of the path, eg /topic/1-foo/
* @param string $param The /page/N/ key
* @return string The cleaned FURL eg /topic/1-foo/
*/
public static function stripPageComponent( $friendlyUrlComponent, $param='page' )
{
return preg_replace( '#/' . $param . '/(\d+?)$#', '', rtrim( $friendlyUrlComponent, '/' ) ) . '/';
}
/**
* Get friendly URL component (e.g. "topic/1-test") from a query string and SEO template
*
@@ -334,7 +519,7 @@ class _Friendly extends \IPS\Http\Url\Internal
/* Get the definition */
$furlDefinition = static::furlDefinition();
if ( !isset( $furlDefinition[ $seoTemplate ] ) )
{
{
throw new \IPS\Http\Url\Exception( 'INVALID_SEO_TEMPLATE' );
}
$component = $furlDefinition[ $seoTemplate ]['friendly'];
@@ -347,15 +532,15 @@ class _Friendly extends \IPS\Http\Url\Internal
{
if ( mb_strpos( $component, "{#{$k}}" ) !== FALSE or mb_strpos( $component, "{@{$k}}" ) !== FALSE )
{
$component = str_replace( "{#{$k}}", intval( $v ), $component );
$component = str_replace( "{#{$k}}", \intval( $v ), $component );
$component = str_replace( "{@{$k}}", $v, $component );
unset( $queryString[ $k ] );
}
}
/* Parse out the titles */
$seoTitles = is_null( $seoTitles ) ? array() : ( is_string( $seoTitles ) ? array( $seoTitles ) : array_values( $seoTitles ) );
$seoTitlesCount = count( $seoTitles );
$seoTitles = \is_null( $seoTitles ) ? array() : ( \is_string( $seoTitles ) ? array( $seoTitles ) : array_values( $seoTitles ) );
$seoTitlesCount = \count( $seoTitles );
for ( $i = 0; $i < $seoTitlesCount; $i++ )
{
if ( $i === 0 )
@@ -420,14 +605,34 @@ class _Friendly extends \IPS\Http\Url\Internal
* @return array|NULL array( $matchedParams, $seoTitles ) if matched, NULL if the $friendlyUrlComponent does not match this $furlDefinition
*/
protected static function getMatchedParamsFromFriendlyUrlComponent( $furlDefinition, $friendlyUrlComponent )
{
{
/* See if it matches */
$seoTitles = array();
$matchedParams = array();
foreach ( $furlDefinition['regex'] as $_regex )
{
if ( preg_match( '/^' . $_regex . '$/i', $friendlyUrlComponent, $matches ) )
$regex = ( ! empty( $furlDefinition['seoPagination'] ) ) ? '#^' . $_regex . '($|/page/\d+?$)#i' : '#^' . $_regex . '$#i';
if ( preg_match( $regex, $friendlyUrlComponent, $matches ) )
{
/* Check pagination first */
if ( ! empty( $furlDefinition['seoPagination'] ) and mb_strstr( $matches[0], '/page/' ) )
{
foreach( $matches as $k => $v )
{
if ( $k and mb_strstr( $matches[ $k ], '/page/' ) )
{
list( $x, $page ) = explode( '/', trim( $matches[ $k ], '/' ) );
if ( $page )
{
$matchedParams['page'] = \intval( $page );
}
}
}
}
foreach ( $furlDefinition['params'] as $k => $param )
{
if ( $param )
@@ -439,7 +644,7 @@ class _Friendly extends \IPS\Http\Url\Internal
$seoTitles[] = $matches[ $k + 1 ];
}
}
return array( $matchedParams, $seoTitles );
}
}
@@ -463,10 +668,10 @@ class _Friendly extends \IPS\Http\Url\Internal
{
if ( static::$furlDefinition === NULL or $revert )
{
$furlCustomizations = ( \IPS\Settings::i()->furl_configuration AND !$revert ) ? json_decode( \IPS\Settings::i()->furl_configuration, TRUE ) : array();
$furlCustomizations = ( \IPS\Settings::i()->furl_configuration AND !$revert and ! \IPS\IN_DEV ) ? json_decode( \IPS\Settings::i()->furl_configuration, TRUE ) : array();
$furlConfiguration = ( isset( \IPS\Data\Store::i()->furl_configuration ) AND \IPS\Data\Store::i()->furl_configuration ) ? json_decode( \IPS\Data\Store::i()->furl_configuration, TRUE ) : array();
if ( ( \IPS\IN_DEV and !\IPS\DEV_USE_FURL_CACHE ) or !count( $furlConfiguration ) or $revert )
if ( ( \IPS\IN_DEV and !\IPS\DEV_USE_FURL_CACHE ) or !\count( $furlConfiguration ) or $revert )
{
$furlConfiguration = static::buildFurlConfiguation();
}
@@ -478,7 +683,7 @@ class _Friendly extends \IPS\Http\Url\Internal
}
/**
* Rebuild and return \IPS\Data\Store::i()->furl_configuration with default, uncustomised values
* Rebuild and return `\IPS\Data\Store::i()->furl_configuration` with default, uncustomised values
*
* @return array
*/
@@ -503,17 +708,17 @@ class _Friendly extends \IPS\Http\Url\Internal
foreach ( $applications as $app )
{
/* If it has a furl.json file... */
if( file_exists( \IPS\ROOT_PATH . "/applications/{$app->directory}/data/furl.json" ) )
if( $app->enabled and file_exists( $app->getApplicationPath() . "/data/furl.json" ) )
{
/* Open it up */
$data = json_decode( preg_replace( '/\/\*.+?\*\//s', '', \file_get_contents( \IPS\ROOT_PATH . "/applications/{$app->directory}/data/furl.json" ) ), TRUE );
$data = json_decode( preg_replace( '/\/\*.+?\*\//s', '', \file_get_contents( $app->getApplicationPath() . "/data/furl.json" ) ), TRUE );
$topLevel = $data['topLevel'];
/* Process them */
$definitions = array();
foreach ( $data['pages'] as $k => $page )
{
$definitions[ $k ] = static::buildFurlDefinition( $page['friendly'], $page['real'], $topLevel, $app->default, isset( $page['alias'] ) ? $page['alias'] : NULL, FALSE, isset( $page['verify'] ) ? $page['verify'] : NULL, isset( $page['seoTitles'] ) ? $page['seoTitles'] : NULL );
$definitions[ $k ] = static::buildFurlDefinition( $page['friendly'], $page['real'], $topLevel, $app->default, isset( $page['alias'] ) ? $page['alias'] : NULL, FALSE, isset( $page['verify'] ) ? $page['verify'] : NULL, isset( $page['seoTitles'] ) ? $page['seoTitles'] : NULL, isset( $page['seoPagination'] ) ? $page['seoPagination'] : NULL );
}
/* Add it in */
@@ -539,9 +744,10 @@ class _Friendly extends \IPS\Http\Url\Internal
* @param bool $custom Flag to indicate if this is a custom FURL definition
* @param string $verify The name of a class that contains a loadFromUrl() and an url() method for verifying the friendly URL is correct
* @param array $seoTitles The class, query param and property to load from to rebuild seo titles
* @param bool|null $seoPagination Whether to use SEO-friendly pagination (e.g. /page/2/) or not
* @return array
*/
public static function buildFurlDefinition( $friendly, $real, $appTopLevel = NULL, $appIsDefault = FALSE, $alias = NULL, $custom = FALSE, $verify = NULL, $seoTitles = NULL )
public static function buildFurlDefinition( $friendly, $real, $appTopLevel = NULL, $appIsDefault = FALSE, $alias = NULL, $custom = FALSE, $verify = NULL, $seoTitles = NULL, $seoPagination = NULL )
{
/* Init */
$return = array(
@@ -561,6 +767,11 @@ class _Friendly extends \IPS\Http\Url\Internal
$return['seoTitles'] = $seoTitles;
}
if ( $seoPagination )
{
$return['seoPagination'] = $seoPagination;
}
/* If it has a top-level (e.g. "/forums") we need to store the definition either with that if it's the default app, or
without it if it isn't, so that if the default app changes we can redirect accordingly */
if ( $appTopLevel )
@@ -600,21 +811,21 @@ class _Friendly extends \IPS\Http\Url\Internal
{
case '#':
$return['regex'] = array_map( function( $_regex ) use ( $tag ) {
return str_replace( '\{#' . mb_substr( $tag, 1 ) . '\}', '(\d+?)', $_regex );
return str_replace( preg_quote( '{#' . mb_substr( $tag, 1 ) . '}', '/' ), '(\d+?)', $_regex );
}, $return['regex'] );
$return['params'][] = mb_substr( $tag, 1 );
break;
case '@':
$return['regex'] = array_map( function( $_regex ) use ( $tag ) {
return str_replace( '\{@' . mb_substr( $tag, 1 ) . '\}', '(.+?)', $_regex );
return str_replace( preg_quote( '{@' . mb_substr( $tag, 1 ) . '}', '/' ), '(.+?)', $_regex );
}, $return['regex'] );
$return['params'][] = mb_substr( $tag, 1 );
break;
case '?':
$return['regex'] = array_map( function( $_regex ) use ( $tag ) {
return str_replace( '\{\?\}', '(?!&)(.+?)', $_regex );
return preg_replace( '/\\\{\\\\\?\d*\\\}/', '(?![&\\/])(.+?)', $_regex );
}, $return['regex'] );
$return['params'][] = '';
break;
+32 -7
View File
@@ -11,7 +11,7 @@
namespace IPS\Http\Url;
/* 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;
@@ -34,7 +34,7 @@ class _Internal extends \IPS\Http\Url
*/
protected static function createInternalFromComponents( $base, $protocol, $path, $query = NULL, $fragment = NULL )
{
$baseUrlData = parse_url( static::baseUrl( is_numeric( $protocol ) ? $protocol : NULL ) );
$baseUrlData = parse_url( static::baseUrl( \is_numeric( $protocol ) ? $protocol : NULL ) );
$pathToUse = '';
if ( isset( $baseUrlData['path'] ) and $baseUrlData['path'] )
@@ -52,7 +52,7 @@ class _Internal extends \IPS\Http\Url
$return = static::createFromComponents(
$baseUrlData['host'],
( is_string( $protocol ) and !is_numeric( $protocol ) ) ? $protocol : ( ( isset( $baseUrlData['scheme'] ) AND $protocol !== NULL ) ? $baseUrlData['scheme'] : NULL ),
( \is_string( $protocol ) and !\is_numeric( $protocol ) ) ? $protocol : ( ( isset( $baseUrlData['scheme'] ) AND $protocol !== NULL ) ? $baseUrlData['scheme'] : NULL ),
$pathToUse ? "/{$pathToUse}" : '',
$query,
isset( $baseUrlData['port'] ) ? $baseUrlData['port'] : NULL,
@@ -65,6 +65,11 @@ class _Internal extends \IPS\Http\Url
return $return;
}
/**
* @brief Does this URL have the SEO pagination (page/n/)?
*/
public $seoPagination = NULL;
/**
* @brief Base
*/
@@ -100,7 +105,7 @@ class _Internal extends \IPS\Http\Url
}
/* If this definition requires a parameter, see if we have it. If not, skip to next definition to check. */
if( count( array_diff( $params, array_keys( $this->queryString ) ) ) )
if( \count( array_diff( $params, array_keys( $this->queryString ) ) ) )
{
continue;
}
@@ -158,7 +163,8 @@ class _Internal extends \IPS\Http\Url
/**
* Get the correct URL using a "verify" property from the FURL definition
*
* @return
* @param object $verify Class containing `preCorrectUrlFromVerifyClass()` method to check URL against
* @return NULL|\IPS\Http\Url
* @throws \OutOfRangeException
*/
protected function correctUrlFromVerifyClass( $verify )
@@ -198,7 +204,7 @@ class _Internal extends \IPS\Http\Url
$paramsToSet[ $k ] = $v;
}
}
if ( count( $paramsToSet ) )
if ( \count( $paramsToSet ) )
{
$correctUrl = $correctUrl->setQueryString( $paramsToSet );
}
@@ -217,6 +223,26 @@ class _Internal extends \IPS\Http\Url
return $this->setQueryString( 'csrfKey', \IPS\Session::i()->csrfKey );
}
/**
* Adds the page parameter to the URL
*
* @param string $param The page key, default is 'page'
* @param int|NULL $number The page number to use
* @return \IPS\Http\Url
*/
public function setPage( $param='page', $number=1 )
{
/* Remove any existing page param */
$url = $this->stripQueryString( $param );
if ( \intval( $number ) > 1 )
{
$url = $this->setQueryString( $param, $number );
}
return $url;
}
/**
* Get ACP query string without adsess
*
@@ -225,7 +251,6 @@ class _Internal extends \IPS\Http\Url
public function acpQueryString()
{
$queryString = $this->queryString;
unset( $queryString['adsess'] );
unset( $queryString['csrf'] );
return static::convertQueryAsArrayToString( $queryString );
}
View File
Whitespace-only changes.