/**
 *
 *
 * @param array $category
 * @param int $indent
 * @param bool $allowSorting
 */
function writeCategoryItem($category, $indent = 0, $allowSorting = true)
{
    $i = str_repeat('  ', $indent);
    echo "{$i}<li class=\"dd-item tree-item\" data-id=\"{$category['CategoryID']}\">\n{$i}";
    if ($allowSorting) {
        echo "{$i}  <div class=\"dd-handle tree-handle\">" . symbol('handle', t('Drag')) . "</div>";
    }
    echo "<div class=\"dd-content tree-content\">";
    if (in_array($category['DisplayAs'], ['Categories', 'Flat'])) {
        echo anchor(htmlspecialchars($category['Name']), '/vanilla/settings/categories?parent=' . urlencode($category['UrlCode']));
    } else {
        echo htmlspecialchars($category['Name']);
    }
    echo "\n{$i}  <div class=\"options\">";
    writeCategoryOptions($category);
    echo "</div>";
    echo "</div>\n";
    if (!empty($category['Children'])) {
        writeCategoryTree($category['Children'], $indent + 1);
    }
    echo "{$i}</li>\n";
}
Example #2
0
<?php

if (!defined('APPLICATION')) {
    exit;
}
echo heading(t('Manage Categories'), t('Add Category'), 'vanilla/settings/addcategory?parent=' . $this->data('Category.CategoryID'));
writeCategoryBreadcrumbs($this->data('Ancestors', []));
?>

<div class="toolbar"><?php 
if ($this->data('UsePagination', false) === true) {
    PagerModule::write(['Sender' => $this, 'View' => 'pager-dashboard']);
}
?>
</div>

<div class="dd tree tree-categories" data-parent-id="<?php 
echo $this->data('ParentID', -1);
?>
"><?php 
writeCategoryTree($this->data('Categories', []), 0, $this->data('AllowSorting', true));
?>
</div>