Ejemplo n.º 1
0
 /**
  * List pages
  *
  * @param array $pages
  * @param array $options
  * @param array $argoptions
  * @return string html
  */
 function pagelist($pages, $options, $argoptions)
 {
     $pagelist = new PluginSonotsPagelist($pages);
     if ($options['non_list']) {
         $pattern = '/' . $GLOBALS['non_list'] . '/';
         $pagelist->grep_by('page', 'preg', $pattern, true);
         // inverse
     }
     if (isset($options['filter']) && $options['filter'] !== '') {
         $pagelist->grep_by('relname', 'preg', '/' . str_replace('/', '\\/', $options['filter']) . '/');
     }
     if (isset($options['except'])) {
         $pagelist->grep_by('relname', 'preg', '/' . str_replace('/', '\\/', $options['except']) . '/', true);
         // inverse
     }
     if (isset($options['newpage'])) {
         switch ($options['newpage']) {
             case 'on':
                 $pagelist->gen_metas('newpage');
                 $pagelist->grep_by('newpage', 'eq', true);
                 break;
             case 'except':
             case 'off':
                 $pagelist->gen_metas('newpage');
                 $pagelist->grep_by('newpage', 'eq', false);
                 break;
             default:
                 break;
         }
     }
     if (is_array($options['info']) || $options['sort'] === 'date') {
         $pagelist->gen_metas('timestamp');
     }
     if ($options['sort'] === 'popular') {
         $pagelist->gen_metas('popular', array($options['popular']));
     }
     if ($options['sort'] === 'reading') {
         $pagelist->gen_metas('reading');
     }
     if ($options['sort'] === 'title') {
         $pagelist->gen_metas('title');
     }
     $pagelist->sort_by($options['sort'], $options['reverse']);
     $max = count($pagelist->metapages);
     // for next option
     if (is_array($options['num'])) {
         list($offset, $length) = $options['num'];
         $pagelist->slice($offset, $length);
     }
     //// display
     if (isset($options['include'])) {
         $pages = $pagelist->get_metas('page');
         $include = new PluginIncludex();
         // just want static var
         $includes = array();
         foreach ($pages as $i => $page) {
             $includes[$i] = PluginIncludex::display_include($page, $options['include'], $include->syntax);
         }
         $html = implode("\n", $includes);
     } else {
         $pagelist->init_metas('depth', 1);
         $pagelist->gen_metas('link', array($options['linkstr'], $options['link']));
         $links = $pagelist->get_metas('link');
         $infos = array();
         if (is_array($options['info'])) {
             $pagelist->gen_metas('info', array($options['info']));
             $infos = $pagelist->get_metas('info');
         }
         $tocs = array();
         if (isset($options['contents'])) {
             $pages = $pagelist->get_metas('page');
             foreach ($pages as $i => $page) {
                 $toc_options = PluginContentsx::check_options($page, '', $options['contents']);
                 $tocs[$i] = PluginContentsx::display_toc($page, $toc_options);
             }
         }
         $items = array();
         foreach ($links as $i => $link) {
             $items[$i] = $links[$i];
             if (isset($infos[$i])) {
                 $items[$i] .= ' ' . $infos[$i];
             }
             if (isset($tocs[$i])) {
                 $items[$i] .= $tocs[$i];
             }
         }
         $levels = $pagelist->get_metas('depth');
         $html = sonots::display_list($items, $levels, $this->plugin);
     }
     if ($options['next'] && is_array($options['num'])) {
         $argoptions['tag'] = $options['tag'];
         unset($argoptions['num']);
         $argoptions = array_intersect_key($argoptions, $options);
         $argline = PluginSonotsOption::glue_uri_option_line($argoptions);
         $basehref = get_script_uri() . '?cmd=' . $this->plugin;
         $basehref .= empty($argline) ? '' : '&' . htmlspecialchars($argline);
         $current = PluginSonotsOption::conv_interval($options['num']);
         $html .= $pagelist->display_navi($current, array(1, $max), $basehref, $this->plugin);
     }
     return $html;
 }
Ejemplo n.º 2
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);
 }
Ejemplo n.º 3
0
 /**
  * List pages
  *
  * @param array $pages
  * @param array $options
  * @param array $argoptions
  * @return string html
  */
 function pagelist($pages, $options, $argoptions)
 {
     $pagelist = new PluginSonotsPagelist($pages);
     if ($options['non_list']) {
         $pattern = '/' . $GLOBALS['non_list'] . '/';
         $pagelist->grep_by('page', 'preg', $pattern, true);
         // inverse
     }
     if (isset($options['filter']) && $options['filter'] !== '') {
         $pagelist->grep_by('relname', 'preg', '/' . str_replace('/', '\\/', $options['filter']) . '/');
     }
     if (isset($options['except'])) {
         $pagelist->grep_by('relname', 'preg', '/' . str_replace('/', '\\/', $options['except']) . '/', true);
         // inverse
     }
     if (isset($options['newpage'])) {
         switch ($options['newpage']) {
             case 'on':
                 $pagelist->gen_metas('newpage');
                 $pagelist->grep_by('newpage', 'eq', true);
                 break;
             case 'except':
             case 'off':
                 $pagelist->gen_metas('newpage');
                 $pagelist->grep_by('newpage', 'eq', false);
                 break;
             default:
                 break;
         }
     }
     if (isset($options['depth']) || $options['tree']) {
         $pagelist->gen_metas('depth');
     }
     if (isset($options['depth'])) {
         // do not use negative interval for depth
         list($min, $max) = PluginSonotsOption::conv_interval($options['depth'], array(1, PHP_INT_MAX));
         $pagelist->grep_by('depth', 'ge', $min);
         $pagelist->grep_by('depth', 'le', $max);
     }
     switch ($options['tree']) {
         case 'leaf':
             $pagelist->gen_metas('leaf');
             $pagelist->grep_by('leaf', 'eq', true);
             break;
         case 'dir':
             $pagelist->gen_metas('leaf');
             $pagelist->grep_by('leaf', 'eq', false);
             break;
         default:
             break;
     }
     if (isset($options['popular'])) {
         $pagelist->gen_metas('popular', array($options['popular']));
     }
     $pagelist->sort_by('popular', $options['reverse']);
     $max = count($pagelist->metapages);
     // for next option
     if (is_array($options['num'])) {
         list($offset, $length) = $options['num'];
         $pagelist->slice($offset, $length);
     }
     //// display
     $pagelist->gen_metas('linkstr', array($options['linkstr']));
     $linkstrs = $pagelist->get_metas('linkstr');
     $pages = $pagelist->get_metas('page');
     $counts = $pagelist->get_metas('popular');
     $links = $this->get_popular_links($pages, $linkstrs, $counts, $GLOBALS['var']['page']);
     if (empty($links)) {
         return '<p>#' . $this->plugin . '(): no counter information is available.</p>';
     }
     $levels = array_map(create_function('', 'return 1;'), $links);
     $html = sonots::display_list($links, $levels, 'popularx');
     //// display navi. $max is needed, $argoptions is need.
     if ($options['next'] && is_array($options['num'])) {
         $argoptions['popular'] = $options['popular'];
         unset($argoptions['num']);
         $argoptions = array_intersect_key($argoptions, $options);
         $argline = PluginSonotsOption::glue_uri_option_line($argoptions);
         $basehref = get_script_uri() . '?cmd=' . $this->plugin;
         $basehref .= empty($argline) ? '' : '&amp;' . htmlspecialchars($argline);
         $current = PluginSonotsOption::conv_interval($options['num']);
         $html .= $pagelist->display_navi($current, array(1, $max), $basehref, $this->plugin);
     }
     return $html;
 }
Ejemplo n.º 4
0
 /**
  * Get HTML of page list
  *
  * @access public
  * @param string $cssclass css class
  * @return string list html
  * @version $Id: v 1.0 2008-06-07 07:23:17Z sonots $
  */
 function display_pages($cssclass = '')
 {
     $items = $this->get_metas('link');
     $levels = $this->get_metas('depth');
     return sonots::display_list($items, $levels, $cssclass);
 }