function make_heading(&$str, $strip = TRUE) { return Rules::getHeading($str, $strip); }
function plugin_ls2_get_headings($page, &$params, $level, $include = FALSE) { static $_ls2_anchor = 0; // ページが未表示のとき $is_done = isset($params["page_{$page}"]) && $params["page_{$page}"] > 0; if (!$is_done) { $params["page_{$page}"] = ++$_ls2_anchor; } $s_page = Utility::htmlsc($page); $wiki = Factory::Wiki($page); $title = $s_page . ' ' . $wiki->passage(false, true); $href = $wiki->uri(); plugin_ls2_list_push($params, $level); $ret = $include ? '<li>include ' : '<li>'; if ($params['title'] && $is_done) { $ret .= '<a href="' . $href . '" title="' . $title . '">' . $s_page . '</a> '; $ret .= '<a href="#list_' . $params["page_{$page}"] . '"><sup>↑</sup></a>'; array_push($params['result'], $ret); return; } $ret .= '<a id="list_' . $params["page_{$page}"] . '" href="' . $href . '" title="' . $title . '">' . $s_page . '</a>'; array_push($params['result'], $ret); $anchor = PLUGIN_LS2_ANCHOR_ORIGIN; $matches = array(); foreach ($wiki->get() as $line) { if ($params['title'] && preg_match('/^(\\*{1,3})/', $line, $matches)) { list($heading, $id) = Rules::getHeading($line); $level = strlen($matches[1]); plugin_ls2_list_push($params, $level + strlen($level)); array_push($params['result'], '<li><a href="' . $href . '#' . $id . '">' . $heading . '</a>'); } else { if ($params['include'] && preg_match('/^#include\\((.+)\\)/', $line, $matches) && is_page($matches[1])) { plugin_ls2_get_headings($matches[1], $params, $level + 1, TRUE); } } } }
public function getAnchor($text, $level) { global $top; global $fixed_heading_edited; // Plus! // Heading id (auto-generated) $autoid = 'content_' . $this->id . '_' . $this->count; $this->count++; $anchor = ''; // Heading id (specified by users) list($_text, $id, $level) = Rules::getHeading($text, false); // Cut fixed-anchor from $text //var_dump(Rules::getHeading($text, false)); if (empty($id)) { // Not specified $id = $autoid; } else { if ($fixed_heading_edited) { //$anchor = ' &aname(' . $id . ',super,full){' . $_symbol_anchor . '};'; //if ($fixed_heading_edited) $anchor .= " &edit(,$id);"; $anchor = ' &edit(,' . $id . ');'; } } //var_dump($text, $id, $level); // Add 'page contents' link to its heading $contents = new ContentsList($_text, $level, $id); $this->contents_last = $this->contents_last->add($contents); // Add heding return array($_text . $anchor, $this->count > 1 ? "\n" . $top : '', $autoid); }
public function toString() { list($this->text, $fixed_anchor) = Rules::getHeading($this->text, FALSE); $id = empty($fixed_anchor) ? $this->id : $fixed_anchor; return $this->msg_top . $this->wrap(parent::toString(), 'h' . $this->level, ' id="' . $id . '"'); }