aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2024-11-21 10:37:31 +0100
committerAndreas Gohr <andi@splitbrain.org>2024-12-04 10:51:14 +0100
commit652715cc973f9ba1db53b1a65ed22e2ec1e5521e (patch)
treec76ed845f6f3a3dee42a8e41bcab446cf28c2668
parent79ff0cd0c6f2643b1208755842379c8042176441 (diff)
downloaddokuwiki-652715cc973f9ba1db53b1a65ed22e2ec1e5521e.tar.gz
dokuwiki-652715cc973f9ba1db53b1a65ed22e2ec1e5521e.zip
Extension Manager: added the last missing GUI tabs
-rw-r--r--lib/plugins/extension/GuiAdmin.php104
-rw-r--r--lib/plugins/extension/GuiExtension.php5
-rw-r--r--lib/plugins/extension/admin.php43
-rw-r--r--lib/plugins/extension/style.less25
4 files changed, 128 insertions, 49 deletions
diff --git a/lib/plugins/extension/GuiAdmin.php b/lib/plugins/extension/GuiAdmin.php
index 16f6e542d..60a182aea 100644
--- a/lib/plugins/extension/GuiAdmin.php
+++ b/lib/plugins/extension/GuiAdmin.php
@@ -2,6 +2,8 @@
namespace dokuwiki\plugin\extension;
+use dokuwiki\Form\Form;
+
class GuiAdmin extends Gui
{
public function render()
@@ -82,7 +84,8 @@ class GuiAdmin extends Gui
*
* @return string
*/
- public function tabTemplates() {
+ public function tabTemplates()
+ {
$html = '<div class="panelHeader">';
$html .= $this->helper->locale_xhtml('intro_templates');
$html .= '</div>';
@@ -103,4 +106,103 @@ class GuiAdmin extends Gui
return $html;
}
+ /**
+ * Return the HTML for the search tab
+ *
+ * @return string
+ */
+ public function tabSearch()
+ {
+ global $INPUT;
+
+ $html = '<div class="panelHeader">';
+ $html .= $this->helper->locale_xhtml('intro_search');
+ $html .= '</div>';
+
+ $form = new Form([
+ 'action' => $this->tabURL('search'),
+ 'class' => 'search',
+ ]);
+ $form->addTagOpen('div')->addClass('no');
+ $form->addTextInput('q', $this->getLang('search_for'))
+ ->addClass('edit')
+ ->val($INPUT->str('q'));
+ $form->addButton('submit', $this->getLang('search'))
+ ->attrs(['type' => 'submit', 'title' => $this->getLang('search')]);
+ $form->addTagClose('div');
+ $html .= $form->toHTML();
+
+ if ($INPUT->str('q')) $html .= $this->SearchResults($INPUT->str('q'));
+
+ return $html;
+ }
+
+ /**
+ * Return the HTML for the install tab
+ *
+ * @return string
+ */
+ public function tabInstall()
+ {
+ global $lang;
+
+ $html = '<div class="panelHeader">';
+ $html .= $this->helper->locale_xhtml('intro_install');
+ $html .= '</div>';
+
+ $form = new Form([
+ 'action' => $this->tabURL('install'),
+ 'enctype' => 'multipart/form-data',
+ 'class' => 'install',
+ ]);
+ $form->addTagOpen('div')->addClass('no');
+ $form->addTextInput('installurl', $this->getLang('install_url'))
+ ->addClass('block')
+ ->attrs(['type' => 'url']);
+ $form->addTag('br');
+ $form->addTextInput('installfile', $this->getLang('install_upload'))
+ ->addClass('block')
+ ->attrs(['type' => 'file']);
+ $form->addTag('br');
+ $form->addCheckbox('overwrite', $lang['js']['media_overwrt'])
+ ->addClass('block');
+ $form->addTag('br');
+ $form->addButton('', $this->getLang('btn_install'))
+ ->attrs(['type' => 'submit', 'title' => $this->getLang('btn_install')]);
+ $form->addTagClose('div');
+ $html .= $form->toHTML();
+
+ return $html;
+ }
+
+ /**
+ * Execute the given search query and return the results
+ *
+ * @param string $q the query
+ * @return string
+ */
+ protected function SearchResults($q)
+ {
+ $repo = Repository::getInstance();
+
+ $html = '<div id="extension__list">';
+ $html .= '<form action="' . $this->tabURL('search') . '" method="post">';
+
+ try {
+ $extensions = $repo->searchExtensions($q);
+ $html .= '<div id="extension__results">';
+ foreach ($extensions as $ext) {
+ $gui = new GuiExtension($ext);
+ $html .= $gui->render();
+ }
+ $html .= '</div>';
+ } catch (Exception $e) {
+ msg($e->getMessage(), -1);
+ }
+
+ $html .= '</form>';
+ $html .= '</div>';
+
+ return $html;
+ }
}
diff --git a/lib/plugins/extension/GuiExtension.php b/lib/plugins/extension/GuiExtension.php
index 1d7946bab..c89dc9cd1 100644
--- a/lib/plugins/extension/GuiExtension.php
+++ b/lib/plugins/extension/GuiExtension.php
@@ -26,7 +26,8 @@ class GuiExtension extends Gui
$html .= '<div class="screenshot">';
$html .= $this->thumbnail();
- $html .= '<span class="id">'. hsc($this->extension->getBase()) .'</span>';
+ $html .= '<span class="id" title="' . hsc($this->extension->getBase()) . '">' .
+ hsc($this->extension->getBase()) . '</span>';
$html .= $this->popularity();
$html .= '</div>';
@@ -144,7 +145,7 @@ class GuiExtension extends Gui
foreach ($messages as $message) {
$message = hsc($message);
$message = nl2br($message);
- $message = '<span>'.Notice::ICONS[$type] . '</span> ' . $message;
+ $message = '<span>' . Notice::ICONS[$type] . '</span> ' . $message;
$message = preg_replace('/`([^`]+)`/', '<bdi>$1</bdi>', $message);
$html .= '<li class="' . $type . '"><div class="li">' . $message . '</div></li>';
}
diff --git a/lib/plugins/extension/admin.php b/lib/plugins/extension/admin.php
index a4962b6e5..9e0dbb793 100644
--- a/lib/plugins/extension/admin.php
+++ b/lib/plugins/extension/admin.php
@@ -4,6 +4,7 @@ use dokuwiki\Extension\AdminPlugin;
use dokuwiki\plugin\extension\Exception as RepoException;
use dokuwiki\plugin\extension\Extension;
use dokuwiki\plugin\extension\Gui;
+use dokuwiki\plugin\extension\GuiAdmin;
use dokuwiki\plugin\extension\Installer;
use dokuwiki\plugin\extension\Repository;
@@ -11,44 +12,9 @@ use dokuwiki\plugin\extension\Repository;
* DokuWiki Plugin extension (Admin Component)
*
* @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
- * @author Michael Hamann <michael@content-space.de>
- */
-
-/**
- * Admin part of the extension manager
*/
class admin_plugin_extension extends AdminPlugin
{
- protected $infoFor;
- /** @var helper_plugin_extension_gui */
- protected $gui;
-
- /**
- * Constructor
- *
- * loads additional helpers
- */
- public function __construct()
- {
- $this->gui = plugin_load('helper', 'extension_gui');
- }
-
- /**
- * @return int sort number in admin menu
- */
- public function getMenuSort()
- {
- return 0;
- }
-
- /**
- * @return bool true if only access for superuser, false is for superusers and moderators
- */
- public function forAdminOnly()
- {
- return true;
- }
-
/**
* Execute the requested action(s) and initialize the plugin repository
*/
@@ -118,7 +84,9 @@ class admin_plugin_extension extends AdminPlugin
}
}
- send_redirect((new Gui())->tabURL('', [], '&', true));
+ // Redirect to clear the POST data
+ $gui = new Gui();
+ send_redirect($gui->tabURL($gui->currentTab(), [], '&', true));
}
/**
@@ -128,9 +96,8 @@ class admin_plugin_extension extends AdminPlugin
{
echo '<h1>' . $this->getLang('menu') . '</h1>';
- $gui = new \dokuwiki\plugin\extension\GuiAdmin();
+ $gui = new GuiAdmin();
echo $gui->render();
}
}
-// vim:ts=4:sw=4:et:
diff --git a/lib/plugins/extension/style.less b/lib/plugins/extension/style.less
index 02de2e7e9..85fbfdb4a 100644
--- a/lib/plugins/extension/style.less
+++ b/lib/plugins/extension/style.less
@@ -62,9 +62,11 @@
#extension__list {
- @thumbwidth: 120px;
- @thumbheight: 70px;
- box-sizing: border-box;
+ @thumbwidth: 125px; // width of the thumbnail column, can be increased once we have larger thumbnails
+
+ &, * {
+ box-sizing: border-box;
+ }
section.extension {
display: grid;
@@ -76,14 +78,16 @@
> .screenshot {
grid-column: 1;
grid-row: 1;
- padding: 0.5em 0.5em 0.5em 0;
+ padding-top: 0.5em;
+ padding-right: 0.5em;
+ margin-bottom: 1.5em; // adds space for the detail summary label
position: relative;
img {
border: 1px solid @ini_border;
border-radius: 2px;
- width: @thumbwidth;
- height: @thumbheight;
+ width: 100%;
+ height: auto;
}
.id {
@@ -95,6 +99,11 @@
top: 0.5em;
left: 0;
border-bottom-left-radius: 2px;
+ white-space: nowrap;
+ max-width: 100%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ cursor: default;
}
.popularity {
@@ -169,7 +178,7 @@
summary {
cursor: pointer;
float: left;
- margin-top: -1.5em;
+ margin-top: -1.5em; // moves it up into the screenshot margin
color: @ini_text_alt;
}
@@ -196,7 +205,7 @@
}
}
- section.extension.disabled {
+ section.extension.installed.disabled {
.screenshot img,
.main,
.details {