Example #1
0
function print_category_tree($arr, $category_id = 0, $excluded = array(), $depth = 0)
{
    $re = '';
    if (!is_array($arr)) {
        return;
    }
    if ($excluded && !is_array($excluded)) {
        $excluded = array($excluded);
    }
    if ($depth > 100) {
        return;
    }
    foreach ($arr as $c) {
        if ($c['category_id'] && in_array($c['category_id'], $excluded)) {
            continue;
        }
        if ($c['status'] == 'folder' && END_CONTROLLER != 'category') {
            $re .= "<optgroup label='" . print_space($depth) . $c['name'] . "'>";
            $re .= print_category_tree($c['children'], $category_id, $excluded, $depth + 1);
            $re .= "</optgroup>";
        } else {
            $re .= "<option status='" . $c['status'] . "' value='" . $c['category_id'] . "' ";
            if ($category_id && $c['category_id'] == $category_id) {
                $re .= " selected='selected' ";
            }
            $re .= ">" . print_space($depth) . $c['name'] . "</option>\n";
            $re .= print_category_tree($c['children'], $category_id, $excluded, $depth + 1);
        }
    }
    return $re;
}
Example #2
0
function print_category_tree($arr, $category_id = 0, $depth = 0)
{
    $re = '';
    if (!is_array($arr)) {
        return;
    }
    foreach ($arr as $c) {
        $re .= "<option value='" . $c['category_id'] . "' ";
        if ($category_id && $c['category_id'] == $category_id) {
            $re .= " selected='selected' ";
        }
        $re .= ">" . print_space($depth) . $c['name'] . "</option>\n";
        $re .= print_category_tree($c['children'], $category_id, $depth + 1);
    }
    return $re;
}
		<?php 
    if (!empty($_obj['categories'])) {
        if (!is_array($_obj['categories'])) {
            $_obj['categories'] = array(array('categories' => $_obj['categories']));
        }
        $_stack[$_stack_cnt++] = $_obj;
        $rowcounter = 0;
        foreach ($_obj['categories'] as $rowcnt => $categories) {
            $categories['ROWCNT'] = $rowcounter;
            $categories['ALTROW'] = $rowcounter % 2;
            $categories['ROWBIT'] = $rowcounter % 2;
            $rowcounter++;
            $_obj =& $categories;
            ?>
		<?php 
            echo print_space($_obj['depth']);
            ?>
		<input type="checkbox" right="category" name="category_<?php 
            echo $_obj['category_id'];
            ?>
" id="category_<?php 
            echo $_obj['category_id'];
            ?>
" <?php 
            if ($this_rights['category_' . $_obj['category_id']]) {
                echo 'checked="checked" ';
                $some_checked = true;
            }
            ?>
 />
		<label for="category_<?php