/** * The main Page editor panel. * * @param string|array $message The activity message */ function page_edit($message = '') { global $event, $step; pagetop(gTxt('edit_pages'), $message); extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew')))); $name = sanitizeForPage(assert_string(gps('name'))); $newname = sanitizeForPage(assert_string(gps('newname'))); if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) { $name = safe_field('page', 'txp_section', "name = 'default'"); } elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) { $name = $newname; } $buttons = n . tag(gTxt('page_name'), 'label', array('for' => 'new_page')) . br . fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_page', false, true); if ($name) { $buttons .= span(href(gTxt('duplicate'), '#', array('id' => 'txp_clone', 'class' => 'clone', 'title' => gTxt('page_clone'))), array('class' => 'txp-actions')); } else { $buttons .= hInput('savenew', 'savenew'); } $html = !$save_error ? fetch('user_html', 'txp_page', 'name', $name) : gps('html'); // Format of each entry is popTagLink -> array ( gTxt() string, class/ID). $tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags')); $tagbuild_links = ''; foreach ($tagbuild_items as $tb => $item) { $tagbuild_links .= wrapRegion($item[1] . '_group', taglinks($tb), $item[1], $item[0], 'page_' . $item[1]); } echo hed(gTxt('tab_pages'), 1, array('class' => 'txp-heading')); echo n . tag(n . tag(hed(gTxt('tagbuilder'), 2) . $tagbuild_links, 'div', array('id' => 'tagbuild_links', 'class' => 'txp-layout-cell txp-layout-1-4')) . n . tag(form(graf($buttons) . graf(tag(gTxt('page_code'), 'label', array('for' => 'html')) . br . '<textarea class="code" id="html" name="html" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($html) . '</textarea>') . graf(fInput('submit', '', gTxt('save'), 'publish') . eInput('page') . sInput('page_save') . hInput('name', $name)), '', '', 'post', 'edit-form', '', 'page_form'), 'div', array('id' => 'main_content', 'class' => 'txp-layout-cell txp-layout-2-4')) . n . tag(graf(sLink('page', 'page_new', gTxt('create_new_page')), ' class="action-create"') . page_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')); }
/** * The main Page editor panel. * * @param string|array $message The activity message */ function page_edit($message = '') { global $event, $step; pagetop(gTxt('edit_pages'), $message); extract(array_map('assert_string', gpsa(array('copy', 'save_error', 'savenew')))); $name = sanitizeForPage(assert_string(gps('name'))); $newname = sanitizeForPage(assert_string(gps('newname'))); if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) { $name = safe_field("page", 'txp_section', "name = 'default'"); } elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) { $name = $newname; } $titleblock = inputLabel('new_page', fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_page', false, true), 'page_name', array('', 'instructions_page_name'), array('class' => 'txp-form-field')); if ($name === '') { $titleblock .= hInput('savenew', 'savenew'); } else { $titleblock .= hInput('name', $name); } $titleblock .= eInput('page') . sInput('page_save'); $html = !$save_error ? fetch('user_html', 'txp_page', 'name', $name) : gps('html'); // Format of each entry is popTagLink -> array ( gTxt() string, class/ID). $tagbuild_items = array('page_article' => array('page_article_hed', 'article-tags'), 'page_article_nav' => array('page_article_nav_hed', 'article-nav-tags'), 'page_nav' => array('page_nav_hed', 'nav-tags'), 'page_xml' => array('page_xml_hed', 'xml-tags'), 'page_misc' => array('page_misc_hed', 'misc-tags'), 'page_file' => array('page_file_hed', 'file-tags')); $tagbuild_links = ''; foreach ($tagbuild_items as $tb => $item) { $tagbuild_links .= wrapRegion($item[1] . '_group', taglinks($tb), $item[1], $item[0], 'page_' . $item[1]); } // Pages code columm. echo n . tag(hed(gTxt('tab_pages'), 1, array('class' => 'txp-heading')) . form($titleblock . inputLabel('html', '<textarea class="code" id="html" name="html" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($html) . '</textarea>', 'page_code', array('', 'instructions_page_code'), array('class' => 'txp-form-field')), '', '', 'post', '', '', 'page_form'), 'div', array('class' => 'txp-layout-4col-cell-1-2-3', 'id' => 'main_content', 'role' => 'region')); // Pages create/switcher column. $buttonExtras = ''; if ($name) { $buttonExtras .= href('<span class="ui-icon ui-icon-copy"></span> ' . gTxt('duplicate'), '#', array('class' => 'txp-clone', 'data-form' => 'page_form')); } $buttons = graf(tag_void('input', array('class' => 'publish', 'type' => 'submit', 'method' => 'post', 'value' => gTxt('save'), 'form' => 'page_form')), ' class="txp-save"') . graf(sLink('page', 'page_new', '<span class="ui-icon ui-extra-icon-new-document"></span> ' . gTxt('create_new_page'), 'txp-new') . $buttonExtras, array('class' => 'txp-actions')); echo n . tag($buttons . page_list($name) . n, 'div', array('class' => 'txp-layout-4col-cell-4alt', 'id' => 'content_switcher', 'role' => 'region')); // Pages tag builder column. TODO: make this a modal? // echo n.tag( // hed(gTxt('tagbuilder'), 2). // $tagbuild_links // , 'div', array( // 'class' => '', // 'id' => 'tagbuild_links', // )); }
/** * Renders the list of preferences. * * Plugins may add their own prefs, for example by using plugin lifecycle events or * raising a (pre) callback on event=admin / step=prefs_list so they are installed * or updated when accessing the Preferences panel. Access to the prefs can be * controlled by using add_privs() on 'prefs.your-prefs-event-name'. * * @param string $message The feedback / error string to display */ function prefs_list($message = '') { global $prefs, $txp_user; extract($prefs); pagetop(gTxt('tab_preferences'), $message); $locale = setlocale(LC_ALL, $locale); echo hed(gTxt('tab_preferences'), 1, array('class' => 'txp-heading')); echo n . '<div id="prefs_container" class="txp-container">' . n . '<form method="post" class="prefs-form" action="index.php">' . n . '<div class="txp-layout-textbox">'; // TODO: remove 'custom' when custom fields are refactored. $core_events = array('site', 'admin', 'publish', 'feeds', 'comments', 'custom'); $joined_core = join(',', quote_list($core_events)); $sql = array(); $sql[] = 'prefs_id = 1 and event != "" and type in(' . PREF_CORE . ', ' . PREF_PLUGIN . ')'; $sql[] = "(user_name = '' or (user_name='" . doSlash($txp_user) . "' and name not in(\n select name from " . safe_pfx('txp_prefs') . " where user_name = ''\n )))"; if (!get_pref('use_comments', 1, 1)) { $sql[] = "event != 'comments'"; } $rs = safe_rows_start("*, FIELD(event,{$joined_core}) as sort_value", 'txp_prefs', join(' and ', $sql) . " ORDER BY sort_value = 0, sort_value, event, position"); $last_event = null; $out = array(); if (numRows($rs)) { while ($a = nextRow($rs)) { if (!has_privs('prefs.' . $a['event'])) { continue; } if ($a['event'] !== $last_event) { if ($last_event !== null) { echo wrapRegion('prefs_group_' . $last_event, join(n, $out), 'prefs_' . $last_event, $last_event, 'prefs_' . $last_event); } $last_event = $a['event']; $out = array(); } $label = ''; if (!in_array($a['html'], array('yesnoradio', 'is_dst'))) { $label = $a['name']; } // TODO: remove exception when custom fields move to meta store. $help = ''; if (strpos($a['name'], 'custom_') === false) { $help = $a['name']; } if ($a['html'] == 'text_input') { $size = INPUT_REGULAR; } else { $size = ''; } $out[] = inputLabel($a['name'], pref_func($a['html'], $a['name'], $a['val'], $size), $label, $help, array('id' => 'prefs-' . $a['name'])); } } if ($last_event === null) { echo graf(gTxt('no_preferences')); } else { echo wrapRegion('prefs_group_' . $last_event, join(n, $out), 'prefs_' . $last_event, $last_event, 'prefs_' . $last_event); } echo n . '</div>' . sInput('prefs_save') . eInput('prefs') . hInput('prefs_id', '1') . tInput(); if ($last_event !== null) { echo graf(fInput('submit', 'Submit', gTxt('save'), 'publish')); } echo n . '</form>' . n . '</div>'; }
/** * Renders all custom fields in one partial. * * The rendered widget can be customised via the 'article_ui > custom_fields' * pluggable UI callback event. * * @param array $rs Article data * @return string HTML */ function article_partial_custom_fields($rs) { global $cfs; $cf = ''; foreach ($cfs as $k => $v) { $cf .= article_partial_custom_field($rs, "custom_field_{$k}"); } return wrapRegion('txp-custom-field-group', pluggable_ui('article_ui', 'custom_fields', $cf, $rs), 'txp-custom-field-group-content', 'custom', 'article_custom_field', $cfs ? '' : 'empty'); }
/** * 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')); }
function file_edit($message = '', $id = '') { global $file_base_path, $levels, $file_statuses, $txp_user, $event, $all_file_cats; extract(gpsa(array('name', 'title', 'category', 'permissions', 'description', 'sort', 'dir', 'page', 'crit', 'search_method', 'publish_now'))); if (!$id) { $id = gps('id'); } $id = assert_int($id); $rs = safe_row('*, unix_timestamp(created) as created, unix_timestamp(modified) as modified', 'txp_file', "id = {$id}"); if ($rs) { extract($rs); $filename = sanitizeForFile($filename); if (!has_privs('file.edit') && !($author === $txp_user && has_privs('file.edit.own'))) { require_privs(); } pagetop(gTxt('edit_file'), $message); if ($permissions == '') { $permissions = '-1'; } if (!has_privs('file.publish') && $status >= STATUS_LIVE) { $status = STATUS_PENDING; } $file_exists = file_exists(build_file_path($file_base_path, $filename)); $existing_files = get_filenames(); $replace = $file_exists ? wrapGroup('file_upload_group', file_upload_form('', '', 'file_replace', $id, 'file_replace'), 'replace_file', 'replace-file', 'file_replace') : wrapGroup('file_upload_group', file_upload_form('', '', 'file_replace', $id, 'file_reassign'), 'file_relink', 'upload-file', 'file_reassign'); $condition = span($file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing'), array('class' => $file_exists ? 'success' : 'error')); $downloadlink = $file_exists ? make_download_link($id, txpspecialchars($filename), $filename) : txpspecialchars($filename); $created = graf(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . n . '<label for="publish_now">' . gTxt('set_to_now') . '</label>', ' class="edit-file-publish-now"') . graf(gTxt('or_publish_at') . popHelp('timestamp'), ' class="edit-file-publish-at"') . graf(span(gTxt('date'), array('class' => 'txp-label-fixed')) . br . tsi('year', '%Y', $rs['created'], '', gTxt('yyyy')) . ' / ' . tsi('month', '%m', $rs['created'], '', gTxt('mm')) . ' / ' . tsi('day', '%d', $rs['created'], '', gTxt('dd')), ' class="edit-file-published"') . graf(span(gTxt('time'), array('class' => 'txp-label-fixed')) . br . tsi('hour', '%H', $rs['created'], '', gTxt('hh')) . ' : ' . tsi('minute', '%M', $rs['created'], '', gTxt('mm')) . ' : ' . tsi('second', '%S', $rs['created'], '', gTxt('ss')), ' class="edit-file-created"'); echo n . '<div id="' . $event . '_container" class="txp-container">'; echo n . '<section class="txp-edit">' . hed(gTxt('edit_file'), 2) . inputLabel('condition', $condition) . inputLabel('name', $downloadlink) . inputLabel('download_count', $downloads) . $replace . n . '<div class="file-detail ' . ($file_exists ? '' : 'not-') . 'exists">' . form(($file_exists ? inputLabel('file_status', selectInput('status', $file_statuses, $status, false, '', 'file_status'), 'file_status') . inputLabel('file_title', fInput('text', 'title', $title, '', '', '', INPUT_REGULAR, '', 'file_title'), 'title') . inputLabel('file_category', treeSelectInput('category', $all_file_cats, $category, 'file_category'), 'file_category') . inputLabel('file_description', '<textarea id="file_description" name="description" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '">' . $description . '</textarea>', 'description', '', '', '') . wrapRegion('file_created', $created, '', gTxt('timestamp'), '', 'file-created') . pluggable_ui('file_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('Save'), 'publish')) . hInput('filename', $filename) : (empty($existing_files) ? '' : gTxt('existing_file') . selectInput('filename', $existing_files, '', 1)) . pluggable_ui('file_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('Save'), 'publish')) . hInput('category', $category) . hInput('perms', $permissions == '-1' ? '' : $permissions) . hInput('title', $title) . hInput('description', $description) . hInput('status', $status)) . eInput('file') . sInput('file_save') . hInput('id', $id) . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('crit', $crit) . hInput('search_method', $search_method), '', '', 'post', 'edit-form', '', $file_exists ? 'file_details' : 'assign_file') . n . '</div>' . n . '</section>' . n . '</div>'; } }
/** * Renders expiration date partial. * * The rendered widget can be customised via the 'article_ui > expires' * pluggable UI callback event. * * @param array $rs Article data * @return string HTML */ function article_partial_expires($rs) { extract($rs); $out = wrapRegion('write-expires', graf(span(gTxt('date'), array('class' => 'txp-label-fixed')) . br . tsi('exp_year', '%Y', $sExpires) . ' / ' . tsi('exp_month', '%m', $sExpires) . ' / ' . tsi('exp_day', '%d', $sExpires), ' class="date expires"') . graf(span(gTxt('time'), array('class' => 'txp-label-fixed')) . br . tsi('exp_hour', '%H', $sExpires) . ' : ' . tsi('exp_minute', '%M', $sExpires) . ' : ' . tsi('exp_second', '%S', $sExpires), ' class="time expires"') . hInput('sExpires', $sExpires), '', gTxt('expires')); return pluggable_ui('article_ui', 'expires', $out, $rs); }
/** * Wraps a region and group structure around content. * * @param string $name HTML id attribute for the group wrapper and ARIA label * @param string $content Content to wrap * @param string $label L10n label name * @param string $class CSS class name to apply to wrapper * @param string $help Help text item * @return string HTML * @see wrapRegion() * @since 4.6.0 */ function wrapGroup($id, $content, $label, $class = '', $help = '') { return wrapRegion($id, $content, '', $label, '', $class, 'region', $help); }
/** * 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' => '', // )); }