| @@ 83-95 (lines=13) @@ | ||
| 80 | * so that the user can 'update' or even 'cancel' the edit request. |
|
| 81 | * |
|
| 82 | */ |
|
| 83 | public function getUpdateForm(){ |
|
| 84 | ||
| 85 | $commentId = Encryption::decryptIdWithDash($this->request->data("comment_id")); |
|
| 86 | ||
| 87 | if(!$this->comment->exists($commentId)){ |
|
| 88 | $this->error(404); |
|
| 89 | } |
|
| 90 | ||
| 91 | $comment = $this->comment->getById($commentId); |
|
| 92 | ||
| 93 | $commentsHTML = $this->view->render(Config::get('VIEWS_PATH') . 'posts/commentUpdateForm.php', array("comment" => $comment[0])); |
|
| 94 | echo $this->view->JSONEncode(array("data" => $commentsHTML)); |
|
| 95 | } |
|
| 96 | ||
| 97 | /** |
|
| 98 | * update comment |
|
| @@ 125-137 (lines=13) @@ | ||
| 122 | * get comment by Id |
|
| 123 | * |
|
| 124 | */ |
|
| 125 | public function getById(){ |
|
| 126 | ||
| 127 | $commentId = Encryption::decryptIdWithDash($this->request->data("comment_id")); |
|
| 128 | ||
| 129 | if(!$this->comment->exists($commentId)){ |
|
| 130 | $this->error(404); |
|
| 131 | } |
|
| 132 | ||
| 133 | $comment = $this->comment->getById($commentId); |
|
| 134 | ||
| 135 | $commentsHTML = $this->view->render(Config::get('VIEWS_PATH') . 'posts/comments.php', array("comments" => $comment)); |
|
| 136 | echo $this->view->JSONEncode(array("data" => $commentsHTML)); |
|
| 137 | } |
|
| 138 | ||
| 139 | public function delete(){ |
|
| 140 | ||
| @@ 43-56 (lines=14) @@ | ||
| 40 | echo $this->view->renderWithLayouts(Config::get('VIEWS_PATH') . "layout/default/", Config::get('VIEWS_PATH') . 'files/index.php', ['pageNum' => $pageNum]); |
|
| 41 | } |
|
| 42 | ||
| 43 | public function create(){ |
|
| 44 | ||
| 45 | $fileData = $this->request->data("file"); |
|
| 46 | ||
| 47 | $file = $this->file->create(Session::getUserId(), $fileData); |
|
| 48 | ||
| 49 | if(!$file){ |
|
| 50 | echo $this->view->renderErrors($this->file->errors()); |
|
| 51 | }else{ |
|
| 52 | ||
| 53 | $fileHTML = $this->view->render(Config::get('VIEWS_PATH') . 'files/files.php', array("files" => $file)); |
|
| 54 | echo $this->view->JSONEncode(array("data" => $fileHTML)); |
|
| 55 | } |
|
| 56 | } |
|
| 57 | ||
| 58 | public function delete(){ |
|
| 59 | ||
| @@ 65-77 (lines=13) @@ | ||
| 62 | } |
|
| 63 | } |
|
| 64 | ||
| 65 | public function getUpdateForm(){ |
|
| 66 | ||
| 67 | $newsfeedId = Encryption::decryptIdWithDash($this->request->data("newsfeed_id")); |
|
| 68 | ||
| 69 | if(!$this->newsfeed->exists($newsfeedId)){ |
|
| 70 | $this->error(404); |
|
| 71 | } |
|
| 72 | ||
| 73 | $newsfeed = $this->newsfeed->getById($newsfeedId); |
|
| 74 | ||
| 75 | $html = $this->view->render(Config::get('VIEWS_PATH') . 'newsfeed/updateForm.php', array("newsfeed" => $newsfeed[0])); |
|
| 76 | echo $this->view->JSONEncode(array("data" => $html)); |
|
| 77 | } |
|
| 78 | ||
| 79 | public function update(){ |
|
| 80 | ||
| @@ 99-111 (lines=13) @@ | ||
| 96 | } |
|
| 97 | } |
|
| 98 | ||
| 99 | public function getById(){ |
|
| 100 | ||
| 101 | $newsfeedId = Encryption::decryptIdWithDash($this->request->data("newsfeed_id")); |
|
| 102 | ||
| 103 | if(!$this->newsfeed->exists($newsfeedId)){ |
|
| 104 | $this->error(404); |
|
| 105 | } |
|
| 106 | ||
| 107 | $newsfeed = $this->newsfeed->getById($newsfeedId); |
|
| 108 | ||
| 109 | $html = $this->view->render(Config::get('VIEWS_PATH') . 'newsfeed/newsfeed.php', array("newsfeed" => $newsfeed)); |
|
| 110 | echo $this->view->JSONEncode(array("data" => $html)); |
|
| 111 | } |
|
| 112 | ||
| 113 | public function delete(){ |
|
| 114 | ||