本文整理汇总了PHP中script_js函数的典型用法代码示例。如果您正苦于以下问题:PHP script_js函数的具体用法?PHP script_js怎么用?PHP script_js使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了script_js函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: announce
function announce($thing)
{
// $thing[0]: message text
// $thing[1]: message type, defaults to "success" unless empty or a different flag is set
if ($thing === '') {
return '';
}
if (!is_array($thing) || !isset($thing[1])) {
$thing = array($thing, 0);
}
switch ($thing[1]) {
case E_ERROR:
$class = 'error';
break;
case E_WARNING:
$class = 'warning';
break;
default:
$class = 'success';
break;
}
$html = "<span id='message' class='{$class}'>" . gTxt($thing[0]) . '</span>';
// Try to inject $html into the message pane no matter when announce()'s output is printed
$js = addslashes($html);
$js = <<<EOS
\t\t\$(document).ready( function(){
\t \t\t\$("#messagepane").html("{$js}");
\t\t\t\$('#messagepane #message.error').fadeOut(800).fadeIn(800);
\t\t\t\$('#messagepane #message.warning').fadeOut(800).fadeIn(800);
\t\t} )
EOS;
return script_js(str_replace('</', '<\\/', $js), $html);
}
示例2: doLoginForm
/**
* 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);
}
示例3: export
/**
* Weave the current template and show it ready to paste.
*/
static function export()
{
$f = file_get_contents(txpath . self::$template);
foreach (self::$what as $table => $columns) {
$tick = '`';
$cols = empty($columns) ? '*' : $tick . join('`,`', doSlash($columns)) . $tick;
$rs = safe_rows($cols, $table, (empty($columns) ? '1=1' : $columns[0] . ' not like \'%.min%\'') . (empty($columns) ? '' : ' ORDER BY `' . $columns[0] . '`'));
$rows = array();
foreach ($rs as $a) {
// Enforce *nix new-lines
$a = str_replace("\r\n", "\n", $a);
// Literal backslash into corresponding MySQL literal
foreach ($a as &$v) {
$v = addcslashes(addcslashes($v, '\\'), '\\');
}
$a = "'" . join("', '", doSlash($a)) . "'";
$rows[] = self::$where . ' = "INSERT INTO `".PFX."' . $table . '`(' . $cols . ') VALUES(' . $a . ')";';
}
$f = preg_replace("#(// sql:{$table}).*(// /sql:{$table})#s", '$1' . n . join(n, $rows) . n . '$2', $f);
}
echo text_area('code', 600, '', $f, 'code');
echo script_js(<<<EOS
\t\t\$('#code').focus(function() {
\t\t\tthis.select();
\t\t});
EOS
);
}
示例4: html_head
function html_head()
{
$js = <<<SF
\t\t\t\$(document).ready( function() {
\t\t\t\t\$("#nav li").hover( function() { \$(this).addClass("sfhover"); }, function() { \$(this).removeClass("sfhover"); } );
\t\t\t});
SF;
return parent::html_head() . n . script_js($js) . n;
}
示例5: plugin_list
function plugin_list($message = '')
{
global $event;
pagetop(gTxt('tab_plugins'), $message);
echo '<h1 class="txp-heading">' . gTxt('tab_plugins') . '</h1>';
echo '<div id="' . $event . '_control" class="txp-control-panel">';
echo n . plugin_form() . n . '</div>';
extract(gpsa(array('sort', 'dir')));
if ($sort === '') {
$sort = get_pref('plugin_sort_column', 'name');
}
if ($dir === '') {
$dir = get_pref('plugin_sort_dir', 'asc');
}
$dir = $dir == 'desc' ? 'desc' : 'asc';
if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) {
$sort = 'name';
}
$sort_sql = $sort . ' ' . $dir;
set_pref('plugin_sort_column', $sort, 'plugin', 2, '', 0, PREF_PRIVATE);
set_pref('plugin_sort_dir', $dir, 'plugin', 2, '', 0, PREF_PRIVATE);
$switch_dir = $dir == 'desc' ? 'asc' : 'desc';
$rs = safe_rows_start('name, status, author, author_uri, version, description, length(help) as help, abs(strcmp(md5(code),code_md5)) as modified, load_order, flags', 'txp_plugin', '1 order by ' . $sort_sql);
if ($rs and numRows($rs) > 0) {
echo n . '<div id="' . $event . '_container" class="txp-container">';
echo '<form action="index.php" id="plugin_form" class="multi_edit_form" method="post" name="longform">' . n . '<div class="txp-listtables">' . n . startTable('', '', 'txp-list') . n . '<thead>' . tr(n . hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' title="' . gTxt('toggle_all_selected') . '" class="multi-edit"') . n . column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'name') . n . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', ('author' == $sort ? "{$dir} " : '') . 'author') . n . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', ('version' == $sort ? "{$dir} " : '') . 'version') . n . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', ('modified' == $sort ? "{$dir} " : '') . 'modified') . n . hCell(gTxt('description'), '', ' class="description"') . n . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', ('status' == $sort ? "{$dir} " : '') . 'status') . n . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', ('load_order' == $sort ? "{$dir} " : '') . 'load-order') . n . hCell(gTxt('manage'), '', ' class="manage actions"')) . n . '</thead>';
echo '<tbody>';
while ($a = nextRow($rs)) {
foreach ($a as $key => $value) {
${$key} = txpspecialchars($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 class="plugin-help" href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . urlencode($name) . '">' . gTxt('help') . '</a>' : '';
$plugin_prefs = $flags & PLUGIN_HAS_PREFS ? '<a class="plugin-prefs" href="?event=plugin_prefs.' . urlencode($name) . '">' . gTxt('plugin_prefs') . '</a>' : '';
$manage = array();
if ($help) {
$manage[] = $help;
}
if ($plugin_prefs) {
$manage[] = $plugin_prefs;
}
$manage_items = $manage ? join(tag(sp . '|' . sp, 'span'), $manage) : '-';
$edit_url = eLink('plugin', 'plugin_edit', 'name', $name, $name);
echo tr(n . td(fInput('checkbox', 'selected[]', $name), '', 'multi-edit') . td($edit_url, '', 'name') . td(href($author, $author_uri, ' rel="external"'), '', 'author') . td($version, '', 'version') . td($modified ? '<span class="warning">' . gTxt('yes') . '</span>' : '', '', 'modified') . td($description, '', 'description') . td(status_link($status, $name, yes_no($status)), '', 'status') . td($load_order, '', 'load-order') . td($manage_items, '', 'manage'), $status ? ' class="active"' : '');
unset($name, $page, $deletelink);
}
echo '</tbody>', n, endTable(), n, '</div>', n, plugin_multiedit_form('', $sort, $dir, '', ''), n, tInput(), n, '</form>', n, '</div>';
// Show/hide "Options" link by setting the appropriate class on the plugins TR
echo script_js(<<<EOS
textpattern.Relay.register('txpAsyncHref.success', function(event, data) {
\t\$(data['this']).closest('tr').toggleClass('active');
});
EOS
);
}
}
示例6: cat_category_list
function cat_category_list($message = "")
{
pagetop(gTxt('categories'), $message);
$out = array('<h1 class="txp-heading">' . gTxt('tab_organise') . '</h1>', '<div id="category_container" class="txp-container">', '<table class="category-list">', '<tr>', tdtl('<div id="categories_article">' . cat_article_list() . '</div>', ' class="categories article"'), tdtl('<div id="categories_link">' . cat_link_list() . '</div>', ' class="categories link"'), tdtl('<div id="categories_image">' . cat_image_list() . '</div>', ' class="categories image"'), tdtl('<div id="categories_file">' . cat_file_list() . '</div>', ' class="categories file"'), '</tr>', endTable(), '</div>', script_js(<<<EOS
\t\t\t\$(document).ready(function() {
\t\t\t\t\$('.category-tree').txpMultiEditForm({
\t\t\t\t\t'row' : 'p',
\t\t\t\t\t'highlighted' : 'p'
\t\t\t\t});
\t\t\t});
EOS
));
echo join(n, $out);
}
示例7: cat_category_list
/**
* Outputs the main panel listing all categories.
*
* @param string|array $message The activity message
*/
function cat_category_list($message = "")
{
pagetop(gTxt('categories'), $message);
$out = array(hed(gTxt('tab_organise'), 1, 'class="txp-heading"'), n . tag(cat_article_list(), 'section', array('class' => 'txp-layout-4col-cell-1', 'id' => 'categories_article')), n . tag(cat_image_list(), 'section', array('class' => 'txp-layout-4col-cell-2', 'id' => 'categories_image')), n . tag(cat_file_list(), 'section', array('class' => 'txp-layout-4col-cell-3', 'id' => 'categories_file')), n . tag(cat_link_list(), 'section', array('class' => 'txp-layout-4col-cell-4', 'id' => 'categories_link')), script_js(<<<EOS
\$(document).ready(function ()
{
\$('.category-tree').txpMultiEditForm({
'row' : 'p',
'highlighted' : 'p'
});
});
EOS
));
echo join(n, $out);
}
示例8: cat_category_list
/**
* Outputs the main panel listing all categories.
*
* @param string|array $message The activity message
*/
function cat_category_list($message = "")
{
pagetop(gTxt('categories'), $message);
$out = array(hed(gTxt('tab_organise'), 1, 'class="txp-heading"'), '<div id="category_container" class="txp-layout-grid">', n . tag(n . tag(cat_article_list(), 'div', array('class' => 'categories')), 'div', array('id' => 'categories_article', 'class' => 'txp-layout-cell txp-layout-1-4')), n . tag(n . tag(cat_image_list(), 'div', array('class' => 'categories')), 'div', array('id' => 'categories_image', 'class' => 'txp-layout-cell txp-layout-1-4')), n . tag(n . tag(cat_file_list(), 'div', array('class' => 'categories')), 'div', array('id' => 'categories_file', 'class' => 'txp-layout-cell txp-layout-1-4')), n . tag(n . tag(cat_link_list(), 'div', array('class' => 'categories')), 'div', array('id' => 'categories_link', 'class' => 'txp-layout-cell txp-layout-1-4')), '</div>', script_js(<<<EOS
\$(document).ready(function ()
{
\$('.category-tree').txpMultiEditForm({
'row' : 'p',
'highlighted' : 'p'
});
});
EOS
));
echo join(n, $out);
}
示例9: form_list
function form_list($curname)
{
global $step, $essential_forms, $form_types;
$types = formTypes('', false);
$methods = array('changetype' => array('label' => gTxt('changetype'), 'html' => $types), 'delete' => gTxt('delete'));
$out[] = '<p class="action-create">' . sLink('form', 'form_create', gTxt('create_new_form')) . '</p>';
$criteria = 1;
$criteria .= callback_event('admin_criteria', 'form_list', 0, $criteria);
$rs = safe_rows_start("*", "txp_form", "{$criteria} order by field(type,'" . join("','", array_keys($form_types)) . "') asc, name asc");
if ($rs) {
$ctr = 1;
$prev_type = '';
while ($a = nextRow($rs)) {
extract($a);
$editlink = $curname != $name ? eLink('form', 'form_edit', 'name', $name, $name) : txpspecialchars($name);
$modbox = !in_array($name, $essential_forms) ? '<input type="checkbox" name="selected_forms[]" value="' . $name . '" />' : '';
if ($prev_type != $type) {
$visipref = 'pane_form_' . $type . '_visible';
$group_start = '<div class="form-list-group ' . $type . '"><h3 class="lever' . (get_pref($visipref) ? ' expanded' : '') . '"><a href="#' . $type . '">' . $form_types[$type] . '</a></h3>' . n . '<div id="' . $type . '" class="toggle form-list" style="display:' . (get_pref($visipref) ? 'block' : 'none') . '">' . n . '<ul class="plain-list">' . n;
$group_end = $ctr > 1 ? '</ul></div></div>' . n : '';
} else {
$group_start = $group_end = '';
}
$out[] = $group_end . $group_start;
$out[] = '<li>' . n . '<span class="form-list-action">' . $modbox . '</span><span class="form-list-name">' . $editlink . '</span></li>';
$prev_type = $type;
$ctr++;
}
$out[] = '</ul></div></div>';
$out[] = multi_edit($methods, 'form', 'form_multi_edit');
return form(join('', $out), '', '', 'post', '', '', 'allforms_form') . script_js(<<<EOS
\t\t\t\t\$(document).ready(function() {
\t\t\t\t\t\$('#allforms_form').txpMultiEditForm({
\t\t\t\t\t\t'checkbox' : 'input[name="selected_forms[]"][type=checkbox]',
\t\t\t\t\t\t'row' : '.plain-list li, .form-list-name',
\t\t\t\t\t\t'highlighted' : '.plain-list li'
\t\t\t\t\t});
\t\t\t\t});
EOS
);
}
}
示例10: pagetop
function pagetop($pagetitle, $message = "")
{
global $siteurl, $sitename, $txp_user, $event, $step, $app_mode, $theme;
if ($app_mode == 'async') {
return;
}
$area = gps('area');
$event = !$event ? 'article' : $event;
$bm = gps('bm');
$privs = safe_field("privs", "txp_users", "name = '" . doSlash($txp_user) . "'");
$GLOBALS['privs'] = $privs;
$areas = areas();
$area = false;
foreach ($areas as $k => $v) {
if (in_array($event, $v)) {
$area = $k;
break;
}
}
if (gps('logout')) {
$body_id = 'page-logout';
} elseif (!$txp_user) {
$body_id = 'page-login';
} else {
$body_id = 'page-' . htmlspecialchars($event);
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php
echo LANG;
?>
" lang="<?php
echo LANG;
?>
" dir="<?php
echo gTxt('lang_dir');
?>
">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<title>Txp › <?php
echo htmlspecialchars($sitename);
?>
› <?php
echo escape_title($pagetitle);
?>
</title>
<script src="jquery.js" type="text/javascript"></script>
<?php
echo script_js('var textpattern = {event: "' . htmlspecialchars($event) . '", step: "' . htmlspecialchars($step) . '"};');
?>
<script type="text/javascript" src="textpattern.js"></script>
<script type="text/javascript">
<!--
var cookieEnabled = checkCookies();
if (!cookieEnabled)
{
confirm('<?php
echo trim(gTxt('cookies_must_be_enabled'));
?>
');
}
<?php
$edit = array();
if ($event == 'list') {
$rs = safe_column('name', 'txp_section', "name != 'default'");
$edit['section'] = $rs ? selectInput('Section', $rs, '', true) : '';
$rs = getTree('root', 'article');
$edit['category1'] = $rs ? treeSelectInput('Category1', $rs, '') : '';
$edit['category2'] = $rs ? treeSelectInput('Category2', $rs, '') : '';
$edit['comments'] = onoffRadio('Annotate', safe_field('val', 'txp_prefs', "name = 'comments_on_default'"));
$edit['status'] = selectInput('Status', array(1 => gTxt('draft'), 2 => gTxt('hidden'), 3 => gTxt('pending'), 4 => gTxt('live'), 5 => gTxt('sticky')), '', true);
$rs = safe_column('name', 'txp_users', "privs not in(0,6) order by name asc");
$edit['author'] = $rs ? selectInput('AuthorID', $rs, '', true) : '';
}
if (in_array($event, array('image', 'file', 'link'))) {
$rs = getTree('root', $event);
$edit['category'] = $rs ? treeSelectInput('category', $rs, '') : '';
$rs = safe_column('name', 'txp_users', "privs not in(0,6) order by name asc");
$edit['author'] = $rs ? selectInput('author', $rs, '', true) : '';
}
if ($event == 'plugin') {
$edit['order'] = selectInput('order', array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9), 5, false);
}
if ($event == 'admin') {
$edit['privilege'] = privs();
$rs = safe_column('name', 'txp_users', '1=1');
$edit_assign_assets = $rs ? selectInput('assign_assets', $rs, '', true) : '';
}
// output JavaScript
?>
function poweredit(elm)
{
var something = elm.options[elm.selectedIndex].value;
// Add another chunk of HTML
//.........这里部分代码省略.........
示例11: is_dst
/**
* Renders a HTML choice for whether Daylight Savings Time is in effect.
*
* Can be altered by plugins via the 'prefs_ui > is_dst'
* pluggable UI callback event.
*
* @param string $name HTML name of the widget
* @param string $val Initial (or current) selected item
* @return string HTML
*/
function is_dst($name, $val)
{
$ui = yesnoRadio($name, $val) . script_js(<<<EOS
\$(document).ready(function ()
{
var radio = \$("#prefs-is_dst input");
if (radio) {
if (\$("#auto_dst-1").prop("checked")) {
radio.prop("disabled", "disabled");
}
\$("#auto_dst-0").click(function () {
radio.removeProp("disabled");
});
\$("#auto_dst-1").click(function () {
radio.prop("disabled", "disabled");
});
}
});
EOS
);
return pluggable_ui('prefs_ui', 'is_dst', $ui, $name, $val);
}
示例12: pagetop
function pagetop($pagetitle, $message = "")
{
global $siteurl, $sitename, $txp_user, $event, $step, $app_mode, $theme;
if ($app_mode == 'async') {
return;
}
$area = gps('area');
$event = !$event ? 'article' : $event;
$bm = gps('bm');
$privs = safe_field("privs", "txp_users", "name = '" . doSlash($txp_user) . "'");
$GLOBALS['privs'] = $privs;
$areas = areas();
$area = false;
foreach ($areas as $k => $v) {
if (in_array($event, $v)) {
$area = $k;
break;
}
}
if (gps('logout')) {
$body_id = 'page-logout';
} elseif (!$txp_user) {
$body_id = 'page-login';
} else {
$body_id = 'page-' . txpspecialchars($event);
}
header('X-Frame-Options: ' . X_FRAME_OPTIONS);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php
echo LANG;
?>
" lang="<?php
echo LANG;
?>
" dir="<?php
echo txpspecialchars(gTxt('lang_dir'));
?>
">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<title><?php
echo escape_title($pagetitle);
?>
- <?php
echo txpspecialchars($sitename);
?>
| Textpattern CMS</title>
<script type="text/javascript" src="jquery.js"></script>
<?php
echo script_js('var textpattern = {
event: "' . txpspecialchars($event) . '",
step: "' . txpspecialchars($step) . '",
_txp_token: "' . txpspecialchars(form_token()) . '",
ajax_timeout: ' . txpspecialchars(AJAX_TIMEOUT) . ',
ajaxally_challenged: ' . (AJAXALLY_CHALLENGED ? 'true' : 'false') . ',
textarray: {},
do_spellcheck: "' . txpspecialchars(get_pref('do_spellcheck', '#page-article #body, #page-article #title,' . '#page-image #alt-text, #page-image #caption,' . '#page-file #description,' . '#page-link #link-title, #page-link #link-description')) . '"};');
gTxtScript(array('form_submission_error', 'are_you_sure'));
?>
<script type="text/javascript" src="textpattern.js"></script>
<script type="text/javascript">
<!--
var cookieEnabled = checkCookies();
if (!cookieEnabled)
{
confirm('<?php
echo trim(gTxt('cookies_must_be_enabled'));
?>
');
}
function poweredit(elm)
{
var something = elm.options[elm.selectedIndex].value;
// Add another chunk of HTML
var pjs = document.getElementById('js');
if (pjs == null)
{
var br = document.createElement('br');
elm.parentNode.appendChild(br);
pjs = document.createElement('P');
pjs.setAttribute('id','js');
elm.parentNode.appendChild(pjs);
}
if (pjs.style.display == 'none' || pjs.style.display == '')
{
pjs.style.display = 'block';
}
if (something != '')
{
switch (something)
{
//.........这里部分代码省略.........
示例13: doLoginForm
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);
}
示例14: renderForm
/**
* Renders an admin-side search form.
*
* @param string $step Textpattern Step for the form submission
* @param array $options Options
* @return string HTML
*/
public function renderForm($step, $options = array())
{
static $id_counter = 0;
$event = $this->event;
$methods = $this->getMethods();
$selected = $this->search_method;
extract(lAtts(array('default_method' => 'all', 'submit_as' => 'get', 'placeholder' => '', 'label_all' => 'search_all', 'class' => ''), (array) $options));
$selected = $selected ? $selected : $default_method;
$submit_as = in_array($submit_as, array('get', 'post')) ? $submit_as : 'get';
if (!is_array($selected)) {
$selected = do_list($selected);
}
$set_all = count($selected) === 1 && $selected[0] === 'all' || count($selected) === count($methods);
if ($label_all) {
$methods = array('all' => gTxt($label_all)) + $methods;
}
$method_list = array();
foreach ($methods as $key => $value) {
$name = $key === 'all' ? 'select_all' : 'search_method[]';
$method_list[] = tag(checkbox($name, $key, $set_all || in_array($key, $selected), 0, 'search-' . $key . $id_counter) . n . tag($value, 'label', array('for' => 'search-' . $key . $id_counter)) . n, 'li');
}
$button_set = n . '<button class="txp-search-button">' . gTxt('search') . '</button>';
if (count($method_list) > 1) {
$button_set .= n . '<button class="txp-search-options">' . gTxt('search_options') . '</button>' . n;
}
$buttons = n . tag($button_set, 'span', array('class' => 'txp-search-buttons')) . n;
// So the search can be used multiple times on a page without id clashes.
$id_counter++;
// TODO: consider moving Route.add() to textpattern.js, but that involves adding one
// call per panel that requires search, instead of auto-adding it when invoked here.
return form(fInput('search', 'crit', $this->crit, 'txp-search-input', '', '', 24, 0, '', false, false, gTxt($placeholder)) . eInput($event) . sInput($step) . $buttons . n . tag(join(n, $method_list), 'ul', array('class' => 'txp-dropdown')), '', '', $submit_as, 'txp-search' . ($class ? ' ' . $class : ''), '', '', 'search') . script_js(<<<EOJS
textpattern.Route.add('{$event}', txp_search);
EOJS
);
}
示例15: article_edit
//.........这里部分代码省略.........
echo n . graf(href(gtxt('create_new'), 'index.php?event=article'));
}
//-- prev/next article links --
if ($step != 'create' and ($prev_id or $next_id)) {
echo '<p>', $prev_id ? prevnext_link('‹' . gTxt('prev'), 'article', 'edit', $prev_id, gTxt('prev')) : '', $next_id ? prevnext_link(gTxt('next') . '›', 'article', 'edit', $next_id, gTxt('next')) : '', '</p>';
}
//-- status radios --------------
echo pluggable_ui('article_ui', 'status', n . n . '<fieldset id="write-status">' . n . '<legend>' . gTxt('status') . '</legend>' . n . status_radio($Status) . n . '</fieldset>', $rs);
//-- category selects -----------
echo pluggable_ui('article_ui', 'categories', n . n . '<fieldset id="write-sort">' . n . '<legend>' . gTxt('sort_display') . '</legend>' . n . graf('<label for="category-1">' . gTxt('category1') . '</label> ' . '<span class="small">[' . eLink('category', '', '', '', gTxt('edit')) . ']</span>' . br . n . category_popup('Category1', $Category1, 'category-1')) . n . graf('<label for="category-2">' . gTxt('category2') . '</label>' . br . n . category_popup('Category2', $Category2, 'category-2')), $rs);
//-- section select --------------
if (!$from_view && !$pull) {
$Section = getDefaultSection();
}
echo pluggable_ui('article_ui', 'section', n . graf('<label for="section">' . gTxt('section') . '</label> ' . '<span class="small">[' . eLink('section', '', '', '', gTxt('edit')) . ']</span>' . br . section_popup($Section, 'section')) . n . '</fieldset>', $rs);
//-- "More" section
echo n . n . '<h3 class="plain lever' . (get_pref('pane_article_more_visible') ? ' expanded' : '') . '"><a href="#more">' . gTxt('more') . '</a></h3>', '<div id="more" class="toggle" style="display:' . (get_pref('pane_article_more_visible') ? 'block' : 'none') . '">';
//-- comments stuff --------------
if ($step == "create") {
//Avoiding invite disappear when previewing
$AnnotateInvite = !empty($store_out['AnnotateInvite']) ? $store_out['AnnotateInvite'] : $comments_default_invite;
if ($comments_on_default == 1) {
$Annotate = 1;
}
}
if ($use_comments == 1) {
$invite[] = n . n . '<fieldset id="write-comments">' . n . '<legend>' . gTxt('comments') . '</legend>';
$comments_expired = false;
if ($step != 'create' && $comments_disabled_after) {
$lifespan = $comments_disabled_after * 86400;
$time_since = time() - $sPosted;
if ($time_since > $lifespan) {
$comments_expired = true;
}
}
if ($comments_expired) {
$invite[] = n . n . graf(gTxt('expired'));
} else {
$invite[] = n . n . graf(onoffRadio('Annotate', $Annotate)) . n . n . graf('<label for="comment-invite">' . gTxt('comment_invitation') . '</label>' . br . fInput('text', 'AnnotateInvite', $AnnotateInvite, 'edit', '', '', '', '', 'comment-invite'));
}
$invite[] = n . n . '</fieldset>';
echo pluggable_ui('article_ui', 'annotate_invite', join('', $invite), $rs);
}
if ($step == "create" and empty($GLOBALS['ID'])) {
//-- timestamp -------------------
//Avoiding modified date to disappear
$persist_timestamp = !empty($store_out['year']) ? safe_strtotime($store_out['year'] . '-' . $store_out['month'] . '-' . $store_out['day'] . ' ' . $store_out['hour'] . ':' . $store_out['minute'] . ':' . $store_out['second']) : time();
echo pluggable_ui('article_ui', 'timestamp', n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('publish_now', '1', $publish_now, '', 'publish_now') . '<label for="publish_now">' . gTxt('set_to_now') . '</label>') . n . graf(gTxt('or_publish_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $persist_timestamp) . ' / ' . tsi('month', '%m', $persist_timestamp) . ' / ' . tsi('day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $persist_timestamp) . ' : ' . tsi('minute', '%M', $persist_timestamp) . ' : ' . tsi('second', '%S', $persist_timestamp)) . n . '</fieldset>', array('sPosted' => $persist_timestamp) + $rs);
//-- expires -------------------
$persist_timestamp = !empty($store_out['exp_year']) ? safe_strtotime($store_out['exp_year'] . '-' . $store_out['exp_month'] . '-' . $store_out['exp_day'] . ' ' . $store_out['exp_hour'] . ':' . $store_out['exp_minute'] . ':' . $store_out['second']) : NULLDATETIME;
echo pluggable_ui('article_ui', 'expires', n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $persist_timestamp) . ' / ' . tsi('exp_month', '%m', $persist_timestamp) . ' / ' . tsi('exp_day', '%d', $persist_timestamp)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $persist_timestamp) . ' : ' . tsi('exp_minute', '%M', $persist_timestamp) . ' : ' . tsi('exp_second', '%S', $persist_timestamp)) . n . '</fieldset>', $rs);
// end "More" section
echo n . n . '</div>';
//-- publish button --------------
echo has_privs('article.publish') ? fInput('submit', 'publish', gTxt('publish'), "publish", '', '', '', 4) : fInput('submit', 'publish', gTxt('save'), "publish", '', '', '', 4);
} else {
//-- timestamp -------------------
if (!empty($year)) {
$sPosted = safe_strtotime($year . '-' . $month . '-' . $day . ' ' . $hour . ':' . $minute . ':' . $second);
}
echo pluggable_ui('article_ui', 'timestamp', n . n . '<fieldset id="write-timestamp">' . n . '<legend>' . gTxt('timestamp') . '</legend>' . n . graf(checkbox('reset_time', '1', $reset_time, '', 'reset_time') . '<label for="reset_time">' . gTxt('reset_time') . '</label>') . n . graf(gTxt('published_at') . sp . popHelp('timestamp')) . n . graf(gtxt('date') . sp . tsi('year', '%Y', $sPosted) . ' / ' . tsi('month', '%m', $sPosted) . ' / ' . tsi('day', '%d', $sPosted)) . n . graf(gTxt('time') . sp . tsi('hour', '%H', $sPosted) . ' : ' . tsi('minute', '%M', $sPosted) . ' : ' . tsi('second', '%S', $sPosted)) . n . hInput('sPosted', $sPosted) . n . hInput('sLastMod', $sLastMod) . n . hInput('AuthorID', $AuthorID) . n . hInput('LastModID', $LastModID) . n . '</fieldset>', $rs);
//-- expires -------------------
if (!empty($exp_year)) {
if (empty($exp_month)) {
$exp_month = 1;
}
if (empty($exp_day)) {
$exp_day = 1;
}
if (empty($exp_hour)) {
$exp_hour = 0;
}
if (empty($exp_minute)) {
$exp_minute = 0;
}
if (empty($exp_second)) {
$exp_second = 0;
}
$sExpires = safe_strtotime($exp_year . '-' . $exp_month . '-' . $exp_day . ' ' . $exp_hour . ':' . $exp_minute . ':' . $exp_second);
}
echo pluggable_ui('article_ui', 'expires', n . n . '<fieldset id="write-expires">' . n . '<legend>' . gTxt('expires') . '</legend>' . n . graf(gtxt('date') . sp . tsi('exp_year', '%Y', $sExpires) . ' / ' . tsi('exp_month', '%m', $sExpires) . ' / ' . tsi('exp_day', '%d', $sExpires)) . n . graf(gTxt('time') . sp . tsi('exp_hour', '%H', $sExpires) . ' : ' . tsi('exp_minute', '%M', $sExpires) . ' : ' . tsi('exp_second', '%S', $sExpires)) . n . hInput('sExpires', $sExpires) . n . '</fieldset>', $rs);
// end "More" section
echo n . n . '</div>';
//-- save button --------------
if ($Status >= 4 and has_privs('article.edit.published') or $Status >= 4 and $AuthorID == $txp_user and has_privs('article.edit.own.published') or $Status < 4 and has_privs('article.edit') or $Status < 4 and $AuthorID == $txp_user and has_privs('article.edit.own')) {
echo fInput('submit', 'save', gTxt('save'), "publish", '', '', '', 4);
}
}
}
echo '</td></tr></table></form>' . n;
// Assume users would not change the timestamp if they wanted to "publish now"/"reset time"
echo script_js(<<<EOS
\t\t\$('#write-timestamp input.edit').change(
\t\t\tfunction() {
\t\t\t\t\$('#publish_now').attr('checked', false);
\t\t\t\t\$('#reset_time').attr('checked', false);
\t\t\t});
EOS
);
}