Пример #1
0
 /**
  * Display navigation
  *
  * @param array $navipages array($home, $up, $prev, $current, $next)
  * @param string $look Show DocBook 'footer' style or DocBook 'header'
  *
  * DocBook header
  * <pre>
  *     Prev          Home          Next
  * </pre>
  * DocBook footer
  * <pre>
  *     Prev          Home          Next
  *     <pagename>     Up     <pagename>
  * </pre>
  *
  * @param string $border 'off' or 'top' or 'bottom'. 
  * - 'off' shows no border.
  * - 'top' shows a border top.
  * - 'bottom' shows a border bottom. 
  * @param bool $printcss print css with html as style="" attributes. 
  * @return string html
  */
 function display_navi($navipages, $look = 'header', $border = 'off', $printcss = false)
 {
     $linkstr = $this->linkstr;
     $css = $this->css;
     $footer = $look == 'footer';
     list($home, $up, $prev, $current, $next) = $navipages;
     // get link
     $link = array();
     $link['prev'] = make_pagelink($prev, $linkstr['prev']);
     $link['home'] = $home == '' ? sonots::make_toplink($linkstr['home']) : make_pagelink($home, $linkstr['home']);
     if ($next) {
         $link['next'] = make_pagelink($next, $linkstr['next']);
     }
     if ($footer) {
         $link['up'] = make_pagelink($up, $linkstr['up']);
         $link['prevfoot'] = strip_tags(make_link(PluginSonotsMetapage::linkstr($prev, $footer, $current, true)));
         if ($next) {
             $link['nextfoot'] = strip_tags(make_link(PluginSonotsMetapage::linkstr($next, $footer, $current, true)));
         }
     }
     // html
     $html = '<div class="wrap_navix" style="margin:0px;padding:0px;">' . "\n";
     if ($border === 'top') {
         $html .= '<hr class="full_hr top"' . ($printcss ? ' style="' . $css['div.wrap_navix hr.top'] . '"' : '') . '/>' . "\n";
     }
     $html .= '<ul class="navix"' . ($printcss ? ' style="' . $css['ul.navix'] . '"' : '') . '>' . "\n";
     $html .= '<li class="left"' . ($printcss ? ' style="' . $css['ul.navix li.left'] . '"' : '') . '>' . $link['prev'] . ($footer ? '<br />' . $link['prevfoot'] : '') . '</li>' . "\n";
     $html .= '<li class="center"' . ($printcss ? ' style="' . $css['ul.navix li.center'] . '"' : '') . '>' . $link['home'] . ($footer ? '<br />' . $link['up'] : '') . '</li>' . "\n";
     $html .= '<li class="right"' . ($printcss ? ' style="' . $css['ul.navix li.right'] . '"' : '') . '>' . ($next ? $link['next'] . ($footer ? '<br />' . $link['nextfoot'] : '') : '&nbsp;') . '</li>' . "\n";
     $html .= '</ul>' . "\n";
     if ($border === 'bottom') {
         $html .= '<hr class="full_hr bottom"' . ($printcss ? ' style="' . $css['div.wrap_navix hr.bottom'] . '"' : '') . '/>' . "\n";
     }
     $html .= '</div>' . "\n";
     return $html;
 }
 function test_linkstr()
 {
     $this->assertEqual(PluginSonotsMetapage::linkstr('Hoge/A', 'relative', 'Hoge/'), 'A');
     $this->assertEqual(PluginSonotsMetapage::linkstr('Hoge/A', 'basename', 'Hoge/'), 'A');
     $this->assertEqual(PluginSonotsMetapage::linkstr('Hoge/A', 'absolute', 'Hoge/'), 'Hoge/A');
 }
Пример #3
0
 /**
  * Include page
  *
  * @access tatic
  * @param string $page
  * @param array $options
  * @param array $syntax
  * @return string html
  */
 function display_include($page, $options, $syntax)
 {
     global $vars;
     $lines = get_source($page);
     if (is_array($options['section'])) {
         $lines = PluginIncludex::get_sections($lines, $page, $options['section']);
     }
     if (isset($options['readmore'])) {
         $toc = new PluginSonotsToc($page, $options['section']['cache']);
         $readmore = $toc->get_readmore();
         if (isset($readmore)) {
             $last = key(array_keys($lines));
             switch ($options['readmore']) {
                 case 'until':
                     for ($i = $readmore; $i <= $last; ++$i) {
                         if (isset($lines[$i])) {
                             unset($lines[$i]);
                         }
                     }
                     break;
                 case 'from':
                     for ($i = 0; $i <= $readmore; ++$i) {
                         if (isset($lines[$i])) {
                             unset($lines[$i]);
                         }
                     }
                     break;
             }
         }
     }
     if (isset($options['filter'])) {
         $lines = sonots::grep_array('/' . str_replace('/', '\\/', $options['filter']) . '/', $lines, 'preg', TRUE);
     }
     if (isset($options['except'])) {
         $lines = sonots::grep_array('/' . str_replace('/', '\\/', $options['except']) . '/', $lines, 'preg', TRUE, TRUE);
         // inverse
     }
     if (is_array($options['num'])) {
         list($offset, $length) = $options['num'];
         $lines = sonots::array_slice($lines, $offset, $length, true);
     }
     if (!$options['firsthead']) {
         // cut the headline on the first line
         $firstline = reset($lines);
         if (preg_match($syntax['headline'], $firstline)) {
             array_shift($lines);
         }
     }
     // html
     $html = sonots::get_convert_html($page, $lines);
     //if (trim($html) === '') return '';
     $titlestr = '';
     if ($options['titlestr'] !== 'off') {
         $titlestr = PluginSonotsMetapage::linkstr($page, $options['titlestr'], $vars['page'], true);
     }
     $title = PluginIncludex::display_title($page, $titlestr, $options['title'], $GLOBALS['fixed_heading_edited'], 'includex');
     $footer = '';
     if (is_string($options['permalink'])) {
         $linkstr = sonots::make_inline($options['permalink']);
         $footer = '<p class="permalink">' . make_pagelink($page, $linkstr) . '</p>';
     }
     return $title . "\n" . $html . $footer;
 }
 /**
  * Generate linkstr property of this page
  *
  * @access public
  * @param string $optlinkstr
  * @param string $currdir computed as default
  * @param boolean $usecache use Toc cache or not (used for title and firsthead)
  * @uses linkstr
  */
 function gen_linkstr($optlinkstr = 'relative', $currdir = '', $usecache = true)
 {
     $currdir = empty($currdir) ? substr($this->page, 0, strlen($this->page) - strlen($this->relname)) : $currdir;
     $this->linkstr = PluginSonotsMetapage::linkstr($this->page, $optlinkstr, $currdir, $usecache);
 }
Пример #5
0
 /**
  * Convert Includeline to Headline
  *
  * @return PluginSonotsHeadline
  */
 function headline($usecache = true)
 {
     $linenum = $this->linenum;
     $depth = 0;
     $options = sonots::parse_options($this->args, array('titlestr' => 'title'));
     $string = PluginSonotsMetapage::linkstr($this->page, $options['titlestr'], $usecache);
     $anchor = sonots::make_pageanchor($this->page);
     return new PluginSonotsHeadline($this->page, $linenum, $depth, $string, $anchor);
 }