/**
  * Displays categories as a tree
  *
  * @param mixed $args
  *
  * This isn't a plugin hook, but a public function call created in the Sidebar plugin.
  */
 public function widget_categories($h)
 {
     $sql = "SELECT * FROM " . TABLE_CATEGORIES . " ORDER BY category_order ASC";
     $the_cats = $h->db->get_results($h->db->prepare($sql));
     require_once LIBS . 'Category.php';
     $catObj = new Category();
     echo "<h2 class='widget_head'>" . $h->lang["categories"] . "</h2>";
     echo "<div class='widget_body'>\n";
     echo "<ul class='categories_widget'>\n";
     foreach ($the_cats as $cat) {
         $cat_level = 1;
         // top level category.
         if ($cat->category_safe_name != "all") {
             echo "<li>";
             if ($cat->category_parent > 1) {
                 $depth = $catObj->getCatLevel($h, $cat->category_id, $cat_level, $the_cats);
                 for ($i = 1; $i < $depth; $i++) {
                     echo "--- ";
                 }
             }
             $category = stripslashes(html_entity_decode(urldecode($cat->category_name), ENT_QUOTES, 'UTF-8'));
             echo "<a href='" . $h->url(array('category' => $cat->category_id)) . "'>";
             echo $category . "</a></li>\n";
         }
     }
     echo "</ul></div>\n";
 }