本文整理汇总了PHP中do_list函数的典型用法代码示例。如果您正苦于以下问题:PHP do_list函数的具体用法?PHP do_list怎么用?PHP do_list使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了do_list函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: file_download_list
function file_download_list($atts)
{
global $thisfile;
extract(lAtts(array('break' => br, 'category' => '', 'class' => __FUNCTION__, 'form' => 'files', 'label' => '', 'labeltag' => '', 'limit' => '10', 'offset' => '0', 'sort' => 'filename asc', 'wraptag' => '', 'status' => '4'), $atts));
if (!is_numeric($status)) {
$status = getStatusNum($status);
}
$where = array('1=1');
if ($category) {
$where[] = "category IN ('" . join("','", doSlash(do_list($category))) . "')";
}
if ($status) {
$where[] = "status = '" . doSlash($status) . "'";
}
$qparts = array('order by ' . doSlash($sort), $limit ? 'limit ' . intval($offset) . ', ' . intval($limit) : '');
$rs = safe_rows_start('*, unix_timestamp(created) as created, unix_timestamp(modified) as modified', 'txp_file', join(' and ', $where) . ' ' . join(' ', $qparts));
if ($rs) {
$out = array();
while ($thisfile = nextRow($rs)) {
$out[] = parse_form($form);
$thisfile = '';
}
if ($out) {
if ($wraptag == 'ul' or $wraptag == 'ol') {
return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class);
}
return $wraptag ? tag(join($break, $out), $wraptag) : join(n, $out);
}
}
return '';
}
示例2: __construct
/**
* Constructor.
*
* Creates core Textfilters according to a preference and registers all
* available filters with the core.
*
* This method triggers 'textfilter.register' callback
* event.
*/
public function __construct()
{
if ($filters = get_pref('admin_textfilter_classes')) {
foreach (do_list($filters) as $filter) {
new $filter();
}
} else {
new Plain();
new Nl2Br();
new Textile();
}
$this->filters = array();
callback_event('textfilter', 'register', 0, $this);
}
示例3: logit
/**
* Writes a record to the visitor log using the current visitor's information.
*
* This function is used by log_hit(). See it before trying to use this one.
*
* The hit is ignore if $r is set to 'refer' and the HTTP REFERER header is empty.
*
* @param string $r Type of record to write, e.g. refer
* @param int $status HTTP status code
* @access private
* @see log_hit()
*/
function logit($r = '', $status = 200)
{
global $prefs, $pretext;
if (!isset($pretext['request_uri'])) {
return;
}
$host = $ip = (string) remote_addr();
$protocol = false;
$referer = serverSet('HTTP_REFERER');
if ($referer) {
foreach (do_list(LOG_REFERER_PROTOCOLS) as $option) {
if (strpos($referer, $option . '://') === 0) {
$protocol = $option;
$referer = substr($referer, strlen($protocol) + 3);
break;
}
}
if (!$protocol || $protocol === 'https' && PROTOCOL !== 'https://') {
$referer = '';
} elseif (preg_match('/^[^\\.]*\\.?' . preg_quote(preg_replace('/^www\\./', '', SITE_HOST), '/') . '/i', $referer)) {
$referer = '';
} else {
$referer = $protocol . '://' . clean_url($referer);
}
}
if ($r == 'refer' && !$referer) {
return;
}
if (!empty($prefs['use_dns'])) {
// A crude rDNS cache.
if (($h = safe_field('host', 'txp_log', "ip='" . doSlash($ip) . "' limit 1")) !== false) {
$host = $h;
} else {
// Double-check the rDNS.
$host = @gethostbyaddr($ip);
if ($host !== $ip && @gethostbyname($host) !== $ip) {
$host = $ip;
}
}
}
insert_logit(array('uri' => $pretext['request_uri'], 'ip' => $ip, 'host' => $host, 'status' => $status, 'method' => serverSet('REQUEST_METHOD'), 'ref' => $referer));
}
示例4: renderAuthors
/**
* Generates a list of authors.
*
* @param array $atts
* @param string $thing
* @return string
*/
public static function renderAuthors($atts, $thing = null)
{
global $thisauthor, $txp_groups;
extract(lAtts(array('break' => '', 'class' => '', 'form' => '', 'group' => '', 'label' => '', 'labeltag' => '', 'limit' => '', 'name' => '', 'offset' => '', 'sort' => 'name ASC', 'wraptag' => ''), $atts));
$sql = array('1 = 1');
$sql_limit = '';
$sql_sort = " ORDER BY " . doSlash($sort);
if ($name) {
$sql[] = "name IN (" . join(', ', quote_list(do_list($name))) . ")";
}
if ($group !== '') {
$privs = do_list($group);
$groups = array_flip($txp_groups);
foreach ($privs as &$priv) {
if (isset($groups[$priv])) {
$priv = $groups[$priv];
}
}
$sql[] = 'convert(privs, char) in (' . join(', ', quote_list($privs)) . ')';
}
if ($limit !== '' || $offset) {
$sql_limit = " LIMIT " . intval($offset) . ", " . ($limit === '' ? PHP_INT_MAX : intval($limit));
}
$rs = safe_rows_start("user_id as id, name, RealName as realname, email, privs, last_access", 'txp_users', join(" AND ", $sql) . " {$sql_sort} {$sql_limit}");
if ($rs && numRows($rs)) {
$out = array();
if ($thing === null && $form !== '') {
$thing = fetch_form($form);
}
while ($a = nextRow($rs)) {
$oldauthor = $thisauthor;
$thisauthor = $a;
$out[] = parse($thing);
$thisauthor = $oldauthor;
}
unset($thisauthor);
return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class);
}
return '';
}
示例5: getNeighbour
/**
* Find an adjacent article relative to a provided threshold level
*
* @param scalar $threshold The value to compare against
* @param string $s string Optional section restriction
* @param string $type string Find lesser or greater neighbour? Possible values: '<' (previous, default) or '>' (next)
* @param array $atts Attribute of article at threshold
* @param string $threshold_type 'cooked': Use $threshold as SQL clause; 'raw': Use $threshold as an escapable scalar
* @return array|string An array populated with article data, or the empty string in case of no matches
*/
function getNeighbour($threshold, $s, $type, $atts = array(), $threshold_type = 'raw')
{
global $prefs;
static $cache = array();
$key = md5($threshold . $s . $type . join(n, $atts));
if (isset($cache[$key])) {
return $cache[$key];
}
extract($atts);
$expired = $expired && $prefs['publish_expired_articles'];
$customFields = getCustomFields();
//Building query parts
// lifted from publish.php. This is somewhat embarrassing, isn't it?
$ids = array_map('intval', do_list($id));
$id = !$id ? '' : " and ID IN (" . join(',', $ids) . ")";
switch ($time) {
case 'any':
$time = "";
break;
case 'future':
$time = " and Posted > now()";
break;
default:
$time = " and Posted <= now()";
}
if (!$expired) {
$time .= " and (now() <= Expires or Expires = " . NULLDATETIME . ")";
}
$custom = '';
if ($customFields) {
foreach ($customFields as $cField) {
if (isset($atts[$cField])) {
$customPairs[$cField] = $atts[$cField];
}
}
if (!empty($customPairs)) {
$custom = buildCustomSql($customFields, $customPairs);
}
}
if ($keywords) {
$keys = doSlash(do_list($keywords));
foreach ($keys as $key) {
$keyparts[] = "FIND_IN_SET('" . $key . "',Keywords)";
}
$keywords = " and (" . join(' or ', $keyparts) . ")";
}
// invert $type for ascending sortdir
$types = array('>' => array('desc' => '>', 'asc' => '<'), '<' => array('desc' => '<', 'asc' => '>'));
$type = $type == '>' ? $types['>'][$sortdir] : $types['<'][$sortdir];
// escape threshold and treat it as a string unless explicitly told otherwise
if ($threshold_type != 'cooked') {
$threshold = "'" . doSlash($threshold) . "'";
}
$safe_name = safe_pfx('textpattern');
$q = array("select ID, Title, url_title, unix_timestamp(Posted) as uposted\n\t\t\tfrom " . $safe_name . " where {$sortby} {$type} " . $threshold, $s != '' && $s != 'default' ? "and Section = '" . doSlash($s) . "'" : filterFrontPage(), $id, $time, $custom, $keywords, 'and Status=4', 'order by ' . $sortby, $type == '<' ? 'desc' : 'asc', 'limit 1');
$cache[$key] = getRow(join(n . ' ', $q));
return is_array($cache[$key]) ? $cache[$key] : '';
}
示例6: sed_lib_home_or_section
function sed_lib_home_or_section($atts, $thing)
{
extract(lAtts(array('sectlist' => ''), $atts, 0));
global $pretext;
$do_thing = $pretext['s'] == "default" && empty($pretext['c']) && empty($pretext['q']) && empty($pretext['pg']);
if (!$do_thing && !empty($sectlist)) {
$sectlist = do_list($sectlist);
$do_thing = in_array($pretext['s'], $sectlist);
}
return parse(EvalElse($thing, $do_thing));
}
示例7: link_list
function link_list($message = '')
{
global $step, $link_list_pageby;
extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
$dir = $dir == 'desc' ? 'desc' : 'asc';
switch ($sort) {
case 'id':
$sort_sql = 'id ' . $dir;
break;
case 'description':
$sort_sql = 'description ' . $dir . ', id asc';
break;
case 'category':
$sort_sql = 'category ' . $dir . ', id asc';
break;
case 'date':
$sort_sql = 'date ' . $dir . ', id asc';
break;
default:
$sort = 'name';
$sort_sql = 'linksort ' . $dir . ', id asc';
break;
}
$switch_dir = $dir == 'desc' ? 'asc' : 'desc';
$criteria = 1;
if ($search_method and $crit) {
$crit_escaped = doSlash($crit);
$critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "linkname like '%{$crit_escaped}%'", 'description' => "description like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'");
if (array_key_exists($search_method, $critsql)) {
$criteria = $critsql[$search_method];
} else {
$search_method = '';
$crit = '';
}
} else {
$search_method = '';
$crit = '';
}
$total = getCount('txp_link', $criteria);
if ($total < 1) {
if ($criteria != 1) {
echo n . link_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"');
} else {
echo n . graf(gTxt('no_links_recorded'), ' class="indicator"');
}
return;
}
$limit = max($link_list_pageby, 15);
list($page, $offset, $numPages) = pager($total, $limit, $page);
echo link_search_form($crit, $search_method);
$rs = safe_rows_start('*, unix_timestamp(date) as uDate', 'txp_link', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
if ($rs) {
echo n . n . '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">', startTable('list') . n . tr(column_head('ID', 'id', 'link', true, $switch_dir, $crit, $search_method, 'id' == $sort ? $dir : '') . hCell() . column_head('link_name', 'name', 'link', true, $switch_dir, $crit, $search_method, 'name' == $sort ? $dir : '') . column_head('description', 'description', 'link', true, $switch_dir, $crit, $search_method, 'description' == $sort ? $dir : '') . column_head('link_category', 'category', 'link', true, $switch_dir, $crit, $search_method, 'category' == $sort ? $dir : '') . column_head('date', 'date', 'link', true, $switch_dir, $crit, $search_method, 'date' == $sort ? $dir : '') . hCell());
while ($a = nextRow($rs)) {
extract($a);
$edit_url = '?event=link' . a . 'step=link_edit' . a . 'id=' . $id . a . 'sort=' . $sort . a . 'dir=' . $dir . a . 'page=' . $page . a . 'search_method=' . $search_method . a . 'crit=' . $crit;
echo tr(n . td($id, 20) . td(n . '<ul>' . n . t . '<li>' . href(gTxt('edit'), $edit_url) . '</li>' . n . t . '<li>' . href(gTxt('view'), $url) . '</li>' . n . '</ul>', 35) . td(href(htmlspecialchars($linkname), $edit_url), 125) . td(htmlspecialchars($description), 150) . td('<span title="' . htmlspecialchars(fetch_category_title($category, 'link')) . '">' . $category . '</span>', 125) . td(gTime($uDate), 75) . td(fInput('checkbox', 'selected[]', $id)));
}
echo n . n . tr(tda(select_buttons() . link_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="7" style="text-align: right; border: none;"')) . endTable() . '</form>' . n . nav_form('link', $page, $numPages, $sort, $dir, $crit, $search_method, $total, $limit) . pageby_form('link', $link_list_pageby);
}
}
示例8: file_list
function file_list($message = '')
{
global $txpcfg, $extensions, $file_base_path, $file_statuses, $file_list_pageby;
pagetop(gTxt('file'), $message);
extract($txpcfg);
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 '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:
$sort = 'filename';
$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 in ('" . join("','", do_list($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'), ' class="indicator"');
} else {
echo n . graf(gTxt('no_files_recorded'), ' class="indicator"');
}
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 '<form name="longform" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list') . tr(column_head('ID', 'id', 'file', true, $switch_dir, $crit, $search_method, 'id' == $sort ? $dir : '') . hCell() . column_head('file_name', 'filename', 'file', true, $switch_dir, $crit, $search_method, 'filename' == $sort ? $dir : '') . column_head('description', 'description', 'file', true, $switch_dir, $crit, $search_method, 'description' == $sort ? $dir : '') . column_head('file_category', 'category', 'file', true, $switch_dir, $crit, $search_method, 'category' == $sort ? $dir : '') . hCell(gTxt('tags')) . hCell(gTxt('status')) . hCell(gTxt('condition')) . column_head('downloads', 'downloads', 'file', true, $switch_dir, $crit, $search_method, 'downloads' == $sort ? $dir : '') . 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, '', $filename) . '</li>' : '';
$category = $category ? '<span title="' . htmlspecialchars(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);
$condition = '<span class="';
$condition .= $file_exists ? 'ok' : 'not-ok';
$condition .= '">';
$condition .= $file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing');
$condition .= '</span>';
echo tr(n . td($id) . td('<ul>' . '<li>' . href(gTxt('edit'), $edit_url) . '</li>' . $download_link . '</ul>', 65) . td(href(htmlspecialchars($filename), $edit_url), 125) . td(htmlspecialchars($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($file_statuses[$status], 45) . td($condition, 45) . td($downloads == '0' ? gTxt('none') : $downloads, 25) . td(fInput('checkbox', 'selected[]', $id), 10));
}
echo tr(tda(select_buttons() . file_multiedit_form($page, $sort, $dir, $crit, $search_method), ' colspan="10" style="text-align: right; border: none;"')) . endTable() . '</form>' . nav_form('file', $page, $numPages, $sort, $dir, $crit, $search_method) . pageby_form('file', $file_list_pageby);
}
}
示例9: show_form
show_form('edit');
break;
case 'doedit':
do_update('edit');
break;
case 'doupdate':
do_update();
break;
case 'dodelete':
do_delete();
break;
case 'list':
view_list();
break;
case 'dolist':
do_list();
break;
case 'editrep':
show_form_rep('edit');
break;
case 'doeditrep':
do_edit_rep();
break;
case 'dodelrep':
do_delete_rep();
break;
default:
show_level();
break;
}
function show_level()
示例10: image_list
function image_list($message = '')
{
global $txpcfg, $extensions, $img_dir, $file_max_upload_size, $image_list_pageby, $txp_user, $event;
pagetop(gTxt('tab_image'), $message);
extract($txpcfg);
extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
if ($sort === '') {
$sort = get_pref('image_sort_column', 'id');
}
if ($dir === '') {
$dir = get_pref('image_sort_dir', 'desc');
}
$dir = $dir == 'asc' ? 'asc' : 'desc';
echo hed(gTxt('tab_image'), 1, array('class' => 'txp-heading'));
echo n . '<div id="' . $event . '_control" class="txp-control-panel">';
if (!is_dir(IMPATH) or !is_writeable(IMPATH)) {
echo graf(span(null, array('class' => 'ui-icon ui-icon-alert')) . ' ' . gTxt('img_dir_not_writeable', array('{imgdir}' => IMPATH)), array('class' => 'alert-block warning'));
} elseif (has_privs('image.edit.own')) {
echo upload_form(gTxt('upload_image'), 'upload_image', 'image_insert', 'image', '', $file_max_upload_size);
}
switch ($sort) {
case 'name':
$sort_sql = 'name ' . $dir;
break;
case 'thumbnail':
$sort_sql = 'thumbnail ' . $dir . ', id asc';
break;
case 'category':
$sort_sql = 'category ' . $dir . ', id asc';
break;
case 'date':
$sort_sql = 'date ' . $dir . ', id asc';
break;
case 'author':
$sort_sql = 'author ' . $dir . ', id asc';
break;
default:
$sort = 'id';
$sort_sql = 'id ' . $dir;
break;
}
set_pref('image_sort_column', $sort, 'image', 2, '', 0, PREF_PRIVATE);
set_pref('image_sort_dir', $dir, 'image', 2, '', 0, PREF_PRIVATE);
$switch_dir = $dir == 'desc' ? 'asc' : 'desc';
$criteria = 1;
if ($search_method and $crit != '') {
$verbatim = preg_match('/^"(.*)"$/', $crit, $m);
$crit_escaped = $verbatim ? doSlash($m[1]) : doLike($crit);
$critsql = $verbatim ? array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "name = '{$crit_escaped}'", 'category' => "category = '{$crit_escaped}'", 'author' => "author = '{$crit_escaped}'", 'alt' => "alt = '{$crit_escaped}'", 'caption' => "caption = '{$crit_escaped}'") : array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "name like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'", 'author' => "author like '%{$crit_escaped}%'", 'alt' => "alt like '%{$crit_escaped}%'", 'caption' => "caption like '%{$crit_escaped}%'");
if (array_key_exists($search_method, $critsql)) {
$criteria = $critsql[$search_method];
$limit = 500;
} else {
$search_method = '';
$crit = '';
}
} else {
$search_method = '';
$crit = '';
}
$criteria .= callback_event('admin_criteria', 'image_list', 0, $criteria);
$total = safe_count('txp_image', "{$criteria}");
if ($total < 1) {
if ($criteria != 1) {
echo n . image_search_form($crit, $search_method) . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>';
} else {
echo graf(gTxt('no_images_recorded'), ' class="indicator"') . '</div>';
}
return;
}
$limit = max($image_list_pageby, 15);
list($page, $offset, $numPages) = pager($total, $limit, $page);
echo image_search_form($crit, $search_method);
$rs = safe_rows_start('*, unix_timestamp(date) as uDate', 'txp_image', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}\n ");
echo pluggable_ui('image_ui', 'extend_controls', '', $rs);
echo '</div>';
// End txp-control-panel.
if ($rs) {
$show_authors = !has_single_author('txp_image');
echo n . tag_start('div', array('id' => $event . '_container', 'class' => 'txp-container')) . n . tag_start('form', array('action' => 'index.php', 'id' => 'images_form', 'class' => 'multi_edit_form', 'method' => 'post', 'name' => 'longform')) . n . tag_start('div', array('class' => 'txp-listtables')) . n . tag_start('table', array('class' => 'txp-list')) . n . tag_start('thead') . tr(hCell(fInput('checkbox', 'select_all', 0, '', '', '', '', '', 'select_all'), '', ' scope="col" title="' . gTxt('toggle_all_selected') . '" class="txp-list-col-multi-edit"') . column_head('ID', 'id', 'image', true, $switch_dir, $crit, $search_method, ('id' == $sort ? "{$dir} " : '') . 'txp-list-col-id') . column_head('name', 'name', 'image', true, $switch_dir, $crit, $search_method, ('name' == $sort ? "{$dir} " : '') . 'txp-list-col-name') . column_head('date', 'date', 'image', true, $switch_dir, $crit, $search_method, ('date' == $sort ? "{$dir} " : '') . 'txp-list-col-created date images_detail') . column_head('thumbnail', 'thumbnail', 'image', true, $switch_dir, $crit, $search_method, ('thumbnail' == $sort ? "{$dir} " : '') . 'txp-list-col-thumbnail') . hCell(gTxt('tags'), '', ' scope="col" class="txp-list-col-tag-build images_detail"') . column_head('image_category', 'category', 'image', true, $switch_dir, $crit, $search_method, ('category' == $sort ? "{$dir} " : '') . 'txp-list-col-category category') . ($show_authors ? column_head('author', 'author', 'image', true, $switch_dir, $crit, $search_method, ('author' == $sort ? "{$dir} " : '') . 'txp-list-col-author name') : '')) . n . tag_end('thead') . n . tag_start('tbody');
$validator = new Validator();
while ($a = nextRow($rs)) {
extract($a);
$edit_url = array('event' => 'image', 'step' => 'image_edit', 'id' => $id, 'sort' => $sort, 'dir' => $dir, 'page' => $page, 'search_method' => $search_method, 'crit' => $crit);
$name = empty($name) ? gTxt('unnamed') : txpspecialchars($name);
if ($thumbnail) {
if ($ext != '.swf') {
$thumbnail = '<img class="content-image" src="' . imagesrcurl($id, $ext, true) . "?{$uDate}" . '" alt="" ' . "title='{$id}{$ext} ({$w} × {$h})'" . ($thumb_w ? " width='{$thumb_w}' height='{$thumb_h}'" : '') . ' />';
} else {
$thumbnail = '';
}
} else {
$thumbnail = gTxt('no');
}
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 = href('Textile', $tag_url . a . 'type=textile', ' target="_blank" onclick="popWin(this.href); return false;"') . sp . span('|', array('role' => 'separator')) . sp . href('Textpattern', $tag_url . a . 'type=textpattern', ' target="_blank" onclick="popWin(this.href); return false;"') . sp . span('|', array('role' => 'separator')) . sp . href('HTML', $tag_url . a . 'type=html', ' target="_blank" onclick="popWin(this.href); return false;"');
} else {
$tagbuilder = sp;
}
//.........这里部分代码省略.........
示例11: getMetaDescription
/**
* Fetch meta description from the given (or automatic) context.
*
* Category context may be refined by specifying the content type as well
* after a dot. e.g. category.image to check image context category.
*
* @param string $type Flavour of meta content to fetch (section, category, article)
*/
function getMetaDescription($type = null)
{
global $thisarticle, $thiscategory, $thissection, $c, $s, $context;
$content = '';
if ($type === null) {
if ($thiscategory) {
$content = $thiscategory['description'];
} elseif ($thissection) {
$content = $thissection['description'];
} elseif ($thisarticle) {
$content = $thisarticle['description'];
} elseif ($c) {
$content = safe_field('description', 'txp_category', "name = '" . doSlash($c) . "' AND type = '" . doSlash($context) . "'");
} elseif ($s) {
$content = safe_field('description', 'txp_section', "name = '" . doSlash($s) . "'");
}
} else {
if (strpos($type, 'category') === 0) {
// Category context.
if ($thiscategory) {
$content = $thiscategory['description'];
} else {
$thisContext = $context;
$catParts = do_list($type, '.');
if (isset($catParts[1])) {
$thisContext = $catParts[1];
}
$clause = " AND type = '" . $thisContext . "'";
$content = safe_field('description', 'txp_category', "name = '" . doSlash($c) . "'" . $clause);
}
} elseif ($type === 'section') {
$theSection = $thissection ? $thissection : $s;
$content = safe_field('description', 'txp_section', "name = '" . doSlash($theSection) . "'");
} elseif ($type === 'article') {
assert_article();
$content = $thisarticle ? $thisarticle['description'] : '';
}
}
return $content;
}
示例12: image_list
function image_list($message = '')
{
global $txpcfg, $extensions, $img_dir, $file_max_upload_size, $image_list_pageby, $txp_user, $event;
pagetop(gTxt('images'), $message);
extract($txpcfg);
extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
if ($sort === '') {
$sort = get_pref('image_sort_column', 'id');
}
if ($dir === '') {
$dir = get_pref('image_sort_dir', 'desc');
}
$dir = $dir == 'asc' ? 'asc' : 'desc';
echo '<div id="' . $event . '_control" class="txp-control-panel">';
if (!is_dir(IMPATH) or !is_writeable(IMPATH)) {
echo graf(gTxt('img_dir_not_writeable', array('{imgdir}' => IMPATH)), ' id="warning"');
} elseif (has_privs('image.edit.own')) {
echo upload_form(gTxt('upload_image'), 'upload_image', 'image_insert', 'image', '', $file_max_upload_size);
}
switch ($sort) {
case 'name':
$sort_sql = 'name ' . $dir;
break;
case 'thumbnail':
$sort_sql = 'thumbnail ' . $dir . ', id asc';
break;
case 'category':
$sort_sql = 'category ' . $dir . ', id asc';
break;
case 'date':
$sort_sql = 'date ' . $dir . ', id asc';
break;
case 'author':
$sort_sql = 'author ' . $dir . ', id asc';
break;
default:
$sort = 'id';
$sort_sql = 'id ' . $dir;
break;
}
set_pref('image_sort_column', $sort, 'image', 2, '', 0, PREF_PRIVATE);
set_pref('image_sort_dir', $dir, 'image', 2, '', 0, PREF_PRIVATE);
$switch_dir = $dir == 'desc' ? 'asc' : 'desc';
$criteria = 1;
if ($search_method and $crit) {
$crit_escaped = doSlash(str_replace(array('\\', '%', '_', '\''), array('\\\\', '\\%', '\\_', '\\\''), $crit));
$critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'name' => "name like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'", 'author' => "author like '%{$crit_escaped}%'", 'alt' => "alt like '%{$crit_escaped}%'", 'caption' => "caption 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_image', "{$criteria}");
if ($total < 1) {
if ($criteria != 1) {
echo n . image_search_form($crit, $search_method) . n . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>';
} else {
echo n . graf(gTxt('no_images_recorded'), ' class="indicator"') . '</div>';
}
return;
}
$limit = max($image_list_pageby, 15);
list($page, $offset, $numPages) = pager($total, $limit, $page);
echo image_search_form($crit, $search_method);
$rs = safe_rows_start('*, unix_timestamp(date) as uDate', 'txp_image', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}\n\t\t");
echo pluggable_ui('image_ui', 'extend_controls', '', $rs);
echo '</div>';
// end txp-control-panel
if ($rs) {
$show_authors = !has_single_author('txp_image');
echo n . '<div id="' . $event . '_container" class="txp-container txp-list">';
echo n . n . '<form name="longform" id="images_form" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . n . n . startTable('list', '', 'list') . n . '<thead>' . n . tr(column_head('ID', 'id', 'image', true, $switch_dir, $crit, $search_method, ('id' == $sort ? "{$dir} " : '') . 'id') . hCell('', '', ' class="actions"') . column_head('date', 'date', 'image', true, $switch_dir, $crit, $search_method, ('date' == $sort ? "{$dir} " : '') . 'date created') . column_head('name', 'name', 'image', true, $switch_dir, $crit, $search_method, ('name' == $sort ? "{$dir} " : '') . 'name') . column_head('thumbnail', 'thumbnail', 'image', true, $switch_dir, $crit, $search_method, ('thumbnail' == $sort ? "{$dir} " : '') . 'thumbnail') . hCell(gTxt('tags'), '', ' class="tag-build"') . column_head('image_category', 'category', 'image', true, $switch_dir, $crit, $search_method, ('category' == $sort ? "{$dir} " : '') . 'category') . ($show_authors ? column_head('author', 'author', 'image', true, $switch_dir, $crit, $search_method, ('author' == $sort ? "{$dir} " : '') . 'author') : '') . hCell('', '', ' class="multi-edit"')) . n . '</thead>';
$tfoot = n . '<tfoot>' . tr(tda(select_buttons() . image_multiedit_form($page, $sort, $dir, $crit, $search_method), ' class="multi-edit" colspan="' . ($show_authors ? '9' : '8') . '" style="text-align: right; border: none;"')) . n . '</tfoot>';
echo $tfoot;
echo '<tbody>';
$ctr = 1;
while ($a = nextRow($rs)) {
extract($a);
$edit_url = '?event=image' . a . 'step=image_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="' . imagesrcurl($id, $ext, true) . "?{$uDate}" . '" alt="" ' . "title='{$id}{$ext} ({$w} × {$h})'" . ($thumb_w ? "width='{$thumb_w}' height='{$thumb_h}'" : '') . ' />';
} else {
$thumbnail = '';
}
} else {
$thumbnail = gTxt('no');
}
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;
//.........这里部分代码省略.........
示例13: file_list
function file_list($message = '')
{
global $file_base_path, $file_statuses, $file_list_pageby, $txp_user, $event;
pagetop(gTxt('file'), $message);
extract(gpsa(array('page', 'sort', 'dir', 'crit', 'search_method')));
if ($sort === '') {
$sort = get_pref('file_sort_column', 'filename');
}
if ($dir === '') {
$dir = get_pref('file_sort_dir', 'asc');
}
$dir = $dir == 'desc' ? 'desc' : 'asc';
echo '<div id="' . $event . '_control" class="txp-control-panel">';
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"');
} elseif (has_privs('file.edit.own')) {
$existing_files = get_filenames();
if (count($existing_files) > 0) {
echo form(eInput('file') . sInput('file_create') . graf('<label for="file-existing">' . gTxt('existing_file') . '</label>' . sp . selectInput('filename', $existing_files, '', 1, '', 'file-existing') . sp . fInput('submit', '', gTxt('Create'), 'smallerbox'), ' class="existing-file"'), 'text-align: center;', '', 'post', '', '', 'assign_file');
}
echo file_upload_form(gTxt('upload_file'), 'upload', 'file_insert');
}
switch ($sort) {
case 'id':
$sort_sql = 'id ' . $dir;
break;
case 'description':
$sort_sql = 'description ' . $dir . ', filename desc';
break;
case 'category':
$sort_sql = 'category ' . $dir . ', filename desc';
break;
case 'title':
$sort_sql = 'title ' . $dir . ', filename desc';
break;
case 'downloads':
$sort_sql = 'downloads ' . $dir . ', filename desc';
break;
case 'author':
$sort_sql = 'author ' . $dir . ', id asc';
break;
default:
$sort = 'filename';
$sort_sql = 'filename ' . $dir;
break;
}
set_pref('file_sort_column', $sort, 'file', 2, '', 0, PREF_PRIVATE);
set_pref('file_sort_dir', $dir, 'file', 2, '', 0, PREF_PRIVATE);
$switch_dir = $dir == 'desc' ? 'asc' : 'desc';
$criteria = 1;
if ($search_method and $crit) {
$crit_escaped = doSlash(str_replace(array('\\', '%', '_', '\''), array('\\\\', '\\%', '\\_', '\\\''), $crit));
$critsql = array('id' => "ID in ('" . join("','", do_list($crit_escaped)) . "')", 'filename' => "filename like '%{$crit_escaped}%'", 'title' => "title like '%{$crit_escaped}%'", 'description' => "description like '%{$crit_escaped}%'", 'category' => "category like '%{$crit_escaped}%'", 'author' => "author 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'), ' class="indicator"') . '</div>';
} else {
echo n . graf(gTxt('no_files_recorded'), ' class="indicator"') . '</div>';
}
return;
}
$limit = max($file_list_pageby, 15);
list($page, $offset, $numPages) = pager($total, $limit, $page);
echo file_search_form($crit, $search_method) . '</div>';
$rs = safe_rows_start('*', 'txp_file', "{$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
if ($rs) {
$show_authors = !has_single_author('txp_file');
echo n . '<div id="' . $event . '_container" class="txp-container txp-list">';
echo '<form name="longform" id="files_form" method="post" action="index.php" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list', '', 'list') . n . '<thead>' . tr(column_head('ID', 'id', 'file', true, $switch_dir, $crit, $search_method, ('id' == $sort ? "{$dir} " : '') . 'id') . hCell('', '', ' class="actions"') . column_head('file_name', 'filename', 'file', true, $switch_dir, $crit, $search_method, ('filename' == $sort ? "{$dir} " : '') . 'name') . column_head('title', 'title', 'file', true, $switch_dir, $crit, $search_method, ('title' == $sort ? "{$dir} " : '') . 'title') . column_head('description', 'description', 'file', true, $switch_dir, $crit, $search_method, ('description' == $sort ? "{$dir} " : '') . 'description') . column_head('file_category', 'category', 'file', true, $switch_dir, $crit, $search_method, ('category' == $sort ? "{$dir} " : '') . 'category') . hCell(gTxt('tags'), '', ' class="tag-build"') . hCell(gTxt('status'), '', ' class="status"') . hCell(gTxt('condition'), '', ' class="condition"') . column_head('downloads', 'downloads', 'file', true, $switch_dir, $crit, $search_method, ('downloads' == $sort ? "{$dir} " : '') . 'downloads') . ($show_authors ? column_head('author', 'author', 'file', true, $switch_dir, $crit, $search_method, ('author' == $sort ? "{$dir} " : '') . 'author') : '') . hCell('', '', ' class="multi-edit"')) . n . '</thead>';
$tfoot = n . '<tfoot>' . tr(tda(select_buttons() . file_multiedit_form($page, $sort, $dir, $crit, $search_method), ' class="multi-edit" colspan="' . ($show_authors ? '12' : '11') . '" style="text-align: right; border: none;"')) . n . '</tfoot>';
echo $tfoot;
echo '<tbody>';
$ctr = 1;
while ($a = nextRow($rs)) {
extract($a);
$filename = sanitizeForFile($filename);
$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 class="action-view">' . make_download_link($id, '', $filename) . '</li>' : '';
$category = $category ? '<span title="' . htmlspecialchars(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);
$condition = '<span class="';
$condition .= $file_exists ? 'ok' : 'not-ok';
$condition .= '">';
$condition .= $file_exists ? gTxt('file_status_ok') : gTxt('file_status_missing');
$condition .= '</span>';
$can_edit = has_privs('file.edit') || $author == $txp_user && has_privs('file.edit.own');
echo tr(n . td($id, '', 'id') . td('<ul>' . ($can_edit ? '<li class="action-edit">' . href(gTxt('edit'), $edit_url) . '</li>' : '') . $download_link . '</ul>', 65, 'actions') . td($can_edit ? href(htmlspecialchars($filename), $edit_url) : htmlspecialchars($filename), 125, 'name') . td(htmlspecialchars($title), 90, 'title') . td(htmlspecialchars($description), 150, 'description') . td($category, 90, 'category') . 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, 'tag-build') . td(in_array($status, array_keys($file_statuses)) ? $file_statuses[$status] : '<span class="not-ok">' . gTxt('none') . '</span>', 45, 'status') . td($condition, 45, 'condition') . td($downloads == '0' ? gTxt('none') : $downloads, 25, 'downloads') . ($show_authors ? td('<span title="' . htmlspecialchars(get_author_name($author)) . '">' . htmlspecialchars($author) . '</span>', '', 'author') : '') . td($can_edit ? fInput('checkbox', 'selected[]', $id) : ' ', 10, 'multi-edit'), ' class="' . ($ctr % 2 == 0 ? 'even' : 'odd') . '"');
//.........这里部分代码省略.........
示例14: adi_menu_section_list
function adi_menu_section_list($ignore_exclude)
{
global $sections, $exclude, $sort, $default_first, $default_title, $include_default;
if ($sections) {
$sections = do_list($sections);
$sections = join("','", doSlash($sections));
$rs = safe_rows_start('name,title,adi_menu_parent,adi_menu_clone,adi_menu_title', 'txp_section', "name in ('{$sections}') order by " . ($sort ? $sort : "field(name, '{$sections}')"));
} else {
if ($exclude) {
$exclude = do_list($exclude);
$exclude = join("','", doSlash($exclude));
$exclude = "and name not in('{$exclude}')";
}
if (!$include_default) {
$exclude = "and name != 'default'";
}
$ignore_exclude ? $exclude_option = "adi_menu_exclude = 0 or adi_menu_exclude = 1" : ($exclude_option = "adi_menu_exclude = 0");
$rs = safe_rows_start('name,title,adi_menu_parent,adi_menu_clone,adi_menu_title', 'txp_section', "{$exclude_option} {$exclude} order by " . $sort);
}
if ($rs) {
$out = array();
while ($a = nextRow($rs)) {
extract($a);
// sets 'name','title','adi_menu_parent' etc in $a
$a['url'] = pagelinkurl(array('s' => $name));
// add url to $a
$out[$name] = $a;
}
if ($out && $default_title && $include_default) {
// set default section title
$out['default']['title'] = $default_title;
}
if ($out && $default_first && $include_default) {
// shift default section to beginning
$remember['default'] = $out['default'];
// remember 'default' element
unset($out['default']);
// remove 'default' element
$out = array_merge($remember, $out);
// join together, 'default' now at beginning
}
return $out;
}
}
示例15: file_download_list
function file_download_list($atts, $thing = NULL)
{
global $s, $c, $context, $thisfile, $thispage, $pretext;
extract(lAtts(array('break' => br, 'category' => '', 'author' => '', 'realname' => '', 'auto_detect' => 'category, author', 'class' => __FUNCTION__, 'form' => 'files', 'id' => '', 'label' => '', 'labeltag' => '', 'pageby' => '', 'limit' => 10, 'offset' => 0, 'sort' => 'filename asc', 'wraptag' => '', 'status' => '4'), $atts));
if (!is_numeric($status)) {
$status = getStatusNum($status);
}
// N.B. status treated slightly differently
$where = $statwhere = array();
$filters = isset($atts['id']) || isset($atts['category']) || isset($atts['author']) || isset($atts['realname']) || isset($atts['status']);
$context_list = empty($auto_detect) || $filters ? array() : do_list($auto_detect);
$pageby = $pageby == 'limit' ? $limit : $pageby;
if ($category) {
$where[] = "category IN ('" . join("','", doSlash(do_list($category))) . "')";
}
$ids = array_map('intval', do_list($id));
if ($id) {
$where[] = "id IN ('" . join("','", $ids) . "')";
}
if ($status) {
$statwhere[] = "status = '" . doSlash($status) . "'";
}
if ($author) {
$where[] = "author IN ('" . join("','", doSlash(do_list($author))) . "')";
}
if ($realname) {
$authorlist = safe_column('name', 'txp_users', "RealName IN ('" . join("','", doArray(doSlash(do_list($realname)), 'urldecode')) . "')");
$where[] = "author IN ('" . join("','", doSlash($authorlist)) . "')";
}
// If no files are selected, try...
if (!$where && !$filters) {
foreach ($context_list as $ctxt) {
switch ($ctxt) {
case 'category':
// ... the global category in the URL
if ($context == 'file' && !empty($c)) {
$where[] = "category = '" . doSlash($c) . "'";
}
break;
case 'author':
// ... the global author in the URL
if ($context == 'file' && !empty($pretext['author'])) {
$where[] = "author = '" . doSlash($pretext['author']) . "'";
}
break;
}
// Only one context can be processed
if ($where) {
break;
}
}
}
if (!$where && !$statwhere && $filters) {
return '';
// If nothing matches, output nothing
}
if (!$where) {
$where[] = "1=1";
// If nothing matches, start with all files
}
$where = join(' AND ', array_merge($where, $statwhere));
// Set up paging if required
if ($limit && $pageby) {
$grand_total = safe_count('txp_file', $where);
$total = $grand_total - $offset;
$numPages = $pageby > 0 ? ceil($total / $pageby) : 1;
$pg = !$pretext['pg'] ? 1 : $pretext['pg'];
$pgoffset = $offset + ($pg - 1) * $pageby;
// send paging info to txp:newer and txp:older
$pageout['pg'] = $pg;
$pageout['numPages'] = $numPages;
$pageout['s'] = $s;
$pageout['c'] = $c;
$pageout['context'] = 'file';
$pageout['grand_total'] = $grand_total;
$pageout['total'] = $total;
if (empty($thispage)) {
$thispage = $pageout;
}
} else {
$pgoffset = $offset;
}
// preserve order of custom file ids unless 'sort' attribute is set
if (!empty($atts['id']) && empty($atts['sort'])) {
$safe_sort = 'field(id, ' . join(',', $ids) . ')';
} else {
$safe_sort = doSlash($sort);
}
$qparts = array('order by ' . $safe_sort, $limit ? 'limit ' . intval($pgoffset) . ', ' . intval($limit) : '');
$rs = safe_rows_start('*', 'txp_file', $where . ' ' . join(' ', $qparts));
if ($rs) {
$out = array();
while ($a = nextRow($rs)) {
$thisfile = file_download_format_info($a);
$out[] = $thing ? parse($thing) : parse_form($form);
$thisfile = '';
}
if ($out) {
return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class);
}
//.........这里部分代码省略.........