summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlsces <lester@lsces.co.uk>2026-04-16 12:00:51 +0100
committerlsces <lester@lsces.co.uk>2026-04-16 12:00:51 +0100
commitb4b0a0e8bbf28b4508c23a5263feda1f9fe5d12f (patch)
tree0d234c8c8ff8aee63a54beb94c87f0e06089ef5a
parent9a7d792185757ee2af3101742d86e6e9d92b957b (diff)
downloadliberty-b4b0a0e8bbf28b4508c23a5263feda1f9fe5d12f.tar.gz
liberty-b4b0a0e8bbf28b4508c23a5263feda1f9fe5d12f.tar.bz2
liberty-b4b0a0e8bbf28b4508c23a5263feda1f9fe5d12f.zip
Style tidies for PHP8.4
-rwxr-xr-xincludes/classes/LibertyContent.php17
-rwxr-xr-xincludes/classes/LibertyMime.php16
-rwxr-xr-xplugins/mime.image.php4
-rw-r--r--plugins/mime.pdf.php24
-rwxr-xr-xplugins/mime.video.php2
-rwxr-xr-xtemplates/mime_meta_inc.tpl4
6 files changed, 35 insertions, 32 deletions
diff --git a/includes/classes/LibertyContent.php b/includes/classes/LibertyContent.php
index 82d4ac8..922cf3c 100755
--- a/includes/classes/LibertyContent.php
+++ b/includes/classes/LibertyContent.php
@@ -730,7 +730,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
* Removes a specific version of a page
*
* @param int $pVersion Version number to roll back to
- * @param string $Comment Comment text to be added to the action log
+ * @param string $pComment Comment text to be added to the action log
* @return bool true if completed successfully
*/
public function expungeVersion( int $pVersion = 0, $pComment = '' ): bool {
@@ -2240,13 +2240,13 @@ class LibertyContent extends LibertyBase implements BitCacheable {
* @param array different possibilities depending on derived class
* @return string Formated URL address to display the page.
*/
- public function getPreviewUrl( $pContentId = null, $pMixed = null ) {
+ public static function getPreviewUrl( $pContentId = 0, $pMixed = null ) {
if( BitBase::verifyId( $pContentId ) ) {
$ret = LIBERTY_PKG_URL.'preview.php?content_id='.$pContentId;
} elseif( BitBase::verifyId( $pMixed['content_id'] ) ) {
$ret = LIBERTY_PKG_URL.'preview.php?content_id='.$pMixed['content_id'];
- } elseif( $this->isValid() ) {
- $ret = LIBERTY_PKG_URL.'preview.php?content_id='.$this->mContentId;
+// } elseif( $this->isValid() ) {
+// $ret = LIBERTY_PKG_URL.'preview.php?content_id='.$this->mContentId;
} else {
$ret = '#';
}
@@ -3318,7 +3318,6 @@ class LibertyContent extends LibertyBase implements BitCacheable {
/**
* Delete liberty cache
*
- * @param array $pContentId
* @access public
* @return bool true on success, false on failure
*/
@@ -3382,7 +3381,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
public static function storeActionLogFromHash( $pParamHash = null ): void {
global $gBitSystem;
- if( $gBitSystem->isFeatureActive( 'liberty_action_log' ) && $this->verifyActionLog( $pParamHash ) ) {
+ if( $gBitSystem->isFeatureActive( 'liberty_action_log' ) && $gBitSystem->verifyActionLog( $pParamHash ) ) {
$gBitSystem->mDb->associateInsert( BIT_DB_PREFIX."liberty_action_log", $pParamHash['action_log_store'] );
}
}
@@ -3433,7 +3432,7 @@ class LibertyContent extends LibertyBase implements BitCacheable {
* @param array $pParamHash
* @return bool true on success, false on failure
*/
- public function verifyActionLog( &$pParamHash ) {
+ public static function verifyActionLog( &$pParamHash ) {
global $gBitUser, $gBitSystem;
// we will set $ret false if there is a problem along the way
@@ -3472,8 +3471,8 @@ class LibertyContent extends LibertyBase implements BitCacheable {
// the log message
$log_message = '';
- if( empty( $pParamHash['action_log']['log_message'] ) && !empty( $this ) && !empty( $this->mLogs ) ) {
- foreach( $this->mLogs as $key => $msg ) {
+ if( empty( $pParamHash['action_log']['log_message'] ) && !empty( $gBitSystem ) && !empty( $gBitSystem->mLogs ) ) {
+ foreach( $gBitSystem->mLogs as $key => $msg ) {
$log_message .= "$msg";
}
} elseif( !empty( $pParamHash['action_log']['log_message'] ) ) {
diff --git a/includes/classes/LibertyMime.php b/includes/classes/LibertyMime.php
index 3c187d2..30fe4d5 100755
--- a/includes/classes/LibertyMime.php
+++ b/includes/classes/LibertyMime.php
@@ -264,13 +264,13 @@ class LibertyMime extends LibertyContent {
* getThumbnailUrl will fetch the primary thumbnail for a given content. If nothing has been set, it will fetch the last thumbnail it can find.
*
* @param string $pSize
- * @param array $pInfoHash
+ * @param array $mInfo
* @access public
* @return bool true on success, false on failure - $this->mErrors will contain reason for failure
*/
public function getThumbnailUrl( string $pSize = 'small', ?array $mInfo = null, ?int $pSecondaryId = null, ?int $pDefault = null ): string|null {
$ret = null;
- if( !empty( $pInfoHash ) ) {
+ if( !empty( $mInfo ) ) {
// do some stuff if we are given a hash of stuff
} elseif( $this->isValid() && !empty( $this->mStorage ) ) {
foreach( array_keys( $this->mStorage ) as $attachmentId ) {
@@ -283,7 +283,7 @@ class LibertyMime extends LibertyContent {
}
}
if( $pDefault && empty( $ret ) ) {
- $ret = parent::getThumbnailUrl( $pSize, $pInfoHash, $pSecondaryId );
+ $ret = parent::getThumbnailUrl( $pSize, $mInfo, $pSecondaryId );
}
return $ret;
}
@@ -893,15 +893,15 @@ class LibertyMime extends LibertyContent {
global $gBitSystem;
$ret = false;
if( BitBase::verifyId( $pAttachmentId ) && !empty( $pType ) && !empty( $pParamHash )) {
- if( is_array( $pParamHash )) {
+ if( \is_array( $pParamHash )) {
foreach( $pParamHash as $key => $data ) {
- if( !is_array( $data )) {
+ if( !\is_array( $data )) {
// store the data in the meta table
- $meta = array(
+ $meta = [
'attachment_id' => $pAttachmentId,
'meta_type_id' => LibertyMime::storeMetaId( $pType, 'type' ),
'meta_title_id' => LibertyMime::storeMetaId( $key, 'title' ),
- );
+ ];
// remove this entry from the database if it already exists
$gBitSystem->mDb->query( "DELETE FROM `".BIT_DB_PREFIX."liberty_attachment_meta_data` WHERE `attachment_id` = ? AND `meta_type_id` = ? AND `meta_title_id` = ?", $meta );
@@ -1082,7 +1082,7 @@ class LibertyMime extends LibertyContent {
/**
* mime_get_storage_sub_dir_name get a filename based on the uploaded file
*
- * @param array $pFileHash File information provided in $_FILES
+ * @param array pFileHash File information provided in $_FILES
* @access public
* @return string appropriate sub dir name
*/
diff --git a/plugins/mime.image.php b/plugins/mime.image.php
index 2400b78..65f2ef0 100755
--- a/plugins/mime.image.php
+++ b/plugins/mime.image.php
@@ -51,7 +51,7 @@ $pluginParams = [
// This should be the same for all mime plugins
'plugin_type' => MIME_PLUGIN,
// Set this to true if you want the plugin active right after installation
- 'auto_activate' => false,
+ 'auto_activate' => true,
// Help page on bitweaver.org
//'help_page' => 'LibertyMime+Image+Plugin',
// this should pick up all image
@@ -203,7 +203,7 @@ function mime_image_store_exif_data( $pFileHash ) {
}
if( !empty( $exifHash['EXIF'] )) {
- // LibertyMime::storeMetaData( $pFileHash['attachment_id'], $exifHash['EXIF'], 'EXIF' );
+ LibertyMime::storeMetaData( $pFileHash['attachment_id'], $exifHash['EXIF'], 'EXIF' );
}
}
diff --git a/plugins/mime.pdf.php b/plugins/mime.pdf.php
index 00fcce1..b5cfee3 100644
--- a/plugins/mime.pdf.php
+++ b/plugins/mime.pdf.php
@@ -48,7 +48,7 @@ $pluginParams = [
// This should be the same for all mime plugins
'plugin_type' => MIME_PLUGIN,
// Set this to true if you want the plugin active right after installation
- 'auto_activate' => false,
+ 'auto_activate' => true,
// Help page on bitweaver.org
//'help_page' => 'LibertyMime+Image+Plugin',
// this should pick up all raw pdf files
@@ -81,7 +81,7 @@ function mime_pdf_store( &$pStoreRow ) {
$ret = false;
}
- if( $gBitSystem->getConfig( 'pdf_thumbnails', 'y' ) == 'y' ) {
+ if( $gBitSystem->getConfig( 'pdf_thumbnails', 'y' ) == 'y' && !empty( $pStoreRow['source_file'] ) ) {
if( !mime_pdf_thumbnail( $pStoreRow )) {
// if it all goes tits up, we'll know why
$pStoreRow['errors'] = $pStoreRow['log'];
@@ -117,7 +117,7 @@ function mime_pdf_update( &$pStoreRow, $pParams = null ) {
}
}
- if( $gBitSystem->getConfig( 'pdf_thumbnails', 'y' ) == 'y' ) {
+ if( $gBitSystem->getConfig( 'pdf_thumbnails', 'y' ) == 'y' && !empty( $pStoreRow['source_file'] ) ) {
if( !mime_pdf_thumbnail( $pStoreRow )) {
// if it all goes tits up, we'll know why
$pStoreRow['errors'] = $pStoreRow['log'];
@@ -189,20 +189,24 @@ function mime_pdf_text_extract( &$pFileHash ) {
*/
function mime_pdf_thumbnail( $pFileHash ) {
global $gBitSystem;
- $stock_command = shell_exec( 'which convert' ) ?? "/usr/bin/convert";
+ $stock_command = shell_exec( 'which magick' ) ?? "/bin/magick";
$mwconvert = trim( $gBitSystem->getConfig( 'mwconvert_path', $stock_command ));
if( is_executable( $mwconvert ) && $gBitSystem->getConfig( 'pdf_thumbnails', 'y' ) == 'y' ) {
- $source = STORAGE_PKG_PATH.$pFileHash['upload']['dest_branch'];
- if ( $gBitSystem->isFeatureActive( 'liberty_jpeg_originals' ) ) {
- $source .= 'original.jpg';
+ if ( !empty($pFileHash['upload']) ) {
+ $source = STORAGE_PKG_PATH.$pFileHash['upload']['dest_branch'];
+ if ( $gBitSystem->isFeatureActive( 'liberty_jpeg_originals' ) ) {
+ $source .= 'original.jpg';
+ } else {
+ $source .= $pFileHash['upload']['name'];
+ }
} else {
- $source .= $pFileHash['upload']['name'];
+ $source = $pFileHash['source_file'];
}
$dest_branch = dirname( $source );
$thumb_file = "$dest_branch/thumb.jpg";
- $mwccommand = "$mwconvert '$source' '$thumb_file' 2>&1";
+ $mwccommand = "$mwconvert '$source'\[0\] -thumbnail 1024x1024 -background white -flatten '$thumb_file' 2>&1";
shell_exec( $mwccommand );
if( is_file( $thumb_file ) && filesize( $thumb_file ) > 0 ) {
@@ -212,7 +216,7 @@ function mime_pdf_thumbnail( $pFileHash ) {
}
$genHash = [
'attachment_id' => $pFileHash['attachment_id'],
- 'dest_branch' => $pFileHash['upload']['dest_branch'],
+ 'dest_branch' => $pFileHash['upload']['dest_branch'] ?? dirname( $source ),
'source_file' => $thumb_file,
'type' => 'image/jpeg',
'thumbnail_sizes' => [ 'extra-large', 'large', 'medium', 'small', 'avatar', 'icon' ],
diff --git a/plugins/mime.video.php b/plugins/mime.video.php
index ba360eb..28bbe01 100755
--- a/plugins/mime.video.php
+++ b/plugins/mime.video.php
@@ -51,7 +51,7 @@ $pluginParams = [
// This should be the same for all mime plugins
'plugin_type' => MIME_PLUGIN,
// Set this to true if you want the plugin active right after installation
- 'auto_activate' => false,
+ 'auto_activate' => true,
// Help page on bitweaver.org
'help_page' => 'LibertyMime+Video+Plugin',
// this should pick up all videos
diff --git a/templates/mime_meta_inc.tpl b/templates/mime_meta_inc.tpl
index 2bb3235..1d946ad 100755
--- a/templates/mime_meta_inc.tpl
+++ b/templates/mime_meta_inc.tpl
@@ -13,7 +13,7 @@
<a href="{$attachment.display_url}">{$attachment.file_name}</a>
{/forminput}
</div>
-{elseif $attachment.download_url}
+{elseif !empty($attachment.download_url)}
<div class="form-group">
{formlabel label="Download" for=""}
{forminput}
@@ -32,7 +32,7 @@
<div class="form-group">
{formlabel label="Last Modified" for=""}
{forminput}
- {$attachment.last_modified|bit_long_datetime}
+ {$attachment.last_modified|default:'---'|bit_long_datetime}
{/forminput}
</div>