Пример #1
0
 /**
  * Check Page Validity
  *
  * @access static
  * @param string $page
  * @param string $current
  * @param array $visited
  * @return string evaluated page
  */
 function check_page($page, $current, $visited = array())
 {
     if (empty($page)) {
         sonots::mythrow("No page is specified.");
         return;
     }
     $page = get_fullname($page, $current);
     if (!is_page($page)) {
         sonots::mythrow('Page ' . sonots::make_pagelink_nopg($page) . ' does not exist.');
         return;
     }
     if (!check_readable($page, false, false)) {
         sonots::mythrow('Page ' . sonots::make_pagelink_nopg($page) . ' is not readable.');
         return;
     }
     if (isset($visited[$page])) {
         sonots::mythrow('Page ' . sonots::make_pagelink_nopg($page) . ' is already included.');
         return;
     }
     return $page;
 }
 /**
  * Get link of a page
  * 
  * @access public
  * @static
  * @param string $page pagename
  * @param string $linkstr linkstr
  * @param string $option option
  * - page   : link to page
  * - anchor : link to anchor
  * - off    : no link
  * @return string
  * @uses sonots::make_pagelink_nopg
  * @uses sonots::make_pageanchor
  */
 function link($page, $linkstr, $option)
 {
     switch ($option) {
         case 'page':
             $link = sonots::make_pagelink_nopg($page, $linkstr);
             break;
         case 'anchor':
             $anchor = sonots::make_pageanchor($page);
             $link = sonots::make_pagelink_nopg('', $linkstr, '#' . $anchor);
             break;
         case 'off':
             $link = $linkstr;
             break;
     }
     return $link;
 }
Пример #3
0
 /**
  * Display Table of Contents
  *
  * @access public
  * @static
  * @param array &$headlines
  * @param string $cssclass css class
  * @param string $optlink link option
  * @param boolean $optinclude show toc of including pages too or not
  * @return string list html
  */
 function display_toc(&$headlines, $cssclass = '', $optlink = 'anchor')
 {
     $links = $levels = array();
     foreach ($headlines as $i => $headline) {
         $linkstr = strip_htmltag(make_link($headline->string));
         switch ($optlink) {
             case 'page':
                 $link = sonots::make_pagelink_nopg($headline->page, $linkstr, '#' . $headline->anchor);
                 break;
             case 'off':
                 $link = $linkstr;
                 break;
             case 'anchor':
             default:
                 $link = sonots::make_pagelink_nopg('', $linkstr, '#' . $headline->anchor);
                 break;
         }
         $links[$i] = $link;
         $levels[$i] = $headline->depth;
     }
     return sonots::display_list($links, $levels, $cssclass);
 }