当前位置: 首页>>代码示例>>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;未经允许,请勿转载。