Example #1
0
function form_list($curname)
{
    global $step, $essential_forms, $form_types;
    $types = formTypes('', false);
    $methods = array('changetype' => array('label' => gTxt('changetype'), 'html' => $types), 'delete' => gTxt('delete'));
    $out[] = '<p class="action-create">' . sLink('form', 'form_create', gTxt('create_new_form')) . '</p>';
    $criteria = 1;
    $criteria .= callback_event('admin_criteria', 'form_list', 0, $criteria);
    $rs = safe_rows_start("*", "txp_form", "{$criteria} order by field(type,'" . join("','", array_keys($form_types)) . "') asc, name asc");
    if ($rs) {
        $ctr = 1;
        $prev_type = '';
        while ($a = nextRow($rs)) {
            extract($a);
            $editlink = $curname != $name ? eLink('form', 'form_edit', 'name', $name, $name) : txpspecialchars($name);
            $modbox = !in_array($name, $essential_forms) ? '<input type="checkbox" name="selected_forms[]" value="' . $name . '" />' : '';
            if ($prev_type != $type) {
                $visipref = 'pane_form_' . $type . '_visible';
                $group_start = '<div class="form-list-group ' . $type . '"><h3 class="lever' . (get_pref($visipref) ? ' expanded' : '') . '"><a href="#' . $type . '">' . $form_types[$type] . '</a></h3>' . n . '<div id="' . $type . '" class="toggle form-list" style="display:' . (get_pref($visipref) ? 'block' : 'none') . '">' . n . '<ul class="plain-list">' . n;
                $group_end = $ctr > 1 ? '</ul></div></div>' . n : '';
            } else {
                $group_start = $group_end = '';
            }
            $out[] = $group_end . $group_start;
            $out[] = '<li>' . n . '<span class="form-list-action">' . $modbox . '</span><span class="form-list-name">' . $editlink . '</span></li>';
            $prev_type = $type;
            $ctr++;
        }
        $out[] = '</ul></div></div>';
        $out[] = multi_edit($methods, 'form', 'form_multi_edit');
        return form(join('', $out), '', '', 'post', '', '', 'allforms_form') . script_js(<<<EOS
\t\t\t\t\$(document).ready(function() {
\t\t\t\t\t\$('#allforms_form').txpMultiEditForm({
\t\t\t\t\t\t'checkbox' : 'input[name="selected_forms[]"][type=checkbox]',
\t\t\t\t\t\t'row' : '.plain-list li, .form-list-name',
\t\t\t\t\t\t'highlighted' : '.plain-list li'
\t\t\t\t\t});
\t\t\t\t});
EOS
);
    }
}
Example #2
0
/**
 * Renders a multi-edit widget.
 *
 * @param  int    $page          The page number
 * @param  string $sort          The current sorting value
 * @param  string $dir           The current sorting direction
 * @param  string $crit          The current search criteria
 * @param  string $search_method The current search method
 * @return string HTML
 */
function log_multiedit_form($page, $sort, $dir, $crit, $search_method)
{
    $methods = array('delete' => gTxt('delete'));
    return multi_edit($methods, 'log', 'log_multi_edit', $page, $sort, $dir, $crit, $search_method);
}
Example #3
0
/**
 * Renders multi-edit form.
 *
 * @param  int    $page          The page
 * @param  string $sort          The sorting value
 * @param  string $dir           The sorting direction
 * @param  string $crit          The search string
 * @param  string $search_method The search method
 * @return string HTML
 */
function author_multiedit_form($page, $sort, $dir, $crit, $search_method)
{
    $privileges = privs();
    $users = safe_column('name', 'txp_users', '1=1');
    $methods = array('changeprivilege' => array('label' => gTxt('changeprivilege'), 'html' => $privileges), 'resetpassword' => gTxt('resetpassword'));
    if (count($users) > 1) {
        $methods['delete'] = array('label' => gTxt('delete'), 'html' => tag(gTxt('assign_assets_to'), 'label', array('for' => 'assign_assets')) . selectInput('assign_assets', $users, '', true, '', 'assign_assets'));
    }
    return multi_edit($methods, 'admin', 'admin_multi_edit', $page, $sort, $dir, $crit, $search_method);
}
Example #4
0
function section_multiedit_form($page, $sort, $dir, $crit, $search_method)
{
    global $all_pages, $all_styles;
    $methods = array('changepage' => array('label' => gTxt('uses_page'), 'html' => selectInput('uses_page', $all_pages, '', false)), 'changecss' => array('label' => gTxt('uses_style'), 'html' => selectInput('css', $all_styles, '', false)), 'changeonfrontpage' => array('label' => gTxt('on_front_page'), 'html' => yesnoRadio('on_frontpage', 1)), 'changesyndicate' => array('label' => gTxt('syndicate'), 'html' => yesnoRadio('in_rss', 1)), 'changesearchable' => array('label' => gTxt('include_in_search'), 'html' => yesnoRadio('searchable', 1)), 'delete' => gTxt('delete'));
    return multi_edit($methods, 'section', 'section_multi_edit', $page, $sort, $dir, $crit, $search_method);
}
Example #5
0
function link_multiedit_form($page, $sort, $dir, $crit, $search_method)
{
    global $all_link_cats, $all_link_authors;
    $categories = $all_link_cats ? treeSelectInput('category', $all_link_cats, '') : '';
    $authors = $all_link_authors ? selectInput('author', $all_link_authors, '', true) : '';
    $methods = array('changecategory' => array('label' => gTxt('changecategory'), 'html' => $categories), 'changeauthor' => array('label' => gTxt('changeauthor'), 'html' => $authors), 'delete' => gTxt('delete'));
    if (!$categories) {
        unset($methods['changecategory']);
    }
    if (has_single_author('txp_link')) {
        unset($methods['changeauthor']);
    }
    if (!has_privs('link.delete.own') && !has_privs('link.delete')) {
        unset($methods['delete']);
    }
    return multi_edit($methods, 'link', 'link_multi_edit', $page, $sort, $dir, $crit, $search_method);
}
Example #6
0
/**
 * Renders a multi-edit form widget for articles.
 *
 * @param  int    $page          The page number
 * @param  string $sort          The current sort value
 * @param  string $dir           The current sort direction
 * @param  string $crit          The current search criteria
 * @param  string $search_method The current search method
 * @return string HTML
 */
function list_multiedit_form($page, $sort, $dir, $crit, $search_method)
{
    global $statuses, $all_cats, $all_authors, $all_sections;
    if ($all_cats) {
        $category1 = treeSelectInput('Category1', $all_cats, '');
        $category2 = treeSelectInput('Category2', $all_cats, '');
    } else {
        $category1 = $category2 = '';
    }
    $sections = $all_sections ? selectInput('Section', $all_sections, '', true) : '';
    $comments = onoffRadio('Annotate', get_pref('comments_on_default'));
    $status = selectInput('Status', $statuses, '', true);
    $authors = $all_authors ? selectInput('AuthorID', $all_authors, '', true) : '';
    $methods = array('changesection' => array('label' => gTxt('changesection'), 'html' => $sections), 'changecategory1' => array('label' => gTxt('changecategory1'), 'html' => $category1), 'changecategory2' => array('label' => gTxt('changecategory2'), 'html' => $category2), 'changestatus' => array('label' => gTxt('changestatus'), 'html' => $status), 'changecomments' => array('label' => gTxt('changecomments'), 'html' => $comments), 'changeauthor' => array('label' => gTxt('changeauthor'), 'html' => $authors), 'duplicate' => gTxt('duplicate'), 'delete' => gTxt('delete'));
    if (!$all_cats) {
        unset($methods['changecategory1'], $methods['changecategory2']);
    }
    if (has_single_author('textpattern', 'AuthorID')) {
        unset($methods['changeauthor']);
    }
    if (!has_privs('article.delete.own') && !has_privs('article.delete')) {
        unset($methods['delete']);
    }
    return multi_edit($methods, 'list', 'list_multi_edit', $page, $sort, $dir, $crit, $search_method);
}
Example #7
0
function author_multiedit_form($page, $sort, $dir, $crit, $search_method)
{
    $privileges = privs();
    $rs = safe_column('name', 'txp_users', '1=1');
    $assign_assets = $rs ? '<label for="assign_assets">' . gTxt('assign_assets_to') . '</label>' . n . selectInput('assign_assets', $rs, '', true, '', 'assign_assets') : '';
    $methods = array('changeprivilege' => array('label' => gTxt('changeprivilege'), 'html' => $privileges), 'resetpassword' => gTxt('resetpassword'), 'delete' => array('label' => gTxt('delete'), 'html' => $assign_assets));
    if (safe_count('txp_users', '1=1') <= 1) {
        unset($methods['delete']);
    }
    // Sorry guy, you're last.
    return multi_edit($methods, 'admin', 'admin_multi_edit', $page, $sort, $dir, $crit, $search_method);
}
Example #8
0
/**
 * Renders a list of form templates.
 *
 * This function returns a list of form templates,
 * wrapped in a multi-edit form widget.
 *
 * @param  string $curname The selected form
 * @return string HTML
 */
function form_list($curname)
{
    global $essential_forms, $form_types;
    $criteria = 1;
    $criteria .= callback_event('admin_criteria', 'form_list', 0, $criteria);
    $rs = safe_rows_start('*', 'txp_form', "{$criteria} order by field(type, " . join(',', quote_list(array_keys($form_types))) . ") asc, name asc");
    if ($rs) {
        $prev_type = null;
        $group_out = array();
        while ($a = nextRow($rs)) {
            extract($a);
            $active = $curname === $name;
            if ($prev_type !== $type) {
                if ($prev_type !== null) {
                    $group_out = tag(n . join(n, $group_out) . n, 'ul', array('class' => 'switcher-list'));
                    $out[] = wrapRegion($prev_type . '_forms_group', $group_out, 'form_' . $prev_type, $form_types[$prev_type], 'form_' . $prev_type);
                }
                $prev_type = $type;
                $group_out = array();
            }
            if ($active) {
                $editlink = txpspecialchars($name);
            } else {
                $editlink = eLink('form', 'form_edit', 'name', $name, $name);
            }
            if (!in_array($name, $essential_forms)) {
                $modbox = span(checkbox('selected_forms[]', txpspecialchars($name), false), array('class' => 'switcher-action'));
            } else {
                $modbox = '';
            }
            $group_out[] = tag(n . $modbox . $editlink . n, 'li', array('class' => $active ? 'active' : ''));
        }
        if ($prev_type !== null) {
            $group_out = tag(n . join(n, $group_out) . n, 'ul', array('class' => 'switcher-list'));
            $out[] = wrapRegion($prev_type . '_forms_group', $group_out, 'form_' . $prev_type, $form_types[$prev_type], 'form_' . $prev_type);
        }
        $methods = array('changetype' => array('label' => gTxt('changetype'), 'html' => formTypes('', false, 'changetype')), 'delete' => gTxt('delete'));
        $out[] = multi_edit($methods, 'form', 'form_multi_edit');
        return form(join('', $out), '', '', 'post', '', '', 'allforms_form');
    }
}
Example #9
0
function file_multiedit_form($page, $sort, $dir, $crit, $search_method)
{
    global $file_statuses, $all_file_cats, $all_file_authors;
    $categories = $all_file_cats ? treeSelectInput('category', $all_file_cats, '') : '';
    $authors = $all_file_authors ? selectInput('author', $all_file_authors, '', true) : '';
    $status = selectInput('status', $file_statuses, '', true);
    $methods = array('changecategory' => array('label' => gTxt('changecategory'), 'html' => $categories), 'changeauthor' => array('label' => gTxt('changeauthor'), 'html' => $authors), 'changestatus' => array('label' => gTxt('changestatus'), 'html' => $status), 'changecount' => array('label' => gTxt('reset_download_count')), 'delete' => gTxt('delete'));
    if (!$categories) {
        unset($methods['changecategory']);
    }
    if (has_single_author('txp_file')) {
        unset($methods['changeauthor']);
    }
    if (!has_privs('file.delete.own') && !has_privs('file.delete')) {
        unset($methods['delete']);
    }
    return multi_edit($methods, 'file', 'file_multi_edit', $page, $sort, $dir, $crit, $search_method);
}
Example #10
0
/**
 * Renders a multi-edit form.
 *
 * @param  string $area  Type of category
 * @param  array  $array Additional HTML added to the form
 * @return string HTML
 */
function cat_article_multiedit_form($area, $array)
{
    $rs = getTree('root', $area);
    $categories = $rs ? treeSelectInput('new_parent', $rs, '') : '';
    $methods = array('changeparent' => array('label' => gTxt('changeparent'), 'html' => $categories), 'deleteforce' => gTxt('deleteforce'), 'delete' => gTxt('delete'));
    if ($array) {
        return form(join('', $array) . hInput('type', $area) . multi_edit($methods, 'category', 'cat_category_multiedit', '', '', '', '', '', $area), '', '', 'post', 'category-tree', '', 'category_' . $area . '_form');
    }
    return;
}
Example #11
0
function discuss_multiedit_form($page, $sort, $dir, $crit, $search_method)
{
    $methods = array('visible' => gTxt('show'), 'unmoderated' => gTxt('hide_unmoderated'), 'spam' => gTxt('hide_spam'), 'ban' => gTxt('ban_author'), 'delete' => gTxt('delete'));
    return multi_edit($methods, 'discuss', 'discuss_multi_edit', $page, $sort, $dir, $crit, $search_method);
}
Example #12
0
function plugin_multiedit_form($page, $sort, $dir, $crit, $search_method)
{
    $orders = selectInput('order', array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9), 5, false);
    $methods = array('changestatus' => gTxt('changestatus'), 'changeorder' => array('label' => gTxt('changeorder'), 'html' => $orders), 'delete' => gTxt('delete'));
    return multi_edit($methods, 'plugin', 'plugin_multi_edit', $page, $sort, $dir, $crit, $search_method);
}