public function __construct(DatabaseObject_BlogPost $post) { parent::__construct(); $this->post = $post; $this->image = new DatabaseObject_BlogPostImage($post->getDb()); $this->image->post_id = $this->post->getId(); }
public function __construct(DatabaseObject_BlogPost $post) { parent::__construct(); $this->post = $post; $this->location = new DatabaseObject_BlogPostLocation($post->getDb()); $this->location->post_id = $this->post->getId(); }
function smarty_function_get_tag_summary($params, $smarty) { $db = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getPluginResource('db')->getDbAdapter(); $user_id = (int) $params['user_id']; $summary = DatabaseObject_BlogPost::GetTagSummary($db, $user_id); if (isset($params['assign']) && strlen($params['assign']) > 0) { $smarty->assign($params['assign'], $summary); } }
public function locationsmanageAction() { $request = $this->getRequest(); $action = $request->getPost('action'); $post_id = $request->getPost('post_id'); $ret = array('post_id' => 0); $post = new DatabaseObject_BlogPost($this->db); if ($post->loadForUser($this->identity->user_id, $post_id)) { $ret['post_id'] = $post->getId(); switch ($action) { case 'get': $ret['locations'] = array(); foreach ($post->locations as $location) { $ret['locations'][] = array('location_id' => $location->getId(), 'latitude' => $location->latitude, 'longitude' => $location->longitude, 'description' => $location->description); } break; case 'add': $fp = new FormProcessor_BlogPostLocation($post); if ($fp->process($request)) { $ret['location_id'] = $fp->location->getId(); $ret['latitude'] = $fp->location->latitude; $ret['longitude'] = $fp->location->longitude; $ret['description'] = $fp->location->description; } else { $ret['location_id'] = 0; } break; case 'delete': $location_id = $request->getPost('location_id'); $location = new DatabaseObject_BlogPostLocation($this->db); if ($location->loadForPost($post->getId(), $location_id)) { $ret['location_id'] = $location->getId(); $location->delete(); } break; case 'move': $location_id = $request->getPost('location_id'); $location = new DatabaseObject_BlogPostLocation($this->db); if ($location->loadForPost($post->getId(), $location_id)) { $location->longitude = $request->getPost('longitude'); $location->latitude = $request->getPost('latitude'); $location->save(); $ret['location_id'] = $location->getId(); $ret['latitude'] = $location->latitude; $ret['longitude'] = $location->longitude; $ret['description'] = $location->description; } break; } } $this->sendJson($ret); }
public function feedAction() { $options = array('user_id' => $this->user->getId(), 'status' => DatabaseObject_BlogPost::STATUS_LIVE, 'limit' => 10, 'order' => 'p.ts_created desc'); $recentPosts = DatabaseObject_BlogPost::GetPosts($this->db, $options); $domain = 'http://' . $this->getRequest()->getServer('HTTP_HOST'); $url = $this->getCustomUrl(array('username' => $this->user->username, 'action' => 'index'), 'user'); $feedData = array('title' => sprintf("%s's Blog", $this->user->username), 'link' => $domain . $url, 'charset' => 'UTF-8', 'entries' => array()); foreach ($recentPosts as $post) { $url = $this->getCustomUrl(array('username' => $this->user->username, 'url' => $post->url), 'post'); $entry = array('title' => $post->profile->title, 'link' => $domain . $url, 'description' => $post->getTeaser(200), 'lastUpdate' => $post->ts_created, 'category' => array()); foreach ($post->getTags() as $tag) { $entry['category'][] = array('term' => $tag); } $feedData['entries'][] = $entry; } $feed = Zend_Feed::importArray($feedData, 'atom'); $this->_helper->viewRenderer->setNoRender(); $feed->send(); }
public function suggestionAction() { $q = trim($this->getRequest()->getPost('q')); $suggestions = DatabaseObject_BlogPost::GetTagSuggestions($this->db, $q, 10); $this->sendJson($suggestions); }