Version 5.0.0 beta 4

This commit is contained in:
Neo committed 2025-12-19 16:57:00 -08:00
1 parent e86153356a
commit 2f24f9de48
276 files changed
+8614 -6044

No files matched your search

+48 -74
View File
@@ -22,9 +22,11 @@ use IPS\cms\Fields;
use IPS\cms\Pages\Folder;
use IPS\cms\Pages\Page;
use IPS\convert\App;
use IPS\convert\Software;
use IPS\Data\Store;
use IPS\DateTime;
use IPS\Db;
use IPS\Db\Exception as DbException;
use IPS\File;
use IPS\Http\Url;
use IPS\IPS;
@@ -33,13 +35,11 @@ use IPS\Member;
use IPS\Patterns\ActiveRecordIterator;
use LogicException;
use OutOfRangeException;
use OutRangeException;
use UnderflowException;
use function count;
use function defined;
use function get_class;
use function in_array;
use function intval;
use function is_array;
use function is_null;
use function is_numeric;
@@ -61,14 +61,14 @@ class Cms extends Core
/**
* @brief Application
*/
public $app = 'cms';
public string $app = 'cms';
/**
* Returns a block of text, or a language string, that explains what the admin must do to complete this conversion
*
* @return string
*/
public function getPostConversionInformation()
public function getPostConversionInformation() : string
{
return parent::getPostConversionInformation() . Member::loggedIn()->language()->addToStack( 'convert_cms_info_message' );
}
@@ -79,7 +79,7 @@ class Cms extends Core
* @param bool $rowCounts enable row counts
* @return array
*/
public function menuRows( $rowCounts=FALSE )
public function menuRows( bool $rowCounts=FALSE ) : array
{
$return = array();
$extraRows = $this->software->extraMenuRows();
@@ -100,7 +100,7 @@ class Cms extends Core
'ips_rows' => Db::i()->select( 'COUNT(*)', 'cms_blocks' ),
'source_rows' => array( 'table' => $v['table'], 'where' => $v['where'] ),
'per_cycle' => 100,
'dependencies' => array(),
'dependencies' => $dependencies,
'link_type' => 'cms_blocks',
);
break;
@@ -318,10 +318,12 @@ class Cms extends Core
* @param string $method Method to truncate
* @return array
*/
protected function truncate( $method )
protected function truncate( string $method ) : array
{
$return = array();
$classname = get_class( $this->software );
/* @var Software $classname */
foreach( $classname::canConvert() as $k => $v )
{
switch( $k )
@@ -403,7 +405,7 @@ class Cms extends Core
}
}
return isset( $return[ $method ] ) ? $return[ $method ] : array();
return $return[$method] ?? array();
}
/**
@@ -424,9 +426,9 @@ class Cms extends Core
* Convert a Folder
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted folder, or FALSE on failure.
* @return int|bool The ID of the newly inserted folder, or FALSE on failure.
*/
public function convertCmsFolder( $info=array() )
public function convertCmsFolder( array $info=array() ) : bool|int
{
if ( !isset( $info['folder_id'] ) )
{
@@ -487,9 +489,9 @@ class Cms extends Core
* Convert a Page
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted page, or FALSE on failure.
* @return int|bool The ID of the newly inserted page, or FALSE on failure.
*/
public function convertCmsPage( $info=array() )
public function convertCmsPage( array $info=array() ) : bool|int
{
if ( !isset( $info['page_id'] ) )
{
@@ -569,7 +571,7 @@ class Cms extends Core
try
{
/* Check folder */
if ( intval( $info['page_folder_id'] ) == Folder::load( $info['page_seo_name'], 'folder_name' )->parent_id )
if ( $info['page_folder_id'] == Folder::load( $info['page_seo_name'], 'folder_name' )->parent_id )
{
$info['page_seo_name'] = Url::seoTitle( $info['page_name'] . '-' . $info['page_id'] );
}
@@ -624,9 +626,9 @@ class Cms extends Core
* Convert a block container
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted container, or FALSE on failure.
* @return int|bool The ID of the newly inserted container, or FALSE on failure.
*/
public function convertCmsContainer( $info=array() )
public function convertCmsContainer( array $info=array() ) : bool|int
{
if ( !isset( $info['container_id'] ) )
{
@@ -656,7 +658,7 @@ class Cms extends Core
$info['container_parent_id'] = 0;
}
if ( !isset( $info['container_type'] ) OR !in_array( $info['container_type'], array( 'block' ) ) )
if ( !isset( $info['container_type'] ) OR $info['container_type'] != 'block' )
{
$info['container_type'] = 'block';
}
@@ -689,9 +691,9 @@ class Cms extends Core
* @note These probably won't really work unless going from Invision Community to Invision Community, but we still support them anyway so they can be refactored.
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted block, or FALSE on failure.
* @return int|bool The ID of the newly inserted block, or FALSE on failure.
*/
public function convertCmsBlock( $info )
public function convertCmsBlock( array $info ) : bool|int
{
if ( !isset( $info['block_id'] ) )
{
@@ -809,14 +811,14 @@ class Cms extends Core
/**
* @brief Orphaned Blocks Container
*/
protected $orphanedBlockContainer = NULL;
protected ?int $orphanedBlockContainer = NULL;
/**
* Returns a category to store blocks that do not have one, creating one if needed.
*
* @return integer The ID.
* @return int The ID.
*/
protected function _orphanedBlocksCategory()
protected function _orphanedBlocksCategory() : int
{
if ( $this->orphanedBlockContainer === NULL )
{
@@ -841,9 +843,9 @@ class Cms extends Core
*
* @param array $info Data to insert
* @param array $fields Custom Field Data
* @return integer|boolean The ID of the newly inserted database, or FALSE on failure.
* @return int|bool The ID of the newly inserted database, or FALSE on failure.
*/
public function convertCmsDatabase( $info=array(), $fields=array() )
public function convertCmsDatabase( array $info=array(), array $fields=array() ) : bool|int
{
/* This is about to get caaaraaaaaazy */
if ( !isset( $info['database_id'] ) )
@@ -1097,10 +1099,6 @@ class Cms extends Core
$info['database_forum_prefix'] = '';
$info['database_forum_suffix'] = '';
}
catch( LogicException $e ) # a bug
{
throw $e;
}
if ( isset( $info['database_tags_predefined'] ) )
{
@@ -1439,7 +1437,7 @@ class Cms extends Core
Db::i()->createTable( $table );
}
}
catch( \IPS\Db\Exception $ex )
catch( DbException $ex )
{
throw new LogicException( $ex );
}
@@ -1553,8 +1551,7 @@ class Cms extends Core
Db::i()->update( 'cms_pages', array( 'page_content' => $page ), array( "page_id=?", $info['database_page_id'] ) );
}
catch( UnderflowException $e ) {}
catch( \IPS\Db\Exception $e ) {}
catch( UnderflowException|DbException $e ) {}
unset( Store::i()->cms_databases );
@@ -1566,9 +1563,9 @@ class Cms extends Core
* Convert a database category
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted category, or FALSE on failure.
* @return int|bool The ID of the newly inserted category, or FALSE on failure.
*/
public function convertCmsDatabaseCategory( $info=array() )
public function convertCmsDatabaseCategory( array $info=array() ) : bool|int
{
if ( !isset( $info['category_id'] ) )
{
@@ -1582,7 +1579,7 @@ class Cms extends Core
{
$info['category_database_id'] = $this->software->app->getLink( $info['category_database_id'], 'cms_databases' );
}
catch( OutRangeException $e )
catch( OutOfRangeException $e )
{
$this->software->app->log( 'cms_database_category_missing_database', __METHOD__, App::LOG_WARNING, $info['category_id'] );
return FALSE;
@@ -1770,7 +1767,7 @@ class Cms extends Core
}
}
}
catch( OutOfRangeException $e )
catch( OutOfRangeException|InvalidArgumentException $e )
{
$info['category_forum_override'] = 0;
$info['category_forum_record'] = 0;
@@ -1780,20 +1777,6 @@ class Cms extends Core
$info['category_forum_prefix'] = NULL;
$info['category_forum_suffix'] = NULL;
}
catch( InvalidArgumentException $e )
{
$info['category_forum_override'] = 0;
$info['category_forum_record'] = 0;
$info['category_forum_comments'] = 0;
$info['category_forum_delete'] = 0;
$info['category_forum_forum'] = 0;
$info['category_forum_prefix'] = NULL;
$info['category_forum_suffix'] = NULL;
}
catch( LogicException $e )
{
throw $e;
}
if ( !isset( $info['category_full_path'] ) )
{
@@ -1884,9 +1867,9 @@ class Cms extends Core
* @param array $fields Custom Field Data.
* @param string|NULL $imagepath Path to record image
* @param string|NULL $imagedata Image data
* @return integer|boolean The ID of the newly inserted record, or FALSE on failure.
* @return int|bool The ID of the newly inserted record, or FALSE on failure.
*/
public function convertCmsDatabaseRecord( $info=array(), $fields=array(), $imagepath=NULL, $imagedata=NULL )
public function convertCmsDatabaseRecord( array $info=array(), array $fields=array(), ?string $imagepath=NULL, ?string $imagedata=NULL ) : bool|int
{
if ( !isset( $info['record_id'] ) )
{
@@ -2028,10 +2011,6 @@ class Cms extends Core
{
$info['record_topicid'] = 0;
}
catch( LogicException $e )
{
throw $e;
}
}
else
{
@@ -2212,7 +2191,7 @@ class Cms extends Core
* @param array $fieldInfo The Field Information to format. This SHOULD be in $foreign_id => $content format, however field_$foreign_id => $content is also accepted.
* @return array An array of data formatted for cms_custom_database_*
*/
protected function _formatFieldsForSaving( $fieldInfo )
protected function _formatFieldsForSaving( array $fieldInfo ) : array
{
$return = array();
@@ -2254,9 +2233,9 @@ class Cms extends Core
* Convert a Comment
*
* @param array $info Data to insert.
* @return integer|boolean The ID of the newly inserted comment, or FALSE on failure.
* @return int|bool The ID of the newly inserted comment, or FALSE on failure.
*/
public function convertCmsDatabaseComment( $info=array() )
public function convertCmsDatabaseComment( array $info=array() ) : bool|int
{
if ( !isset( $info['comment_id'] ) )
{
@@ -2427,9 +2406,9 @@ class Cms extends Core
* Convert a review
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted review, or FALSE on failure.
* @return int|bool The ID of the newly inserted review, or FALSE on failure.
*/
public function convertCmsDatabaseReview( $info=array() )
public function convertCmsDatabaseReview( array $info=array() ) : bool|int
{
if ( !isset( $info['review_id'] ) )
{
@@ -2648,9 +2627,9 @@ class Cms extends Core
* Convert a Media Folder
*
* @param array $info Data to insert
* @return integer|boolean The ID of the newly inserted folder, or FALSE on failure.
* @return int|bool The ID of the newly inserted folder, or FALSE on failure.
*/
public function convertCmsMediaFolder( $info=array() )
public function convertCmsMediaFolder( array $info=array() ) : bool|int
{
if ( !isset( $info['media_folder_id'] ) )
{
@@ -2701,9 +2680,9 @@ class Cms extends Core
* @param array $info Data to insert
* @param string|NULL $filepath The path to the file, or NULL.
* @param string|NULL $filedata The data for the file, or NULL.
* @return integer|boolean The ID of the newly inserted media file, or FALSE on failure.
* @return int|bool The ID of the newly inserted media file, or FALSE on failure.
*/
public function convertCmsMedia( $info=array(), $filepath=NULL, $filedata=NULL )
public function convertCmsMedia( array $info=array(), ?string $filepath=NULL, ?string $filedata=NULL ) : bool|int
{
if ( !isset( $info['media_id'] ) )
{
@@ -2798,17 +2777,12 @@ class Cms extends Core
}
}
}
catch( Exception $e )
catch( Exception|ErrorException $e )
{
$this->software->app->log( $e->getMessage(), __METHOD__, App::LOG_WARNING, $info['media_id'] );
return FALSE;
}
catch( ErrorException $e )
{
$this->software->app->log( $e->getMessage(), __METHOD__, App::LOG_WARNING, $info['media_id'] );
return FALSE;
}
$id = $info['media_id'];
unset( $info['media_id'] );
@@ -2826,9 +2800,9 @@ class Cms extends Core
* @param string|NULL $filepath Path to the file, or NULL.
* @param string|NULL $filedata Binary data for the file, or NULL.
* @param string|NULL $thumbnailpath Path to the thumbnail, or NULL.
* @return integer|boolean The ID of the newly inserted attachment, or FALSE on failure.
* @return int|bool The ID of the newly inserted attachment, or FALSE on failure.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath = NULL )
public function convertAttachment( array $info=array(), array $map=array(), ?string $filepath=NULL, ?string $filedata=NULL, ?string $thumbnailpath = NULL ) : bool|int
{
$database = $this->software->app->getLink( str_replace( '-review', '', $map['id3'] ), 'cms_databases' );
@@ -2860,11 +2834,11 @@ class Cms extends Core
* Convert a Tag - CMS, we need to verify the database in a different way that doesn't require it to be on a page
*
* @param array $info Data to insert
* @return boolean|integer The ID of the newly inserted tag, or FALSE on failure.
* @return bool|int The ID of the newly inserted tag, or FALSE on failure.
* @note Like Follows, this should be done when the actual content it's attached too is being converted.
* @note core_tags_cache and core_tags_perms need to be populated by the converter.
*/
public function convertTag( $info=array() )
public function convertTag( array $info=array() ) : bool|int
{
$classname = 'IPS\cms\\' . ucfirst( $info['tag_meta_area'] );