示例#1
0
文件: rss.php 项目: apenwarr/nitlog
function do_entry($file, $yearmonth, $day)
{
    global $months;
    global $absoluteurl;
    global $topdir;
    global $firstdate;
    $s = "";
    $monthnum = substr($yearmonth, 4, 2);
    $year = substr($yearmonth, 0, 4);
    // $title = "$months[$monthnum] $day, $year";
    if (!tags_match($file)) {
        return "";
    }
    $title = sprintf("%04d-%02d-%02d", $year, $monthnum, $day);
    $intitle = get_entrytitle($yearmonth, $day);
    $mtime = filemtime($file);
    if ($intitle) {
        $title = $intitle;
    }
    $s .= "    <item>\n" . "      <title>{$title}</title>\n" . "      <pubDate>" . date("r", $mtime) . "</pubDate>\n" . "      <link>{$absoluteurl}/{$topdir}/?m={$yearmonth}#{$day}</link>\n" . "      <guid isPermaLink=\"true\">{$absoluteurl}/{$topdir}/?m={$yearmonth}#{$day}</guid>\n" . "      <description>";
    $entrylines = do_entrycontent($yearmonth, $day);
    if (preg_match('@^\\s*<b>.*</b>\\s*$@', $entrylines[0])) {
        $entrylines[0] = "";
    }
    foreach ($entrylines as $eline) {
        $s .= escape($eline);
    }
    $s .= "      </description>\n" . "    </item>\n";
    return $s;
}
示例#2
0
文件: index.php 项目: apenwarr/nitlog
function do_entry($when, $day, $entryformatting)
{
    global $months;
    $monthnum = substr($when, 4, 2);
    $year = substr($when, 0, 4);
    $mode = 'none';
    foreach ($entryformatting as $line) {
        // check for special inline constants
        $tmp = $line;
        // $entrytitle = "$months[$monthnum] $day, $year";
        $entrytitle = sprintf("%04d-%02d-%02d", $year, $monthnum, $day);
        // $intitle = get_entrytitle( $when, $day );
        // if ( $intitle ) $entrytitle .= ": " . $intitle;
        $entrytime = date('F j, Y H:i', filemtime("{$when}/{$day}"));
        $entrylink = "?m={$when}#{$day}";
        $entryanchor = "{$day}";
        $line = preg_replace('/(?im)<## entrytitle ##>/', $entrytitle, preg_replace('/(?im)<## entrytime ##>/', $entrytime, preg_replace('/(?im)<## entrylink ##>/', $entrylink, preg_replace('/(?im)<## entryanchor ##>/', $entryanchor, $tmp))));
        // check for flow control commands
        if (substr($line, 0, 4) == '### ') {
            $tmp = trim(substr($line, 4));
            if ($tmp == 'ifentrytitle') {
                // since the title is the date, check for 00...
                if ($day == '00') {
                    $mode = 'silent';
                }
            } else {
                if ($tmp == 'endif') {
                    $mode = 'none';
                } else {
                    if ($tmp == 'entrycontent') {
                        if ($mode != 'silent') {
                            $entrylines = do_entrycontent($when, $day);
                            foreach ($entrylines as $eline) {
                                print $eline;
                            }
                        }
                    }
                }
            }
        } else {
            if ($mode != 'silent') {
                print $line;
            }
        }
    }
}