From 768948b85f948653d0882da2698f1bdde59a0e4d Mon Sep 17 00:00:00 2001 From: lsces Date: Wed, 27 Aug 2025 17:18:02 +0100 Subject: Code updated to PHP8.4 and namespace --- admin/admin_rss_inc.php | 83 ++++++++++++++++++++++---------------------- includes/bit_setup_inc.php | 20 ++++++----- liberty_plugins/data.rss.php | 41 ++++++++++++---------- templates/html_head_inc.tpl | 2 +- 4 files changed, 77 insertions(+), 69 deletions(-) mode change 100644 => 100755 liberty_plugins/data.rss.php diff --git a/admin/admin_rss_inc.php b/admin/admin_rss_inc.php index 79ba37d..f3eb8b1 100644 --- a/admin/admin_rss_inc.php +++ b/admin/admin_rss_inc.php @@ -1,5 +1,7 @@ mPackages as $pkg => $pkgInfo ) { if( is_file( $pkgInfo['path'].$pkg.'_rss.php' ) ) { - $formRSSFeeds[$pkg.'_rss'] = array( + $formRSSFeeds["{$pkg}_rss"] = [ 'label' => $pkg, - ); + ]; } } $gBitSmarty->assign( "formRSSFeeds", $formRSSFeeds ); -$formRSSSettings = array( - 'rssfeed_language' => array( +$formRSSSettings = [ + 'rssfeed_language' => [ 'label' => 'Language', - ), - 'rssfeed_creator' => array( + ], + 'rssfeed_creator' => [ 'label' => 'Creator', - ), - 'rssfeed_editor' => array( + ], + 'rssfeed_editor' => [ 'label' => 'Editor', - 'note' => 'Email address for person responsible for editorial content. For RDF 2.0', - ), - 'rssfeed_webmaster' => array( + 'note' => 'Email address for person responsible for editorial content. For RDF 2.0', + ], + 'rssfeed_webmaster' => [ 'label' => 'Webmaster', - 'note' => 'Email address for person responsible for technical issues relating to channel. For RDF 2.0', - ), - 'rssfeed_image_url' => array( + 'note' => 'Email address for person responsible for technical issues relating to channel. For RDF 2.0', + ], + 'rssfeed_image_url' => [ 'label' => 'Image URL', - 'note' => 'Enter the full URL to an image that you want to associate with your RSS channels', - ), - 'rssfeed_css_url' => array( + 'note' => 'Enter the full URL to an image that you want to associate with your RSS channels', + ], + 'rssfeed_css_url' => [ 'label' => 'CSS File URL', - 'note' => 'Enter the full URL to a CSS file you want to use to style your RSS Feeds.', - ), - 'rssfeed_truncate' => array( + 'note' => 'Enter the full URL to a CSS file you want to use to style your RSS Feeds.', + ], + 'rssfeed_truncate' => [ 'label' => 'Truncate RSS feed', - 'note' => 'Enter the number of characters you want to feed per item in the rss feeds. Default is 5000 characters.', - ), -); + 'note' => 'Enter the number of characters you want to feed per item in the rss feeds. Default is 5000 characters.', + ], +]; $gBitSmarty->assign( "formRSSSettings", $formRSSSettings ); -$formRSSOptions = array( - 'rssfeed_httpauth' => array( +$formRSSOptions = [ + 'rssfeed_httpauth' => [ 'label' => 'Enable HTTP Authentication', - 'note' => 'Use HTTP Authentication with SSL to enable Registered Users to gain access to Private Content Feeds.', - ), -); + 'note' => 'Use HTTP Authentication with SSL to enable Registered Users to gain access to Private Content Feeds.', + ], +]; $gBitSmarty->assign( "formRSSOptions", $formRSSOptions ); -$cacheTimes = array( - 0 => tra( "(no cache)" ), - 60 => "1 ".tra( "minute" ), - 300 => "5 ".tra( "minutes" ), - 600 => "10 ".tra( "minutes" ), - 1800 => "30 ".tra( "minutes" ), - 3600 => "1 ".tra( "hour" ), - 7200 => "2 ".tra( "hours" ), - 14400 => "4 ".tra( "hours" ), -); +$cacheTimes = [ + 0 => KernelTools::tra( "(no cache)" ), + 60 => "1 " . KernelTools::tra( "minute" ), + 300 => "5 " . KernelTools::tra( "minutes" ), + 600 => "10 " . KernelTools::tra( "minutes" ), + 1800 => "30 " . KernelTools::tra( "minutes" ), + 3600 => "1 " . KernelTools::tra( "hour" ), + 7200 => "2 " . KernelTools::tra( "hours" ), + 14400 => "4 " . KernelTools::tra( "hours" ), +]; $gBitSmarty->assign( "cacheTimes", $cacheTimes ); -$feedTypes = array( +$feedTypes = [ 0 => "RSS 0.91", 1 => "RSS 1.0", 2 => "RSS 2.0", @@ -76,7 +78,7 @@ $feedTypes = array( 7 => "OPML", 8 => "HTML", 9 => "JS", -); +]; $gBitSmarty->assign( "feedTypes", $feedTypes ); if( !empty( $_REQUEST['feed_settings'] ) ) { @@ -100,4 +102,3 @@ if( !empty( $_REQUEST['feed_settings'] ) ) { simple_set_toggle( $item, RSS_PKG_NAME ); } } -?> diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index a41e339..06e2421 100644 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -1,18 +1,22 @@ 'rss', - 'package_path' => dirname( dirname( __FILE__ ) ).'/', -); -$gBitSystem->registerPackage( $registerHash ); + 'package_path' => dirname( dirname( __FILE__ ) ) . '/', +]; + +// fix to quieten down VS Code which can't see the dynamic creation of these ... +define( 'RSS_PKG_NAME', $pRegisterHash['package_name'] ); +define( 'RSS_PKG_URL', BIT_ROOT_URL . basename( $pRegisterHash['package_path'] ) . '/' ); + +$gBitSystem->registerPackage( $pRegisterHash ); if( $gBitSystem->isPackageActive( 'rss' ) ) { - $menuHash = array( + $menuHash = [ 'package_name' => RSS_PKG_NAME, - 'index_url' => RSS_PKG_URL.'index.php', + 'index_url' => RSS_PKG_URL . 'index.php', 'menu_template' => 'bitpackage:rss/menu_rss.tpl', - ); + ]; $gBitSystem->registerAppMenu( $menuHash ); } -?> diff --git a/liberty_plugins/data.rss.php b/liberty_plugins/data.rss.php old mode 100644 new mode 100755 index 849c726..ec900cf --- a/liberty_plugins/data.rss.php +++ b/liberty_plugins/data.rss.php @@ -1,10 +1,16 @@ 'rss', - 'auto_activate' => FALSE, - 'requires_pair' => FALSE, + 'auto_activate' => false, + 'requires_pair' => false, 'load_function' => 'rss_parse_data', 'title' => 'RSS Feed', 'help_page' => 'DataPluginRSS', - 'description' => tra("Display RSS Feeds"), + 'description' => KernelTools::tra("Display RSS Feeds"), 'help_function' => 'rss_extended_help', 'syntax' => "{RSS id= max= }", 'plugin_type' => DATA_PLUGIN, 'biticon' => '{biticon ilocation=quicktag ipackage=rss iname=rss-16x16 iexplain="RSS Feed"}', 'taginsert' => '{rss}' -); +]; $gLibertySystem->registerPlugin( PLUGIN_GUID_DATARSS, $pluginParams ); $gLibertySystem->registerDataTag( $pluginParams['tag'], PLUGIN_GUID_DATARSS ); @@ -46,19 +52,19 @@ function rss_extended_help() { $help = '' .'' - .'' - .'' - .'' + .'' + .'' + .'' .'' .'' .'' - .'' - .'' + .'' + .'' .'' .'' .'' - .'' - .'' + .'' + .'' .'' .'
' . tra( "Key" ) . '' . tra( "Type" ) . '' . tra( "Comments" ) . '' . KernelTools::tra( "Key" ) . '' . KernelTools::tra( "Type" ) . '' . KernelTools::tra( "Comments" ) . '
id' . tra( "string") . '
' . tra("(mandatory)") . '
' . tra( "IDs of the RSS-feeds to process. Separate multiple ids with \",\"") . '' . KernelTools::tra( "string") . '
' . KernelTools::tra("(mandatory)") . '
' . KernelTools::tra( "IDs of the RSS-feeds to process. Separate multiple ids with \",\"") . '
max' . tra( "integer") . '
' . tra("(optional)") . '
' . tra( "Number of entries to be displayed from given RSS Feed, prefixed with publication date.") . '' . KernelTools::tra( "integer") . '
' . KernelTools::tra("(optional)") . '
' . KernelTools::tra( "Number of entries to be displayed from given RSS Feed, prefixed with publication date.") . '
' ; @@ -69,15 +75,14 @@ function rss_parse_data( $data, $params ) { $repl = ''; if( !empty( $params['id'] ) ) { global $rsslib; - require_once( RSS_PKG_PATH.'rss_lib.php' ); $max = !empty( $params['max'] ) ? $params['max'] : 99; if ( $items = $rsslib->parse_feeds( $params ) ){ //if we want short descriptions get them - $shortdescs = Array(); - if ( !empty($module_params['desc_length']) && is_numeric($module_params['desc_length']) && !empty($items)){ - $shortdescs = $rsslib->get_short_descs( $items, $module_params['desc_length'] ); + $shortdescs = []; + if ( !empty($params['desc_length']) && is_numeric($params['desc_length']) && !empty($items)){ + $shortdescs = $rsslib->get_short_descs( $items, $params['desc_length'] ); } } @@ -98,5 +103,3 @@ function rss_parse_data( $data, $params ) { return $repl; } - -?> diff --git a/templates/html_head_inc.tpl b/templates/html_head_inc.tpl index b245010..6af4972 100644 --- a/templates/html_head_inc.tpl +++ b/templates/html_head_inc.tpl @@ -3,7 +3,7 @@ {/if} -{if $gBitSystem->isPackageActive( 'rss' ) and $feedlink.url} +{if $gBitSystem->isPackageActive( 'rss' ) and !empty($feedlink.url)} {/if} {/strip} -- cgit v1.3