当前位置: 首页>>代码示例>>PHP>>正文


PHP numRows函数代码示例

本文整理汇总了PHP中numRows函数的典型用法代码示例。如果您正苦于以下问题:PHP numRows函数的具体用法?PHP numRows怎么用?PHP numRows使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了numRows函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: plugin_list

function plugin_list($message = '')
{
    pagetop(gTxt('edit_plugins'), $message);
    echo n . n . startTable('edit') . tr(tda(plugin_form(), ' colspan="8" style="height: 30px; border: none;"')) . endTable();
    extract(gpsa(array('sort', 'dir')));
    $dir = $dir == 'desc' ? 'desc' : 'asc';
    if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) {
        $sort = 'name';
    }
    $sort_sql = $sort . ' ' . $dir;
    $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 '<form action="index.php" method="post" name="longform" onsubmit="return verify(\'' . gTxt('are_you_sure') . '\')">' . startTable('list') . tr(column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', 'name' == $sort ? $dir : '') . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', 'author' == $sort ? $dir : '') . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', 'version' == $sort ? $dir : '') . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', 'modified' == $sort ? $dir : '') . hCell(gTxt('description')) . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', 'status' == $sort ? $dir : '') . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', 'load_order' == $sort ? $dir : '') . hCell(gTxt('manage'), '', ' class="manage"') . hCell());
        while ($a = nextRow($rs)) {
            foreach ($a as $key => $value) {
                ${$key} = htmlspecialchars($value);
            }
            // Fix up the description for clean cases
            $description = preg_replace(array('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), array('<br />', '<$1>', '<a href="$1$2">'), $description);
            $help = !empty($help) ? n . t . '<li><a href="?event=plugin' . a . 'step=plugin_help' . a . 'name=' . urlencode($name) . '">' . gTxt('help') . '</a></li>' : '';
            $plugin_prefs = $flags & PLUGIN_HAS_PREFS && $status ? n . t . '<li><a href="?event=plugin_prefs.' . urlencode($name) . '">' . gTxt('plugin_prefs') . '</a></li>' : '';
            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($load_order) . td(n . '<ul class="plugin_manage">' . $help . n . t . '<li>' . eLink('plugin', 'plugin_edit', 'name', $name, gTxt('edit')) . '</li>' . $plugin_prefs . n . '</ul>') . td(fInput('checkbox', 'selected[]', $name), 30));
            unset($name, $page, $deletelink);
        }
        echo tr(tda(select_buttons() . plugin_multiedit_form('', $sort, $dir, '', ''), ' colspan="10" style="text-align: right; border: none;"')) . n . endTable() . n . '</form>';
    }
}
开发者ID:joebushi,项目名称:textpattern,代码行数:28,代码来源:txp_plugin.php

示例2: userExist

function userExist($qry)
{
    $run = Run($qry);
    if ($run) {
        return numRows($run);
    } else {
        return '1';
    }
}
开发者ID:rohini01,项目名称:-MicroHealthLLC-iphone,代码行数:9,代码来源:comfunction.php

示例3: 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('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), 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 . '&#124;' . 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
);
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:57,代码来源:txp_plugin.php

示例4: plugin_list

/**
 * The main panel listing all installed plugins.
 *
 * @param string|array $message The activity message
 */
function plugin_list($message = '')
{
    global $event;
    pagetop(gTxt('tab_plugins'), $message);
    extract(gpsa(array('sort', 'dir')));
    if ($sort === '') {
        $sort = get_pref('plugin_sort_column', 'name');
    } else {
        if (!in_array($sort, array('name', 'status', 'author', 'version', 'modified', 'load_order'))) {
            $sort = 'name';
        }
        set_pref('plugin_sort_column', $sort, 'plugin', 2, '', 0, PREF_PRIVATE);
    }
    if ($dir === '') {
        $dir = get_pref('plugin_sort_dir', 'asc');
    } else {
        $dir = $dir == 'desc' ? "desc" : "asc";
        set_pref('plugin_sort_dir', $dir, 'plugin', 2, '', 0, PREF_PRIVATE);
    }
    $sort_sql = "{$sort} {$dir}";
    $switch_dir = $dir == 'desc' ? 'asc' : 'desc';
    echo n . tag(hed(gTxt('tab_plugins'), 1, array('class' => 'txp-heading')), 'div', array('class' => 'txp-layout-2col-cell-1')) . n . tag_start('div', array('class' => 'txp-layout-1col', 'id' => $event . '_container')) . n . tag(plugin_form(), 'div', array('class' => 'txp-control-panel'));
    $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 = 1 ORDER BY {$sort_sql}");
    if ($rs and numRows($rs) > 0) {
        echo n . tag_start('form', array('class' => 'multi_edit_form', 'id' => 'plugin_form', 'name' => 'longform', 'method' => 'post', 'action' => 'index.php')) . 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'), '', ' class="txp-list-col-multi-edit" scope="col" title="' . gTxt('toggle_all_selected') . '"') . column_head('plugin', 'name', 'plugin', true, $switch_dir, '', '', ('name' == $sort ? "{$dir} " : '') . 'txp-list-col-name') . column_head('author', 'author', 'plugin', true, $switch_dir, '', '', ('author' == $sort ? "{$dir} " : '') . 'txp-list-col-author') . column_head('version', 'version', 'plugin', true, $switch_dir, '', '', ('version' == $sort ? "{$dir} " : '') . 'txp-list-col-version') . column_head('plugin_modified', 'modified', 'plugin', true, $switch_dir, '', '', ('modified' == $sort ? "{$dir} " : '') . 'txp-list-col-modified') . hCell(gTxt('description'), '', ' class="txp-list-col-description" scope="col"') . column_head('active', 'status', 'plugin', true, $switch_dir, '', '', ('status' == $sort ? "{$dir} " : '') . 'txp-list-col-status') . column_head('order', 'load_order', 'plugin', true, $switch_dir, '', '', ('load_order' == $sort ? "{$dir} " : '') . 'txp-list-col-load-order') . hCell(gTxt('manage'), '', ' class="txp-list-col-manage" scope="col"')) . n . tag_end('thead') . n . tag_start('tbody');
        while ($a = nextRow($rs)) {
            foreach ($a as $key => $value) {
                ${$key} = txpspecialchars($value);
            }
            // Fix up the description for clean cases.
            $description = preg_replace(array('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), array('<br />', '<$1>', '<a href="$1$2">'), $description);
            if (!empty($help)) {
                $help = href(gTxt('help'), array('event' => 'plugin', 'step' => 'plugin_help', 'name' => $name), array('class' => 'plugin-help'));
            }
            if ($flags & PLUGIN_HAS_PREFS) {
                $plugin_prefs = href(gTxt('plugin_prefs'), array('event' => 'plugin_prefs.' . $name), array('class' => 'plugin-prefs'));
            } else {
                $plugin_prefs = '';
            }
            $manage = array();
            if ($help) {
                $manage[] = $help;
            }
            if ($plugin_prefs) {
                $manage[] = $plugin_prefs;
            }
            $manage_items = $manage ? join(tag(sp . '&#124;' . sp, 'span'), $manage) : '-';
            $edit_url = eLink('plugin', 'plugin_edit', 'name', $name, $name);
            echo tr(td(fInput('checkbox', 'selected[]', $name), '', 'txp-list-col-multi-edit') . hCell($edit_url, '', ' class="txp-list-col-name" scope="row"') . td(href($author, $a['author_uri'], array('rel' => 'external')), '', 'txp-list-col-author') . td($version, '', 'txp-list-col-version') . td($modified ? span(gTxt('yes'), array('class' => 'warning')) : '', '', 'txp-list-col-modified') . td($description, '', 'txp-list-col-description') . td(status_link($status, $name, yes_no($status)), '', 'txp-list-col-status') . td($load_order, '', 'txp-list-col-load-order') . td($manage_items, '', 'txp-list-col-manage'), $status ? ' class="active"' : '');
            unset($name, $page, $deletelink);
        }
        echo n . tag_end('tbody') . n . tag_end('table') . n . tag_end('div') . plugin_multiedit_form('', $sort, $dir, '', '') . tInput() . n . tag_end('form');
    }
    echo n . tag_end('div');
}
开发者ID:ClaireBrione,项目名称:textpattern,代码行数:60,代码来源:txp_plugin.php

示例5: get

 /**
  * Get the translation for all languages
  *
  * @param  string    $code 'Code for the text to be translated'
  * @return array  'Translated text'
  */
 public function get($code)
 {
     $sql = "SELECT * FROM lang WHERE code='{$code}'";
     $query = $this->db->query($sql);
     if (numRows($query) > 0) {
         $row = $query->row();
         return (array) $row;
     } else {
         return FALSE;
     }
 }
开发者ID:robotamer,项目名称:oldstuff,代码行数:17,代码来源:Translate.php

示例6: 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 '';
 }
开发者ID:ClaireBrione,项目名称:textpattern,代码行数:47,代码来源:Authors.php

示例7: plugin_list

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('#&lt;br /&gt;#', '#&lt;(/?(a|b|i|em|strong))&gt;#', '#&lt;a href=&quot;(https?|\\.|\\/|ftp)([A-Za-z0-9:/?.=_]+?)&quot;&gt;#'), 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();
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:22,代码来源:txp_plugin.php

示例8: article_partial_recent_articles

/**
 * Renders &lt;ol&gt; list of recent articles.
 *
 * The rendered widget can be customised via the 'article_ui > recent_articles'
 * pluggable UI callback event.
 *
 * @param  array $rs Article data
 * @return string HTML
 */
function article_partial_recent_articles($rs)
{
    $recents = safe_rows_start("Title, ID", 'textpattern', "1 = 1 ORDER BY LastMod DESC LIMIT " . (int) WRITE_RECENT_ARTICLES_COUNT);
    $ra = '';
    if ($recents && numRows($recents)) {
        $ra = '<ol class="recent">';
        while ($recent = nextRow($recents)) {
            if ($recent['Title'] === '') {
                $recent['Title'] = gTxt('untitled') . sp . $recent['ID'];
            }
            $ra .= n . '<li class="recent-article">' . href(escape_title($recent['Title']), '?event=article' . a . 'step=edit' . a . 'ID=' . $recent['ID']) . '</li>';
        }
        $ra .= '</ol>';
    }
    return pluggable_ui('article_ui', 'recent_articles', $ra, $rs);
}
开发者ID:ClaireBrione,项目名称:textpattern,代码行数:25,代码来源:txp_article.php

示例9: doArticles


//.........这里部分代码省略.........
    $section = !$section ? '' : " and Section IN ('" . join("','", doSlash(do_list($section))) . "')";
    $excerpted = $excerpted == 'y' ? " and Excerpt !=''" : '';
    $author = !$author ? '' : " and AuthorID IN ('" . join("','", doSlash(do_list($author))) . "')";
    $month = !$month ? '' : " and Posted like '" . doSlash($month) . "%'";
    $id = !$id ? '' : " and ID IN (" . join(',', array_map('intval', do_list($id))) . ")";
    switch ($time) {
        case 'any':
            $time = "";
            break;
        case 'future':
            $time = " and Posted > now()";
            break;
        default:
            $time = " and Posted <= now()";
    }
    if (!$publish_expired_articles) {
        $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);
        }
    }
    //Allow keywords for no-custom articles. That tagging mode, you know
    if ($keywords) {
        $keys = doSlash(do_list($keywords));
        foreach ($keys as $key) {
            $keyparts[] = "FIND_IN_SET('" . $key . "',Keywords)";
        }
        $keywords = " and (" . join(' or ', $keyparts) . ")";
    }
    if ($q and $searchsticky) {
        $statusq = ' and Status >= 4';
    } elseif ($id) {
        $statusq = ' and Status >= 4';
    } else {
        $statusq = ' and Status = ' . intval($status);
    }
    $where = "1=1" . $statusq . $time . $search . $id . $category . $section . $excerpted . $month . $author . $keywords . $custom . $frontpage;
    //do not paginate if we are on a custom list
    if (!$iscustom and !$issticky) {
        $grand_total = safe_count('textpattern', $where);
        $total = $grand_total - $offset;
        $numPages = ceil($total / $pageby);
        $pg = !$pg ? 1 : $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['grand_total'] = $grand_total;
        $pageout['total'] = $total;
        global $thispage;
        if (empty($thispage)) {
            $thispage = $pageout;
        }
        if ($pgonly) {
            return;
        }
    } else {
        $pgoffset = $offset;
    }
    $rs = safe_rows_start("*, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod" . $match, 'textpattern', $where . ' order by ' . doSlash($sort) . ' limit ' . intval($pgoffset) . ', ' . intval($limit));
    // get the form name
    if ($q and !$iscustom and !$issticky) {
        $fname = $searchform ? $searchform : 'search_results';
    } else {
        $fname = $listform ? $listform : $form;
    }
    if ($rs) {
        $count = 0;
        $last = numRows($rs);
        $articles = array();
        while ($a = nextRow($rs)) {
            ++$count;
            populateArticleData($a);
            global $thisarticle, $uPosted, $limit;
            $thisarticle['is_first'] = $count == 1;
            $thisarticle['is_last'] = $count == $last;
            if (@constant('txpinterface') === 'admin' and gps('Form')) {
                $articles[] = parse(gps('Form'));
            } elseif ($allowoverride and $a['override_form']) {
                $articles[] = parse_form($a['override_form']);
            } else {
                $articles[] = $thing ? parse($thing) : parse_form($fname);
            }
            // sending these to paging_link(); Required?
            $uPosted = $a['uPosted'];
            unset($GLOBALS['thisarticle']);
        }
        return doLabel($label, $labeltag) . doWrap($articles, $wraptag, $break, $class);
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:publish.php

示例10: file_list

function file_list($message = '')
{
    global $file_base_path, $file_statuses, $file_list_pageby, $txp_user, $event;
    pagetop(gTxt('tab_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');
    }
    if ($dir === 'desc') {
        $dir = 'desc';
    } else {
        $dir = 'asc';
    }
    echo hed(gTxt('tab_file'), 1, array('class' => 'txp-heading')) . n . tag_start('div', array('id' => $event . '_control', 'class' => 'txp-control-panel'));
    if (!is_dir($file_base_path) || !is_writeable($file_base_path)) {
        echo graf(span(null, array('class' => 'ui-icon ui-icon-alert')) . ' ' . gTxt('file_dir_not_writeable', array('{filedir}' => $file_base_path)), array('class' => 'alert-block warning'));
    } elseif (has_privs('file.edit.own')) {
        $existing_files = get_filenames();
        if ($existing_files) {
            echo form(eInput('file') . sInput('file_create') . graf(tag(gTxt('existing_file'), 'label', array('for' => 'file-existing')) . sp . selectInput('filename', $existing_files, '', 1, '', 'file-existing') . sp . fInput('submit', '', gTxt('Create')), array('class' => 'existing-file')), '', '', 'post', '', '', 'assign_file');
        }
        echo file_upload_form(gTxt('upload_file'), 'upload', 'file_insert');
    }
    switch ($sort) {
        case 'id':
            $sort_sql = 'txp_file.id ' . $dir;
            break;
        case 'description':
            $sort_sql = 'txp_file.description ' . $dir . ', txp_file.filename desc';
            break;
        case 'category':
            $sort_sql = 'txp_category.title ' . $dir . ', txp_file.filename desc';
            break;
        case 'title':
            $sort_sql = 'txp_file.title ' . $dir . ', txp_file.filename desc';
            break;
        case 'downloads':
            $sort_sql = 'txp_file.downloads ' . $dir . ', txp_file.filename desc';
            break;
        case 'author':
            $sort_sql = 'txp_users.RealName ' . $dir . ', txp_file.id asc';
            break;
        default:
            $sort = 'filename';
            $sort_sql = 'txp_file.filename ' . $dir;
            break;
    }
    set_pref('file_sort_column', $sort, 'file', PREF_HIDDEN, '', 0, PREF_PRIVATE);
    set_pref('file_sort_dir', $dir, 'file', PREF_HIDDEN, '', 0, PREF_PRIVATE);
    if ($dir == 'desc') {
        $switch_dir = 'asc';
    } else {
        $switch_dir = 'desc';
    }
    $criteria = 1;
    if ($search_method && $crit !== '') {
        $verbatim = preg_match('/^"(.*)"$/', $crit, $m);
        $crit_escaped = $verbatim ? doSlash($m[1]) : doLike($crit);
        $critsql = $verbatim ? array('id' => "txp_file.id in ('" . join("','", do_list($crit_escaped)) . "')", 'filename' => "txp_file.filename = '{$crit_escaped}'", 'title' => "txp_file.title = '{$crit_escaped}'", 'description' => "txp_file.description = '{$crit_escaped}'", 'category' => "txp_file.category = '{$crit_escaped}' or txp_category.title = '{$crit_escaped}'", 'author' => "txp_file.author = '{$crit_escaped}' or txp_users.RealName = '{$crit_escaped}'") : array('id' => "txp_file.id in ('" . join("','", do_list($crit_escaped)) . "')", 'filename' => "txp_file.filename like '%{$crit_escaped}%'", 'title' => "txp_file.title like '%{$crit_escaped}%'", 'description' => "txp_file.description like '%{$crit_escaped}%'", 'category' => "txp_file.category like '%{$crit_escaped}%' or txp_category.title like '%{$crit_escaped}%'", 'author' => "txp_file.author like '%{$crit_escaped}%' or txp_users.RealName 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', 'file_list', 0, $criteria);
    $sql_from = safe_pfx_j('txp_file') . "\n        left join " . safe_pfx_j('txp_category') . " on txp_category.name = txp_file.category and txp_category.type = 'file'\n        left join " . safe_pfx_j('txp_users') . " on txp_users.name = txp_file.author";
    if ($criteria === 1) {
        $total = safe_count('txp_file', $criteria);
    } else {
        $total = getThing('select count(*) from ' . $sql_from . ' where ' . $criteria);
    }
    if ($total < 1) {
        if ($criteria != 1) {
            echo file_search_form($crit, $search_method) . graf(gTxt('no_results_found'), ' class="indicator"') . '</div>';
        } else {
            echo 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_query("select\n            txp_file.id,\n            txp_file.filename,\n            txp_file.title,\n            txp_file.category,\n            txp_file.description,\n            txp_file.downloads,\n            txp_file.status,\n            txp_file.author,\n            txp_users.RealName as realname,\n            txp_category.Title as category_title\n        from {$sql_from} where {$criteria} order by {$sort_sql} limit {$offset}, {$limit}");
    if ($rs && numRows($rs)) {
        $show_authors = !has_single_author('txp_file');
        echo n . tag_start('div', array('id' => $event . '_container', 'class' => 'txp-container')) . n . tag_start('form', array('action' => 'index.php', 'id' => 'files_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', 'file', true, $switch_dir, $crit, $search_method, ('id' == $sort ? "{$dir} " : '') . 'txp-list-col-id') . column_head('file_name', 'filename', 'file', true, $switch_dir, $crit, $search_method, ('filename' == $sort ? "{$dir} " : '') . 'txp-list-col-filename') . column_head('title', 'title', 'file', true, $switch_dir, $crit, $search_method, ('title' == $sort ? "{$dir} " : '') . 'txp-list-col-title') . column_head('description', 'description', 'file', true, $switch_dir, $crit, $search_method, ('description' == $sort ? "{$dir} " : '') . 'txp-list-col-description files_detail') . column_head('file_category', 'category', 'file', true, $switch_dir, $crit, $search_method, ('category' == $sort ? "{$dir} " : '') . 'txp-list-col-category category') . hCell(gTxt('tags'), '', ' scope="col" class="txp-list-col-tag-build files_detail"') . hCell(gTxt('status'), '', ' scope="col" class="txp-list-col-status"') . hCell(gTxt('condition'), '', ' scope="col" class="txp-list-col-condition"') . column_head('downloads', 'downloads', 'file', true, $switch_dir, $crit, $search_method, ('downloads' == $sort ? "{$dir} " : '') . 'txp-list-col-downloads') . ($show_authors ? column_head('author', 'author', 'file', 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);
            $filename = sanitizeForFile($filename);
            $edit_url = array('event' => 'file', 'step' => 'file_edit', 'id' => $id, 'sort' => $sort, 'dir' => $dir, 'page' => $page, 'search_method' => $search_method, 'crit' => $crit);
//.........这里部分代码省略.........
开发者ID:hcgtv,项目名称:textpattern,代码行数:101,代码来源:txp_file.php

示例11: doArticles


//.........这里部分代码省略.........
    } else {
        $match = $search = '';
        if (!$sortby) {
            $sortby = 'Posted';
        }
    }
    //Building query parts
    $frontpage = ($frontpage and !$q) ? filterFrontPage() : '';
    $category = !$category ? '' : " and ((Category1='" . doslash($category) . "') or (Category2='" . doSlash($category) . "')) ";
    $section = !$section ? '' : " and Section = '" . doslash($section) . "'";
    $excerpted = $excerpted == 'y' ? " and Excerpt !=''" : '';
    $author = !$author ? '' : " and AuthorID = '" . doslash($author) . "'";
    $month = !$month ? '' : " and Posted like '" . doSlash($month) . "%'";
    $id = !$id ? '' : " and ID = '" . intval($id) . "'";
    switch ($time) {
        case 'any':
            $time = "";
            break;
        case 'future':
            $time = " and Posted > now()";
            break;
        default:
            $time = " and Posted < now()";
    }
    if (!is_numeric($status)) {
        $status = getStatusNum($status);
    }
    $custom = '';
    // trying custom fields here
    $customFields = getCustomFields();
    if ($customFields) {
        foreach ($customFields as $cField) {
            if (isset($atts[$cField])) {
                $customPairs[$cField] = $atts[$cField];
            }
        }
        if (!empty($customPairs)) {
            $custom = buildCustomSql($customFields, $customPairs);
        } else {
            $custom = '';
        }
    }
    //Allow keywords for no-custom articles. That tagging mode, you know
    if ($keywords) {
        $keys = split(',', $keywords);
        foreach ($keys as $key) {
            $keyparts[] = " Keywords like '%" . doSlash(trim($key)) . "%'";
        }
        $keywords = " and (" . join(' or ', $keyparts) . ")";
    }
    $where = "1" . ($id ? " and Status >= '4'" : " and Status='" . doSlash($status) . "'") . $time . $search . $id . $category . $section . $excerpted . $month . $author . $keywords . $custom . $frontpage;
    //do not paginate if we are on a custom list
    if (!$iscustom and !$issticky) {
        $total = safe_count('textpattern', $where) - $offset;
        $numPages = ceil($total / $pageby);
        $pg = !$pg ? 1 : $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['total'] = $total;
        $GLOBALS['thispage'] = $pageout;
        if ($pgonly) {
            return;
        }
    } else {
        $pgoffset = $offset . ', ';
    }
    $rs = safe_rows_start("*, unix_timestamp(Posted) as uPosted" . $match, 'textpattern', $where . ' order by ' . doslash($sortby) . ' ' . doSlash($sortdir) . ' limit ' . doSlash($pgoffset . $limit));
    // alternative form override for search or list
    if ($q and !$iscustom and !$issticky) {
        $form = gAtt($atts, 'searchform', 'search_results');
    } else {
        $form = gAtt($atts, 'listform', $form);
    }
    // might be a form preview, otherwise grab it from the db
    $form = isset($_POST['Form']) ? gps('Form') : fetch_form($form);
    if ($rs) {
        $count = 0;
        $articles = array();
        while ($a = nextRow($rs)) {
            ++$count;
            populateArticleData($a);
            $GLOBALS['thisarticle']['is_first'] = $count == 1;
            $GLOBALS['thisarticle']['is_last'] = $count == numRows($rs);
            // define the article form
            $article = ($allowoverride and $a['override_form']) ? fetch_form($a['override_form']) : $form;
            $articles[] = parse($article);
            // sending these to paging_link(); Required?
            $GLOBALS['uPosted'] = $a['uPosted'];
            $GLOBALS['limit'] = $limit;
            unset($GLOBALS['thisarticle']);
            unset($GLOBALS['theseatts']);
            //Required?
        }
        return join('', $articles);
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:publish.php

示例12: WriteForumEditContents

function WriteForumEditContents($fid)
{
    global $loguser;
    //Get all categories.
    $rCats = Query("SELECT * FROM {categories} ORDER BY corder, id");
    $cats = array();
    while ($cat = Fetch($rCats)) {
        $cats[$cat['id']] = $cat;
    }
    $rFora = Query("SELECT * FROM {forums} ORDER BY forder, id");
    $fora = array();
    while ($forum = Fetch($rFora)) {
        $fora[$forum['id']] = $forum;
    }
    if (count($cats) == 0) {
        $cats[0] = __("No categories");
    }
    if ($fid != -1) {
        $rForum = Query("SELECT * FROM {forums} WHERE id={0}", $fid);
        if (!NumRows($rForum)) {
            Kill(__("Forum not found."));
        }
        $forum = Fetch($rForum);
        $title = htmlspecialchars($forum['title']);
        $description = htmlspecialchars($forum['description']);
        $catselect = MakeCatSelect('cat', $cats, $fora, $forum['catid'], $forum['id']);
        $minpower = PowerSelect('minpower', $forum['minpower']);
        $minpowerthread = PowerSelect("minpowerthread", $forum['minpowerthread']);
        $minpowerreply = PowerSelect('minpowerreply', $forum['minpowerreply']);
        $forder = $forum['forder'];
        $func = "changeForumInfo";
        $button = __("Save");
        $boxtitle = __("Edit Forum");
        $delbutton = "\n\t\t\t<button onclick='showDeleteForum(); return false;'>\n\t\t\t\t" . __("Delete") . "\n\t\t\t</button>";
        $localmods = "";
        $rMods = query("SELECT u.(_userfields)\n\t\t\t\t\t\tFROM {forummods} m\n\t\t\t\t\t\tLEFT JOIN {users} u ON u.id = m.user\n\t\t\t\t\t\tWHERE m.forum={0}\n\t\t\t\t\t\tORDER BY m.user", $fid);
        $addedMods = array();
        if (!numRows($rMods)) {
            $localmods .= "(No local moderators assigned to this forum)<br /><br />";
        } else {
            $localmods .= "<ul>";
            while ($mod = fetch($rMods)) {
                $mod = getDataPrefix($mod, "u_");
                $localmods .= "<li>" . UserLink($mod);
                $mid = $mod["id"];
                $addedMods[$mid] = 1;
                $localmods .= " <sup><a href=\"\" onclick=\"deleteMod({$mid}); return false;\">&#x2718;</a></li>";
            }
            $localmods .= "</ul>";
        }
        $rMods = query("SELECT u.(_userfields)\n\t\t\t\t\t\tFROM {users} u\n\t\t\t\t\t\tWHERE u.powerlevel = 1\n\t\t\t\t\t\tORDER BY u.id");
        $canAddMods = false;
        $addmod = "Add a mod: ";
        $addmod .= "<select name=\"addmod\" id=\"addmod\">";
        while ($mod = fetch($rMods)) {
            $mod = getDataPrefix($mod, "u_");
            if (isset($addedMods[$mod["id"]])) {
                continue;
            }
            $canAddMods = true;
            $mid = $mod["id"];
            $mname = $mod["displayname"];
            if (!$mname) {
                $mname = $mod["name"];
            }
            $addmod .= "<option value=\"{$mid}\">{$mname} ({$mid})</option>";
        }
        $addmod .= "</select>";
        $addmod .= "<button type=\"button\" onclick=\"addMod(); return false;\">Add</button>";
        if (!$canAddMods) {
            $addmod = "<br>No moderators available for adding.<br>To add a mod, set his powerlevel to Local Mod first.";
        }
        $localmods .= $addmod;
    } else {
        $title = __("New Forum");
        $description = __("Description goes here. <strong>HTML allowed.</strong>");
        $catselect = MakeCatSelect('cat', $cats, $fora, 1, -1);
        $minpower = PowerSelect('minpower', 0);
        $minpowerthread = PowerSelect("minpowerthread", 0);
        $minpowerreply = PowerSelect('minpowerreply', 0);
        $forder = 0;
        $func = "addForum";
        $button = __("Add");
        $boxtitle = __("New Forum");
        $delbutton = "";
        $localmods = "(Create the forum before managing mods)";
        $privusers = '<small>(create the forum before adding users here)</small>';
    }
    echo "\n\t<form method=\"post\" id=\"forumform\" action=\"" . actionLink("editfora") . "\">\n\t<input type=\"hidden\" name=\"key\" value=\"" . $loguser['token'] . "\">\n\t<input type=\"hidden\" name=\"id\" value=\"{$fid}\">\n\t<table class=\"outline margin\">\n\t\t<tr class=\"header1\">\n\t\t\t<th colspan=\"2\">\n\t\t\t\t{$boxtitle}\n\t\t\t</th>\n\t\t</tr>\n\t\t<tr class=\"cell1\">\n\t\t\t<td style=\"width: 25%;\">\n\t\t\t\t" . __("Title") . "\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<input type=\"text\" style=\"width: 98%;\" name=\"title\" value=\"{$title}\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr class=\"cell0\">\n\n\t\t\t<td>\n\t\t\t\t" . __("Description") . "\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<input type=\"text\" style=\"width: 98%;\" name=\"description\" value=\"{$description}\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr class=\"cell1\">\n\t\t\t<td>\n\t\t\t\t" . __("Parent") . "\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t{$catselect}\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr class=\"cell0\">\n\t\t\t<td>\n\t\t\t\t" . __("Listing order") . "\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<input type=\"text\" size=\"2\" name=\"forder\" value=\"{$forder}\" />\n\t\t\t\t<img src=\"" . resourceLink("img/icons/icon5.png") . "\" title=\"" . __("Everything is sorted by listing order first, then by ID. If everything has its listing order set to 0, they will therefore be sorted by ID only.") . "\" alt=\"[?]\" />\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr class=\"cell1\">\n\t\t\t<td>\n\t\t\t\t" . __("Powerlevel required") . "\n\t\t\t</td>\n\t\t\t<td>\n\n\t\t\t\t{$minpower}\n\t\t\t\t" . __("to view") . "\n\t\t\t\t<br />\n\t\t\t\t{$minpowerthread}\n\t\t\t\t" . __("to post threads") . "\n\t\t\t\t<br />\n\t\t\t\t{$minpowerreply}\n\t\t\t\t" . __("to reply") . "\n\t\t\t</td>\n\t\t</tr>\n\t\t<tr class=\"cell0\">\n\t\t\t<td>\n\t\t\t\t" . __("Local moderators") . "\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t{$localmods}\n\t\t\t</td>\n\t\t</tr>\n\n\t\t<tr class=\"cell2\">\n\t\t\t<td>\n\t\t\t\t&nbsp;\n\t\t\t</td>\n\t\t\t<td>\n\t\t\t\t<button onclick=\"{$func}(); return false;\">\n\t\t\t\t\t{$button}\n\t\t\t\t</button>\n\t\t\t\t{$delbutton}\n\t\t\t</td>\n\t\t</tr>\n\t</table></form>\n\n\t<form method=\"post\" id=\"deleteform\" action=\"" . actionLink("editfora") . "\">\n\t<input type=\"hidden\" name=\"key\" value=\"" . $loguser['token'] . "\">\n\t<input type=\"hidden\" name=\"id\" value=\"{$fid}\">\n\t<div id=\"deleteforum\" style=\"display:none\">\n\t\t<table class=\"outline margin\">\n\t\t\t<tr class=\"header1\">\n\n\t\t\t\t<th>\n\t\t\t\t\t" . __("Delete forum") . "\n\t\t\t\t</th>\n\t\t\t</tr>\n\t\t\t<tr class=\"cell0\">\n\t\t\t\t<td>\n\t\t\t\t\t" . __("Instead of deleting a forum, you might want to consider archiving it: Change its name or description to say so, and raise the minimum powerlevel to reply and create threads so it's effectively closed.") . "<br><br>\n\t\t\t\t\t" . __("If you still want to delete it, click below:") . "<br>\n\t\t\t\t\t<button onclick=\"deleteForum('delete'); return false;\">\n\t\t\t\t\t\t" . __("Delete forum") . "\n\t\t\t\t\t</button>\n\t\t\t\t</td>\n\t\t\t</tr>\n\t\t</table>\n\t</div>\n\t</form>";
    //	, $title, $description, $catselect, $minpower, $minpowerthread, $minpowerreply, $fid, $forder, $loguser['token'], $func, $button, $boxtitle, $delbutton);
}
开发者ID:knytrune,项目名称:ABXD,代码行数:91,代码来源:editfora.php

示例13: getInstalledVersion

function getInstalledVersion()
{
    //If no misc table, not installed.
    if (numRows(query("SHOW TABLES LIKE '{misc}'")) == 0) {
        return -1;
    }
    $row = query("SELECT * FROM {misc}");
    //If no row in misc table, not installed.
    if (numRows($row) == 0) {
        return -1;
    }
    //Otherwise return version.
    $row = fetch($row);
    return $row["version"];
}
开发者ID:knytrune,项目名称:ABXD,代码行数:15,代码来源:installer.php

示例14: define

        }
    }
}
define('txpath', dirname(dirname(__FILE__)) . '/textpattern');
define('txpinterface', 'xmlrpc');
require_once txpath . '/config.php';
require_once txpath . '/lib/txplib_db.php';
require_once txpath . '/lib/txplib_misc.php';
require_once txpath . '/lib/admin_config.php';
require_once txpath . '/lib/IXRClass.php';
require_once txpath . '/vendors/Textpattern/Loader.php';
$loader = new \Textpattern\Loader(txpath . '/vendors');
$loader->register();
$loader = new \Textpattern\Loader(txpath . '/lib');
$loader->register();
if ($connected && numRows(safe_query("show tables like '" . PFX . "textpattern'"))) {
    // TODO: where is dbversion used?
    $dbversion = safe_field('val', 'txp_prefs', "name = 'version'");
    // Hold it globally, instead of do several calls to the function.
    $prefs = get_prefs();
    extract($prefs);
    if (!defined('LANG')) {
        define("LANG", $language);
    }
    if (!defined('hu')) {
        define("hu", 'http://' . $siteurl . '/');
    }
    if (!defined('txrpcpath')) {
        define('txrpcpath', hu . 'rpc/');
    }
    if (!empty($locale)) {
开发者ID:scar45,项目名称:textpattern,代码行数:31,代码来源:index.php

示例15: doArticles


//.........这里部分代码省略.........
            $time = " AND Posted <= " . now('posted');
    }
    if (!$expired) {
        $time .= " AND (" . now('expires') . " <= 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);
        }
    }
    // Allow keywords for no-custom articles. That tagging mode, you know.
    if ($keywords) {
        $keys = doSlash(do_list_unique($keywords));
        foreach ($keys as $key) {
            $keyparts[] = "FIND_IN_SET('" . $key . "', Keywords)";
        }
        $keywords = " AND (" . join(' or ', $keyparts) . ")";
    }
    if ($q and $searchsticky) {
        $statusq = " AND Status >= " . STATUS_LIVE;
    } elseif ($id) {
        $statusq = " AND Status >= " . STATUS_LIVE;
    } else {
        $statusq = " AND Status = " . intval($status);
    }
    $where = "1 = 1" . $statusq . $time . $search . $id . $category . $section . $excerpted . $month . $author . $keywords . $custom . $frontpage;
    // Do not paginate if we are on a custom list.
    if (!$iscustom and !$issticky) {
        $grand_total = safe_count('textpattern', $where);
        $total = $grand_total - $offset;
        $numPages = ceil($total / $pageby);
        $pg = !$pg ? 1 : $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'] = 'article';
        $pageout['grand_total'] = $grand_total;
        $pageout['total'] = $total;
        global $thispage;
        if (empty($thispage)) {
            $thispage = $pageout;
        }
        if ($pgonly) {
            return;
        }
    } else {
        $pgoffset = $offset;
    }
    // Preserve order of custom article ids unless 'sort' attribute is set.
    if (!empty($atts['id']) && empty($atts['sort'])) {
        $safe_sort = "FIELD(id, " . join(',', $ids) . ")";
    } else {
        $safe_sort = doSlash($sort);
    }
    $rs = safe_rows_start("*, UNIX_TIMESTAMP(Posted) AS uPosted, UNIX_TIMESTAMP(Expires) AS uExpires, UNIX_TIMESTAMP(LastMod) AS uLastMod" . $match, 'textpattern', "{$where} ORDER BY {$safe_sort} LIMIT " . intval($pgoffset) . ", " . intval($limit));
    // Get the form name.
    if ($q and !$iscustom and !$issticky) {
        $fname = $searchform ? $searchform : 'search_results';
    } else {
        $fname = !empty($listform) ? $listform : $form;
    }
    if ($rs) {
        $count = 0;
        $last = numRows($rs);
        $articles = array();
        while ($a = nextRow($rs)) {
            ++$count;
            populateArticleData($a);
            global $thisarticle, $uPosted, $limit;
            $thisarticle['is_first'] = $count == 1;
            $thisarticle['is_last'] = $count == $last;
            // Article form preview.
            if (txpinterface === 'admin' && ps('Form')) {
                doAuth();
                if (!has_privs('form')) {
                    txp_status_header('401 Unauthorized');
                    exit(hed('401 Unauthorized', 1) . graf(gTxt('restricted_area')));
                }
                $articles[] = parse(gps('Form'));
            } elseif ($allowoverride and $a['override_form']) {
                $articles[] = parse_form($a['override_form']);
            } else {
                $articles[] = $thing ? parse($thing) : parse_form($fname);
            }
            // Sending these to paging_link(); Required?
            $uPosted = $a['uPosted'];
            unset($GLOBALS['thisarticle']);
        }
        return doLabel($label, $labeltag) . doWrap($articles, $wraptag, $break, $class);
    }
}
开发者ID:ClaireBrione,项目名称:textpattern,代码行数:101,代码来源:publish.php


注:本文中的numRows函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。