/** * Applies the callback to the members of the given array objects * * PHP API Extension * * @access public * @static * @param array &$objects array of objects * @param string $name member name * @param callback $callback * @return void * @version $Id: v 1.0 2008-06-10 11:14:46 sonots $ * @since 1.10 */ function map_members(&$objects, $name, $callback) { $members = sonots::get_members($objects, $name); $members = array_map($callback, $members); sonots::set_members($objects, $name, $members); }
/** * Reverse expand_includes * * @access public * @return void * @see expand_includes */ function shrink_includes() { $pages = sonots::get_members($this->headlines, 'page'); $keys = sonots::grep_array($this->page, $pages, 'eq'); $this->headlines = array_intersect_key($this->headlines, $keys); }
function get_sections($lines, $page, $options) { $toc = new PluginSonotsToc($page, $options['cache']); $headlines = $toc->get_headlines(); if (isset($options['filter'])) { sonots::grep_by($headlines, 'string', 'preg', '/' . str_replace('/', '\\/', $options['filter']) . '/'); } if (isset($options['except'])) { sonots::grep_by($headlines, 'string', 'preg', '/' . str_replace('/', '\\/', $options['except']) . '/', TRUE); // inverse } if (is_array($options['depth'])) { // Do not use negative offsets list($min, $max) = PluginSonotsOption::conv_interval($options['depth'], array(1, PHP_INT_MAX)); sonots::grep_by($headlines, 'depth', 'ge', $min); sonots::grep_by($headlines, 'depth', 'le', $max); } $outlines = array(); if (is_array($options['num'])) { array_unshift($headlines, new PluginSonotsHeadline($page, 0, 0, '', '')); list($offset, $length) = $options['num']; $headlines = sonots::array_slice($headlines, $offset, $length, true); } $linenums = sonots::get_members($headlines, 'linenum'); // extract from current head till next head - 1 $allheadlines = $toc->get_headlines(); $alllinenums = sonots::get_members($allheadlines, 'linenum'); if (!isset($alllinenums[0])) { array_unshift($alllinenums, 0); } // virtual head at the file head array_push($alllinenums, end(array_keys($lines)) + 1); // virtual head at the file tail $outlines = array(); $current = 0; foreach ($alllinenums as $next) { if (in_array($current, $linenums)) { if ($next == $current) { continue; } $outlines += sonots::array_slice($lines, $current, $next - $current, true); } $current = $next; } return $outlines; }
/** * Get the specific meta informations of pages * * @access public * @param string $metakey meta information name * @return array metas * @version $Id: v 1.0 2008-06-07 07:23:17Z sonots $ */ function get_metas($metakey) { return sonots::get_members($this->metapages, $metakey); }