function test_get_tree() { $pages = array('test/a', 'test/a/aa', 'test/a/aa/aaa', 'test/a/bb/bbb', 'test/c/cc/ccc', 'test/c'); $parse = sonots::get_tree($pages); $truth = array('test/a' => false, 'test/a/aa' => false, 'test/a/aa/aaa' => true, 'test/a/bb/bbb' => true, 'test/c' => false, 'test/c/cc/ccc' => true); $this->assertEqual($parse, $truth); }
/** * Generate the specific meta infomration to pages * * @access public * @param string $metakey meta information name * @param array $args if arguments required to set meta information * @version $Id: v 1.0 2008-06-07 07:23:17Z sonots $ */ function gen_metas($metakey, $args = array()) { switch ($metakey) { case 'leaf': // tree can't be constructed item by item $leafs = sonots::get_tree(get_existpages()); foreach ($this->metapages as $i => $val) { $page = $this->metapages[$i]->page; $this->metapages[$i]->leaf = $leafs[$page]; } break; default: // others can be $metapages =& $this->metapages; foreach ($metapages as $i => $val) { call_user_func_array(array(&$metapages[$i], 'gen_' . $metakey), $args); } break; } }