aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/inc/Menu/Item/Edit.php
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2017-05-19 15:08:35 +0200
committerAndreas Gohr <andi@splitbrain.org>2017-05-19 17:02:13 +0200
commit93b8c351fad5246a7a91c86418f15bec833dc99f (patch)
tree5ad78fe9f2a8639f8c2e095690506972b76aa326 /inc/Menu/Item/Edit.php
parent08ee0671938eeed96f27428c408e3877a01120c9 (diff)
downloaddokuwiki-93b8c351fad5246a7a91c86418f15bec833dc99f.tar.gz
dokuwiki-93b8c351fad5246a7a91c86418f15bec833dc99f.zip
beginning of a complete refactoring of the menues
This is an attempt to: * get rid of the super long, complex functions in in/template.php * make it easy for plugin authors to add their own items to any of our menus, regardless of the used template * continue the progress to make use of SVG in the menues This takes a similar approach as my actionrefactor branch. Originially I thought both refactorings could be done in one, merging the functionality of DokuWiki actions and the menu items. However I couldn't make it work. So instead we have two separate but similar things. Maybe they can converge later on.
Diffstat (limited to 'inc/Menu/Item/Edit.php')
-rw-r--r--inc/Menu/Item/Edit.php59
1 files changed, 59 insertions, 0 deletions
diff --git a/inc/Menu/Item/Edit.php b/inc/Menu/Item/Edit.php
new file mode 100644
index 000000000..45a05eb1e
--- /dev/null
+++ b/inc/Menu/Item/Edit.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace dokuwiki\Menu\Item;
+
+class Edit extends AbstractItem {
+
+ /** @inheritdoc */
+ public function __construct() {
+ global $ACT;
+ global $INFO;
+ global $REV;
+
+ parent::__construct();
+
+ if($ACT == 'show' || $ACT == 'search') {
+ $this->method = 'post';
+ if($INFO['writable']) {
+ $this->accesskey = 'e';
+ if(!empty($INFO['draft'])) {
+ $this->type = 'draft';
+ $this->params['do'] = 'draft';
+ } else {
+ $this->params['rev'] = $REV;
+ if(!$INFO['exists']) {
+ $this->type = 'create';
+ }
+ }
+ } else {
+ if(!actionOK($this->type)) throw new \RuntimeException("action disabled: source");
+ $params['rev'] = $REV;
+ $this->type = 'source';
+ $this->accesskey = 'v';
+ }
+ } else {
+ $this->params = array('do' => '');
+ $this->type = 'show';
+ $this->accesskey = 'v';
+ }
+
+ $this->svg = $this->setIcon();
+ }
+
+ /**
+ * change the icon according to what type the edit button has
+ */
+ protected function setIcon() {
+ $icons = array(
+ 'edit' => '01-edit_pencil.svg',
+ 'create' => '02-create_pencil.svg',
+ 'draft' => '03-draft_android-studio.svg',
+ 'show' => '04-show_file-document.svg',
+ 'source' => '05-source_file-xml.svg',
+ );
+ if(isset($icons[$this->type])) {
+ $this->svg = DOKU_BASE . 'lib/images/menu/' . $icons[$this->type];
+ }
+ }
+
+}