From c9d5d295d59735064e5aae76343d9d62a1a460c1 Mon Sep 17 00:00:00 2001 From: lastlink Date: Mon, 19 Aug 2024 08:15:27 -0400 Subject: [PATCH 01/50] add more tests --- Test/Model/WikiModelTest.php | 134 +++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) diff --git a/Test/Model/WikiModelTest.php b/Test/Model/WikiModelTest.php index 8ee92e9..0b77855 100644 --- a/Test/Model/WikiModelTest.php +++ b/Test/Model/WikiModelTest.php @@ -137,4 +137,138 @@ public function testReOrderByIndex(){ $this->assertEquals($expectedColumnOrders[$wikiPages[$i]['id']-1], $wikiPages[$i]['ordercolumn'], 'Failed to reorder page id:'. $wikiPages[$i]['id']); } } + + + + public function testGetEditionsReturnsArray() + { + $this->db + ->expects($this->once()) + ->method('table') + ->with(WikiModel::WIKI_EDITION_TABLE) + ->willReturnSelf(); + + $this->db + ->method('eq') + ->with('wikipage_id', 123) + ->willReturnSelf(); + + $this->db + ->method('desc') + ->with('edition') + ->willReturnSelf(); + + $expected = [ + ['id' => 1, 'content' => 'test'] + ]; + + $this->db + ->method('findAll') + ->willReturn($expected); + + $result = $this->wikiModel->getEditions(123); + + $this->assertSame($expected, $result); + } + + public function testCreatePageSavesCorrectly() + { + $this->db + ->expects($this->once()) + ->method('table') + ->with(WikiModel::WIKITABLE) + ->willReturnSelf(); + + $this->db + ->method('persist') + ->willReturn(1); + + $result = $this->wikiModel->createpage(1, 'Test title', 'Test content'); + + $this->assertEquals(1, $result); + } + + public function testUpdatePageUpdatesCorrectly() + { + $this->db + ->expects($this->once()) + ->method('table') + ->with(WikiModel::WIKITABLE) + ->willReturnSelf(); + + $this->db + ->method('eq') + ->with('id', 1) + ->willReturnSelf(); + + $this->db + ->method('update') + ->willReturn(true); + + $result = $this->wikiModel->updatepage(['title' => 'New Title', 'content' => 'New content', 'id' => 1], 1); + + $this->assertEquals(1, $result); + } + + public function testRemovePageRemovesCorrectly() + { + $this->db + ->expects($this->once()) + ->method('table') + ->with(WikiModel::WIKITABLE) + ->willReturnSelf(); + + $this->db + ->method('eq') + ->with('id', 1) + ->willReturnSelf(); + + $this->db + ->method('remove') + ->willReturn(true); + + $result = $this->wikiModel->removepage(1); + + $this->assertTrue($result); + } + + public function testGetWikipageReturnsCorrectData() + { + $this->db + ->expects($this->once()) + ->method('table') + ->with(WikiModel::WIKITABLE) + ->willReturnSelf(); + + $this->db + ->method('columns') + ->willReturnSelf(); + + $this->db + ->method('eq') + ->with('id', 1) + ->willReturnSelf(); + + $expected = ['id' => 1, 'title' => 'Test']; + + $this->db + ->method('findOne') + ->willReturn($expected); + + $result = $this->wikiModel->getWikipage(1); + + $this->assertSame($expected, $result); + } + + public function testGetWikipageThrowsPageNotFoundException() + { + $this->db + ->method('findOne') + ->willReturn(null); + + $this->expectException(\Kanboard\Core\Controller\PageNotFoundException::class); + + $this->wikiModel->getWiki(); + } + } From 3cc3091d4e53e6e7b8ac35686e3629fd2dfceaef Mon Sep 17 00:00:00 2001 From: lastlink Date: Mon, 19 Aug 2024 08:16:35 -0400 Subject: [PATCH 02/50] add more tests --- Test/Model/WikiModelTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Test/Model/WikiModelTest.php b/Test/Model/WikiModelTest.php index 0b77855..b081d5f 100644 --- a/Test/Model/WikiModelTest.php +++ b/Test/Model/WikiModelTest.php @@ -266,7 +266,7 @@ public function testGetWikipageThrowsPageNotFoundException() ->method('findOne') ->willReturn(null); - $this->expectException(\Kanboard\Core\Controller\PageNotFoundException::class); + $this->expectException(\Kanboard\Core\ExternalTask\NotFoundException::class); $this->wikiModel->getWiki(); } From 7cb7cf303f3f8356fafc2cfee4e2940f6e2f5bec Mon Sep 17 00:00:00 2001 From: lastlink Date: Mon, 19 Aug 2024 08:26:25 -0400 Subject: [PATCH 03/50] another try --- Test/Model/WikiModelTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Test/Model/WikiModelTest.php b/Test/Model/WikiModelTest.php index b081d5f..1b58423 100644 --- a/Test/Model/WikiModelTest.php +++ b/Test/Model/WikiModelTest.php @@ -139,7 +139,7 @@ public function testReOrderByIndex(){ } - + /* public function testGetEditionsReturnsArray() { $this->db @@ -170,6 +170,7 @@ public function testGetEditionsReturnsArray() $this->assertSame($expected, $result); } + */ public function testCreatePageSavesCorrectly() { From d3a91eb8a86ec3ff81a1590f8ac9323d8eccb500 Mon Sep 17 00:00:00 2001 From: lastlink Date: Mon, 19 Aug 2024 08:31:00 -0400 Subject: [PATCH 04/50] take 3 --- Test/Model/WikiModelTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Test/Model/WikiModelTest.php b/Test/Model/WikiModelTest.php index 1b58423..902de30 100644 --- a/Test/Model/WikiModelTest.php +++ b/Test/Model/WikiModelTest.php @@ -19,6 +19,15 @@ class WikiModelTest extends Base protected function setUp(): void { parent::setUp(); + + $this->db = $this->createMock(\PicoDb\Database::class); + $this->container = $this->createMock(\Psr\Container\ContainerInterface::class); + + // $this->container + // ->method('get') + // ->willReturnMap([ + // [\PicoDb\Database::class, $this->db] + // ]); // $this->plugin = new Plugin($this->container); $plugin = new Loader($this->container); From 3f55331fd4f8bbb969733f800856b8cbb9cd9553 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alfred=20B=C3=BChler?= Date: Tue, 8 Oct 2024 09:02:52 +0200 Subject: [PATCH 05/50] Added locale de_DE_du --- ChangeLog | 5 +++ Locale/de_DE_du/translations.php | 54 ++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+) create mode 100644 Locale/de_DE_du/translations.php diff --git a/ChangeLog b/ChangeLog index 5227e4b..5874681 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Version 0.3.9 +Bug fixes: + +* Fix https://github.com/funktechno/kanboard-plugin-wiki/issues/99 + Version 0.3.8 Improvements: diff --git a/Locale/de_DE_du/translations.php b/Locale/de_DE_du/translations.php new file mode 100644 index 0000000..71d15bb --- /dev/null +++ b/Locale/de_DE_du/translations.php @@ -0,0 +1,54 @@ + 'Stundensatz entfernen', + 'Do you really want to remove this hourly rate?' => 'Diesen Stundensatz wirklich entfernen?', + 'Hourly rate' => 'Stundensatz', + 'Effective date' => 'Inkraftsetzung', + 'Add new rate' => 'Neue Rate hinzufügen', + 'Rate removed successfully.' => 'Rate erfolgreich entfernt', + 'Unable to remove this rate.' => 'Nicht in der Lage, diese Rate zu entfernen.', + 'Unable to save the hourly rate.' => 'Nicht in der Lage, diese Rate zu speichern', + 'Hourly rate created successfully.' => 'Stundensatz erfolgreich angelegt.', + 'Amount' => 'Betrag', + 'Wiki' => 'Wiki', + 'Wiki line' => 'Wikilinie', + 'Wiki line removed successfully.' => 'Wikilinie erfolgreich entfernt', + 'Wiki lines' => 'Wikilinien', + 'Cost' => 'Kosten', + 'Cost breakdown' => 'Kostenaufschlüsselung', + 'Do you really want to remove this wiki page?' => 'Soll diese Wikilinie wirklich entfernt werden?', + 'Expenses' => 'Kosten', + 'New Wiki page' => 'Neue Wikilinie', + 'Remove a wiki line' => 'Wikilinie entfernen', + 'Remove wiki line' => 'Wikilinie entfernen', + 'The wiki line have been created successfully.' => 'Die Wikilinie wurde erfolgreich angelegt.', + 'Unable to create the wiki line.' => 'Wikilinie konnte nicht erstellt werden.', + 'Unable to remove this wiki page.' => 'Wikilinie konnte nicht gelöscht werden.', + 'Remaining' => 'Verbleibend', + 'Currency rates are used to calculate project wiki.' => 'Währungskurse werden verwendet, um das Projektwiki zu berechnen.', + 'Burndown chart for "%s"' => 'Burn-Down-Chart für "%s"', + 'Wiki overview' => 'Wiki-Übersicht', + 'Type' => 'Typ', + 'There is not enough data to show something.' => 'Es sind nicht genügend Daten vorhanden, um irgendetwas anzuzeigen.', + 'Created' => 'Erstellt', + 'Last modifier' => 'Letzter Bearbeiter', + 'Modified' => 'Geändert', + 'Edit page' => 'Seite bearbeiten', + 'View Editions' => 'Bearbeitungen anzeigen', + 'Creator' => 'Ersteller', + 'Modifier' => 'Bearbeiter', + 'Editions' => 'Bearbeitungen', + 'Current Edition' => 'Aktuelle Bearbeitung', + 'Date Creation' => 'Erstellungs-Datum', + 'Date Modification' => 'Änderungs-Datum', + 'Content' => 'Inhalt', + 'Date Created' => 'Erstellungsdatum', + 'Date Modified' => 'Änderungsdatum', + '%d Wiki pages' => '%d Wiki-Seiten', + 'Search by content' => 'Suche nach Inhalt', + 'Wiki page Title' => 'Wikiseiten-Titel', + 'There are no editions for this Wiki page saved to restore.' => 'Es sind keine Bearbeitungen zur Wiederherstellung für diese Wiki-Seite gespeichert.', + 'There are no Wiki pages that you have access to.' => 'Es gibt keine Wiki-Seiten, auf die Du Zugriff hast.', + 'There are no Wiki pages for this project.' => 'Es gibt keine Wiki-Seiten für dieses Projekt.' +); From f0d16df66ef08a513987813af98e757d861f1449 Mon Sep 17 00:00:00 2001 From: "Im[F(x)]" Date: Tue, 29 Oct 2024 12:57:25 +0200 Subject: [PATCH 06/50] * adding 'Project' to wiki list details --- Template/wiki_list/wiki_details.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Template/wiki_list/wiki_details.php b/Template/wiki_list/wiki_details.php index c5fe43a..e0a6a73 100644 --- a/Template/wiki_list/wiki_details.php +++ b/Template/wiki_list/wiki_details.php @@ -1,5 +1,7 @@
    +
  • : model->projectModel->getById($wiki['project_id'])['name']?>
  • + 0): ?>
  • : text->e($wiki['creator_name'] ?: $wiki['creator_username'])?>
  • From cfee926ddb430502a2c8bb70ad0da23548115196 Mon Sep 17 00:00:00 2001 From: "Im[F(x)]" Date: Tue, 29 Oct 2024 12:59:23 +0200 Subject: [PATCH 07/50] * fixed the new line symbol in images info tooltip --- Template/wiki_file/images.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Template/wiki_file/images.php b/Template/wiki_file/images.php index 1767578..d9ff10c 100644 --- a/Template/wiki_file/images.php +++ b/Template/wiki_file/images.php @@ -31,7 +31,7 @@
- dt->datetime($file['date'])).'
'.t('Size: %s', $this->text->bytes($file['size'])) ?>'> + dt->datetime($file['date'])).' '.t('Size: %s', $this->text->bytes($file['size'])) ?>'> From 3957f88b1b3000ce7db11c55588d9ffdace74163 Mon Sep 17 00:00:00 2001 From: "Im[F(x)]" Date: Tue, 29 Oct 2024 13:04:25 +0200 Subject: [PATCH 08/50] * removed redundant parameter `no_layout` * adjusted all titles of pages to show the project name * removed obsolete references to 'wiki:wiki/sidebar' template in WikiController --- Controller/WikiController.php | 38 +++++++++++++++-------------------- 1 file changed, 16 insertions(+), 22 deletions(-) diff --git a/Controller/WikiController.php b/Controller/WikiController.php index 4da7b37..c04474c 100755 --- a/Controller/WikiController.php +++ b/Controller/WikiController.php @@ -65,11 +65,10 @@ public function readonly() $this->response->html($this->helper->layout->app('wiki:wiki/show', array( 'project' => $project, - 'no_layout' => true, 'not_editable' => true, - 'title' => $project['name'] .= " ". t('Wiki'), + 'title' => $project['name'], 'wikipages' => $this->wikiModel->getWikipages($project['id']), - ), 'wiki:wiki/sidebar')); + ))); } /** @@ -85,9 +84,9 @@ public function show() $this->response->html($this->helper->layout->app('wiki:wiki/show', array( 'project' => $project, - 'title' => $project['name'] .= " ". t('Wiki'), + 'title' => $project['name'], 'wikipages' => $this->wikiModel->getWikipages($project['id']), - ), 'wiki:wiki/sidebar')); + ))); // ,array( // 'wikipages' => $this->wikiModel->getWikipages($project['id']) @@ -106,12 +105,12 @@ public function editions() // restore button use undo - $this->response->html($this->helper->layout->project('wiki:wiki/editions', array( + $this->response->html($this->helper->layout->app('wiki:wiki/editions', array( 'project' => $project, - 'title' => t('Wiki Editions'), + 'title' => $project['name'], 'wiki_id'=> $wiki_id, 'editions' => $this->wikiModel->getEditions($wiki_id), - ), 'wiki:wiki/sidebar')); + ))); } @@ -144,7 +143,7 @@ public function edit(array $values = array(), array $errors = array()) 'errors' => $errors, 'wiki_list' => $wiki_list, 'title' => t('Edit Wikipage'), - ), 'wiki:wiki/sidebar')); + ))); } public function detail_readonly() { @@ -174,17 +173,16 @@ public function detail_readonly() { // use a wiki helper for better side bar TODO: $this->response->html($this->helper->layout->app('wiki:wiki/detail', array( 'project' => $project, - 'title' => t('Wikipage'), + 'title' => $project['name'], 'wiki_id' => $wiki_id, 'wiki' => $wikipage, - 'no_layout' => true, 'not_editable' => true, 'files' => $this->wikiFileModel->getAllDocuments($wiki_id), 'images' => $this->wikiFileModel->getAllImages($wiki_id), // 'wikipage' => $this->wikiModel->getWikipage($wiki_id), 'wikipage' => $wikipage, 'wikipages' => $wikipages, - ), 'wiki:wiki/sidebar')); + ))); } function getNestedChildren($parent_id, $items) { @@ -212,15 +210,12 @@ public function detail() $wikipages = $this->wikiModel->getWikipages($project['id']); $wikiPagesResult = array(); - foreach ($wikipages as $page) { if (t($wiki_id) == t($page['id'])) { $wikipage = $page; } if(!isset($page['parent_id'])){ - $page['children'] = $this->getNestedChildren($page['id'], $wikipages); - array_push($wikiPagesResult, $page); } } @@ -233,15 +228,14 @@ public function detail() // use a wiki helper for better side bar TODO: $this->response->html($this->helper->layout->app('wiki:wiki/detail', array( 'project' => $project, - 'title' => t('Wikipage'), + 'title' => $project['name'], 'wiki_id' => $wiki_id, 'wiki' => $wikipage, 'files' => $this->wikiFileModel->getAllDocuments($wiki_id), 'images' => $this->wikiFileModel->getAllImages($wiki_id), - // 'wikipage' => $this->wikiModel->getWikipage($wiki_id), 'wikipage' => $wikipage, 'wikipages' => $wikiPagesResult, - ), 'wiki:wiki/sidebar')); + ))); // $wikipage= $wikipages->select(1)->eq('id', $wiki_id)->findOne(); @@ -249,12 +243,12 @@ public function detail() // $this->response->html($this->helper->layout->project('wiki:wiki/detail', array( // 'project' => $project, - // 'title' => t('Wikipage'), + // 'title' => $project['name'], // 'wiki_id' => $wiki_id, // // 'wikipage' => $this->wikiModel->getWikipage($wiki_id), // 'wikipage' => $wikipage, // 'wikipages' => $wikipages, - // ), 'wiki:wiki/sidebar')); + // ))); // ,array( // 'wikipages' => $this->wikiModel->getWikipages($project['id']) @@ -277,7 +271,7 @@ public function detail() // 'paginator' => $paginator, // 'project' => $project, // 'title' => t('Wiki'), - // ), 'wiki:wiki/sidebar')); + // ))); // } /** @@ -428,7 +422,7 @@ public function create(array $values = array(), array $errors = array()) 'errors' => $errors, 'project' => $project, 'title' => t('Wikipage'), - ), 'wiki:wiki/sidebar')); + ))); } /** From 02e3763203042e082092cc52834e1cd2c0bb9b69 Mon Sep 17 00:00:00 2001 From: "Im[F(x)]" Date: Tue, 29 Oct 2024 13:05:53 +0200 Subject: [PATCH 09/50] * adjusted elements in create/edit wiki page modals --- Template/wiki/create.php | 1 + Template/wiki/edit.php | 26 ++++++++++++++------------ 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Template/wiki/create.php b/Template/wiki/create.php index 149d1f5..254f864 100644 --- a/Template/wiki/create.php +++ b/Template/wiki/create.php @@ -11,6 +11,7 @@ form->label(t('Title'), 'title') ?> form->text('title', $values, $errors, array('required', 'maxlength="255"', 'autofocus', 'tabindex="1"')) ?> +

form->label(t('Content'), 'content') ?> form->textEditor('content', $values, $errors) ?> diff --git a/Template/wiki/edit.php b/Template/wiki/edit.php index c6cb940..1cd51a1 100644 --- a/Template/wiki/edit.php +++ b/Template/wiki/edit.php @@ -2,21 +2,23 @@

-
- form->csrf()?> + + form->csrf() ?> - form->hidden('id', $values)?> - form->hidden('editions', $values)?> - form->hidden('order', $values)?> + form->hidden('id', $values) ?> + form->hidden('editions', $values) ?> + form->hidden('order', $values) ?> - form->label(t('Title'), 'title')?> - form->text('title', $values, $errors, array('required', 'maxlength="255"', 'autofocus', 'tabindex="1"'))?> + form->label(t('Title'), 'title') ?> + form->text('title', $values, $errors, array('required', 'maxlength="255"', 'autofocus', 'tabindex="1"')) ?> +
- form->label(t('is a child of'), 'is a child of')?> - form->select('parent_id', $wiki_list, $values, $errors) ?> + form->label(t('is a child of'), 'is a child of') ?> + form->select('parent_id', $wiki_list, $values, $errors) ?> - form->label(t('Content'), 'content')?> - form->textEditor('content', $values, $errors)?> +

+ form->label(t('Content'), 'content') ?> + form->textEditor('content', $values, $errors) ?> - modal->submitButtons()?> + modal->submitButtons() ?>
From 1f453553ed2144d56fabdad767d96bdbf03081cd Mon Sep 17 00:00:00 2001 From: "Im[F(x)]" Date: Tue, 29 Oct 2024 13:13:28 +0200 Subject: [PATCH 10/50] * reusing the `wiki/sidebar` template to show wiki links and contents in a sidebar when showing wiki page details and editions * the sidebar is also horizontally resizable now * the original KB styles for sidebar/container/content replace the inline hardcoded clearfix styles --- Controller/WikiController.php | 21 +++++++-- Template/wiki/detail.php | 86 +++++++---------------------------- Template/wiki/editions.php | 75 +++++++++++++++--------------- Template/wiki/sidebar.php | 69 ++++++++++++++++++++-------- 4 files changed, 120 insertions(+), 131 deletions(-) diff --git a/Controller/WikiController.php b/Controller/WikiController.php index c04474c..14e6d34 100755 --- a/Controller/WikiController.php +++ b/Controller/WikiController.php @@ -99,16 +99,29 @@ public function editions() $project = $this->getProject(); $wiki_id = $this->request->getIntegerParam('wiki_id'); - // $project = $this->getProject(); - // - // for list use window-restore + $wikipages = $this->wikiModel->getWikipages($project['id']); + $wikiPagesResult = array(); + foreach ($wikipages as $page) { + if (t($wiki_id) == t($page['id'])) { + $wikipage = $page; + } + if(!isset($page['parent_id'])){ + $page['children'] = $this->getNestedChildren($page['id'], $wikipages); + array_push($wikiPagesResult, $page); + } + } - // restore button use undo + // If the last wikipage was deleted, select the new last wikipage. + if (!isset($wikipage)) { + $wikipage = end($wikipages); + } $this->response->html($this->helper->layout->app('wiki:wiki/editions', array( 'project' => $project, 'title' => $project['name'], 'wiki_id'=> $wiki_id, + 'wikipage' => $wikipage, + 'wikipages' => $wikiPagesResult, 'editions' => $this->wikiModel->getEditions($wiki_id), ))); diff --git a/Template/wiki/detail.php b/Template/wiki/detail.php index 8286ae6..7b992ba 100755 --- a/Template/wiki/detail.php +++ b/Template/wiki/detail.php @@ -1,79 +1,21 @@ - + - wikiHelper->js("plugins/Wiki/Asset/vendor/jquery-sortable/jquery-sortable.js")?> - wikiHelper->js("plugins/Wiki/Asset/Javascript/wiki.js")?> projectHeader->render($project, 'TaskListController', 'show') ?> - - - -
- - -
+ - -
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
- - url->link(t($wikipage['title']), 'WikiController', 'detail', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $wikipage['id']))?> - modal->confirm('trash-o', t(''), 'WikiController', 'confirm', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $wikipage['id']))?> - - url->link(t($wikipage['title']), 'WikiController', 'detail_readonly', array('plugin' => 'wiki', 'token' => $project['token'], 'wiki_id' => $wikipage['id']))?> - - - - - - url->link($wikipage['parent_id'], 'WikiController', 'detail', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $wikipage['parent_id']))?> - - url->link($wikipage['parent_id'], 'WikiController', 'detail_readonly', array('plugin' => 'wiki', 'token' => $project['token'], 'wiki_id' => $wikipage['parent_id']))?> - - text->e($wikipage['creator_name'] ?: $wikipage['creator_username'])?>dt->date($wikipage['date_creation'])?>text->e($wikipage['modifier_name'] ?: $wikipage['modifier_username'])?>dt->date($wikipage['date_modification'])?>
-
+ + + + + + + + + + + + + + + + + + + + + + + + + +
+ + url->link(t($wikipage['title']), 'WikiController', 'detail', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $wikipage['id']))?> + modal->confirm('trash-o', t(''), 'WikiController', 'confirm', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $wikipage['id']))?> + + url->link(t($wikipage['title']), 'WikiController', 'detail_readonly', array('plugin' => 'wiki', 'token' => $project['token'], 'wiki_id' => $wikipage['id']))?> + + + + + + url->link($wikipage['parent_id'], 'WikiController', 'detail', array('plugin' => 'wiki', 'project_id' => $project['id'], 'wiki_id' => $wikipage['parent_id']))?> + + url->link($wikipage['parent_id'], 'WikiController', 'detail_readonly', array('plugin' => 'wiki', 'token' => $project['token'], 'wiki_id' => $wikipage['parent_id']))?> + + text->e($wikipage['creator_name'] ?: $wikipage['creator_username'])?>dt->date($wikipage['date_creation'])?>text->e($wikipage['modifier_name'] ?: $wikipage['modifier_username'])?>dt->date($wikipage['date_modification'])?>

-
- - From 757cdc8cc6ba0edaa6d855c343875d08d764d18b Mon Sep 17 00:00:00 2001 From: "Im[F(x)]" Date: Tue, 29 Oct 2024 14:21:00 +0200 Subject: [PATCH 12/50] * fixed some sane routes for 'WikiController' and 'WikiFileViewController' using a minimalistic notation corresponding to actions and parameters * removed the totally unnecessary 'wikipage_id' and 'project_id' parameters for file controller URLs --- Controller/WikiFileController.php | 4 +-- Plugin.php | 45 +++++++++++++------------------ Template/file_viewer/show.php | 2 +- Template/wiki_file/files.php | 6 ++--- Template/wiki_file/images.php | 8 +++--- 5 files changed, 28 insertions(+), 37 deletions(-) diff --git a/Controller/WikiFileController.php b/Controller/WikiFileController.php index 71d1e43..d932f65 100644 --- a/Controller/WikiFileController.php +++ b/Controller/WikiFileController.php @@ -23,7 +23,7 @@ public function screenshot() if ($this->request->isPost() && $this->wikiFileModel->uploadScreenshot($wiki['id'], $this->request->getValue('screenshot')) !== false) { $this->flash->success(t('Screenshot uploaded successfully.')); - return $this->response->redirect($this->helper->url->to('WikiViewController', 'show', array('wiki_id' => $wiki['id'], 'project_id' => $wiki['project_id'])), true); + return $this->response->redirect($this->helper->url->to('WikiController', 'show', array('wiki_id' => $wiki['id'], 'project_id' => $wiki['project_id'])), true); } return $this->response->html($this->template->render('wiki:wiki_file/screenshot', array( @@ -82,7 +82,7 @@ public function save() $this->response->redirect($this->helper->url->to('WikiController', 'detail', array('plugin' => 'wiki', 'project_id' => $wiki['project_id'], 'wiki_id' => $wiki['id'])), true); - // $this->response->redirect($this->helper->url->to('WikiViewController', 'show', array('wiki_id' => $wiki['id'], 'project_id' => $wiki['project_id'])), true); + // $this->response->redirect($this->helper->url->to('WikiController', 'show', array('wiki_id' => $wiki['id'], 'project_id' => $wiki['project_id'])), true); } } diff --git a/Plugin.php b/Plugin.php index f7e6c7a..fffabb6 100755 --- a/Plugin.php +++ b/Plugin.php @@ -10,47 +10,39 @@ class Plugin extends Base { public function initialize() { + // access map $this->projectAccessMap->add('WikiController', '*', Role::PROJECT_MEMBER); $this->projectAccessMap->add('WikiAjaxController', '*', Role::PROJECT_MEMBER); - $this->applicationAccessMap->add('WikiController', array('readonly','detail_readonly'), Role::APP_PUBLIC); $this->projectAccessMap->add('WikiFileController', '*', Role::PROJECT_MEMBER); $this->projectAccessMap->add('WikiFileViewController', '*', Role::PROJECT_MEMBER); + $this->applicationAccessMap->add('WikiController', array('readonly','detail_readonly'), Role::APP_PUBLIC); - // $this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'readonly', 'wiki'); - // dont think these are even currently used + // page routes $this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'show', 'wiki'); - $this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'detail', 'wiki'); - $this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'editions', 'wiki'); - $this->route->addRoute('/wiki/project/:project_id', 'WikiController', 'edit', 'wiki'); - - // show images as list - $this->route->addRoute('/wiki/project/:project_id', 'WikiFileController', 'show', 'wiki_file'); - $this->route->addRoute('/wiki/project/:project_id', 'WikiFileController', 'create', 'wiki_file'); - $this->route->addRoute('/wiki/project/:project_id', 'WikiFileController', 'remove', 'wiki_file'); - $this->route->addRoute('/wiki/project/:project_id', 'WikiFileController', 'images', 'wiki_file'); - $this->route->addRoute('/wiki/project/:project_id', 'WikiFileController', 'files', 'wiki_file'); - - - + $this->route->addRoute('/wiki/project/:project_id/readonly', 'WikiController', 'readonly', 'wiki'); + $this->route->addRoute('/wiki/project/:project_id/detail/:wiki_id', 'WikiController', 'detail', 'wiki'); + $this->route->addRoute('/wiki/project/:project_id/detail/:wiki_id/readonly', 'WikiController', 'detail_readonly', 'wiki'); + $this->route->addRoute('/wiki/project/:project_id/editions/:wiki_id', 'WikiController', 'editions', 'wiki'); + // $this->route->addRoute('/wiki/project/:project_id/breakdown', 'WikiController', 'breakdown', 'wiki'); + $this->route->addRoute('/wiki/file/:file_id', 'WikiFileViewController', 'show', 'wiki'); + $this->route->addRoute('/wiki/file/:file_id/image', 'WikiFileViewController', 'image', 'wiki'); + $this->route->addRoute('/wiki/file/:file_id/thumbnail', 'WikiFileViewController', 'thumbnail', 'wiki'); + $this->route->addRoute('/wiki/file/:file_id/browser', 'WikiFileViewController', 'browser', 'wiki'); + $this->route->addRoute('/wiki/file/:file_id/download', 'WikiFileViewController', 'download', 'wiki'); + + // template hooks $this->template->hook->attach('template:config:sidebar', 'Wiki:config/sidebar'); - - // $this->route->addRoute('/wiki/project/:project_id&:wikipage_id', 'WikiController', 'detail', 'wiki'); - $this->route->addRoute('/wiki/project/:project_id/breakdown', 'WikiController', 'breakdown', 'wiki'); - $this->template->hook->attach('template:project:dropdown', 'wiki:project/dropdown'); - $this->template->hook->attach('template:project-list:menu:after', 'wiki:wiki_list/menu'); - $this->template->hook->attach('template:header:dropdown', 'wiki:header/dropdown'); $this->template->hook->attach('template:project-header:view-switcher', 'Wiki:project_header/views'); + // template overrides $this->template->setTemplateOverride('board/view_public', 'wiki:board/view_public'); - $this->template->setTemplateOverride('file_viewer/show', 'wiki:file_viewer/show'); + // CSS + JS $this->hook->on('template:layout:css', array('template' => 'plugins/Wiki/Asset/css/wiki.css')); - // $this->hook->on('template:layout:js', array('template' => 'plugins/Wiki/Asset/vendor/jquery-sortable/jquery-sortable.js')); - // $this->hook->on('template:layout:js', array('template' => 'plugins/Wiki/Asset/Javascript/wiki.js')); $this->hook->on('template:layout:js', array('template' => 'plugins/Wiki/Asset/Javascript/main.js')); @@ -59,9 +51,8 @@ public function initialize() // $this->layout->register('wiki', '\Kanboard\Plugin\Wiki\Helper\layout'); // $this->helper->register('wiki', '\Kanboard\Plugin\Wiki\Helper\layout'); + // helpers $this->helper->register('wikiHelper', '\Kanboard\Plugin\Wiki\Helper\WikiHelper'); - - } public function onStartup() diff --git a/Template/file_viewer/show.php b/Template/file_viewer/show.php index b0e12e8..ac5add6 100644 --- a/Template/file_viewer/show.php +++ b/Template/file_viewer/show.php @@ -3,7 +3,7 @@
- <?= $this->text->e($file['name']) ?> + <?= $this->text->e($file['name']) ?>
text->markdown($content) ?> diff --git a/Template/wiki_file/files.php b/Template/wiki_file/files.php index beda880..8656cae 100644 --- a/Template/wiki_file/files.php +++ b/Template/wiki_file/files.php @@ -15,16 +15,16 @@
    file->getPreviewType($file['name']) !== null): ?>
  • - modal->large('eye', t('View file'), 'WikiFileViewController', 'show', array('plugin' => 'wiki', 'wikipage_id' => $wiki['id'], 'project_id' => $wiki['project_id'], 'file_id' => $file['id'])) ?> + modal->large('eye', t('View file'), 'WikiFileViewController', 'show', array('plugin' => 'wiki', 'file_id' => $file['id'])) ?>
  • file->getBrowserViewType($file['name']) !== null): ?>
  • - url->link(t('View file'), 'WikiFileViewController', 'browser', array('plugin' => 'wiki', 'wikipage_id' => $wiki['id'], 'project_id' => $wiki['project_id'], 'file_id' => $file['id']), false, '', '', true) ?> + url->link(t('View file'), 'WikiFileViewController', 'browser', array('plugin' => 'wiki', 'file_id' => $file['id']), false, '', '', true) ?>
  • - url->icon('download', t('Download'), 'WikiFileViewController', 'download', array('plugin' => 'wiki', 'wikipage_id' => $wiki['id'], 'project_id' => $wiki['project_id'], 'file_id' => $file['id'])) ?> + url->icon('download', t('Download'), 'WikiFileViewController', 'download', array('plugin' => 'wiki', 'file_id' => $file['id'])) ?>
  • user->hasProjectAccess('WikiFileController', 'remove', $wiki['project_id'])): ?>
  • diff --git a/Template/wiki_file/images.php b/Template/wiki_file/images.php index d9ff10c..b91d623 100644 --- a/Template/wiki_file/images.php +++ b/Template/wiki_file/images.php @@ -8,9 +8,9 @@ 'regex_file_id' => 'FILE_ID', 'regex_etag' => 'ETAG', 'url' => array( - 'image' => $this->url->to('WikiFileViewController', 'image', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'])), - 'thumbnail' => $this->url->to('WikiFileViewController', 'thumbnail', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'])), - 'download' => $this->url->to('WikiFileViewController', 'download', array('plugin' => 'wiki', 'file_id' => 'FILE_ID', 'project_id' => $wiki['project_id'], 'wikipage_id' => $wiki['id'])), + 'image' => $this->url->to('WikiFileViewController', 'image', array('plugin' => 'wiki', 'file_id' => 'FILE_ID')), + 'thumbnail' => $this->url->to('WikiFileViewController', 'thumbnail', array('plugin' => 'wiki', 'file_id' => 'FILE_ID')), + 'download' => $this->url->to('WikiFileViewController', 'download', array('plugin' => 'wiki', 'file_id' => 'FILE_ID')), ) )) ?> @@ -20,7 +20,7 @@ text->e($file['name']) ?>
    • - url->icon('download', t('Download'), 'WikiFileViewController', 'download', array('plugin' => 'wiki', 'wikipage_id' => $wiki['id'], 'project_id' => $wiki['project_id'], 'file_id' => $file['id'], 'file_id' => $file['id'])) ?> + url->icon('download', t('Download'), 'WikiFileViewController', 'download', array('plugin' => 'wiki', 'file_id' => $file['id'], 'file_id' => $file['id'])) ?>
    • user->hasProjectAccess('WikiFileController', 'remove', $wiki['project_id'])): ?>
    • From cde08dd32f22a67ef8110ec1490c27df8dcfc515 Mon Sep 17 00:00:00 2001 From: "Im[F(x)]" Date: Tue, 29 Oct 2024 15:34:16 +0200 Subject: [PATCH 13/50] * making the content of wiki pages expandable on demand (instead of fully preloaded) for the 'editions' and 'wiki listing' pages that show multiple rows with versions/pages at once * making sure the sidebar layout for detail/editions takes the whole screen width --- Controller/WikiController.php | 2 +- Template/wiki/editions.php | 14 ++++++-------- Template/wiki/sidebar.php | 3 +++ Template/wiki_list/wiki_details.php | 8 ++++++-- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/Controller/WikiController.php b/Controller/WikiController.php index 14e6d34..ef5eeb3 100755 --- a/Controller/WikiController.php +++ b/Controller/WikiController.php @@ -254,7 +254,7 @@ public function detail() // $wikipage= $wikipages->eq('id', $wiki_id); - // $this->response->html($this->helper->layout->project('wiki:wiki/detail', array( + // $this->response->html($this->helper->layout->app('wiki:wiki/detail', array( // 'project' => $project, // 'title' => $project['name'], // 'wiki_id' => $wiki_id, diff --git a/Template/wiki/editions.php b/Template/wiki/editions.php index d98b227..90a3d7f 100755 --- a/Template/wiki/editions.php +++ b/Template/wiki/editions.php @@ -38,14 +38,12 @@ dt->date($edition['date_creation'])?>
diff --git a/Template/wiki/sidebar.php b/Template/wiki/sidebar.php index 2d72b93..bd3d2bb 100755 --- a/Template/wiki/sidebar.php +++ b/Template/wiki/sidebar.php @@ -4,6 +4,9 @@ resize: horizontal; overflow: auto; } +.sidebar-container { + width: 100%; +}