Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+121 -39
View File
@@ -117,39 +117,48 @@ class _Cms extends Core
$count += \IPS\Db::i()->select( 'COUNT(*)', "cms_custom_database_{$database}" )->first();
$links[] = "cms_custom_database_{$database}";
}
$dependencies = array();
if ( array_key_exists( 'convertCmsDatabaseCategories', $this->getConvertableItems() ) )
{
$dependencies[] = 'convertCmsDatabaseCategories';
}
$return[ $k ] = array(
'step_title' => 'convert_cms_database_records',
'step_method' => 'convertCmsDatabaseRecords',
'ips_rows' => $count,
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
'per_cycle' => 100,
'dependencies' => array( 'convertCmsDatabases', 'convertCmsDatabaseCategories' ),
'link_type' => $links,
'step_title' => 'convert_cms_database_records',
'step_method' => 'convertCmsDatabaseRecords',
'ips_rows' => $count,
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
'per_cycle' => 100,
'dependencies' => array( 'convertCmsDatabases' ),
'link_type' => $links,
'requires_rebuild' => TRUE
);
break;
case 'convertCmsDatabaseComments':
$return[ $k ] = array(
'step_title' => 'convert_cms_database_comments',
'step_method' => 'convertCmsDatabaseComments',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_comments' )->first(),
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
'per_cycle' => 2000,
'dependencies' => array( 'convertCmsDatabaseRecords' ),
'link_type' => 'cms_database_comments',
'step_title' => 'convert_cms_database_comments',
'step_method' => 'convertCmsDatabaseComments',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_comments' )->first(),
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
'per_cycle' => 2000,
'dependencies' => array( 'convertCmsDatabaseRecords' ),
'link_type' => 'cms_database_comments',
'requires_rebuild' => TRUE
);
break;
case 'convertCmsDatabaseReviews':
$return[ $k ] = array(
'step_title' => 'convert_cms_database_reviews',
'step_method' => 'convertCmsDatabaseReviews',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_reviews' )->first(),
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
'per_cycle' => 2000,
'dependencies' => array( 'convertCmsDatabaseRecords' ),
'link_type' => 'cms_database_reviews',
'step_title' => 'convert_cms_database_reviews',
'step_method' => 'convertCmsDatabaseReviews',
'ips_rows' => \IPS\Db::i()->select( 'COUNT(*)', 'cms_database_reviews' )->first(),
'source_rows' => $this->software->countRows( $v['table'], $v['where'] ),
'per_cycle' => 2000,
'dependencies' => array( 'convertCmsDatabaseRecords' ),
'link_type' => 'cms_database_reviews',
'requires_rebuild' => TRUE
);
break;
@@ -234,6 +243,8 @@ class _Cms extends Core
}
}
$return = $this->software->extraMenuRows( $return );
return $return;
}
@@ -283,7 +294,7 @@ class _Cms extends Core
break;
case 'convertCmsDatabaseCategories':
$return['convertCmsDatabaseDategories'] = array( 'cms_database_categories' => NULL );
$return['convertCmsDatabaseCategories'] = array( 'cms_database_categories' => NULL );
break;
case 'convertCmsDatabaseRecords':
@@ -296,6 +307,8 @@ class _Cms extends Core
}
$return['convertCmsDatabaseRecords'] = $toReturn;
}
$return['convertCmsDatabaseRecords']['core_tags'] = array( 'tag_meta_app=?', 'cms' );
break;
case 'convertCmsDatabaseComments':
@@ -322,7 +335,7 @@ class _Cms extends Core
}
}
return $return[ $method ];
return isset( $return[ $method ] ) ? $return[ $method ] : array();
}
/**
@@ -426,12 +439,12 @@ class _Cms extends Core
$info['page_js_css_ids'] = '';
$info['page_js_css_objects'] = json_encode( array( 'css' => NULL, 'js' => NULL ) );
if ( !isset( $info['page_name'] ) )
if ( !isset( $info['page_name'] ) OR empty( $info['page_name'] ) )
{
$info['page_name'] = "Untitled Page {$info['page_id']}";
}
if ( !isset( $info['page_seo_name'] ) )
if ( !isset( $info['page_seo_name'] ) OR empty( $info['page_seo_name'] ) )
{
$info['page_seo_name'] = \IPS\Http\Url::seoTitle( $info['page_name'] );
}
@@ -483,6 +496,23 @@ class _Cms extends Core
{
$info['page_folder_id'] = 0;
}
/* We cannot have a page name the same as a folder name in this folder */
try
{
/* Check folder */
if ( intval( $info['page_folder_id'] ) == \IPS\cms\Pages\Folder::load( $info['page_seo_name'], 'folder_name' )->parent_id )
{
$info['page_seo_name'] = \IPS\Http\Url::seoTitle( $info['page_name'] . '-' . $info['page_id'] );
}
}
catch ( \OutOfRangeException $e ) {}
/* Check that we don't have the same FURL as an app */
if ( \IPS\cms\Pages\Page::isFurlCollision( $info['page_seo_name'] ) )
{
$info['page_seo_name'] = \IPS\Http\Url::seoTitle( $info['page_name'] . '-page' );
}
if ( !isset( $info['page_full_path'] ) )
{
@@ -1060,7 +1090,7 @@ class _Cms extends Core
}
else
{
$fieldName = ucfirst( $field['field_type'] );
$fieldName = mb_ucfirst( $field['field_type'] );
}
if ( isset( $field['field_desc'] ) )
@@ -1104,6 +1134,32 @@ class _Cms extends Core
{
$field['field_extra'] = '';
}
/* An Item Field needs extra data set */
if( $field['field_type'] == 'Item' )
{
$fieldExtra = !empty( $field['field_extra'] ) ? $field['field_extra'] : array();
if( isset( $fieldExtra['database'] ) )
{
try
{
$fieldExtra['database'] = $this->software->app->getLink( $fieldExtra['database'], 'cms_databases' );
}
catch( \OutOfRangeException $e )
{
/* Can't convert this if we don't know what it's referencing */
$this->software->app->log( 'cms_database_field_item_no_reference', __METHOD__, \IPS\convert\APP::LOG_NOTICE, $field['field_id'] );
continue;
}
}
else
{
$fieldExtra['database'] = $inserted_id;
}
$field['field_extra'] = json_encode( $fieldExtra );
}
if ( !isset( $field['field_html'] ) )
{
@@ -1345,6 +1401,7 @@ class _Cms extends Core
case 'Youtube':
case 'Spotify':
case 'Soundcloud':
case 'Item':
$columnDefinition['type'] = 'TEXT';
break;
@@ -1452,7 +1509,7 @@ class _Cms extends Core
if ( array_key_exists( 'category_desc', $info ) )
{
$desc = $info['category_desc'];
$desc = !empty( $info['category_desc'] ) ? $info['category_desc'] : '';
unset( $info['category_desc'] );
}
else
@@ -1567,6 +1624,25 @@ class _Cms extends Core
{
$info['category_meta_description'] = NULL;
}
if ( isset( $info['category_parent_id'] ) )
{
if ( $info['category_parent_id'] !== 0 )
{
try
{
$info['category_parent_id'] = $this->software->app->getLink( $info['category_parent_id'], 'cms_database_categories' );
}
catch( \OutOfRangeException $e )
{
/* Does the ID exist in the source? */
$info['category_conv_parent'] = $info['category_parent_id'];
/* Default to a category unless a later converted forum updates the parent_id */
$info['category_parent_id'] = 0;
}
}
}
/* Forum Integration */
try
@@ -1699,6 +1775,8 @@ class _Cms extends Core
$inserted_id = \IPS\Db::i()->insert( 'cms_database_categories', $info );
$this->software->app->addLink( $inserted_id, $id, 'cms_database_categories' );
\IPS\Db::i()->update( 'cms_database_categories', array( "category_parent_id" => $inserted_id ), array( "category_conv_parent=? AND category_conv_parent<>?", $id, 0 ) );
\IPS\Lang::saveCustom( 'cms', "content_cat_name_{$inserted_id}", $info['category_name'] );
\IPS\Lang::saveCustom( 'cms', "content_cat_name_{$inserted_id}_desc", $desc );
@@ -1709,8 +1787,10 @@ class _Cms extends Core
/**
* Convert a Record
*
* @param array $info The data to insert.
* @param array $fields Custom Field Data.
* @param array $info The data to insert.
* @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.
*/
public function convertCmsDatabaseRecord( $info=array(), $fields=array(), $imagepath=NULL, $imagedata=NULL )
@@ -1918,6 +1998,12 @@ class _Cms extends Core
if ( isset( $info['record_image'] ) AND ( !is_null( $imagepath ) OR !is_null( $imagedata ) ) )
{
$container = NULL;
if( $info['record_saved'] )
{
$container = 'monthly_' . date( 'Y', $info['record_saved'] ) . '_' . date( 'm', $info['record_saved'] );
}
try
{
if ( is_null( $imagedata ) AND !is_null( $imagepath ) )
@@ -1925,10 +2011,10 @@ class _Cms extends Core
$imagedata = @file_get_contents( $imagepath );
$imagepath = NULL;
}
$file = \IPS\File::create( 'cms_Records', $info['record_image'], $imagedata );
$file = \IPS\File::create( 'cms_Records', $info['record_image'], $imagedata, $container, TRUE );
$info['record_image'] = (string) $file;
$info['record_image_thumb'] = (string) $file->thumbnail();
$info['record_image_thumb'] = (string) $file->thumbnail( 'cms_Records' );
}
catch( \Exception $e )
{
@@ -2174,10 +2260,6 @@ class _Cms extends Core
$info['comment_author'] = NULL;
}
}
else
{
$info['comment_author'] = NULL;
}
if ( isset( $info['comment_edit_date'] ) )
{
@@ -2322,7 +2404,7 @@ class _Cms extends Core
/* This seems silly, but we really do need a rating */
if ( !isset( $info['review_rating'] ) OR $info['review_rating'] < 1 )
{
$this->software->app->log( 'calendar_event_review_invalid_rating', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
$this->software->app->log( 'cms_database_review_invalid_rating', __METHOD__, \IPS\convert\App::LOG_WARNING, $info['review_id'] );
return FALSE;
}
@@ -2648,7 +2730,7 @@ class _Cms extends Core
* @param string|NULL $filedata Binary data for the file, or NULL.
* @return integer|boolean The ID of the newly inserted attachment, or FALSE on failure.
*/
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL )
public function convertAttachment( $info=array(), $map=array(), $filepath=NULL, $filedata=NULL, $thumbnailpath = NULL )
{
$database = $this->software->app->getLink( str_replace( '-review', '', $map['id3'] ), 'cms_databases' );
@@ -2669,6 +2751,6 @@ class _Cms extends Core
$map['id3'] = $database;
return parent::convertAttachment( $info, $map, $filepath, $filedata );
return parent::convertAttachment( $info, $map, $filepath, $filedata, $thumbnailpath );
}
}