Skip to content

Commit

Permalink
Merge pull request #336 from humhub/enh/159-rename-global-space-page-…
Browse files Browse the repository at this point in the history
…snippet

Renaming page and snippet to global and space types
  • Loading branch information
luke- committed Jul 15, 2024
2 parents 2c8da6a + 47d0518 commit f906cde
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 20 deletions.
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.10.5 (Unreleased)
----------------------
- Enh #336: Renaming page and snippet to global and space types

1.10.4 (June 19, 2024)
----------------------
- Fix #328: Missing Iframe attributes in snippet
Expand Down
4 changes: 3 additions & 1 deletion models/CustomContentContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ public function getContentName()
return $target->contentName;
}

return PageType::getContentName($this->getPageType());
$containerClass = $this instanceof ContainerPage || $this instanceof ContainerSnippet ? Space::class : null;

return PageType::getContentName($this->getPageType(), $containerClass);
}

private function getRulesByContentType()
Expand Down
30 changes: 12 additions & 18 deletions models/PageType.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
<?php


namespace humhub\modules\custom_pages\models;


use humhub\modules\content\components\ContentContainerActiveRecord;
use humhub\modules\space\models\Space;
use Yii;

abstract class PageType
{
const Page = 'page';
const Snippet = 'snippet';

public static function getLabel($type)
{
switch ($type) {
case static::Page:
return Yii::t('CustomPagesModule.models_Page', 'page');
case static::Snippet:
return Yii::t('CustomPagesModule.models_ContainerSnippet', 'snippet');
}
}
public const Page = 'page';
public const Snippet = 'snippet';

public static function getContentName($type)
public static function getContentName($type, ?string $containerClass = null)
{
switch ($type) {
case static::Page:
return Yii::t('CustomPagesModule.models_Page', 'Page');
return $containerClass === Space::class
? Yii::t('CustomPagesModule.base', 'Space Page')
: Yii::t('CustomPagesModule.base', 'Global Page');
case static::Snippet:
return Yii::t('CustomPagesModule.models_ContainerSnippet', 'Snippet');
return $containerClass === Space::class
? Yii::t('CustomPagesModule.base', 'Space Widget')
: Yii::t('CustomPagesModule.base', 'Global Widget');
}
}
}
}
2 changes: 1 addition & 1 deletion module.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Custom Pages",
"description": "Create custom pages and widgets and share them with your users. Take advantage of a wide range of editing options, including HTML and Markdown.",
"keywords": ["pages", "custom", "iframe", "markdown", "link", "navigation", "spaces"],
"version": "1.10.4",
"version": "1.10.5",
"homepage": "https://github.com/humhub/custom-pages",
"humhub": {
"minVersion": "1.14"
Expand Down

0 comments on commit f906cde

Please sign in to comment.