Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.17] Fix module ID #345

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/marketplace-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ jobs:
uses: humhub/actions/.github/workflows/module-marketplace-upload.yml@main
with:
install-composer: true
module-id: custom_pages
module-id: custom-pages
secrets: inherit
4 changes: 2 additions & 2 deletions .github/workflows/php-test-develop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ jobs:
tests:
uses: humhub/actions/.github/workflows/module-tests-develop.yml@main
with:
module-id: custom_pages
install-composer: true
module-id: custom-pages
install-composer: true
2 changes: 1 addition & 1 deletion .github/workflows/php-test-master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ jobs:
tests:
uses: humhub/actions/.github/workflows/module-tests-master.yml@main
with:
module-id: custom_pages
module-id: custom-pages
install-composer: true
26 changes: 13 additions & 13 deletions .github/workflows/php-test-next.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: PHP Codeception Tests - next
on:
push:
schedule:
- cron: "0 0 * * 0"
jobs:
tests:
uses: humhub/actions/.github/workflows/module-tests-next.yml@main
with:
module-id: custom_pages
install-composer: true
name: PHP Codeception Tests - next

on:
push:
schedule:
- cron: "0 0 * * 0"

jobs:
tests:
uses: humhub/actions/.github/workflows/module-tests-next.yml@main
with:
module-id: custom-pages
install-composer: true
44 changes: 22 additions & 22 deletions Events.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,16 @@ public static function onBeforeRequest()
*/
public static function registerAutoloader()
{
Yii::setAlias('@vendor/tinymce/tinymce', '@custom_pages/vendor/tinymce/tinymce');
Yii::setAlias('@vendor/2amigos/yii2-tinymce-widget/src/assets', '@custom_pages/vendor/2amigos/yii2-tinymce-widget/src/assets');
Yii::setAlias('@vendor/tinymce/tinymce', '@custom-pages/vendor/tinymce/tinymce');
Yii::setAlias('@vendor/2amigos/yii2-tinymce-widget/src/assets', '@custom-pages/vendor/2amigos/yii2-tinymce-widget/src/assets');

require Yii::getAlias('@custom_pages/vendor/autoload.php');
require Yii::getAlias('@custom-pages/vendor/autoload.php');
}

public static function onAdminMenuInit($event)
{
try {
Yii::$app->moduleManager->getModule('custom_pages')->checkOldGlobalContent();
Yii::$app->moduleManager->getModule('custom-pages')->checkOldGlobalContent();

if (!Yii::$app->user->can([ManageModules::class, ManagePages::class])) {
return;
Expand All @@ -64,7 +64,7 @@ public static function onAdminMenuInit($event)
'group' => 'manage',
'icon' => '<i class="fa fa-file-text-o"></i>',
'isActive' => (Yii::$app->controller->module
&& (Yii::$app->controller->module->id === 'custom_pages'
&& (Yii::$app->controller->module->id === 'custom-pages'
&& (Yii::$app->controller->id === 'page' || Yii::$app->controller->id === 'config'))
|| Yii::$app->controller->module->id == 'template'),
'sortOrder' => 300,
Expand All @@ -78,11 +78,11 @@ public static function onAdminMenuInit($event)
public static function onSpaceMenuInit($event)
{
try {
Yii::$app->moduleManager->getModule('custom_pages')->checkOldGlobalContent();
Yii::$app->moduleManager->getModule('custom-pages')->checkOldGlobalContent();

/* @var $space \humhub\modules\space\models\Space */
$space = $event->sender->space;
if ($space->moduleManager->isEnabled('custom_pages')) {
if ($space->moduleManager->isEnabled('custom-pages')) {
/* @var Page[] $pages */
$pages = ContainerPage::find()
->contentContainer($space)
Expand All @@ -104,7 +104,7 @@ public static function onSpaceMenuInit($event)
'url' => $page->getUrl(),
'icon' => '<i class="fa ' . Html::encode($page->icon) . '"></i>',
'isActive' => (Yii::$app->controller->module
&& Yii::$app->controller->module->id === 'custom_pages'
&& Yii::$app->controller->module->id === 'custom-pages'
&& Yii::$app->controller->id === 'view'
&& Yii::$app->controller->action->id === 'index' && Yii::$app->request->get('id') == $page->id),
'sortOrder' => ($page->sort_order != '') ? $page->sort_order : 1000,
Expand All @@ -119,18 +119,18 @@ public static function onSpaceMenuInit($event)
public static function onSpaceAdminMenuInit($event)
{
try {
Yii::$app->moduleManager->getModule('custom_pages')->checkOldGlobalContent();
Yii::$app->moduleManager->getModule('custom-pages')->checkOldGlobalContent();

/* @var $space \humhub\modules\space\models\Space */
$space = $event->sender->space;
if ($space->moduleManager->isEnabled('custom_pages') && $space->isAdmin() && $space->isMember()) {
if ($space->moduleManager->isEnabled('custom-pages') && $space->isAdmin() && $space->isMember()) {
$event->sender->addItem([
'label' => Yii::t('CustomPagesModule.base', 'Custom Pages'),
'group' => 'admin',
'url' => Url::toPageOverview($space),
'icon' => '<i class="fa fa-file-text-o"></i>',
'isActive' => (Yii::$app->controller->module
&& Yii::$app->controller->module->id === 'custom_pages'
&& Yii::$app->controller->module->id === 'custom-pages'
&& Yii::$app->controller->id === 'container'
&& Yii::$app->controller->action->id !== 'view'),
]);
Expand All @@ -146,7 +146,7 @@ public static function onTopMenuInit($event)
$menu = $event->sender;

try {
Yii::$app->moduleManager->getModule('custom_pages')->checkOldGlobalContent();
Yii::$app->moduleManager->getModule('custom-pages')->checkOldGlobalContent();

foreach (self::findPagesByTarget(Page::NAV_CLASS_TOPNAV) as $page) {
if (!$page->canView()) {
Expand All @@ -156,12 +156,12 @@ public static function onTopMenuInit($event)
$menu->addEntry(new MenuLink([
'id' => 'custom-page-' . $page->id,
'label' => Html::encode(Yii::t('CustomPagesModule.base', $page->title)),
'url' => ['/custom_pages/view', 'id' => $page->id],
'url' => ['/custom-pages/view', 'id' => $page->id],
'htmlOptions' => ['target' => ($page->in_new_window) ? '_blank' : ''],
'icon' => $page->icon,
'isActive' => (
(
MenuLink::isActiveState('custom_pages', 'view')
MenuLink::isActiveState('custom-pages', 'view')
&& !Yii::$app->controller->contentContainer
&& (int)Yii::$app->request->get('id') === $page->id
)
Expand Down Expand Up @@ -203,7 +203,7 @@ private static function isCurrentTargetUrl(Page $page): bool
public static function onAccountMenuInit($event)
{
try {
Yii::$app->moduleManager->getModule('custom_pages')->checkOldGlobalContent();
Yii::$app->moduleManager->getModule('custom-pages')->checkOldGlobalContent();

foreach (self::findPagesByTarget(Page::NAV_CLASS_ACCOUNTNAV) as $page) {
if (!$page->canView()) {
Expand All @@ -212,11 +212,11 @@ public static function onAccountMenuInit($event)

$event->sender->addItem([
'label' => Html::encode(Yii::t('CustomPagesModule.base', $page->title)),
'url' => Url::to(['/custom_pages/view', 'id' => $page->id]),
'url' => Url::to(['/custom-pages/view', 'id' => $page->id]),
'htmlOptions' => ['target' => ($page->in_new_window) ? '_blank' : ''],
'icon' => '<i class="fa ' . Html::encode($page->icon) . '"></i>',
'isActive' => (Yii::$app->controller->module
&& Yii::$app->controller->module->id === 'custom_pages'
&& Yii::$app->controller->module->id === 'custom-pages'
&& Yii::$app->controller->id === 'view' && Yii::$app->request->get('id') == $page->id),
'sortOrder' => ($page->sort_order != '') ? $page->sort_order : 1000,
]);
Expand All @@ -239,7 +239,7 @@ public static function onAccountTopMenuInit($event)
public static function onDashboardSidebarInit($event)
{
try {
Yii::$app->moduleManager->getModule('custom_pages')->checkOldGlobalContent();
Yii::$app->moduleManager->getModule('custom-pages')->checkOldGlobalContent();

/* @var Snippet[] $snippets */
$snippets = Snippet::find()->where(['target' => Snippet::SIDEBAR_DASHBOARD])->readable()->all();
Expand All @@ -258,11 +258,11 @@ public static function onDashboardSidebarInit($event)
public static function onSpaceSidebarInit($event)
{
try {
Yii::$app->moduleManager->getModule('custom_pages')->checkOldGlobalContent();
Yii::$app->moduleManager->getModule('custom-pages')->checkOldGlobalContent();

$space = $event->sender->space;
$canEdit = PagePermission::canEdit();
if ($space->moduleManager->isEnabled('custom_pages')) {
if ($space->moduleManager->isEnabled('custom-pages')) {
/* @var Snippet[] $snippets */
$snippets = ContainerSnippet::find()->contentContainer($space)->readable()->all();
foreach ($snippets as $snippet) {
Expand All @@ -288,7 +288,7 @@ public static function onFooterMenuInit($event)

$event->sender->addItem([
'label' => Html::encode(Yii::t('CustomPagesModule.base', $page->title)),
'url' => Url::to(['/custom_pages/view', 'id' => $page->id], true),
'url' => Url::to(['/custom-pages/view', 'id' => $page->id], true),
'htmlOptions' => ['target' => ($page->in_new_window) ? '_blank' : ''],
'sortOrder' => ($page->sort_order != '') ? $page->sort_order : 1000,
]);
Expand All @@ -310,7 +310,7 @@ public static function onPeopleHeadingButtonsInit($event)

$peopleHeadingButtons->addEntry(new MenuLink([
'label' => Html::encode(Yii::t('CustomPagesModule.base', $page->title)),
'url' => Url::to(['/custom_pages/view', 'id' => $page->id]),
'url' => Url::to(['/custom-pages/view', 'id' => $page->id]),
'htmlOptions' => ['target' => ($page->in_new_window) ? '_blank' : ''],
'sortOrder' => ($page->sort_order != '') ? $page->sort_order : 1000,
'icon' => $page->icon,
Expand Down
2 changes: 1 addition & 1 deletion assets/Assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Assets extends AssetBundle
*/
public $defer = true;

public $sourcePath = '@custom_pages/resources';
public $sourcePath = '@custom-pages/resources';

public $publishOptions = [
'forceCopy' => false,
Expand Down
2 changes: 1 addition & 1 deletion assets/InlineStyleAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class InlineStyleAssets extends AssetBundle
/**
* @inheritdoc
*/
public $sourcePath = '@custom_pages/resources';
public $sourcePath = '@custom-pages/resources';

/**
* @inheritdoc
Expand Down
4 changes: 2 additions & 2 deletions assets/TinyMcePluginsAssets.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ class TinyMcePluginsAssets extends AssetBundle
/**
* @inheritdoc
*/
public $sourcePath = '@custom_pages/resources/tinymce/plugins';
}
public $sourcePath = '@custom-pages/resources/tinymce/plugins';
}
2 changes: 1 addition & 1 deletion components/PageUrlRule.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class PageUrlRule extends Component implements UrlRuleInterface
/**
* @var string default route to page home
*/
public $defaultRoutes = ['custom_pages/view', 'custom_pages/view/view'];
public $defaultRoutes = ['custom-pages/view', 'custom-pages/view/view'];

/**
* @var array map with space guid/url pairs
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "humhub/custom_pages",
"name": "humhub/custom-pages",
"description": "Custom Pages",
"type": "library",
"require": {
Expand Down
4 changes: 2 additions & 2 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use humhub\widgets\TopMenu;

return [
'id' => 'custom_pages',
'id' => 'custom-pages',
'class' => 'humhub\modules\custom_pages\Module',
'modules' => [
'template' => [
Expand All @@ -40,4 +40,4 @@
['class' => DashboardSidebar::class, 'event' => BaseMenu::EVENT_INIT, 'callback' => [Events::class, 'onDashboardSidebarInit']],
['class' => SpaceSidebar::class, 'event' => BaseMenu::EVENT_INIT, 'callback' => [Events::class, 'onSpaceSidebarInit']],
],
];
];
2 changes: 1 addition & 1 deletion controllers/AbstractCustomContainerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ abstract class AbstractCustomContainerController extends ContentContainerControl

public function init()
{
Yii::$app->moduleManager->getModule('custom_pages')->checkOldGlobalContent();
Yii::$app->moduleManager->getModule('custom-pages')->checkOldGlobalContent();
parent::init();
}

Expand Down
6 changes: 3 additions & 3 deletions controllers/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public function actionIndex()
*/
public function actionOverview()
{
return $this->render('@custom_pages/views/common/list', [
return $this->render('@custom-pages/views/common/list', [
'targets' => $this->customPagesService->getTargets($this->getPageType(), $this->contentContainer),
'pageType' => $this->getPageType(),
'subNav' => $this->getSubNav()
Expand Down Expand Up @@ -144,7 +144,7 @@ public function actionAdd($targetId, $type = null)
return $this->redirect(Url::toCreatePage($targetId, $this->getPageType(), $type, $this->contentContainer));
}

return $this->render('@custom_pages/views/common/add', [
return $this->render('@custom-pages/views/common/add', [
'model' => $model,
'target' => $target,
'pageType' => $this->getPageType(),
Expand Down Expand Up @@ -196,7 +196,7 @@ public function actionEdit($targetId = null, $type = null, $id = null)
// if its visibility is not allowed for its page type:
$page->fixVisibility();

return $this->render('@custom_pages/views/common/edit', [
return $this->render('@custom-pages/views/common/edit', [
'page' => $page,
'pageType' => $this->getPageType(),
'subNav' => $this->getSubNav()
Expand Down
4 changes: 2 additions & 2 deletions controllers/SnippetController.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ public function actionEditSnippet($id)
}

$view = $this->contentContainer
? '@custom_pages/views/container/edit_snippet'
: '@custom_pages/views/global/edit_snippet';
? '@custom-pages/views/container/edit_snippet'
: '@custom-pages/views/global/edit_snippet';

return $this->render($view, [
'snippet' => $snippet,
Expand Down
20 changes: 10 additions & 10 deletions controllers/ViewController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function actionIndex()
? $page->getTargetModel()->getSubLayout()
: $this->subLayout;

$this->view->pageTitle = Html::encode($page->title);
$this->view->setPageTitle(Html::encode($page->title));

if(!$page->getTargetModel()->isAllowedContentType($page->type)) {
throw new HttpException(404);
Expand Down Expand Up @@ -88,15 +88,15 @@ public function renderContainerView($page)
{
switch ($page->type) {
case IframeType::ID:
return $this->render('@custom_pages/views/container/iframe', ['page' => $page, 'url' => $page->page_content]);
return $this->render('@custom-pages/views/container/iframe', ['page' => $page, 'url' => $page->page_content]);
case TemplateType::ID:
return $this->viewTemplatePage($page, '@custom_pages/views/container/template');
return $this->viewTemplatePage($page, '@custom-pages/views/container/template');
case LinkType::ID:
return $this->redirect($page->page_content);
case MarkdownType::ID:
return $this->render('@custom_pages/views/container/markdown', ['page' => $page, 'md' => $page->page_content]);
return $this->render('@custom-pages/views/container/markdown', ['page' => $page, 'md' => $page->page_content]);
case PhpType::ID:
return $this->render('@custom_pages/views/container/php', ['page' => $page, 'contentContainer' => $this->contentContainer]);
return $this->render('@custom-pages/views/container/php', ['page' => $page, 'contentContainer' => $this->contentContainer]);
default:
throw new HttpException('500', 'Invalid page type!');
}
Expand All @@ -111,22 +111,22 @@ public function renderGlobalView($page)
{
switch ($page->type) {
case HtmlType::ID:
return $this->render('@custom_pages/views/global/html', ['page' => $page, 'html' => $page->getPageContent(), 'title' => $page->title]);
return $this->render('@custom-pages/views/global/html', ['page' => $page, 'html' => $page->getPageContent(), 'title' => $page->title]);
case IframeType::ID:
return $this->render('@custom_pages/views/global/iframe', ['page' => $page, 'url' => $page->page_content, 'navigationClass' => $page->getTargetId()]);
return $this->render('@custom-pages/views/global/iframe', ['page' => $page, 'url' => $page->page_content, 'navigationClass' => $page->getTargetId()]);
case TemplateType::ID:
return $this->viewTemplatePage($page, '@custom_pages/views/global/template');
return $this->viewTemplatePage($page, '@custom-pages/views/global/template');
case LinkType::ID:
return $this->redirect($page->page_content);
case MarkdownType::ID:
return $this->render('@custom_pages/views/global/markdown', [
return $this->render('@custom-pages/views/global/markdown', [
'page' => $page,
'md' => $page->page_content,
'navigationClass' => $page->getTargetId(),
'title' => $page->title
]);
case PhpType::ID:
return $this->render('@custom_pages/views/global/php', ['page' => $page]);
return $this->render('@custom-pages/views/global/php', ['page' => $page]);
default:
throw new HttpException('500', 'Invalid page type!');
}
Expand Down
4 changes: 4 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
Changelog
=========

1.11.0 (Unreleased)
----------------------------
- Fix #345: Fix module ID

1.10.8 (September 24, 2024)
---------------------------
- Fix #347: Fix errors after save a new page
Expand Down
Loading
Loading