コード例 #1
0
ファイル: BlogPost.php プロジェクト: bsa-git/zf-myblog
 /**
  * Constructor
  * 
  * @param Zend_Db_Adapter_Abstract $db
  * @param int $user_id
  * @param int $post_id 
  */
 public function __construct($db, $user_id, $post_id = 0)
 {
     $this->db = $db;
     $this->user = new Default_Model_DbTable_User($db);
     $this->user->load($user_id);
     $this->post = new Default_Model_DbTable_BlogPost($db);
     $this->post->loadForUser($this->user->getId(), $post_id);
     if (!$this->post->isSaved()) {
         $this->post->user_id = $this->user->getId();
     }
     parent::__construct();
 }
コード例 #2
0
 /**
  * Action - getlocations
  * get geographic coordinates
  *
  * Access to the action is possible in the following paths:
  * - /blogmanager/getlocations?user_id=1234&post_id=2345
  *
  * @return void
  */
 public function getlocationsAction()
 {
     $request = $this->getRequest();
     $post_id = $request->getPost('post_id');
     $user_id = $request->getPost('user_id');
     $ret = array('post_id' => 0);
     $post = new Default_Model_DbTable_BlogPost($this->db);
     if ($post->loadForUser($user_id, $post_id)) {
         $ret['post_id'] = $post->getId();
         $ret['locations'] = array();
         foreach ($post->locations as $location) {
             $location_id = $location->getId();
             $details_url = $this->getUrl('details', 'blogmanager') . "?post_id={$post_id}&location_id={$location_id}";
             $ret['locations'][] = array('location_id' => $location_id, 'latitude' => $location->latitude, 'longitude' => $location->longitude, 'description' => $location->description, 'content' => $location->content, 'correction' => $location->correction, 'details' => $location->details ? $details_url : '');
         }
     }
     $this->sendJson($ret);
 }