Example #1
0
 * @var Chapter
 */
global $edited_GenericCategory;
/**
 * @var Chapter
 */
$edited_Chapter =& $edited_GenericCategory;
/**
 * @var GenericCategoryCache
 */
global $GenericCategoryCache;
global $Settings, $action, $subset_ID;
// Determine if we are creating or updating...
$creating = is_create_action($action);
$Form = new Form(NULL, 'form');
$close_url = get_chapter_redirect_url(get_param('redirect_page'), $edited_Chapter->parent_ID, $edited_Chapter->ID);
$Form->global_icon(T_('Cancel editing!'), 'close', $close_url);
$Form->begin_form('fform', $creating ? T_('New category') : T_('Category'));
$Form->add_crumb('element');
$Form->hidden('action', $creating ? 'create' : 'update');
$Form->hiddens_by_key(get_memorized('action'));
$Form->begin_fieldset(T_('Properties'));
// We're essentially double checking here...
$edited_Blog =& $edited_Chapter->get_Blog();
$move = '';
if ($Settings->get('allow_moving_chapters') && !$creating) {
    // If moving cats between blogs is allowed:
    $move = ' ' . action_icon(T_('Move to a different blog...'), 'file_move', regenerate_url('action,cat_ID', 'cat_ID=' . $edited_Chapter->ID . '&action=move'), T_('Move'));
}
$Form->info(T_('Blog'), $edited_Blog->get_maxlen_name() . $move);
$Form->select_input_options('cat_parent_ID', $GenericCategoryCache->recurse_select($edited_Chapter->parent_ID, $subset_ID, true, NULL, 0, array($edited_Chapter->ID)), T_('Parent category'));
Example #2
0
     $cat_ID = NULL;
     $action = 'list';
     break;
 case 'delete':
     // Delete entry:
     param($ChapterCache->dbIDname, 'integer', true);
     if (param('confirm', 'integer', 0)) {
         // confirmed, Delete from DB:
         $parent_ID = $edited_Chapter->parent_ID;
         $msg = sprintf(T_('Chapter «%s» deleted.'), $edited_Chapter->dget('name'));
         $ChapterCache->dbdelete_by_ID($edited_Chapter->ID);
         unset($edited_Chapter);
         forget_param($ChapterCache->dbIDname);
         $Messages->add($msg, 'success');
         // Redirect so that a reload doesn't write to the DB twice:
         $redirect_to = get_chapter_redirect_url(param('redirect_page', 'string', ''), $parent_ID);
         header_redirect($redirect_to, 303);
         // Will EXIT
         // We have EXITed already at this point!!
     } else {
         // not confirmed, Check for restrictions:
         // TODO: dh> allow to delete a category which has links (and unbreak those after confirmation).
         // Get the page number we come from:
         $previous_page = param('results_' . $ChapterCache->dbprefix . 'page', 'integer', 1, true);
         if (!$edited_Chapter->check_delete(sprintf(T_('Cannot delete element «%s»'), $edited_Chapter->dget('name')))) {
             // There are restrictions:
             $action = 'edit';
         }
     }
     break;
 case 'make_default':