コード例 #1
0
ファイル: post.php プロジェクト: R-J/elefant
$p = new blog\Post ($this->params[0]);

// post not found
if ($p->error) {
	return $this->error (404, __ ('Post not found'), '<p>' . __ ('Hmm, we can\'t seem to find the post you wanted at the moment.') . '</p>');
}

if ($p->published === 'no' && ! User::require_acl ('admin', 'blog')) {
	return $this->error (404, __ ('Post not found'), '<p>' . __ ('Hmm, we can\'t seem to find the post you wanted at the moment.') . '</p>');
}

// published if it was scheduled and it's time
if ($p->published === 'que') {
	if ($p->ts <= gmdate ('Y-m-d H:i:s')) {
		$p->published = 'yes';
		$p->put ();
		Versions::add ($p);
	} else {
	    return $this->error (404, __ ('Post not found'), '<p>' . __ ('Hmm, we can\'t seem to find the post you wanted at the moment.') . '</p>');
	}
}

$page->title = $p->title;

$post = $p->orig ();
$post->full = true;
$post->url = '/blog/post/' . $post->id . '/';
$post->fullurl = $post->url . URLify::filter ($post->title);
$post->tag_list = (strlen ($post->tags) > 0) ? explode (',', $post->tags) : array ();
if (Appconf::blog ('Blog', 'post_format') === 'html') {
	$post->body = $tpl->run_includes ($post->body);
コード例 #2
0
ファイル: wordpress.php プロジェクト: nathanieltite/elefant
    if (move_uploaded_file($_FILES['import_file']['tmp_name'], 'cache/blog_' . $_FILES['import_file']['name'])) {
        $file = 'cache/blog_' . $_FILES['import_file']['name'];
        $imported = 0;
        try {
            $posts = new SimpleXMLElement(file_get_contents($file));
            foreach ($posts->channel->item as $entry) {
                $dc = $entry->children('http://purl.org/dc/elements/1.1/');
                $content = $entry->children('http://purl.org/rss/1.0/modules/content/');
                $post = array('title' => (string) $entry->title, 'author' => (string) $dc->creator, 'ts' => gmdate('Y-m-d H:i:s', strtotime($entry->pubDate)), 'published' => $_POST['published'], 'body' => str_replace("\n", "<br />\n", (string) $content->encoded), 'tags' => '');
                $sep = '';
                for ($i = 0; $i < count($entry->category); $i++) {
                    $post['tags'] .= $sep . $entry->category[$i]->attributes()->nicename;
                    $sep = ', ';
                }
                $p = new blog\Post($post);
                if ($p->put()) {
                    Versions::add($p);
                    $imported++;
                }
            }
            echo '<p>' . i18n_getf('Imported %d posts.', $imported) . '</p>';
            echo '<p><a href="/blog/admin">' . i18n_get('Continue') . '</a></p>';
        } catch (Exception $e) {
            echo '<p><strong>' . i18n_get('Error importing file') . ': ' . $e->getMessage() . '</strong></p>';
            echo '<p><a href="/blog/admin">' . i18n_get('Back') . '</a></p>';
        }
        return;
    } else {
        echo '<p><strong>' . i18n_get('Error uploading file.') . '</strong></p>';
    }
}
コード例 #3
0
ファイル: bgsave.php プロジェクト: Selwyn-b/elefant
    $res->success = false;
    $res->error = 'Authorization required.';
    echo json_encode($res);
    return;
}
$error = false;
$o = new blog\Post($_GET['id']);
if ($o->error) {
    $error = $o->error;
} else {
    foreach ($_POST as $k => $v) {
        if ($k != $o->key && isset($o->data[$k])) {
            $o->{$k} = $v;
        }
    }
    if (!$o->put()) {
        $error = $o->error;
    } else {
        Versions::add($o);
        require_once 'apps/blog/lib/Filters.php';
        $_POST['page'] = 'blog/post/' . $o->id . '/' . URLify::filter($o->title);
        $this->hook('blog/edit', $_POST);
    }
}
$res = new StdClass();
if ($error) {
    $res->success = false;
    $res->error = $error;
} else {
    $res->success = true;
    $res->data = $_GET['id'];