public function testSpeedBuildAllCategoryListRunWithEmptyDataSet()
 {
     $desired_speed = 0.05;
     $t_start = microtime(true);
     // {{{ Run build all category list
     $output = Category::build_all_category_list();
     // }}}
     $t_end = microtime(true);
     $speed = $t_end - $t_start;
     $message = '';
     $message .= '---------------------------------' . "\n";
     $message .= 'Actual speed: ' . (double) $speed . "\n";
     $message .= 'Desired speed: ' . (double) $desired_speed . "\n";
     $message .= '---------------------------------' . "\n";
     $this->assertTrue((double) $desired_speed > (double) $speed, $message);
 }
 function render()
 {
     switch (@$_GET["type"]) {
         case 'Content':
             $this->type = 'Content';
             break;
         case 'Default':
         default:
             $this->type = 'Default';
     }
     if (@$_GET['a'] == "edit" && !empty($_GET['cat_id'])) {
         $edit_cat = new Category();
         $edit_cat->category_id = $_GET['cat_id'];
         $edit_cat->load();
         $this->edit_title = $edit_cat->name;
         $this->edit_desc = $edit_cat->description;
         $this->cat_id = $edit_cat->category_id;
         $this->type = $edit_cat->type;
         $parent_id = $edit_cat->find_parent($edit_cat->category_id);
         $this->parent_id = $parent_id ? $parent_id : 0;
         if ($this->parent_id) {
             $edit_cat->category_id = $this->parent_id;
             $edit_cat->load();
             $this->parent_name = $edit_cat->name;
         } else {
             $this->parent_name = '';
         }
     }
     $this->categories = Category::build_all_category_list('', '', '', $this->type);
     $category = Category::build_root_list(NULL, $this->type);
     if (is_array($category)) {
         foreach ($category as $catg) {
             $this->get_childs($catg);
         }
     }
     $this->inner_HTML = $this->generate_inner_html();
     $content = parent::render();
     return $content;
 }
 /**
  * Builds a category tree for all cateogories
  * @access public static
  * return array of all categories
  */
 public static function build_all_category_list($position = '', $spacing = '', $category_tree_array = '', $type = 'Default', $exclude = 1)
 {
     if (!is_array($category_tree_array)) {
         $category_tree_array = array();
     }
     if (sizeof($category_tree_array) < 1 && $exclude != 0) {
         $category_tree_array[] = array('category_id' => '0', 'name' => 'Select Category');
     }
     $sql = "SELECT * FROM {categories} WHERE position RLIKE  '^" . $position . "[0-9]+>\$' AND type = ?";
     $res = Dal::query($sql, array($type));
     if ($res->numRows() > 0) {
         while ($row = $res->fetchRow(DB_FETCHMODE_OBJECT)) {
             $category_tree_array[] = array('category_id' => $row->category_id, 'name' => $spacing . $row->name);
             $category_tree_array = Category::build_all_category_list($row->position, $spacing . '&nbsp;&nbsp;&nbsp;', $category_tree_array, $type);
         }
     }
     return $category_tree_array;
 }
 function load_data($error_msg = '')
 {
     global $base_url;
     global $current_theme_path;
     $this->categories = Category::build_all_category_list();
     if (!empty($error_msg)) {
         $this->error_msg = $error_msg;
     }
     if ($this->id == 0) {
         $this->title = 'Add Blog Post';
         return;
     } else {
         $this->title = '';
         $content = Content::load_content((int) $this->id, $_SESSION['user']['id']);
         $content_tags = Tag::load_tags_for_content((int) $this->id);
         $this->blog_title = stripslashes($content->title);
         $this->body = stripslashes($content->body);
         $this->trackback = $content->trackbacks;
         $this->collection_id = @$content->collection_id;
         if (count($content_tags)) {
             foreach ($content_tags as $tag) {
                 $out[] = $tag['name'];
             }
             $this->tag_entry = implode(', ', $out);
         }
     }
 }