コード例 #1
0
function wpm_move_item($old_item_id, $new_parent_id)
{
    if ($old_item_id == 0) {
        return false;
    }
    $old_item = wpm_old_read_node($old_item_id);
    $new_item = wpm_create_child($new_parent_id, unserialize(serialize($old_item)));
    wpm_move_item($old_item->down, $new_item->id);
    wpm_move_item($old_item->side, $new_parent_id);
    return true;
}
コード例 #2
0
function wpm_append_nodes($id)
{
    global $wpm_options;
    $wpm_options->update_option = false;
    $item = wpm_readnode($id);
    switch ($item->type) {
        case 'TagList':
            $item->down = 0;
            _wpm_update_links($item);
            $node->type = 'Heading';
            $node->name = wpm_display_name($item);
            wpm_update_node($item->id, $node);
            $tags = wpm_get_tags();
            foreach ($tags as $tag) {
                if (in_array($tag->term_id, (array) $item->exclude)) {
                    continue;
                }
                $node->type = 'Tag';
                $node->name = $tag->name;
                $node->selection = $tag->term_id;
                wpm_create_child($item->id, $node);
            }
            break;
        case 'CategoryTree':
            $item->down = 0;
            _wpm_update_links($item);
            $node->type = !$item->selection || in_array($item->selection, (array) $item->headings) ? 'Heading' : 'Category';
            $node->name = wpm_display_name($item);
            wpm_update_node($item->id, $node);
            $cats = wpm_get_cats();
            $newparents = array($item->selection);
            while (++$level) {
                if ($item->depth > 0 && $level > $item->depth) {
                    break;
                }
                if (count($newparents) == 0) {
                    break;
                }
                $parents = $newparents;
                $newparents = array();
                foreach ($cats as $cat) {
                    if (in_array($cat->term_id, (array) $item->exclude)) {
                        continue;
                    }
                    if (in_array($cat->parent, $parents)) {
                        $newparents[] = $cat->term_id;
                        $node->type = in_array($cat->term_id, (array) $item->headings) ? 'Heading' : 'Category';
                        $node->name = get_cat_name($cat->term_id);
                        $node->selection = $cat->term_id;
                        $parent = wpm_find_node($item->id, 'selection', $cat->parent);
                        wpm_create_child($parent->id, $node);
                    }
                }
            }
            break;
        case 'PageTree':
            $item->down = 0;
            _wpm_update_links($item);
            $node->type = !$item->selection || in_array($item->selection, (array) $item->headings) ? 'Heading' : 'Page';
            $node->name = wpm_display_name($item);
            wpm_update_node($item->id, $node);
            $pages = wpm_get_pages();
            $newparents = array($item->selection);
            while (++$level) {
                if ($item->depth > 0 && $level > $item->depth) {
                    break;
                }
                if (count($newparents) == 0) {
                    break;
                }
                $parents = $newparents;
                $newparents = array();
                foreach ($pages as $page) {
                    if (in_array($page->ID, (array) $item->exclude)) {
                        continue;
                    }
                    if (in_array($page->post_parent, $parents)) {
                        $newparents[] = $page->ID;
                        $node->type = in_array($page->ID, (array) $item->headings) ? 'Heading' : 'Page';
                        $node->name = get_the_title($page->ID);
                        $node->selection = $page->ID;
                        $parent = wpm_find_node($item->id, 'selection', $page->post_parent);
                        wpm_create_child($parent->id, $node);
                    }
                }
            }
            break;
    }
    $wpm_options->update_option = true;
}
コード例 #3
0
     if ($wpm_item->type == 'Category') {
         $wpm_item->type = 'CategoryTree';
     }
     if ($wpm_item->type == 'Tag') {
         break;
     }
 }
 if ($order == 0) {
     $created = wpm_create_child($menuid, $wpm_item);
 } else {
     switch ($order) {
         case '1':
             $created = wpm_create_before($orderid, $wpm_item);
             break;
         case '2':
             $created = wpm_create_child($orderid, $wpm_item);
             break;
         case '3':
             $created = wpm_create_after($orderid, $wpm_item);
             break;
         default:
             $created = 0;
             break;
     }
 }
 if ($created) {
     $msg = 1;
 } else {
     $msg = 4;
 }
 break;