getRecentPosts() public method

public getRecentPosts ( $blogID, $numPosts )
Exemplo n.º 1
0
 protected function getResource($ticket, $path)
 {
     if (false === ($session = $this->retrieveSessionData($ticket))) {
         throw new Exception('Could not load blogposts. Session error.');
     }
     $resource = array();
     $blog = new mtclient($session[0], $session[1], $session[2], $session[3]);
     if ('/' == $path) {
         $posts = $blog->getRecentPosts(1, 20);
         if (!is_array($posts)) {
             throw new Exception('Could not load blogposts from server.');
         }
         foreach ($posts as $post) {
             $basename = $post['title'] . '.html';
             $resources[] = array('basename' => $basename, 'is_collection' => false);
             $map['/' . $basename] = $post['postid'];
         }
         $session[5] = $map;
         $this->storeSessionData($ticket, $session);
     } else {
         $map = $session[5];
         if (isset($map[$path])) {
             $postid = $map[$path];
             $post = $blog->getPost($postid);
             if (!is_array($post)) {
                 throw new Exception("Could not load blogpost `{$postid}' from server.");
             }
             $resources = $post['description'];
         }
     }
     return $resources;
 }
Exemplo n.º 2
0
    $mt = new mtclient($config['plugins'][$_REQUEST['p']]['username'], $config['plugins'][$_REQUEST['p']]['password'], $host, $path);
}
// Handle a request to delete an entry before loading the others
if (isset($_POST['delete_entry']) && strlen($_POST['delete_entry'])) {
    $del = $_POST['delete_entry'];
    $good = $mt->deletePost($del, true);
    if (!$good) {
        echo "<script language=\"JavaScript\" type=\"text/javascript\">\n";
        echo "<!--\n";
        echo "alert('Can\\'t delete that post - you might not have permission to do so.');\n";
        echo "// -->\n";
        echo "</script>\n";
    }
}
$blogs = $mt->getUsersBlogs();
$entries = $mt->getRecentPosts($blogs[$_REQUEST['b']]['blogid'], 15);
// Now list out the entries available
if (is_array($entries) && sizeof($entries)) {
    foreach ($entries as $e => $entry) {
        $post_id = urlencode(isset($entry['postId']) ? $entry['postId'] : $entry['postid']);
        $title = $entry['title'];
        if ($title == '') {
            preg_match('/^<title>(.*)<\\/title>/sUi', $entry['content'], $title);
            $title = $title[1];
        }
        $title = preg_replace('/(<[^>]*>)/is', '', $title);
        $title = htmlspecialchars($title);
        $title_short = substr($title, 0, 45) . (strlen($title) > 45 ? '...' : '');
        if ($title_short == '') {
            $title_short = 'No Title (Created: ' . $entry['dateCreated'] . ')';
            $title = $title_short;