コード例 #1
0
 function get_parent_cat_array()
 {
     global $config_vars;
     $cat_obj = $this;
     $parent_cat['name'] = $cat_obj->get_name();
     $parent_cat['id'] = $cat_obj->get_id();
     $parent_cats[] = $parent_cat;
     while ($cat_obj->get_parent_id() != $config_vars['root_categorie'] and $cat_obj->id != $cat_obj->get_parent_id()) {
         $old_cat_id = $cat_obj->get_parent_id();
         $cat_obj = new categorie();
         $cat_obj->generate_from_id($old_cat_id);
         $parent_cat['name'] = $cat_obj->get_name();
         $parent_cat['id'] = $cat_obj->get_id();
         $parent_cats[] = $parent_cat;
     }
     return array_reverse($parent_cats);
 }
コード例 #2
0
function add_dir_parsed($dir, $group_id, $parent_id = -1)
{
    // Add all pictures under the Directory $dir to categories and series depending on the relativ path to $dir
    global $db, $config_vars, $filetypes;
    if ($parent_id == -1) {
        $parent_id = $config_vars['root_categorie'];
    }
    $dir_handle = opendir($dir);
    while ($file = readdir($dir_handle)) {
        if ($file != "." && $file != "..") {
            $dir_and_file = $dir . '/' . $file;
            if (isset($filetypes[getext($file)])) {
                // $file is content
                // generate a new album_content obj
                add_content($file, $dir_and_file, getfile($file), $parent_id, 0, $group_id);
            } elseif (is_dir($dir_and_file)) {
                //file is a sub dir
                $cat = new categorie();
                $cat->set_name($file);
                $cat->set_parent_id($parent_id);
                $cat->fill_up();
                $cat->set_catgroup_id($group_id);
                if (!isset($cat->id)) {
                    $cat->commit();
                }
                add_dir_parsed($dir . '/' . $file, $group_id, $cat->get_id());
            }
        }
    }
    closedir($dir_handle);
}