1<?php 2 3use dokuwiki\Extension\Plugin; 4 5/** 6 * DokuWiki Plugin linklist (Helper Component) 7 * 8 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 9 * @author Andreas Gohr <dokuwiki@cosmocode.de> 10 */ 11class helper_plugin_linklist extends Plugin 12{ 13 /** 14 * Get the title for this link 15 * 16 * @param string $link 17 * @return string 18 */ 19 public static function getTitle($link) 20 { 21 global $conf; 22 if ($conf['useheading']) { 23 $title = p_get_first_heading($link); 24 if ($title) return $title; 25 } 26 27 $r = new renderer_plugin_linklist(); 28 return $r->_simpleTitle($link); 29 } 30 31 /** 32 * Get the title for this URL 33 * 34 * @param $link 35 * @return string 36 */ 37 public static function getUrlTitle($link) 38 { 39 $url = parse_url($link); 40 $title = $url['host']; 41 if (str_starts_with($title, 'www.')) { 42 $title = substr($title, 4); 43 } 44 45 if (isset($url['port'])) $title .= ':' . $url['port']; 46 $title .= $url['path']; 47 return $title; 48 } 49} 50