Example #1
0
function sec_section_list($message = '')
{
    pagetop(gTxt('sections'), $message);
    global $wlink;
    $pageslist = safe_column("name", "txp_page", "1=1");
    $styleslist = safe_column("name", "txp_css", "1=1");
    $out[] = tr(tdcs(strong(gTxt('section_head')) . popHelp('section_category'), 3));
    $out[] = tr(tdcs(form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('Create'), 'smallerbox') . eInput('section') . sInput('section_create')), 3));
    $defrow = safe_row("page, css", "txp_section", "name like 'default'");
    $out[] = form(tr(td(gTxt('default')) . td(startTable('edit', 'left', '') . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $defrow['page']) . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $defrow['css']) . popHelp('section_uses_css'), '', 'noline')) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable()) . td()) . eInput('section') . sInput('section_save') . hInput('name', 'default'));
    $rs = safe_rows_start("*", "txp_section", "name!='' order by name");
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            if ($name == 'default') {
                continue;
            }
            $deletelink = dLink('section', 'section_delete', 'name', $name, '', 'type', 'section');
            $form = startTable('edit') . stackRows(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20), fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $page) . popHelp('section_uses_page'), '', 'noline'), fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $css) . popHelp('section_uses_css'), '', 'noline'), fLabelCell(gTxt('selected_by_default') . '?') . td(yesnoradio('is_default', $is_default) . popHelp('section_is_default'), '', 'noline'), fLabelCell(gTxt('on_front_page') . '?') . td(yesnoradio('on_frontpage', $on_frontpage) . popHelp('section_on_frontpage'), '', 'noline'), fLabelCell(gTxt('syndicate') . '?') . td(yesnoradio('in_rss', $in_rss) . popHelp('section_syndicate'), '', 'noline'), fLabelCell(gTxt('include_in_search') . '?') . td(yesnoradio('searchable', $searchable) . popHelp('section_searchable'), '', 'noline'), tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable() . eInput('section') . sInput('section_save') . hInput('old_name', $name);
            $form = form($form);
            $out[] = tr(td($name) . td($form) . td($deletelink));
        }
    }
    echo startTable('list') . join('', $out) . endTable();
}
Example #2
0
function form_list($curname)
{
    global $step, $essential_forms;
    $out[] = '<p class="action-create smallerbox">' . sLink('form', 'form_create', gTxt('create_new_form')) . '</p>';
    $methods = array('delete' => gTxt('delete'));
    $rs = safe_rows_start("*", "txp_form", "1 order by type 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) : htmlspecialchars($name);
            $modbox = !in_array($name, $essential_forms) ? '<input type="checkbox" name="selected_forms[]" value="' . $name . '" />' : '';
            if ($prev_type != $type) {
                $visipref = 'pane_form_' . $type . '_visible';
                //TODO: Add 'article', 'comment', 'misc' to rpc server for gTxt()
                $group_start = '<div class="form-list-group ' . $type . '"><h3 class="plain lever' . (get_pref($visipref) ? ' expanded' : '') . '"><a href="#' . $type . '">' . ucfirst(gTxt($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 class="' . ($ctr % 2 == 0 ? 'even' : 'odd') . '">' . 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[] = eInput('form') . sInput('form_multi_edit');
        $out[] = graf(selectInput('edit_method', $methods, '', 1) . sp . gTxt('selected') . sp . fInput('submit', 'form_multi_edit', gTxt('go'), 'smallerbox'), ' align="right"');
        return form(join('', $out), '', "verify('" . gTxt('are_you_sure') . "')", 'post', '', '', 'allforms_form');
    }
}
Example #3
0
function plugin_list($message = '')
{
    pagetop(gTxt('edit_plugins'), $message);
    echo n . n . startTable('edit') . tr(tda(plugin_form(), ' colspan="8" style="height: 30px; border: none;"')) . endTable();
    extract(gpsa(array('sort', 'dir')));
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) {
        $sort = 'name';
    }
    $sort_sql = $sort . ' ' . $dir;
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $rs = safe_rows_start('name, status, author, author_uri, version, description, length(help) as help, abs(strcmp(md5(code),code_md5)) as modified, load_order, flags', 'txp_plugin', '1 order by ' . $sort_sql);
    if ($rs and numRows($rs) > 0) {
        echo '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list') . tr(column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', 'name' == $sort ? $dir : '') . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', 'author' == $sort ? $dir : '') . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', 'version' == $sort ? $dir : '') . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', 'modified' == $sort ? $dir : '') . hCell(gTxt('description')) . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', 'status' == $sort ? $dir : '') . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', 'load_order' == $sort ? $dir : '') . hCell(gTxt('manage'), '', ' class="manage"') . hCell());
        while ($a = nextRow($rs)) {
            foreach ($a as $key => $value) {
                ${$key} = htmlspecialchars($value);
            }
            // Fix up the description for clean cases
            $description = preg_replace(array('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), array('<br />', '<$1>', '<a href="$1$2">'), $description);
            $help = !empty($help) ? n . t . '<li><a href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . urlencode($name) . '">' . gTxt('help') . '</a></li>' : '';
            $plugin_prefs = $flags & PLUGIN_HAS_PREFS && $status ? n . t . '<li><a href="?event=plugin_prefs.' . urlencode($name) . '">' . gTxt('plugin_prefs') . '</a></li>' : '';
            echo tr(n . td($name) . td(href($author, $author_uri)) . td($version, 10) . td($modified ? gTxt('yes') : '') . td($description, 260) . td(status_link($status, $name, yes_no($status)), 30) . td($load_order) . td(n . '<ul class="plugin_manage">' . $help . n . t . '<li>' . eLink('plugin', 'plugin_edit', 'name', $name, gTxt('edit')) . '</li>' . $plugin_prefs . n . '</ul>') . td(fInput('checkbox', 'selected[]', $name), 30));
            unset($name, $page, $deletelink);
        }
        echo tr(tda(select_buttons() . plugin_multiedit_form('', $sort, $dir, '', ''), ' colspan="10" style="text-align: right; border: none;"')) . n . endTable() . n . '</form>';
    }
}
Example #4
0
function file_download_list($atts)
{
    global $thisfile;
    extract(lAtts(array('break' => br, 'category' => '', 'class' => __FUNCTION__, 'form' => 'files', 'label' => '', 'labeltag' => '', 'limit' => '10', 'offset' => '0', 'sort' => 'filename asc', 'wraptag' => '', 'status' => '4'), $atts));
    if (!is_numeric($status)) {
        $status = getStatusNum($status);
    }
    $where = array('1=1');
    if ($category) {
        $where[] = "category IN ('" . join("','", doSlash(do_list($category))) . "')";
    }
    if ($status) {
        $where[] = "status = '" . doSlash($status) . "'";
    }
    $qparts = array('order by ' . doSlash($sort), $limit ? 'limit ' . intval($offset) . ', ' . intval($limit) : '');
    $rs = safe_rows_start('*, unix_timestamp(created) as created, unix_timestamp(modified) as modified', 'txp_file', join(' and ', $where) . ' ' . join(' ', $qparts));
    if ($rs) {
        $out = array();
        while ($thisfile = nextRow($rs)) {
            $out[] = parse_form($form);
            $thisfile = '';
        }
        if ($out) {
            if ($wraptag == 'ul' or $wraptag == 'ol') {
                return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class);
            }
            return $wraptag ? tag(join($break, $out), $wraptag) : join(n, $out);
        }
    }
    return '';
}
Example #5
0
/**
 * Renders a list of stylesheets.
 *
 * @param  string $current The active stylesheet
 * @param  string $default Not used
 * @return string HTML
 */
function css_list($current, $default)
{
    $out = array();
    $protected = safe_column('DISTINCT css', 'txp_section', '1=1');
    $criteria = 1;
    $criteria .= callback_event('admin_criteria', 'css_list', 0, $criteria);
    $rs = safe_rows_start('name', 'txp_css', $criteria);
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            $active = $current === $name;
            if ($active) {
                $edit = txpspecialchars($name);
            } else {
                $edit = eLink('css', '', 'name', $name, $name);
            }
            if (!array_key_exists($name, $protected)) {
                $edit .= dLink('css', 'css_delete', 'name', $name);
            }
            $out[] = tag(n . $edit . n, 'li', array('class' => $active ? 'active' : ''));
        }
        $out = tag(join(n, $out), 'ul', array('class' => 'switcher-list'));
        return wrapGroup('all_styles', $out, 'all_stylesheets');
    }
}
Example #6
0
function build_rss()
{
    global $site_url, $site_name;
    if (public_page_exists('rss')) {
        $i = 0;
        /* Prevents insecure undefined variable $i */
        $rs = safe_rows_start('*', 'pixie_module_rss', "1 order by feed_display_name desc");
        $num = count($rs);
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"{$feed_display_name}\" href=\"{$url}\" />\n\t";
                $i++;
            }
        }
    } else {
        $rs = safe_rows('*', 'pixie_dynamic_settings', "rss = 'yes'");
        $num = count($rs);
        if ($rs) {
            $i = 0;
            while ($i < $num) {
                $out = $rs[$i];
                $page_id = $out['page_id'];
                $rs1 = safe_row('*', 'pixie_core', "page_id = '{$page_id}' limit 0,1");
                extract($rs1);
                echo "<link rel=\"alternate\" type=\"application/rss+xml\" title=\"{$site_name} - {$page_display_name}\" href=\"{$site_url}{$page_name}/rss/\" />\n\t";
                $i++;
            }
        }
    }
}
Example #7
0
function plugin_list($message = '')
{
    global $event;
    pagetop(gTxt('tab_plugins'), $message);
    echo '<h1 class="txp-heading">' . gTxt('tab_plugins') . '</h1>';
    echo '<div id="' . $event . '_control" class="txp-control-panel">';
    echo n . plugin_form() . n . '</div>';
    extract(gpsa(array('sort', 'dir')));
    if ($sort === '') {
        $sort = get_pref('plugin_sort_column', 'name');
    }
    if ($dir === '') {
        $dir = get_pref('plugin_sort_dir', 'asc');
    }
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) {
        $sort = 'name';
    }
    $sort_sql = $sort . ' ' . $dir;
    set_pref('plugin_sort_column', $sort, 'plugin', 2, '', 0, PREF_PRIVATE);
    set_pref('plugin_sort_dir', $dir, 'plugin', 2, '', 0, PREF_PRIVATE);
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    $rs = safe_rows_start('name, status, author, author_uri, version, description, length(help) as help, abs(strcmp(md5(code),code_md5)) as modified, load_order, flags', 'txp_plugin', '1 order by ' . $sort_sql);
    if ($rs and numRows($rs) > 0) {
        echo n . '<div id="' . $event . '_container" class="txp-container">';
        echo '<form action="index.php" id="plugin_form" class="multi_edit_form" method="post" name="longform">' . n . '<div class="txp-listtables">' . n . startTable('', '', 'txp-list') . n . '<thead>' . tr(n . hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' title="' . gTxt('toggle_all_selected') . '" class="multi-edit"') . n . column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'name') . n . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', ('author' == $sort ? "{$dir} " : '') . 'author') . n . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', ('version' == $sort ? "{$dir} " : '') . 'version') . n . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', ('modified' == $sort ? "{$dir} " : '') . 'modified') . n . hCell(gTxt('description'), '', ' class="description"') . n . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', ('status' == $sort ? "{$dir} " : '') . 'status') . n . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', ('load_order' == $sort ? "{$dir} " : '') . 'load-order') . n . hCell(gTxt('manage'), '', ' class="manage actions"')) . n . '</thead>';
        echo '<tbody>';
        while ($a = nextRow($rs)) {
            foreach ($a as $key => $value) {
                ${$key} = txpspecialchars($value);
            }
            // Fix up the description for clean cases
            $description = preg_replace(array('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), array('<br />', '<$1>', '<a href="$1$2">'), $description);
            $help = !empty($help) ? '<a class="plugin-help" href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . urlencode($name) . '">' . gTxt('help') . '</a>' : '';
            $plugin_prefs = $flags & PLUGIN_HAS_PREFS ? '<a class="plugin-prefs" href="?event=plugin_prefs.' . urlencode($name) . '">' . gTxt('plugin_prefs') . '</a>' : '';
            $manage = array();
            if ($help) {
                $manage[] = $help;
            }
            if ($plugin_prefs) {
                $manage[] = $plugin_prefs;
            }
            $manage_items = $manage ? join(tag(sp . '&#124;' . sp, 'span'), $manage) : '-';
            $edit_url = eLink('plugin', 'plugin_edit', 'name', $name, $name);
            echo tr(n . td(fInput('checkbox', 'selected[]', $name), '', 'multi-edit') . td($edit_url, '', 'name') . td(href($author, $author_uri, ' rel="external"'), '', 'author') . td($version, '', 'version') . td($modified ? '<span class="warning">' . gTxt('yes') . '</span>' : '', '', 'modified') . td($description, '', 'description') . td(status_link($status, $name, yes_no($status)), '', 'status') . td($load_order, '', 'load-order') . td($manage_items, '', 'manage'), $status ? ' class="active"' : '');
            unset($name, $page, $deletelink);
        }
        echo '</tbody>', n, endTable(), n, '</div>', n, plugin_multiedit_form('', $sort, $dir, '', ''), n, tInput(), n, '</form>', n, '</div>';
        // Show/hide "Options" link by setting the appropriate class on the plugins TR
        echo script_js(<<<EOS
textpattern.Relay.register('txpAsyncHref.success', function(event, data) {
\t\$(data['this']).closest('tr').toggleClass('active');
});
EOS
);
    }
}
Example #8
0
/**
 * The main panel listing all installed plugins.
 *
 * @param string|array $message The activity message
 */
function plugin_list($message = '')
{
    global $event;
    pagetop(gTxt('tab_plugins'), $message);
    extract(gpsa(array('sort', 'dir')));
    if ($sort === '') {
        $sort = get_pref('plugin_sort_column', 'name');
    } else {
        if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) {
            $sort = 'name';
        }
        set_pref('plugin_sort_column', $sort, 'plugin', 2, '', 0, PREF_PRIVATE);
    }
    if ($dir === '') {
        $dir = get_pref('plugin_sort_dir', 'asc');
    } else {
        $dir = $dir == 'desc' ? "desc" : "asc";
        set_pref('plugin_sort_dir', $dir, 'plugin', 2, '', 0, PREF_PRIVATE);
    }
    $sort_sql = "{$sort} {$dir}";
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    echo n . tag(hed(gTxt('tab_plugins'), 1, array('class' => 'txp-heading')), 'div', array('class' => 'txp-layout-2col-cell-1')) . n . tag_start('div', array('class' => 'txp-layout-1col', 'id' => $event . '_container')) . n . tag(plugin_form(), 'div', array('class' => 'txp-control-panel'));
    $rs = safe_rows_start("name, status, author, author_uri, version, description, length(help) AS help, ABS(STRCMP(MD5(code), code_md5)) AS modified, load_order, flags", 'txp_plugin', "1 = 1 ORDER BY {$sort_sql}");
    if ($rs and numRows($rs) > 0) {
        echo n . tag_start('form', array('class' => 'multi_edit_form', 'id' => 'plugin_form', 'name' => 'longform', 'method' => 'post', 'action' => 'index.php')) . n . tag_start('div', array('class' => 'txp-listtables')) . n . tag_start('table', array('class' => 'txp-list')) . n . tag_start('thead') . tr(hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' class="txp-list-col-multi-edit" scope="col" title="' . gTxt('toggle_all_selected') . '"') . column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'txp-list-col-name') . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', ('author' == $sort ? "{$dir} " : '') . 'txp-list-col-author') . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', ('version' == $sort ? "{$dir} " : '') . 'txp-list-col-version') . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', ('modified' == $sort ? "{$dir} " : '') . 'txp-list-col-modified') . hCell(gTxt('description'), '', ' class="txp-list-col-description" scope="col"') . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', ('status' == $sort ? "{$dir} " : '') . 'txp-list-col-status') . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', ('load_order' == $sort ? "{$dir} " : '') . 'txp-list-col-load-order') . hCell(gTxt('manage'), '', ' class="txp-list-col-manage" scope="col"')) . n . tag_end('thead') . n . tag_start('tbody');
        while ($a = nextRow($rs)) {
            foreach ($a as $key => $value) {
                ${$key} = txpspecialchars($value);
            }
            // Fix up the description for clean cases.
            $description = preg_replace(array('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), array('<br />', '<$1>', '<a href="$1$2">'), $description);
            if (!empty($help)) {
                $help = href(gTxt('help'), array('event' => 'plugin', 'step' => 'plugin_help', 'name' => $name), array('class' => 'plugin-help'));
            }
            if ($flags & PLUGIN_HAS_PREFS) {
                $plugin_prefs = href(gTxt('plugin_prefs'), array('event' => 'plugin_prefs.' . $name), array('class' => 'plugin-prefs'));
            } else {
                $plugin_prefs = '';
            }
            $manage = array();
            if ($help) {
                $manage[] = $help;
            }
            if ($plugin_prefs) {
                $manage[] = $plugin_prefs;
            }
            $manage_items = $manage ? join(tag(sp . '&#124;' . sp, 'span'), $manage) : '-';
            $edit_url = eLink('plugin', 'plugin_edit', 'name', $name, $name);
            echo tr(td(fInput('checkbox', 'selected[]', $name), '', 'txp-list-col-multi-edit') . hCell($edit_url, '', ' class="txp-list-col-name" scope="row"') . td(href($author, $a['author_uri'], array('rel' => 'external')), '', 'txp-list-col-author') . td($version, '', 'txp-list-col-version') . td($modified ? span(gTxt('yes'), array('class' => 'warning')) : '', '', 'txp-list-col-modified') . td($description, '', 'txp-list-col-description') . td(status_link($status, $name, yes_no($status)), '', 'txp-list-col-status') . td($load_order, '', 'txp-list-col-load-order') . td($manage_items, '', 'txp-list-col-manage'), $status ? ' class="active"' : '');
            unset($name, $page, $deletelink);
        }
        echo n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . plugin_multiedit_form('', $sort, $dir, '', '') . tInput() . n . tag_end('form');
    }
    echo n . tag_end('div');
}
Example #9
0
function page_list($current)
{
    $rs = safe_rows_start("name", "txp_page", "name != '' order by name");
    while ($a = nextRow($rs)) {
        extract($a);
        $dlink = $name != 'default' ? dLink('page', 'page_delete', 'name', $name) : '';
        $link = '<a href="?event=page' . a . 'name=' . $name . '">' . $name . '</a>';
        $out[] = $current == $name ? tr(td($name) . td($dlink)) : tr(td($link) . td($dlink));
    }
    return startTable('list') . join(n, $out) . endTable();
}
Example #10
0
function page_list($current)
{
    $protected = safe_column('DISTINCT page', 'txp_section', '1=1') + array('error_default');
    $rs = safe_rows_start('name', 'txp_page', "1 order by name asc");
    while ($a = nextRow($rs)) {
        extract($a);
        $link = eLink('page', '', 'name', $name, $name);
        $dlink = !in_array($name, $protected) ? dLink('page', 'page_delete', 'name', $name) : '';
        $out[] = $current == $name ? tr(td($name) . td($dlink)) : tr(td($link) . td($dlink));
    }
    return startTable('list') . join(n, $out) . endTable();
}
Example #11
0
function list_list($message = "", $post = '')
{
    extract(get_prefs());
    $lvars = array("page", "sort", "dir", "crit", 'method');
    extract(gpsa($lvars));
    global $statuses, $step;
    $sesutats = array_flip($statuses);
    pagetop(gTxt('tab_list'), $message);
    $total = getCount('textpattern', "1");
    $limit = max(@$article_list_pageby, 25);
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    if (!$sort) {
        $sort = "Posted";
    }
    if (!$dir) {
        $dir = "desc";
    }
    if ($dir == "desc") {
        $linkdir = "asc";
    } else {
        $linkdir = "desc";
    }
    if ($crit) {
        $critsql = array('title_body' => "Title rlike '{$crit}' or Body rlike '{$crit}'", 'author' => "AuthorID rlike '{$crit}'", 'categories' => "Category1 rlike '{$crit}' or Category2 rlike '{$crit}'", 'section' => "Section rlike '{$crit}'", 'status' => "Status = '" . @$sesutats[$crit] . "'");
        $criteria = $critsql[$method];
        $limit = 500;
    } else {
        $criteria = 1;
    }
    $rs = safe_rows_start("*, unix_timestamp(Posted) as uPosted", "textpattern", "{$criteria} order by {$sort} {$dir} limit {$offset}, {$limit}");
    echo !$crit ? list_nav_form($page, $numPages, $sort, $dir) : '', list_searching_form($crit, $method);
    if ($rs) {
        echo '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list'), '<tr>', column_head('posted', 'posted', 'list', 1, $linkdir), column_head('title', 'title', 'list', 1, $linkdir), column_head('section', 'section', 'list', 1, $linkdir), column_head('category1', 'category1', 'list', 1, $linkdir) . column_head('category2', 'category2', 'list', 1, $linkdir), hCell(gTxt('author')), column_head(gTxt('status'), 'Status', 'list', 1, $linkdir), td(), '</tr>';
        while ($a = nextRow($rs)) {
            extract($a);
            $stat = !empty($Status) ? $statuses[$Status] : '';
            $adate = date("d M y", $uPosted + tz_offset());
            $alink = eLink('article', 'edit', 'ID', $ID, $adate);
            $tlink = eLink('article', 'edit', 'ID', $ID, $Title);
            $modbox = fInput('checkbox', 'selected[]', $ID, '', '', '', '', '', $ID);
            echo "<tr>" . n, td($alink), td($tlink, 200), td($Section, 75), td($Category1, 75) . td($Category2, 75), td($AuthorID), td($stat, 45), td($modbox), '</tr>' . n;
        }
        echo tr(tda(select_buttons() . list_multiedit_form(), ' colspan="8" style="text-align:right;border:0px"'));
        echo "</table></form>";
        echo pageby_form('list', $article_list_pageby);
        unset($sort);
    }
}
Example #12
0
function plugin_list($message = '')
{
    pagetop(gTxt('edit_plugins'), $message);
    echo startTable('list') . tr(tda(plugin_form() . plugin_form_old(), ' colspan="8" style="border:0;height:50px"')) . assHead('plugin', 'author', 'version', 'description', 'active', '', '', '');
    $rs = safe_rows_start("*", "txp_plugin", "1 order by name");
    while ($a = nextRow($rs)) {
        extract($a);
        $elink = eLink('plugin', 'plugin_edit', 'name', $name, gTxt('edit'));
        $hlink = '<a href="?event=plugin&#38;step=plugin_help&#38;name=' . $name . '">' . gTxt('help') . '</a>';
        echo tr(td($name) . td('<a href="' . $author_uri . '">' . $author . '</a>') . td($version, 10) . td($description, 260) . td(status_link($status, $name, yes_no($status)), 30) . td($elink) . td($hlink) . td(dLink('plugin', 'plugin_delete', 'name', $name), 30));
        unset($name, $page, $deletelink);
    }
    echo endTable();
}
Example #13
0
function css_list($name)
{
    $out[] = startTable('list', 'left');
    $rs = safe_rows_start("name as cssname", "txp_css", "1");
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            $namelink = $name != $cssname ? eLink('css', '', 'name', $cssname, $cssname) : $cssname;
            $deletelink = $cssname != 'default' ? dLink('css', 'css_delete', 'name', $cssname) : '';
            $out[] = tr(td($namelink) . td($deletelink));
        }
        $out[] = endTable();
        return join('', $out);
    }
}
Example #14
0
function css_list($current, $default)
{
    $out[] = startTable('list', 'left');
    $rs = safe_rows_start('name', 'txp_css', "1=1");
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            $edit = $current != $name ? eLink('css', '', 'name', $name, $name) : $name;
            $delete = $name != $default ? dLink('css', 'css_delete', 'name', $name) : '';
            $out[] = tr(td($edit) . td($delete));
        }
        $out[] = endTable();
        return join('', $out);
    }
}
Example #15
0
function parseCSV(&$csv, $function)
{
    $fieldNames = nextRow($csv);
    $fieldCount = sizeof($fieldNames);
    while (strlen($csv) > 0) {
        $fields = nextRow($csv);
        if (sizeof($fields) > 0) {
            $next = [];
            for ($i = 0; $i < $fieldCount; $i++) {
                $next[$fieldNames[$i]] = @$fields[$i];
            }
            $function($next);
        }
    }
}
Example #16
0
function get_user_prefs()
{
    global $txp_user;
    if (empty($txp_user)) {
        return array();
    }
    $r = safe_rows_start('name, val', 'txp_prefs_user', "user='******'");
    if ($r) {
        $out = array();
        while ($a = nextRow($r)) {
            $out[$a['name']] = $a['val'];
        }
        return $out;
    }
    return array();
}
function sec_section_list($message = '')
{
    global $wlink;
    pagetop(gTxt('sections'), $message);
    $default = safe_row('page, css', 'txp_section', "name = 'default'");
    $pages = safe_column('name', 'txp_page', "1 = 1");
    $styles = safe_column('name', 'txp_css', "1 = 1");
    echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 1) . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create')), ' colspan="3"')) . n . n . tr(td(gTxt('default')) . td(form('<table>' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $default['page']) . sp . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $default['css']) . sp . popHelp('section_uses_css'), '', 'noline')) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'default'), ' colspan="2" class="noline"')) . endTable())) . td());
    $rs = safe_rows_start('*', 'txp_section', "name != 'default' order by name");
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            echo n . n . tr(n . td($name) . n . td(form('<table>' . n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20)) . n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20)) . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline')) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('old_name', $name), ' colspan="2" class="noline"')) . endTable(), '', '', 'post', '', 'section-' . $name)) . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section')), " id=\"section-{$name}\"");
        }
    }
    echo n . n . endTable();
}
Example #18
0
function css_list($current, $default)
{
    $out[] = startTable('', '', 'txp-list');
    $criteria = 1;
    $criteria .= callback_event('admin_criteria', 'css_list', 0, $criteria);
    $rs = safe_rows_start('name', 'txp_css', $criteria);
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            $edit = $current != $name ? eLink('css', '', 'name', $name, $name) : txpspecialchars($name);
            $delete = $name != $default ? dLink('css', 'css_delete', 'name', $name) : '';
            $out[] = tr(td($edit) . td($delete));
        }
        $out[] = endTable();
        return join('', $out);
    }
}
Example #19
0
function css_list($current, $default)
{
    $out[] = startTable('list', 'left', 'list');
    $rs = safe_rows_start('name', 'txp_css', "1=1");
    $ctr = 1;
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            $edit = $current != $name ? eLink('css', '', 'name', $name, $name) : htmlspecialchars($name);
            $delete = $name != $default ? dLink('css', 'css_delete', 'name', $name) : '';
            $trcls = ' class="' . (($ctr == 1 ? 'first ' : '') . ($ctr % 2 == 0 ? 'even' : 'odd')) . '"';
            $out[] = tr(td($edit) . td($delete), $trcls);
            $ctr++;
        }
        $out[] = endTable();
        return join('', $out);
    }
}
Example #20
0
function sec_section_list($message = '')
{
    global $wlink, $event;
    pagetop(gTxt('sections'), $message);
    $default = safe_row('page, css, name', 'txp_section', "name = 'default'");
    echo n . '<div id="' . $event . '_container" class="txp-container txp-list">';
    echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 2) . n . '<div id="' . $event . '_control" class="txp-control-panel">' . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create'), '', '', 'post', 'edit-form', '', 'section_create') . n . '</div>', ' colspan="3"')) . n . n . tr(td(gTxt('default'), '', 'label') . n . td(section_detail_partial($default)) . n . td(), ' class="section default"');
    $rs = safe_rows_start('*', 'txp_section', "name != 'default' order by name");
    if ($rs) {
        $ctr = 1;
        while ($a = nextRow($rs)) {
            extract($a);
            echo n . n . tr(n . td($name, '', 'label') . n . td(section_detail_partial($a), '', 'main') . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section'), '', 'actions'), ' id="section-' . $name . '" class="section ' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"');
            $ctr++;
        }
    }
    echo n . n . endTable() . '</div>';
}
Example #21
0
function sec_section_list($message = '')
{
    global $wlink;
    pagetop(gTxt('sections'), $message);
    $default = safe_row('page, css', 'txp_section', "name = 'default'");
    $home = safe_row('page, css', 'txp_section', "name = 'home'");
    $pages = safe_column('name', 'txp_page', "1 = 1");
    $styles = safe_column('name', 'txp_css', "1 = 1");
    echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 1) . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create')), ' colspan="3"')) . n . n . tr(tda(gTxt('home'), ' onclick="toggleDisplay(\'section_home\'); return false;"') . td(form('<table id="section_home">' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $home['page']) . sp . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $home['css']) . sp . popHelp('section_uses_css'), '', 'noline')) . pluggable_ui('section_ui', 'extend_detail_form', '', $home) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'home'), ' colspan="2" class="noline"')) . endTable())) . td()) . n . n . tr(tda(gTxt('default'), ' onclick="toggleDisplay(\'section_default\'); return false;"') . td(form('<table id="section_default">' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $default['page']) . sp . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $default['css']) . sp . popHelp('section_uses_css'), '', 'noline')) . pluggable_ui('section_ui', 'extend_detail_form', '', $default) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'default'), ' colspan="2" class="noline"')) . endTable())) . td());
    $rs = safe_rows_start('*', 'txp_section', "name != 'default' AND name != 'home' order by name");
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            echo n . n . tr(n . tda($name, ' onclick="toggleDisplay(\'section_' . $name . '\'); return false;"') . n . td(form('<table id="section_' . $name . '">' . n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20)) . n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20)) . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('section_descr') . ':') . fTextCell('descr', $descr, 1, 4, 20)) . n . n . tr(fLabelCell(gTxt('section_metakey') . ':') . fInputCell('metakey', $metakey, 1, 20)) . n . n . tr(fLabelCell(gTxt('section_metadesc') . ':') . fTextCell('metadesc', $metadesc, 1, 4, 20)) . pluggable_ui('section_ui', 'extend_detail_form', '', $a) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('old_name', $name), ' colspan="2" class="noline"')) . endTable(), '', '', 'post', '', 'section-' . $name)) . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section')), " id=\"section-{$name}\" class=\"jsection\" ");
        }
    }
    echo n . n . endTable();
}
Example #22
0
function log_list()
{
    pagetop(gTxt('visitor_logs'));
    extract(get_prefs());
    safe_delete("txp_log", "`time` < date_sub(now(),interval " . $expire_logs_after . " day)");
    safe_optimize("txp_log");
    safe_repair("txp_log");
    $page = gps('page');
    $total = getCount('txp_log', "1");
    $limit = 50;
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $nav[] = $page > 1 ? PrevNextLink("log", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("log", $page + 1, gTxt('next'), 'next') : '';
    $rs = safe_rows_start("*, unix_timestamp(time) as stamp", "txp_log", "1 order by time desc limit {$offset},{$limit}");
    if ($rs) {
        echo startTable('list'), assHead('time', 'host', 'page', 'referrer');
        $stamp = '';
        while ($a = nextRow($rs)) {
            extract($a);
            if ($refer) {
                $referprint = preg_replace("/^www\\./", "", chunk(htmlspecialchars($refer), 50));
                $referprint = '<a href="http://' . htmlspecialchars($refer) . '">' . $referprint . '</a>';
            } else {
                $referprint = '&#160;';
            }
            $pageprint = preg_replace('/\\/$/', '', htmlspecialchars(substr($page, 1)));
            $pageprint = $pageprint == '' ? '' : '<a href="' . htmlspecialchars($page) . '" target="_blank">' . chunk($pageprint, 50) . '</a>';
            if ($method == 'POST') {
                $pageprint = '<b>' . $pageprint . '</b>';
            }
            $fstamp = date("n/j g:i a", $stamp + tz_offset());
            $hostprint = chunk($host, 40);
            echo tr(td($fstamp) . td($hostprint) . td($pageprint) . td($referprint));
            unset($refer, $referprint, $page, $pageprint);
        }
        echo '<tr><td colspan="4" align="right" style="padding:10px">', join('', $nav), "</td></tr>", endTable();
    } else {
        echo graf(gTxt('no_refers_recorded'), ' align="center"');
    }
}
Example #23
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 #24
0
function sec_section_list($message = '')
{
    global $wlink, $event;
    pagetop(gTxt('sections'), $message);
    $default = safe_row('page, css', 'txp_section', "name = 'default'");
    $pages = safe_column('name', 'txp_page', "1 = 1");
    $styles = safe_column('name', 'txp_css', "1 = 1");
    echo n . '<div id="' . $event . '_container" class="txp-container txp-list">';
    echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 2) . n . '<div id="' . $event . '_control" class="txp-control-panel">' . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create'), '', '', 'post', 'edit-form', '', 'section_create') . n . '</div>', ' colspan="3"')) . n . n . tr(td(gTxt('default'), '', 'label') . td(form('<table>' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $default['page']) . sp . popHelp('section_uses_page'), '', 'noline'), ' class="uses-page"') . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $default['css']) . sp . popHelp('section_uses_css'), '', 'noline'), ' class="uses-style"') . pluggable_ui('section_ui', 'extend_detail_form', '', $default) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'default'), ' colspan="2" class="noline"')) . endTable())) . td(), ' class="section default"');
    $rs = safe_rows_start('*', 'txp_section', "name != 'default' order by name");
    if ($rs) {
        $ctr = 1;
        while ($a = nextRow($rs)) {
            extract($a);
            echo n . n . tr(n . td($name, '', 'label') . n . td(form('<table>' . n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), ' class="name"') . n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20), ' class="title"') . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline'), ' class="uses-page"') . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline'), ' class="uses-style"') . n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline'), ' class="option is-default"') . n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline'), ' class="option on-frontpage"') . n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline'), ' class="option in-rss"') . n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline'), ' class="option is-searchable"') . pluggable_ui('section_ui', 'extend_detail_form', '', $a) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('old_name', $name), ' colspan="2" class="noline"')) . endTable(), '', '', 'post', '', 'section-' . $name), '', 'main') . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section'), '', 'actions'), ' id="section-' . $name . '" class="section ' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"');
            $ctr++;
        }
    }
    echo n . n . endTable() . '</div>';
}
Example #25
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 #26
0
function form_list($curname)
{
    global $step, $essential_forms;
    $out[] = startTable('list');
    $out[] = tr(tda(sLink('form', 'form_create', gTxt('create_new_form')), ' colspan="3" style="height:30px"'));
    $out[] = assHead('form', 'type', '');
    $methods = array('delete' => gTxt('delete'));
    $rs = safe_rows_start("*", "txp_form", "1 order by type asc, name asc");
    if ($rs) {
        while ($a = nextRow($rs)) {
            extract($a);
            $editlink = $curname != $name ? eLink('form', 'form_edit', 'name', $name, $name) : htmlspecialchars($name);
            $modbox = !in_array($name, $essential_forms) ? '<input type="checkbox" name="selected_forms[]" value="' . $name . '" />' : sp;
            $out[] = tr(td($editlink) . td(small($type)) . td($modbox));
        }
        $out[] = endTable();
        $out[] = eInput('form') . sInput('form_multi_edit');
        $out[] = graf(selectInput('edit_method', $methods, '', 1) . sp . gTxt('selected') . sp . fInput('submit', 'form_multi_edit', gTxt('go'), 'smallerbox'), ' align="right"');
        return form(join('', $out), '', "verify('" . gTxt('are_you_sure') . "')");
    }
}
Example #27
0
function tree_get_path($table, $target, $where = '1=1')
{
    extract(safe_row("lft as l, rgt as r", $table, "id='" . doSlash($target) . "' and {$where}"));
    if (empty($l) or empty($r)) {
        return array();
    }
    $rs = safe_rows_start("*", $table, "lft <= {$l} and rgt >= {$r} and {$where} order by lft asc");
    $out = array();
    $right = array();
    while ($rs and $row = nextRow($rs)) {
        extract($row);
        while (count($right) > 0 && $right[count($right) - 1] < $rgt) {
            array_pop($right);
        }
        $row['level'] = count($right);
        $row['children'] = ($rgt - $lft - 1) / 2;
        $out[] = $row;
        $right[] = $rgt;
    }
    return $out;
}
Example #28
0
 /**
  * Generates a list of authors.
  *
  * @param  array  $atts
  * @param  string $thing
  * @return string
  */
 public static function renderAuthors($atts, $thing = null)
 {
     global $thisauthor, $txp_groups;
     extract(lAtts(array('break' => '', 'class' => '', 'form' => '', 'group' => '', 'label' => '', 'labeltag' => '', 'limit' => '', 'name' => '', 'offset' => '', 'sort' => 'name ASC', 'wraptag' => ''), $atts));
     $sql = array('1 = 1');
     $sql_limit = '';
     $sql_sort = " ORDER BY " . doSlash($sort);
     if ($name) {
         $sql[] = "name IN (" . join(', ', quote_list(do_list($name))) . ")";
     }
     if ($group !== '') {
         $privs = do_list($group);
         $groups = array_flip($txp_groups);
         foreach ($privs as &$priv) {
             if (isset($groups[$priv])) {
                 $priv = $groups[$priv];
             }
         }
         $sql[] = 'convert(privs, char) in (' . join(', ', quote_list($privs)) . ')';
     }
     if ($limit !== '' || $offset) {
         $sql_limit = " LIMIT " . intval($offset) . ", " . ($limit === '' ? PHP_INT_MAX : intval($limit));
     }
     $rs = safe_rows_start("user_id as id, name, RealName as realname, email, privs, last_access", 'txp_users', join(" AND ", $sql) . " {$sql_sort} {$sql_limit}");
     if ($rs && numRows($rs)) {
         $out = array();
         if ($thing === null && $form !== '') {
             $thing = fetch_form($form);
         }
         while ($a = nextRow($rs)) {
             $oldauthor = $thisauthor;
             $thisauthor = $a;
             $out[] = parse($thing);
             $thisauthor = $oldauthor;
         }
         unset($thisauthor);
         return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class);
     }
     return '';
 }
Example #29
0
function plugin_list($message = '')
{
    pagetop(gTxt('edit_plugins'), $message);
    echo n . n . startTable('list') . tr(tda(plugin_form(), ' colspan="8" style="height: 30px; border: none;"'));
    $rs = safe_rows_start('name, status, author, author_uri, version, description, code_md5, length(help) as help, md5(code) as md5', 'txp_plugin', '1 order by name');
    if ($rs and numRows($rs) > 0) {
        echo assHead('plugin', 'author', 'version', 'plugin_modified', 'description', 'active', 'help', '', '');
        while ($a = nextRow($rs)) {
            foreach ($a as $key => $value) {
                ${$key} = htmlspecialchars($value);
            }
            // Fix up the description for clean cases
            $description = preg_replace(array('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), array('<br />', '<$1>', '<a href="$1$2">'), $description);
            $help = !empty($help) ? '<a href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . $name . '">' . gTxt('view') . '</a>' : gTxt('none');
            // modified?
            $modified = strtolower($md5) != strtolower($code_md5);
            echo tr(n . td($name) . td(href($author, $author_uri)) . td($version, 10) . td($modified ? gTxt('yes') : '') . td($description, 260) . td(status_link($status, $name, yes_no($status)), 30) . td($help) . td(eLink('plugin', 'plugin_edit', 'name', $name, gTxt('edit'))) . td(dLink('plugin', 'plugin_delete', 'name', $name), 30));
            unset($name, $page, $deletelink);
        }
    }
    echo endTable();
}
Example #30
0
function link_list($message = "")
{
    global $step, $link_list_pageby;
    extract(get_prefs());
    $page = gps('page');
    $total = getCount('txp_link', "1");
    $limit = max(@$link_list_pageby, 25);
    $numPages = ceil($total / $limit);
    $page = !$page ? 1 : $page;
    $offset = ($page - 1) * $limit;
    $sort = gps('sort');
    $dir = gps('dir');
    $sort = $sort ? $sort : 'linksort';
    $dir = $dir ? $dir : 'asc';
    if ($dir == "desc") {
        $dir = "asc";
    } else {
        $dir = "desc";
    }
    $nav[] = $page > 1 ? PrevNextLink("link", $page - 1, gTxt('prev'), 'prev') : '';
    $nav[] = sp . small($page . '/' . $numPages) . sp;
    $nav[] = $page != $numPages ? PrevNextLink("link", $page + 1, gTxt('next'), 'next') : '';
    $rs = safe_rows_start("*", "txp_link", "1 order by {$sort} {$dir} limit {$offset}, {$limit}");
    if ($rs) {
        echo '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list'), tr(column_head('link_name', 'linksort', 'link', 1, $dir) . column_head('description', 'description', 'link', 1, $dir) . column_head('link_category', 'category', 'link', 1, $dir) . td());
        while ($a = nextRow($rs)) {
            extract($a);
            $elink = eLink('link', 'link_edit', 'id', $id, $linkname);
            $cbox = fInput('checkbox', 'selected[]', $id);
            echo tr(td($elink) . td($description) . td($category) . td($cbox));
        }
        echo tr(tda(select_buttons() . link_multiedit_form(), ' colspan="4" style="border:0px;text-align:right"'));
        echo endTable(), '</form>';
        echo pageby_form('link', $link_list_pageby);
        echo graf(join('', $nav), ' align="center"');
    }
}