function doLoginForm($message) { include txpath . '/lib/txplib_head.php'; pagetop(gTxt('login'), $message); $stay = (cs('txp_login') and !gps('logout') ? 1 : 0); $reset = gps('reset'); $name = join(',', array_slice(explode(',', cs('txp_login')), 0, -1)); echo n . '<div id="login_container" class="txp-container">'; echo form('<div class="txp-login">' . n . hed(gTxt($reset ? 'password_reset' : 'login_to_textpattern'), 2) . n . graf('<span class="login-label"><label for="login_name">' . gTxt('name') . '</label></span>' . n . '<span class="login-value">' . fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name') . '</span>', ' class="login-name"') . ($reset ? '' : n . graf('<span class="login-label"><label for="login_password">' . gTxt('password') . '</label></span>' . n . '<span class="login-value">' . fInput('password', 'p_password', '', '', '', '', INPUT_REGULAR, '', 'login_password') . '</span>', ' class="login-password"')) . ($reset ? '' : graf(checkbox('stay', 1, $stay, '', 'login_stay') . n . '<label for="login_stay">' . gTxt('stay_logged_in') . '</label>' . sp . popHelp('remember_login'), ' class="login-stay"')) . ($reset ? n . hInput('p_reset', 1) : '') . n . graf(fInput('submit', '', gTxt($reset ? 'password_reset_button' : 'log_in_button'), 'publish')) . n . ($reset ? graf('<a href="index.php">' . gTxt('back_to_login') . '</a>', ' class="login-return"') : graf('<a href="?reset=1">' . gTxt('password_forgotten') . '</a>', ' class="login-forgot"')) . (gps('event') ? eInput(gps('event')) : '') . '</div>', '', '', 'post', '', '', 'login_form') . '</div>' . n . script_js(<<<EOSCR // Focus on either username or password when empty \$(document).ready( \tfunction() { \t\tvar has_name = \$("#login_name").val().length; \t\tvar password_box = \$("#login_password").val(); \t\tvar has_password = (password_box) ? password_box.length : 0; \t\tif (!has_name) { \t\t\t\$("#login_name").focus(); \t\t} else if (!has_password) { \t\t \t\$("#login_password").focus(); \t\t} \t} ); EOSCR ) . n . '</div><!-- /txp-body -->' . n . '</body>' . n . '</html>'; exit(0); }
function header() { global $txp_user; $out[] = hed(htmlspecialchars($GLOBALS["prefs"]["sitename"]), 1, ' class="txp-accessibility"'); $out[] = '<nav role="navigation" id="masthead" aria-label="' . gTxt('navigation') . '">'; $out[] = '<ul id="nav">'; foreach ($this->menu as $tab) { $class = $tab['active'] ? ' active' : ''; $out[] = '<li class="primary' . $class . '">' . href($tab["label"], array('event' => $tab['event'])); if (!empty($tab['items'])) { $out[] = '<ul>'; foreach ($tab['items'] as $item) { $class = $item['active'] ? ' active' : ''; $out[] = '<li class="secondary' . $class . '">' . href($item["label"], array('event' => $item['event'])) . '</li>'; } $out[] = '</ul>'; } $out[] = '</li>'; } $out[] = '<li id="view-site" class="primary tabdown inactive">' . href(gTxt('tab_view_site'), hu, ' target="_blank"') . '</li>'; if ($txp_user) { $out[] = '<li id="logout" class="primary tabdown inactive">' . href(gTxt('logout'), 'index.php?logout=1', ' onclick="return verify(\'' . gTxt('are_you_sure') . '\')"') . '</li>'; } $out[] = '</ul>'; $out[] = '</nav>'; $out[] = '<div id="messagepane">' . $this->announce($this->message) . '</div>' . n; return join(n, $out); }
function header() { $out[] = hed(htmlspecialchars($GLOBALS["prefs"]["sitename"]), 1, ' class="txp-accessibility"'); $out[] = '<div id="masthead">'; $out[] = '<div id="navpop">' . navPop(1) . '</div>'; $out[] = hed('Textpattern', 1, ' id="branding"'); $out[] = '</div>'; if (!$this->is_popup) { $out[] = '<nav role="navigation" aria-label="' . gTxt('navigation') . '">'; $out[] = '<div class="nav-tabs" id="nav-primary">'; $out[] = '<ul>'; $secondary = ''; foreach ($this->menu as $tab) { $tc = $tab['active'] ? 'tabup' : 'tabdown'; $out[] = '<li>' . href($tab["label"], array('event' => $tab['event']), ' class="' . $tc . '"') . '</li>'; if ($tab['active'] && !empty($tab['items'])) { $secondary = '<div class="nav-tabs" id="nav-secondary">' . n . '<ul>'; foreach ($tab['items'] as $item) { $tc = $item['active'] ? 'tabup' : 'tabdown'; $secondary .= n . '<li>' . href($item['label'], array('event' => $item['event']), ' class="' . $tc . '"') . '</li>'; } $secondary .= n . '</ul>' . n . '</div>'; } } $out[] = '<li id="view-site">' . href(gTxt('tab_view_site'), hu, ' class="tabdown" target="_blank"') . '</li>'; $out[] = '</ul>'; $out[] = '</div>'; $out[] = $secondary; $out[] = '</nav>'; } $out[] = '<div id="messagepane">' . $this->announce($this->message) . '</div>' . n; return join(n, $out); }
function header() { global $txp_user; $out[] = hed(htmlspecialchars($GLOBALS["prefs"]["sitename"]), 1); if ($txp_user) { $out[] = '<button class="txp-nav-toggle collapsed" type="button" data-toggle="collapse" data-target=".txp-nav"><span class="txp-accessibility">' . gTxt('navigation') . '</span></button>'; $out[] = '<nav class="txp-nav" aria-label="' . gTxt('navigation') . '">'; $out[] = '<ul class="data-dropdown">'; $txpnavdrop = 0; foreach ($this->menu as $tab) { $txpnavdrop++; $class = $tab['active'] ? ' selected' : ''; $out[] = '<li class="dropdown' . $class . '">' . n . href($tab['label'], '#', ' class="dropdown-toggle" id="txp-nav-drop' . $txpnavdrop . '" role="button" aria-controls="txp-nav-drop' . $txpnavdrop . '-menu" data-toggle="dropdown"'); if (!empty($tab['items'])) { $out[] = '<ul class="dropdown-menu" id="txp-nav-drop' . $txpnavdrop . '-menu" role="menu" aria-labelledby="txp-nav-drop' . $txpnavdrop . '">'; foreach ($tab['items'] as $item) { $class = $item['active'] ? ' class="selected"' : ''; $out[] = '<li' . $class . ' role="presentation">' . href($item["label"], array('event' => $item['event']), ' role="menuitem" tabindex="-1"') . '</li>'; } $out[] = '</ul>'; } $out[] = '</li>'; } $out[] = '</ul>'; $out[] = '</nav>'; $out[] = graf(href(span(htmlspecialchars($GLOBALS["prefs"]["sitename"]), array('class' => 'txp-view-site-name')), hu, array('rel' => 'external', 'target' => '_blank', 'title' => gTxt('tab_view_site'))), array('class' => 'txp-view-site')); $out[] = graf(href(gTxt('logout'), 'index.php?logout=1', ' onclick="return verify(\'' . gTxt('are_you_sure') . '\')"'), array('class' => 'txp-logout')); } return join(n, $out); }
/** * 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'; if (gps('logout')) { $step = 'logout'; } elseif (gps('reset')) { $step = 'reset'; } pagetop(gTxt('login'), $message); $stay = (cs('txp_login') and !gps('logout') ? 1 : 0); $reset = gps('reset'); $name = join(',', array_slice(explode(',', cs('txp_login')), 0, -1)); $out = array(); if ($reset) { $out[] = hed(gTxt('password_reset'), 2, array('id' => 'txp-login-heading')) . graf(n . span(tag(gTxt('name'), 'label', array('for' => 'login_name')), array('class' => 'txp-label')) . n . span(fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), array('class' => 'txp-value')), ' class="login-name"') . graf(fInput('submit', '', gTxt('password_reset_button'), 'publish') . n) . graf(href(gTxt('back_to_login'), 'index.php'), array('class' => 'login-return')) . hInput('p_reset', 1); } else { $out[] = hed(gTxt('login_to_textpattern'), 2, array('id' => 'txp-login-heading')) . graf(n . span(tag(gTxt('name'), 'label', array('for' => 'login_name')), array('class' => 'txp-label')) . n . span(fInput('text', 'p_userid', $name, '', '', '', INPUT_REGULAR, '', 'login_name'), array('class' => 'txp-value')), array('class' => 'login-name')) . graf(n . span(tag(gTxt('password'), 'label', array('for' => 'login_password')), array('class' => 'txp-label')) . n . span(fInput('password', 'p_password', '', '', '', '', INPUT_REGULAR, '', 'login_password'), array('class' => 'txp-value')), array('class' => 'login-password')) . graf(checkbox('stay', 1, $stay, '', 'login_stay') . n . tag(gTxt('stay_logged_in'), 'label', array('for' => 'login_stay')) . popHelp('remember_login') . n, array('class' => 'login-stay')) . graf(fInput('submit', '', gTxt('log_in_button'), 'publish') . n) . graf(href(gTxt('password_forgotten'), '?reset=1'), array('class' => 'login-forgot')); if (gps('event')) { $out[] = eInput(gps('event')); } } echo form(tag(join('', $out), 'section', array('role' => 'region', 'class' => 'txp-login', 'aria-labelledby' => 'txp-login-heading')), '', '', 'post', '', '', 'login_form') . script_js('textpattern.textarray = ' . json_encode($textarray_script)) . n . '</main><!-- /txp-body -->' . n . '</body>' . n . '</html>'; exit(0); }
/** * 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')); }
function css_edit_raw() { global $event, $step; $default_name = safe_field('css', 'txp_section', "name = 'default'"); extract(gpsa(array('name', 'newname', 'copy', 'savenew'))); if ($step == 'css_delete' || empty($name) && $step != 'pour' && !$savenew) { $name = $default_name; } elseif (($copy || $savenew) && trim(preg_replace('/[<>&"\']/', '', $newname))) { $name = $newname; } if (empty($name)) { $buttons = '<div class="edit-title">' . gTxt('name_for_this_style') . ': ' . fInput('text', 'newname', '', 'edit', '', '', 20) . hInput('savenew', 'savenew') . '</div>'; $thecss = gps('css'); } else { $buttons = '<div class="edit-title">' . gTxt('you_are_editing_css') . sp . strong(htmlspecialchars($name)) . '</div>'; $thecss = fetch("css", 'txp_css', 'name', $name); } if (!empty($name)) { $copy = '<span class="copy-as"><label for="copy-css">' . gTxt('copy_css_as') . '</label>' . sp . fInput('text', 'newname', '', 'edit', '', '', '', '', 'copy-css') . sp . fInput('submit', 'copy', gTxt('copy'), 'smallerbox') . '</span>'; } else { $copy = ''; } $right = '<div id="content_switcher">' . hed(gTxt('all_stylesheets'), 2) . graf(sLink('css', 'pour', gTxt('create_new_css')), ' class="action-create smallerbox"') . css_list($name, $default_name) . '</div>'; echo '<div id="' . $event . '_container" class="txp-container txp-edit">' . startTable('edit') . tr(td(form('<div id="main_content">' . $buttons . '<textarea id="css" class="code" name="css" cols="78" rows="32">' . htmlspecialchars($thecss) . '</textarea>' . br . fInput('submit', '', gTxt('save'), 'publish') . eInput('css') . sInput('css_save') . hInput('name', $name) . $copy . '</div>', '', '', 'post', 'edit-form', '', 'style_form'), '', 'column') . tdtl($right, ' class="column"')) . endTable() . '</div>'; }
function page_edit($message = '') { global $step; pagetop(gTxt('edit_pages'), $message); extract(gpsa(array('name', 'div'))); $name = (!$name or $step == 'page_delete') ? 'default' : $name; $divline = $step == "div_edit" ? graf(gTxt('you_are_editing_div') . sp . strong($div)) : ''; echo startTable('edit') . tr(td() . td(graf(gTxt('you_are_editing_page') . sp . strong($name)) . $divline) . td()) . tr(tda(hed(gTxt('useful_tags'), 2) . graf(gTxt('page_article_hed') . br . small(taglinks('page_article')), ' class="column"') . graf(gTxt('page_article_nav_hed') . br . small(taglinks('page_article_nav')), ' class="column"') . graf(gTxt('page_nav_hed') . br . small(taglinks('page_nav')), ' class="column"') . graf(gTxt('page_xml_hed') . br . small(taglinks('page_xml')), ' class="column"') . graf(gTxt('page_misc_hed') . br . small(taglinks('page_misc')), ' class="column"') . graf(gTxt('page_file_hed') . br . small(taglinks('page_file')), ' class="column"')) . tda(page_edit_form($name), ' class="column"') . tda(hed(gTxt('all_pages'), 2) . page_list($name), ' class="column"')) . endTable(); }
function getDbInfo() { $temp_txpath = dirname(__FILE__); $temp_doc_root = $_SERVER['DOCUMENT_ROOT']; echo '<form action="setup.php" method="post">', '<table id="setup" cellpadding="0" cellspacing="0" border="0">', tr(tda(hed('Welcome to Textpattern', 3) . graf('Inevitably, we need a few details.', ' style="margin-bottom:3em"') . hed('MySQL', 3) . graf('Note that the database you specify must exist; Textpattern won’t create it for you.'), ' width="400" height="50" colspan="4", align="left"')), tr(fLabelCell('MySQL login') . fInputCell('duser', '', 1) . fLabelCell('MySQL password') . fInputCell('dpass', '', 2)), tr(fLabelCell('MySQL server') . fInputCell('dhost', '', 3) . fLabelCell('MySQL database') . fInputCell('ddb', '', 4)), tr(fLabelCell('Table prefix') . fInputCell('dprefix', '', 5) . tdcs(small('(Use ONLY for multiple installations in one database)'), 2)), tr(tdcs(' ', 4)), tr(tdcs(hed('Site Paths', 3) . graf('Please confirm the following paths to your site root and to the Textpattern directory.'), 4)), tr(fLabelCell('Full path to server\'s web root') . tdcs(fInput('text', 'doc_root', $temp_doc_root, 'edit', '', '', 40) . popHelp('doc_root'), 3)), tr(fLabelCell('Full path to Textpattern') . tdcs(fInput('text', 'txpath', $temp_txpath, 'edit', '', '', 40) . popHelp('full_path'), 3)); echo tr(td() . td(fInput('submit', 'Submit', 'Next', 'publish')) . td() . td()); echo endTable(), sInput('printConfig'), '</form>'; }
function page_edit($message = '') { global $step; pagetop(gTxt('edit_pages'), $message); extract(gpsa(array('name', 'div', 'newname', 'copy'))); $name = (!$name or $step == 'page_delete') ? 'default' : $name; $name = $copy && trim(preg_replace('/[<>&"\']/', '', $newname)) ? $newname : $name; echo startTable('edit') . tr(tda(n . hed(gTxt('tagbuilder'), 2) . n . n . hed('<a href="#article-tags" onclick="toggleDisplay(\'article-tags\'); return false;">' . gTxt('page_article_hed') . '</a>', 3, ' class="plain"') . n . '<div id="article-tags">' . taglinks('page_article') . '</div>' . n . n . hed('<a href="#article-nav-tags" onclick="toggleDisplay(\'article-nav-tags\'); return false;">' . gTxt('page_article_nav_hed') . '</a>', 3, ' class="plain"') . n . '<div id="article-nav-tags" style="display: none;">' . taglinks('page_article_nav') . '</div>' . n . n . hed('<a href="#nav-tags" onclick="toggleDisplay(\'nav-tags\'); return false;">' . gTxt('page_nav_hed') . '</a>', 3, ' class="plain"') . n . '<div id="nav-tags" style="display: none;">' . taglinks('page_nav') . '</div>' . n . n . hed('<a href="#xml-tags" onclick="toggleDisplay(\'xml-tags\'); return false;">' . gTxt('page_xml_hed') . '</a>', 3, ' class="plain"') . n . '<div id="xml-tags" style="display: none;">' . taglinks('page_xml') . '</div>' . n . n . hed('<a href="#misc-tags" onclick="toggleDisplay(\'misc-tags\'); return false;">' . gTxt('page_misc_hed') . '</a>', 3, ' class="plain"') . n . '<div id="misc-tags" style="display: none;">' . taglinks('page_misc') . '</div>' . n . n . hed('<a href="#file-tags" onclick="toggleDisplay(\'file-tags\'); return false;">' . gTxt('page_file_hed') . '</a>', 3, ' class="plain"') . n . '<div id="file-tags" style="display: none;">' . taglinks('page_file') . '</div>', ' class="column"') . tda(page_edit_form($name), ' class="column"') . tda(hed(gTxt('all_pages'), 2) . page_list($name), ' class="column"')) . endTable(); }
function page_edit($message = '') { global $step; pagetop(gTxt('edit_pages'), $message); extract(gpsa(array('name', 'newname', 'copy'))); if (!$name or $step == 'page_delete') { $name = safe_field('page', 'txp_section', "name = 'default'"); } $name = $copy && trim(preg_replace('/[<>&"\']/', '', $newname)) ? $newname : $name; echo startTable('edit') . tr(tda(n . hed(gTxt('tagbuilder'), 2) . n . n . hed('<a href="#article-tags">' . gTxt('page_article_hed') . '</a>', 3, ' class="plain lever expanded"') . n . '<div id="article-tags" class="toggle on" style="display:block">' . taglinks('page_article') . '</div>' . n . n . hed('<a href="#article-nav-tags">' . gTxt('page_article_nav_hed') . '</a>', 3, ' class="plain lever"') . n . '<div id="article-nav-tags" class="toggle" style="display:none">' . taglinks('page_article_nav') . '</div>' . n . n . hed('<a href="#nav-tags">' . gTxt('page_nav_hed') . '</a>', 3, ' class="plain lever"') . n . '<div id="nav-tags" class="toggle" style="display:none">' . taglinks('page_nav') . '</div>' . n . n . hed('<a href="#xml-tags">' . gTxt('page_xml_hed') . '</a>', 3, ' class="plain lever"') . n . '<div id="xml-tags" class="toggle" style="display:none">' . taglinks('page_xml') . '</div>' . n . n . hed('<a href="#misc-tags">' . gTxt('page_misc_hed') . '</a>', 3, ' class="plain lever"') . n . '<div id="misc-tags" class="toggle" style="display:none">' . taglinks('page_misc') . '</div>' . n . n . hed('<a href="#file-tags">' . gTxt('page_file_hed') . '</a>', 3, ' class="plain lever"') . n . '<div id="file-tags" class="toggle" style="display:none">' . taglinks('page_file') . '</div>', ' class="column"') . tda(page_edit_form($name), ' class="column"') . tda(hed(gTxt('all_pages'), 2) . page_list($name), ' class="column"')) . endTable(); }
function show_mentions() { global $id; if ($id) { $rs = safe_rows("*", "txp_log_mention", "article_id='{$id}'"); if ($rs) { foreach ($rs as $a) { extract($a); $out[] = '<a href="http://' . $refpage . '" title="' . $excerpt . '">' . $reftitle . '</a>'; } return hed(gTxt('mentions'), 3) . graf(join(br, $out)); } } }
function sec_section_list($message = '') { global $wlink; pagetop(gTxt('sections'), $message); $default = safe_row('page, css', 'txp_section', "name = 'default'"); $pages = safe_column('name', 'txp_page', "1 = 1"); $styles = safe_column('name', 'txp_css', "1 = 1"); echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 1) . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create')), ' colspan="3"')) . n . n . tr(td(gTxt('default')) . td(form('<table>' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $default['page']) . sp . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $default['css']) . sp . popHelp('section_uses_css'), '', 'noline')) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'default'), ' colspan="2" class="noline"')) . endTable())) . td()); $rs = safe_rows_start('*', 'txp_section', "name != 'default' order by name"); if ($rs) { while ($a = nextRow($rs)) { extract($a); echo n . n . tr(n . td($name) . n . td(form('<table>' . n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20)) . n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20)) . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline')) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('old_name', $name), ' colspan="2" class="noline"')) . endTable(), '', '', 'post', '', 'section-' . $name)) . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section')), " id=\"section-{$name}\""); } } echo n . n . endTable(); }
function sec_section_list($message = '') { global $wlink; pagetop(gTxt('sections'), $message); $default = safe_row('page, css', 'txp_section', "name = 'default'"); $home = safe_row('page, css', 'txp_section', "name = 'home'"); $pages = safe_column('name', 'txp_page', "1 = 1"); $styles = safe_column('name', 'txp_css', "1 = 1"); echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 1) . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create')), ' colspan="3"')) . n . n . tr(tda(gTxt('home'), ' onclick="toggleDisplay(\'section_home\'); return false;"') . td(form('<table id="section_home">' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $home['page']) . sp . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $home['css']) . sp . popHelp('section_uses_css'), '', 'noline')) . pluggable_ui('section_ui', 'extend_detail_form', '', $home) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'home'), ' colspan="2" class="noline"')) . endTable())) . td()) . n . n . tr(tda(gTxt('default'), ' onclick="toggleDisplay(\'section_default\'); return false;"') . td(form('<table id="section_default">' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $default['page']) . sp . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $default['css']) . sp . popHelp('section_uses_css'), '', 'noline')) . pluggable_ui('section_ui', 'extend_detail_form', '', $default) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'default'), ' colspan="2" class="noline"')) . endTable())) . td()); $rs = safe_rows_start('*', 'txp_section', "name != 'default' AND name != 'home' order by name"); if ($rs) { while ($a = nextRow($rs)) { extract($a); echo n . n . tr(n . tda($name, ' onclick="toggleDisplay(\'section_' . $name . '\'); return false;"') . n . td(form('<table id="section_' . $name . '">' . n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20)) . n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20)) . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline')) . n . n . tr(fLabelCell(gTxt('section_descr') . ':') . fTextCell('descr', $descr, 1, 4, 20)) . n . n . tr(fLabelCell(gTxt('section_metakey') . ':') . fInputCell('metakey', $metakey, 1, 20)) . n . n . tr(fLabelCell(gTxt('section_metadesc') . ':') . fTextCell('metadesc', $metadesc, 1, 4, 20)) . pluggable_ui('section_ui', 'extend_detail_form', '', $a) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('old_name', $name), ' colspan="2" class="noline"')) . endTable(), '', '', 'post', '', 'section-' . $name)) . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section')), " id=\"section-{$name}\" class=\"jsection\" "); } } echo n . n . endTable(); }
function page_edit($message = '') { global $event, $step; pagetop(gTxt('edit_pages'), $message); extract(gpsa(array('name', 'newname', 'copy', 'savenew'))); if ($step == 'page_delete' || empty($name) && $step != 'page_new' && !$savenew) { $name = safe_field('page', 'txp_section', "name = 'default'"); } elseif (($copy || $savenew) && trim(preg_replace('/[<>&"\']/', '', $newname))) { $name = $newname; } // 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_options = ''; foreach ($tagbuild_items as $tb => $item) { $tagbuild_options .= n . n . '<div class="' . $item[1] . '">' . hed('<a href="#' . $item[1] . '">' . gTxt($item[0]) . '</a>', 3, ' class="plain lever' . (get_pref('pane_page_' . $item[1] . '_visible') ? ' expanded' : '') . '"') . n . '<div id="' . $item[1] . '" class="toggle" style="display:' . (get_pref('pane_page_' . $item[1] . '_visible') ? 'block' : 'none') . '">' . taglinks($tb) . '</div></div>'; } echo '<div id="' . $event . '_container" class="txp-container txp-edit">' . startTable('edit', '', 'edit-pane') . tr(tda('<div id="tagbuild_links">' . n . hed(gTxt('tagbuilder'), 2) . $tagbuild_options . n . '</div>', ' class="column"') . tda(page_edit_form($name), ' class="column"') . tda('<div id="content_switcher">' . hed(gTxt('all_pages'), 2) . graf(sLink('page', 'page_new', gTxt('create_new_page')), ' class="action-create smallerbox"') . page_list($name) . '</div>', ' class="column"')) . endTable() . '</div>'; }
function sec_section_list($message = '') { global $wlink, $event; pagetop(gTxt('sections'), $message); $default = safe_row('page, css, name', 'txp_section', "name = 'default'"); echo n . '<div id="' . $event . '_container" class="txp-container txp-list">'; echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 2) . n . '<div id="' . $event . '_control" class="txp-control-panel">' . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create'), '', '', 'post', 'edit-form', '', 'section_create') . n . '</div>', ' colspan="3"')) . n . n . tr(td(gTxt('default'), '', 'label') . n . td(section_detail_partial($default)) . n . td(), ' class="section default"'); $rs = safe_rows_start('*', 'txp_section', "name != 'default' order by name"); if ($rs) { $ctr = 1; while ($a = nextRow($rs)) { extract($a); echo n . n . tr(n . td($name, '', 'label') . n . td(section_detail_partial($a), '', 'main') . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section'), '', 'actions'), ' id="section-' . $name . '" class="section ' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"'); $ctr++; } } echo n . n . endTable() . '</div>'; }
/** * 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', // )); }
function getDbInfo() { $lang = isPost('lang'); $GLOBALS['textarray'] = setup_load_lang($lang); @(include './config.php'); if (!empty($txpcfg['db'])) { exit(graf(gTxt('already_installed'))); } $temp_txpath = dirname(__FILE__); if (@$_SERVER['SCRIPT_NAME'] && (@$_SERVER['SERVER_NAME'] || @$_SERVER['HTTP_HOST'])) { $guess_siteurl = @$_SERVER['SERVER_NAME'] ? $_SERVER['SERVER_NAME'] : $_SERVER['HTTP_HOST']; $guess_siteurl .= rtrim(dirname(dirname($_SERVER['SCRIPT_NAME'])), '/'); } else { $guess_siteurl = 'mysite.com'; } echo '<form action="setup.php" method="post">', '<table id="setup" cellpadding="0" cellspacing="0" border="0">', tr(tda(hed(gTxt('welcome_to_textpattern'), 3) . graf(gTxt('need_details'), ' style="margin-bottom:3em"') . hed('MySQL', 3) . graf(gTxt('db_must_exist')), ' width="400" height="50" colspan="4" align="left"')), tr(fLabelCell(gTxt('mysql_login')) . fInputCell('duser', '', 1) . fLabelCell(gTxt('mysql_password')) . fInputCell('dpass', '', 2)), tr(fLabelCell(gTxt('mysql_server')) . fInputCell('dhost', '', 3) . fLabelCell(gTxt('mysql_database')) . fInputCell('ddb', '', 4)), tr(fLabelCell(gTxt('table_prefix')) . fInputCell('dprefix', '', 5) . tdcs(small(gTxt('prefix_warning')), 2)), tr(tdcs(' ', 4)), tr(tdcs(hed(gTxt('site_path'), 3) . graf(gTxt('confirm_site_path')), 4)), tr(fLabelCell(gTxt('full_path_to_txp')) . tdcs(fInput('text', 'txpath', $temp_txpath, 'edit', '', '', 40) . popHelp('full_path'), 3)), tr(tdcs(' ', 4)), tr(tdcs(hed(gTxt('site_url'), 3) . graf(gTxt('please_enter_url')), 4)), tr(fLabelCell('http://') . tdcs(fInput('text', 'siteurl', $guess_siteurl, 'edit', '', '', 40) . popHelp('site_url'), 3)); echo tr(td() . td(fInput('submit', 'Submit', gTxt('next'), 'publish')) . td() . td()); echo endTable(), hInput('lang', $lang), sInput('printConfig'), '</form>'; }
function sec_section_list($message = '') { global $wlink, $event; pagetop(gTxt('sections'), $message); $default = safe_row('page, css', 'txp_section', "name = 'default'"); $pages = safe_column('name', 'txp_page', "1 = 1"); $styles = safe_column('name', 'txp_css', "1 = 1"); echo n . '<div id="' . $event . '_container" class="txp-container txp-list">'; echo n . n . startTable('list') . n . n . tr(tda(n . n . hed(gTxt('section_head') . sp . popHelp('section_category'), 2) . n . '<div id="' . $event . '_control" class="txp-control-panel">' . n . n . form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('create'), 'smallerbox') . eInput('section') . sInput('section_create'), '', '', 'post', 'edit-form', '', 'section_create') . n . '</div>', ' colspan="3"')) . n . n . tr(td(gTxt('default'), '', 'label') . td(form('<table>' . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $default['page']) . sp . popHelp('section_uses_page'), '', 'noline'), ' class="uses-page"') . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $default['css']) . sp . popHelp('section_uses_css'), '', 'noline'), ' class="uses-style"') . pluggable_ui('section_ui', 'extend_detail_form', '', $default) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('name', 'default'), ' colspan="2" class="noline"')) . endTable())) . td(), ' class="section default"'); $rs = safe_rows_start('*', 'txp_section', "name != 'default' order by name"); if ($rs) { $ctr = 1; while ($a = nextRow($rs)) { extract($a); echo n . n . tr(n . td($name, '', 'label') . n . td(form('<table>' . n . n . tr(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), ' class="name"') . n . n . tr(fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20), ' class="title"') . n . n . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pages, $page) . sp . popHelp('section_uses_page'), '', 'noline'), ' class="uses-page"') . n . n . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styles, $css) . sp . popHelp('section_uses_css'), '', 'noline'), ' class="uses-style"') . n . n . tr(fLabelCell(gTxt('selected_by_default')) . td(yesnoradio('is_default', $is_default, '', $name) . sp . popHelp('section_is_default'), '', 'noline'), ' class="option is-default"') . n . n . tr(fLabelCell(gTxt('on_front_page')) . td(yesnoradio('on_frontpage', $on_frontpage, '', $name) . sp . popHelp('section_on_frontpage'), '', 'noline'), ' class="option on-frontpage"') . n . n . tr(fLabelCell(gTxt('syndicate')) . td(yesnoradio('in_rss', $in_rss, '', $name) . sp . popHelp('section_syndicate'), '', 'noline'), ' class="option in-rss"') . n . n . tr(fLabelCell(gTxt('include_in_search')) . td(yesnoradio('searchable', $searchable, '', $name) . sp . popHelp('section_searchable'), '', 'noline'), ' class="option is-searchable"') . pluggable_ui('section_ui', 'extend_detail_form', '', $a) . n . n . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox') . eInput('section') . sInput('section_save') . hInput('old_name', $name), ' colspan="2" class="noline"')) . endTable(), '', '', 'post', '', 'section-' . $name), '', 'main') . td(dLink('section', 'section_delete', 'name', $name, '', 'type', 'section'), '', 'actions'), ' id="section-' . $name . '" class="section ' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"'); $ctr++; } } echo n . n . endTable() . '</div>'; }
function getDbInfo() { $GLOBALS['textarray'] = setup_load_lang(ps('lang')); @(include txpath . '/config.php'); if (!empty($txpcfg['db'])) { exit(graf(gTxt('already_installed', array('{txpath}' => txpath)))); } if (@$_SERVER['SCRIPT_NAME'] && (@$_SERVER['SERVER_NAME'] || @$_SERVER['HTTP_HOST'])) { $guess_siteurl = @$_SERVER['HTTP_HOST'] ? $_SERVER['HTTP_HOST'] : $_SERVER['SERVER_NAME']; $guess_siteurl .= $GLOBALS['rel_siteurl']; } else { $guess_siteurl = 'mysite.com'; } echo '<form action="' . $GLOBALS['rel_siteurl'] . '/textpattern/setup/index.php" method="post">', '<table id="setup" cellpadding="0" cellspacing="0" border="0">', tr(tda(hed(gTxt('welcome_to_textpattern'), 3) . graf(gTxt('need_details'), ' style="margin-bottom:3em"') . hed('MySQL', 3) . graf(gTxt('db_must_exist')), ' width="400" height="50" colspan="4" align="left"')), tr(fLabelCell(gTxt('mysql_login')) . fInputCell('duser', '', 1) . fLabelCell(gTxt('mysql_password')) . fInputCell('dpass', '', 2)), tr(fLabelCell(gTxt('mysql_server')) . fInputCell('dhost', 'localhost', 3) . fLabelCell(gTxt('mysql_database')) . fInputCell('ddb', '', 4)), tr(fLabelCell(gTxt('table_prefix')) . fInputCell('dprefix', '', 5) . tdcs(small(gTxt('prefix_warning')), 2)), tr(tdcs(' ', 4)), tr(tdcs(hed(gTxt('site_url'), 3) . graf(gTxt('please_enter_url')), 4)), tr(fLabelCell('http://') . tdcs(fInput('text', 'siteurl', $guess_siteurl, 'edit', '', '', 40) . popHelp('siteurl'), 3)); if (!is_callable('mail')) { echo tr(tdcs(gTxt('warn_mail_unavailable'), 3, null, '" style="color:red;text-align:center')); } echo tr(td() . td(fInput('submit', 'Submit', gTxt('next'), 'publish')) . td() . td()); echo endTable(), hInput('lang', LANG), sInput('printConfig'), '</form>'; }
function form_edit($message = '') { global $step; pagetop(gTxt('edit_forms'), $message); extract(gpsa(array('Form', 'name', 'type'))); if ($step == 'form_create') { $Form = ''; $name = ''; $type = ''; $inputs = fInput('submit', 'savenew', gTxt('save_new'), 'publish') . eInput("form") . sInput('form_save'); } else { $name = (!$name or $step == 'form_delete') ? 'default' : $name; $rs = safe_row("*", "txp_form", "name='{$name}'"); if ($rs) { extract($rs); $inputs = fInput('submit', 'save', gTxt('save'), 'publish') . eInput("form") . sInput('form_save') . hInput('oldname', $name); } } $out = startTable('edit') . tr(tdtl(hed(gTxt('useful_tags'), 2) . graf(gTxt('articles') . sp . popHelp('form_place_article') . br . popTagLinks('article')) . graf(gTxt('links') . sp . popHelp('form_place_link') . br . popTagLinks('link')) . graf(gTxt('displayed_comments') . sp . popHelp('form_place_comment') . br . popTagLinks('comment')) . graf(gTxt('comment_form') . sp . popHelp('form_place_input') . br . popTagLinks('comment_form')) . graf(gTxt('search_input_form') . sp . popHelp('form_place_search_input') . br . popTagLinks('search_input')) . graf(gTxt('search_results_form') . sp . popHelp('form_place_search_results') . br . popTagLinks('search_result')) . graf(tag('<strong>' . gTxt('file_download_tags') . '</strong>', 'a', ' href="#" onclick="toggleDisplay(\'downloadtags\');"') . sp . popHelp('form_file_download_tags')) . graf(popTagLinks('file_download'), ' style="display:none;" id="downloadtags"')) . tdtl('<form action="index.php" method="post">' . input_textarea($Form) . graf(gTxt('form_name') . br . fInput('text', 'name', $name, 'edit', '', '', 15)) . graf(gTxt('form_type') . br . formtypes($type)) . graf(gTxt('only_articles_can_be_previewed')) . fInput('submit', 'preview', gTxt('preview'), 'smallbox') . graf($inputs) . '</form>') . tdtl(form_list($name))) . endTable(); echo $out; }
function rss_admin_editlink($event, $step) { global $rss_ae_cookie; include txpath . '/include/txp_prefs.php'; if (!isset($rss_ae_cookie)) { $rss_ae_cookie = "rss_article_edit"; $rs = safe_insert('txp_prefs', "name='rss_ae_cookie', val='{$rss_ae_cookie}', prefs_id='1'"); } if (gps("add")) { safe_update("txp_prefs", "val = '" . addslashes(ps('rss_ae_cookie')) . "'", "name = 'rss_ae_cookie' and prefs_id ='1'"); setcookie($rss_ae_cookie, $rss_ae_cookie, time() + 31536000, "/"); header("Location: index.php?event=editlink"); } else { if (gps("rem")) { safe_update("txp_prefs", "val = '" . addslashes(ps('rss_ae_cookie')) . "'", "name = 'rss_ae_cookie' and prefs_id ='1'"); setcookie($rss_ae_cookie, $rss_ae_cookie, time() - 3600, "/"); header("Location: index.php?event=editlink"); } } pagetop("Edit Link"); $aeset = isset($_COOKIE[$rss_ae_cookie]) ? "" : " not"; $tdaStyle = ' style="text-align:right;vertical-align:middle"'; echo form(startTable("list") . tr(tdcs(hed("Add/Remove Public Site Article Edit Link", 1), 2)) . tr(tda(graf('Cookie ' . $rss_ae_cookie . ' is' . $aeset . ' set.', ' align="center"'), ' colspan="2"')) . tr(tda(gTxt('Cookie Name:'), ' style="text-align:right;vertical-align:middle"') . tda(text_input("rss_ae_cookie", $rss_ae_cookie, '20'), ' ')) . tr(tda(graf(fInput("submit", "add", gTxt("Add Edit Link"), "publish") . fInput("submit", "rem", gTxt("Remove Edit Link"), "publish") . eInput("editlink"), ' align="center"'), ' colspan="2"')) . endTable()); }
/** * Processes the selected import tool action. * * Basically does the importing. */ function start_import() { global $event, $vars; extract(psa($vars)); $insert_into_section = $import_section; $insert_with_status = $import_status; $default_comment_invite = $import_comments_invite; include_once txpath . '/include/import/import_' . $import_tool . '.php'; $ini_time = ini_get('max_execution_time'); @ini_set('max_execution_time', 300 + intval($ini_time)); switch ($import_tool) { case 'mtdb': $out = doImportMTDB($importdblogin, $importdb, $importdbpass, $importdbhost, $import_blog_id, $insert_into_section, $insert_with_status, $default_comment_invite); rebuild_tree('root', 1, 'article'); break; case 'mt': $file = check_import_file(); if (!empty($file)) { $out = doImportMT($file, $insert_into_section, $insert_with_status, $import_comments_invite); // Rebuilding category tree. rebuild_tree('root', 1, 'article'); } else { $out = 'Import file not found'; } break; case 'b2': $out = doImportB2($importdblogin, $importdb, $importdbpass, $importdbhost, $insert_into_section, $insert_with_status, $default_comment_invite); break; case 'wp': $out = doImportWP($importdblogin, $importdb, $importdbpass, $importdbhost, $wpdbprefix, $insert_into_section, $insert_with_status, $default_comment_invite, $wpdbcharset); rebuild_tree('root', 1, 'article'); break; case 'blogger': $file = check_import_file(); if (!empty($file)) { $out = doImportBLOGGER($file, $insert_into_section, $insert_with_status, $import_comments_invite); } else { $out = gTxt('import_file_not_found'); } break; } $out = tag('max_execution_time = ' . ini_get('max_execution_time'), 'p', ' class="highlight"') . $out; pagetop(gTxt('txp_import')); $content = '<div id="' . $event . '_container" class="txp-container">'; $content .= startTable('', '', 'txp-list'); $content .= tr(tdcs(hed(gTxt('txp_import'), 2), 2)); $content .= tr(td($out)); $content .= endTable(); $content .= '</div>'; echo $content; $rs = safe_rows_start('parentid, count(*) as thecount', 'txp_discuss', 'visible=1 group by parentid'); if (numRows($rs) > 0) { while ($a = nextRow($rs)) { safe_update('textpattern', "comments_count=" . $a['thecount'], "ID=" . $a['parentid']); } } }
function css_edit_raw() { global $step; $name = gps('name'); $default_name = safe_field('css', 'txp_section', "name = 'default'"); $name = (!$name or $step == 'css_delete') ? $default_name : $name; if (gps('copy') && trim(preg_replace('/[<>&"\']/', '', gps('newname')))) { $name = gps('newname'); } if ($step == 'pour') { $buttons = gTxt('name_for_this_style') . ': ' . fInput('text', 'newname', '', 'edit', '', '', 20) . hInput('savenew', 'savenew'); $thecss = ''; } else { $buttons = ''; $thecss = base64_decode(fetch("css", 'txp_css', 'name', $name)); } if ($step != 'pour') { $left = graf(gTxt('you_are_editing_css') . br . strong($name)) . graf(eLink('css', 'css_edit_form', 'name', $name, gTxt('edit_css_in_form'))) . graf(sLink('css', 'pour', gTxt('bulkload_existing_css'))); $copy = gTxt('copy_css_as') . sp . fInput('text', 'newname', '', 'edit') . sp . fInput('submit', 'copy', gTxt('copy'), 'smallerbox'); } else { $left = ' '; $copy = ''; } $right = hed(gTxt('all_stylesheets'), 2) . css_list($name, $default_name); echo startTable('edit') . tr(tdtl($left) . td(form(graf($buttons) . '<textarea id="css" class="code" name="css" cols="78" rows="32">' . htmlspecialchars($thecss) . '</textarea>' . br . fInput('submit', '', gTxt('save'), 'publish') . eInput('css') . sInput('css_save') . hInput('name', $name) . $copy)) . tdtl($right)) . endTable(); }
function tag_file_download_link() { global $step, $endform, $name; $invars = gpsa(array('filename', 'id')); extract($invars); $out = form(startTable('list') . tr(tdcs(hed(gTxt('tag_file_download_link'), 3), 2)) . tagRow('id', fInput('text', 'id', $id, 'edit', '', '', 4)) . tagRow('filename', fInput('text', 'filename', $filename, 'edit', '', '', 15)) . $endform); $out .= tdb(tb('file_download_link', $invars, gTxt('text_or_tag'))); return $out; }
/** * Generates a <table> of every language that Textpattern supports. * * If requested with HTTP POST parameter 'force' set anything other than 'file', * outputs any errors in RPC server connection. * * @param string|array $message The activity message */ function list_languages($message = '') { require_once txpath . '/lib/IXRClass.php'; $active_lang = safe_field("val", 'txp_prefs', "name = 'language'"); $lang_form = tag(form(tag(gTxt('active_language'), 'label', array('for' => 'language')) . languages('language', $active_lang) . eInput('lang') . sInput('save_language')), 'div', array('class' => 'txp-control-panel')); $client = new IXR_Client(RPC_SERVER); // $client->debug = true; $available_lang = array(); $rpc_connect = false; $show_files = false; // Get items from RPC. @set_time_limit(90); // TODO: 90 seconds: seriously? if ($client->query('tups.listLanguages', get_pref('blog_uid'))) { $rpc_connect = true; $response = $client->getResponse(); foreach ($response as $language) { $available_lang[$language['language']]['rpc_lastmod'] = gmmktime($language['lastmodified']->hour, $language['lastmodified']->minute, $language['lastmodified']->second, $language['lastmodified']->month, $language['lastmodified']->day, $language['lastmodified']->year); } } elseif (gps('force') != 'file') { $msg = gTxt('rpc_connect_error') . "<!--" . $client->getErrorCode() . ' ' . $client->getErrorMessage() . "-->"; } // Get items from Filesystem. $files = get_lang_files(); if (is_array($files) && !empty($files)) { foreach ($files as $file) { if ($fp = @fopen(txpath . DS . 'lang' . DS . $file, 'r')) { $name = preg_replace('/\\.(txt|textpack)$/i', '', $file); $firstline = fgets($fp, 4069); fclose($fp); if (strpos($firstline, '#@version') !== false) { @(list($fversion, $ftime) = explode(';', trim(substr($firstline, strpos($firstline, ' ', 1))))); } else { $fversion = $ftime = null; } $available_lang[$name]['file_note'] = isset($fversion) ? $fversion : 0; $available_lang[$name]['file_lastmod'] = isset($ftime) ? $ftime : 0; } } } // Get installed items from the database. // We need a value here for the language itself, not for each one of the rows. $rows = safe_rows("lang, UNIX_TIMESTAMP(MAX(lastmod)) AS lastmod", 'txp_lang', "1 = 1 GROUP BY lang ORDER BY lastmod DESC"); $installed_lang = array(); foreach ($rows as $language) { $available_lang[$language['lang']]['db_lastmod'] = $language['lastmod']; if ($language['lang'] != $active_lang) { $installed_lang[] = $language['lang']; } } $list = ''; // Create the language table components. foreach ($available_lang as $langname => $langdat) { $file_updated = isset($langdat['db_lastmod']) && @$langdat['file_lastmod'] > $langdat['db_lastmod']; $rpc_updated = @$langdat['rpc_lastmod'] > @$langdat['db_lastmod']; $rpc_install = tda($rpc_updated ? strong(eLink('lang', 'get_language', 'lang_code', $langname, isset($langdat['db_lastmod']) ? gTxt('update') : gTxt('install'), 'updating', isset($langdat['db_lastmod']), '')) . n . span(safe_strftime('%d %b %Y %X', @$langdat['rpc_lastmod']), array('class' => 'date modified')) : (isset($langdat['rpc_lastmod']) ? gTxt('up_to_date') : '-') . (isset($langdat['db_lastmod']) ? n . span(safe_strftime('%d %b %Y %X', $langdat['db_lastmod']), array('class' => 'date modified')) : ''), isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-value"' : ' class="lang-value"'); $lang_file = tda(isset($langdat['file_lastmod']) ? strong(eLink('lang', 'get_language', 'lang_code', $langname, $file_updated ? gTxt('update') : gTxt('install'), 'force', 'file', '')) . n . span(safe_strftime(get_pref('archive_dateformat'), $langdat['file_lastmod']), array('class' => 'date ' . ($file_updated ? 'created' : 'modified'))) : '-', ' class="lang-value languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"'); $list .= tr(hCell(gTxt($langname), '', isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-label" scope="row"' : ' class="lang-label" scope="row"') . n . $rpc_install . n . $lang_file . tda(in_array($langname, $installed_lang) ? dLink('lang', 'remove_language', 'lang_code', $langname, 1) : '-', ' class="languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"')) . n; } // Output table and content. pagetop(gTxt('tab_languages'), $message); echo n . tag(hed(gTxt('tab_languages'), 1, array('class' => 'txp-heading')), 'div', array('class' => 'txp-layout-2col-cell-1')) . n . tag_start('div', array('class' => 'txp-layout-1col', 'id' => 'language_container')); if (isset($msg) && $msg) { echo graf('<span class="ui-icon ui-icon-closethick"></span> ' . $msg, array('class' => 'alert-block error')); } echo $lang_form, n . tag(toggle_box('languages_detail'), 'div', array('class' => 'txp-list-options')) . n . tag_start('div', array('class' => 'txp-listtables')) . n . tag_start('table', array('class' => 'txp-list')) . n . tag_start('thead') . tr(hCell(gTxt('language'), '', ' scope="col"') . hCell(gTxt('from_server') . popHelp('install_lang_from_server'), '', ' scope="col"') . hCell(gTxt('from_file') . popHelp('install_lang_from_file'), '', ' class="languages_detail" scope="col"') . hCell(gTxt('remove_lang') . popHelp('remove_lang'), '', ' class="languages_detail" scope="col"')) . n . tag_end('thead') . n . tag_start('tbody') . $list . n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . hed(gTxt('install_from_textpack'), 2) . n . tag(form('<label for="textpack-install">' . gTxt('install_textpack') . '</label>' . popHelp('get_textpack') . n . '<textarea class="code" id="textpack-install" name="textpack" cols="' . INPUT_LARGE . '" rows="' . TEXTAREA_HEIGHT_SMALL . '" dir="ltr"></textarea>' . fInput('submit', 'install_new', gTxt('upload')) . eInput('lang') . sInput('get_textpack'), '', '', 'post', '', '', 'text_uploader'), 'div', array('class' => 'txp-control-panel')) . n . tag_end('div'); }
function side_help($textile_body, $textile_excerpt) { if ($textile_body == USE_TEXTILE or $textile_excerpt == USE_TEXTILE) { return n . hed('<a href="#textile_help" onclick="toggleDisplay(\'textile_help\'); return false;">' . gTxt('textile_help') . '</a>', 3, ' class="plain"') . n . '<div id="textile_help" class="toggle" style="display:none">' . n . '<ul class="plain-list small">' . n . t . '<li>' . gTxt('header') . ': <strong>h<em>n</em>.</strong>' . sp . popHelpSubtle('header', 400, 400) . '</li>' . n . t . '<li>' . gTxt('blockquote') . ': <strong>bq.</strong>' . sp . popHelpSubtle('blockquote', 400, 400) . '</li>' . n . t . '<li>' . gTxt('numeric_list') . ': <strong>#</strong>' . sp . popHelpSubtle('numeric', 400, 400) . '</li>' . n . t . '<li>' . gTxt('bulleted_list') . ': <strong>*</strong>' . sp . popHelpSubtle('bulleted', 400, 400) . '</li>' . n . '</ul>' . n . '<ul class="plain-list small">' . n . t . '<li>' . '_<em>' . gTxt('emphasis') . '</em>_' . sp . popHelpSubtle('italic', 400, 400) . '</li>' . n . t . '<li>' . '*<strong>' . gTxt('strong') . '</strong>*' . sp . popHelpSubtle('bold', 400, 400) . '</li>' . n . t . '<li>' . '??<cite>' . gTxt('citation') . '</cite>??' . sp . popHelpSubtle('cite', 500, 300) . '</li>' . n . t . '<li>' . '-' . gTxt('deleted_text') . '-' . sp . popHelpSubtle('delete', 400, 300) . '</li>' . n . t . '<li>' . '+' . gTxt('inserted_text') . '+' . sp . popHelpSubtle('insert', 400, 300) . '</li>' . n . t . '<li>' . '^' . gTxt('superscript') . '^' . sp . popHelpSubtle('super', 400, 300) . '</li>' . n . t . '<li>' . '~' . gTxt('subscript') . '~' . sp . popHelpSubtle('subscript', 400, 400) . '</li>' . n . '</ul>' . n . graf('"' . gTxt('linktext') . '":url' . sp . popHelpSubtle('link', 400, 500), ' class="small"') . n . graf('!' . gTxt('imageurl') . '!' . sp . popHelpSubtle('image', 500, 500), ' class="small"') . n . graf('<a id="textile-docs-link" href="http://textpattern.com/textile-sandbox" target="_blank">' . gTxt('More') . '</a>') . n . '</div>'; } }
function form_edit($message = '') { global $step, $essential_forms; pagetop(gTxt('edit_forms'), $message); extract(gpsa(array('Form', 'name', 'type'))); $name = trim(preg_replace('/[<>&"\']/', '', $name)); if ($step == 'form_create') { $inputs = fInput('submit', 'savenew', gTxt('save_new'), 'publish') . eInput("form") . sInput('form_save'); } else { $name = (!$name or $step == 'form_delete') ? 'default' : $name; $rs = safe_row("*", "txp_form", "name='" . doSlash($name) . "'"); extract($rs); $inputs = fInput('submit', 'save', gTxt('save'), 'publish') . eInput("form") . sInput('form_save') . hInput('oldname', $name); } if (!in_array($name, $essential_forms)) { $changename = graf(gTxt('form_name') . br . fInput('text', 'name', $name, 'edit', '', '', 15)); } else { $changename = graf(gTxt('form_name') . br . tag($name, 'em') . hInput('name', $name)); } $out = startTable('edit') . tr(tdtl(hed(gTxt('tagbuilder'), 2) . hed('<a href="#article-tags" onclick="toggleDisplay(\'article-tags\'); return false;">' . gTxt('articles') . '</a>' . sp . popHelp('form_articles'), 3, ' class="plain"') . '<div id="article-tags" class="toggle on" style="display:block">' . popTagLinks('article') . '</div>' . hed('<a href="#link-tags" onclick="toggleDisplay(\'link-tags\'); return false;">' . gTxt('links') . '</a>' . sp . popHelp('form_place_link'), 3, ' class="plain"') . '<div id="link-tags" class="toggle" style="display:none">' . popTagLinks('link') . '</div>' . hed('<a href="#comment-tags" onclick="toggleDisplay(\'comment-tags\'); return false;">' . gTxt('comments') . '</a>' . sp . popHelp('form_comments'), 3, ' class="plain"') . '<div id="comment-tags" class="toggle" style="display:none">' . popTagLinks('comment') . '</div>' . hed('<a href="#comment-detail-tags" onclick="toggleDisplay(\'comment-detail-tags\'); return false;">' . gTxt('comment_details') . '</a>' . sp . popHelp('form_comment_details'), 3, ' class="plain"') . '<div id="comment-detail-tags" class="toggle" style="display:none">' . popTagLinks('comment_details') . '</div>' . hed('<a href="#comment-form-tags" onclick="toggleDisplay(\'comment-form-tags\'); return false;">' . gTxt('comment_form') . '</a>' . sp . popHelp('form_comment_form'), 3, ' class="plain"') . '<div id="comment-form-tags" class="toggle" style="display:none">' . popTagLinks('comment_form') . '</div>' . hed('<a href="#search-result-tags" onclick="toggleDisplay(\'search-result-tags\'); return false;">' . gTxt('search_results_form') . '</a>' . sp . popHelp('form_search_results'), 3, ' class="plain"') . '<div id="search-result-tags" class="toggle" style="display:none">' . popTagLinks('search_result') . '</div>' . hed('<a href="#file-tags" onclick="toggleDisplay(\'file-tags\'); return false;">' . gTxt('file_download_tags') . '</a>' . sp . popHelp('form_file_download_tags'), 3, ' class="plain"') . '<div id="file-tags" class="toggle" style="display:none">' . popTagLinks('file_download') . '</div>' . hed('<a href="#category-tags" onclick="toggleDisplay(\'category-tags\'); return false;">' . gTxt('category_tags') . '</a>' . sp . popHelp('form_category_tags'), 3, ' class="plain"') . '<div id="category-tags" class="toggle" style="display:none">' . popTagLinks('category') . '</div>' . hed('<a href="#section-tags" onclick="toggleDisplay(\'section-tags\'); return false;">' . gTxt('section_tags') . '</a>' . sp . popHelp('form_section_tags'), 3, ' class="plain"') . '<div id="section-tags" class="toggle" style="display:none">' . popTagLinks('section') . '</div>') . tdtl('<form action="index.php" method="post">' . '<textarea id="form" class="code" name="Form" cols="60" rows="20">' . htmlspecialchars($Form) . '</textarea>' . $changename . graf(gTxt('form_type') . br . formtypes($type)) . graf(gTxt('only_articles_can_be_previewed')) . fInput('submit', 'form_preview', gTxt('preview'), 'smallbox') . graf($inputs) . '</form>') . tdtl(form_list($name))) . endTable(); echo $out; }
function plugin_verify() { global $event; if (ps('txt_plugin')) { $plugin = join("\n", file($_FILES['theplugin']['tmp_name'])); } else { $plugin = ps('plugin'); } // pre-4.0 style plugin? if (strpos($plugin, '$plugin=\'') !== false) { // try to increase PCRE's backtrack limit in PHP 5.2+ to accommodate to x-large plugins // @see http://bugs.php.net/bug.php?id=40846 et al. @ini_set('pcre.backtrack_limit', '1000000'); $plugin = preg_replace('@.*\\$plugin=\'([\\w=+/]+)\'.*@s', '$1', $plugin); // have we hit yet another PCRE restriction? if ($plugin === null) { plugin_list(array(gTxt('plugin_pcre_error', array('{errno}' => preg_last_error())), E_ERROR)); return; } } // strip out #comment lines $plugin = preg_replace('/^#.*$/m', '', $plugin); if ($plugin === null) { plugin_list(array(gTxt('plugin_pcre_error', array('{errno}' => preg_last_error())), E_ERROR)); return; } if (isset($plugin)) { $plugin_encoded = $plugin; $plugin = base64_decode($plugin); if (strncmp($plugin, "‹", 2) === 0) { if (function_exists('gzinflate')) { $plugin = gzinflate(substr($plugin, 10)); } else { plugin_list(array(gTxt('plugin_compression_unsupported'), E_ERROR)); return; } } if ($plugin = @unserialize($plugin)) { if (is_array($plugin)) { extract($plugin); $source = ''; if (isset($help_raw) && empty($plugin['allow_html_help'])) { include_once txpath . '/lib/classTextile.php'; $textile = new Textile(); $help_source = $textile->TextileRestricted($help_raw, 0, 0); } else { $help_source = highlight_string($help, true); } $source .= highlight_string('<?php' . $plugin['code'] . '?>', true); $sub = fInput('submit', '', gTxt('install'), 'publish'); pagetop(gTxt('edit_plugins')); echo '<div id="' . $event . '_container" class="txp-container txp-view">' . form(hed(gTxt('previewing_plugin'), 3) . tag($source, 'div', ' id="preview-plugin" class="code"') . hed(gTxt('plugin_help') . ':', 3) . tag($help_source, 'div', ' id="preview-help" class="code"') . $sub . sInput('plugin_install') . eInput('plugin') . hInput('plugin64', $plugin_encoded), 'margin: 0 auto; width: 65%;', '', 'post', 'plugin-info', '', 'plugin_preview') . '</div>'; return; } } } plugin_list(array(gTxt('bad_plugin_code'), E_ERROR)); }
function tag_file_download_description() { global $step, $endform, $tag_name; $atts = gpsa(array('class', 'escape', 'wraptag')); extract($atts); $out = form(startTable('tagbuilder') . tr(tdcs(hed(gTxt('tag_' . $tag_name), 3), 2)) . tagRow('escape', escape_pop($escape)) . tagRow('wraptag', input_tag('wraptag', $wraptag)) . tagRow('class', fInput('text', 'class', $class, 'edit', '', '', 25)) . $endform); if ($step == 'build') { $out .= tdb(tb($tag_name, $atts)); } return $out; }