1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
|
<?php // -*-php-*-
rcs_id('$Id: BlogJournal.php,v 1.4 2005/11/21 20:56:23 rurban Exp $');
/*
* Copyright 2005 $ThePhpWikiProgrammingTeam
*/
require_once('lib/plugin/WikiBlog.php');
/**
* BlogJournal - Include the latest blog entries for the current users blog if signed,
* or the ADMIN_USER's Blog if not.
* UnfoldSubpages for blogs.
* Rui called this plugin "JournalLast", but this was written completely independent,
* without having seen the src.
*
* @author: Reini Urban
*/
class WikiPlugin_BlogJournal
extends WikiPlugin_WikiBlog
{
function getName() {
return _("BlogJournal");
}
function getDescription() {
return _("Include latest blog entries for the current or ADMIN user");
}
function getVersion() {
return preg_replace("/[Revision: $]/", '',
"\$Revision: 1.4 $");
}
function getDefaultArguments() {
return array('count' => 7,
'user' => '',
'order' => 'reverse', // latest first
'month' => false,
'noheader' => 0
);
}
function run($dbi, $argstr, &$request, $basepage) {
if (is_array($argstr)) { // can do with array also.
$args =& $argstr;
if (!isset($args['order'])) $args['order'] = 'reverse';
} else {
$args = $this->getArgs($argstr, $request);
}
$user = $request->getUser();
if (empty($args['user'])) {
if ($user->isAuthenticated()) {
$args['user'] = $user->UserName();
} else {
$args['user'] = '';
}
}
if (!$args['user'] or $args['user'] == ADMIN_USER) {
if (BLOG_EMPTY_DEFAULT_PREFIX)
$args['user'] = ''; // "Blogs/day" pages
else
$args['user'] = ADMIN_USER; // "Admin/Blogs/day" pages
}
$parent = (empty($args['user']) ? '' : $args['user'] . SUBPAGE_SEPARATOR);
$sp = HTML::Raw('· ');
$prefix = $parent . $this->_blogPrefix('wikiblog');
if ($args['month'])
$prefix .= (SUBPAGE_SEPARATOR . $args['month']);
$pages = $dbi->titleSearch(new TextSearchQuery("^".$prefix, true, 'posix'));
$html = HTML(); $i = 0;
while (($page = $pages->next()) and $i < $args['count']) {
$rev = $page->getCurrentRevision(false);
if ($rev->get('pagetype') != 'wikiblog') continue;
$i++;
$blog = $this->_blog($rev);
//$html->pushContent(HTML::h3(WikiLink($page, 'known', $rev->get('summary'))));
$html->pushContent($rev->getTransformedContent('wikiblog'));
}
if ($args['user'] == $user->UserName())
$html->pushContent(WikiLink(_("WikiBlog"), 'known', "New entry"));
if (!$i)
return HTML(HTML::h3(_("No Blog Entries")), $html);
if (!$args['noheader'])
return HTML(HTML::h3(sprintf(_("Blog Entries for %s:"), $this->_monthTitle($args['month']))),
$html);
else
return $html;
}
};
// $Log: BlogJournal.php,v $
// Revision 1.4 2005/11/21 20:56:23 rurban
// no duplicate headline and no direct page link anymore
//
// Revision 1.3 2005/11/21 20:47:21 rurban
// fix count error
//
// Revision 1.2 2005/10/29 09:06:37 rurban
// move common blog methods to WikiBlog
//
// Revision 1.1 2005/10/29 09:03:17 rurban
// Include the latest blog entries for the current users blog if signed,
// or the ADMIN_USER's Blog if not.
// UnfoldSubpages for blogs.
// Rui called this plugin "JournalLast", but this was written completely
// independently, without having seen the src (yet).
//
// Local Variables:
// mode: php
// tab-width: 8
// c-basic-offset: 4
// c-hanging-comment-ender-p: nil
// indent-tabs-mode: nil
// End:
?>
|