Пример #1
0
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;
}
Пример #2
0
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;
}
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;
}
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;
}
Пример #5
0
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;
}
Пример #6
0
 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;
 }
Пример #7
0
/**
 * 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);
}
Пример #8
0
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);
}
Пример #9
0
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;
}
Пример #10
0
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;
}
Пример #11
0
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;
}
Пример #12
0
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;
}
Пример #13
0
function rebuild_the_tree()
{
    rebuild_tree(0, 0, table_categories, "category__auto_id", "category_parent");
}
Пример #14
0
    $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`');
Пример #15
0
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)
        {
            $ctree->set_indent($adj->value);
        }
        function change_spacing($adj, $ctree)
        {
            $ctree->set_spacing($adj->value);
        }
        function expand_all($button, $ctree)
        {
            $ctree->expand_recursive();
            after_press($ctree);
        }
        function collapse_all($button, $ctree)
        {
            $ctree->collapse_recursive();
            after_press($ctree);
        }
        function change_style($button, $ctree)
        {
            static $style1, $style2;
            if ($ctree->focus_row >= 0) {
                $node = $ctree->row_list[$ctree->focus_row];
            } else {
                $node = $ctree->row_list[0];
            }
            if (!is_object($node)) {
                return;
            }
            if (!isset($style1)) {
                $col1 =& new GdkColor(0, 56000, 0);
                $col2 =& new GdkColor(32000, 0, 56000);
                $style1 =& new GtkStyle();
                $style1->base[GTK_STATE_NORMAL] = $col1;
                $style1->fg[GTK_STATE_SELECTED] = $col2;
                $style2 =& new GtkStyle();
                $style2->base[GTK_STATE_SELECTED] = $col2;
                $style2->fg[GTK_STATE_NORMAL] = $col1;
                $style2->base[GTK_STATE_NORMAL] = $col2;
                $style2->font = gdk::font_load("-*-courier-medium-*-*-*-*-300-*-*-*-*-*-*");
            }
            $ctree->node_set_cell_style($node, 1, $style1);
            $ctree->node_set_cell_style($node, 0, $style2);
            if ($node->children) {
                $ctree->node_set_row_style($node->children[0], $style2);
            }
        }
        function select_all($button, $ctree)
        {
            $ctree->select_recursive();
            after_press($ctree);
        }
        function unselect_all($button, $ctree)
        {
            $ctree->unselect_recursive();
            after_press($ctree);
        }
        function count_items($ctree, $node)
        {
            global $ctree_data;
            if ($node->is_leaf) {
                $ctree_data['pages']--;
            } else {
                $ctree_data['books']--;
            }
        }
        function remove_selection($button, $ctree)
        {
            global $ctree_data;
            $ctree->freeze();
            while (($node = $ctree->selection[0]) !== null) {
                if ($node->is_leaf) {
                    $ctree_data['pages']--;
                } else {
                    $ctree->post_recursive($node, 'count_items');
                }
                $ctree->remove_node($node);
                if ($ctree->selection_mode == GTK_SELECTION_BROWSE) {
                    break;
                }
            }
            if ($ctree->selection_mode == GTK_SELECTION_EXTENDED && $ctree->selection[0] === null && $ctree->focus_row >= 0) {
                $node = $ctree->node_nth($ctree->focus_row);
                if ($node) {
                    $ctree->select($node);
                }
            }
            $ctree->thaw();
            after_press($ctree);
        }
        function set_background($ctree, $node)
        {
            if (!$node) {
                return;
            }
            if ($ctree->line_style != GTK_CTREE_LINES_TABBED) {
                if (!$node->is_leaf) {
                    $style = $ctree->node_get_row_data($node);
                } else {
                    $style = $ctree->node_get_row_data($node->parent);
                }
            }
            $ctree->node_set_row_style($node, $style);
        }
        function ctree_toggle_line_style($menu_item, $ctree, $line_style)
        {
            if ($ctree->line_style == GTK_CTREE_LINES_TABBED && $line_style != GTK_CTREE_LINES_TABBED || $ctree->line_style != GTK_CTREE_LINES_TABBED && $line_style == GTK_CTREE_LINES_TABBED) {
                $ctree->pre_recursive(null, 'set_background');
            }
            $ctree->set_line_style($line_style);
        }
        function ctree_toggle_expander_style($menu_item, $ctree, $expander_style)
        {
            $ctree->set_expander_style($expander_style);
        }
        function ctree_toggle_justify($menu_item, $ctree, $justification)
        {
            $ctree->set_column_justification($ctree->tree_column, $justification);
        }
        function ctree_toggle_sel_mode($menu_item, $ctree, $sel_mode)
        {
            $ctree->set_selection_mode($sel_mode);
            after_press($ctree);
        }
        $window =& new GtkWindow();
        $windows['ctree'] = $window;
        $window->connect('delete-event', 'delete_event');
        $window->set_title('GtkCTree');
        $window->set_border_width(0);
        $tooltips =& new GtkTooltips();
        $vbox =& new GtkVBox();
        $window->add($vbox);
        $vbox->show();
        $hbox =& new GtkHBox(false, 5);
        $hbox->set_border_width(5);
        $vbox->pack_start($hbox, false);
        $hbox->show();
        $label =& new GtkLabel('Depth :');
        $hbox->pack_start($label, false);
        $label->show();
        $adj =& new GtkAdjustment(4, 1, 10, 1, 5, 0);
        $ctree_data['spin1'] =& new GtkSpinButton($adj, 0, 0);
        $hbox->pack_start($ctree_data['spin1'], false, true, 5);
        $ctree_data['spin1']->show();
        $label =& new GtkLabel('Books :');
        $hbox->pack_start($label, false);
        $label->show();
        $adj =& new GtkAdjustment(3, 1, 20, 1, 5, 0);
        $ctree_data['spin2'] =& new GtkSpinButton($adj, 0, 0);
        $hbox->pack_start($ctree_data['spin2'], false, true, 5);
        $ctree_data['spin2']->show();
        $label =& new GtkLabel('Pages :');
        $hbox->pack_start($label, false);
        $label->show();
        $adj =& new GtkAdjustment(5, 1, 20, 1, 5, 0);
        $ctree_data['spin3'] =& new GtkSpinButton($adj, 0, 0);
        $hbox->pack_start($ctree_data['spin3'], false, true, 5);
        $ctree_data['spin3']->show();
        $button =& new GtkButton('Close');
        $button->connect('clicked', 'close_window');
        $hbox->pack_end($button);
        $button->show();
        $button =& new GtkButton('Rebuild Tree');
        $hbox->pack_start($button);
        $button->show();
        $scrolled_win =& new GtkScrolledWindow();
        $scrolled_win->set_border_width(5);
        $scrolled_win->set_policy(GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS);
        $vbox->pack_start($scrolled_win);
        $scrolled_win->show();
        $ctree =& new GtkCTree(2, 0, array('Tree', 'Info'));
        $scrolled_win->add($ctree);
        $ctree->show();
        $ctree->set_column_auto_resize(0, true);
        $ctree->set_column_width(1, 200);
        $ctree->set_selection_mode(GTK_SELECTION_EXTENDED);
        $ctree->set_line_style(GTK_CTREE_LINES_DOTTED);
        $line_style = GTK_CTREE_LINES_DOTTED;
        $button->connect('clicked', 'rebuild_tree', $ctree);
        $ctree->connect('click_column', 'ctree_click_column');
        $ctree->connect_after('button_press_event', 'after_press');
        $ctree->connect_after('button_release_event', 'after_press');
        $ctree->connect_after('tree_move', 'after_press');
        $ctree->connect_after('end_selection', 'after_press');
        $ctree->connect_after('toggle_focus_row', 'after_press');
        $ctree->connect_after('select_all', 'after_press');
        $ctree->connect_after('unselect_all', 'after_press');
        $ctree->connect_after('scroll_vertical', 'after_press');
        $bbox =& new GtkHBox(false, 5);
        $bbox->set_border_width(5);
        $vbox->pack_start($bbox, false);
        $bbox->show();
        $mbox =& new GtkVBox(true, 5);
        $bbox->pack_start($mbox, false);
        $mbox->show();
        $label =& new GtkLabel('Row Height :');
        $mbox->pack_start($label, false, false);
        $label->show();
        $label =& new GtkLabel('Indent :');
        $mbox->pack_start($label, false, false);
        $label->show();
        $label =& new GtkLabel('Spacing :');
        $mbox->pack_start($label, false, false);
        $label->show();
        $mbox =& new GtkVBox(true, 5);
        $bbox->pack_start($mbox, false);
        $mbox->show();
        $adj =& new GtkAdjustment(20, 12, 100, 1, 10, 0);
        $spinner =& new GtkSpinButton($adj, 0, 0);
        $tooltips->set_tip($spinner, 'Row height of list items.', '');
        $adj->connect('value_changed', 'change_row_height', $ctree);
        $ctree->set_row_height($adj->value);
        $mbox->pack_start($spinner, false, false, 5);
        $spinner->show();
        $adj =& new GtkAdjustment(20, 0, 60, 1, 10, 0);
        $spinner =& new GtkSpinButton($adj, 0, 0);
        $tooltips->set_tip($spinner, 'Tree indentation.', '');
        $adj->connect('value_changed', 'change_indent', $ctree);
        $mbox->pack_start($spinner, false, false, 5);
        $spinner->show();
        $adj =& new GtkAdjustment(5, 0, 60, 1, 10, 0);
        $spinner =& new GtkSpinButton($adj, 0, 0);
        $tooltips->set_tip($spinner, 'Tree spacing.', '');
        $adj->connect('value_changed', 'change_spacing', $ctree);
        $mbox->pack_start($spinner, false, false, 5);
        $spinner->show();
        $mbox =& new GtkVBox(true, 5);
        $bbox->pack_start($mbox, false);
        $mbox->show();
        $hbox =& new GtkHBox(false, 5);
        $mbox->pack_start($hbox, false, false);
        $hbox->show();
        $button =& new GtkButton('Expand All');
        $button->connect('clicked', 'expand_all', $ctree);
        $hbox->pack_start($button);
        $button->show();
        $button =& new GtkButton('Collapse All');
        $button->connect('clicked', 'collapse_all', $ctree);
        $hbox->pack_start($button);
        $button->show();
        $button =& new GtkButton('Change Style');
        $button->connect('clicked', 'change_style', $ctree);
        $hbox->pack_start($button);
        $button->show();
        $button =& new GtkButton('Export Tree');
        $button->connect('clicked', 'export_ctree', $ctree);
        $hbox->pack_start($button);
        $button->show();
        $hbox =& new GtkHBox(false, 5);
        $mbox->pack_start($hbox, false, false);
        $hbox->show();
        $button =& new GtkButton('Select All');
        $button->connect('clicked', 'select_all', $ctree);
        $hbox->pack_start($button);
        $button->show();
        $button =& new GtkButton('Unselect All');
        $button->connect('clicked', 'unselect_all', $ctree);
        $hbox->pack_start($button);
        $button->show();
        $button =& new GtkButton('Remove Selection');
        $button->connect('clicked', 'remove_selection', $ctree);
        $hbox->pack_start($button);
        $button->show();
        $check =& new GtkCheckButton('Reorderable');
        $tooltips->set_tip($check, 'Tree items can be reordered by dragging.', '');
        $check->connect('clicked', 'toggle_reorderable', $ctree);
        $check->set_active(true);
        $hbox->pack_start($check, false);
        $check->show();
        $hbox =& new GtkHBox(false, 5);
        $mbox->pack_start($hbox, false, false);
        $hbox->show();
        $items1 = array('No lines' => array('ctree_toggle_line_style', $ctree, GTK_CTREE_LINES_NONE), 'Solid' => array('ctree_toggle_line_style', $ctree, GTK_CTREE_LINES_SOLID), 'Dotted' => array('ctree_toggle_line_style', $ctree, GTK_CTREE_LINES_DOTTED), 'Tabbed' => array('ctree_toggle_line_style', $ctree, GTK_CTREE_LINES_TABBED));
        $omenu1 = build_option_menu($items1, 2);
        $tooltips->set_tip($omenu1, "The tree's line style.", '');
        $hbox->pack_start($omenu1, false);
        $omenu1->show();
        $items2 = array('None' => array('ctree_toggle_expander_style', $ctree, GTK_CTREE_EXPANDER_NONE), 'Square' => array('ctree_toggle_expander_style', $ctree, GTK_CTREE_EXPANDER_SQUARE), 'Triangle' => array('ctree_toggle_expander_style', $ctree, GTK_CTREE_EXPANDER_TRIANGLE), 'Circular' => array('ctree_toggle_expander_style', $ctree, GTK_CTREE_EXPANDER_CIRCULAR));
        $omenu2 = build_option_menu($items2, 2);
        $tooltips->set_tip($omenu1, "The tree's expander style.", '');
        $hbox->pack_start($omenu2, false);
        $omenu2->show();
        $items3 = array('Left' => array('ctree_toggle_justify', $ctree, GTK_JUSTIFY_LEFT), 'Right' => array('ctree_toggle_justify', $ctree, GTK_JUSTIFY_RIGHT));
        $omenu3 = build_option_menu($items3, 0);
        $tooltips->set_tip($omenu1, "The tree's justification.", '');
        $hbox->pack_start($omenu3, false);
        $omenu3->show();
        $items4 = array('Single' => array('ctree_toggle_sel_mode', $ctree, GTK_SELECTION_SINGLE), 'Browse' => array('ctree_toggle_sel_mode', $ctree, GTK_SELECTION_BROWSE), 'Multiple' => array('ctree_toggle_sel_mode', $ctree, GTK_SELECTION_MULTIPLE), 'Extended' => array('ctree_toggle_sel_mode', $ctree, GTK_SELECTION_EXTENDED));
        $omenu4 = build_option_menu($items4, 1);
        $tooltips->set_tip($omenu1, "The list's selection mode.", '');
        $hbox->pack_start($omenu4, false);
        $omenu4->show();
        $window->realize();
        $mini_page_xpm = array("16 16 4 1", "       c None s None", ".      c black", "X      c white", "o      c #808080", "                ", "   .......      ", "   .XXXXX..     ", "   .XoooX.X.    ", "   .XXXXX....   ", "   .XooooXoo.o  ", "   .XXXXXXXX.o  ", "   .XooooooX.o  ", "   .XXXXXXXX.o  ", "   .XooooooX.o  ", "   .XXXXXXXX.o  ", "   .XooooooX.o  ", "   .XXXXXXXX.o  ", "   ..........o  ", "    oooooooooo  ", "                ");
        $transparent =& new GdkColor(0, 0, 0);
        list($ctree_data['pixmap1'], $ctree_data['mask1']) = Gdk::pixmap_create_from_xpm_d($window->window, $transparent, $book_closed_xpm);
        list($ctree_data['pixmap2'], $ctree_data['mask2']) = Gdk::pixmap_create_from_xpm_d($window->window, $transparent, $book_open_xpm);
        list($ctree_data['pixmap3'], $ctree_data['mask3']) = Gdk::pixmap_create_from_xpm_d($window->window, $transparent, $mini_page_xpm);
        $ctree->set_usize(0, 300);
        $frame =& new GtkFrame();
        $frame->set_border_width(0);
        $frame->set_shadow_type(GTK_SHADOW_OUT);
        $vbox->pack_start($frame, false);
        $frame->show();
        $hbox =& new GtkHBox(true, 2);
        $hbox->set_border_width(2);
        $frame->add($hbox);
        $hbox->show();
        $frame =& new GtkFrame();
        $frame->set_shadow_type(GTK_SHADOW_IN);
        $hbox->pack_start($frame, false);
        $frame->show();
        $hbox2 =& new GtkHBox();
        $hbox2->set_border_width(2);
        $frame->add($hbox2);
        $hbox2->show();
        $label =& new GtkLabel('Books :');
        $hbox2->pack_start($label, false);
        $label->show();
        $ctree_data['book_label'] =& new GtkLabel($ctree_data['books']);
        $hbox2->pack_start($ctree_data['book_label'], false, true, 5);
        $ctree_data['book_label']->show();
        $frame =& new GtkFrame();
        $frame->set_shadow_type(GTK_SHADOW_IN);
        $hbox->pack_start($frame, false);
        $frame->show();
        $hbox2 =& new GtkHBox();
        $hbox2->set_border_width(2);
        $frame->add($hbox2);
        $hbox2->show();
        $label =& new GtkLabel('Pages :');
        $hbox2->pack_start($label, false);
        $label->show();
        $ctree_data['page_label'] =& new GtkLabel($ctree_data['pages']);
        $hbox2->pack_start($ctree_data['page_label'], false, true, 5);
        $ctree_data['page_label']->show();
        $frame =& new GtkFrame();
        $frame->set_shadow_type(GTK_SHADOW_IN);
        $hbox->pack_start($frame, false);
        $frame->show();
        $hbox2 =& new GtkHBox();
        $hbox2->set_border_width(2);
        $frame->add($hbox2);
        $hbox2->show();
        $label =& new GtkLabel('Selected :');
        $hbox2->pack_start($label, false);
        $label->show();
        $ctree_data['sel_label'] =& new GtkLabel(count($ctree->selection));
        $hbox2->pack_start($ctree_data['sel_label'], false, true, 5);
        $ctree_data['sel_label']->show();
        $frame =& new GtkFrame();
        $frame->set_shadow_type(GTK_SHADOW_IN);
        $hbox->pack_start($frame, false);
        $frame->show();
        $hbox2 =& new GtkHBox();
        $hbox2->set_border_width(2);
        $frame->add($hbox2);
        $hbox2->show();
        $label =& new GtkLabel('Visible :');
        $hbox2->pack_start($label, false);
        $label->show();
        $ctree_data['vis_label'] =& new GtkLabel($ctree->clist->rows);
        $hbox2->pack_start($ctree_data['vis_label'], false, true, 5);
        $ctree_data['vis_label']->show();
        rebuild_tree(null, $ctree);
    }
    if ($windows['ctree']->flags() & GTK_VISIBLE) {
        $windows['ctree']->hide();
    } else {
        $windows['ctree']->show();
    }
}
Пример #16
0
\t</div>
</body>
</html>
eod;
    $popform = addslashes($popform);
    safe_insert("txp_form", "name='popup_comments',type='comment',Form='{$popform}'");
}
safe_update("txp_category", "lft=0,rgt=0", "name!='root'");
safe_delete("txp_category", "name='root'");
safe_update("txp_category", "parent='root'", "parent = ''");
safe_insert("txp_category", "name='root',parent='',type='article',lft=1,rgt=0");
rebuild_tree('root', 1, 'article');
safe_insert("txp_category", "name='root',parent='',type='link',lft=1,rgt=0");
rebuild_tree('root', 1, 'link');
safe_insert("txp_category", "name='root',parent='',type='image',lft=1,rgt=0");
rebuild_tree('root', 1, 'image');
safe_delete('txp_prefs', "name = 'version'");
safe_insert('txp_prefs', "prefs_id=1, name='version',val='{$thisversion}'");
if (!safe_field('val', 'txp_prefs', "name='article_list_pageby'")) {
    safe_insert('txp_prefs', "prefs_id=1,name='article_list_pageby',val=25");
}
if (!safe_field('val', 'txp_prefs', "name='link_list_pageby'")) {
    safe_insert('txp_prefs', "prefs_id=1,name='link_list_pageby',val=25");
}
if (!safe_field('val', 'txp_prefs', "name='image_list_pageby'")) {
    safe_insert('txp_prefs', "prefs_id=1,name='image_list_pageby',val=25");
}
if (!safe_field('val', 'txp_prefs', "name='log_list_pageby'")) {
    safe_insert('txp_prefs', "prefs_id=1,name='log_list_pageby',val=25");
}
if (!safe_field('val', 'txp_prefs', "name='comment_list_pageby'")) {
Пример #17
0
function cat_event_category_save($event, $table_name)
{
    global $txpcfg;
    extract(doSlash(psa(array('id', 'name', 'old_name', 'parent', 'title'))));
    $id = assert_int($id);
    $name = sanitizeForUrl($name);
    // make sure the name is valid
    if (!$name) {
        $message = gTxt($event . '_category_invalid', array('{name}' => $name));
        return cat_category_list($message);
    }
    // don't allow rename to clobber an existing category
    $existing_id = safe_field('id', 'txp_category', "name = '{$name}' and type = '{$event}'");
    if ($existing_id and $existing_id != $id) {
        $message = gTxt($event . '_category_already_exists', array('{name}' => $name));
        return cat_category_list($message);
    }
    $parent = $parent ? $parent : 'root';
    if (safe_update('txp_category', "name = '{$name}', parent = '{$parent}', title = '{$title}'", "id = {$id}")) {
        safe_update('txp_category', "parent = '{$name}'", "parent = '{$old_name}'");
    }
    rebuild_tree('root', 1, $event);
    if ($event == 'article') {
        safe_update('textpattern', "Category1 = '{$name}'", "Category1 = '{$old_name}'");
        safe_update('textpattern', "Category2 = '{$name}'", "Category2 = '{$old_name}'");
    } else {
        safe_update($table_name, "category = '{$name}'", "category = '{$old_name}'");
    }
    $message = gTxt($event . '_category_updated', array('{name}' => doStrip($name)));
    cat_category_list($message);
}
Пример #18
0
function image_save()
{
    extract(doSlash(gpsa(array('name', 'old_name', 'parent'))));
    $parent = $parent ? $parent : 'root';
    safe_update("txp_category", "name='{$name}', parent='{$parent}'", "name='{$old_name}' and type='image'");
    rebuild_tree('root', 1, 'image');
    safe_update("txp_image", "category='{$name}'", "category='{$old_name}'");
    category_list(messenger('image_category', $name, 'saved'));
}
Пример #19
0
function event_category_save($evname, $table_name)
{
    global $txpcfg;
    //Prevent non url chars on category names
    include_once $txpcfg['txpath'] . '/lib/classTextile.php';
    $textile = new Textile();
    $in = psa(array('id', 'name', 'old_name', 'parent', 'title'));
    extract(doSlash($in));
    $title = $textile->TextileThis($title, 1);
    $name = dumbDown($textile->TextileThis($name, 1));
    $name = preg_replace("/[^[:alnum:]\\-_]/", "", str_replace(" ", "-", $name));
    $parent = $parent ? $parent : 'root';
    safe_update("txp_category", "name='{$name}',parent='{$parent}',title='{$title}'", "id={$id}");
    rebuild_tree('root', 1, $evname);
    if ($evname == 'article') {
        safe_update("textpattern", "Category1='{$name}'", "Category1 = '{$old_name}'");
        safe_update("textpattern", "Category2='{$name}'", "Category2 = '{$old_name}'");
    } else {
        safe_update($table_name, "category='{$name}'", "category='{$old_name}'");
    }
    category_list(messenger($evname . '_category', stripslashes($name), 'saved'));
}
Пример #20
0
function cat_vendor_category_create($name)
{
    global $txpcfg;
    //Prevent non url chars on category names
    include_once txpath . '/lib/classTextile.php';
    $textile = new Textile();
    //$name = ps('name');
    $title = doSlash($name);
    $name = dumbDown($textile->TextileThis(trim(doSlash($name)), 1));
    $name = preg_replace("/[^[:alnum:]\\-_]/", "", str_replace(" ", "-", $name));
    $check = safe_field("name", "txp_category", "name='{$name}' and type='article'");
    if (!$check) {
        if ($name) {
            $q = safe_insert("txp_category", "name='{$name}', title='{$title}', type='article', parent='Vendors'");
            //rebuild_tree('Vendor', 2, "article");
            rebuild_tree('root', 1, "article");
        }
    }
}
Пример #21
0
        while ($row = $result->fetchAssoc()) {
            $children[] = $row['cid'];
            verify_children($row['cid'], $cid);
        }
    }
    $result->free();
    return false;
}
if ($superCage->post->keyExists('update_config')) {
    //Check if the form token is valid
    if (!checkFormToken()) {
        cpg_die(ERROR, $lang_errors['invalid_form_token'], __FILE__, __LINE__);
    }
    $value = $superCage->post->getInt('categories_alpha_sort');
    cpg_config_set('categories_alpha_sort', $value);
    rebuild_tree();
}
if ($superCage->get->keyExists('op')) {
    $op = $superCage->get->getAlpha('op');
    //Check if the form token is valid
    if (!checkFormToken()) {
        cpg_die(ERROR, $lang_errors['invalid_form_token'], __FILE__, __LINE__);
    }
} else {
    $op = '';
}
$current_category = array('cid' => 0, 'name' => '', 'parent' => 0, 'description' => '');
switch ($op) {
    case 'move':
        if (!$superCage->get->keyExists('cid1') || !$superCage->get->keyExists('cid2') || !$superCage->get->keyExists('pos1') || !$superCage->get->keyExists('pos2')) {
            cpg_die(CRITICAL_ERROR, sprintf($lang_catmgr_php['miss_param'], 'move'), __FILE__, __LINE__);
function rebuild_tree($parent = 0, $left = 0, $depth = 0, $pos = 0)
{
    global $CONFIG;
    // the right value of this node is the left value + 1
    $right = $left + 1;
    if ($CONFIG['categories_alpha_sort'] == 1) {
        $sort_query = 'name';
    } else {
        $sort_query = 'pos';
    }
    $childpos = 0;
    // get all children of this node
    $result = cpg_db_query("SELECT cid FROM {$CONFIG['TABLE_PREFIX']}categories WHERE parent = {$parent} ORDER BY {$sort_query}, cid");
    while ($row = mysql_fetch_assoc($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
        if ($row['cid']) {
            $right = rebuild_tree($row['cid'], $right, $depth + 1, $childpos++);
        }
    }
    // we've got the left value, and now that we've processed
    // the children of this node we also know the right value
    cpg_db_query("UPDATE {$CONFIG['TABLE_PREFIX']}categories SET lft = {$left}, rgt = {$right}, depth = {$depth}, pos = {$pos} WHERE cid = {$parent} LIMIT 1");
    // return the right value of this node + 1
    return $right + 1;
}
Пример #23
0
/**
 * Processes the selected import tool action.
 *
 * Basically does the importing.
 */
function start_import()
{
    global $event, $vars;
    extract(psa($vars));
    $insert_into_section = $import_section;
    $insert_with_status = $import_status;
    $default_comment_invite = $import_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, $import_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, $import_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, $wpdbcharset);
            rebuild_tree('root', 1, 'article');
            break;
        case 'blogger':
            $file = check_import_file();
            if (!empty($file)) {
                $out = doImportBLOGGER($file, $insert_into_section, $insert_with_status, $import_comments_invite);
            } else {
                $out = gTxt('import_file_not_found');
            }
            break;
    }
    $out = tag('max_execution_time = ' . ini_get('max_execution_time'), 'p', ' class="highlight"') . $out;
    pagetop(gTxt('txp_import'));
    $content = '<div id="' . $event . '_container" class="txp-container">';
    $content .= startTable('', '', 'txp-list');
    $content .= tr(tdcs(hed(gTxt('txp_import'), 2), 2));
    $content .= tr(td($out));
    $content .= endTable();
    $content .= '</div>';
    echo $content;
    $rs = safe_rows_start('parentid, count(*) as thecount', 'txp_discuss', 'visible=1 group by parentid');
    if (numRows($rs) > 0) {
        while ($a = nextRow($rs)) {
            safe_update('textpattern', "comments_count=" . $a['thecount'], "ID=" . $a['parentid']);
        }
    }
}
Пример #24
0
function zem_event_cat_tab_multiedit()
{
    $method = ps('edit_method');
    $things = ps('selected');
    if ($things) {
        foreach ($things as $catid) {
            $catid = assert_int($catid);
            if ($method == 'delete') {
                $catname = safe_field('name', 'txp_category', "id = {$catid}");
                if (safe_delete('txp_category', "id = {$catid}")) {
                    if ($catname) {
                        safe_update('txp_category', "parent = 'root'", "type = 'event' and parent = '" . doSlash($catname) . "'");
                    }
                    $categories[] = $catid;
                }
            }
        }
        if (function_exists('rebuild_tree_full')) {
            rebuild_tree_full('event');
        } else {
            rebuild_tree('root', 1, 'event');
        }
        $message = zem_event_gTxt('categories_deleted', array('{list}' => join(', ', $categories)));
        zem_event_cat_tab_list($message);
    }
}