Version 4.0.13.1

This commit is contained in:
Neo committed 2025-12-19 04:57:54 -08:00
1 parent f9e857d255
commit c6a86f0d9b
7517 files changed
+597400 -668041

No files matched your search

+20
View File
@@ -0,0 +1,20 @@
//<?php
class cms_hook_Database extends _HOOK_CLASS_
{
/**
* Constructor
* Gets stores which are always needed to save individual queries
*
*/
public function __construct()
{
$this->initLoad[] = 'cms_menu';
/* Hand over to normal method */
parent::__construct();
}
}
+104
View File
@@ -0,0 +1,104 @@
//<?php
class cms_hook_Post extends _HOOK_CLASS_
{
/**
* Create comment
*
* @param \IPS\Content\Item $item The content item just created
* @param string $comment The comment
* @param bool $first Is the first comment?
* @param string $guestName If author is a guest, the name to use
* @param bool|NULL $incrementPostCount Increment post count? If NULL, will use static::incrementPostCount()
* @param \IPS\Member|NULL $member The author of this comment. If NULL, uses currently logged in member.
* @param \IPS\DateTime|NULL $time The time
* @return static
*/
public static function create( $item, $comment, $first=FALSE, $guestName=NULL, $incrementPostCount=NULL, $member=NULL, \IPS\DateTime $time=NULL )
{
$comment = parent::create( $item, $comment, $first, $guestName, $incrementPostCount, $member, $time );
static::recordSync( $item );
return $comment;
}
/**
* Delete Post
*
* @return void
*/
public function delete()
{
parent::delete();
static::recordSync( $this->item() );
}
/**
* Syncing to run when hiding
*
* @return void
*/
public function onHide()
{
parent::onHide();
static::recordSync( $this->item() );
}
/**
* Syncing to run when unhiding
*
* @param bool $approving If true, is being approved for the first time
* @return void
*/
public function onUnhide( $approving )
{
parent::onUnhide( $approving );
static::recordSync( $this->item() );
}
/**
* Sync up the topic
*
* @param \IPS\forums\Topic $item Topic object
*
* @return void
*/
protected static function recordSync( $item )
{
$synced = array();
foreach( \IPS\Db::i()->select( '*', 'cms_database_categories', array( 'category_forum_record=? AND category_forum_forum=? AND category_forum_comments=?', 1, $item->forum_id, 1 ) ) as $category )
{
try
{
$synced[] = $category['category_database_id'];
$class = '\IPS\cms\Records' . $category['category_database_id'];
$class::load( $item->tid, 'record_topicid' )->syncRecordFromTopic( $item );
}
catch( \Exception $ex )
{
}
}
foreach( \IPS\Db::i()->select( '*', 'cms_databases', array( 'database_forum_record=? AND database_forum_forum=? AND database_forum_comments=?', 1, $item->forum_id, 1 ) ) as $database )
{
try
{
if ( ! in_array( $database['database_id'], $synced ) )
{
$class = '\IPS\cms\Records' . $database['database_id'];
$class::load( $item->tid, 'record_topicid' )->syncRecordFromTopic( $item );
}
}
catch( \Exception $ex )
{
}
}
}
}
+60
View File
@@ -0,0 +1,60 @@
//<?php
class cms_hook_Topic extends _HOOK_CLASS_
{
/**
* Do Moderator Action
*
* @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)
* @return void
* @throws \OutOfRangeException|\InvalidArgumentException|\RuntimeException
*/
public function modAction( $action, \IPS\Member $member = NULL, $reason = NULL )
{
if ( $action === 'delete' )
{
$databaseId = NULL;
try
{
$database = \IPS\Db::i()->select( '*', 'cms_databases', array( array( 'database_forum_forum=? AND database_forum_comments=1', $this->forum_id ) ) )->first();
$databaseId = $database['database_id'];
}
catch( \UnderflowException $ex )
{
try
{
$category = \IPS\Db::i()->select( '*', 'cms_database_categories', array( array( 'category_forum_forum=? AND category_forum_comments=1', $this->forum_id ) ) )->first();
$databaseId = $category['category_database_id'];
}
catch( \UnderflowException $ex )
{
return parent::modAction( $action, $member, $reason );
}
}
/* Still here? */
$class = '\IPS\cms\Records' . $databaseId;
try
{
$class::load( $this->tid, 'record_topicid' );
$database = \IPS\cms\Databases::load( $databaseId );
\IPS\Member::loggedIn()->language()->words['cms_delete_linked_topic'] = sprintf( \IPS\Member::loggedIn()->language()->get('cms_delete_linked_topic'), $database->recordWord( 1 ) );
\IPS\Output::i()->error( 'cms_delete_linked_topic', '1T281/1', 403, '' );
}
catch( \OutOfRangeException $ex )
{
/* Not attached to a database record */
return parent::modAction( $action, $member, $reason );
}
}
return parent::modAction( $action, $member, $reason );
}
}
+135
View File
@@ -0,0 +1,135 @@
//<?php
class cms_hook_Url extends _HOOK_CLASS_
{
protected static $gatewayDir = NULL;
/**
* Get friendly URL data
*
* @param bool $verify If TRUE, will check URL uses correct SEO title
* @return array Parameters
* @throws \OutOfRangeException Invalid URL
* @throws \DomainException URL does not have correct SEO title (exception message will contain correct URL)
*/
public function getFriendlyUrlData( $verify=false )
{
try
{
return call_user_func_array( 'parent::getFriendlyUrlData', func_get_args() );
}
catch( \OutOfRangeException $ex )
{
/* Pass to IP.Content to handle */
$baseUrl = parse_url( \IPS\Settings::i()->base_url );
if ( \IPS\Settings::i()->htaccess_mod_rewrite )
{
$query = ( isset( $this->data['path'] ) ? $this->data['path'] : '' );
}
else
{
if ( isset( $this->data['path'] ) and mb_strpos( $this->data['path'], 'index.php?' ) )
{
$query = ( isset( $this->data['query'] ) ? $this->data['query'] : '' );
}
else
{
$query = '';
}
}
/* Because pages can have "nothing" in the URL for SEO reasons, we need to capture query strings first before sending to the parent class */
$queryString = '';
if( mb_strpos( $query, '&' ) !== FALSE )
{
$queryString = ltrim( mb_substr( $query, mb_strpos( $query, '&' ) ), '&' );
$query = mb_substr( $query, 0, mb_strpos( $query, '&' ) );
}
$set = array();
/* Need to remember the template we use for FURL verification */
$usedTemplate = NULL;
/* Get furl definition */
$furlDefinition = array('cms_page' => array(
'friendly' => '{@path}',
'real' => 'app=cms&module=pages&controller=page'
) );
$query = preg_replace( '#^(' . preg_quote( rtrim( $baseUrl['path'], '/' ), '#' ) . ')/(index.php)?(?:(?:\?/|\?))?(.+?)?$#', '$3', $query );
$this->examineFurl( $furlDefinition, $query, $set, $usedTemplate );
/* Now set the query string back */
if( $queryString )
{
$queryString = explode( '&', $queryString );
foreach( $queryString as $k => $v )
{
$set[ $k ] = $v;
}
}
if ( count( $set ) )
{
if ( ! \IPS\Settings::i()->htaccess_mod_rewrite and isset( $set['path'] ) )
{
/* Is the path URL encoded?
@note this only affects when not using mod_rewrite. We specifically do not urldecode the query string in \IPS\Request::i()->url()
for other reasons, presumaly, hence this code here as it only affects Pages */
if ( str_replace( '%2F', '/', urlencode( urldecode( $set['path'] ) ) ) === $set['path'] )
{
$set['path'] = urldecode( $set['path'] );
}
}
return $set;
}
else
{
throw new \OutOfRangeException();
}
}
}
/**
* Make friendly
*
* @param string|array $seoTemplate The key for making this a friendly URL; or a manual FURL definition
* @param string|array $seoTitles The title(s) needed for the friendly URL
* @param bool $forceHttps Force HTTPS
* @return parent
*/
public function makeFriendly( $seoTemplate, $seoTitles, $forceHttps=FALSE )
{
$called = $seoTemplate;
if ( $seoTemplate === 'content_page_path' )
{
$seoTemplate = array(
'friendly' => '{@path}',
'real' => 'app=cms&module=pages&controller=page'
);
}
parent::makeFriendly( $seoTemplate, $seoTitles, $forceHttps );
if ( $called === 'content_page_path' and \IPS\Settings::i()->cms_use_different_gateway )
{
if ( static::$gatewayDir === NULL )
{
static::$gatewayDir = preg_replace( '#^/?(.+?)/?$#', '\1', str_replace( \IPS\Settings::i()->cms_root_page_url, '', \IPS\Settings::i()->base_url ) );
}
/* If $gatewayDir is empty, we do not want to do this as it will remove all slashes from the entire path */
if ( !empty( static::$gatewayDir ) )
{
$this->data['path'] = str_replace( '/' . static::$gatewayDir, '', $this->data['path'] );
}
$this->url = str_replace( static::baseUrl(), \IPS\Settings::i()->cms_root_page_url, $this->url );
}
}
}
+20
View File
@@ -0,0 +1,20 @@
//<?php
abstract class cms_hook_Widget extends _HOOK_CLASS_
{
/**
* Delete caches
*
* @param String $key Widget key
* @param String $app Parent application
* @param String $plugin Parent plugin
* @return void
*/
static public function deleteCaches( $key=NULL, $app=NULL, $plugin=NULL )
{
\IPS\cms\Widget::deleteCachesForBlocks( $key, $app, $plugin );
/* Hand over to normal method */
parent::deleteCaches( $key, $app, $plugin );
}
}
View File
Whitespace-only changes.