Skip to content

Commit

Permalink
changed: updated for Elgg 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jdalsem committed Oct 26, 2023
1 parent a81f521 commit 5de4b57
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 53 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Entity Tools
============

![Elgg 5.0](https://img.shields.io/badge/Elgg-5.0-green.svg)
![Elgg 5.1](https://img.shields.io/badge/Elgg-5.1-green.svg)
![Lint Checks](https://github.com/ColdTrick/entity_tools/actions/workflows/lint.yml/badge.svg?event=push)
[![Latest Stable Version](https://poser.pugx.org/coldtrick/entity_tools/v/stable.svg)](https://packagist.org/packages/coldtrick/entity_tools)
[![License](https://poser.pugx.org/coldtrick/entity_tools/license.svg)](https://packagist.org/packages/coldtrick/entity_tools)
Expand All @@ -12,9 +12,9 @@ Features
--------
- support for:
- Blogs
- Discussions
- Pages
- File
- Questions
- TheWire
- backdate entities
- change owner
- change container (from/to personal/group)
2 changes: 1 addition & 1 deletion classes/ColdTrick/EntityTools/Menus/AdminHeader.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function register(\Elgg\Event $event): ?MenuItems {
'name' => 'entity_tools',
'href' => elgg_generate_url('entity_tools:site'),
'text' => elgg_echo('entity_tools:menu:admin'),
'parent_name' => 'administer_utilities',
'parent_name' => 'utilities',
]);

return $return;
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"npm-asset/jquery-datetimepicker": "~2.5.21"
},
"conflict": {
"elgg/elgg": "<5.0"
"elgg/elgg": "<5.1"
},
"config": {
"fxp-asset": {
Expand Down
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: 2 additions & 0 deletions elgg-plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
'resource' => 'entity_tools/owner',
'middleware' => [
Gatekeeper::class,
\Elgg\Router\Middleware\UserPageOwnerGatekeeper::class,
],
'detect_page_owner' => true,
],
Expand All @@ -40,6 +41,7 @@
'resource' => 'entity_tools/group',
'middleware' => [
Gatekeeper::class,
\Elgg\Router\Middleware\GroupPageOwnerGatekeeper::class,
],
'detect_page_owner' => true,
],
Expand Down
20 changes: 2 additions & 18 deletions views/default/resources/entity_tools/group.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
<?php

use Elgg\Exceptions\Http\EntityNotFoundException;
use Elgg\Exceptions\Http\GatekeeperException;

$page_owner = elgg_get_page_owner_entity();
if (!$page_owner instanceof ElggGroup) {
throw new EntityNotFoundException();
}

// get supported types
$supported_types = array_keys(entity_tools_get_supported_entity_types());

$subtype = elgg_extract('subtype', $vars);
if (empty($subtype)) {
$subtype = $supported_types[0];
}

$subtype = elgg_extract('subtype', $vars, $supported_types[0], false);
if (!in_array($subtype, $supported_types)) {
throw new GatekeeperException(elgg_echo('entity_tools:error:unsupported_subtype', [$subtype]));
}

// breadcrumb
elgg_push_breadcrumb($page_owner->getDisplayName(), $page_owner->getURL());
elgg_push_breadcrumb(elgg_echo('entity_tools:menu:owner_block:group'), elgg_generate_url('entity_tools:group', [
'guid' => $page_owner->guid
]));
elgg_push_breadcrumb(elgg_echo("collection:object:{$subtype}"), false);
elgg_push_entity_breadcrumbs($page_owner);

// page components
$title_text = elgg_echo('entity_tools:page:group:title', [
elgg_echo("collection:object:{$subtype}"),
$page_owner->getDisplayName(),
Expand All @@ -38,7 +23,6 @@
'container_guid' => $page_owner->guid,
]);

// show page
echo elgg_view_page($title_text, [
'content' => $content,
'filter_id' => 'entity_tools',
Expand Down
20 changes: 2 additions & 18 deletions views/default/resources/entity_tools/owner.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,18 @@
<?php

use Elgg\Exceptions\Http\EntityNotFoundException;
use Elgg\Exceptions\Http\GatekeeperException;

$page_owner = elgg_get_page_owner_entity();
if (!$page_owner instanceof ElggUser) {
throw new EntityNotFoundException();
}

// get supported types
$supported_types = array_keys(entity_tools_get_supported_entity_types());

$subtype = elgg_extract('subtype', $vars);
if (empty($subtype)) {
$subtype = $supported_types[0];
}

$subtype = elgg_extract('subtype', $vars, $supported_types[0], false);
if (!in_array($subtype, $supported_types)) {
throw new GatekeeperException(elgg_echo('entity_tools:error:unsupported_subtype', [$subtype]));
}

// breadcrumb
elgg_push_breadcrumb($page_owner->getDisplayName(), $page_owner->getURL());
elgg_push_breadcrumb(elgg_echo('entity_tools:menu:owner_block'), elgg_generate_url('entity_tools:owner', [
'username' => $page_owner->username
]));
elgg_push_breadcrumb(elgg_echo("collection:object:{$subtype}"), false);
elgg_push_entity_breadcrumbs($page_owner);

// page components
$title_text = elgg_echo('entity_tools:page:owner:title', [
$page_owner->getDisplayName(),
elgg_echo("collection:object:{$subtype}"),
Expand All @@ -38,7 +23,6 @@
'owner_guid' => $page_owner->guid,
]);

// show page
echo elgg_view_page($title_text, [
'content' => $content,
'filter_id' => 'entity_tools',
Expand Down
12 changes: 1 addition & 11 deletions views/default/resources/entity_tools/site.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@

use Elgg\Exceptions\Http\GatekeeperException;

// get supported types
$supported_types = array_keys(entity_tools_get_supported_entity_types());

$subtype = elgg_extract('subtype', $vars);
if (empty($subtype)) {
$subtype = $supported_types[0];
}

$subtype = elgg_extract('subtype', $vars, $supported_types[0], false);
if (!in_array($subtype, $supported_types)) {
throw new GatekeeperException(elgg_echo('entity_tools:error:unsupported_subtype', [$subtype]));
}

// breadcrumb
elgg_push_breadcrumb(elgg_echo("collection:object:{$subtype}"), false);

// page components
$title_text = elgg_echo('entity_tools:page:owner:title', [
elgg_get_site_entity()->getDisplayName(),
elgg_echo("collection:object:{$subtype}"),
Expand All @@ -28,7 +19,6 @@
'owner_guid' => elgg_get_site_entity()->guid,
]);

// show page
echo elgg_view_page($title_text, [
'content' => $content,
'filter_id' => 'entity_tools',
Expand Down

0 comments on commit 5de4b57

Please sign in to comment.