/** * 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; }