Esempio n. 1
0
/**
 * Displays a single blog post.
 */
if ($appconf['Custom Handlers']['blog/post'] != 'blog/post') {
    if (!$appconf['Custom Handlers']['blog/post']) {
        echo $this->error(404, i18n_get('Not found'), i18n_get('The page you requested could not be found.'));
        return;
    }
    echo $this->run($appconf['Custom Handlers']['blog/post'] . '/' . $this->params[0], $data);
    return;
}
$page->layout = $appconf['Blog']['post_layout'];
require_once 'apps/blog/lib/Filters.php';
$p = new blog\Post($this->params[0]);
$page->title = $appconf['Blog']['title'];
$post = $p->orig();
$post->full = true;
$post->url = '/blog/post/' . $post->id . '/' . URLify::filter($post->title);
$post->tag_list = explode(',', $post->tags);
$post->body = $tpl->run_includes($post->body);
$post->social_buttons = $appconf['Social Buttons'];
echo $tpl->render('blog/post', $post);
switch ($appconf['Blog']['comments']) {
    case 'disqus':
        echo $this->run('blog/disqus/comments', $post);
        break;
    case 'facebook':
        echo $this->run('social/facebook/comments', $post);
        break;
}
$page->add_script(sprintf('<link rel="alternate" type="application/rss+xml" href="http://%s/blog/rss" />', $_SERVER['HTTP_HOST']));
Esempio n. 2
0
 * Blog post delete handler.
 */
$this->require_acl('admin', 'admin/delete', 'blog');
$page->layout = 'admin';
if (!isset($_POST['id'])) {
    $this->redirect('/blog/admin');
}
$lock = new Lock('Blog', $_POST['id']);
if ($lock->exists()) {
    $page->title = __('Editing Locked');
    echo $tpl->render('admin/locked', $lock->info());
    return;
}
require_once 'apps/blog/lib/Filters.php';
$p = new blog\Post($_POST['id']);
$tags = $p->tags;
$title = $p->title;
$_POST = array_merge($_POST, (array) $p->orig());
if (!$p->remove()) {
    $page->title = __('An Error Occurred');
    echo __('Error Message') . ': ' . $u->error;
    return;
}
// reset blog rss cache
$cache->delete('blog_rss');
DB::execute('delete from #prefix#blog_post_tag where post_id = ?', $_POST['id']);
$_POST['page'] = 'blog/post/' . $_POST['id'] . '/' . URLify::filter($title);
$_POST['url'] = '/' . $_POST['page'];
$this->hook('blog/delete', $_POST);
$this->add_notification(__('Blog post deleted.'));
$this->redirect('/blog/admin');