/** * Renders a list of stylesheets. * * @param string $current The active stylesheet * @param string $default Not used * @return string HTML */ function css_list($current, $default) { $out = array(); $protected = safe_column('DISTINCT css', 'txp_section', '1=1'); $criteria = 1; $criteria .= callback_event('admin_criteria', 'css_list', 0, $criteria); $rs = safe_rows_start('name', 'txp_css', $criteria); if ($rs) { while ($a = nextRow($rs)) { extract($a); $active = $current === $name; if ($active) { $edit = txpspecialchars($name); } else { $edit = eLink('css', '', 'name', $name, $name); } if (!array_key_exists($name, $protected)) { $edit .= dLink('css', 'css_delete', 'name', $name); } $out[] = tag(n . $edit . n, 'li', array('class' => $active ? 'active' : '')); } $out = tag(join(n, $out), 'ul', array('class' => 'switcher-list')); return wrapGroup('all_styles', $out, 'all_stylesheets'); } }
function sec_section_list($message = '') { pagetop(gTxt('sections'), $message); global $wlink; $pageslist = safe_column("name", "txp_page", "1=1"); $styleslist = safe_column("name", "txp_css", "1=1"); $out[] = tr(tdcs(strong(gTxt('section_head')) . popHelp('section_category'), 3)); $out[] = tr(tdcs(form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('Create'), 'smallerbox') . eInput('section') . sInput('section_create')), 3)); $defrow = safe_row("page, css", "txp_section", "name like 'default'"); $out[] = form(tr(td(gTxt('default')) . td(startTable('edit', 'left', '') . tr(fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $defrow['page']) . popHelp('section_uses_page'), '', 'noline')) . tr(fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $defrow['css']) . popHelp('section_uses_css'), '', 'noline')) . tr(tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable()) . td()) . eInput('section') . sInput('section_save') . hInput('name', 'default')); $rs = safe_rows_start("*", "txp_section", "name!='' order by name"); if ($rs) { while ($a = nextRow($rs)) { extract($a); if ($name == 'default') { continue; } $deletelink = dLink('section', 'section_delete', 'name', $name, '', 'type', 'section'); $form = startTable('edit') . stackRows(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), fLabelCell(gTxt('section_longtitle') . ':') . fInputCell('title', $title, 1, 20), fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $page) . popHelp('section_uses_page'), '', 'noline'), fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $css) . popHelp('section_uses_css'), '', 'noline'), fLabelCell(gTxt('selected_by_default') . '?') . td(yesnoradio('is_default', $is_default) . popHelp('section_is_default'), '', 'noline'), fLabelCell(gTxt('on_front_page') . '?') . td(yesnoradio('on_frontpage', $on_frontpage) . popHelp('section_on_frontpage'), '', 'noline'), fLabelCell(gTxt('syndicate') . '?') . td(yesnoradio('in_rss', $in_rss) . popHelp('section_syndicate'), '', 'noline'), fLabelCell(gTxt('include_in_search') . '?') . td(yesnoradio('searchable', $searchable) . popHelp('section_searchable'), '', 'noline'), tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable() . eInput('section') . sInput('section_save') . hInput('old_name', $name); $form = form($form); $out[] = tr(td($name) . td($form) . td($deletelink)); } } echo startTable('list') . join('', $out) . endTable(); }
function section_list($message = '') { pagetop(gTxt('sections'), $message); global $url_mode, $txpac, $wlink; $out[] = tr(tdcs(strong(gTxt('section_head')) . popHelp('section_category'), 3)); $out[] = tr(tdcs(form(fInput('text', 'name', '', 'edit', '', '', 10) . fInput('submit', '', gTxt('Create'), 'smallerbox') . eInput('section') . sInput('section_create')), 3)); $pageslist = safe_column("name", "txp_page", "1"); $styleslist = safe_column("name", "txp_css", "1"); $rs = safe_rows("*", "txp_section", "name!='' order by name"); if ($rs) { foreach ($rs as $a) { extract($a); if ($name == 'default') { continue; } if ($url_mode) { $wlink = !check_sections($name) ? sp . wLink('section', 'missing_section_file', 'name', $name) : ''; } $deletelink = dLink('section', 'section_delete', 'name', $name, '', 'type', 'section'); $form = startTable('edit') . stackRows(fLabelCell(gTxt('section_name') . ':') . fInputCell('name', $name, 1, 20), fLabelCell(gTxt('uses_page') . ':') . td(selectInput('page', $pageslist, $page) . popHelp('section_uses_page'), '', 'noline'), fLabelCell(gTxt('uses_style') . ':') . td(selectInput('css', $styleslist, $css) . popHelp('section_uses_css'), '', 'noline'), fLabelCell(gTxt('selected_by_default') . '?') . td(yesnoradio('is_default', $is_default) . popHelp('section_is_default'), '', 'noline'), fLabelCell(gTxt('on_front_page') . '?') . td(yesnoradio('on_frontpage', $on_frontpage) . popHelp('section_on_frontpage'), '', 'noline'), fLabelCell(gTxt('syndicate') . '?') . td(yesnoradio('in_rss', $in_rss) . popHelp('section_syndicate'), '', 'noline'), fLabelCell(gTxt('include_in_search') . '?') . td(yesnoradio('searchable', $searchable) . popHelp('section_searchable'), '', 'noline'), tda(fInput('submit', '', gTxt('save_button'), 'smallerbox'), ' colspan="2" style="border:0"')) . endTable() . eInput('section') . sInput('section_save') . hInput('old_name', $name); $form = form($form); $out[] = tr(td($name . $wlink) . td($form) . td($deletelink)); } } echo startTable('list') . join('', $out) . endTable(); }
function page_list($current) { $rs = safe_rows_start("name", "txp_page", "name != '' order by name"); while ($a = nextRow($rs)) { extract($a); $dlink = $name != 'default' ? dLink('page', 'page_delete', 'name', $name) : ''; $link = '<a href="?event=page' . a . 'name=' . $name . '">' . $name . '</a>'; $out[] = $current == $name ? tr(td($name) . td($dlink)) : tr(td($link) . td($dlink)); } return startTable('list') . join(n, $out) . endTable(); }
function page_list($current) { $protected = safe_column('DISTINCT page', 'txp_section', '1=1') + array('error_default'); $rs = safe_rows_start('name', 'txp_page', "1 order by name asc"); while ($a = nextRow($rs)) { extract($a); $link = eLink('page', '', 'name', $name, $name); $dlink = !in_array($name, $protected) ? dLink('page', 'page_delete', 'name', $name) : ''; $out[] = $current == $name ? tr(td($name) . td($dlink)) : tr(td($link) . td($dlink)); } return startTable('list') . join(n, $out) . endTable(); }
function list_plugins($message = '') { pagetop(gTxt('edit_plugins'), $message); echo startTable('list') . tr(tda(plugin_form() . plugin_form_old(), ' colspan="5" style="border:0;height:50px"')) . assHead('plugin', 'author', 'version', 'description', 'active', ''); $rs = safe_rows("*", "txp_plugin", "1 order by name"); foreach ($rs as $a) { extract($a); // nice to have eval() do a syntax check on the plugin here echo tr(td(eLink('plugin', 'edit', 'name', $name, $name), 150) . td('<a href="' . $author_uri . '">' . $author . '</a>', 100) . td($version, 10) . td($description, 260) . td(status_link($status, $name, yes_no($status)), 30) . td(dLink('plugin', 'delete', 'name', $name), 30)); unset($name, $page, $deletelink); } echo endTable(); }
function plugin_list($message = '') { pagetop(gTxt('edit_plugins'), $message); echo startTable('list') . tr(tda(plugin_form() . plugin_form_old(), ' colspan="8" style="border:0;height:50px"')) . assHead('plugin', 'author', 'version', 'description', 'active', '', '', ''); $rs = safe_rows_start("*", "txp_plugin", "1 order by name"); while ($a = nextRow($rs)) { extract($a); $elink = eLink('plugin', 'plugin_edit', 'name', $name, gTxt('edit')); $hlink = '<a href="?event=plugin&step=plugin_help&name=' . $name . '">' . gTxt('help') . '</a>'; echo tr(td($name) . td('<a href="' . $author_uri . '">' . $author . '</a>') . td($version, 10) . td($description, 260) . td(status_link($status, $name, yes_no($status)), 30) . td($elink) . td($hlink) . td(dLink('plugin', 'plugin_delete', 'name', $name), 30)); unset($name, $page, $deletelink); } echo endTable(); }
function css_list($current, $default) { $out[] = startTable('', '', 'txp-list'); $criteria = 1; $criteria .= callback_event('admin_criteria', 'css_list', 0, $criteria); $rs = safe_rows_start('name', 'txp_css', $criteria); if ($rs) { while ($a = nextRow($rs)) { extract($a); $edit = $current != $name ? eLink('css', '', 'name', $name, $name) : txpspecialchars($name); $delete = $name != $default ? dLink('css', 'css_delete', 'name', $name) : ''; $out[] = tr(td($edit) . td($delete)); } $out[] = endTable(); return join('', $out); } }
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, $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>'; }
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 css_list($current, $default) { $out[] = startTable('list', 'left', 'list'); $rs = safe_rows_start('name', 'txp_css', "1=1"); $ctr = 1; if ($rs) { while ($a = nextRow($rs)) { extract($a); $edit = $current != $name ? eLink('css', '', 'name', $name, $name) : htmlspecialchars($name); $delete = $name != $default ? dLink('css', 'css_delete', 'name', $name) : ''; $trcls = ' class="' . (($ctr == 1 ? 'first ' : '') . ($ctr % 2 == 0 ? 'even' : 'odd')) . '"'; $out[] = tr(td($edit) . td($delete), $trcls); $ctr++; } $out[] = endTable(); return join('', $out); } }
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 plugin_list($message = '') { pagetop(gTxt('edit_plugins'), $message); echo n . n . startTable('list') . tr(tda(plugin_form(), ' colspan="8" style="height: 30px; border: none;"')); $rs = safe_rows_start('name, status, author, author_uri, version, description, code_md5, length(help) as help, md5(code) as md5', 'txp_plugin', '1 order by name'); if ($rs and numRows($rs) > 0) { echo assHead('plugin', 'author', 'version', 'plugin_modified', 'description', 'active', 'help', '', ''); while ($a = nextRow($rs)) { foreach ($a as $key => $value) { ${$key} = htmlspecialchars($value); } // Fix up the description for clean cases $description = preg_replace(array('#<br />#', '#<(/?(a|b|i|em|strong))>#', '#<a href="(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)">#'), array('<br />', '<$1>', '<a href="$1$2">'), $description); $help = !empty($help) ? '<a href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . $name . '">' . gTxt('view') . '</a>' : gTxt('none'); // modified? $modified = strtolower($md5) != strtolower($code_md5); echo tr(n . td($name) . td(href($author, $author_uri)) . td($version, 10) . td($modified ? gTxt('yes') : '') . td($description, 260) . td(status_link($status, $name, yes_no($status)), 30) . td($help) . td(eLink('plugin', 'plugin_edit', 'name', $name, gTxt('edit'))) . td(dLink('plugin', 'plugin_delete', 'name', $name), 30)); unset($name, $page, $deletelink); } } echo endTable(); }
function image_list($message = '') { global $txpcfg, $extensions, $path_from_root, $img_dir; $pfr = $path_from_root; extract($txpcfg); extract(get_prefs()); pagetop(gTxt('image'), $message); echo pageby_form('image', $article_list_pageby); echo startTable('list'), tr(tda(upload_form(gTxt('upload_file'), gTxt('upload'), 'image_insert'), ' colspan="4" style="border:0"')), tr(hCell(ucfirst(gTxt('name'))) . hCell(gTxt('image_category')) . hCell(gTxt('tags')) . hCell(gTxt('author')) . hCell(gTxt('thumbnail')) . hCell()); $page = gps('page'); $total = getCount('txp_image', "1"); $limit = 15; $numPages = ceil($total / $limit); $page = !$page ? 1 : $page; $offset = ($page - 1) * $limit; $nav[] = $page > 1 ? PrevNextLink("image", $page - 1, gTxt('prev'), 'prev') : ''; $nav[] = sp . small($page . '/' . $numPages) . sp; $nav[] = $page != $numPages ? PrevNextLink("image", $page + 1, gTxt('next'), 'next') : ''; $rs = safe_rows("*", "txp_image", "1 order by category,name limit {$offset},{$limit}"); if ($rs) { foreach ($rs as $a) { extract($a); $thumbnail = $thumbnail ? '<img src="' . $pfr . $img_dir . '/' . $id . 't' . $ext . '" />' : gTxt('no'); $elink = eLink('image', 'image_edit', 'id', $id, $name); $txtilelink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'alt=' . $alt . a . 'h=' . $h . a . 'w=' . $w . a . 'type=textile" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textile</a>'; $txplink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'type=textpattern" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textpattern</a>'; $xhtmlink = '<a target="_blank" href="?event=tag' . a . 'name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'h=' . $h . a . 'w=' . $w . a . 'type=xhtml" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">XHTML</a>'; $dlink = dLink('image', 'image_delete', 'id', $id); echo tr(td($elink) . td($category) . td($txtilelink . ' / ' . $txplink . ' / ' . $xhtmlink) . td($author) . td($thumbnail) . td($dlink, 10)); } echo tr(tdcs(graf(join('', $nav)), 4)); } echo endTable(); $imgdir = $doc_root . $path_from_root . $img_dir; if (!is_dir($imgdir) or !is_writeable($imgdir)) { echo graf(str_replace("{imgdir}", $imgdir, gTxt('img_dir_not_writeable')), ' style="text-align:center;color:red"'); } }
/** * Renders a list of page templates. * * @param string $current The selected template * @return string HTML */ function page_list($current) { $out = array(); $protected = safe_column("DISTINCT page", 'txp_section', "1 = 1") + array('error_default'); $criteria = 1; $criteria .= callback_event('admin_criteria', 'page_list', 0, $criteria); $rs = safe_rows_start("name", 'txp_page', "{$criteria} ORDER BY name ASC"); if ($rs) { while ($a = nextRow($rs)) { extract($a); $active = $current === $name; $edit = eLink('page', '', 'name', $name, $name); if (!in_array($name, $protected)) { $edit .= dLink('page', 'page_delete', 'name', $name); } $out[] = tag($edit, 'li', array('class' => $active ? 'active' : '')); } $out = tag(join(n, $out), 'ul', array('class' => 'switcher-list')); return wrapGroup('all_pages', $out, 'all_pages'); } }
/** * 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>'; } }
function image_edit($message = '', $id = '') { global $txpcfg, $img_dir, $file_max_upload_size, $txp_user, $event; 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'))); $categories = getTree("root", "image"); if ($ext != '.swf') { $aspect = $h == $w ? ' square' : ($h > $w ? ' portrait' : ' landscape'); $img = '<img class="image fullsize" src="' . imagesrcurl($id, $ext) . "?{$uDate}" . '" height="' . $h . '" width="' . $w . '" alt="" title="' . $id . $ext . ' (' . $w . ' × ' . $h . ')" id="image-fullsize" />'; } else { $img = $aspect = ''; } if ($thumbnail and $ext != '.swf') { $thumb = '<img class="image thumbnail" src="' . imagesrcurl($id, $ext, true) . "?{$uDate}" . '" alt="" ' . ($thumb_w ? "width='{$thumb_w}' height='{$thumb_h}'" : '') . ' />'; } else { $thumb = ''; } echo n . '<div id="' . $event . '_container" class="txp-container txp-edit">'; echo startTable('list', '', 'edit-pane'), tr(td(pluggable_ui('image_ui', 'image_edit', $img . br . upload_form(gTxt('replace_image'), 'replace_image_form', 'image_replace', 'image', $id, $file_max_upload_size, 'image-replace', 'image-replace'), $rs)), ' class="image-edit' . $aspect . '"'), tr(td(pluggable_ui('image_ui', 'thumbnail_edit', join('', array($thumbnail ? startTable('image-thumbnail', '', 'image-thumbnail') . tr(td($thumb, '', 'thumbwrapper') . td(dLink('image', 'thumbnail_delete', 'id', $id, '', '', '', '', array($page, $sort, $dir, $crit, $search_method)))) . endTable() . br : '', upload_form(gTxt('upload_thumbnail'), 'upload_thumbnail', 'thumbnail_insert', 'image', $id, $file_max_upload_size, 'upload-thumbnail', 'thumbnail-upload'))), $rs)), ' class="thumbnail-edit"'), check_gd($ext) ? thumb_ui($id, $rs) : '', tr(td(form(graf('<label for="image-name">' . gTxt('image_name') . '</label>' . br . fInput('text', 'name', $name, 'edit', '', '', '', '', 'image-name'), ' class="name"') . graf('<label for="image-category">' . gTxt('image_category') . '</label>' . br . treeSelectInput('category', $categories, $category, 'image-category'), ' class="category"') . graf('<label for="alt-text">' . gTxt('alt_text') . '</label>' . br . fInput('text', 'alt', $alt, 'edit', '', '', 50, '', 'alt-text'), ' class="alt text"') . graf('<label for="caption">' . gTxt('caption') . '</label>' . br . '<textarea id="caption" name="caption">' . $caption . '</textarea>', ' class="caption description text"') . pluggable_ui('image_ui', 'extend_detail_form', '', $rs) . n . graf(fInput('submit', '', gTxt('save'), 'publish')) . n . hInput('id', $id) . n . eInput('image') . n . sInput('image_save') . n . hInput('sort', $sort) . n . hInput('dir', $dir) . n . hInput('page', $page) . n . hInput('search_method', $search_method) . n . hInput('crit', $crit), '', '', 'post', 'edit-form', '', 'image_details_form')), ' class="image-detail"'), endTable() . n . '</div>'; } }
function author_list() { global $myprivs, $txp_user; $out[] = hed(gTxt('authors'), 3, ' align="center"'); $out[] = startTable('list'); $out[] = tr(hCell(gTxt('real_name')) . hCell(gTxt('login_name')) . hCell(ucfirst(gTxt('email'))) . hCell(gTxt('privileges')) . td() . td()); $rs = safe_rows_start("*", "txp_users", "1"); if ($rs) { while ($a = nextRow($rs)) { extract($a); if ($name == $txp_user) { $deletelink = ''; } else { $deletelink = dLink('admin', 'author_delete', 'user_id', $user_id); } $savelink = fInput("submit", 'save', gTxt('save'), 'smallerbox'); $emailhref = '<a href="mailto:' . $email . '">' . $email . '</a>'; $RealNameInput = fInput('text', 'RealName', $RealName, 'edit'); $emailInput = fInput('text', 'email', $email, 'edit'); $row[] = '<form action="index.php" method="post">'; $row[] = $myprivs == 1 ? td($RealNameInput) : td($RealName); $row[] = td($name); $row[] = $myprivs == 1 ? td($emailInput) : td($emailhref); $row[] = $myprivs == 1 ? td(privs($privs) . popHelp("about_privileges")) : td(get_priv_level($privs) . popHelp("about_privileges")); $row[] = $myprivs == 1 ? td($savelink) : ''; $row[] = $myprivs == 1 ? hInput("user_id", $user_id) . eInput("admin") . sInput('author_save') : td(); $row[] = '</form>'; $row[] = $myprivs == 1 ? td($deletelink, 10) : td(); $out[] = tr(join('', $row)); unset($row); } $out[] = endTable(); return join('', $out); } }
function row($row) { global $prefs; extract($prefs); if (!$this->controller) { return; } extract($this->controller->context); extract($row); $event = $this->controller->event; $edit_url = "?event={$event}" . a . 'step=edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; $name = empty($name) ? gTxt('unnamed') : htmlspecialchars($name); if ($thumbnail) { if ($ext != '.swf') { $thumbnail = '<img src="' . hu . $img_dir . '/' . $id . 't' . $ext . '" alt="" />'; } else { $thumbnail = ''; } } if ($ext != '.swf') { $tag_url = '?event=tag' . a . 'tag_name=image' . a . 'id=' . $id . a . 'ext=' . $ext . a . 'w=' . $w . a . 'h=' . $h . a . 'alt=' . urlencode($alt) . a . 'caption=' . urlencode($caption); $tagbuilder = '<ul>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=textile" onclick="popWin(this.href); return false;">Textile</a></li>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=textpattern" onclick="popWin(this.href); return false;">Textpattern</a></li>' . '<li><a target="_blank" href="' . $tag_url . a . 'type=xhtml" onclick="popWin(this.href); return false;">XHTML</a></li>' . '</ul>'; } else { $tagbuilder = sp; } $category = $category ? '<span title="' . htmlspecialchars(fetch_category_title($category, 'image')) . '">' . $category . '</span>' : ''; $tr = array(); $tr[] = $id; $tr[] = n . '<ul>' . n . t . '<li>' . href(gTxt('edit'), $edit_url) . '</li>' . n . t . '<li><a href="' . hu . $img_dir . '/' . $id . $ext . '">' . gTxt('view') . '</a></li>' . n . '</ul>'; $tr[] = gTime($uDate); $tr[] = href($name, $edit_url); $tr[] = $thumbnail; $tr[] = $tagbuilder; $tr[] = $category; $tr[] = '<span title="' . htmlspecialchars(get_author_name($author)) . '">' . $author . '</span>'; $tr[] = dLink($this->controller->event, 'delete', 'id', $id, '', '', '', false, array($page, $sort, $dir, $crit, $search_method)); if ($this->edit_actions and isset($row['id'])) { $tr[] = fInput('checkbox', 'selected[]', $row['id']); } return doWrap($tr, 'tr', 'td', 'row-' . (++$this->count % 2 ? 'odd' : 'even')); }
function file_list($message = '') { global $txpcfg, $extensions, $file_base_path; extract($txpcfg); extract(get_prefs()); pagetop(gTxt('file'), $message); $page = gps('page'); $total = getCount('txp_file', "1=1"); $limit = max(@$file_list_pageby, 25); $numPages = ceil($total / $limit); $page = !$page ? 1 : $page; $offset = ($page - 1) * $limit; $sort = gps('sort'); $dir = gps('dir'); $sort = $sort ? $sort : 'filename'; $dir = $dir ? $dir : 'desc'; if ($dir == "desc") { $dir = "asc"; } else { $dir = "desc"; } $existing_files = get_filenames(); echo startTable('list'), tr(tda(file_upload_form(gTxt('upload_file'), 'upload', 'file_insert'), ' colspan="4" style="border:0"')), count($existing_files) > 0 ? tr(tda(form(graf(gTxt('existing_file') . sp . selectInput('filename', $existing_files, "", 1) . sp . fInput('submit', '', gTxt('Create'), 'smallerbox') . sp . eInput('file') . sInput('file_create'))), ' colspan="4" style="border:0"')) : '', tr(column_head('Id', 'id', 'file', 1, $dir) . column_head('file_name', 'filename', 'file', 1, $dir) . td(gTxt('status')) . td(gTxt('tags')) . column_head('file_category', 'category', 'file', 1, $dir) . column_head('description', 'description', 'file', 1, $dir) . column_head('downloads', 'downloads', 'file', 1, $dir) . td()); $nav[] = $page > 1 ? PrevNextLink("file", $page - 1, gTxt('prev'), 'prev') : ''; $nav[] = sp . small($page . '/' . $numPages) . sp; $nav[] = $page != $numPages ? PrevNextLink("file", $page + 1, gTxt('next'), 'next') : ''; $rs = safe_rows_start("*", "txp_file", "1=1 order by {$sort} {$dir} limit {$offset}, {$limit}"); if ($rs) { while ($a = nextRow($rs)) { extract($a); // does the downloads column exist? if (!isset($downloads)) { // nope, add it safe_alter("txp_file", "ADD downloads INT DEFAULT '0' NOT NULL"); $downloads = 0; } else { if (empty($downloads)) { $downloads = '0'; } } $elink = eLink('file', 'file_edit', 'id', $id, $filename); $dlink = dLink('file', 'file_delete', 'id', $id); //Add tags helper $txtilelink = '<a target="_blank" href="?event=tag' . a . 'name=file' . a . 'id=' . $id . a . 'description=' . urlencode($description) . a . 'filename=' . urlencode($filename) . a . 'type=textile" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textile</a>'; $txplink = '<a target="_blank" href="?event=tag' . a . 'name=file' . a . 'id=' . $id . a . 'description=' . urlencode($description) . a . 'filename=' . urlencode($filename) . a . 'type=textpattern" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">Textpattern</a>'; $xhtmlink = '<a target="_blank" href="?event=tag' . a . 'name=file' . a . 'id=' . $id . a . 'description=' . urlencode($description) . a . 'filename=' . urlencode($filename) . a . 'type=xhtml" onclick="window.open(this.href, \'popupwindow\', \'width=400,height=400,scrollbars,resizable\'); return false;">XHTML</a>'; $file_exists = file_exists(build_file_path($file_base_path, $filename)); $missing = '<span style="color:'; $missing .= $file_exists ? 'green' : 'red'; $missing .= '">'; $missing .= $file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing'); $missing .= '</span>'; $downloadlink = $file_exists ? make_download_link($id, $filename, $id) : $id; echo tr(td($downloadlink) . td($elink) . td($missing) . td($txtilelink . ' / ' . $txplink . ' / ' . $xhtmlink) . td($category, 90) . td($description, 150) . td($downloads == '0' ? " 0" : $downloads, 20) . td($dlink, 10)); } echo tr(tdcs(graf(join('', $nav)), 4)); } echo endTable(); echo pageby_form('file', $file_list_pageby); if (!is_dir($file_base_path) or !is_writeable($file_base_path)) { echo graf(str_replace("{filedir}", $file_base_path, gTxt('file_dir_not_writeable')), ' style="text-align:center;color:red"'); } }
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 image_edit($message = '', $id = '') { if (!$id) { $id = gps('id'); } $id = assert_int($id); global $txpcfg, $img_dir, $file_max_upload_size; pagetop(gTxt('edit_image'), $message); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); $categories = getTree("root", "image"); $rs = safe_row("*, unix_timestamp(date) as uDate", "txp_image", "id = {$id}"); if ($rs) { extract($rs); if ($ext != '.swf') { $img = '<img src="' . hu . $img_dir . '/' . $id . $ext . "?{$uDate}" . '" height="' . $h . '" width="' . $w . '" alt="" title="' . $id . $ext . ' (' . $w . ' × ' . $h . ')" />'; } else { $img = ''; } if ($thumbnail and $ext != '.swf') { $thumb = '<img src="' . hu . $img_dir . '/' . $id . 't' . $ext . "?{$uDate}" . '" alt="" />'; } else { $thumb = ''; } echo startTable('list'), tr(td($img . br . upload_form(gTxt('replace_image'), 'replace_image_form', 'image_replace', 'image', $id, $file_max_upload_size, 'image-replace', ''))), tr(td(join('', array($thumbnail ? startTable('image-thumbnail') . tr(td($thumb) . td(dLink('image', 'thumbnail_delete', 'id', $id))) . endTable() . br : '', upload_form(gTxt('upload_thumbnail'), 'upload_thumbnail', 'thumbnail_insert', 'image', $id, $file_max_upload_size, 'upload-thumbnail', ''))))), check_gd($ext) ? thumb_ui($id) : '', tr(td(form(graf('<label for="image-name">' . gTxt('image_name') . '</label>' . br . fInput('text', 'name', $name, 'edit', '', '', '', '', 'image-name')) . graf('<label for="image-category">' . gTxt('image_category') . '</label>' . br . treeSelectInput('category', $categories, $category, 'image-category')) . graf('<label for="alt-text">' . gTxt('alt_text') . '</label>' . br . fInput('text', 'alt', $alt, 'edit', '', '', 50, '', 'alt-text')) . graf('<label for="caption">' . gTxt('caption') . '</label>' . br . text_area('caption', '100', '400', $caption, 'caption')) . n . graf(fInput('submit', '', gTxt('save'), 'publish')) . n . hInput('id', $id) . n . eInput('image') . n . sInput('image_save') . n . hInput('sort', $sort) . n . hInput('dir', $dir) . n . hInput('page', $page) . n . hInput('search_method', $search_method) . n . hInput('crit', $crit)))), endTable(); } }
function ign_userList() { global $myprivs, $ign_user, $ign_user_db, $prefs, $ign_privs; $allow_edit = in_array($myprivs, explode(',', $ign_privs['edit_users'])) ? true : false; if (version_compare($prefs['version'], '4.0.4') < 0) { ign_add_paging(); } //pagination code $total = safe_count($ign_user_db, '1'); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method', 'last_access'))); $limit = 25; $dir = $dir == 'desc' ? 'desc' : 'asc'; switch ($sort) { case 'name': $sort_by = 'name'; break; case 'email': $sort_by = 'email'; break; case 'privs': $sort_by = 'privs'; break; case 'last_access': $sort_by = 'last_access'; break; case 'realname': default: $sort_by = 'realname'; break; } $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; list($page, $offset, $numPages) = pager($total, $limit, $page); //build search here //TODO: Implement search on user name / real name $rs = safe_rows_start("*", $ign_user_db, "{$criteria} order by {$sort_by} {$dir} limit {$offset}, {$limit}"); $out[] = hed(ign_gTxt('users'), 3, ' align="center"'); $out[] = startTable('list'); $out[] = tr(hCell(href(gTxt('real_name'), "index.php?event=ign_user_mgmt&step=list&page={$page}&dir={$switch_dir}&sort=real_name")) . hCell(href(gTxt('login_name'), "index.php?event=ign_user_mgmt&step=list&page={$page}&dir={$switch_dir}&sort=name")) . hCell(href(ucfirst(gTxt('email')), "index.php?event=ign_user_mgmt&step=list&page={$page}&dir={$switch_dir}&sort=email")) . hCell(href(gTxt('privileges'), "index.php?event=ign_user_mgmt&step=list&page={$page}&dir={$switch_dir}&sort=privs")) . td() . td() . hCell(href(gTxt('last_access'), "index.php?event=ign_user_mgmt&step=list&page={$page}&dir={$switch_dir}&sort=last_access"))); if ($rs) { while ($a = nextRow($rs)) { extract($a); if ($name == $ign_user) { $deletelink = ''; } else { $deletelink = dLink('ign_user_mgmt', 'ign_user_delete', 'user_id', $user_id); } $savelink = fInput("submit", 'save', gTxt('save'), 'smallerbox'); $emailhref = '<a href="mailto:' . $email . '">' . $email . '</a>'; $RealNameInput = fInput('text', 'RealName', $RealName, 'edit'); $emailInput = fInput('text', 'email', $email, 'edit'); $row[] = '<form action="index.php" method="post">'; $row[] = $allow_edit ? td($RealNameInput) : td($RealName); $row[] = td($name); $row[] = $allow_edit ? td($emailInput) : td($emailhref); $row[] = $allow_edit ? td(ign_privList($privs) . popHelp("about_privileges")) : td(ign_getPrivLevel($privs) . popHelp("about_privileges")); $row[] = $allow_edit ? td($savelink) : ''; $row[] = $allow_edit ? hInput("user_id", $user_id) . eInput("ign_user_mgmt") . sInput('ign_userSave') : td(); $row[] = '</form>'; $row[] = $allow_edit ? td($deletelink, 10) : td(); //clean up last_access if ($last_access == 0) { $last_access = 'Never'; } $row[] = td($last_access); $out[] = tr(join('', $row)); unset($row); } $out[] = endTable(); $out[] = nav_form('ign_user_mgmt', $page, $numPages, $sort, 'asc', '1', '1'); return join('', $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 file_list($message = '') { global $txpcfg, $extensions, $file_base_path; pagetop(gTxt('file'), $message); extract($txpcfg); extract(get_prefs()); extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method'))); if (!is_dir($file_base_path) or !is_writeable($file_base_path)) { echo graf(gTxt('file_dir_not_writeable', array('{filedir}' => $file_base_path)), ' id="warning"'); } else { $existing_files = get_filenames(); if (count($existing_files) > 0) { echo form(eInput('file') . sInput('file_create') . graf(gTxt('existing_file') . sp . selectInput('filename', $existing_files, '', 1) . sp . fInput('submit', '', gTxt('Create'), 'smallerbox')), 'text-align: center;'); } echo file_upload_form(gTxt('upload_file'), 'upload', 'file_insert'); } $dir = $dir == 'desc' ? 'desc' : 'asc'; switch ($sort) { case 'id': $sort_sql = 'id ' . $dir; break; case 'filename': $sort_sql = 'filename ' . $dir; break; case 'description': $sort_sql = 'description ' . $dir . ', filename desc'; break; case 'category': $sort_sql = 'category ' . $dir . ', filename desc'; break; case 'downloads': $sort_sql = 'downloads ' . $dir . ', filename desc'; break; default: $dir = 'desc'; $sort_sql = 'filename ' . $dir; break; } $switch_dir = $dir == 'desc' ? 'asc' : 'desc'; $criteria = 1; if ($search_method and $crit) { $crit_escaped = doSlash($crit); $critsql = array('id' => "id = '{$crit_escaped}'", 'filename' => "filename like '%{$crit_escaped}%'", 'description' => "description like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'"); if (array_key_exists($search_method, $critsql)) { $criteria = $critsql[$search_method]; $limit = 500; } else { $search_method = ''; $crit = ''; } } else { $search_method = ''; $crit = ''; } $total = safe_count('txp_file', "{$criteria}"); if ($total < 1) { if ($criteria != 1) { echo n . file_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' style="text-align: center;"'); } else { echo n . graf(gTxt('no_files_recorded'), ' style="text-align: center;"'); } return; } $limit = max(@$file_list_pageby, 15); list($page, $offset, $numPages) = pager($total, $limit, $page); echo file_search_form($crit, $search_method); $rs = safe_rows_start('*', 'txp_file', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}"); if ($rs) { echo startTable('list') . tr(column_head('ID', 'id', 'file', true, $switch_dir, $crit, $search_method) . td() . column_head('file_name', 'filename', 'file', true, $switch_dir, $crit, $search_method) . column_head('description', 'description', 'file', true, $switch_dir, $crit, $search_method) . column_head('file_category', 'category', 'file', true, $switch_dir, $crit, $search_method) . hCell(gTxt('tags')) . hCell(gTxt('status')) . column_head('downloads', 'downloads', 'file', true, $switch_dir, $crit, $search_method) . hCell()); while ($a = nextRow($rs)) { extract($a); $edit_url = '?event=file' . a . 'step=file_edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit; $file_exists = file_exists(build_file_path($file_base_path, $filename)); $download_link = $file_exists ? '<li>' . make_download_link($id) . '</li>' : ''; $category = $category ? '<span title="' . fetch_category_title($category, 'file') . '">' . $category . '</span>' : ''; $tag_url = '?event=tag' . a . 'tag_name=file_download_link' . a . 'id=' . $id . a . 'description=' . urlencode($description) . a . 'filename=' . urlencode($filename); $status = '<span class="'; $status .= $file_exists ? 'ok' : 'not-ok'; $status .= '">'; $status .= $file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing'); $status .= '</span>'; // does the downloads column exist? if (!isset($downloads)) { // nope, add it safe_alter('txp_file', "ADD downloads INT DEFAULT '0' NOT NULL"); $downloads = 0; } elseif (empty($downloads)) { $downloads = '0'; } echo tr(n . td($id) . td('<ul>' . '<li>' . href(gTxt('edit'), $edit_url) . '</li>' . $download_link . '</ul>', 65) . td(href($filename, $edit_url), 125) . td($description, 150) . td($category, 90) . td(n . '<ul>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=textile" onclick="popWin(this.href, 400, 250); return false;">Textile</a></li>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=textpattern" onclick="popWin(this.href, 400, 250); return false;">Textpattern</a></li>' . n . t . '<li><a target="_blank" href="' . $tag_url . a . 'type=xhtml" onclick="popWin(this.href, 400, 250); return false;">XHTML</a></li>' . n . '</ul>', 75) . td($status, 45) . td($downloads == '0' ? gTxt('none') : $downloads, 25) . td(dLink('file', 'file_delete', 'id', $id), 10)); } echo endTable() . nav_form('file', $page, $numPages, $sort, $dir, $crit, $search_method) . pageby_form('file', $file_list_pageby); } }
function author_list() { global $txp_user; echo n . n . hed(gTxt('authors'), 3, ' style="text-align: center;"') . n . n . startTable('list') . n . tr(n . hCell(gTxt('real_name')) . n . hCell(gTxt('login_name')) . n . hCell(gTxt('email')) . n . hCell(gTxt('privileges')) . n . hCell() . n . hCell()); $rs = safe_rows_start('*', 'txp_users', '1 = 1 order by name asc'); if ($rs) { if (has_privs('admin.edit')) { while ($a = nextRow($rs)) { extract($a); echo n . n . '<tr>' . n . '<form method="post" action="index.php">' . n . td(fInput('text', 'RealName', $RealName, 'edit')) . td(htmlspecialchars($name)) . td(fInput('text', 'email', $email, 'edit')); if ($name != $txp_user) { echo td(privs($privs) . sp . popHelp('about_privileges')); } else { echo td(get_priv_level($privs) . sp . popHelp('about_privileges') . hInput('privs', $privs)); } echo td(fInput('submit', 'save', gTxt('save'), 'smallerbox')) . n . hInput('user_id', $user_id) . n . eInput('admin') . n . sInput('author_save') . n . '</form>'; if ($name != $txp_user) { echo td(dLink('admin', 'author_delete', 'user_id', $user_id)); } else { echo td(); } echo n . '</tr>'; } } else { while ($a = nextRow($rs)) { extract(doSpecial($a)); echo tr(td($RealName) . td($name) . td('<a href="mailto:' . $email . '">' . $email . '</a>') . td(get_priv_level($privs) . sp . popHelp('about_privileges') . hInput('privs', $privs)) . td() . td()); } } echo n . endTable(); } }
function page_list($current) { $protected = safe_column('DISTINCT page', 'txp_section', '1=1') + array('error_default'); $rs = safe_rows_start('name', 'txp_page', "1 order by name asc"); $ctr = 1; while ($a = nextRow($rs)) { extract($a); $link = eLink('page', '', 'name', $name, $name); $dlink = !in_array($name, $protected) ? dLink('page', 'page_delete', 'name', $name) : ''; $trcls = ' class="' . (($ctr == 1 ? 'first ' : '') . ($ctr % 2 == 0 ? 'even' : 'odd')) . '"'; $out[] = $current == $name ? tr(td($name) . td($dlink), $trcls) : tr(td($link) . td($dlink), $trcls); $ctr++; } return startTable('list', '', 'list') . join(n, $out) . endTable(); }
function css_edit_form() { 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'); } $css = base64_decode(fetch("css", 'txp_css', 'name', $name)); $css = parseCSS($css); $css = $step == 'add_dec' ? add_declaration($css) : $css; $css = $step == 'del_dec' ? delete_declaration($css) : $css; $css = $step == 'add_sel' ? addSel($css) : $css; $right = hed(gTxt('all_stylesheets'), 2) . css_list($name, $default_name); $left = graf(gTxt('you_are_editing_css') . br . strong($name)) . graf(eLink('css', 'css_edit_raw', 'name', $name, gTxt('edit_raw_css'))) . graf(sLink('css', 'pour', gTxt('bulkload_existing_css'))); $out[] = startTable('css-edit', '', '', 3); $out[] = tr(td(strong(gTxt('css_selector'))) . td(strong(gTxt('css_property_value')))); $i = -1; foreach ($css as $selector => $propvals) { $out[] = n . '<tr>' . n . td(fInput('text', ++$i, $selector, 'css') . ' ' . aLink('css', 'add_dec', 'selector', $selector, 'name', $name), '', 'selector', 's' . $i); if (is_array($propvals)) { $out[] = n . t . '<td class="selector2">'; $ii = -1; foreach ($propvals as $property => $value) { $out[] = fInput('text', $i . '-' . ++$ii . 'p', $property, 'css') . ' ' . fInput('text', $i . '-' . $ii . 'v', ltrim($value), 'css') . ' ' . dLink('css', 'del_dec', 'declaration', $i . '-' . $ii, '', 'name', $name, 1) . br; } $out[] = '</td>' . n . '</tr>'; } } $out[] = tr(tdcs(fInput('submit', '', gTxt('save'), 'publish'), 2)) . endTable() . eInput('css') . sInput('css_save_posted') . hInput('name', $name); echo startTable('edit') . tr(tdtl($left) . td(form(graf(gTxt('add_new_selector') . ': ' . sp . fInput('text', 'selector', '', 'css') . sp . fInput('submit', 'add_sel', gTxt('submit'), 'smallerbox') . eInput('css') . sInput('add_sel') . hInput('name', $name))) . form(join('', $out)) . form(graf(gTxt('copy_css_as') . sp . fInput('text', 'newname', '', 'edit') . sp . fInput('submit', 'copy', gTxt('copy'), 'smallerbox') . eInput('css') . sInput('css_copy') . hInput('oldname', $name) . hInput('name', $name)))) . tdtl($right)) . endTable(); }
function list_languages($message = '') { global $prefs, $locale, $textarray; require_once txpath . '/lib/IXRClass.php'; // Select and save active language if (!$message && ps('step') == 'list_languages' && ps('language')) { $locale = doSlash(getlocale(ps('language'))); safe_update("txp_prefs", "val='" . doSlash(ps('language')) . "'", "name='language'"); safe_update("txp_prefs", "val='" . $locale . "'", "name='locale'"); $textarray = load_lang(doSlash(ps('language'))); $locale = setlocale(LC_ALL, $locale); $message = gTxt('preferences_saved'); } $active_lang = safe_field('val', 'txp_prefs', "name='language'"); $lang_form = '<div id="language_control" class="txp-control-panel">' . form(graf(gTxt('active_language') . languages('language', $active_lang) . n . fInput('submit', 'Submit', gTxt('save'), 'publish') . eInput('prefs') . sInput('list_languages'))) . '</div>'; $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); if ($client->query('tups.listLanguages', $prefs['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 = str_replace('.txt', '', $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 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 = ''; // Show the language table 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('prefs', 'get_language', 'lang_code', $langname, isset($langdat['db_lastmod']) ? gTxt('update') : gTxt('install'), 'updating', isset($langdat['db_lastmod']), '')) . n . '<span class="date modified">' . safe_strftime('%d %b %Y %X', @$langdat['rpc_lastmod']) . '</span>' : (isset($langdat['rpc_lastmod']) ? gTxt('updated') : '-') . (isset($langdat['db_lastmod']) ? n . '<span class="date modified">' . safe_strftime('%d %b %Y %X', $langdat['db_lastmod']) . '</span>' : ''), isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-value"' : ' class="lang-value"'); $lang_file = tda(isset($langdat['file_lastmod']) ? strong(eLink('prefs', 'get_language', 'lang_code', $langname, $file_updated ? gTxt('update') : gTxt('install'), 'force', 'file', '')) . n . '<span class="date ' . ($file_updated ? 'created' : 'modified') . '">' . safe_strftime($prefs['archive_dateformat'], $langdat['file_lastmod']) . '</span>' : '-', ' class="lang-value languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"'); $list .= tr(tda(gTxt($langname), isset($langdat['db_lastmod']) && $rpc_updated ? ' class="highlight lang-label"' : ' class="lang-label"') . n . $rpc_install . n . $lang_file . n . tda(in_array($langname, $installed_lang) ? dLink('prefs', 'remove_language', 'lang_code', $langname, 1) : '-', ' class="languages_detail' . (isset($langdat['db_lastmod']) && $rpc_updated ? ' highlight' : '') . '"')) . n . n; } // Output Table + Content // TODO: tab_languages when this panel is moved to its own tab pagetop(gTxt('update_languages'), $message); //TODO: tab_languages when this panel is moved to its own tab echo '<h1 class="txp-heading">' . gTxt('update_languages') . '</h1>'; echo n . '<div id="language_container" class="txp-container">'; if (isset($msg) && $msg) { echo tag($msg, 'p', ' class="error lang-msg"'); } echo n . '<p class="nav-tertiary">' . sLink('prefs', 'prefs_list', gTxt('site_prefs'), 'navlink') . sLink('prefs', 'advanced_prefs', gTxt('advanced_preferences'), 'navlink') . sLink('prefs', 'list_languages', gTxt('manage_languages'), 'navlink-active') . n . '</p>'; echo $lang_form; echo n, '<div class="txp-listtables">', startTable('', '', 'txp-list'), '<thead>', tr(hCell(gTxt('language')) . hCell(gTxt('from_server') . n . popHelp('install_lang_from_server')) . hCell(gTxt('from_file') . n . popHelp('install_lang_from_file'), '', ' class="languages_detail"') . hCell(gTxt('remove_lang') . n . popHelp('remove_lang'), '', ' class="languages_detail"')), '</thead>'; echo '<tbody>' . $list . '</tbody>', endTable(), n, '</div>'; echo graf(toggle_box('languages_detail'), ' class="detail-toggle"'); echo hed(gTxt('install_from_textpack'), 3) . n . form(graf('<label for="textpack-install">' . gTxt('install_textpack') . '</label>' . n . popHelp('get_textpack') . n . '<textarea id="textpack-install" class="code" name="textpack" cols="' . INPUT_LARGE . '" rows="' . INPUT_XSMALL . '"></textarea>' . n . fInput('submit', 'install_new', gTxt('upload')) . eInput('prefs') . sInput('get_textpack')), '', '', 'post', 'edit-form', '', 'text_uploader'); echo '</div>'; // end language_container }