Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
674992a
#1 cleaned up the branch and implmented numbering to overview and con…
vidhyasagargm Sep 12, 2024
90d7840
Update widgets/PageListItemTitle.php
vidhyasagargm Sep 18, 2024
e591a41
Delete widgets/.WikiRichText.php.swp
vidhyasagargm Sep 18, 2024
59ee21d
added unit testing for numbering logic
vidhyasagargm Sep 18, 2024
b1e21c5
Merge branch '1-content-overview-title-numbering' of https://github.c…
vidhyasagargm Sep 18, 2024
0dc8f5d
Revert "Merge branch '1-content-overview-title-numbering' of https://…
vidhyasagargm Sep 18, 2024
3d1df8b
#1 Toggle button for numbering pagelist with unit testing
vidhyasagargm Sep 18, 2024
b1c56d5
#1 Fixed double numbering in content and added a button
vidhyasagargm Sep 20, 2024
7dd22b1
#1 Fixed double numbering in content and added a button
vidhyasagargm Sep 20, 2024
531d360
Delete widgets/.WikiRichText.php.swp
vidhyasagargm Sep 20, 2024
c9e2ba4
#1 Implemented German Language for button content
vidhyasagargm Sep 25, 2024
ffeb277
Update _view_body.php
vidhyasagargm Sep 25, 2024
f886205
Update _view_content.php
vidhyasagargm Sep 25, 2024
855c04c
Update _view_content.php
vidhyasagargm Sep 25, 2024
e1979a5
#1 toggle for numbering fixed appearance on edit page
vidhyasagargm Oct 1, 2024
6d93c5e
Update _view_body.php
vidhyasagargm Oct 1, 2024
f17a7ad
Restore menu.php
vidhyasagargm Oct 1, 2024
add39f1
Update widgets/PageListItemTitle.php
vidhyasagargm Oct 2, 2024
b14519e
Update widgets/PageListItemTitle.php
vidhyasagargm Oct 2, 2024
6dc658c
#1 Added CSS styling to css file and changed naming convention
vidhyasagargm Oct 4, 2024
1a67e0f
#1 changed the test case with html render
vidhyasagargm Oct 4, 2024
b9492e5
#1 implemented preserve settings
vidhyasagargm Oct 9, 2024
733b08d
#1 Matched numbering with TOC
vidhyasagargm Oct 17, 2024
fbe27ec
#1 used grunt build to generate min and less files
vidhyasagargm Oct 21, 2024
3f11786
#1 changed all the test files added a functional testing
vidhyasagargm Oct 21, 2024
9c1fb5e
#1 Added Numbering Setting Checkmark in wiki/config
vidhyasagargm Oct 22, 2024
5f5ea4a
Update DefaultSettings.php
vidhyasagargm Oct 22, 2024
c45de85
Update PageController.php
vidhyasagargm Oct 22, 2024
8ae5bfd
Update ConfigForm.php
vidhyasagargm Oct 22, 2024
7d652ad
Update messages/de/base.php
vidhyasagargm Oct 24, 2024
d788aff
Update resources/css/humhub.wiki.less
vidhyasagargm Oct 24, 2024
9ec7b1a
Update resources/css/humhub.wiki.css
vidhyasagargm Oct 24, 2024
6e8442b
Update resources/js/humhub.wiki.Page.js
vidhyasagargm Oct 24, 2024
ef94b75
Update resources/js/humhub.wiki.bundle.js
vidhyasagargm Oct 24, 2024
1b4162d
Update resources/js/humhub.wiki.Page.js
vidhyasagargm Oct 24, 2024
96d04a3
#1 updated code to show numbering on wiki/config
vidhyasagargm Oct 24, 2024
0cc7113
#1 removed min file
vidhyasagargm Oct 24, 2024
bec369f
#1 Added translation to the config page
vidhyasagargm Nov 1, 2024
b22ead0
#1 Changed button content of config form
vidhyasagargm Nov 6, 2024
c70fbad
#1 Added partial reload after sorting and removed unwanted comment
vidhyasagargm Nov 8, 2024
f7deb4c
#1 added condition for partial reload
vidhyasagargm Nov 11, 2024
6f561a4
#1 removed numbering button, created a new test file
vidhyasagargm Dec 4, 2024
785e08f
#1 Numbering on path and title
vidhyasagargm Dec 10, 2024
68661bd
Deleted unwanted test file
vidhyasagargm Dec 10, 2024
d8d8820
#1 NUmbering toggle for title and path
vidhyasagargm Dec 11, 2024
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
10 changes: 10 additions & 0 deletions Module.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,16 @@ public function getHideNavigationEntryDefault(): bool
return $this->settings->get('hideNavigationEntryDefault', false);
}

public function getWikiNumberingEnabledDefault(): bool
{
return $this->settings->get('wikiNumberingEnabledDefault', false);
}

public function getOverviewNumberingEnabledDefault(): bool
{
return $this->settings->get('overviewNumberingEnabledDefault', false);
}

public function getContentHiddenDefault(ContentContainerActiveRecord $contentContainer): bool
{
return (new DefaultSettings(['contentContainer' => $contentContainer]))->contentHiddenDefault;
Expand Down
6 changes: 6 additions & 0 deletions messages/de/base.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,4 +86,10 @@
'Hide Navigation Entries of this module globally by default' => '',
'Hide Navigation Entry' => '',
'No wiki pages found.' => '',
'Enable Numbering' => 'Nummerierung aktivieren',
'Disable Numbering' => 'Nummerierung deaktivieren',
'Enable Default wiki page numbering for current spaces' => 'Standard-Wikiseitennummerierung für aktuelle Bereiche aktivieren',
'Enable Default overview numbering for current spaces' => 'Standard-übersichtsnummerierung für aktuelle Bereiche aktivieren',
'Enable wiki page header numbering for all spaces by default' => 'Nummerierung der Überschriften standardmäßig für alle Bereiche aktivieren',
'Enable overview numbering for all spaces by default' => 'Nummerierung der Seitentitel für alle Bereiche standardmäßig aktivieren',
];
12 changes: 11 additions & 1 deletion models/ConfigForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ class ConfigForm extends Model

public bool $hideNavigationEntryDefault = false;

public bool $wikiNumberingEnabledDefault = false;

public bool $overviewNumberingEnabledDefault = false;

/**
* @inheritdoc
*/
Expand All @@ -25,6 +29,8 @@ public function init()
parent::init();
$this->contentHiddenDefault = $this->getModule()->contentHiddenGlobalDefault;
$this->hideNavigationEntryDefault = $this->getModule()->hideNavigationEntryDefault;
$this->wikiNumberingEnabledDefault = $this->getModule()->wikiNumberingEnabledDefault;
$this->overviewNumberingEnabledDefault = $this->getModule()->overviewNumberingEnabledDefault;
}

public function getModule(): Module
Expand All @@ -38,14 +44,16 @@ public function getModule(): Module
public function rules()
{
return [
[['contentHiddenDefault', 'hideNavigationEntryDefault'], 'boolean'],
[['contentHiddenDefault', 'hideNavigationEntryDefault','wikiNumberingEnabledDefault','overviewNumberingEnabledDefault'], 'boolean'],
];
}

public function attributeLabels()
{
return [
'hideNavigationEntryDefault' => Yii::t('WikiModule.base', 'Hide Navigation Entries of this module globally by default'),
'wikiNumberingEnabledDefault'=> Yii::t('WikiModule.base', 'Enable wiki page header numbering for all spaces by default'),
'overviewNumberingEnabledDefault'=> Yii::t('WikiModule.base', 'Enable overview numbering for all spaces by default'),
];
}

Expand All @@ -57,6 +65,8 @@ public function save(): bool

$this->getModule()->settings->set('contentHiddenGlobalDefault', $this->contentHiddenDefault);
$this->getModule()->settings->set('hideNavigationEntryDefault', $this->hideNavigationEntryDefault);
$this->getModule()->settings->set('wikiNumberingEnabledDefault', $this->wikiNumberingEnabledDefault);
$this->getModule()->settings->set('overviewNumberingEnabledDefault', $this->overviewNumberingEnabledDefault);

return true;
}
Expand Down
22 changes: 21 additions & 1 deletion models/DefaultSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ class DefaultSettings extends Model
public const SETTING_MODULE_LABEL = 'defaults.moduleLabel';
public const SETTING_CONTENT_HIDDEN_DEFAULT = 'contentHiddenDefault';
public const SETTING_HIDE_NAVIGATION_ENTRY = 'hideNavigationEntry';
public const SETTING_WIKI_NUMBERING_ENABLED = 'wikiNumberingEnabled';
public const SETTING_OVERVIEW_NUMBERING_ENABLED = 'overviewNumberingEnabled';

/**
* @var ContentContainerActiveRecord
Expand All @@ -43,6 +45,10 @@ class DefaultSettings extends Model

public bool $hideNavigationEntry = false;

public bool $wikiNumberingEnabled = false;

public bool $overviewNumberingEnabled = false;

/**
* @var Module
*/
Expand All @@ -67,6 +73,16 @@ public function init()
$this->module->hideNavigationEntryDefault,
);

$this->wikiNumberingEnabled = $this->getSettings()->get(
self::SETTING_WIKI_NUMBERING_ENABLED,
$this->module->wikiNumberingEnabledDefault,
);

$this->overviewNumberingEnabled = $this->getSettings()->get(
self::SETTING_OVERVIEW_NUMBERING_ENABLED,
$this->module->overviewNumberingEnabledDefault,
);

}

private function getSettings(): ContentContainerSettingsManager
Expand All @@ -81,7 +97,7 @@ public function rules()
{
return [
[['module_label'], 'string'],
[['contentHiddenDefault', 'hideNavigationEntry'], 'boolean'],
[['contentHiddenDefault', 'hideNavigationEntry','wikiNumberingEnabled','overviewNumberingEnabled'], 'boolean'],
];
}

Expand All @@ -90,6 +106,8 @@ public function attributeLabels()
return [
'module_label' => Yii::t('WikiModule.base', 'Module name'),
'hideNavigationEntry' => Yii::t('WikiModule.base', 'Hide Navigation Entry'),
'wikiNumberingEnabled'=> Yii::t('WikiModule.base', 'Enable Default wiki page numbering for current spaces'),
'overviewNumberingEnabled'=> Yii::t('WikiModule.base', 'Enable Default overview numbering for current spaces'),
];
}
public function save(): bool
Expand All @@ -101,6 +119,8 @@ public function save(): bool
$this->getSettings()->set(self::SETTING_MODULE_LABEL, $this->module_label);
$this->getSettings()->set(self::SETTING_CONTENT_HIDDEN_DEFAULT, $this->contentHiddenDefault);
$this->getSettings()->set(self::SETTING_HIDE_NAVIGATION_ENTRY, $this->hideNavigationEntry);
$this->getSettings()->set(self::SETTING_WIKI_NUMBERING_ENABLED, $this->wikiNumberingEnabled);
$this->getSettings()->set(self::SETTING_OVERVIEW_NUMBERING_ENABLED, $this->overviewNumberingEnabled);

return true;
}
Expand Down
30 changes: 30 additions & 0 deletions models/WikiPage.php
Original file line number Diff line number Diff line change
Expand Up @@ -540,4 +540,34 @@ public function getIsCategory(): bool

return $this->_isCategory;
}

public function getNumbering() {
if (is_null($this->parent_page_id)) {
return $this->getPositionInHierarchy() + 1;
}

return $this->categoryPage->getNumbering() . '.' . ($this->getPositionInHierarchy() + 1);
}

protected function getPositionInHierarchy() {
$parentCondition = is_null($this->parent_page_id) ? ['parent_page_id' => null] : ['parent_page_id' => $this->parent_page_id];

$query = static::find()
->contentContainer($this->content->container)
->andWhere($parentCondition)
->orderBy([
static::tableName() . '.sort_order' => SORT_ASC,
static::tableName() . '.title' => SORT_ASC,
]);

$pages = $query->all();

foreach ($pages as $index => $page) {
if ($page->id == $this->id) {
return $index;
}
}
return 0;
}

}
3 changes: 3 additions & 0 deletions resources/js/humhub.wiki.CategoryListView.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,9 @@ humhub.module('wiki.CategoryListView', function(module, require, $) {
$item.closest('.category_list_view, .wiki-page-list').sortable('cancel');
}
pageTitle.removeClass('wiki-page-dropped');
if(document.querySelector('.numbered') !== null){
client.reload();
}
}).catch(function (e) {
module.log.error(e, true);
$item.closest('.category_list_view, .wiki-page-list').sortable('cancel');
Expand Down
5 changes: 5 additions & 0 deletions resources/js/humhub.wiki.Page.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ humhub.module('wiki.Page', function (module, require, $) {
});
$li.append($anchor);
$list.append($li);

// Added numbering to content
if(document.querySelector('.numbered') !== null){
$(this).prepend('<span class="wiki-header-numbering">' + numberString + '. </span>');
}
});

if (hasHeadLine) {
Expand Down
48 changes: 48 additions & 0 deletions tests/codeception/functional/NumberingButtonCest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php

namespace wiki\functional;

use humhub\modules\space\models\Space;
use humhub\modules\wiki\helpers\Url;
use humhub\modules\wiki\models\WikiPage;
use humhub\modules\wiki\Module;
use humhub\modules\user\models\User;
use wiki\FunctionalTester;
use Yii;

class NumberingButtonCest
{
public function testNumberingButtonHtml(FunctionalTester $I)
{
$I->wantTo('check if the numbering toggles between enabled and disabled');
$space = $I->loginBySpaceUserGroup(Space::USERGROUP_MEMBER);
$I->amAdmin(true);
$I->enableModule($space->guid, 'wiki');
$category = $I->createWiki($space, 'Test Wiki Page', 'Test Wiki Page content');

$I->amOnSpace($space->guid, '/wiki/container-config', ['id' => $category->id]);
$I->seeElement('input#defaultsettings-wikinumberingenabled');
$I->checkOption('input#defaultsettings-wikinumberingenabled');
$I->seeElement('input#defaultsettings-overviewnumberingenabled');
$I->checkOption('input#defaultsettings-overviewnumberingenabled');
$I->click('Save', 'button');

$I->amOnSpace($space->guid, '/wiki/overview/list-categories');
$I->seeElement('div.numbered');
$I->amOnSpace($space->guid, '/wiki/page/view', ['id' => $category->id, 'title'=> $category->title]);
$I->seeElement('div.numbered');

$I->amOnSpace($space->guid, '/wiki/container-config', ['id' => $category->id]);
$I->seeElement('input#defaultsettings-wikinumberingenabled');
$I->uncheckOption('input#defaultsettings-wikinumberingenabled');
$I->seeElement('input#defaultsettings-overviewnumberingenabled');
$I->uncheckOption('input#defaultsettings-overviewnumberingenabled');
$I->click('Save', 'button');

$I->amOnSpace($space->guid, '/wiki/overview/list-categories');
$I->dontSeeElement('div.numbered');
$I->amOnSpace($space->guid, '/wiki/page/view', ['id' => $category->id, 'title'=> $category->title]);
$I->dontSeeElement('div.numbered');

}
}
4 changes: 4 additions & 0 deletions views/common/defaultConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@

<?= $form->field($model, 'hideNavigationEntry')->checkbox() ?>

<?= $form->field($model, 'wikiNumberingEnabled')->checkbox() ?>

<?= $form->field($model, 'overviewNumberingEnabled')->checkbox() ?>

<?= Button::primary(Yii::t('base', 'Save'))->submit() ?>

<?php ActiveForm::end(); ?>
Expand Down
4 changes: 4 additions & 0 deletions views/config/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@

<?= $form->field($model, 'hideNavigationEntryDefault')->checkbox() ?>

<?= $form->field($model, 'wikiNumberingEnabledDefault')->checkbox() ?>

<?= $form->field($model, 'overviewNumberingEnabledDefault')->checkbox() ?>

<?= Button::save()->submit() ?>
<?php ActiveForm::end() ?>
</div>
Expand Down
4 changes: 3 additions & 1 deletion views/overview/list-categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@
}

$settings = new DefaultSettings(['contentContainer' => $contentContainer]);
$module = Yii::$app->getModule('wiki');
$numberingEnabled = $module->settings->space()->get('overviewNumberingEnabled');
?>
<div class="panel panel-default">
<div class="panel panel-default <?php if($numberingEnabled) echo 'numbered';?>">
<div class="panel-body">
<div class="row">
<?php WikiContent::begin(['cssClass' => 'wiki-page-content']) ?>
Expand Down
8 changes: 6 additions & 2 deletions views/page/_view_body.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use humhub\modules\wiki\assets\Assets;
use humhub\modules\wiki\models\WikiPage;
use humhub\modules\wiki\models\WikiPageRevision;
use humhub\modules\wiki\helpers\Url;

/* @var $this View */
/* @var $page WikiPage */
Expand All @@ -19,10 +20,13 @@
/* @var $canEdit bool */

Assets::register($this);
$module = Yii::$app->getModule('wiki');
$numberingEnabled = $module->settings->space()->get('wikiNumberingEnabled');
?>
<?= $this->render('_view_header', ['page' => $page, 'revision' => $revision, 'displayTitle' => false]) ?>

<div class="wiki-page-body">
<!-- Adding ID for the body of the wiki page -->
<div class="wiki-page-body <?php if($numberingEnabled) echo 'numbered';?>">
<?= $this->render('_view_content', ['page' => $page, 'canEdit' => $canEdit, 'content' => $content]) ?>
</div>

Expand All @@ -35,4 +39,4 @@
]) ?>
</div>

<?= Comments::widget(['object' => $page]) ?>
<?= Comments::widget(['object' => $page]) ?>
5 changes: 4 additions & 1 deletion views/page/_view_content.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,22 @@
use humhub\modules\wiki\widgets\WikiRichText;
use humhub\widgets\Button;
use humhub\modules\wiki\helpers\Url;
use Yii;

/* @var $this \humhub\modules\ui\view\components\View */
/* @var $page \humhub\modules\wiki\models\WikiPage */
/* @var $canEdit bool */
/* @var $content string */
$module = Yii::$app->getModule('wiki');
$numberingEnabled = $module->settings->space()->get('wikiNumberingEnabled');
?>
<div class="topic-label-list">
<?php foreach ($page->content->getTags(Topic::class)->all() as $topic) : ?>
<?= TopicLabel::forTopic($topic) ?>
<?php endforeach; ?>
</div>

<h1 class="wiki-page-title"><?= Html::encode($page->title) ?></h1>
<h1 class="wiki-page-title"><?= Html::encode($numberingEnabled? $page->getNumbering().'.'.$page->title : $page->title) ?></h1>

<?= $this->render('_view_category_index', ['page' => $page]) ?>

Expand Down
8 changes: 7 additions & 1 deletion widgets/PageListItemTitle.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class PageListItemTitle extends Widget
*/
public $maxLevel;

public $numberingString;

/**
* @inheritdoc
*/
Expand All @@ -81,6 +83,7 @@ public function run()
} else {
$icon = $this->iconPage;
}
$this->numberingString = $this->page->getNumbering();
}

if ($this->titleInfo === null &&
Expand All @@ -90,9 +93,12 @@ public function run()
$this->titleInfo = Yii::t('WikiModule.base', '({n,plural,=1{+1 subpage}other{+{count} subpages}})', ['n' => $this->page->childrenCount, 'count' => $this->page->childrenCount]);
}

$module = Yii::$app->getModule('wiki');
$numberingEnabled = $module->settings->space()->get('overviewNumberingEnabled');

return $this->render('pageListItemTitle', [
'page' => $this->page,
'title' => $this->title,
'title' => $numberingEnabled ? ($this->numberingString . ' ' . $this->title) : $this->title,
'titleIcon' => $this->getVisibilityIcon(),
'titleInfo' => $this->titleInfo,
'url' => $this->page ? $this->page->getUrl() : null,
Expand Down
7 changes: 5 additions & 2 deletions widgets/views/wikiPath.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,14 @@
use humhub\modules\wiki\helpers\Url;
use humhub\modules\wiki\models\WikiPage;
use humhub\widgets\Link;
use Yii;

/* @var $page WikiPage */
/* @var $path WikiPage[]|string[] */

$pathLength = count($path);
$module = Yii::$app->getModule('wiki');
$numberingEnabled = $module->settings->space()->get('wikiNumberingEnabled');
?>
<div class="wiki-page-path wiki-page-path-length-<?= $pathLength ?>">
<?= Link::to('', Url::toHome($page->content->container))->icon('home')->id('wiki_index') ?>
Expand All @@ -30,8 +33,8 @@

/ <?= $categoryPage instanceof WikiPage
? Link::to($isLast
? $categoryPage->title
: Helpers::truncateText($categoryPage->title, 25),
? $numberingEnabled? $categoryPage->getNumbering().'.'.$categoryPage->title : $categoryPage->title
: Helpers::truncateText($numberingEnabled? $categoryPage->getNumbering().'.'.$categoryPage->title : $categoryPage->title, 25),
Url::toWiki($categoryPage))
: '<span>' . $categoryPage . '</span>' ?>

Expand Down