當前位置: 首頁>>代碼示例>>PHP>>正文


PHP rebuild_tree函數代碼示例

本文整理匯總了PHP中rebuild_tree函數的典型用法代碼示例。如果您正苦於以下問題:PHP rebuild_tree函數的具體用法?PHP rebuild_tree怎麽用?PHP rebuild_tree使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了rebuild_tree函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: Rebuild_tree

function Rebuild_tree($parent, $left)
{
    // el valor derecho de este nodo es valor izquierdo+1
    $right = $left + 1;
    //Si $parent es 0 buscamos la raiz.
    if ($parent == 0) {
        $result = mysqli_query($mysqli, "SELECT id FROM secciones WHERE padre is null");
        if ($result) {
            $row = mysqli_fetch_array($result);
            $parent = $row["id"];
        }
    }
    // seleccionar todos los hijos de este nodo
    $result = mysqli_query($mysqli, "SELECT id FROM secciones WHERE padre={$parent} ORDER BY nombre ASC;");
    while ($row = mysqli_fetch_array($result)) {
        // ejecucion recursiva de esta función
        // hijo de este nodo
        // $right es el valor actual izquierdo, el cual
        // se incrementa por la función rebuild_tree
        $right = rebuild_tree($row["id"], $right);
    }
    // tenemos el valor izquierdo, y ahora procesamos
    // el hjo de este nodo del cual conocemos el valor derecho.
    mysqli_query($mysqli, "UPDATE secciones SET lft={$left} , rgt={$right} WHERE id={$parent};");
    // return the right value of this node + 1
    return $right + 1;
}
開發者ID:pabalexa,項目名稱:handyq03,代碼行數:27,代碼來源:directoryhowto6.php

示例2: rebuild_tree

function rebuild_tree($parent, $left)
{
    // the right value of this node is the left value + 1
    $right = $left + 1;
    // get all children of this node
    $result = mysql_query('SELECT title FROM tree ' . 'WHERE parent="' . $parent . '";');
    while ($row = mysql_fetch_array($result)) {
        // recursive execution of this function for each
        // child of this node
        // $right is the current right value, which is
        // incremented by the rebuild_tree function
        $right = rebuild_tree($row['title'], $right);
    }
    // we've got the left value, and now that we've processed
    // the children of this node we also know the right value
    mysql_query('UPDATE tree SET lft=' . $left . ', rgt=' . $right . ' WHERE title="' . $parent . '";');
    // return the right value of this node + 1
    return $right + 1;
}
開發者ID:nopticon,項目名稱:mag,代碼行數:19,代碼來源:tree.php

示例3: rebuild_tree

function rebuild_tree($parent, $parentName, $parentSanitizedCategoryName, $categoryRank, $url = '')
{
    // get all children of this node
    $result = mysql_query('SELECT CategoryID,CategoryName,SanitizedCategoryName,CategoryRank FROM AdjacencyListCategories ' . 'WHERE ParentCategoryID=' . $parent) or die('CreateCategoryUrls.php: SELECT query failed: ' . mysql_error());
    $this_url = '';
    while ($row = mysql_fetch_array($result)) {
        // recursive execution of this function for each
        // child of this node
        // $right is the current right value, which is
        // incremented by the rebuild_tree function
        $this_url = $url . $row['SanitizedCategoryName'] . '/';
        rebuild_tree($row['CategoryID'], $row['CategoryName'], $row['SanitizedCategoryName'], $row['CategoryRank'], $this_url);
    }
    $result = mysql_query("UPDATE ModifiedPreorderTreeTraversalCategories SET CategoryUrl='" . $url . "' WHERE CategoryID=" . $parent) or die('CreateCategoryUrls.php: UPDATE ModifiedPreorderTreeTraversalCategories SET CategoryUrl query failed: ' . mysql_error());
    echo "\ncategory {$parentName} url = {$url}";
    mysql_free_result($result);
    $parentName = mysql_escape_string($parentName);
    return;
}
開發者ID:jassenm,項目名稱:mongotickets_php,代碼行數:19,代碼來源:CreateCategoryUrls.php

示例4: rebuild_tree

function rebuild_tree($parent, $parentName, $parentSanitizedCategoryName, $categoryRank, $left, $depth)
{
    // the right value of this node is the left value + 1
    $right = $left + 1;
    $depth = $depth + 1;
    // get all children of this node
    $result = mysql_query('SELECT CategoryID,CategoryName,SanitizedCategoryName,CategoryRank FROM AdjacencyListCategories_temp ' . 'WHERE ParentCategoryID=' . $parent) or die('SELECT query failed: ' . mysql_error());
    while ($row = mysql_fetch_array($result)) {
        // recursive execution of this function for each
        // child of this node
        // $right is the current right value, which is
        // incremented by the rebuild_tree function
        $right = rebuild_tree($row['CategoryID'], $row['CategoryName'], $row['SanitizedCategoryName'], $row['CategoryRank'], $right, $depth);
    }
    mysql_free_result($result);
    // we've got the left value, and now that we've processed
    // the children of this node we also know the right value
    $parentName = mysql_escape_string($parentName);
    $result = mysql_query("INSERT INTO ModifiedPreorderTreeTraversalCategories_temp (CategoryID, CategoryName, SanitizedCategoryName, lft, rgt, CategoryRank, Depth) VALUES (" . $parent . ",'" . $parentName . "','" . $parentSanitizedCategoryName . "'," . $left . "," . $right . "," . $categoryRank . "," . $depth . ")") or die('INSERT INTO ModifiedPreorderTreeTraversalCategories_temp query failed: ' . mysql_error());
    // return the right value of this node + 1
    return $right + 1;
}
開發者ID:jassenm,項目名稱:mongotickets_php,代碼行數:22,代碼來源:CreateModifiedPreorderTreeOfCategories.php

示例5: rebuild_tree

function rebuild_tree($parent, $left, $pr)
{
    global $db;
    // the right value of this node is the left value + 1
    $right = $left + 1;
    // get all children of this node
    $result = $db->Query('SELECT category_id FROM {list_category} WHERE parent_id = ? AND project_id = ?', array($parent, $pr));
    while ($row = $db->FetchRow($result)) {
        // recursive execution of this function for each
        // child of this node
        // $right is the current right value, which is
        // incremented by the rebuild_tree function
        $right = rebuild_tree($row['category_id'], $right, $pr);
    }
    // we've got the left value, and now that we've processed
    // the children of this node we also know the right value
    $db->Query('UPDATE {list_category} SET lft= ?, rgt= ? WHERE category_id = ?', array($left, $right, $parent));
    $sql = $db->Query('SELECT * FROM {list_category} WHERE category_id = ? OR project_id=? AND parent_id=-1', array($parent, $pr));
    if (!$db->CountRows($sql)) {
        $db->Query('INSERT INTO {list_category} (project_id, lft, rgt, category_name, parent_id) VALUES(?,?,?,?,-1)', array($pr, $left, $right, 'root'));
    }
    // return the right value of this node + 1
    return $right + 1;
}
開發者ID:canneverbe,項目名稱:flyspray,代碼行數:24,代碼來源:convert_categories.php

示例6: rebuild_tree

 function rebuild_tree($parent, $left)
 {
     // the right value of this node is the left value + 1
     $right = $left + 1;
     // get all children of this node
     $result = $this->_db()->where('parent', $parent)->get($this->_name)->result_array();
     foreach ($result as $row) {
         // recursive execution of this function for each
         // child of this node
         // $right is the current right value, which is
         // incremented by the rebuild_tree function
         $right = rebuild_tree($row['id'], $right);
     }
     // we've got the left value, and now that we've processed
     // the children of this node we also know the right value
     $this->save(array('lft' => $left, 'rgt' => $right), $parent);
     // return the right value of this node + 1
     return $right + 1;
 }
開發者ID:rip-projects,項目名稱:ark-php,代碼行數:19,代碼來源:base_model.php

示例7: rebuild_tree_full

/**
 * Rebuilds a tree.
 *
 * This function is used by categories.
 *
 * @param  string $type   The category type
 * @param  string $tbl    The table
 * @return int The next left ID
 */
function rebuild_tree_full($type, $tbl = 'txp_category')
{
    // Fix circular references, otherwise rebuild_tree() could get stuck in a loop.
    safe_update($tbl, "parent = ''", "type = '" . doSlash($type) . "' AND name = 'root'");
    safe_update($tbl, "parent = 'root'", "type = '" . doSlash($type) . "' AND parent = name");
    rebuild_tree('root', 1, $type, $tbl);
}
開發者ID:ClaireBrione,項目名稱:textpattern,代碼行數:16,代碼來源:txplib_db.php

示例8: rebuild_tree_full

function rebuild_tree_full($type)
{
    # fix circular references, otherwise rebuild_tree() could get stuck in a loop
    safe_update('txp_category', "parent=''", "type='" . doSlash($type) . "' and name='root'");
    safe_update('txp_category', "parent='root'", "type='" . doSlash($type) . "' and parent=name");
    rebuild_tree('root', 1, $type);
}
開發者ID:bgarrels,項目名稱:textpattern,代碼行數:7,代碼來源:txplib_db.php

示例9: start_import

function start_import()
{
    global $vars;
    extract(psa($vars));
    $insert_into_section = $Section;
    $insert_with_status = $type;
    $default_comment_invite = $comments_invite;
    include_once txpath . '/include/import/import_' . $import_tool . '.php';
    $ini_time = ini_get('max_execution_time');
    @ini_set('max_execution_time', 300 + intval($ini_time));
    switch ($import_tool) {
        case 'mtdb':
            $out = doImportMTDB($importdblogin, $importdb, $importdbpass, $importdbhost, $blog_id, $insert_into_section, $insert_with_status, $default_comment_invite);
            rebuild_tree('root', 1, 'article');
            break;
        case 'mt':
            $file = check_import_file();
            if (!empty($file)) {
                $out = doImportMT($file, $insert_into_section, $insert_with_status, $comments_invite);
                //Rebuilding category tree
                rebuild_tree('root', 1, 'article');
            } else {
                $out = 'Import file not found';
            }
            break;
        case 'b2':
            $out = doImportB2($importdblogin, $importdb, $importdbpass, $importdbhost, $insert_into_section, $insert_with_status, $default_comment_invite);
            break;
        case 'wp':
            $out = doImportWP($importdblogin, $importdb, $importdbpass, $importdbhost, $wpdbprefix, $insert_into_section, $insert_with_status, $default_comment_invite);
            rebuild_tree('root', 1, 'article');
            break;
        case 'blogger':
            $file = check_import_file();
            if (!empty($file)) {
                $out = doImportBLOGGER($file, $insert_into_section, $insert_with_status, $comments_invite);
            } else {
                $out = gTxt('import_file_not_found');
            }
            break;
    }
    $out = tag('max_execution_time = ' . ini_get('max_execution_time'), 'p', ' style="color:red;"') . $out;
    pagetop(gTxt('txp_import'));
    $content = startTable('list');
    $content .= tr(tdcs(hed(gTxt('txp_import'), 3), 2));
    $content .= tr(td($out));
    $content .= endTable();
    echo $content;
}
開發者ID:bgarrels,項目名稱:textpattern,代碼行數:49,代碼來源:txp_import.php

示例10: rebuild_tree

function rebuild_tree($content, $left)
{
    global $sqlfp;
    $right = $left + 1;
    if (array_key_exists("items", $content)) {
        $last = sizeof($content['items']) - 1;
        if ($content['items'][$last]['type'] == "photo") {
            $content['items'] = array();
        }
        foreach ($content['items'] as $val) {
            $right = rebuild_tree($val, $right);
        }
        $query = "update " . KOKEN_PREFIX . "albums set left_id=" . $left . ",right_id=" . $right . " where id='" . $content['id'] . "'";
        fwrite($sqlfp, $query . ";\n");
        return $right + 1;
    }
    return $left;
}
開發者ID:softcat,項目名稱:gallery_to_koken,代碼行數:18,代碼來源:g1_to_koken.php

示例11: rebuild_tree

function rebuild_tree($parent, $left, $db, $table)
{
    // the right value of this node is the left value + 1
    $right = $left + 1;
    //抓取所有子節點
    $sql = "SELECT id FROM " . $table . " WHERE parent_id ='" . $parent . "' ORDER BY sort asc,lft asc";
    //order by sort,lft asc 最要 有了這個才會依據此排序
    $rs = $db->Execute($sql);
    if (!$rs) {
        Error($db);
    }
    while ($row = $rs->FetchRow()) {
        // recursive execution of this function for each
        // child of this node
        // $right is the current right value, which is
        // incremented by the rebuild_tree function
        $right = rebuild_tree($row['id'], $right, $db, $table);
    }
    // we've got the left value, and now that we've processed
    // the children of this node we also know the right value
    $sql = "UPDATE " . $table . " SET lft='" . $left . "', rgt='" . $right . "' WHERE id='" . $parent . "'";
    $rs = $db->Execute($sql);
    if (!$rs) {
        Error($db);
    }
    // return the right value of this node + 1
    return $right + 1;
}
開發者ID:Jonesyei,項目名稱:modelphp,代碼行數:28,代碼來源:seback_func.php

示例12: rebuild_tree

function rebuild_tree($parent, $left, $type)
{
    $right = $left + 1;
    $parent = doSlash($parent);
    $result = safe_column("name", "txp_category", "parent='{$parent}' and type='{$type}' order by name");
    foreach ($result as $row) {
        $right = rebuild_tree($row, $right, $type);
    }
    safe_update("txp_category", "lft={$left}, rgt={$right}", "name='{$parent}' and type='{$type}'");
    return $right + 1;
}
開發者ID:bgarrels,項目名稱:textpattern,代碼行數:11,代碼來源:txplib_db.php

示例13: rebuild_the_tree

function rebuild_the_tree()
{
    rebuild_tree(0, 0, table_categories, "category__auto_id", "category_parent");
}
開發者ID:holsinger,項目名稱:openfloor,代碼行數:4,代碼來源:dbtree.php

示例14: addslashes

    $tempdir = addslashes(find_temp_dir());
    safe_insert('txp_prefs', "prefs_id=1,name='tempdir',val='{$tempdir}'");
}
//non image file upload tab:
if (!safe_field('val', 'txp_prefs', "name='file_list_pageby'")) {
    safe_insert('txp_prefs', "val=25,name='file_list_pageby',prefs_id=1");
}
// 1.0: max file upload size
if (!safe_field('val', 'txp_prefs', "name='file_max_upload_size'")) {
    safe_insert('txp_prefs', "prefs_id=1,name='file_max_upload_size',val=2000000");
}
// 1.0: txp_file root cat
if (!safe_field('name', 'txp_category', "type='file' AND name='root'")) {
    safe_insert('txp_category', "name='root',type='file',lft=1,rgt=0");
}
rebuild_tree('root', 1, 'file');
// 1.0: txp_file folder
if (!safe_field('val', 'txp_prefs', "name='file_base_path'")) {
    safe_insert('txp_prefs', "val='{$tempdir}',name='file_base_path',prefs_id=1");
}
// 1.0: txp_file table
if (!safe_query("SELECT 1 FROM `" . PFX . "txp_file` LIMIT 0")) {
    // do install
    safe_query("CREATE TABLE `" . PFX . "txp_file` (\n\t\t\t\t`id` int(11) NOT NULL auto_increment,\n\t\t\t\t`filename` varchar( 255 ) NOT NULL default '',\n\t\t\t\t`category` varchar( 255 ) NOT NULL default '',\n\t\t\t\t`permissions` varchar( 32 ) NOT NULL DEFAULT '0',\n\t\t\t\t`description` text NOT NULL default '',\n\t\t\t\t`downloads` int(4) unsigned NOT NULL default '0',\n\t\t\t\tPRIMARY KEY ( `id` ) ,\n\t\t\t\tUNIQUE KEY `filename` ( `filename` )\n\t\t\t) {$tabletype} PACK_KEYS=0 AUTO_INCREMENT=1 ");
}
if (!safe_field('name', 'txp_form', "type='file'")) {
    safe_insert('txp_form', "\n\t\t\tname='files',\n\t\t\ttype='file',\n\t\t\tForm='<txp:text item=\"file\" />: \n<txp:file_download_link>\n<txp:file_download_name /> [<txp:file_download_size format=\"auto\" decimals=\"2\" />]\n</txp:file_download_link>\n<br />\n<txp:text item=\"category\" />: <txp:file_download_category /><br />\n<txp:text item=\"download\" />: <txp:file_download_downloads />'");
}
//eof: non image file upload tab
// 1.0: improved comment spam nonce
$txpnonce = getThings('describe `' . PFX . 'txp_discuss_nonce`');
開發者ID:psic,項目名稱:websites,代碼行數:31,代碼來源:_to_1.0.0.php

示例15: create_ctree

function create_ctree()
{
    global $windows, $ctree_data, $book_closed_xpm, $book_open_xpm;
    if (!isset($windows['ctree'])) {
        function rebuild_tree($button, $ctree)
        {
            global $ctree_data;
            $d = $ctree_data['spin1']->get_value_as_int();
            $b = $ctree_data['spin2']->get_value_as_int();
            $p = $ctree_data['spin3']->get_value_as_int();
            $n = intval((pow($b, $d) - 1) / ($b - 1)) * ($p + 1);
            if ($n > 100000) {
                print "{$n} total items? Try less\n";
                return;
            }
            $ctree_data['books'] = 1;
            $ctree_data['pages'] = 0;
            $ctree->freeze();
            $ctree->clear();
            $text = array('Root', '');
            $parent = $ctree->insert_node(null, null, $text, 5, $ctree_data['pixmap1'], $ctree_data['mask1'], $ctree_data['pixmap2'], $ctree_data['mask2'], false, true);
            $style =& new GtkStyle();
            $style->base[GTK_STATE_NORMAL] = new GdkColor(0, 45000, 55000);
            $ctree->node_set_row_data($parent, $style);
            if ($ctree->line_style == GTK_CTREE_LINES_TABBED) {
                $ctree->node_set_row_style($parent, $style);
            }
            build_recursive($ctree, 1, $d, $b, $p, $parent);
            $ctree->thaw();
            after_press($ctree);
        }
        function build_recursive($ctree, $cur_depth, $depth, $num_books, $num_pages, $parent)
        {
            global $ctree_data;
            $sibling = null;
            for ($i = $num_pages + $num_books; $i > $num_books; $i--) {
                $ctree_data['pages']++;
                $text[0] = sprintf('Page %02d', rand() % 100);
                $text[1] = sprintf('Item %d-%d', $cur_depth, $i);
                $sibling = $ctree->insert_node($parent, $sibling, $text, 5, $ctree_data['pixmap3'], $ctree_data['mask3'], null, null, true, false);
                if ($parent && $ctree->line_style == GTK_CTREE_LINES_TABBED) {
                    $ctree->node_set_row_style($sibling, $parent->row->style);
                }
            }
            if ($cur_depth == $depth) {
                return;
            }
            for ($i = $num_books; $i > 0; $i--) {
                $ctree_data['books']++;
                $text[0] = sprintf('Book %02d', rand() % 100);
                $text[1] = sprintf('Item %d-%d', $cur_depth, $i);
                $sibling = $ctree->insert_node($parent, $sibling, $text, 5, $ctree_data['pixmap1'], $ctree_data['mask1'], $ctree_data['pixmap2'], $ctree_data['mask2'], false, false);
                $style =& new GtkStyle();
                switch ($cur_depth % 3) {
                    case 0:
                        $color =& new GdkColor(10000 * ($cur_depth % 6), 0, 65535 - $i * 10000 % 65535);
                        $style->base[GTK_STATE_NORMAL] = $color;
                        break;
                    case 1:
                        $color =& new GdkColor(10000 * ($cur_depth % 6), 65535 - $i * 10000 % 65535, 0);
                        $style->base[GTK_STATE_NORMAL] = $color;
                        break;
                    default:
                        $color =& new GdkColor(65535 - $i * 10000 % 65535, 0, 10000 * ($cur_depth % 6));
                        $style->base[GTK_STATE_NORMAL] = $color;
                        break;
                }
                $ctree->node_set_row_data($sibling, $style);
                if ($ctree->line_style == GTK_CTREE_LINES_TABBED) {
                    $ctree->node_set_row_style($sibling, $style);
                }
                build_recursive($ctree, $cur_depth + 1, $depth, $num_books, $num_pages, $sibling);
            }
        }
        function after_press($ctree)
        {
            global $ctree_data;
            $ctree_data['sel_label']->set_text(count($ctree->selection));
            $ctree_data['vis_label']->set_text($ctree->clist->rows);
            $ctree_data['book_label']->set_text($ctree_data['books']);
            $ctree_data['page_label']->set_text($ctree_data['pages']);
        }
        function ctree_click_column($ctree, $column)
        {
            if ($column == $ctree->sort_column) {
                if ($ctree->sort_type == GTK_SORT_ASCENDING) {
                    $ctree->set_sort_type(GTK_SORT_DESCENDING);
                } else {
                    $ctree->set_sort_type(GTK_SORT_ASCENDING);
                }
            } else {
                $ctree->set_sort_column($column);
            }
            $ctree->sort_recursive();
        }
        function change_row_height($adj, $ctree)
        {
            $ctree->set_row_height($adj->value);
        }
        function change_indent($adj, $ctree)
//.........這裏部分代碼省略.........
開發者ID:jenalgit,項目名稱:roadsend-php,代碼行數:101,代碼來源:gtk.php


注:本文中的rebuild_tree函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。