-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: organized menu callbacks in seperated files
fixes #130
- Loading branch information
Showing
4 changed files
with
98 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
<?php | ||
|
||
namespace ColdTrick\WidgetManager\Menus; | ||
|
||
use Elgg\Menu\MenuItems; | ||
|
||
/** | ||
* Entity menu callbacks | ||
*/ | ||
class Entity { | ||
|
||
/** | ||
* Adds an optional fix link to the menu | ||
* | ||
* @param \Elgg\Event $event 'register', 'menu:entity' | ||
* | ||
* @return null|MenuItems | ||
*/ | ||
public static function addWidgetPageEntityMenuItems(\Elgg\Event $event): ?MenuItems { | ||
$entity = $event->getEntityParam(); | ||
if (!$entity instanceof \WidgetPage || !$entity->canEdit()) { | ||
return null; | ||
} | ||
|
||
$result = $event->getValue(); | ||
|
||
$result[] = \ElggMenuItem::factory([ | ||
'name' => 'edit', | ||
'text' => elgg_echo('edit'), | ||
'icon' => 'edit', | ||
'href' => "ajax/form/widget_manager/widget_page?guid={$entity->guid}", | ||
'link_class' => 'elgg-lightbox', | ||
'data-colorbox-opts' => json_encode([ | ||
'trapFocus' => false, | ||
]), | ||
]); | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace ColdTrick\WidgetManager\Menus; | ||
|
||
use Elgg\Menu\MenuItems; | ||
|
||
/** | ||
* Title entity menu callbacks | ||
*/ | ||
class Title { | ||
|
||
/** | ||
* Adds a toggle to show/hide widget contents | ||
* | ||
* @param \Elgg\Event $event 'register', 'menu:title:widgets' | ||
* | ||
* @return null|MenuItems | ||
*/ | ||
public static function addWidgetsContentToggle(\Elgg\Event $event): ?MenuItems { | ||
|
||
if (!elgg_get_plugin_setting('show_collapse_content', 'widget_manager')) { | ||
return null; | ||
} | ||
|
||
if (!$event->getParam('show_collapse_content', false)) { | ||
return null; | ||
} | ||
|
||
$result = $event->getValue(); | ||
|
||
$result[] = \ElggMenuItem::factory([ | ||
'name' => 'hide-widget-contents', | ||
'class' => 'elgg-more', | ||
'text' => elgg_echo('widget_manager:layout:content:hide'), | ||
'icon' => 'eye-slash', | ||
'href' => false, | ||
'priority' => 80, | ||
]); | ||
|
||
$result[] = \ElggMenuItem::factory([ | ||
'name' => 'show-widget-contents', | ||
'class' => 'elgg-more', | ||
'item_class' => 'hidden', | ||
'text' => elgg_echo('widget_manager:layout:content:show'), | ||
'icon' => 'eye', | ||
'href' => false, | ||
'priority' => 81, | ||
]); | ||
|
||
return $result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters