1<?php 2 3namespace dokuwiki\plugin\folded; 4 5use dokuwiki\Menu\Item\AbstractItem; 6 7/** 8 * Class MenuItemFolded 9 * 10 * Implements the 'fold/unfold all' button for DokuWiki's menu system 11 * 12 * @package dokuwiki\plugin\folded 13 */ 14class MenuItemFolded extends AbstractItem { 15 16 /** @var string icon file */ 17 protected $svg = DOKU_INC . 'lib/plugins/folded/menu-folded.svg'; 18 19 /** 20 * MenuItem constructor. 21 */ 22 public function __construct() { 23 parent::__construct(); 24 global $REV; 25 if($REV) $this->params['rev'] = $REV; 26 } 27 28 /** 29 * Get label from plugin language file 30 * 31 * @return string 32 */ 33 public function getLabel() { 34 $hlp = plugin_load('action', 'folded'); 35 return $hlp->getLang('fold_unfold_all_button'); 36 } 37 38 /** 39 * Return this item's title 40 * 41 * @return string 42 */ 43 public function getTitle() { 44 return $this->getLabel(); 45 } 46 47 /** 48 * Return the link this item links to 49 * 50 * @return string 51 */ 52 public function getLink() { 53 return 'javascript:void(0);'; 54 } 55 56 /** 57 * Convenience method to get the attributes for constructing an <a> element 58 * 59 * @see buildAttributes() 60 * @return array 61 */ 62 public function getLinkAttributes($classprefix = 'menuitem ') { 63 $attr = array( 64 'href' => $this->getLink(), 65 'title' => $this->getTitle(), 66 ); 67 $attr['rel'] = 'nofollow'; 68 $attr['class'] = 'fold_unfold_all_new'; 69 $attr['onclick'] = 'fold_unfold_all();'; 70 71 return $attr; 72 } 73 74} 75