Example #1
0
function form_edit($message = '')
{
    global $step;
    pagetop(gTxt('edit_forms'), $message);
    extract(gpsa(array('Form', 'name', 'type')));
    if ($step == 'form_create') {
        $Form = '';
        $name = '';
        $type = '';
        $inputs = fInput('submit', 'savenew', gTxt('save_new'), 'publish') . eInput("form") . sInput('form_save');
    } else {
        $name = (!$name or $step == 'form_delete') ? 'default' : $name;
        $rs = safe_row("*", "txp_form", "name='{$name}'");
        if ($rs) {
            extract($rs);
            $inputs = fInput('submit', 'save', gTxt('save'), 'publish') . eInput("form") . sInput('form_save') . hInput('oldname', $name);
        }
    }
    $out = startTable('edit') . tr(tdtl(hed(gTxt('useful_tags'), 2) . graf(gTxt('articles') . sp . popHelp('form_place_article') . br . popTagLinks('article')) . graf(gTxt('links') . sp . popHelp('form_place_link') . br . popTagLinks('link')) . graf(gTxt('displayed_comments') . sp . popHelp('form_place_comment') . br . popTagLinks('comment')) . graf(gTxt('comment_form') . sp . popHelp('form_place_input') . br . popTagLinks('comment_form')) . graf(gTxt('search_input_form') . sp . popHelp('form_place_search_input') . br . popTagLinks('search_input')) . graf(gTxt('search_results_form') . sp . popHelp('form_place_search_results') . br . popTagLinks('search_result')) . graf(tag('<strong>' . gTxt('file_download_tags') . '</strong>', 'a', ' href="#" onclick="toggleDisplay(\'downloadtags\');"') . sp . popHelp('form_file_download_tags')) . graf(popTagLinks('file_download'), ' style="display:none;" id="downloadtags"')) . tdtl('<form action="index.php" method="post">' . input_textarea($Form) . graf(gTxt('form_name') . br . fInput('text', 'name', $name, 'edit', '', '', 15)) . graf(gTxt('form_type') . br . formtypes($type)) . graf(gTxt('only_articles_can_be_previewed')) . fInput('submit', 'preview', gTxt('preview'), 'smallbox') . graf($inputs) . '</form>') . tdtl(form_list($name))) . endTable();
    echo $out;
}
Example #2
0
function form_edit($message = '')
{
    global $step, $essential_forms;
    pagetop(gTxt('edit_forms'), $message);
    extract(gpsa(array('Form', 'name', 'type')));
    $name = trim(preg_replace('/[<>&"\']/', '', $name));
    if ($step == 'form_create') {
        $inputs = fInput('submit', 'savenew', gTxt('save_new'), 'publish') . eInput("form") . sInput('form_save');
    } else {
        $name = (!$name or $step == 'form_delete') ? 'default' : $name;
        $rs = safe_row("*", "txp_form", "name='" . doSlash($name) . "'");
        extract($rs);
        $inputs = fInput('submit', 'save', gTxt('save'), 'publish') . eInput("form") . sInput('form_save') . hInput('oldname', $name);
    }
    if (!in_array($name, $essential_forms)) {
        $changename = graf(gTxt('form_name') . br . fInput('text', 'name', $name, 'edit', '', '', 15));
    } else {
        $changename = graf(gTxt('form_name') . br . tag($name, 'em') . hInput('name', $name));
    }
    $out = startTable('edit') . tr(tdtl(hed(gTxt('tagbuilder'), 2) . hed('<a href="#article-tags" onclick="toggleDisplay(\'article-tags\'); return false;">' . gTxt('articles') . '</a>' . sp . popHelp('form_articles'), 3, ' class="plain"') . '<div id="article-tags" class="toggle on" style="display:block">' . popTagLinks('article') . '</div>' . hed('<a href="#link-tags" onclick="toggleDisplay(\'link-tags\'); return false;">' . gTxt('links') . '</a>' . sp . popHelp('form_place_link'), 3, ' class="plain"') . '<div id="link-tags" class="toggle" style="display:none">' . popTagLinks('link') . '</div>' . hed('<a href="#comment-tags" onclick="toggleDisplay(\'comment-tags\'); return false;">' . gTxt('comments') . '</a>' . sp . popHelp('form_comments'), 3, ' class="plain"') . '<div id="comment-tags" class="toggle" style="display:none">' . popTagLinks('comment') . '</div>' . hed('<a href="#comment-detail-tags" onclick="toggleDisplay(\'comment-detail-tags\'); return false;">' . gTxt('comment_details') . '</a>' . sp . popHelp('form_comment_details'), 3, ' class="plain"') . '<div id="comment-detail-tags" class="toggle" style="display:none">' . popTagLinks('comment_details') . '</div>' . hed('<a href="#comment-form-tags" onclick="toggleDisplay(\'comment-form-tags\'); return false;">' . gTxt('comment_form') . '</a>' . sp . popHelp('form_comment_form'), 3, ' class="plain"') . '<div id="comment-form-tags" class="toggle" style="display:none">' . popTagLinks('comment_form') . '</div>' . hed('<a href="#search-result-tags" onclick="toggleDisplay(\'search-result-tags\'); return false;">' . gTxt('search_results_form') . '</a>' . sp . popHelp('form_search_results'), 3, ' class="plain"') . '<div id="search-result-tags" class="toggle" style="display:none">' . popTagLinks('search_result') . '</div>' . hed('<a href="#file-tags" onclick="toggleDisplay(\'file-tags\'); return false;">' . gTxt('file_download_tags') . '</a>' . sp . popHelp('form_file_download_tags'), 3, ' class="plain"') . '<div id="file-tags" class="toggle" style="display:none">' . popTagLinks('file_download') . '</div>' . hed('<a href="#category-tags" onclick="toggleDisplay(\'category-tags\'); return false;">' . gTxt('category_tags') . '</a>' . sp . popHelp('form_category_tags'), 3, ' class="plain"') . '<div id="category-tags" class="toggle" style="display:none">' . popTagLinks('category') . '</div>' . hed('<a href="#section-tags" onclick="toggleDisplay(\'section-tags\'); return false;">' . gTxt('section_tags') . '</a>' . sp . popHelp('form_section_tags'), 3, ' class="plain"') . '<div id="section-tags" class="toggle" style="display:none">' . popTagLinks('section') . '</div>') . tdtl('<form action="index.php" method="post">' . '<textarea id="form" class="code" name="Form" cols="60" rows="20">' . htmlspecialchars($Form) . '</textarea>' . $changename . graf(gTxt('form_type') . br . formtypes($type)) . graf(gTxt('only_articles_can_be_previewed')) . fInput('submit', 'form_preview', gTxt('preview'), 'smallbox') . graf($inputs) . '</form>') . tdtl(form_list($name))) . endTable();
    echo $out;
}
Example #3
0
function taglinks($type)
{
    return popTagLinks($type);
}
Example #4
0
function form_edit($message = '')
{
    global $event, $step, $essential_forms;
    pagetop(gTxt('edit_forms'), $message);
    extract(gpsa(array('Form', 'name', 'type')));
    $name = trim(preg_replace('/[<>&"\']/', '', $name));
    if ($step == 'form_create') {
        $inputs = fInput('submit', 'savenew', gTxt('save_new'), 'publish') . eInput("form") . sInput('form_save');
    } else {
        $name = (!$name or $step == 'form_delete') ? 'default' : $name;
        $rs = safe_row("*", "txp_form", "name='" . doSlash($name) . "'");
        extract($rs);
        $inputs = fInput('submit', 'save', gTxt('save'), 'publish') . eInput("form") . sInput('form_save') . hInput('oldname', $name);
    }
    if (!in_array($name, $essential_forms)) {
        $changename = graf(gTxt('form_name') . br . fInput('text', 'name', $name, 'edit', '', '', INPUT_REGULAR));
    } else {
        $changename = graf(gTxt('form_name') . br . tag($name, 'em') . hInput('name', $name));
    }
    // Generate the tagbuilder links
    // Format of each entry is popTagLink -> array ( gTxt string, class/ID )
    $tagbuild_items = array('article' => array('articles', 'article-tags'), 'link' => array('links', 'link-tags'), 'comment' => array('comments', 'comment-tags'), 'comment_details' => array('comment_details', 'comment-detail-tags'), 'comment_form' => array('comment_form', 'comment-form-tags'), 'search_result' => array('search_results_form', 'search-result-tags'), 'file_download' => array('file_download_tags', 'file-tags'), 'category' => array('category_tags', 'category-tags'), 'section' => array('section_tags', 'section-tags'));
    $tagbuild_links = '';
    foreach ($tagbuild_items as $tb => $item) {
        $tagbuild_links .= '<div class="' . $item[1] . '">' . hed('<a href="#' . $item[1] . '">' . gTxt($item[0]) . '</a>', 3, ' class="lever' . (get_pref('pane_form_' . $item[1] . '_visible') ? ' expanded' : '') . '"') . '<div id="' . $item[1] . '" class="toggle on" style="display:' . (get_pref('pane_form_' . $item[1] . '_visible') ? 'block' : 'none') . '">' . popTagLinks($tb) . '</div></div>';
    }
    $out = '<h1 class="txp-heading">' . gTxt('tab_forms') . sp . popHelp('forms_overview') . '</h1>' . '<div id="' . $event . '_container" class="txp-container">' . startTable('', '', 'txp-columntable') . tr(tdtl('<div id="tagbuild_links">' . hed(gTxt('tagbuilder'), 2) . $tagbuild_links . '</div>', ' class="column"') . tdtl('<form action="index.php" method="post" id="form_form">' . '<div id="main_content">' . '<div class="edit-title">' . gTxt('you_are_editing_form') . sp . strong($name ? $name : gTxt('untitled')) . '</div>' . '<textarea id="form" class="code" name="Form" cols="' . INPUT_LARGE . '" rows="' . INPUT_REGULAR . '">' . txpspecialchars($Form) . '</textarea>' . $changename . graf(gTxt('form_type') . br . formtypes($type)) . (empty($type) ? graf(gTxt('only_articles_can_be_previewed')) : '') . (empty($type) || $type == 'article' ? fInput('submit', 'form_preview', gTxt('preview')) : '') . graf($inputs) . '</div>' . n . tInput() . n . '</form>', ' class="column"') . tdtl('<div id="content_switcher">' . hed(gTxt('all_forms'), 2) . form_list($name) . '</div>', ' class="column"')) . endTable() . '</div>';
    echo $out;
}
Example #5
0
/**
 * Renders the main Form editor panel.
 *
 * @param string|array $message The activity message
 */
function form_edit($message = '')
{
    global $event, $step, $essential_forms;
    pagetop(gTxt('edit_forms'), $message);
    extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew'))));
    $name = sanitizeForPage(assert_string(gps('name')));
    $type = assert_string(gps('type'));
    $newname = sanitizeForPage(assert_string(gps('newname')));
    if ($step == 'form_delete' || empty($name) && $step != 'form_create' && !$savenew) {
        $name = 'default';
    } elseif ((($copy || $savenew) && $newname || $newname && $newname !== $name) && !$save_error) {
        $name = $newname;
    }
    $Form = gps('Form');
    if (!$save_error) {
        $rs = safe_row('*', 'txp_form', "name='" . doSlash($name) . "'");
        extract($rs);
    }
    if (in_array($name, $essential_forms)) {
        $name_widgets = span(gTxt('form_name'), array('class' => 'txp-label-fixed')) . br . span($name, array('class' => 'txp-value-fixed'));
        $type_widgets = span(gTxt('form_type'), array('class' => 'txp-label-fixed')) . br . span($type, array('class' => 'txp-value-fixed'));
    } else {
        $name_widgets = tag(gTxt('form_name'), 'label', 'for="new_form"') . br . fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_form', false, true);
        $type_widgets = tag(gTxt('form_type'), 'label', 'for="type"') . br . formTypes($type, false);
    }
    $buttons = href(gTxt('duplicate'), '#', array('id' => 'txp_clone', 'class' => 'clone', 'title' => gTxt('form_clone')));
    if (empty($type) || $type == 'article') {
        $buttons .= href(gTxt('preview'), '#', array('id' => 'form_preview', 'class' => 'form-preview'));
    }
    if ($name) {
        $name_widgets .= n . span($buttons, array('class' => 'txp-actions'));
    } else {
        $name_widgets .= hInput('savenew', 'savenew');
    }
    // Generate the tagbuilder links.
    // Format of each entry is popTagLink -> array ( gTxt string, class/ID ).
    $tagbuild_items = array('article' => array('articles', 'article-tags'), 'link' => array('links', 'link-tags'), 'comment' => array('comments', 'comment-tags'), 'comment_details' => array('comment_details', 'comment-detail-tags'), 'comment_form' => array('comment_form', 'comment-form-tags'), 'search_result' => array('search_results_form', 'search-result-tags'), 'file_download' => array('file_download_tags', 'file-tags'), 'category' => array('category_tags', 'category-tags'), 'section' => array('section_tags', 'section-tags'));
    $tagbuild_links = '';
    foreach ($tagbuild_items as $tb => $item) {
        $tagbuild_links .= wrapRegion($item[1] . '_group', popTagLinks($tb), $item[1], $item[0], $item[1]);
    }
    echo hed(gTxt('tab_forms') . popHelp('forms_overview'), 1, array('class' => 'txp-heading'));
    echo n . tag(n . tag(hed(gTxt('tagbuilder'), 2) . $tagbuild_links . n, 'div', array('id' => 'tagbuild_links', 'class' => 'txp-layout-cell txp-layout-1-4')) . n . tag(form(graf($name_widgets) . graf(tag(gTxt('form_code'), 'label', array('for' => 'form')) . br . '<textarea class="code" id="form" name="Form" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($Form) . '</textarea>') . graf($type_widgets) . (empty($type) ? graf(gTxt('only_articles_can_be_previewed')) : '') . graf(fInput('submit', 'save', gTxt('save'), 'publish') . eInput('form') . sInput('form_save') . hInput('name', $name)), '', '', 'post', 'edit-form', '', 'form_form') . n, 'div', array('id' => 'main_content', 'class' => 'txp-layout-cell txp-layout-2-4')) . n . tag(graf(sLink('form', 'form_create', gTxt('create_new_form')), ' class="action-create"') . form_list($name) . n, 'div', array('id' => 'content_switcher', 'class' => 'txp-layout-cell txp-layout-1-4')) . n, 'div', array('id' => $event . '_container', 'class' => 'txp-layout-grid'));
}
Example #6
0
/**
 * Renders the main Form editor panel.
 *
 * @param string|array $message The activity message
 */
function form_edit($message = '')
{
    global $event, $step, $essential_forms;
    pagetop(gTxt('edit_forms'), $message);
    extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew'))));
    $name = sanitizeForPage(assert_string(gps('name')));
    $type = assert_string(gps('type'));
    $newname = sanitizeForPage(assert_string(gps('newname')));
    if ($step == 'form_delete' || empty($name) && $step != 'form_create' && !$savenew) {
        $name = 'default';
    } elseif ((($copy || $savenew) && $newname || $newname && $newname !== $name) && !$save_error) {
        $name = $newname;
    }
    $Form = gps('Form');
    if (!$save_error) {
        $rs = safe_row("*", 'txp_form', "name = '" . doSlash($name) . "'");
        extract($rs);
    }
    if (in_array($name, $essential_forms)) {
        $name_widgets = inputLabel('new_form', fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_form', true), 'form_name', array('', 'instructions_form_name'), array('class' => 'txp-form-field'));
        $type_widgets = inputLabel('type', formTypes($type, false, 'type', true), 'form_type', array('', 'instructions_form_type'), array('class' => 'txp-form-field'));
    } else {
        $name_widgets = inputLabel('new_form', fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_form', false, true), 'form_name', array('', 'instructions_form_name'), array('class' => 'txp-form-field'));
        $type_widgets = inputLabel('type', formTypes($type, false), 'form_type', array('', 'instructions_form_type'), array('class' => 'txp-form-field'));
    }
    if ($name === '') {
        $name_widgets .= hInput('savenew', 'savenew');
    } else {
        $name_widgets .= hInput('name', $name);
    }
    $name_widgets .= eInput('form') . sInput('form_save');
    $buttonExtras = '';
    if ($name) {
        $buttonExtras .= href('<span class="ui-icon ui-icon-copy"></span> ' . gTxt('duplicate'), '#', array('class' => 'txp-clone', 'data-form' => 'form_form'));
    }
    $buttons = graf(tag_void('input', array('class' => 'publish', 'type' => 'submit', 'method' => 'post', 'value' => gTxt('save'), 'form' => 'form_form')), ' class="txp-save"') . graf(sLink('form', 'form_create', '<span class="ui-icon ui-extra-icon-new-document"></span> ' . gTxt('create_new_form'), 'txp-new') . $buttonExtras, array('class' => 'txp-actions'));
    // Generate the tagbuilder links.
    // Format of each entry is popTagLink -> array ( gTxt string, class/ID ).
    $tagbuild_items = array('article' => array('articles', 'article-tags'), 'link' => array('links', 'link-tags'), 'comment' => array('comments', 'comment-tags'), 'comment_details' => array('comment_details', 'comment-detail-tags'), 'comment_form' => array('comment_form', 'comment-form-tags'), 'search_result' => array('search_results_form', 'search-result-tags'), 'file_download' => array('file_download_tags', 'file-tags'), 'category' => array('category_tags', 'category-tags'), 'section' => array('section_tags', 'section-tags'));
    $tagbuild_links = '';
    foreach ($tagbuild_items as $tb => $item) {
        $tagbuild_links .= wrapRegion($item[1] . '_group', popTagLinks($tb), $item[1], $item[0], $item[1]);
    }
    // Forms code columm.
    echo n . tag(hed(gTxt('tab_forms') . popHelp('forms_overview'), 1, array('class' => 'txp-heading')) . form($name_widgets . $type_widgets . inputLabel('form', '<textarea class="code" id="form" name="Form" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($Form) . '</textarea>', 'form_code', array('', 'instructions_form_code'), array('class' => 'txp-form-field')) . (empty($type) ? graf(gTxt('only_articles_can_be_previewed')) : ''), '', '', 'post', '', '', 'form_form'), 'div', array('class' => 'txp-layout-4col-cell-1-2-3', 'id' => 'main_content', 'role' => 'region'));
    // Forms create/switcher column.
    echo n . tag($buttons . form_list($name) . n, 'div', array('class' => 'txp-layout-4col-cell-4alt', 'id' => 'content_switcher', 'role' => 'region'));
    // Forms tag builder column. TODO: make this a modal?
    //    echo n.tag(
    //        hed(gTxt('tagbuilder'), 2).
    //        $tagbuild_links.n
    //    , 'div', array(
    //        'id'    => 'tagbuild_links',
    //        'class' => '',
    //    ));
}