Ejemplo n.º 1
0
require_once ('apps/blog/lib/Filters.php');

$preview_chars = (int) Appconf::blog('Blog', 'preview_chars') ? (int) Appconf::blog('Blog', 'preview_chars') : false;

if ($data['number'] !== '') {
    $limit = $data['number'];
} else {
    $limit = 5;
}

$offset = 0;

$p = new blog\Post;
if (isset ($data['tag']) && $data['tag'] !== '') {
	$posts = $p->tagged ($data['tag'], $limit, $offset);
} else {
	$posts = $p->latest ($limit, $offset);
}
$page->count = $p->query ()->where ('published', 'yes')->count ();

if (Appconf::blog ('Blog', 'post_format') === 'markdown') {
	require_once ('apps/blog/lib/markdown.php');
}

if (! is_array ($posts) || count ($posts) === 0) {
	echo '<p>' . __ ('No posts yet... :(') . '</p>';
	if (User::require_admin ()) {
		echo '<p class="hide-in-preview"><a href="/blog/add">' . __ ('Add Blog Post') . '</a></p>';
	}
} else {
Ejemplo n.º 2
0
 * In PHP code, call it like this:
 *
 *     echo $this->run ('blog/headlines');
 *
 * In a view template, call it like this:
 *
 *     {! blog/headlines !}
 *
 * Parameters:
 *
 * - `limit` - Number of posts to show (default=10)
 * - `tag` - Show posts with this tag only (optional)
 * - `dates` - Show post dates (yes, no, default=no)
 *
 * Also available in the dynamic objects menu as "Blog: Headlines".
 */
if (!$this->internal) {
    $page->id = 'blog';
    $page->layout = $appconf['Blog']['layout'];
    $page->title = __('Latest Posts');
}
require_once 'apps/blog/lib/Filters.php';
$limit = isset($data['limit']) ? $data['limit'] : 10;
$p = new blog\Post();
if (isset($data['tag']) && $data['tag'] !== '') {
    $posts = $p->tagged($data['tag']);
} else {
    $posts = $p->headlines($limit);
}
$dates = isset($data['dates']) && $data['dates'] === 'yes' ? true : false;
echo $tpl->render('blog/headlines', array('posts' => $posts, 'dates' => $dates));
Ejemplo n.º 3
0
/**
 * Displays a list of blog posts by tag.
 */
$page->id = 'blog';
$page->layout = $appconf['Blog']['layout'];
require_once 'apps/blog/lib/Filters.php';
$preview_chars = (int) Appconf::blog('Blog', 'preview_chars') ? (int) Appconf::blog('Blog', 'preview_chars') : false;
$page->limit = 10;
$page->tag = urldecode($this->params[0]);
if (!$page->tag) {
    $this->redirect('/blog');
}
$page->num = count($this->params) > 1 && is_numeric($this->params[1]) ? $this->params[1] - 1 : 0;
$page->offset = $page->num * $page->limit;
$p = new blog\Post();
$posts = $p->tagged($page->tag, $page->limit, $page->offset);
$page->count = $p->count_by_tag($page->tag);
$page->last = $page->offset + count($posts);
$page->more = $page->count > $page->last ? true : false;
$page->next = $page->num + 2;
$footer = Appconf::blog('Blog', 'post_footer');
$footer_stripped = strip_tags($footer);
$footer = $footer && !empty($footer_stripped) ? $tpl->run_includes($footer) : false;
if (Appconf::blog('Blog', 'post_format') === 'markdown') {
    require_once 'apps/blog/lib/markdown.php';
}
foreach ($posts as $post) {
    $post->url = '/blog/post/' . $post->id . '/' . URLify::filter($post->title);
    $post->tag_list = strlen($post->tags) > 0 ? explode(',', $post->tags) : array();
    $post->social_buttons = $appconf['Social Buttons'];
    if (Appconf::blog('Blog', 'post_format') === 'html') {