Changeset 488

Show
Ignore:
Timestamp:
05/18/2007 05:44:30 AM (3 years ago)
Author:
DarTar
Message:

First draft of link tail support, refs #35

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/libs/Wakka.class.php

    r487 r488  
    17021702         * @param        boolean $escapeText optional: 
    17031703         * @param        string $title optional: 
     1704         * @param       string $class optional: 
    17041705         * @return      string 
    17051706         * @todo        i18n 
    1706          * @todo        add class depending on link type 
    17071707         * @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='') 
    17111710        { 
    17121711                if (!$text) 
     
    17291728                { 
    17301729                        $url = $this->GetInterWikiUrl($matches[1], $matches[2]); 
     1730                        $class = 'interwiki'; 
    17311731                } 
    17321732                elseif (preg_match('/^(http|https|ftp|news|irc|gopher):\/\/([^\\s\"<>]+)$/', $tag)) 
    17331733                { 
    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                        } 
    17351740                } 
    17361741                // is this a full link? ie, does it contain something *else* than valid WikiName (alpha-numeric) characters? 
     
    17421747                        { 
    17431748                                $url = 'mailto:'.$tag; 
     1749                                $class = 'mailto'; 
    17441750                        } 
    17451751                        // check for protocol-less URLs 
     
    17471753                        { 
    17481754                                $url = 'http://'.$tag; 
     1755                                $class = 'ext'; 
    17491756                        } 
    17501757                } 
     
    17591766                        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 
    17601767                } 
    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; 
    17631769        } 
    17641770 
     
    22052211                return ($user['show_comments'] == 'Y'); 
    22062212        } 
    2207     /** 
    2208     * Formatter for usernames. 
    2209     * 
    2210     * Renders usernames as links only when needed, avoiding the creation of missing page links  
    2211     * for users without userpage. Makes other options configurable (like truncating long  
    2212     * hostnames or disabling link formatting). 
    2213     * 
    2214      * @author        {@link http://www.wikkawiki.org/DarTar Dario Taraborelli}  
    2215     * 
    2216      * @param    string    $user    required: name of user or hostname retrieved from the DB; 
    2217      * @param    string    $link    optional: enables/disables linking to userpage; 
    2218      * @param    string    $maxhostlength    optional: max length for hostname, hostnames longer 
    2219      *                                 than this will be truncated with an ellipsis; 
    2220      * @param    string    $ellipsis    optional: 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        */ 
    22232229        function FormatUser ($user, $link='1', $maxhostlength='10', $ellipsis='&#8230;') 
    22242230        { 
     
    22842290         *  
    22852291         * 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!! 
    22872293         * @uses    Query() 
    22882294         * @param       string $tablename mandatory: Table to modify