The page you are looking at now is at this URL: http://pastoid.com/b0n
This paste was last updated on March 1, 2010 at 3:19 pm.
/** * Retrieve the vocabulary * @return Array The Term objects in the vocabulary, in tree order **/ public function get_tree($orderby = 'mptt_left ASC') { return DB::get_results( "SELECT * FROM {terms} WHERE vocabulary_id=:vid ORDER BY {$orderby}", array('vid' => $this->id), 'Term' ); } /** * Retrieve the vocabulary as an associative array suitable for FormUI select controls * @return Array The Term objects in the vocabulary, in tree order **/ public function get_options() { $tree = $this->get_tree('mptt_left ASC'); $output = array(); $lastright = $lastleft = reset($tree)->mptt_left; $indent = 0; $stack = array(); foreach($tree as $term) { while ( count($stack) > 0 && end($stack)->mptt_right < $term->mptt_left ) { array_pop($stack); } $output[$term->id] = str_repeat('- ', count($stack)) . $term->term_display; $stack[] = $term; } return $output; }
//create the vocabulary in hconsole $x = Vocabulary::get( 'categories' ); foreach($x->get_tree() as $t) {$x->delete_term($t);} $x->add_term( 'A' ); $x->add_term( 'G' ); $x->add_term( 'H' ); $x->add_term( 'B',$x->get_term('A') ); $x->add_term( 'E',$x->get_term('A') ); $x->add_term( 'C',$x->get_term('B') ); $x->add_term( 'D',$x->get_term('B') ); $x->add_term( 'F',$x->get_term('E') ); $out = array(); foreach($x->get_tree() as $t) {$out[] = $t->mptt_left.$t->term. $t->mptt_right;} Utils::debug($x->get_options(), implode(' ', $out)); $source = $x->get_term('E'); $target = $x->get_term('H'); $x->move_term($source,$target,true); $out = array(); foreach($x->get_tree() as $t) {$out[] = $t->mptt_left.$t->term. $t->mptt_right;} Utils::debug($x->get_options(),implode(' ', $out));
| Referring Domain | Hits |
|---|---|
| Unknown Referer | 137 |
| drunkenmonkey.org | 1 |
| pastoid.com | 1 |
Tip: Use Pastoid to shorten URLs with this bookmarklet: Pastoid This