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); }
} unset($HTTP_SESSION_VARS['contents']); if (!isset($HTTP_GET_VARS['cat_id'])) { $HTTP_GET_VARS['cat_id'] = $config_vars['root_categorie']; $template_file = 'index'; } // create new categorie if (isset($HTTP_POST_VARS['newcat'])) { $new_cat = new categorie(); $new_cat->set_parent_id($HTTP_GET_VARS['cat_id']); $new_cat->set_name($HTTP_POST_VARS['cat_name']); $new_cat->set_description($HTTP_POST_VARS['cat_describtion']); if ($HTTP_POST_VARS['cat_is_serie'] == 'on') { $new_cat->set_is_serie(1); } $new_cat->set_catgroup_id($HTTP_POST_VARS['add_to_catgroup']); $new_cat->commit(); } //get the cats in the actual cat and information about them $child_cats = get_cats_of_cat($HTTP_GET_VARS['cat_id']); // get the amount of child_cats without perm checking $sql = "SELECT * FROM " . $config_vars['table_prefix'] . "cats WHERE (parent_id = {$HTTP_GET_VARS['cat_id']})"; if (!($result = $db->sql_query($sql))) { error_report(SQL_ERROR, 'get_cats_of_cat', __LINE__, __FILE__, $sql); } $child_cats_total_amount = $db->sql_affectedrows($result); $child_cats_viewable_amount = sizeof($child_cats); $smarty->assign('viewable_total_cats', sprintf($lang['viewable_total_cats'], $child_cats_viewable_amount, $child_cats_total_amount)); if (isset($HTTP_POST_VARS['edit_cat'])) { for ($i = 0; $i < sizeof($child_cats); $i++) { $child_cats[$i]->set_name($HTTP_POST_VARS['cat_name'][$i]);