blog->getCategory($mov_cat); if ($c->isEmpty()) { throw new Exception(__('Category where to move posts does not exist')); } unset($c); if (in_array($mov_cat, $_POST['categories'])) { throw new Exception(__('The entries cannot be moved to the category you choose to delete.')); } } foreach ($_POST['categories'] as $cat_id) { # Check if category to delete exists $c = $core->blog->getCategory((integer) $cat_id); if ($c->isEmpty()) { continue; } unset($c); # Move posts if ($mov_cat != $cat_id) { $core->blog->changePostsCategory($cat_id,$mov_cat); } # Delete category $core->blog->delCategory($cat_id); } http::redirect('categories.php?del='.count($_POST['categories'])); } catch (Exception $e) { $core->error->add($e->getMessage()); } } # Update order if (!empty($_POST['save_order']) && !empty($_POST['categories_order'])) { $categories = json_decode($_POST['categories_order']); foreach ($categories as $category) { if (!empty($category->item_id)) { $core->blog->updCategoryPosition($category->item_id, $category->left, $category->right); } } http::redirect('categories.php?reord=1'); } # Reset order if (!empty($_POST['reset'])) { try { $core->blog->resetCategoriesOrder(); http::redirect('categories.php?reord=1'); } catch (Exception $e) { $core->error->add($e->getMessage()); } } /* Display -------------------------------------------------------- */ $rs = $core->blog->getCategories(array('post_type'=>'post')); $starting_script = ""; if (!$core->auth->user_prefs->accessibility->nodragdrop && $core->auth->check('categories',$core->blog->id) && $rs->count()>1) { $starting_script .= dcPage::jsLoad('js/jquery/jquery-ui.custom.js'); $starting_script .= dcPage::jsLoad('js/jquery/jquery.mjs.nestedSortable.js'); } $starting_script .= dcPage::jsLoad('js/_categories.js'); dcPage::open(__('Categories'),$starting_script, dcPage::breadcrumb( array( html::escapeHTML($core->blog->name) => '', ''.__('Categories').'' => '' )) ); if (!empty($_GET['del'])) { dcPage::success(__('The category has been successfully removed.', 'The categories have been successfully removed.', (int) $_GET['del'] ) ); } if (!empty($_GET['reord'])) { dcPage::success(__('Categories have been successfully reordered.')); } $categories_combo = dcAdminCombos::getCategoriesCombo($rs); echo '
'; echo ''.__('No category so far.').'
'; } else { echo ''; } echo '