Changeset 488
- Timestamp:
- 05/18/2007 05:44:30 AM (3 years ago)
- Files:
-
- 1 modified
-
trunk/libs/Wakka.class.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/libs/Wakka.class.php
r487 r488 1702 1702 * @param boolean $escapeText optional: 1703 1703 * @param string $title optional: 1704 * @param string $class optional: 1704 1705 * @return string 1705 1706 * @todo i18n 1706 * @todo add class depending on link type1707 1707 * @todo move regexps to regexp-library 1708 * @todo remove link tail (should be generated by the stylesheet) 1709 */ 1710 function Link($tag, $handler='', $text='', $track=TRUE, $escapeText=TRUE, $title='') 1708 */ 1709 function Link($tag, $handler='', $text='', $track=TRUE, $escapeText=TRUE, $title='', $class='') 1711 1710 { 1712 1711 if (!$text) … … 1729 1728 { 1730 1729 $url = $this->GetInterWikiUrl($matches[1], $matches[2]); 1730 $class = 'interwiki'; 1731 1731 } 1732 1732 elseif (preg_match('/^(http|https|ftp|news|irc|gopher):\/\/([^\\s\"<>]+)$/', $tag)) 1733 1733 { 1734 $url = $tag; // this is a valid external URL 1734 $url = $tag; 1735 //add ext class only if URL is external 1736 if (!preg_match('/'.$_SERVER['SERVER_NAME'].'/', $tag)) 1737 { 1738 $class = 'ext'; 1739 } 1735 1740 } 1736 1741 // is this a full link? ie, does it contain something *else* than valid WikiName (alpha-numeric) characters? … … 1742 1747 { 1743 1748 $url = 'mailto:'.$tag; 1749 $class = 'mailto'; 1744 1750 } 1745 1751 // check for protocol-less URLs … … 1747 1753 { 1748 1754 $url = 'http://'.$tag; 1755 $class = 'ext'; 1749 1756 } 1750 1757 } … … 1759 1766 return ($linkedPage ? '<a href="'.$this->Href($handler, $linkedPage['tag']).'"'.$title_attr.'>'.$text.'</a>' : '<a class="missingpage" href="'.$this->Href("edit", $tag).'" title="'.CREATE_THIS_PAGE_LINK_TITLE.'">'.$text.'</a>'); #i18n 1760 1767 } 1761 $external_link_tail = $this->GetConfigValue('external_link_tail'); 1762 return $url ? '<a class="ext" href="'.$url.'">'.$text.'</a>'.$external_link_tail : $text; 1768 return $url ? '<a class="'.$class.'" href="'.$url.'">'.$text.'</a>' : $text; 1763 1769 } 1764 1770 … … 2205 2211 return ($user['show_comments'] == 'Y'); 2206 2212 } 2207 /**2208 * Formatter for usernames.2209 *2210 * Renders usernames as links only when needed, avoiding the creation of missing page links2211 * for users without userpage. Makes other options configurable (like truncating long2212 * hostnames or disabling link formatting).2213 *2214 * @author{@link http://www.wikkawiki.org/DarTar Dario Taraborelli}2215 *2216 * @param string $userrequired: name of user or hostname retrieved from the DB;2217 * @param string $linkoptional: enables/disables linking to userpage;2218 * @param string $maxhostlengthoptional: max length for hostname, hostnames longer2219 *than this will be truncated with an ellipsis;2220 * @param string $ellipsisoptional: character to be use at the end of truncated hosts;2221 * @return string$formatted_user: formatted username.2222 */2213 /** 2214 * Formatter for usernames. 2215 * 2216 * Renders usernames as links only when needed, avoiding the creation of missing page links 2217 * for users without userpage. Makes other options configurable (like truncating long 2218 * hostnames or disabling link formatting). 2219 * 2220 * @author {@link http://www.wikkawiki.org/DarTar Dario Taraborelli} 2221 * 2222 * @param string $user required: name of user or hostname retrieved from the DB; 2223 * @param string $link optional: enables/disables linking to userpage; 2224 * @param string $maxhostlength optional: max length for hostname, hostnames longer 2225 * than this will be truncated with an ellipsis; 2226 * @param string $ellipsis optional: character to be use at the end of truncated hosts; 2227 * @return string $formatted_user: formatted username. 2228 */ 2223 2229 function FormatUser ($user, $link='1', $maxhostlength='10', $ellipsis='…') 2224 2230 { … … 2284 2290 * 2285 2291 * WARNING: Do not add, delete, or reorder records or fields in 2286 * queries prior to calling this function!!2292 * queries prior to calling this function!! 2287 2293 * @uses Query() 2288 2294 * @param string $tablename mandatory: Table to modify