Skip to content

Commit

Permalink
changed: updated for Elgg 6
Browse files Browse the repository at this point in the history
  • Loading branch information
jeabakker committed Jun 3, 2024
1 parent 0c5eb88 commit 4b5f69a
Show file tree
Hide file tree
Showing 31 changed files with 123 additions and 132 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/phpunit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: PHPUnit Plugin Tests
on: [push, pull_request]

jobs:
lint:
phpunit:
name: Run PHPUnit test suites
uses: ColdTrick/.github/.github/workflows/phpunit.yml@master
with:
elgg_major_version: 6
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
The Wire Tools
==============

![Elgg 5.0](https://img.shields.io/badge/Elgg-5.0-green.svg)
![Elgg 6.0](https://img.shields.io/badge/Elgg-6.0-green.svg)
![Lint Checks](https://github.com/ColdTrick/thewire_tools/actions/workflows/lint.yml/badge.svg?event=push)
[![Latest Stable Version](https://poser.pugx.org/coldtrick/thewire_tools/v/stable.svg)](https://packagist.org/packages/coldtrick/thewire_tools)
[![License](https://poser.pugx.org/coldtrick/thewire_tools/license.svg)](https://packagist.org/packages/coldtrick/thewire_tools)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@
class GroupToolContainerLogicCheck extends ToolContainerLogicCheck {

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getContentType(): string {
return 'object';
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getContentSubtype(): string {
return 'thewire';
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function getToolName(): string {
return 'thewire';
Expand Down
6 changes: 1 addition & 5 deletions classes/ColdTrick/TheWireTools/Menus/OwnerBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,12 @@ public static function registerGroup(\Elgg\Event $event): ?MenuItems {
return null;
}

if (!$group->canEdit() && !$group->isMember()) {
return null;
}

/* @var $return MenuItems */
$return = $event->getValue();

$return[] = \ElggMenuItem::factory([
'name' => 'thewire',
'text' => elgg_echo('thewire_tools:group:title'),
'text' => elgg_echo('collection:object:thewire:group'),
'href' => elgg_generate_url('collection:object:thewire:group', [
'guid' => $group->guid,
]),
Expand Down
1 change: 0 additions & 1 deletion classes/ColdTrick/TheWireTools/Menus/Social.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ public static function registerReshare(\Elgg\Event $event): ?MenuItems {
'reshare_guid' => $reshare_guid,
]),
'link_class' => 'elgg-lightbox',
'is_trusted' => true,
'priority' => 500,
'data-colorbox-opts' => json_encode([
'scrolling' => false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class CreateTheWireEventHandler extends CoreTheWireEventHandler {
protected $reshare_entity;

/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected function getNotificationSubject(\ElggUser $recipient, string $method): string {
$shared_entity = $this->getReshareEntity();
Expand All @@ -42,7 +42,7 @@ protected function getNotificationSubject(\ElggUser $recipient, string $method):
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected function getNotificationSummary(\ElggUser $recipient, string $method): string {
$shared_entity = $this->getReshareEntity();
Expand All @@ -67,7 +67,7 @@ protected function getNotificationSummary(\ElggUser $recipient, string $method):
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected function getNotificationBody(\ElggUser $recipient, string $method): string {
$shared_entity = $this->getReshareEntity();
Expand Down Expand Up @@ -113,7 +113,7 @@ protected function getReshareEntity(): ?\ElggEntity {
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
protected static function isConfigurableForGroup(\ElggGroup $group): bool {
return $group->isToolEnabled('thewire');
Expand Down
11 changes: 5 additions & 6 deletions classes/ColdTrick/TheWireTools/Plugins/EntityTools/Migrate.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
class Migrate extends \ColdTrick\EntityTools\Migrate\TheWire {

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function canChangeContainer() {
public function canChangeContainer(): bool {
$page_owner_entity = elgg_get_page_owner_entity();
if ($page_owner_entity) {
// viewing a listing
Expand All @@ -31,10 +31,9 @@ public function canChangeContainer() {
}

/**
* {@inheritDoc}
* {@inheritdoc}
*/
public function changeContainer($new_container_guid) {

public function changeContainer($new_container_guid): void {
// do all the default stuff
parent::changeContainer($new_container_guid);

Expand All @@ -51,7 +50,7 @@ public function changeContainer($new_container_guid) {
*
* @return void
*/
protected function moveThreadItems($new_container_guid) {
protected function moveThreadItems(int $new_container_guid): void {
// ignore access for this part
elgg_call(ELGG_IGNORE_ACCESS, function() use ($new_container_guid) {
$object = $this->getObject();
Expand Down
8 changes: 6 additions & 2 deletions classes/ColdTrick/TheWireTools/Widgets.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ public static function widgetTitleURL(\Elgg\Event $event): ?string {

switch ($widget->handler) {
case 'thewire':
return elgg_generate_url('collection:object:thewire:owner', [
'username' => $widget->getOwnerEntity()->username,
$owner = $widget->getOwnerEntity();
if (!$owner instanceof \ElggGroup) {
return null;
}
return elgg_generate_url('collection:object:thewire:group', [
'guid' => $owner->guid,
]);

case 'index_thewire':
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
"issues": "https://github.com/ColdTrick/thewire_tools/issues"
},
"conflict": {
"elgg/elgg": "<5.0"
"elgg/elgg": "<6.0"
}
}
2 changes: 1 addition & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion elgg-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
],
],
'entity:url' => [
'object' => [
'object:widget' => [
'\ColdTrick\TheWireTools\Widgets::widgetTitleURL' => [],
],
],
Expand Down
2 changes: 1 addition & 1 deletion languages/en.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
%s",

// group wire
'thewire_tools:group:title' => "Group wire posts",
'collection:object:thewire:group' => "Group wire posts",
'groups:tool:thewire' => "Enable group wire posts",
'groups:tool:thewire:description' => "Allow group members to write wire posts in this group.",
'thewire_tools:groups:error:not_enabled' => "The wire has been disabled for this group",
Expand Down
2 changes: 1 addition & 1 deletion languages/fr.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

return array (
'thewire_tools:group:title' => 'Flux des partages du groupe',
'collection:object:thewire:group' => 'Flux des partages du groupe',
'groups:tool:thewire' => 'Activer le flux de partages du groupe',
'thewire_tools:groups:error:not_enabled' => 'Le flux de partages a été désactivé pour ce groupe',
'thewire_tools:reshare' => 'Partager dans le flux',
Expand Down
2 changes: 1 addition & 1 deletion languages/gd.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
Cuir freagairt ris:
%s',
'thewire_tools:group:title' => 'Postaichean-ùeire ann am buidhnean',
'collection:object:thewire:group' => 'Postaichean-ùeire ann am buidhnean',
'groups:tool:thewire' => 'Cuir an comas postaichean-ùeire ann am buidhnean',
'thewire_tools:groups:error:not_enabled' => 'Chaidh an ùeir a chur à comas anns a\' bhuidhinn seo',
'thewire_tools:add:container:site' => 'Postaich ris an làrach',
Expand Down
2 changes: 1 addition & 1 deletion languages/nl.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'thewire_tools:no_result' => 'Geen Wire berichten gevonden',
'thewire_tools:settings:enable_group' => 'Schakel The Wire in voor groepen',
'thewire_tools:settings:extend_widgets' => 'Breidt The Wire widget uit met de optie om direct een bericht te kunnen plaatsen',
'thewire_tools:group:title' => 'Groeps wire berichten',
'collection:object:thewire:group' => 'Groeps wire berichten',
'widgets:thewire_groups:name' => 'Groeps wire berichten',
'widgets:thewire_groups:description' => 'Toon The Wire berichten in de groep',
'widgets:index_thewire:name' => 'The Wire',
Expand Down
4 changes: 3 additions & 1 deletion views/default/forms/thewire/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* @uses $vars['post']
*/

elgg_require_css('forms/thewire/add');

$post = elgg_extract('post', $vars);
$char_limit = thewire_tools_get_wire_length();
$reshare = elgg_extract('reshare', $vars); // for reshare functionality
Expand All @@ -30,7 +32,7 @@
}

if ($char_limit && !elgg_is_active_plugin('ckeditor')) {
elgg_require_js('forms/thewire/add');
elgg_import_esm('forms/thewire/add');
}

$post_value = '';
Expand Down
13 changes: 13 additions & 0 deletions views/default/groups/profile/module/thewire.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
/**
* Group blog module
*/

$params = [
'entity_type' => 'object',
'entity_subtype' => 'thewire',
'no_results' => elgg_echo('thewire:noposts'),
'add_link' => false,
];
$params = $params + $vars;
echo elgg_view('groups/profile/module', $params);
2 changes: 0 additions & 2 deletions views/default/object/thewire.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
$more_link = elgg_view('output/url', [
'text' => elgg_echo('more'),
'href' => $entity->getURL(),
'is_trusted' => true,
'class' => 'mls',
]);
}
Expand All @@ -43,7 +42,6 @@
$more_link = elgg_view('output/url', [
'text' => elgg_echo('more'),
'href' => false,
'is_trusted' => true,
'class' => ['mls', 'elgg-toggle'],
'data-toggle-selector' => "#thewire-full-view-{$entity->guid}, #thewire-summary-view-{$entity->guid}",
]);
Expand Down
2 changes: 1 addition & 1 deletion views/default/resources/thewire/group.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
]);

// Display page
echo elgg_view_page(elgg_echo('thewire_tools:group:title'), [
echo elgg_view_page(elgg_echo('collection:object:thewire:group'), [
'content' => $content,
'sidebar' => elgg_view('thewire/sidebar'),
'filter_id' => 'thewire/group',
Expand Down
8 changes: 1 addition & 7 deletions views/default/river/object/thewire/create.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@
$excerpt .= '&nbsp;' . elgg_view('output/url', [
'text' => strtolower(elgg_echo('more')),
'href' => $object->getURL(),
'is_trusted' => true,
]);
}

$subject = $item->getSubjectEntity();
$subject_link = elgg_view('output/url', [
'href' => $subject->getURL(),
'text' => $subject->getDisplayName(),
'class' => 'elgg-river-subject',
'is_trusted' => true,
]);
$subject_link = elgg_view_entity_url($subject, ['class' => 'elgg-river-subject']);

$object_link = elgg_view('output/url', [
'href' => elgg_generate_url('collection:object:thewire:thread', [
Expand Down
21 changes: 0 additions & 21 deletions views/default/thewire_tools/ReplyLoader.js

This file was deleted.

22 changes: 22 additions & 0 deletions views/default/thewire_tools/ReplyLoader.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import 'jquery';
import Ajax from 'elgg/Ajax';

$(document).on('click', '.elgg-menu-item-reply a[data-thewire-reply]:not(.elgg-toggle)', function(event) {
event.preventDefault();

var guid = $(this).data('thewireReply');
var $menu_item = $(this);

var ajax = new Ajax();
ajax.view('thewire_tools/reply_loader', {
data: {
guid: guid
},
success: function(data) {
$('#thewire-tools-reply-' + guid).replaceWith(data);
$menu_item.addClass('elgg-toggle');
}
});

return false;
});
20 changes: 0 additions & 20 deletions views/default/thewire_tools/ReshareBadge.js

This file was deleted.

18 changes: 18 additions & 0 deletions views/default/thewire_tools/ReshareBadge.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'jquery';
import lightbox from 'elgg/lightbox';

$(document).on('click', '.elgg-menu-item-thewire-tools-reshare > a > .elgg-badge', function(event) {
var data = $(this).closest('a').data();
if (!data || !data.badgeLink) {
return true;
}

event.preventDefault();

lightbox.open({
href: data.badgeLink,
maxHeigth: '85%'
});

return false;
});
Loading

0 comments on commit 4b5f69a

Please sign in to comment.