diff options
| author | lsces <lester@lsces.co.uk> | 2025-08-27 17:01:22 +0100 |
|---|---|---|
| committer | lsces <lester@lsces.co.uk> | 2025-08-27 17:01:22 +0100 |
| commit | cd65f3b9afa75bc70c95a08949c965bde43d98fd (patch) | |
| tree | 8ff77a7e18fefce950db7bc36bc4671295722f83 /includes | |
| parent | 0ae6ef9faac97b5cdc316d7d701adc05ce651002 (diff) | |
| download | feed-cd65f3b9afa75bc70c95a08949c965bde43d98fd.tar.gz feed-cd65f3b9afa75bc70c95a08949c965bde43d98fd.tar.bz2 feed-cd65f3b9afa75bc70c95a08949c965bde43d98fd.zip | |
updated to PHP8.4 and namespace
Diffstat (limited to 'includes')
| -rwxr-xr-x[-rw-r--r--] | includes/bit_setup_inc.php | 18 | ||||
| -rwxr-xr-x[-rw-r--r--] | includes/classes/FeedStatus.php | 18 | ||||
| -rw-r--r-- | includes/feed_lib.php | 30 |
3 files changed, 35 insertions, 31 deletions
diff --git a/includes/bit_setup_inc.php b/includes/bit_setup_inc.php index bcfb0c5..65525f5 100644..100755 --- a/includes/bit_setup_inc.php +++ b/includes/bit_setup_inc.php @@ -1,23 +1,25 @@ <?php +namespace Bitweaver\Feed; + global $gBitSystem, $gBitUser, $gBitThemes; -$registerHash = array( +$pRegisterHash = [ 'package_name' => 'feed', 'package_path' => dirname( dirname( __FILE__ ) ).'/', -); - -$gBitSystem->registerPackage( $registerHash ); +]; +define( 'FEED_PKG_NAME', $pRegisterHash['package_name'] ); +define( 'FEED_PKG_PATH', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/'); +define( 'FEED_PKG_INCLUDE_URL', BIT_ROOT_PATH . basename( $pRegisterHash['package_path'] ) . '/includes/'); +$gBitSystem->registerPackage( $pRegisterHash ); if( $gBitSystem->isPackageActive( 'feed' ) ) { if( $gBitUser->hasPermission( 'p_feed_view' )) { - $menuHash = array( + $menuHash = [ 'package_name' => FEED_PKG_NAME, 'index_url' => FEED_PKG_URL.'index.php', 'menu_template' => 'bitpackage:feed/menu_feed.tpl', - ); + ]; $gBitSystem->registerAppMenu( $menuHash ); } } - -?> diff --git a/includes/classes/FeedStatus.php b/includes/classes/FeedStatus.php index 8edf1be..a079a04 100644..100755 --- a/includes/classes/FeedStatus.php +++ b/includes/classes/FeedStatus.php @@ -11,11 +11,12 @@ /** * required setup */ -require_once( LIBERTY_PKG_CLASS_PATH.'LibertyComment.php' ); +namespace Bitweaver\Feed; +use Bitweaver\Liberty\LibertyComment; +use Bitweaver\Users\RoleUser; define( 'FEEDSTATUS_CONTENT_TYPE_GUID','feedstatus'); - /** * FeedStatus * @package feed @@ -25,7 +26,7 @@ class FeedStatus extends LibertyComment { /** * During initialisation, be sure to call our base constructors **/ - function FeedStatus($pCommentId = NULL, $pContentId = NULL, $pInfo = NULL) { + public function FeedStatus($pCommentId = null, $pContentId = null, $pInfo = null) { LibertyComment::LibertyComment($pCommentId,$pContentId,$pInfo); @@ -36,14 +37,14 @@ class FeedStatus extends LibertyComment { */ $this->mContentTypeGuid = FEEDSTATUS_CONTENT_TYPE_GUID; - $this->registerContentType( FEEDSTATUS_CONTENT_TYPE_GUID, array( + $this->registerContentType( FEEDSTATUS_CONTENT_TYPE_GUID, [ 'content_type_guid' => FEEDSTATUS_CONTENT_TYPE_GUID, 'content_name' => 'Feed Status', 'handler_class' => 'FeedStatus', 'handler_package' => 'feed', 'handler_file' => 'FeedStatus.php', 'maintainer_url' => 'http://www.bitweaver.org' - ) ); + ] ); /* $this->mViewContentPerm = 'p_loc_view'; $this->mCreateContentPerm = 'p_loc_edit'; @@ -52,15 +53,14 @@ class FeedStatus extends LibertyComment { */ } - function getThumbnailUrl($pSize = 'avatar', $pInfoHash = NULL){ - $rootUser = new BitUser(NULL,$this->mInfo['root_id']); + public function getThumbnailUrl( string $pSize = 'avatar', ?array $pInfoHash = null, ?int $pSecondaryId = null, ?int $pDefault = null ): string|null { + $rootUser = new RoleUser(null,$this->mInfo['root_id']); $rootUser->load(); $thumbnailUrl = $rootUser->getThumbnailUrl( $pSize ); if( empty ($thumbnailUrl) ){ - $thumbnailUrl = USERS_PKG_URL.'icons/silhouette.png'; + $thumbnailUrl = USERS_PKG_PATH.'icons/silhouette.png'; } return $thumbnailUrl; } } -?> diff --git a/includes/feed_lib.php b/includes/feed_lib.php index 2f4f949..e4766c2 100644 --- a/includes/feed_lib.php +++ b/includes/feed_lib.php @@ -12,11 +12,18 @@ /** * feed_get_actions */ +namespace Bitweaver\Feed; +use Bitweaver\BitBase; +use Bitweaver\KernelTools; +use Bitweaver\Liberty\LibertyContent; +use Bitweaver\Liberty\LibertyComment; +use Bitweaver\Users\RoleUser; + function feed_get_actions( $pListHash ) { global $gBitDb; $whereSql = ''; - $bindVars = array(); + $bindVars = []; BitBase::prepGetList( $pListHash ); if( !empty( $pListHash['user_id'] ) ) { @@ -38,14 +45,14 @@ function feed_get_actions( $pListHash ) { $conjugationQuery = "SELECT * FROM feed_conjugation"; $overrides = $gBitDb->getAssoc( $conjugationQuery ); - $actions = array(); + $actions = []; //loop through directed actions while ( $action = $res->fetchRow() ){ if( !empty($action['content_id']) ) { //indicates that this isn't a direct action, more of a "status update" ex. "Ronald is pleased with his artwork" if( $content = LibertyContent::getLibertyObject($action['content_id']) ) { $contentType = $content->getContentType(); - $action['real_log'] = BitUser::getDisplayNameFromHash( $action, empty( $pListHash['no_link_user'] ) ).' '; + $action['real_log'] = RoleUser::getDisplayNameFromHash( $action, empty( $pListHash['no_link_user'] ) ).' '; if(!empty($overrides[strtolower($contentType)])){ $action['real_log'] .= $overrides[$contentType]['conjugation_phrase']; if($overrides[$contentType]['is_target_linked'] == 'y'){ @@ -55,7 +62,7 @@ function feed_get_actions( $pListHash ) { $action['feed_icon_url'] = $overrides[$contentType]['feed_icon_url']; } }else{ - $action['real_log'] .= tra( 'edited' ).' <a href="'.$content->getDisplayUrl().'">'.$content->getTitle().'</a>'; + $action['real_log'] .= KernelTools::tra( 'edited' ).' <a href="'.$content->getDisplayUrl().'">'.$content->getTitle().'</a>'; } } else { unset( $action ); //invalid content_id @@ -77,8 +84,8 @@ function feed_get_status( $pListHash ){ global $gBitDb; $whereSql = ''; - $bindVars = array(); - $statuses = array(); + $bindVars = []; + $statuses = []; BitBase::prepGetList( $pListHash ); if( !empty( $pListHash['user_id'] ) ) { @@ -99,7 +106,7 @@ function feed_get_status( $pListHash ){ $res = $gBitDb->query( $query, $bindVars, $pListHash['max_records'] ); - $user = new BitUser($pListHash['user_id']); + $user = new RoleUser($pListHash['user_id']); $user->load(); @@ -111,12 +118,12 @@ function feed_get_status( $pListHash ){ $status['feed_icon_url'] = $avatarUrl; - $comment = new LibertyComment(NULL,$status['content_id']); + $comment = new LibertyComment(null,$status['content_id']); $replies = $comment->getComments($status['content_id'],null,null,'commentDate_asc'); $status['replies'] = $replies; foreach ( $status['replies'] as &$reply ){ - $replyUser = new BitUser($reply['user_id']); + $replyUser = new RoleUser($reply['user_id']); $replyUser->load(); $replyAvatarUrl = $replyUser->getThumbnailUrl(); if(empty($replyAvatarUrl)){ @@ -155,8 +162,6 @@ function feed_set_status( $pParamHash ){ global $gBitDb; - require_once ( FEED_PKG_CLASSES_PATH.'FeedStatus.php'); - $status = new FeedStatus(); global $gBitUser; @@ -170,6 +175,3 @@ function feed_set_status( $pParamHash ){ $status->storeComment($pParamHash); } - - -?> |
