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


PHP populateArticleData函数代码示例

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


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

示例1: article_format_info

/**
 * Convenience for those who prefer "SELECT * FROM textpattern"
 *
 * @param array $rs An assoc w/ one article's data from the DB
 */
function article_format_info($rs)
{
    $rs['uPosted'] = ($unix_ts = @strtotime($rs['Posted'])) > 0 ? $unix_ts : NULLDATETIME;
    $rs['uLastMod'] = ($unix_ts = @strtotime($rs['LastMod'])) > 0 ? $unix_ts : NULLDATETIME;
    $rs['uExpires'] = ($unix_ts = @strtotime($rs['Expires'])) > 0 ? $unix_ts : NULLDATETIME;
    populateArticleData($rs);
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:12,代码来源:txplib_publish.php

示例2: discuss

function discuss($id)
{
    $rs = safe_row('*, unix_timestamp(Posted) as uPosted, unix_timestamp(LastMod) as uLastMod, unix_timestamp(Expires) as uExpires', 'textpattern', 'ID=' . intval($id) . ' and Status >= 4');
    if ($rs) {
        populateArticleData($rs);
        $result = parse_form('comments_display');
        return $result;
    }
    return '';
}
开发者ID:evanfarrar,项目名称:opensprints.org,代码行数:10,代码来源:comment.php

示例3: discuss

function discuss($id)
{
    $rs = safe_row('*, unix_timestamp(Posted) as uPosted', 'textpattern', "ID='" . doSlash($id) . "' and Status >= 4");
    if ($rs) {
        populateArticleData($rs);
        if (ps('preview')) {
            $GLOBALS['comment_preview'] = 1;
        }
        $result = parse(fetch_form('comments_display'));
        unset($GLOBALS['comment_preview']);
        return $result;
    }
    return '';
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:14,代码来源:comment.php

示例4: atom

/**
 * Generates and outputs an Atom feed.
 *
 * This function can only be called once on a page. It outputs an Atom feed
 * based on the requested URL parameters. Accepts HTTP GET parameters 'limit',
 * 'area', 'section' and 'category'.
 */
function atom()
{
    global $thisarticle, $prefs;
    set_error_handler('feedErrorHandler');
    ob_clean();
    extract($prefs);
    $last = fetch("UNIX_TIMESTAMP(val)", 'txp_prefs', 'name', 'lastmod');
    extract(doSlash(gpsa(array('limit', 'area'))));
    // Build filter criteria from a comma-separated list of sections
    // and categories.
    $feed_filter_limit = get_pref('feed_filter_limit', 10);
    $section = gps('section');
    $category = gps('category');
    if (!is_scalar($section) || !is_scalar($category)) {
        txp_die('Not Found', 404);
    }
    $section = $section ? array_slice(do_list_unique($section), 0, $feed_filter_limit) : array();
    $category = $category ? array_slice(do_list_unique($category), 0, $feed_filter_limit) : array();
    $st = array();
    foreach ($section as $s) {
        $st[] = fetch_section_title($s);
    }
    $ct = array();
    foreach ($category as $c) {
        $ct[] = fetch_category_title($c);
    }
    $sitename .= $section ? ' - ' . join(' - ', $st) : '';
    $sitename .= $category ? ' - ' . join(' - ', $ct) : '';
    $pub = safe_row("RealName, email", 'txp_users', "privs = 1");
    // Feed header.
    $out[] = tag(htmlspecialchars($sitename), 'title', t_text);
    $out[] = tag(htmlspecialchars($site_slogan), 'subtitle', t_text);
    $out[] = '<link' . r_relself . ' href="' . pagelinkurl(array('atom' => 1, 'area' => $area, 'section' => $section, 'category' => $category, 'limit' => $limit)) . '" />';
    $out[] = '<link' . r_relalt . t_texthtml . ' href="' . hu . '" />';
    // Atom feeds with mail or domain name.
    $dn = explode('/', $siteurl);
    $mail_or_domain = $use_mail_on_feeds_id ? eE($blog_mail_uid) : $dn[0];
    $out[] = tag('tag:' . $mail_or_domain . ',' . $blog_time_uid . ':' . $blog_uid . ($section ? '/' . join(',', $section) : '') . ($category ? '/' . join(',', $category) : ''), 'id');
    $out[] = tag('Textpattern', 'generator', ' uri="http://textpattern.com/" version="' . $version . '"');
    $out[] = tag(safe_strftime("w3cdtf", $last), 'updated');
    $auth[] = tag($pub['RealName'], 'name');
    $auth[] = $include_email_atom ? tag(eE($pub['email']), 'email') : '';
    $auth[] = tag(hu, 'uri');
    $out[] = tag(n . t . t . join(n . t . t, $auth) . n, 'author');
    $out[] = callback_event('atom_head');
    // Feed items.
    $articles = array();
    $section = doSlash($section);
    $category = doSlash($category);
    if (!$area or $area == 'article') {
        $sfilter = !empty($section) ? "AND Section IN ('" . join("','", $section) . "')" : '';
        $cfilter = !empty($category) ? "AND (Category1 IN ('" . join("','", $category) . "') OR Category2 IN ('" . join("','", $category) . "'))" : '';
        $limit = $limit ? $limit : $rss_how_many;
        $limit = intval(min($limit, max(100, $rss_how_many)));
        $frs = safe_column("name", 'txp_section', "in_rss != '1'");
        $query = array();
        foreach ($frs as $f) {
            $query[] = "AND Section != '" . doSlash($f) . "'";
        }
        $query[] = $sfilter;
        $query[] = $cfilter;
        $expired = $publish_expired_articles ? " " : " AND (" . now('expires') . " <= Expires OR Expires = " . NULLDATETIME . ") ";
        $rs = safe_rows_start("*,\n            ID AS thisid,\n            UNIX_TIMESTAMP(Posted) AS uPosted,\n            UNIX_TIMESTAMP(Expires) AS uExpires,\n            UNIX_TIMESTAMP(LastMod) AS uLastMod", 'textpattern', "Status = 4 AND Posted <= " . now('posted') . $expired . join(' ', $query) . "ORDER BY Posted DESC LIMIT {$limit}");
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                populateArticleData($a);
                $cb = callback_event('atom_entry');
                $e = array();
                $a['posted'] = $uPosted;
                $a['expires'] = $uExpires;
                if ($show_comment_count_in_feed) {
                    $count = $comments_count > 0 ? ' [' . $comments_count . ']' : '';
                } else {
                    $count = '';
                }
                $thisauthor = get_author_name($AuthorID);
                $e['thisauthor'] = tag(n . t . t . t . tag(htmlspecialchars($thisauthor), 'name') . n . t . t, 'author');
                $e['issued'] = tag(safe_strftime('w3cdtf', $uPosted), 'published');
                $e['modified'] = tag(safe_strftime('w3cdtf', $uLastMod), 'updated');
                $escaped_title = htmlspecialchars($Title);
                $e['title'] = tag($escaped_title . $count, 'title', t_html);
                $permlink = permlinkurl($a);
                $e['link'] = '<link' . r_relalt . t_texthtml . ' href="' . $permlink . '" />';
                $e['id'] = tag('tag:' . $mail_or_domain . ',' . $feed_time . ':' . $blog_uid . '/' . $uid, 'id');
                $e['category1'] = trim($Category1) ? '<category term="' . htmlspecialchars($Category1) . '" />' : '';
                $e['category2'] = trim($Category2) ? '<category term="' . htmlspecialchars($Category2) . '" />' : '';
                $summary = trim(replace_relative_urls(parse($thisarticle['excerpt']), $permlink));
                $content = trim(replace_relative_urls(parse($thisarticle['body']), $permlink));
                if ($syndicate_body_or_excerpt) {
                    // Short feed: use body as summary if there's no excerpt.
                    if (!trim($summary)) {
                        $summary = $content;
//.........这里部分代码省略.........
开发者ID:ClaireBrione,项目名称:textpattern,代码行数:101,代码来源:atom.php

示例5: doArticle

function doArticle($atts, $thing = null)
{
    global $pretext, $prefs, $thisarticle;
    extract($prefs);
    extract($pretext);
    extract(gpsa(array('parentid', 'preview')));
    $theAtts = lAtts(array('allowoverride' => '1', 'form' => 'default', 'status' => STATUS_LIVE, 'pgonly' => 0), $atts, 0);
    extract($theAtts);
    // Save *all* atts to get hold of the current article filter criteria.
    filterAtts($atts);
    // No output required.
    if ($pgonly) {
        return '';
    }
    // If a form is specified, $thing is for doArticles() - hence ignore
    // $thing here.
    if (!empty($atts['form'])) {
        $thing = '';
    }
    if ($status) {
        $status = in_array(strtolower($status), array('sticky', STATUS_STICKY)) ? STATUS_STICKY : STATUS_LIVE;
    }
    if (empty($thisarticle) or $thisarticle['thisid'] != $id) {
        $id = assert_int($id);
        $thisarticle = null;
        $q_status = $status ? "AND Status = " . intval($status) : "AND Status IN (" . STATUS_LIVE . "," . STATUS_STICKY . ")";
        $rs = safe_row("*, UNIX_TIMESTAMP(Posted) AS uPosted, UNIX_TIMESTAMP(Expires) AS uExpires, UNIX_TIMESTAMP(LastMod) AS uLastMod", 'textpattern', "ID = {$id} {$q_status} LIMIT 1");
        if ($rs) {
            extract($rs);
            populateArticleData($rs);
        }
    }
    if (!empty($thisarticle) and ($thisarticle['status'] == $status or gps('txpreview'))) {
        extract($thisarticle);
        $thisarticle['is_first'] = 1;
        $thisarticle['is_last'] = 1;
        if ($allowoverride and $override_form) {
            $article = parse_form($override_form);
        } else {
            $article = $thing ? parse($thing) : parse_form($form);
        }
        if ($use_comments and $comments_auto_append) {
            $article .= parse_form('comments_display');
        }
        unset($GLOBALS['thisarticle']);
        return $article;
    }
}
开发者ID:ClaireBrione,项目名称:textpattern,代码行数:48,代码来源:publish.php

示例6: doArticle

function doArticle($atts, $thing = NULL)
{
    global $pretext, $prefs, $thisarticle;
    extract($prefs);
    extract($pretext);
    extract(gpsa(array('parentid', 'preview')));
    extract(lAtts(array('allowoverride' => '1', 'form' => 'default', 'status' => '4'), $atts, 0));
    // if a form is specified, $thing is for doArticles() - hence ignore $thing here.
    if (!empty($atts['form'])) {
        $thing = '';
    }
    if ($status) {
        $status = in_array(strtolower($status), array('sticky', '5')) ? 5 : 4;
    }
    if (empty($thisarticle) or $thisarticle['thisid'] != $id) {
        $thisarticle = NULL;
        $q_status = $status ? 'and Status = ' . intval($status) : 'and Status in (4,5)';
        $rs = safe_row("*, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod", "textpattern", 'ID = ' . intval($id) . " {$q_status} limit 1");
        if ($rs) {
            extract($rs);
            populateArticleData($rs);
        }
    }
    if (!empty($thisarticle) and ($thisarticle['status'] == $status or gps('txpreview'))) {
        extract($thisarticle);
        $thisarticle['is_first'] = 1;
        $thisarticle['is_last'] = 1;
        if ($allowoverride and $override_form) {
            $article = parse_form($override_form);
        } else {
            $article = $thing ? parse($thing) : parse_form($form);
        }
        if ($use_comments and $comments_auto_append) {
            $article .= parse_form('comments_display');
        }
        unset($GLOBALS['thisarticle']);
        return $article;
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:39,代码来源:publish.php

示例7: popup_comments

function popup_comments($atts, $thing = null)
{
    extract(lAtts(array('form' => 'comments_display'), $atts));
    $rs = safe_row("*, UNIX_TIMESTAMP(Posted) AS uPosted, UNIX_TIMESTAMP(LastMod) AS uLastMod, UNIX_TIMESTAMP(Expires) AS uExpires", 'textpattern', "ID=" . intval(gps('parentid')) . " AND Status >= 4");
    if ($rs) {
        populateArticleData($rs);
        return $thing === null ? parse_form($form) : parse($thing);
    }
    return '';
}
开发者ID:ClaireBrione,项目名称:textpattern,代码行数:10,代码来源:taghandlers.php

示例8: related_articles

function related_articles($atts, $thing = NULL)
{
    global $thisarticle, $prefs;
    assert_article();
    extract(lAtts(array('break' => br, 'class' => __FUNCTION__, 'form' => '', 'label' => '', 'labeltag' => '', 'limit' => 10, 'match' => 'Category1,Category2', 'no_widow' => @$prefs['title_no_widow'], 'section' => '', 'sort' => 'Posted desc', 'wraptag' => ''), $atts));
    if (empty($thisarticle['category1']) and empty($thisarticle['category2'])) {
        return;
    }
    $match = do_list($match);
    if (!in_array('Category1', $match) and !in_array('Category2', $match)) {
        return;
    }
    $id = $thisarticle['thisid'];
    $cats = array();
    if ($thisarticle['category1']) {
        $cats[] = doSlash($thisarticle['category1']);
    }
    if ($thisarticle['category2']) {
        $cats[] = doSlash($thisarticle['category2']);
    }
    $cats = join("','", $cats);
    $categories = array();
    if (in_array('Category1', $match)) {
        $categories[] = "Category1 in('{$cats}')";
    }
    if (in_array('Category2', $match)) {
        $categories[] = "Category2 in('{$cats}')";
    }
    $categories = 'and (' . join(' or ', $categories) . ')';
    $section = $section ? " and Section IN ('" . join("','", doSlash(do_list($section))) . "')" : '';
    $expired = $prefs['publish_expired_articles'] ? '' : ' and (now() <= Expires or Expires = ' . NULLDATETIME . ') ';
    $rs = safe_rows_start('*, unix_timestamp(Posted) as posted, unix_timestamp(LastMod) as uLastMod, unix_timestamp(Expires) as uExpires', 'textpattern', 'ID != ' . intval($id) . " and Status = 4 {$expired}  and Posted <= now() {$categories} {$section} order by " . doSlash($sort) . ' limit 0,' . intval($limit));
    if ($rs) {
        $out = array();
        $old_article = $thisarticle;
        while ($a = nextRow($rs)) {
            $a['Title'] = $no_widow ? noWidow(escape_title($a['Title'])) : escape_title($a['Title']);
            $a['uPosted'] = $a['posted'];
            // populateArticleData() and permlinkurl() assume quite a bunch of posting dates...
            if (empty($form) && empty($thing)) {
                $out[] = href($a['Title'], permlinkurl($a));
            } else {
                populateArticleData($a);
                $out[] = $thing ? parse($thing) : parse_form($form);
            }
        }
        $thisarticle = $old_article;
        if ($out) {
            return doLabel($label, $labeltag) . doWrap($out, $wraptag, $break, $class);
        }
    }
    return '';
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:53,代码来源:taghandlers.php

示例9: doArticle

function doArticle($atts)
{
    global $pretext, $prefs;
    extract($prefs);
    extract($pretext);
    $preview = ps('preview');
    $parentid = ps('parentid');
    extract(lAtts(array('form' => 'default', 'status' => ''), $atts));
    if ($status and !is_numeric($status)) {
        $status = getStatusNum($status);
    }
    $q_status = $status ? "and Status='" . doSlash($status) . "'" : 'and Status in (4,5)';
    $rs = safe_row("*, unix_timestamp(Posted) as uPosted", "textpattern", "ID='" . intval($id) . "' {$q_status} limit 1");
    if ($rs) {
        extract($rs);
        populateArticleData($rs);
        $GLOBALS['thisarticle']['is_first'] = 1;
        $GLOBALS['thisarticle']['is_last'] = 1;
        // define the article form
        $article = fetch_form($override_form ? $override_form : $form);
        if ($preview && $parentid) {
            $article = '<txp:comments_preview bc="1" id="' . $parentid . '" />' . $article;
        }
        $article = parse($article);
        if ($use_comments and $comments_auto_append) {
            $f = fetch_form('comments_display');
            $article .= parse($f);
        }
        unset($GLOBALS['thisarticle']);
        return $article;
    }
}
开发者ID:bgarrels,项目名称:textpattern,代码行数:32,代码来源:publish.php

示例10: atom

function atom()
{
    global $thisarticle;
    extract($GLOBALS['prefs']);
    define("textplain", ' type="text/plain"');
    define("texthtml", ' type="text/html"');
    define("relalt", ' rel="alternate"');
    define('appxhtml', ' type="application/xhtml+xml"');
    define("divxhtml", '<div xmlns="http://www.w3.org/1999/xhtml">');
    $area = doSlash(gps('area'));
    extract(doSlash(gpsa(array('category', 'section', 'limit'))));
    $last = fetch('unix_timestamp(val)', 'txp_prefs', 'name', 'lastmod');
    $sitename .= $section ? ' - ' . $section : '';
    $sitename .= $category ? ' - ' . $category : '';
    $pub = safe_row("RealName, email", "txp_users", "privs=1");
    $out[] = tag($sitename, 'title', textplain);
    $out[] = tag($site_slogan, 'tagline', textplain);
    $out[] = '<link' . relalt . texthtml . ' href="' . hu . '" />';
    $articles = array();
    //Atom feeds with mail or domain name
    $dn = explode('/', $siteurl);
    $mail_or_domain = $use_mail_on_feeds_id ? eE($blog_mail_uid) : $dn[0];
    $out[] = tag('tag:' . $mail_or_domain . ',' . $blog_time_uid . ':' . $blog_uid . ($section ? '/' . $section : '') . ($category ? '/' . $category : ''), 'id');
    $out[] = tag('Textpattern', 'generator', ' url="http://textpattern.com" version="' . $version . '"');
    $out[] = tag(date("Y-m-d\\TH:i:s\\Z", $last), 'modified');
    $auth[] = tag($pub['RealName'], 'name');
    $auth[] = $include_email_atom ? tag(eE($pub['email']), 'email') : '';
    $auth[] = tag(hu, 'url');
    $out[] = tag(n . t . t . join(n . t . t, $auth) . n, 'author');
    if (!$area or $area == 'article') {
        $sfilter = $section ? "and Section = '" . $section . "'" : '';
        $cfilter = $category ? "and (Category1='" . $category . "' or Category2='" . $category . "')" : '';
        $limit = $limit ? $limit : '5';
        $frs = safe_column("name", "txp_section", "in_rss != '1'");
        foreach ($frs as $f) {
            $query[] = "and Section != '" . $f . "'";
        }
        $query[] = $sfilter;
        $query[] = $cfilter;
        $rs = safe_rows_start("*, \n\t\t\t\tID as thisid, \n\t\t\t\tunix_timestamp(Posted) as uPosted,\n\t\t\t\tunix_timestamp(LastMod) as uLastMod", "textpattern", "Status=4 and Posted <= now() " . join(' ', $query) . "order by Posted desc limit {$limit}");
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                populateArticleData($a);
                $a['posted'] = $uPosted;
                if ($show_comment_count_in_feed) {
                    $dc = getCount('txp_discuss', "parentid={$ID} and visible=1");
                    $count = $dc > 0 ? ' [' . $dc . ']' : '';
                } else {
                    $count = '';
                }
                $thisauthor = safe_field("RealName", "txp_users", "name='{$AuthorID}'");
                $e['thisauthor'] = tag(n . t . t . t . tag(htmlspecialchars($thisauthor), 'name') . n . t . t, 'author');
                $e['issued'] = tag(gmdate("Y-m-d\\TH:i:s\\Z", $uPosted), 'issued');
                $e['modified'] = tag(gmdate("Y-m-d\\TH:i:s\\Z", $uLastMod), 'modified');
                $escaped_title = safe_hed($Title);
                $escaped_title = preg_replace("/&(?![#a-z0-9]+;)/i", '&amp;', $escaped_title);
                $escaped_title = str_replace('<', '&lt;', $escaped_title);
                $escaped_title = str_replace('>', '&gt;', $escaped_title);
                $e['title'] = tag($escaped_title . $count, 'title');
                $uTitle = $url_title ? $url_title : stripSpace($Title);
                $uTitle = htmlspecialchars($uTitle, ENT_NOQUOTES);
                $permlink = permlinkurl($a);
                $e['link'] = '<link' . relalt . texthtml . ' href="' . $permlink . '" />';
                $e['id'] = tag('tag:' . $mail_or_domain . ',' . $feed_time . ':' . $blog_uid . '/' . $uid, 'id');
                $e['subject'] = tag(htmlspecialchars($Category1), 'dc:subject');
                // pull Body or Excerpt?
                $Body = !$syndicate_body_or_excerpt ? $thisarticle['body'] : $thisarticle['excerpt'];
                // if Excerpt is empty, switch back to Body_html
                $Body = !trim($Body) ? $thisarticle['body'] : $Body;
                // fix relative urls
                $Body = str_replace('href="/', 'href="' . hu, $Body);
                $Body = preg_replace("/href=\\\"#(.*)\"/", "href=\"" . permlinkurl($a) . "#\\1\"", $Body);
                $Body = safe_hed($Body);
                // encode and entify
                $Body = preg_replace(array('/</', '/>/', "/'/", '/"/'), array('&#60;', '&#62;', '&#039;', '&#34;'), $Body);
                // encode bare ampersands
                $Body = preg_replace("/&(?![#0-9]+;|\\w+;)/i", '&amp;', $Body);
                $e['content'] = tag(n . $Body . n, 'content', ' type="text/html" mode="escaped"');
                $articles[$ID] = tag(n . t . t . join(n . t . t, $e) . n, 'entry');
                $etags[$ID] = strtoupper(dechex(crc32($articles[$ID])));
                $dates[$ID] = $uLastMod;
            }
        }
    } elseif ($area == 'link') {
        $cfilter = $category ? "category='{$category}'" : '1';
        $limit = $limit ? $limit : 15;
        $rs = safe_rows_start("*", "txp_link", "{$cfilter} order by date desc limit {$limit}");
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                $e['title'] = tag(doSpecial($linkname), 'title');
                $content = utf8_encode(htmlspecialchars($description));
                $e['content'] = tag(n . $description . n, 'content', ' type="text/html" mode="escaped"');
                $url = preg_replace("/^\\/(.*)/", "http://{$siteurl}/\$1", $url);
                $url = preg_replace("/&((?U).*)=/", "&amp;\\1=", $url);
                $e['link'] = '<link' . relalt . texthtml . ' href="' . $url . '" />';
                $e['issued'] = tag(gmdate("Y-m-d\\TH:i:s\\Z", $date), 'issued');
                $e['modified'] = tag(gmdate("Y-m-d\\TH:i:s\\Z", $date), 'modified');
                $e['id'] = tag('tag:' . $mail_or_domain . ',' . $feed_time . ':' . $id, 'id');
//.........这里部分代码省略.........
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:atom.php

示例11: doHomeArticles

function doHomeArticles($atts, $thing = NULL)
{
    global $pretext, $prefs;
    extract($pretext);
    extract($prefs);
    $customFields = getCustomFields();
    $customlAtts = array_null(array_flip($customFields));
    //getting attributes
    $theAtts = lAtts(array('form' => 'default', 'listform' => '', 'searchform' => '', 'limit' => 10, 'category' => '', 'section' => '', 'excerpted' => '', 'author' => '', 'sort' => '', 'month' => '', 'keywords' => '', 'frontpage' => '', 'time' => 'past', 'pgonly' => 0, 'searchall' => 1, 'allowoverride' => true, 'offset' => 0, 'wraptag' => '', 'break' => '', 'label' => '', 'labeltag' => '', 'class' => '') + $customlAtts, $atts);
    $theAtts['category'] = $c ? $c : '';
    $theAtts['section'] = $s && $s != 'default' && $s != 'home' ? $s : '';
    $theAtts['author'] = !empty($author) ? $author : '';
    $theAtts['month'] = !empty($month) ? $month : '';
    $theAtts['frontpage'] = $s && $s == 'home' ? true : false;
    $theAtts['excerpted'] = '';
    extract($theAtts);
    // if a listform is specified, $thing is for doArticle() - hence ignore here.
    if (!empty($listform)) {
        $thing = '';
    }
    $pageby = empty($pageby) ? $limit : $pageby;
    $match = $search = '';
    if (!$sort) {
        $sort = 'Posted desc';
    }
    //Building query parts
    $frontpage = filterFrontPage();
    $category = join("','", doSlash(do_list($category)));
    $category = !$category ? '' : " and (Category1 IN ('" . $category . "') or Category2 IN ('" . $category . "'))";
    $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);
        }
    }
    $statusq = ' and Status = 5';
    $where = "1=1" . $statusq . $time . $search . $category . $section . $excerpted . $month . $author . $keywords . $custom . $frontpage;
    $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 0' . intval($limit));
    // get the form name
    $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:nope,项目名称:textpattern,代码行数:87,代码来源:publish.php

示例12: _textpattern


//.........这里部分代码省略.........
             } else {
                 if (array_key_exists('year', $pretext_replacement) || array_key_exists('month', $pretext_replacement) || array_key_exists('day', $pretext_replacement)) {
                     $month = '';
                     $month .= array_key_exists('year', $pretext_replacement) ? $pretext_replacement['year'] . '-' : '____-';
                     $month .= array_key_exists('month', $pretext_replacement) ? $pretext_replacement['month'] . '-' : '__-';
                     $month .= array_key_exists('day', $pretext_replacement) ? $pretext_replacement['day'] . ' ' : '__ ';
                     $pretext_replacement['month'] = $month;
                     unset($pretext_replacement['year']);
                     unset($pretext_replacement['day']);
                 }
             }
             // Section needs to be defined so we can always get a page template.
             if (!array_key_exists('s', $pretext_replacement)) {
                 if (!@$pretext_replacement['id']) {
                     $pretext_replacement['s'] = 'default';
                 } else {
                     $pretext_replacement['s'] = safe_field('Section', 'textpattern', 'ID = ' . $pretext_replacement['id']);
                 }
             }
             // Set the css and page template, otherwise we get an unknown section
             $section_settings = safe_row('css, page', 'txp_section', "name = '{$pretext_replacement['s']}' limit 1");
             $pretext_replacement['page'] = @$des_page ? $des_page : $section_settings['page'];
             $pretext_replacement['css'] = $section_settings['css'];
             $this->matched_permlink = $pretext_replacement;
             global $permlink_mode;
             if (in_array($prefs['permlink_mode'], array('id_title', 'section_id_title')) && @$pretext_replacement['pg'] && !@$pretext_replacement['id']) {
                 $pretext_replacement['id'] = '';
                 $pretext_replacement['is_article_list'] = true;
             }
             // Merge pretext_replacement with pretext
             $pretext = array_merge($pretext, $pretext_replacement);
             if (is_numeric(@$pretext['id'])) {
                 $a = safe_row('*, unix_timestamp(Posted) as uPosted, unix_timestamp(Expires) as uExpires, unix_timestamp(LastMod) as uLastMod', 'textpattern', 'ID=' . intval($pretext['id']) . ' and Status >= 4');
                 populateArticleData($a);
             }
             // Export required values to the global namespace
             foreach (array('id', 's', 'c', 'pg', 'is_article_list', 'prev_id', 'prev_title', 'next_id', 'next_title', 'css') as $key) {
                 if (array_key_exists($key, $pretext)) {
                     $GLOBALS[$key] = $pretext[$key];
                 }
             }
             if (count($this->matched_permlink) || @$mt_redirect) {
                 $pl_index = $pretext['permlink_id'];
                 if (!@$mt_redirect || !$this->pref('redirect_mt_style_links')) {
                     $pl = $this->get_permlink($pretext['permlink_id']);
                     $pl_index = @$pl['settings']['des_permlink'];
                 }
                 if (@$pretext['id'] && $pl_index) {
                     if (count($this->get_permlink($pl_index)) > 0) {
                         ob_clean();
                         global $siteurl;
                         $rs = safe_row('*, ID as thisid, unix_timestamp(Posted) as posted', 'textpattern', "ID = '{$pretext['id']}'");
                         $host = rtrim(str_replace(rtrim(doStrip($pretext['subpath']), '/'), '', hu), '/');
                         $this->redirect($host . $this->_permlinkurl($rs, PERMLINKURL, $pl_index), $this->pref('permlink_redirect_http_status'));
                     }
                 } else {
                     if ($url = @$pl['settings']['des_location']) {
                         ob_clean();
                         $this->redirect($url, $this->pref('url_redirect_http_status'));
                     }
                 }
             }
             if (@$pretext['rss']) {
                 if (@$pretext['s']) {
                     $_POST['section'] = $pretext['s'];
                 }
开发者ID:gbp,项目名称:gbp_permanent_links,代码行数:67,代码来源:gbp_permanent_links.php

示例13: render_feed

function render_feed($rs, $area, $type, $feedtitle, $atom_self_ref, $atom_id_ext)
{
    global $prefs, $thisarticle;
    extract($prefs);
    set_error_handler('tagErrorHandler');
    $atom = $type == 'atom';
    if ($atom) {
        define("t_texthtml", ' type="text/html"');
        define("t_text", ' type="text"');
        define("t_html", ' type="html"');
        define("t_xhtml", ' type="xhtml"');
        define('t_appxhtml', ' type="xhtml"');
        define("r_relalt", ' rel="alternate"');
        define("r_relself", ' rel="self"');
    } else {
        define("t_texthtml", '');
        define("t_text", '');
        define("t_html", '');
        define("t_xhtml", '');
        define('t_appxhtml', '');
        define("r_relalt", '');
        define("r_relself", '');
    }
    $dn = explode('/', $siteurl);
    $mail_or_domain = $use_mail_on_feeds_id ? eE($blog_mail_uid) : $dn[0];
    $last = fetch('unix_timestamp(val)', 'txp_prefs', 'name', 'lastmod');
    if ($atom) {
        $out[] = tag('Textpattern', 'generator', ' uri="http://textpattern.com/" version="' . $version . '"');
        $out[] = tag(htmlspecialchars($feedtitle), 'title', t_text);
        $out[] = tag(htmlspecialchars($site_slogan), 'subtitle', t_text);
        $out[] = tag(safe_strftime("w3cdtf", $last), 'updated');
        $out[] = '<link' . r_relself . ' href="' . $atom_self_ref . '" />';
        $out[] = '<link' . r_relalt . t_texthtml . ' href="' . hu . '" />';
        //Atom feeds with mail or domain name
        $out[] = tag('tag:' . $mail_or_domain . ',' . $blog_time_uid . ':' . $blog_uid . $atom_id_ext, 'id');
        $pub = safe_row("RealName, email", "txp_users", "privs=1");
        $auth[] = tag($pub['RealName'], 'name');
        $auth[] = $include_email_atom ? tag(eE($pub['email']), 'email') : '';
        $auth[] = tag(hu, 'uri');
        $out[] = tag(n . t . t . join(n . t . t, $auth) . n, 'author');
    } else {
        $out[] = tag('http://textpattern.com/?v=' . $version, 'generator');
        $out[] = tag(doSpecial($feedtitle), 'title');
        $out[] = tag(doSpecial($site_slogan), 'description');
        $out[] = tag(safe_strftime('rfc822', $last), 'pubDate');
        $out[] = tag(hu, 'link');
        $out[] = '<atom:link href="' . $atom_self_ref . '" rel="self" type="application/rss+xml" />';
    }
    $out[] = callback_event($atom ? 'atom_head' : 'rss_head');
    $articles = array();
    if (!$area or $area == 'article') {
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                populateArticleData($a);
                $cb = callback_event($atom ? 'atom_entry' : 'rss_entry');
                $e = array();
                $thisauthor = doSpecial(get_author_name($AuthorID));
                $thisauthor = tag($thisauthor, $atom ? 'name' : 'dc:creator');
                if ($atom) {
                    $thisauthor = tag(n . t . t . t . $thisauthor . n . t . t, 'author');
                }
                $e['thisauthor'] = $thisauthor;
                if ($atom) {
                    $e['issued'] = tag(safe_strftime('w3cdtf', $uPosted), 'published');
                } else {
                    $e['issued'] = tag(safe_strftime('rfc822', $uPosted), 'pubDate');
                }
                if ($atom) {
                    $e['modified'] = tag(safe_strftime('w3cdtf', $uLastMod), 'updated');
                    $e['category1'] = trim($Category1) ? '<category term="' . doSpecial($Category1) . '" />' : '';
                    $e['category2'] = trim($Category2) ? '<category term="' . doSpecial($Category2) . '" />' : '';
                }
                $count = '';
                if ($show_comment_count_in_feed && $comments_count > 0) {
                    $count = ' [' . $comments_count . ']';
                }
                $escaped_title = $atom ? htmlspecialchars($Title) : htmlspecialchars(strip_tags($Title));
                $e['title'] = tag($escaped_title . $count, 'title', t_html);
                $a['posted'] = $uPosted;
                $permlink = permlinkurl($a);
                if ($atom) {
                    $e['link'] = '<link' . r_relalt . t_texthtml . ' href="' . $permlink . '" />';
                } else {
                    $e['link'] = tag($permlink, 'link');
                }
                $e['id'] = tag('tag:' . $mail_or_domain . ',' . $feed_time . ':' . $blog_uid . '/' . $uid, $atom ? 'id' : 'guid', $atom ? '' : ' isPermaLink="false"');
                $summary = trim(replace_relative_urls(parse($thisarticle['excerpt']), $permlink));
                $content = trim(replace_relative_urls(parse($thisarticle['body']), $permlink));
                if ($syndicate_body_or_excerpt) {
                    # short feed: use body as summary if there's no excerpt
                    if (!trim($summary)) {
                        $summary = $content;
                    }
                    $content = '';
                }
                if (trim($summary)) {
                    $e['summary'] = tag(n . escape_cdata($summary) . n, $atom ? 'summary' : 'description', t_html);
                }
                if (trim($content)) {
//.........这里部分代码省略.........
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:feeds.php

示例14: rss

function rss()
{
    global $prefs, $thisarticle;
    extract($prefs);
    extract(doSlash(gpsa(array('category', 'section', 'limit', 'area'))));
    $area = gps('area');
    $sitename .= $section ? ' - ' . $section : '';
    $sitename .= $category ? ' - ' . $category : '';
    $dn = explode('/', $siteurl);
    $mail_or_domain = $use_mail_on_feeds_id ? eE($blog_mail_uid) : $dn[0];
    $out[] = tag('http://textpattern.com/?v=' . $version, 'generator');
    $out[] = tag(doSpecial($sitename), 'title');
    $out[] = tag(hu, 'link');
    $out[] = tag(doSpecial($site_slogan), 'description');
    $last = fetch('unix_timestamp(val)', 'txp_prefs', 'name', 'lastmod');
    $out[] = tag(safe_strftime('rfc822', $last), 'pubDate');
    $articles = array();
    if (!$area or $area == 'article') {
        $sfilter = $section ? "and Section = '" . $section . "'" : '';
        $cfilter = $category ? "and (Category1='" . $category . "' or Category2='" . $category . "')" : '';
        $limit = $limit ? $limit : $rss_how_many;
        $limit = intval(min($limit, max(100, $rss_how_many)));
        $frs = safe_column("name", "txp_section", "in_rss != '1'");
        if ($frs) {
            foreach ($frs as $f) {
                $query[] = "and Section != '" . doSlash($f) . "'";
            }
        }
        $query[] = $sfilter;
        $query[] = $cfilter;
        $rs = safe_rows_start("*, unix_timestamp(Posted) as uPosted, ID as thisid", "textpattern", "Status = 4 " . join(' ', $query) . "and Posted < now() order by Posted desc limit {$limit}");
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                populateArticleData($a);
                $cb = callback_event('rss_entry');
                $a['posted'] = $uPosted;
                $permlink = permlinkurl($a);
                $summary = trim(replace_relative_urls(parse($thisarticle['excerpt']), $permlink));
                $content = trim(replace_relative_urls(parse($thisarticle['body']), $permlink));
                if ($syndicate_body_or_excerpt) {
                    # short feed: use body as summary if there's no excerpt
                    if (!trim($summary)) {
                        $summary = $content;
                    }
                    $content = '';
                }
                if ($show_comment_count_in_feed) {
                    $count = $comments_count > 0 ? ' [' . $comments_count . ']' : '';
                } else {
                    $count = '';
                }
                $Title = escape_output(strip_tags($Title)) . $count;
                $thisauthor = get_author_name($AuthorID);
                $item = tag($Title, 'title') . n . (trim($summary) ? tag(n . escape_cdata($summary) . n, 'description') . n : '') . (trim($content) ? tag(n . escape_cdata($content) . n, 'content:encoded') . n : '') . tag($permlink, 'link') . n . tag(safe_strftime('rfc822', $a['posted']), 'pubDate') . n . tag(htmlspecialchars($thisauthor), 'dc:creator') . n . tag('tag:' . $mail_or_domain . ',' . $feed_time . ':' . $blog_uid . '/' . $uid, 'guid', ' isPermaLink="false"') . n . $cb;
                $articles[$ID] = tag($item, 'item');
                $etags[$ID] = strtoupper(dechex(crc32($articles[$ID])));
                $dates[$ID] = $uPosted;
            }
        }
    } elseif ($area == 'link') {
        $cfilter = $category ? "category='{$category}'" : '1';
        $limit = $limit ? $limit : $rss_how_many;
        $limit = intval(min($limit, max(100, $rss_how_many)));
        $rs = safe_rows_start("*, unix_timestamp(date) as uDate", "txp_link", "{$cfilter} order by date desc limit {$limit}");
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                $item = tag(doSpecial($linkname), 'title') . n . tag(doSpecial($description), 'description') . n . tag(doSpecial($url), 'link') . n . tag(safe_strftime('rfc822', $uDate), 'pubDate');
                $articles[$id] = tag($item, 'item');
                $etags[$id] = strtoupper(dechex(crc32($articles[$id])));
                $dates[$id] = $date;
            }
        }
    }
    //turn on compression if we aren't using it already
    if (extension_loaded('zlib') && ini_get("zlib.output_compression") == 0 && ini_get('output_handler') != 'ob_gzhandler' && !headers_sent()) {
        @ob_start("ob_gzhandler");
    }
    handle_lastmod();
    $hims = serverset('HTTP_IF_MODIFIED_SINCE');
    $imsd = $hims ? strtotime($hims) : 0;
    if (is_callable('apache_request_headers')) {
        $headers = apache_request_headers();
        if (isset($headers["A-IM"])) {
            $canaim = strpos($headers["A-IM"], "feed");
        } else {
            $canaim = false;
        }
    } else {
        $canaim = false;
    }
    $hinm = stripslashes(serverset('HTTP_IF_NONE_MATCH'));
    $cutarticles = false;
    if ($canaim !== false) {
        foreach ($articles as $id => $thing) {
            if (strpos($hinm, $etags[$id]) !== false) {
                unset($articles[$id]);
                $cutarticles = true;
                $cut_etag = true;
//.........这里部分代码省略.........
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:rss.php

示例15: rss

function rss()
{
    global $prefs, $thisarticle;
    extract($prefs);
    ob_start();
    extract(doSlash(gpsa(array('category', 'section', 'limit', 'area'))));
    $area = gps('area');
    $sitename .= $section ? ' - ' . $section : '';
    $sitename .= $category ? ' - ' . $category : '';
    $out[] = tag(doSpecial($sitename), 'title');
    $out[] = tag(hu, 'link');
    $out[] = tag(doSpecial($site_slogan), 'description');
    $articles = array();
    if (!$area or $area == 'article') {
        $sfilter = $section ? "and Section = '" . $section . "'" : '';
        $cfilter = $category ? "and (Category1='" . $category . "' or Category2='" . $category . "')" : '';
        $limit = $limit ? $limit : '5';
        $frs = safe_column("name", "txp_section", "in_rss != '1'");
        if ($frs) {
            foreach ($frs as $f) {
                $query[] = "and Section != '" . $f . "'";
            }
        }
        $query[] = $sfilter;
        $query[] = $cfilter;
        $rs = safe_rows_start("*, unix_timestamp(Posted) as uPosted, ID as thisid", "textpattern", "Status = 4 " . join(' ', $query) . "and Posted < now() order by Posted desc limit {$limit}");
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                populateArticleData($a);
                $a['posted'] = $uPosted;
                $Body = !$syndicate_body_or_excerpt ? $thisarticle['body'] : $thisarticle['excerpt'];
                $Body = !trim($Body) ? $thisarticle['body'] : $Body;
                $Body = str_replace('href="/', 'href="' . hu, $Body);
                $Body = preg_replace("/href=\\\"#(.*)\"/", "href=\"" . permlinkurl($a) . "#\\1\"", $Body);
                $Body = safe_hed($Body);
                $Body = preg_replace(array('/</', '/>/', "/'/", '/"/'), array('&lt;', '&gt;', '&#039;', '&quot;'), $Body);
                // encode bare ampersands
                $Body = preg_replace("/&(?![#0-9]+;|\\w+;)/i", '&amp;', $Body);
                $uTitle = $url_title ? $url_title : stripSpace($Title);
                $uTitle = htmlspecialchars($uTitle, ENT_NOQUOTES);
                if ($show_comment_count_in_feed) {
                    $dc = getCount('txp_discuss', "parentid={$ID} and visible=1");
                    $count = $dc > 0 ? ' [' . $dc . ']' : '';
                } else {
                    $count = '';
                }
                $Title = doSpecial($Title) . $count;
                $permlink = permlinkurl($a);
                $item = tag(strip_tags($Title), 'title') . n . tag($Body, 'description') . n . tag($permlink, 'link');
                $articles[$ID] = tag($item, 'item');
                $etags[$ID] = strtoupper(dechex(crc32($articles[$ID])));
                $dates[$ID] = $uPosted;
            }
        }
    } elseif ($area == 'link') {
        $cfilter = $category ? "category='{$category}'" : '1';
        $limit = $limit ? $limit : 15;
        $rs = safe_rows_start("*", "txp_link", "{$cfilter} order by date desc limit {$limit}");
        if ($rs) {
            while ($a = nextRow($rs)) {
                extract($a);
                $item = tag(doSpecial($linkname), 'title') . n . tag(doSpecial($description), 'description') . n . tag(doSpecial($url), 'link');
                $articles[$id] = tag($item, 'item');
                $etags[$id] = strtoupper(dechex(crc32($articles[$id])));
                $dates[$id] = $date;
            }
        }
    }
    //turn on compression if we aren't using it already
    if (extension_loaded('zlib') && ini_get("zlib.output_compression") == 0 && ini_get('output_handler') != 'ob_gzhandler' && !headers_sent()) {
        ob_start("ob_gzhandler");
    }
    $last = fetch('unix_timestamp(val)', 'txp_prefs', 'name', 'lastmod');
    $last = gmdate("D, d M Y H:i:s \\G\\M\\T", $last);
    header("Last-Modified: {$last}");
    $expires = gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 3600 * 1);
    header("Expires: {$expires}");
    $hims = serverset('HTTP_IF_MODIFIED_SINCE');
    if ($hims == $last) {
        header("HTTP/1.1 304 Not Modified");
        exit;
    }
    $imsd = @strtotime($hims);
    if (is_callable('apache_request_headers')) {
        $headers = apache_request_headers();
        if (isset($headers["A-IM"])) {
            $canaim = strpos($headers["A-IM"], "feed");
        } else {
            $canaim = false;
        }
    } else {
        $canaim = false;
    }
    $hinm = stripslashes(serverset('HTTP_IF_NONE_MATCH'));
    $cutarticles = false;
    if ($canaim !== false) {
        foreach ($articles as $id => $thing) {
            if (strpos($hinm, $etags[$id]) !== false) {
                unset($articles[$id]);
//.........这里部分代码省略.........
开发者ID:bgarrels,项目名称:textpattern,代码行数:101,代码来源:rss.php


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