function switch_tool() { global $vars, $event, $step, $tools; extract(gpsa($vars)); pagetop(gTxt('txp_import'), ''); echo '<h1 class="txp-heading">' . gTxt('tab_import') . '</h1>'; ?> <script type="text/javascript"> <!--// function showHideFields($sel) { if(document.getElementById){ document.getElementById('mtblogid').style.display = ($sel=='mtdb') ? 'block': 'none'; document.getElementById('wponly').style.display = ($sel=='wp') ? 'block': 'none'; document.getElementById('databased').style.display = ($sel=='wp' || $sel=='mtdb' || $sel=='b2')? 'block':'none'; } } //--> </script> <?php $content = '<div class="txp-edit">'; $content .= hed(gTxt('txp_import'), 2); //Select tool $content .= inputLabel('import_from', tag(type_options($tools), 'select', ' id="import_from" name="import_tool" onchange="showHideFields(this.value);"'), 'select_tool', 'import'); //Some data we collect $content .= inputLabel('import_section', import_section_popup(''), 'import_section', 'import_section'); $status_options = array(STATUS_LIVE => gTxt('live'), STATUS_DRAFT => gTxt('draft'), STATUS_HIDDEN => gTxt('hidden'), STATUS_PENDING => gTxt('pending')); $content .= inputLabel('import_status', tag(type_options($status_options), 'select', ' id="import_status"'), 'import_status', 'import_status'); $content .= inputLabel('import_comment', fInput('text', 'import_comments_invite', gTxt('comments'), '', '', '', INPUT_REGULAR, '', 'import_comment'), 'import_invite', 'import_invite'); //DataBase imports only $databased = hed(gTxt('database_stuff'), 2) . inputLabel('import_database', fInput('text', 'importdb', '', '', '', '', INPUT_REGULAR, '', 'import_database'), 'import_database', 'import_database') . inputLabel('import_login', fInput('text', 'importdblogin', '', '', '', '', INPUT_REGULAR, '', 'import_login'), 'import_login', 'import_login') . inputLabel('import_password', fInput('text', 'importdbpass', '', '', '', '', INPUT_REGULAR, '', 'import_password'), 'import_password', 'import_password') . inputLabel('import_host', fInput('text', 'importdbhost', '', '', '', '', INPUT_REGULAR, '', 'import_host'), 'import_host', 'import_host'); $content .= tag($databased, 'div', ' id="databased" style="display: none;"'); //MT-DB Specific $mtblogid = inputLabel('import_blogid', fInput('text', 'import_blog_id', '', '', '', '', INPUT_REGULAR, '', 'import_blogid'), 'import_blogid', 'import_blogid'); $content .= tag($mtblogid, 'div', ' id="mtblogid" style="display: none;"'); //WordPress specific option $wponly = inputLabel('import_wpprefix', fInput('text', 'wpdbprefix', 'wp_', '', '', '', INPUT_REGULAR, '', 'import_wpprefix'), 'import_wpprefix', 'import_wpprefix') . inputLabel('import_wpdbcharset', selectInput('wpdbcharset', array('utf8' => gTxt('utf8'), 'latin1' => gTxt('latin1')), 'utf8', '', '', 'import_wpdbcharset'), 'import_wpdbcharset', 'import_wpdbcharset'); $content .= tag($wponly, 'div', ' id="wponly" style="display: none;"'); $content .= graf(fInput('submit', 'choose', gTxt('continue'), 'publish')); $content .= sInput('start_import') . eInput('import'); $content .= '</div>'; echo '<div id="' . $event . '_container" class="txp-container">' . form($content, '', '', 'post', '', '', 'import') . '</div>'; }
/** * 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 an upload form. * * The rendered form can be customised via the '{$event}_ui > upload_form' * pluggable UI callback event. * * @param string $label File name label. May be empty * @param string $pophelp Help item * @param string $step Step * @param string $event Event * @param string $id File id * @param int $max_file_size Maximum allowed file size * @param string $label_id HTML id attribute for the filename input element * @param string $class HTML class attribute for the form element * @param string|array $wraptag_val Tag to wrap the value / label in, or empty to omit * @return string HTML */ function upload_form($label, $pophelp = '', $step, $event, $id = '', $max_file_size = 1000000, $label_id = '', $class = '', $wraptag_val = array('div', 'div')) { extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if (is_array($search_method)) { $search_method = join(',', $search_method); } if (!$label_id) { $label_id = $event . '-upload'; } if ($wraptag_val) { $wraptag_class = 'txp-form-field file-uploader'; } else { $wraptag_class = 'inline-file-uploader'; } $argv = func_get_args(); return pluggable_ui($event . '_ui', 'upload_form', n . tag((!empty($max_file_size) ? hInput('MAX_FILE_SIZE', $max_file_size) : '') . eInput($event) . sInput($step) . hInput('id', $id) . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit) . inputLabel($label_id, fInput('file', 'thefile', '', '', '', '', '', '', $label_id) . fInput('submit', '', gTxt('upload')), $label, array($pophelp, 'instructions_' . $pophelp), $wraptag_class, $wraptag_val) . tInput() . n, 'form', array('class' => 'upload-form' . $class, 'method' => 'post', 'enctype' => 'multipart/form-data', 'action' => 'index.php')), $argv); }
/** * User editor panel. * * Accessing requires 'admin.edit' privileges. */ function author_edit() { global $step, $txp_user; require_privs('admin.edit'); pagetop(gTxt('tab_site_admin'), ''); $vars = array('user_id', 'name', 'RealName', 'email', 'privs'); $rs = array(); $out = array(); extract(gpsa($vars)); $is_edit = $user_id && $step == 'author_edit'; if ($is_edit) { $user_id = assert_int($user_id); $rs = safe_row('*', 'txp_users', "user_id = {$user_id}"); extract($rs); } if ($is_edit) { $out[] = hed(gTxt('edit_author'), 2); } else { $out[] = hed(gTxt('add_new_author'), 2); } if ($is_edit) { $out[] = inputLabel('login_name', strong(txpspecialchars($name))); } else { $out[] = inputLabel('login_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), 'login_name', 'add_new_author'); } $out[] = inputLabel('real_name', fInput('text', 'RealName', $RealName, '', '', '', INPUT_REGULAR, '', 'real_name'), 'real_name') . inputLabel('login_email', fInput('email', 'email', $email, '', '', '', INPUT_REGULAR, '', 'login_email'), 'email'); if ($txp_user != $name) { $out[] = inputLabel('privileges', privs($privs), 'privileges', 'about_privileges'); } else { $out[] = inputLabel('privileges', strong(get_priv_level($privs))) . hInput('privs', $privs); } $out[] = pluggable_ui('author_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('admin'); if ($user_id) { $out[] = hInput('user_id', $user_id) . hInput('name', $name) . sInput('author_save'); } else { $out[] = sInput('author_save_new'); } echo form(n . tag(join('', $out) . n, 'section', array('class' => 'txp-edit')), '', '', 'post', 'edit-form', '', 'user_edit'); }
function link_edit($message = '') { global $vars, $event, $step, $txp_user; pagetop(gTxt('tab_link'), $message); echo '<div id="' . $event . '_container" class="txp-container">'; extract(array_map('assert_string', gpsa($vars))); $is_edit = $id && $step == 'link_edit'; $rs = array(); if ($is_edit) { $id = assert_int($id); $rs = safe_row('*', 'txp_link', "id = {$id}"); if ($rs) { extract($rs); if (!has_privs('link.edit') && !($author == $txp_user && has_privs('link.edit.own'))) { link_list(gTxt('restricted_area')); return; } } } if (has_privs('link.edit') || has_privs('link.edit.own')) { $caption = gTxt($is_edit ? 'edit_link' : 'add_new_link'); echo form('<div class="txp-edit">' . n . hed($caption, 2) . n . inputLabel('linkname', fInput('text', 'linkname', $linkname, '', '', '', INPUT_REGULAR, '', 'linkname'), 'title') . n . inputLabel('linksort', fInput('text', 'linksort', $linksort, '', '', '', INPUT_REGULAR, '', 'linksort'), 'sort_value', 'link_sort') . n . inputLabel('url', fInput('text', 'url', $url, '', '', '', INPUT_REGULAR, '', 'url'), 'url', 'link_url', 'edit-link-url') . n . inputLabel('link_category', linkcategory_popup($category) . ' [' . eLink('category', 'list', '', '', gTxt('edit')) . ']', 'link_category', 'link_category') . n . inputLabel('link_description', '<textarea id="link_description" name="description" cols="' . INPUT_LARGE . '" rows="' . INPUT_SMALL . '">' . txpspecialchars($description) . '</textarea>', 'description', 'link_description', '', '') . n . pluggable_ui('link_ui', 'extend_detail_form', '', $rs) . n . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('link') . sInput('link_save') . hInput('id', $id) . hInput('search_method', gps('search_method')) . hInput('crit', gps('crit')) . '</div>', '', '', 'post', 'edit-form', '', 'link_details'); } echo '</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 = inputLabel('exp_year', tsi('exp_year', '%Y', $sExpires, '', 'exp_year') . ' <span role="separator">/</span> ' . tsi('exp_month', '%m', $sExpires, '', 'exp_month') . ' <span role="separator">/</span> ' . tsi('exp_day', '%d', $sExpires, '', 'exp_day'), 'expire_date', array('expires', 'instructions_expire_date'), array('class' => 'txp-form-field date expires')) . inputLabel('exp_hour', tsi('exp_hour', '%H', $sExpires, '', 'exp_hour') . ' <span role="separator">:</span> ' . tsi('exp_minute', '%M', $sExpires, '', 'exp_minute') . ' <span role="separator">:</span> ' . tsi('exp_second', '%S', $sExpires, '', 'exp_second'), 'expire_time', array('', 'instructions_expire_time'), array('class' => 'txp-form-field time expires')) . hInput('sExpires', $sExpires); return pluggable_ui('article_ui', 'expires', $out, $rs); }
/** * The editor for sections. */ function section_edit() { global $event, $step, $all_pages, $all_styles; require_privs('section.edit'); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method', 'name'))); $is_edit = $name && $step == 'section_edit'; $caption = gTxt('create_section'); $is_default_section = false; if ($is_edit) { $rs = safe_row('*', 'txp_section', "name = '" . doSlash($name) . "'"); if ($name == 'default') { $caption = gTxt('edit_default_section'); $is_default_section = true; } else { $caption = gTxt('edit_section'); } } else { // Pulls defaults for the new section from the 'default'. $rs = safe_row('*', 'txp_section', "name = 'default'"); if ($rs) { $rs['name'] = $rs['title'] = ''; } } if (!$rs) { sec_section_list(array(gTxt('unknown_section'), E_ERROR)); return; } extract($rs, EXTR_PREFIX_ALL, 'sec'); pagetop(gTxt('tab_sections')); $out = array(); $out[] = n . tag_start('section', array('class' => 'txp-edit')) . hed($caption, 2); if ($is_default_section) { $out[] = hInput('name', 'default'); } else { $out[] = inputLabel('section_name', fInput('text', 'name', $sec_name, '', '', '', INPUT_REGULAR, '', 'section_name'), 'section_name') . inputLabel('section_title', fInput('text', 'title', $sec_title, '', '', '', INPUT_REGULAR, '', 'section_title'), 'section_longtitle'); } $out[] = inputLabel('section_description', text_area('description', 0, 0, $sec_description, 'section_description', TEXTAREA_HEIGHT_SMALL, INPUT_LARGE), 'section_description'); $out[] = inputLabel('section_page', selectInput('section_page', $all_pages, $sec_page, '', '', 'section_page'), 'uses_page', 'section_uses_page') . inputLabel('section_css', selectInput('css', $all_styles, $sec_css, '', '', 'section_css'), 'uses_style', 'section_uses_css'); if (!$is_default_section) { $out[] = inputLabel('on_front_page', yesnoradio('on_frontpage', $sec_on_frontpage, '', $sec_name), '', 'section_on_frontpage') . inputLabel('syndicate', yesnoradio('in_rss', $sec_in_rss, '', $sec_name), '', 'section_syndicate') . inputLabel('include_in_search', yesnoradio('searchable', $sec_searchable, '', $sec_name), '', 'section_searchable'); } $out[] = pluggable_ui('section_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('section') . sInput('section_save') . hInput('old_name', $sec_name) . hInput('search_method', $search_method) . hInput('crit', $crit) . hInput('page', $page) . hInput('sort', $sort) . hInput('dir', $dir) . n . tag_end('section'); echo n . tag_start('div', array('id' => $event . '_container', 'class' => 'txp-container')) . form(join('', $out), '', '', 'post', 'edit-form', '', 'section_details') . n . tag_end('div'); }
/** * Renders and outputs a login form. * * This function outputs a full HTML document, * including <head> and footer. * * @param string|array $message The activity message */ function doLoginForm($message) { global $textarray_script, $event, $step; include txpath . '/lib/txplib_head.php'; $event = 'login'; $stay = cs('txp_login') && !gps('logout') ? 1 : 0; $reset = gps('reset'); $confirm = gps('confirm'); $activate = gps('activate'); if (gps('logout')) { $step = 'logout'; } elseif ($reset) { $step = 'reset'; } elseif ($activate) { $step = 'activate'; } elseif ($confirm) { $step = 'confirm'; } $name = join(',', array_slice(explode(',', cs('txp_login')), 0, -1)); $out = array(); if ($reset) { $pageTitle = gTxt('password_reset'); $out[] = hed(gTxt('password_reset'), 1, array('id' => 'txp-login-heading')) . inputLabel('login_name', fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), 'name', '', array('class' => 'txp-form-field login-name')) . graf(fInput('submit', '', gTxt('password_reset_button'), 'publish')) . graf(href(gTxt('back_to_login'), 'index.php'), array('class' => 'login-return')) . hInput('p_reset', 1); } elseif ($confirm || $activate) { $pageTitle = $confirm ? gTxt('change_password') : gTxt('set_password'); $label = $confirm ? 'change_password' : 'set_password'; $class = $confirm ? 'change-password' : 'set-password'; $out[] = hed($pageTitle, 1, array('id' => 'txp-' . $class . '-heading')) . inputLabel($label, fInput('password', 'p_password', '', 'txp-maskable txp-strength-hint', '', '', INPUT_REGULAR, '', $label, false, true) . n . tag(null, 'div', array('class' => 'strength-meter')) . n . tag(checkbox('unmask', 1, false, 0, 'show_password') . n . tag(gTxt('show_password'), 'label', array('for' => 'show_password')), 'div', array('class' => 'show-password')), 'new_password', '', array('class' => 'txp-form-field ' . $class)) . graf(fInput('submit', '', gTxt('password_confirm_button'), 'publish')) . graf(href(gTxt('back_to_login'), 'index.php'), array('class' => 'login-return')) . hInput('hash', gps('confirm') . gps('activate')) . hInput($confirm ? 'p_alter' : 'p_set', 1); } else { $pageTitle = gTxt('login'); $out[] = hed(gTxt('login_to_textpattern'), 1, array('id' => 'txp-login-heading')) . inputLabel('login_name', fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), 'name', '', array('class' => 'txp-form-field login-name')) . inputLabel('login_password', fInput('password', 'p_password', '', '', '', '', INPUT_REGULAR, '', 'login_password'), 'password', '', array('class' => 'txp-form-field login-password')) . graf(checkbox('stay', 1, $stay, '', 'login_stay') . n . tag(gTxt('stay_logged_in'), 'label', array('for' => 'login_stay')) . popHelp('remember_login'), array('class' => 'login-stay')) . graf(fInput('submit', '', gTxt('log_in_button'), 'publish')) . graf(href(gTxt('password_forgotten'), '?reset=1'), array('class' => 'login-forgot')); if (gps('event')) { $out[] = eInput(gps('event')); } } pagetop($pageTitle, $message); gTxtScript(array('password_strength_0', 'password_strength_1', 'password_strength_2', 'password_strength_3', 'password_strength_4')); echo form(join('', $out), '', '', 'post', 'txp-login', '', 'login_form') . script_js('vendors/dropbox/zxcvbn/zxcvbn.js', TEXTPATTERN_SCRIPT_URL) . script_js('textpattern.textarray = ' . json_encode($textarray_script)) . n . '</main><!-- /txp-body -->' . n . '</body>' . n . '</html>'; exit(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' => '', // )); }
/** * Renders and outputs the image editor panel. * * @param string|array $message The activity message * @param int $id The image ID */ function image_edit($message = '', $id = '') { global $prefs, $file_max_upload_size, $txp_user, $event, $all_image_cats; if (!$id) { $id = gps('id'); } $id = assert_int($id); $rs = safe_row("*, UNIX_TIMESTAMP(date) AS uDate", 'txp_image', "id = {$id}"); if ($rs) { extract($rs); if (!has_privs('image.edit') && !($author === $txp_user && has_privs('image.edit.own'))) { image_list(gTxt('restricted_area')); return; } pagetop(gTxt('edit_image'), $message); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if ($ext != '.swf') { $aspect = $h == $w ? ' square' : ($h > $w ? ' portrait' : ' landscape'); $img_info = $id . $ext . ' (' . $w . ' × ' . $h . ')'; $img = '<div class="fullsize-image"><img class="content-image" src="' . imagesrcurl($id, $ext) . "?{$uDate}" . '" alt="' . $img_info . '" title="' . $img_info . '" /></div>'; } else { $img = $aspect = ''; } if ($thumbnail and $ext != '.swf') { $thumb_info = $id . 't' . $ext . ' (' . $thumb_w . ' × ' . $thumb_h . ')'; $thumb = '<img class="content-image" src="' . imagesrcurl($id, $ext, true) . "?{$uDate}" . '" alt="' . $thumb_info . '" title="' . $thumb_info . '" />'; } else { $thumb = ''; if ($thumb_w == 0) { $thumb_w = get_pref('thumb_w', 0); } if ($thumb_h == 0) { $thumb_h = get_pref('thumb_h', 0); } } $imageBlock = array(); $thumbBlock = array(); $imageBlock[] = pluggable_ui('image_ui', 'fullsize_image', $img, $rs); $imageBlock[] = pluggable_ui('image_ui', 'image_edit', upload_form('replace_image', 'replace_image_form', 'image_replace', 'image', $id, $file_max_upload_size, 'image-upload', ' image-replace'), $rs); $thumbBlock[] = hed(gTxt('create_thumbnail') . popHelp('create_thumbnail'), 3); $thumbBlock[] = check_gd($ext) ? pluggable_ui('image_ui', 'thumbnail_create', form(graf(n . '<label for="width">' . gTxt('thumb_width') . '</label>' . fInput('text', 'width', @$thumb_w, 'input-xsmall', '', '', INPUT_XSMALL, '', 'width') . n . '<label for="height">' . gTxt('thumb_height') . '</label>' . fInput('text', 'height', @$thumb_h, 'input-xsmall', '', '', INPUT_XSMALL, '', 'height') . n . '<label for="crop">' . gTxt('keep_square_pixels') . '</label>' . checkbox('crop', 1, @$prefs['thumb_crop'], '', 'crop') . fInput('submit', '', gTxt('create')), ' class="edit-alter-thumbnail"') . hInput('id', $id) . eInput('image') . sInput('thumbnail_create') . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit), '', '', 'post', '', '', 'thumbnail_alter_form'), $rs) : ''; $thumbBlock[] = pluggable_ui('image_ui', 'thumbnail_image', '<div class="thumbnail-image">' . ($thumbnail ? $thumb . n . dLink('image', 'thumbnail_delete', 'id', $id, '', '', '', '', array($page, $sort, $dir, $crit, $search_method)) : '') . '</div>', $rs); $thumbBlock[] = pluggable_ui('image_ui', 'thumbnail_edit', upload_form('upload_thumbnail', 'upload_thumbnail', 'thumbnail_insert', 'image', $id, $file_max_upload_size, 'thumbnail-upload', ' thumbnail-upload'), $rs); echo n . tag(hed(gTxt('edit_image'), 1, array('class' => 'txp-heading')) . n . implode(n, $imageBlock) . '<hr />' . tag(implode(n, $thumbBlock), 'section', array('class' => 'thumbnail-alter')), 'div', array('class' => 'txp-layout-4col-cell-1-2-3')) . '<div class="txp-layout-4col-cell-4alt">', form(graf(fInput('submit', '', gTxt('save'), 'publish'), array('class' => 'txp-save')) . wrapGroup('image-details', inputLabel('image_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'image_name'), 'image_name', '', array('class' => 'txp-form-field edit-image-name')) . inputLabel('image_category', event_category_popup('image', $category, 'image_category') . n . eLink('category', 'list', '', '', gTxt('edit'), '', '', '', 'txp-option-link'), 'image_category', '', array('class' => 'txp-form-field edit-image-category')) . inputLabel('image_alt_text', fInput('text', 'alt', $alt, '', '', '', INPUT_REGULAR, '', 'image_alt_text'), 'alt_text', '', array('class' => 'txp-form-field edit-image-alt-text')) . inputLabel('image_caption', '<textarea id="image_caption" name="caption" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '">' . $caption . '</textarea>', 'caption', '', array('class' => 'txp-form-field txp-form-field-textarea edit-image-caption')) . pluggable_ui('image_ui', 'extend_detail_form', '', $rs) . hInput('id', $id) . eInput('image') . sInput('image_save') . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit), 'image_details'), '', '', 'post', '', '', 'image_details_form'), '</div>'; } }
/** * Renders and outputs a category editor. * * @param string $evname Type of category */ function cat_event_category_edit($evname) { $id = assert_int(gps('id')); $parent = doSlash(gps('parent')); $row = safe_row('*', 'txp_category', "id={$id}"); if ($row) { pagetop(gTxt('edit_category')); extract($row); list($parent_widget, $has_parent) = cat_parent_pop($parent, $evname, $id); $out = n . '<section class="txp-edit">' . hed(gTxt('edit_category'), 2) . inputLabel('category_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'category_name'), $evname . '_category_name') . ($has_parent ? inputLabel('category_parent', $parent_widget, 'parent') : inputLabel('category_parent', $parent_widget)) . inputLabel('category_title', fInput('text', 'title', $title, '', '', '', INPUT_REGULAR, '', 'category_title'), $evname . '_category_title') . inputLabel('category_description', text_area('description', 0, 0, $description, 'category_description', TEXTAREA_HEIGHT_SMALL, INPUT_LARGE), $evname . '_category_description') . pluggable_ui('category_ui', 'extend_detail_form', '', $row) . hInput('id', $id) . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('category') . sInput('cat_' . $evname . '_save') . hInput('old_name', $name) . n . '</section>'; echo n . '<div id="category_container" class="txp-container">' . form($out, '', '', 'post', 'edit-form') . n . '</div>'; } else { cat_category_list(array(gTxt('category_not_found'), E_ERROR)); } }
function cat_event_category_edit($evname) { $id = assert_int(gps('id')); $parent = doSlash(gps('parent')); $row = safe_row('*', 'txp_category', "id={$id}"); if ($row) { pagetop(gTxt('edit_category')); extract($row); list($parent_widget, $has_parent) = cat_parent_pop($parent, $evname, $id); $out = '<div class="txp-edit">' . n . hed(gTxt('edit_category'), 2) . n . inputLabel('category_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'category_name'), $evname . '_category_name') . n . ($has_parent ? inputLabel('category_parent', $parent_widget, 'parent') : graf('<span class="edit-label">' . gTxt('parent') . '</span><span class="edit-value">' . $parent_widget . '</span>')) . n . inputLabel('category_title', fInput('text', 'title', $title, '', '', '', INPUT_REGULAR, '', 'category_title'), $evname . '_category_title') . n . pluggable_ui('category_ui', 'extend_detail_form', '', $row) . n . hInput('id', $id) . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('category') . sInput('cat_' . $evname . '_save') . hInput('old_name', $name) . '</div>'; echo '<div id="category_container" class="txp-container">' . form($out, '', '', 'post', 'edit-form') . '</div>'; } else { cat_category_list(array(gTxt('category_not_found'), E_ERROR)); } }
function discuss_edit() { global $event; pagetop(gTxt('edit_comment')); extract(gpsa(array('discussid', 'sort', 'dir', 'page', 'crit', 'search_method'))); $discussid = assert_int($discussid); $rs = safe_row('*, unix_timestamp(posted) as uPosted', 'txp_discuss', "discussid = {$discussid}"); if ($rs) { extract($rs); $message = txpspecialchars($message); if (fetch('ip', 'txp_discuss_ipban', 'ip', $ip)) { $ban_step = 'ipban_unban'; $ban_text = gTxt('unban'); } else { $ban_step = 'ipban_add'; $ban_text = gTxt('ban'); } $ban_link = sp . span('[', array('aria-hidden' => 'true')) . href($ban_text, array('event' => 'discuss', 'step' => $ban_step, 'ip' => $ip, 'name' => $name, 'discussid' => $discussid, '_txp_token' => form_token()), array('class' => 'action-ban')) . span(']', array('aria-hidden' => 'true')); $status_list = selectInput('visible', array(VISIBLE => gTxt('visible'), SPAM => gTxt('spam'), MODERATE => gTxt('unmoderated')), $visible, false, '', 'status'); echo '<div id="' . $event . '_container" class="txp-container">' . form(n . '<section class="txp-edit">' . hed(gTxt('edit_comment'), 2) . inputLabel('status', $status_list, 'status') . inputLabel('name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'name'), 'name') . inputLabel('IP', href(txpspecialchars($ip), 'https://whois.domaintools.com/' . rawurlencode($ip), array('rel' => 'external', 'target' => '_blank')) . $ban_link, '') . inputLabel('email', fInput('email', 'email', $email, '', '', '', INPUT_REGULAR, '', 'email'), 'email') . inputLabel('website', fInput('text', 'web', $web, '', '', '', INPUT_REGULAR, '', 'website'), 'website') . inputLabel('date', safe_strftime('%d %b %Y %X', $uPosted), '') . inputLabel('commentmessage', '<textarea id="commentmessage" name="message" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_REGULAR . '">' . $message . '</textarea>', 'message', '', '', '') . graf(fInput('submit', 'step', gTxt('save'), 'publish')) . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('crit', $crit) . hInput('search_method', $search_method) . hInput('discussid', $discussid) . hInput('parentid', $parentid) . hInput('ip', $ip) . eInput('discuss') . sInput('discuss_save') . n . '</section>', '', '', 'post', 'edit-form', '', 'discuss_edit_form'), '</div>'; } else { echo graf(gTxt('comment_not_found'), ' class="indicator"'); } }
/** * Outputs a diagnostics report. * * This is the main panel. */ function doDiagnostics() { global $prefs, $files, $txpcfg, $event, $step, $theme, $DB, $txp_using_svn; extract(get_prefs()); $urlparts = parse_url(hu); $mydomain = $urlparts['host']; $is_apache = stristr(serverSet('SERVER_SOFTWARE'), 'Apache') || is_callable('apache_get_version'); $real_doc_root = isset($_SERVER['DOCUMENT_ROOT']) ? realpath($_SERVER['DOCUMENT_ROOT']) : ''; // ini_get() returns string values passed via php_value as a string, // not boolean. $is_register_globals = (strcasecmp(ini_get('register_globals'), 'on') === 0 or ini_get('register_globals') === '1'); $fail = array(); $now = time(); if (!$txp_using_svn) { // Check for Textpattern updates, at most once every 24 hours. $updateInfo = unserialize(get_pref('last_update_check', '')); if (!$updateInfo || $now > $updateInfo['when'] + 60 * 60 * 24) { $updates = checkUpdates(); $updateInfo['msg'] = $updates ? gTxt($updates['msg'], array('{version}' => $updates['version'])) : ''; $updateInfo['when'] = $now; set_pref('last_update_check', serialize($updateInfo), 'publish', PREF_HIDDEN, 'text_input'); } if (!empty($updateInfo['msg'])) { $fail['textpattern_version_update'] = diag_msg_wrap($updateInfo['msg'], 'information'); } } if (!is_callable('version_compare') || version_compare(PHP_VERSION, REQUIRED_PHP_VERSION, '<')) { $fail['php_version_required'] = diag_msg_wrap(gTxt('php_version_required', array('{version}' => REQUIRED_PHP_VERSION))); } if (@gethostbyname($mydomain) === $mydomain) { $fail['dns_lookup_fails'] = diag_msg_wrap(gTxt('dns_lookup_fails') . cs . $mydomain, 'warning'); } if (!@is_dir($path_to_site)) { $fail['path_to_site_inacc'] = diag_msg_wrap(gTxt('path_to_site_inacc') . cs . $path_to_site); } if (rtrim($siteurl, '/') != $siteurl) { $fail['site_trailing_slash'] = diag_msg_wrap(gTxt('site_trailing_slash') . cs . $path_to_site, 'warning'); } if (!@is_file($path_to_site . "/index.php") || !@is_readable($path_to_site . "/index.php")) { $fail['index_inaccessible'] = diag_msg_wrap("{$path_to_site}/index.php " . gTxt('is_inaccessible')); } $not_readable = array(); if (!@is_writable($path_to_site . '/' . $img_dir)) { $not_readable[] = diag_msg_wrap(str_replace('{dirtype}', gTxt('img_dir'), gTxt('dir_not_writable')) . ": {$path_to_site}/{$img_dir}", 'warning'); } if (!@is_writable($file_base_path)) { $not_readable[] = diag_msg_wrap(str_replace('{dirtype}', gTxt('file_base_path'), gTxt('dir_not_writable')) . ": {$file_base_path}", 'warning'); } if (!@is_writable($tempdir)) { $not_readable[] = diag_msg_wrap(str_replace('{dirtype}', gTxt('tempdir'), gTxt('dir_not_writable')) . ": {$tempdir}", 'warning'); } if ($not_readable) { $fail['dir_not_writable'] = join(n, $not_readable); } if ($permlink_mode != 'messy' && !$is_apache) { $fail['cleanurl_only_apache'] = diag_msg_wrap(gTxt('cleanurl_only_apache'), 'information'); } if ($permlink_mode != 'messy' and !@is_readable($path_to_site . '/.htaccess')) { $fail['htaccess_missing'] = diag_msg_wrap(gTxt('htaccess_missing')); } if ($permlink_mode != 'messy' and is_callable('apache_get_modules') and !apache_module('mod_rewrite')) { $fail['mod_rewrite_missing'] = diag_msg_wrap(gTxt('mod_rewrite_missing')); } if (!ini_get('file_uploads')) { $fail['file_uploads_disabled'] = diag_msg_wrap(gTxt('file_uploads_disabled'), 'information'); } if (@is_dir(txpath . DS . 'setup')) { $fail['setup_still_exists'] = diag_msg_wrap(txpath . DS . "setup" . DS . ' ' . gTxt('still_exists'), 'warning'); } if (empty($tempdir)) { $fail['no_temp_dir'] = diag_msg_wrap(gTxt('no_temp_dir'), 'warning'); } if (is_disabled('mail')) { $fail['warn_mail_unavailable'] = diag_msg_wrap(gTxt('warn_mail_unavailable'), 'warning'); } if ($is_register_globals) { $fail['warn_register_globals_or_update'] = diag_msg_wrap(gTxt('warn_register_globals_or_update'), 'warning'); } if ($permlink_mode != 'messy') { $rs = safe_column("name", 'txp_section', "1 = 1"); foreach ($rs as $name) { if ($name and @file_exists($path_to_site . '/' . $name)) { $fail['old_placeholder_exists'] = diag_msg_wrap(gTxt('old_placeholder') . ": {$path_to_site}/{$name}"); } } } $cs = check_file_integrity(INTEGRITY_REALPATH); if (!$cs) { $cs = array(); } // Files that don't match their checksums. if (!$txp_using_svn and $modified_files = array_keys($cs, INTEGRITY_MODIFIED)) { $fail['modified_files'] = diag_msg_wrap(gTxt('modified_files') . cs . n . t . join(', ' . n . t, $modified_files), 'warning'); } // Running development code in live mode is not recommended. if (preg_match('/-dev$/', txp_version) and $production_status == 'live') { $fail['dev_version_live'] = diag_msg_wrap(gTxt('dev_version_live'), 'warning'); } // Missing files. if ($missing = array_merge(array_keys($cs, INTEGRITY_MISSING), array_keys($cs, INTEGRITY_NOT_FILE), array_keys($cs, INTEGRITY_NOT_READABLE))) { $fail['missing_files'] = diag_msg_wrap(gTxt('missing_files') . cs . n . t . join(', ' . n . t, $missing)); } // Anything might break if arbitrary functions are disabled. if (ini_get('disable_functions')) { $disabled_funcs = array_map('trim', explode(',', ini_get('disable_functions'))); // Commonly disabled functions that we don't need. $disabled_funcs = array_diff($disabled_funcs, array('imagefilltoborder', 'escapeshellarg', 'escapeshellcmd', 'exec', 'passthru', 'proc_close', 'proc_get_status', 'proc_nice', 'proc_open', 'proc_terminate', 'shell_exec', 'system', 'popen', 'dl', 'chown')); if ($disabled_funcs) { $fail['some_php_functions_disabled'] = diag_msg_wrap(gTxt('some_php_functions_disabled') . cs . join(', ', $disabled_funcs), 'warning'); } } // Not sure about this one. // if (strncmp(php_sapi_name(), 'cgi', 3) == 0 and ini_get('cgi.rfc2616_headers')) // $fail['cgi_header_config'] = gTxt('cgi_header_config'); $guess_site_url = $_SERVER['HTTP_HOST'] . preg_replace('#[/\\\\]$#', '', dirname(dirname($_SERVER['SCRIPT_NAME']))); if ($siteurl and strip_prefix($siteurl, 'www.') != strip_prefix($guess_site_url, 'www.')) { $fail['site_url_mismatch'] = diag_msg_wrap(gTxt('site_url_mismatch') . cs . $guess_site_url, 'warning'); } // Test clean URL server vars. if (hu) { if (ini_get('allow_url_fopen') and $permlink_mode != 'messy') { $s = md5(uniqid(rand(), true)); ini_set('default_socket_timeout', 10); $pretext_data = @file(hu . $s . '/?txpcleantest=1'); if ($pretext_data) { $pretext_req = trim(@$pretext_data[0]); if ($pretext_req != md5('/' . $s . '/?txpcleantest=1')) { $fail['clean_url_data_failed'] = diag_msg_wrap(gTxt('clean_url_data_failed') . cs . txpspecialchars($pretext_req), 'warning'); } } else { $fail['clean_url_test_failed'] = diag_msg_wrap(gTxt('clean_url_test_failed'), 'warning'); } } } if ($tables = list_txp_tables()) { $table_errors = check_tables($tables); if ($table_errors) { $fail['mysql_table_errors'] = diag_msg_wrap(gTxt('mysql_table_errors') . cs . n . t . join(', ' . n . t, $table_errors)); } } $active_plugins = array(); if ($rows = safe_rows("name, version, code_md5, MD5(code) AS md5", 'txp_plugin', "status > 0")) { foreach ($rows as $row) { $n = $row['name'] . '-' . $row['version']; if (strtolower($row['md5']) != strtolower($row['code_md5'])) { $n .= 'm'; } $active_plugins[] = $n; } } $theme_manifest = $theme->manifest(); // Check GD info. if (function_exists('gd_info')) { $gd_info = gd_info(); $gd_support = array(); if ($gd_info['GIF Create Support']) { $gd_support[] = 'GIF'; } // Aside: In PHP 5.3, they chose to add a previously unemployed capital // "E" to the array key. if (!empty($gd_info['JPEG Support']) || !empty($gd_info['JPG Support'])) { $gd_support[] = 'JPG'; } if ($gd_info['PNG Support']) { $gd_support[] = 'PNG'; } if ($gd_support) { $gd_support = join(', ', $gd_support); } else { $gd_support = gTxt('none'); } $gd = gTxt('gd_info', array('{version}' => $gd_info['GD Version'], '{supported}' => $gd_support)); } else { $gd = gTxt('gd_unavailable'); } if (realpath($prefs['tempdir']) === realpath($prefs['plugin_cache_dir'])) { $fail['tmp_plugin_paths_match'] = diag_msg_wrap(gTxt('tmp_plugin_paths_match')); } // Database server time. extract(doSpecial(getRow("SELECT @@global.time_zone AS db_global_timezone, @@session.time_zone AS db_session_timezone, NOW() AS db_server_time, UNIX_TIMESTAMP(NOW()) AS db_server_timestamp"))); $db_server_timeoffset = $db_server_timestamp - $now; echo pagetop(gTxt('tab_diagnostics'), ''); echo hed(gTxt('tab_diagnostics'), 1, array('class' => 'txp-heading')) . n . tag_start('div', array('class' => 'txp-layout-1col', 'id' => $event . '_container')) . n . tag_start('div', array('id' => 'pre_flight_check')) . hed(gTxt('preflight_check'), 2); if ($fail) { foreach ($fail as $help => $message) { echo graf(nl2br($message) . popHelp($help)); } } else { echo graf(diag_msg_wrap(gTxt('all_checks_passed'), 'success')); } echo n . tag_end('div') . n . tag_start('div', array('id' => 'diagnostics')) . hed(gTxt('diagnostic_info'), 2); $fmt_date = '%Y-%m-%d %H:%M:%S'; $dets = array('low' => gTxt('low'), 'high' => gTxt('high')); $out = array(form(eInput('diag') . inputLabel('diag_detail_level', selectInput('step', $dets, $step, 0, 1, 'diag_detail_level'), 'detail', '', array('class' => 'txp-form-field diagnostic-details-level'), '')), '<textarea class="code" id="diagnostics-detail" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr" readonly>', gTxt('txp_version') . cs . txp_version . ' (' . check_file_integrity(INTEGRITY_DIGEST) . ')' . n, gTxt('last_update') . cs . gmstrftime($fmt_date, $dbupdatetime) . '/' . gmstrftime($fmt_date, @filemtime(txpath . '/update/_update.php')) . n, gTxt('document_root') . cs . @$_SERVER['DOCUMENT_ROOT'] . ($real_doc_root != @$_SERVER['DOCUMENT_ROOT'] ? ' (' . $real_doc_root . ')' : '') . n, '$path_to_site' . cs . $path_to_site . n, gTxt('txp_path') . cs . txpath . n, gTxt('permlink_mode') . cs . $permlink_mode . n, ini_get('open_basedir') ? 'open_basedir: ' . ini_get('open_basedir') . n : '', ini_get('upload_tmp_dir') ? 'upload_tmp_dir: ' . ini_get('upload_tmp_dir') . n : '', gTxt('tempdir') . cs . $tempdir . n, gTxt('web_domain') . cs . $siteurl . n, gTxt('php_version') . cs . phpversion() . n, $is_register_globals ? gTxt('register_globals') . cs . $is_register_globals . n : '', gTxt('gd_library') . cs . $gd . n, gTxt('server') . ' TZ: ' . Txp::get('\\Textpattern\\Date\\Timezone')->getTimeZone() . n, gTxt('server_time') . cs . strftime('%Y-%m-%d %H:%M:%S') . n, strip_tags(gTxt('is_dst')) . cs . $is_dst . n, strip_tags(gTxt('auto_dst')) . cs . $auto_dst . n, strip_tags(gTxt('gmtoffset')) . cs . $timezone_key . sp . "({$gmtoffset})" . n, 'MySQL' . cs . mysqli_get_server_info($DB->link) . n, gTxt('db_server_time') . cs . $db_server_time . n, gTxt('db_server_timeoffset') . cs . $db_server_timeoffset . ' s' . n, gTxt('db_global_timezone') . cs . $db_global_timezone . n, gTxt('db_session_timezone') . cs . $db_session_timezone . n, gTxt('locale') . cs . $locale . n, isset($_SERVER['SERVER_SOFTWARE']) ? gTxt('server') . cs . $_SERVER['SERVER_SOFTWARE'] . n : '', is_callable('apache_get_version') ? gTxt('apache_version') . cs . @apache_get_version() . n : '', gTxt('php_sapi_mode') . cs . PHP_SAPI . n, gTxt('rfc2616_headers') . cs . ini_get('cgi.rfc2616_headers') . n, gTxt('os_version') . cs . php_uname('s') . ' ' . php_uname('r') . n, $active_plugins ? gTxt('active_plugins') . cs . join(', ', $active_plugins) . n : '', gTxt('theme_name') . cs . $theme_name . sp . $theme_manifest['version'] . n, $fail ? n . gTxt('preflight_check') . cs . n . ln . join("\n", doStripTags($fail)) . n . ln : '', is_readable($path_to_site . '/.htaccess') ? n . gTxt('htaccess_contents') . cs . n . ln . txpspecialchars(join('', file($path_to_site . '/.htaccess'))) . n . ln : ''); if ($step == 'high') { $out[] = n . 'Charset (default/config)' . cs . $DB->default_charset . '/' . $DB->charset . n; $result = safe_query("SHOW variables LIKE 'character_se%'"); while ($row = mysqli_fetch_row($result)) { $out[] = $row[0] . cs . $row[1] . n; if ($row[0] == 'character_set_connection') { $conn_char = $row[1]; } } $table_names = array(PFX . 'textpattern'); $result = safe_query("SHOW TABLES LIKE '" . PFX . "txp\\_%'"); while ($row = mysqli_fetch_row($result)) { $table_names[] = $row[0]; } $table_msg = array(); foreach ($table_names as $table) { $ctr = safe_query("SHOW CREATE TABLE {$table}"); if (!$ctr) { unset($table_names[$table]); continue; } $row = mysqli_fetch_assoc($ctr); $ctcharset = preg_replace('#^CREATE TABLE.*SET=([^ ]+)[^)]*$#is', '\\1', $row['Create Table']); if (isset($conn_char) && !stristr($ctcharset, 'CREATE') && $conn_char != $ctcharset) { $table_msg[] = "{$table} is {$ctcharset}"; } $ctr = safe_query("CHECK TABLE {$table}"); $row = mysqli_fetch_assoc($ctr); if (in_array($row['Msg_type'], array('error', 'warning'))) { $table_msg[] = $table . cs . $row['Msg_Text']; } } if ($table_msg == array()) { $table_msg = count($table_names) < 17 ? array('-') : array('OK'); } $out[] = count($table_names) . ' Tables' . cs . implode(', ', $table_msg) . n; $cf = preg_grep('/^custom_\\d+/', getThings("DESCRIBE `" . PFX . "textpattern`")); $out[] = n . get_pref('max_custom_fields', 10) . sp . gTxt('custom') . cs . implode(', ', $cf) . sp . '(' . count($cf) . ')' . n; $extns = get_loaded_extensions(); $extv = array(); foreach ($extns as $e) { $extv[] = $e . (phpversion($e) ? '/' . phpversion($e) : ''); } $out[] = n . gTxt('php_extensions') . cs . join(', ', $extv) . n; if (is_callable('apache_get_modules')) { $out[] = n . gTxt('apache_modules') . cs . join(', ', apache_get_modules()) . n; } if (@is_array($pretext_data) and count($pretext_data) > 1) { $out[] = n . gTxt('pretext_data') . cs . txpspecialchars(join('', array_slice($pretext_data, 1, 20))) . n; } $out[] = n; if ($md5s = check_file_integrity(INTEGRITY_MD5)) { foreach ($md5s as $f => $checksum) { $out[] = $f . cs . n . t . (!$checksum ? gTxt('unknown') : $checksum) . n; } } $out[] = n . ln; } $out[] = callback_event('diag_results', $step) . n; $out[] = '</textarea>'; echo join('', $out), n . tag_end('div') . n . tag_end('div'); }
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 and outputs the file editor panel. * * @param string|array $message The activity message * @param int $id The file ID */ 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 ? file_upload_form('replace_file', 'file_replace', 'file_replace', $id, 'file_replace', ' replace-file') : file_upload_form('file_relink', 'file_reassign', 'file_replace', $id, 'file_reassign', ' upload-file'); $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 = inputLabel('year', tsi('year', '%Y', $rs['created'], '', 'year') . ' <span role="separator">/</span> ' . tsi('month', '%m', $rs['created'], '', 'month') . ' <span role="separator">/</span> ' . tsi('day', '%d', $rs['created'], '', 'day'), 'publish_date', array('timestamp_file', 'instructions_file_date'), array('class' => 'txp-form-field date posted')) . inputLabel('hour', tsi('hour', '%H', $rs['created'], '', 'hour') . ' <span role="separator">:</span> ' . tsi('minute', '%M', $rs['created'], '', 'minute') . ' <span role="separator">:</span> ' . tsi('second', '%S', $rs['created'], '', 'second'), 'publish_time', array('', 'instructions_file_time'), array('class' => 'txp-form-field time posted')) . n . tag(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . n . tag(gTxt('set_to_now'), 'label', array('for' => 'publish_now')), 'div', array('class' => 'posted-now')); echo n . tag_start('div', array('class' => 'txp-edit')) . hed(gTxt('edit_file'), 2) . $replace . inputLabel('condition', $condition, '', '', array('class' => 'txp-form-field edit-file-condition')) . inputLabel('name', $downloadlink, '', '', array('class' => 'txp-form-field edit-file-name')) . inputLabel('download_count', $downloads, '', '', array('class' => 'txp-form-field edit-file-download-count')) . form(($file_exists ? inputLabel('file_status', selectInput('status', $file_statuses, $status, false, '', 'file_status'), 'file_status', '', array('class' => 'txp-form-field edit-file-status')) . $created . inputLabel('file_title', fInput('text', 'title', $title, '', '', '', INPUT_REGULAR, '', 'file_title'), 'title', '', array('class' => 'txp-form-field edit-file-title')) . inputLabel('file_category', event_category_popup('file', $category, 'file_category') . n . eLink('category', 'list', '', '', gTxt('edit'), '', '', '', 'txp-option-link'), 'file_category', '', array('class' => 'txp-form-field edit-file-category')) . inputLabel('file_description', '<textarea id="file_description" name="description" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '">' . $description . '</textarea>', 'description', '', array('class' => 'txp-form-field txp-form-field-textarea edit-file-description')) . pluggable_ui('file_ui', 'extend_detail_form', '', $rs) . graf(sLink('file', '', gTxt('cancel'), 'txp-button') . fInput('submit', '', gTxt('save'), 'publish'), array('class' => 'txp-edit-actions')) . hInput('filename', $filename) : (empty($existing_files) ? '' : gTxt('existing_file') . selectInput('filename', $existing_files, '', 1)) . pluggable_ui('file_ui', 'extend_detail_form', '', $rs) . graf(sLink('file', '', gTxt('cancel'), 'txp-button') . fInput('submit', '', gTxt('save'), 'publish'), array('class' => 'txp-edit-actions')) . 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', 'file-detail ' . ($file_exists ? '' : 'not-') . 'exists', '', $file_exists ? 'file_details' : 'assign_file') . n . tag_end('div'); } }
function author_edit() { global $step, $txp_user; require_privs('admin.edit'); pagetop(gTxt('tab_site_admin'), ''); $vars = array('user_id', 'name', 'RealName', 'email', 'privs'); $rs = array(); extract(gpsa($vars)); $is_edit = $user_id && $step == 'author_edit'; if ($is_edit) { $user_id = assert_int($user_id); $rs = safe_row('*', 'txp_users', "user_id = {$user_id}"); extract($rs); } $caption = gTxt($is_edit ? 'edit_author' : 'add_new_author'); echo form('<div class="txp-edit">' . n . hed($caption, 2) . n . inputLabel('login_name', $is_edit ? strong($name) : fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), $is_edit ? '' : 'login_name', $is_edit ? '' : 'add_new_author') . n . inputLabel('real_name', fInput('text', 'RealName', $RealName, '', '', '', INPUT_REGULAR, '', 'real_name'), 'real_name') . n . inputLabel('login_email', fInput('text', 'email', $email, '', '', '', INPUT_REGULAR, '', 'login_email'), 'email') . n . inputLabel('privileges', $txp_user != $name ? privs($privs) : hInput('privs', $privs) . strong(get_priv_level($privs)), $is_edit ? '' : 'privileges', 'about_privileges') . n . pluggable_ui('author_ui', 'extend_detail_form', '', $rs) . n . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('admin') . ($user_id ? hInput('user_id', $user_id) . sInput('author_save') : sInput('author_save_new')) . '</div>', '', '', 'post', 'edit-form', '', 'user_edit'); }
function discuss_edit() { global $event; pagetop(gTxt('edit_comment')); extract(gpsa(array('discussid', 'sort', 'dir', 'page', 'crit', 'search_method'))); $discussid = assert_int($discussid); $rs = safe_row('*, unix_timestamp(posted) as uPosted', 'txp_discuss', "discussid = {$discussid}"); if ($rs) { extract($rs); $message = txpspecialchars($message); if (fetch('ip', 'txp_discuss_ipban', 'ip', $ip)) { $ban_step = 'ipban_unban'; $ban_text = gTxt('unban'); } else { $ban_step = 'ipban_add'; $ban_text = gTxt('ban'); } $ban_link = '[<a class="action-ban" href="?event=discuss' . a . 'step=' . $ban_step . a . 'ip=' . $ip . a . 'name=' . urlencode($name) . a . 'discussid=' . $discussid . a . '_txp_token=' . form_token() . '">' . $ban_text . '</a>]'; $status_list = selectInput('visible', array(VISIBLE => gTxt('visible'), SPAM => gTxt('spam'), MODERATE => gTxt('unmoderated')), $visible, false, '', 'status'); echo '<div id="' . $event . '_container" class="txp-container">' . form('<div class="txp-edit">' . n . hed(gTxt('edit_comment'), 2) . n . inputLabel('status', $status_list, 'status') . n . inputLabel('name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'name'), 'name') . n . inputLabel('IP', $ip . n . $ban_link, '') . n . inputLabel('email', fInput('text', 'email', $email, '', '', '', INPUT_REGULAR, '', 'email'), 'email') . n . inputLabel('website', fInput('text', 'web', $web, '', '', '', INPUT_REGULAR, '', 'website'), 'website') . n . inputLabel('date', safe_strftime('%d %b %Y %X', $uPosted), '') . n . inputLabel('commentmessage', '<textarea id="commentmessage" name="message" cols="' . INPUT_LARGE . '" rows="' . INPUT_MEDIUM . '">' . $message . '</textarea>', 'message', '', '', '') . n . graf(fInput('submit', 'step', gTxt('save'), 'publish')) . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('crit', $crit) . hInput('search_method', $search_method) . hInput('discussid', $discussid) . hInput('parentid', $parentid) . hInput('ip', $ip) . eInput('discuss') . sInput('discuss_save') . '</div>', '', '', 'post', 'edit-form', '', 'discuss_edit_form'), '</div>'; } else { echo graf(gTxt('comment_not_found'), ' class="indicator"'); } }
/** * Renders and outputs the section editor panel. */ function section_edit() { global $event, $step, $all_pages, $all_styles; require_privs('section.edit'); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method', 'name'))); $is_edit = $name && $step == 'section_edit'; $caption = gTxt('create_section'); $is_default_section = false; if ($is_edit) { $rs = safe_row("*", 'txp_section', "name = '" . doSlash($name) . "'"); if ($name == 'default') { $caption = gTxt('edit_default_section'); $is_default_section = true; } else { $caption = gTxt('edit_section'); } } else { // Pulls defaults for the new section from the 'default'. $rs = safe_row("page, css, on_frontpage, in_rss, searchable", 'txp_section', "name = 'default'"); if ($rs) { $rs['name'] = $rs['title'] = $rs['description'] = ''; } } if (!$rs) { sec_section_list(array(gTxt('unknown_section'), E_ERROR)); return; } extract($rs, EXTR_PREFIX_ALL, 'sec'); pagetop(gTxt('tab_sections')); $out = array(); $out[] = hed($caption, 2); if ($is_default_section) { $out[] = hInput('name', 'default'); } else { $out[] = inputLabel('section_name', fInput('text', 'name', $sec_name, '', '', '', INPUT_REGULAR, '', 'section_name'), 'section_name', '', array('class' => 'txp-form-field edit-section-name')) . inputLabel('section_title', fInput('text', 'title', $sec_title, '', '', '', INPUT_REGULAR, '', 'section_title'), 'section_longtitle', '', array('class' => 'txp-form-field edit-section-longtitle')); } $out[] = inputLabel('section_page', selectInput('section_page', $all_pages, $sec_page, '', '', 'section_page'), 'uses_page', 'section_uses_page', array('class' => 'txp-form-field edit-section-uses-page')) . inputLabel('section_css', selectInput('css', $all_styles, $sec_css, '', '', 'section_css'), 'uses_style', 'section_uses_css', array('class' => 'txp-form-field edit-section-uses-css')); if (!$is_default_section) { $out[] = inputLabel('on_front_page', yesnoradio('on_frontpage', $sec_on_frontpage, '', $sec_name), '', 'section_on_frontpage', array('class' => 'txp-form-field edit-section-on-frontpage')) . inputLabel('syndicate', yesnoradio('in_rss', $sec_in_rss, '', $sec_name), '', 'section_syndicate', array('class' => 'txp-form-field edit-section-syndicate')) . inputLabel('include_in_search', yesnoradio('searchable', $sec_searchable, '', $sec_name), '', 'section_searchable', array('class' => 'txp-form-field edit-section-searchable')); } $out[] = inputLabel('section_description', '<textarea id="section_description" name="description" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '">' . $sec_description . '</textarea>', 'description', 'section_description', array('class' => 'txp-form-field txp-form-field-textarea edit-section-description')); $out[] = pluggable_ui('section_ui', 'extend_detail_form', '', $rs) . graf(sLink('section', '', gTxt('cancel'), 'txp-button') . fInput('submit', '', gTxt('save'), 'publish'), array('class' => 'txp-edit-actions')) . eInput('section') . sInput('section_save') . hInput('old_name', $sec_name) . hInput('search_method', $search_method) . hInput('crit', $crit) . hInput('page', $page) . hInput('sort', $sort) . hInput('dir', $dir); echo form(join('', $out), '', '', 'post', 'txp-edit', '', 'section_details'); }
/** * Renders and outputs a category editor panel. * * @param string $evname Type of category */ function cat_event_category_edit($evname, $message = '') { $id = assert_int(gps('id')); $parent = doSlash(gps('parent')); $row = safe_row("*", 'txp_category', "id = {$id}"); if ($row) { pagetop(gTxt('edit_category'), $message); extract($row); list($parent_widget, $has_parent) = cat_parent_pop($parent, $evname, $id); $out = hed(gTxt('edit_category'), 2) . inputLabel('category_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'category_name'), $evname . '_category_name', '', array('class' => 'txp-form-field edit-category-name')) . inputLabel('category_parent', $parent_widget, 'parent', '', array('class' => 'txp-form-field edit-category-parent')) . inputLabel('category_title', fInput('text', 'title', $title, '', '', '', INPUT_REGULAR, '', 'category_title'), $evname . '_category_title', '', array('class' => 'txp-form-field edit-category-title')) . inputLabel('category_description', '<textarea id="category_description" name="description" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '">' . $description . '</textarea>', $evname . '_category_description', 'category_description', array('class' => 'txp-form-field txp-form-field-textarea edit-category-description')) . pluggable_ui('category_ui', 'extend_detail_form', '', $row) . hInput('id', $id) . graf(sLink('category', '', gTxt('cancel'), 'txp-button') . fInput('submit', '', gTxt('save'), 'publish'), array('class' => 'txp-edit-actions')) . eInput('category') . sInput('cat_' . $evname . '_save') . hInput('old_name', $name); echo form($out, '', '', 'post', 'txp-edit'); } else { cat_category_list(array(gTxt('category_not_found'), E_ERROR)); } }
/** * 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 n . '<form class="prefs-form" id="prefs_form" method="post" action="index.php">'; // 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(); $build = array(); $groupOut = array(); if (numRows($rs)) { while ($a = nextRow($rs)) { if (!has_privs('prefs.' . $a['event'])) { continue; } if ($a['event'] !== $last_event) { if ($last_event !== null) { $build[] = tag(hed(gTxt($last_event), 2, array('id' => 'prefs_group_' . $last_event . '-label')) . join(n, $out), 'section', array('class' => 'txp-prefs-group', 'id' => 'prefs_group_' . $last_event, 'aria-labelledby' => 'prefs_group_' . $last_event . '-label')); $groupOut[] = n . tag(href(gTxt($last_event), '#prefs_group_' . $last_event, array('data-txp-pane' => $last_event, 'data-txp-token' => form_token())), 'li'); } $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('class' => 'txp-form-field', 'id' => 'prefs-' . $a['name'])); } } if ($last_event === null) { echo graf(gTxt('no_preferences')); } else { $build[] = tag(hed(gTxt($last_event), 2, array('id' => 'prefs_group_' . $last_event . '-label')) . join(n, $out), 'section', array('class' => 'txp-prefs-group', 'id' => 'prefs_group_' . $last_event, 'aria-labelledby' => 'prefs_group_' . $last_event . '-label')); $groupOut[] = n . tag(href(gTxt($last_event), '#prefs_group_' . $last_event, array('data-txp-pane' => $last_event, 'data-txp-token' => form_token())), 'li') . n; echo hed(gTxt('tab_preferences'), 1, array('class' => 'txp-heading')) . n . '<div class="txp-layout-4col-cell-1alt">' . wrapGroup('all_preferences', n . tag(join($groupOut), 'ul', array('class' => 'switcher-list')), 'all_preferences'); if ($last_event !== null) { echo graf(fInput('submit', 'Submit', gTxt('save'), 'publish'), array('class' => 'txp-save')); } echo n . '</div>' . n . '<div class="txp-layout-4col-cell-2-3-4">' . join(n, $build) . n . '</div>' . sInput('prefs_save') . eInput('prefs') . hInput('prefs_id', '1') . tInput(); } echo n . '</form>'; }
/** * Renders an input widget. * * @param string $label The label reference to use (will be subject to l10n) * @param string $thing Content * @return string HTML */ private function widget($label, $thing) { // TODO: Link to attribute help? return inputLabel($label, $thing, $label); }
/** * Paint our user interface: * - A form which sends a new user name to the server. This is done by AJAX and thus requires no page reload. * - An asynchronous link which shows the server's response when clicked. */ static function ui() { pagetop(gTxt(__CLASS__)); // Parameters for the AJAX link // 'event', 'step', 'thing', and 'property' are optional array members. See txplib_html.php for their default values. $async_params = array('step' => 'say_hi', 'thing' => '', 'property' => ''); // Build a AJAX link $greez = asyncHref(self::$greeting[0], $async_params); // Build the output fragment with a well-known id $patron = '<span id="my_name_output">' . self::$my_name . '</span>'; echo '<div class="txp-edit">' . n . hed($greez . ' ' . $patron, 2) . n . form(inputLabel('my_name', fInput('text', 'my_name', self::$my_name, '', '', '', INPUT_REGULAR, '', 'my_name'), 'What is your name?') . n . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput(__CLASS__) . sInput('my_name_is') . '</div>', '', '', 'post', 'async', '', __CLASS__); }
/** * The main stylesheet editor panel. * * @param string|array $message The activity message */ function css_edit($message = '') { global $event, $step; pagetop(gTxt('edit_css'), $message); $default_name = safe_field("css", 'txp_section', "name = 'default'"); 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 == 'css_delete' || empty($name) && $step != 'pour' && !$savenew) { $name = $default_name; } elseif ((($copy || $savenew) && $newname || $newname && $newname != $name) && !$save_error) { $name = $newname; } $titleblock = inputLabel('new_style', fInput('text', 'newname', $name, 'input-medium', '', '', INPUT_MEDIUM, '', 'new_style', false, true), 'css_name', array('', 'instructions_style_name'), array('class' => 'txp-form-field')); if ($name === '') { $titleblock .= hInput('savenew', 'savenew'); } else { $titleblock .= hInput('name', $name); } $titleblock .= eInput('css') . sInput('css_save'); $thecss = gps('css'); if (!$save_error) { $thecss = fetch('css', 'txp_css', 'name', $name); } // Styles code columm. echo n . tag(hed(gTxt('tab_style'), 1, array('class' => 'txp-heading')) . form($titleblock . inputLabel('css', '<textarea class="code" id="css" name="css" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_LARGE . '" dir="ltr">' . txpspecialchars($thecss) . '</textarea>', 'css_code', array('', 'instructions_style_code'), array('class' => 'txp-form-field')), '', '', 'post', '', '', 'style_form'), 'div', array('class' => 'txp-layout-4col-cell-1-2-3', 'id' => 'main_content', 'role' => 'region')); // Styles create/switcher column. $buttonExtras = ''; if ($name) { $buttonExtras .= href('<span class="ui-icon ui-icon-copy"></span> ' . gTxt('duplicate'), '#', array('class' => 'txp-clone', 'data-form' => 'style_form')); } $buttons = graf(tag_void('input', array('class' => 'publish', 'type' => 'submit', 'method' => 'post', 'value' => gTxt('save'), 'form' => 'style_form')), ' class="txp-save"') . graf(sLink('css', 'pour', '<span class="ui-icon ui-extra-icon-new-document"></span> ' . gTxt('create_new_css'), 'txp-new') . $buttonExtras, array('class' => 'txp-actions')); echo n . tag($buttons . css_list($name, $default_name) . n, 'div', array('class' => 'txp-layout-4col-cell-4alt', 'id' => 'content_switcher', 'role' => 'region')); }
/** * 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>'; }
function image_edit($message = '', $id = '') { global $prefs, $file_max_upload_size, $txp_user, $event, $all_image_cats; if (!$id) { $id = gps('id'); } $id = assert_int($id); $rs = safe_row("*, unix_timestamp(date) as uDate", "txp_image", "id = {$id}"); if ($rs) { extract($rs); if (!has_privs('image.edit') && !($author === $txp_user && has_privs('image.edit.own'))) { image_list(gTxt('restricted_area')); return; } pagetop(gTxt('edit_image'), $message); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if ($ext != '.swf') { $aspect = $h == $w ? ' square' : ($h > $w ? ' portrait' : ' landscape'); $img_info = $id . $ext . ' (' . $w . ' × ' . $h . ')'; $img = '<div class="fullsize-image"><img class="content-image" src="' . imagesrcurl($id, $ext) . "?{$uDate}" . '" alt="' . $img_info . '" title="' . $img_info . '" /></div>'; } else { $img = $aspect = ''; } if ($thumbnail and $ext != '.swf') { $thumb_info = $id . 't' . $ext . ' (' . $thumb_w . ' × ' . $thumb_h . ')'; $thumb = '<img class="content-image" src="' . imagesrcurl($id, $ext, true) . "?{$uDate}" . '" alt="' . $thumb_info . '" ' . ($thumb_w ? 'width="' . $thumb_w . '" height="' . $thumb_h . '" title="' . $thumb_info . '"' : '') . ' />'; } else { $thumb = ''; if ($thumb_w == 0) { $thumb_w = get_pref('thumb_w', 0); } if ($thumb_h == 0) { $thumb_h = get_pref('thumb_h', 0); } } echo n . '<div id="' . $event . '_container" class="txp-container">'; echo pluggable_ui('image_ui', 'fullsize_image', $img, $rs), '<section class="txp-edit">', hed(gTxt('edit_image'), 2), pluggable_ui('image_ui', 'image_edit', wrapGroup('image_edit_group', upload_form('', '', 'image_replace', 'image', $id, $file_max_upload_size, 'image_replace', 'image-replace'), 'replace_image', 'replace-image', 'replace_image_form'), $rs), pluggable_ui('image_ui', 'thumbnail_image', '<div class="thumbnail-edit">' . ($thumbnail ? $thumb . n . dLink('image', 'thumbnail_delete', 'id', $id, '', '', '', '', array($page, $sort, $dir, $crit, $search_method)) : '') . '</div>', $rs), pluggable_ui('image_ui', 'thumbnail_edit', wrapGroup('thumbnail_edit_group', upload_form('', '', 'thumbnail_insert', 'image', $id, $file_max_upload_size, 'upload_thumbnail', 'thumbnail-upload'), 'upload_thumbnail', 'thumbnail-upload', 'upload_thumbnail'), $rs), check_gd($ext) ? pluggable_ui('image_ui', 'thumbnail_create', wrapGroup('thumbnail_create_group', form(graf(n . '<label for="width">' . gTxt('thumb_width') . '</label>' . fInput('text', 'width', @$thumb_w, 'input-xsmall', '', '', INPUT_XSMALL, '', 'width') . n . '<label for="height">' . gTxt('thumb_height') . '</label>' . fInput('text', 'height', @$thumb_h, 'input-xsmall', '', '', INPUT_XSMALL, '', 'height') . n . '<label for="crop">' . gTxt('keep_square_pixels') . '</label>' . checkbox('crop', 1, @$prefs['thumb_crop'], '', 'crop') . fInput('submit', '', gTxt('Create')), ' class="edit-alter-thumbnail"') . hInput('id', $id) . eInput('image') . sInput('thumbnail_create') . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit), '', '', 'post', 'edit-form', '', 'thumbnail_alter_form'), 'create_thumbnail', 'thumbnail-alter', 'create_thumbnail'), $rs) : '', '<div class="image-detail">', form(inputLabel('image_name', fInput('text', 'name', $name, '', '', '', INPUT_REGULAR, '', 'image_name'), 'image_name') . inputLabel('image_category', treeSelectInput('category', $all_image_cats, $category, 'image_category'), 'image_category') . inputLabel('image_alt_text', fInput('text', 'alt', $alt, '', '', '', INPUT_REGULAR, '', 'image_alt_text'), 'alt_text') . inputLabel('image_caption', text_area('caption', 0, 0, $caption, 'image_caption', TEXTAREA_HEIGHT_SMALL, INPUT_LARGE), 'caption', '', '', '') . pluggable_ui('image_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('save'), 'publish')) . hInput('id', $id) . eInput('image') . sInput('image_save') . hInput('sort', $sort) . hInput('dir', $dir) . hInput('page', $page) . hInput('search_method', $search_method) . hInput('crit', $crit), '', '', 'post', 'edit-form', '', 'image_details_form'), '</div>', '</section>' . n . '</div>'; } }
function section_edit() { global $event, $step, $txp_user, $all_pages, $all_styles; $name = gps('name'); $is_edit = $name && $step == 'section_edit'; if ($is_edit) { $name = assert_string($name); $rs = safe_row('*', 'txp_section', "name = '" . doSlash($name) . "'"); } else { $rs = array_flip(getThings('describe `' . PFX . 'txp_section`')); } if ($rs) { if (!has_privs('section.edit')) { sec_section_list(gTxt('restricted_area')); return; } pagetop(gTxt('tab_sections')); extract($rs, EXTR_PREFIX_ALL, 'sec'); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); $is_default_section = $is_edit && $sec_name == 'default'; $caption = gTxt($is_default_section ? 'edit_default_section' : ($is_edit ? 'edit_section' : 'create_section')); if (!$is_edit) { // Pulling out the radio items from the default entry might seem pointless since they can't be directly // edited, but they will take on either: // a) the default (SQL) values as defined at table creation time, or // b) the values set when a multi-edit was performed that included the default section (because the values are silently updated then) $default = doSlash(safe_row('page, css, on_frontpage, in_rss, searchable', 'txp_section', "name = 'default'")); $sec_name = $sec_title = ''; $sec_page = $default['page']; $sec_css = $default['css']; $sec_on_frontpage = $default['on_frontpage']; $sec_in_rss = $default['in_rss']; $sec_searchable = $default['searchable']; } echo '<div id="' . $event . '_container" class="txp-container">'; echo form('<div class="txp-edit">' . hed($caption, 2) . ($is_default_section ? hInput('name', 'default') : inputLabel('section_name', fInput('text', 'name', $sec_name, '', '', '', INPUT_REGULAR, '', 'section_name'), 'section_name')) . ($is_default_section ? '' : inputLabel('section_title', fInput('text', 'title', $sec_title, '', '', '', INPUT_REGULAR, '', 'section_title'), 'section_longtitle')) . inputLabel('section_page', selectInput('section_page', $all_pages, $sec_page, '', '', 'section_page'), 'uses_page', 'section_uses_page') . inputLabel('section_css', selectInput('css', $all_styles, $sec_css, '', '', 'section_css'), 'uses_style', 'section_uses_css') . ($is_default_section ? '' : inputLabel('on_front_page', yesnoradio('on_frontpage', $sec_on_frontpage, '', $sec_name), '', 'section_on_frontpage')) . ($is_default_section ? '' : inputLabel('syndicate', yesnoradio('in_rss', $sec_in_rss, '', $sec_name), '', 'section_syndicate')) . ($is_default_section ? '' : inputLabel('include_in_search', yesnoradio('searchable', $sec_searchable, '', $sec_name), '', 'section_searchable')) . pluggable_ui('section_ui', 'extend_detail_form', '', $rs) . graf(fInput('submit', '', gTxt('save'), 'publish')) . eInput('section') . sInput('section_save') . hInput('old_name', $sec_name) . hInput('search_method', $search_method) . hInput('crit', $crit) . hInput('page', $page) . hInput('sort', $sort) . hInput('dir', $dir) . '</div>', '', '', 'post', 'edit-form', '', 'section_details'); echo '</div>'; } }
/** * Renders either stage 3: admin user details panel (on success), or stage 2: * config details error message (on fail). */ function getTxpLogin() { $GLOBALS['textarray'] = setup_load_lang($_SESSION['lang']); global $txpcfg; $problems = array(); if (!isset($txpcfg['db'])) { if (!is_readable(txpath . '/config.php')) { $problems[] = graf(span(null, array('class' => 'ui-icon ui-icon-closethick')) . ' ' . setup_gTxt('config_php_not_found', array('{file}' => txpspecialchars(txpath . '/config.php')), 'raw'), array('class' => 'alert-block error')); } else { @(include txpath . '/config.php'); } } if (!isset($txpcfg) || $txpcfg['db'] != $_SESSION['ddb'] || $txpcfg['table_prefix'] != $_SESSION['dprefix']) { $problems[] = graf(span(null, array('class' => 'ui-icon ui-icon-closethick')) . ' ' . setup_gTxt('config_php_does_not_match_input', '', 'raw'), array('class' => 'alert-block error')); echo txp_setup_progress_meter(2) . n . '<div class="txp-setup">' . n . join(n, $problems) . setup_config_contents() . n . '</div>'; exit; } // Default theme selector. $core_themes = array('classic', 'remora', 'hive'); $themes = \Textpattern\Admin\Theme::names(); foreach ($themes as $t) { $theme = \Textpattern\Admin\Theme::factory($t); if ($theme) { $m = $theme->manifest(); $title = empty($m['title']) ? ucwords($theme->name) : $m['title']; $vals[$t] = in_array($t, $core_themes) ? setup_gTxt('core_theme', array('{theme}' => $title)) : $title; unset($theme); } } asort($vals, SORT_STRING); $theme_chooser = selectInput('theme', $vals, isset($_SESSION['theme']) ? txpspecialchars($_SESSION['theme']) : 'hive', '', '', 'setup_admin_theme'); echo txp_setup_progress_meter(3) . n . '<div class="txp-setup">' . n . '<form class="prefs-form" method="post" action="' . txpspecialchars($_SERVER['PHP_SELF']) . '">' . hed(setup_gTxt('creating_db_tables'), 2) . graf(setup_gTxt('about_to_create')) . inputLabel('setup_user_realname', fInput('text', 'RealName', isset($_SESSION['realname']) ? txpspecialchars($_SESSION['realname']) : '', '', '', '', INPUT_REGULAR, '', 'setup_user_realname', '', true), 'your_full_name', '', array('class' => 'txp-form-field')) . inputLabel('setup_user_email', fInput('text', 'email', isset($_SESSION['email']) ? txpspecialchars($_SESSION['email']) : '', '', '', '', INPUT_REGULAR, '', 'setup_user_email', '', true), 'your_email', '', array('class' => 'txp-form-field')) . inputLabel('setup_user_login', fInput('text', 'name', isset($_SESSION['name']) ? txpspecialchars($_SESSION['name']) : '', '', '', '', INPUT_REGULAR, '', 'setup_user_login', '', true), 'setup_login', 'setup_user_login', array('class' => 'txp-form-field')) . inputLabel('setup_user_pass', fInput('password', 'pass', isset($_SESSION['pass']) ? txpspecialchars($_SESSION['pass']) : '', 'txp-maskable txp-strength-hint', '', '', INPUT_REGULAR, '', 'setup_user_pass', '', true) . n . tag(null, 'div', array('class' => 'strength-meter')) . n . tag(checkbox('unmask', 1, false, 0, 'show_password') . n . tag(gTxt('setup_show_password'), 'label', array('for' => 'show_password')), 'div', array('class' => 'show-password')), 'choose_password', 'setup_user_pass', array('class' => 'txp-form-field')) . hed(setup_gTxt('site_config'), 2) . inputLabel('setup_admin_theme', $theme_chooser, 'admin_theme', 'theme_name', array('class' => 'txp-form-field')) . graf(fInput('submit', 'Submit', setup_gTxt('next_step'), 'publish')) . sInput('createTxp') . n . '</form>' . n . '</div>'; }
/** * Renders a panel for selecting the import tool. * * Lets users select the tool and provide required * configuration options. */ function switch_tool() { global $vars, $event, $step, $tools; extract(gpsa($vars)); pagetop(gTxt('txp_import'), ''); echo hed(gTxt('tab_import'), 1, array('class' => 'txp-heading')); $content = '<section class="txp-edit">'; $content .= hed(gTxt('txp_import'), 2); // Select tool. $content .= inputLabel('import_from', tag(type_options($tools), 'select', ' id="import_from" name="import_tool"'), 'select_tool', 'import'); // Some data we collect. $content .= inputLabel('import_section', import_section_popup(''), 'import_section', 'import_section'); $status_options = array(STATUS_LIVE => gTxt('live'), STATUS_DRAFT => gTxt('draft'), STATUS_HIDDEN => gTxt('hidden'), STATUS_PENDING => gTxt('pending')); $content .= inputLabel('import_status', tag(type_options($status_options), 'select', ' id="import_status"'), 'import_status', 'import_status'); $content .= inputLabel('import_comment', fInput('text', 'import_comments_invite', gTxt('comments'), '', '', '', INPUT_REGULAR, '', 'import_comment'), 'import_invite', 'import_invite'); // Database imports only. $databased = hed(gTxt('database_stuff'), 2) . inputLabel('import_database', fInput('text', 'importdb', '', '', '', '', INPUT_REGULAR, '', 'import_database'), 'import_database', 'import_database') . inputLabel('import_login', fInput('text', 'importdblogin', '', '', '', '', INPUT_REGULAR, '', 'import_login'), 'import_login', 'import_login') . inputLabel('import_password', fInput('text', 'importdbpass', '', '', '', '', INPUT_REGULAR, '', 'import_password'), 'import_password', 'import_password') . inputLabel('import_host', fInput('text', 'importdbhost', '', '', '', '', INPUT_REGULAR, '', 'import_host'), 'import_host', 'import_host'); $content .= tag($databased, 'div', ' id="databased" style="display: none;"'); // Movable Type (MySQL DB) specific. $mtblogid = inputLabel('import_blogid', fInput('text', 'import_blog_id', '', '', '', '', INPUT_REGULAR, '', 'import_blogid'), 'import_blogid', 'import_blogid'); $content .= tag($mtblogid, 'div', ' id="mtblogid" style="display: none;"'); // WordPress specific. $wponly = inputLabel('import_wpprefix', fInput('text', 'wpdbprefix', 'wp_', '', '', '', INPUT_REGULAR, '', 'import_wpprefix'), 'import_wpprefix', 'import_wpprefix') . inputLabel('import_wpdbcharset', selectInput('wpdbcharset', array('utf8' => gTxt('utf8'), 'latin1' => gTxt('latin1')), 'utf8', '', '', 'import_wpdbcharset'), 'import_wpdbcharset', 'import_wpdbcharset'); $content .= tag($wponly, 'div', ' id="wponly" style="display: none;"'); $content .= graf(fInput('submit', 'choose', gTxt('continue'), 'publish')); $content .= sInput('start_import') . eInput('import'); $content .= '</section>'; echo '<div id="' . $event . '_container" class="txp-container">' . form($content, '', '', 'post', '', '', 'import') . '</div>'; }
/** * Renders and outputs the link editor panel. * * @param string|array $message The activity message */ function link_edit($message = '') { global $vars, $event, $step, $txp_user; pagetop(gTxt('tab_link'), $message); extract(array_map('assert_string', gpsa($vars))); $is_edit = $id && $step == 'link_edit'; $rs = array(); if ($is_edit) { $id = assert_int($id); $rs = safe_row("*", 'txp_link', "id = {$id}"); if ($rs) { extract($rs); if (!has_privs('link.edit') && !($author === $txp_user && has_privs('link.edit.own'))) { link_list(gTxt('restricted_area')); return; } } } if (has_privs('link.edit') || has_privs('link.edit.own')) { $caption = gTxt($is_edit ? 'edit_link' : 'add_new_link'); echo form(hed($caption, 2) . inputLabel('link_name', fInput('text', 'linkname', $linkname, '', '', '', INPUT_REGULAR, '', 'link_name'), 'title', '', array('class' => 'txp-form-field edit-link-name')) . inputLabel('link_sort', fInput('text', 'linksort', $linksort, 'input-medium', '', '', INPUT_MEDIUM, '', 'link_sort'), 'sort_value', 'link_sort', array('class' => 'txp-form-field edit-link-sort')) . inputLabel('link_url', fInput('text', 'url', $url, '', '', '', INPUT_REGULAR, '', 'link_url'), 'url', 'link_url', array('class' => 'txp-form-field edit-link-url')) . inputLabel('link_category', event_category_popup('link', $category, 'link_category') . n . eLink('category', 'list', '', '', gTxt('edit'), '', '', '', 'txp-option-link'), 'link_category', 'link_category', array('class' => 'txp-form-field edit-link-category')) . inputLabel('link_description', '<textarea id="link_description" name="description" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '">' . txpspecialchars($description) . '</textarea>', 'description', 'link_description', array('class' => 'txp-form-field txp-form-field-textarea edit-link-description')) . pluggable_ui('link_ui', 'extend_detail_form', '', $rs) . graf(sLink('link', '', gTxt('cancel'), 'txp-button') . fInput('submit', '', gTxt('save'), 'publish'), array('class' => 'txp-edit-actions')) . eInput('link') . sInput('link_save') . hInput('id', $id) . hInput('search_method', gps('search_method')) . hInput('crit', gps('crit')), '', '', 'post', 'txp-edit', '', 'link_details'); } }