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;
}