Ejemplo n.º 1
0
 /**
  * Get string used in html link
  *
  * @access public
  * @static
  * @param string $page pagename
  * @param string $option option
  *  - name|page|pagename|absolute: pagename (absolute path)
  *  - base|basename      : page basename
  *  - title              : TITLE: of page
  *  - headline|firsthead : The first headline of a page
  *  - relative|relname   : relative pagename from currdir
  * @param string $currdir current dir name($currdir is required for relative)
  * @param boolean $usecache use cache of Toc or not (used for title and headline)
  * @return string
  * @uses sonots::get_basename
  * @uses title
  * @uses firsthead
  * @uses relname
  */
 function linkstr($page, $option = 'relative', $currdir = '', $usecache = true)
 {
     switch ($option) {
         case 'name':
         case 'page':
         case 'pagename':
         case 'absolute':
         default:
             $linkstr = htmlspecialchars($page);
             break;
         case 'base':
         case 'basename':
             $linkstr = htmlspecialchars(sonots::get_basename($page));
             break;
         case 'title':
             $title = PluginSonotsMetapage::title($page, $usecache);
             if (is_null($title)) {
                 $linkstr = htmlspecialchars($page);
             } else {
                 $linkstr = strip_htmltag(make_link($title));
             }
             break;
         case 'firsthead':
         case 'headline':
             $firsthead = PluginSonotsMetapage::firsthead($page, $usecache);
             if (is_null($firsthead)) {
                 $linkstr = htmlspecialchars($page);
             } else {
                 $linkstr = strip_htmltag(make_link($firsthead));
             }
             break;
         case 'relname':
         case 'relative':
             $linkstr = htmlspecialchars(PluginSonotsMetapage::relname($page, $currdir));
             break;
     }
     return $linkstr;
 }