1<?php 2 3namespace dokuwiki\Menu\Item; 4 5/** 6 * Class ShareOn 7 */ 8class ShareOn extends AbstractItem 9{ 10 11 /** @inheritdoc */ 12 public function __construct() 13 { 14 parent::__construct(); 15 16 if (!in_array('social-share', explode(',', tpl_getConf('pageIcons')))) { 17 throw new \RuntimeException("share on is not available"); 18 } 19 20 unset($this->params['do']); 21 22 $this->label = tpl_getLang('share_on'); 23 $this->svg = tpl_incdir() . 'images/menu/share-variant.svg'; 24 $this->id = '#'; 25 } 26 27 public function getLinkAttributes($classprefix = 'menuitem dropdown-toggle ') 28 { 29 global $ID; 30 31 $attr = parent::getLinkAttributes($classprefix); 32 33 $attr['data-toggle'] = 'dropdown'; 34 $attr['data-remote'] = wl($ID); 35 $attr['data-target'] = '#'; 36 $attr['aria-haspopup'] = 'true'; 37 $attr['aria-expanded'] = 'true'; 38 39 return $attr; 40 } 41 42 public function getDropDownMenu() 43 { 44 $enabled_providers = explode(',', tpl_getConf('socialShareProviders')); 45 46 $share_providers = array( 47 'twitter' => array('label' => 'Twitter'), 48 'linkedin' => array('label' => 'LinkedIn'), 49 'facebook' => array('label' => 'Facebook'), 50 'pinterest' => array('label' => 'Pinterest'), 51 'telegram' => array('label' => 'Telegram'), 52 'whatsapp' => array('label' => 'WhatsApp'), 53 'yammer' => array('label' => 'Yammer'), 54 'reddit' => array('label' => 'Reddit'), 55 'microsoft-teams' => array('label' => 'Teams'), 56 ); 57 58 $html = ''; 59 60 $html .= '<ul class="dropdown-menu">'; 61 $html .= '<li class="dropdown-header">'; 62 $html .= iconify('mdi:share-variant') . ' ' . tpl_getLang('share_on') . '...'; 63 $html .= '</li>'; 64 65 foreach ($share_providers as $provider => $data) { 66 if (!in_array($provider, $enabled_providers)) { 67 continue; 68 } 69 70 $html .= '<li><a href="#" class="share share-' . $provider . '" title="' . tpl_getLang('share_on') . ' ' . $data['label'] . '">' . iconify("mdi:$provider") . ' ' . $data['label'] . '</a></li>'; 71 } 72 73 $html .= '</ul>'; 74 75 return $html; 76 } 77} 78