Example #1
0
 public function editAction()
 {
     $form = new Blog_Form();
     $mdlBlog = new Blog_Blog();
     if ($this->_request->isPost() && $form->isValid($_POST) && $this->_request->getParam('isInsert') != true) {
         $values = $form->getValues();
         $blog = $mdlBlog->updateBlog($values['id'], $values['name']);
         $blog = $blog->page;
         //the update blog function returns the results of open
     } else {
         $id = $this->_request->getParam('id');
         $blog = $mdlBlog->find($id)->current();
         $form->populate($blog->toArray());
     }
     $form->setAction($this->baseUrl . '/mod_blog/blog/edit');
     $submit = $form->getElement('submit');
     $submit->setLabel($this->view->getTranslation('Update Blog'));
     $this->view->form = $form;
     $this->view->blog = $blog;
     $mdlPost = new Blog_Post();
     $this->view->posts = $mdlPost->getPosts($blog->id);
     $postForm = new Post_Form();
     $postFormValues['blog_id'] = $blog->id;
     $postForm->populate($postFormValues);
     $postForm->setAction($this->baseUrl . '/mod_blog/post/create');
     $submit = $postForm->getElement('submit');
     $submit->setLabel($this->view->getTranslation('Add New Post'));
     $this->view->postForm = $postForm;
     $this->view->breadcrumbs[$blog->name] = $this->baseUrl . '/mod_blog/blog/edit/id/' . $blog->id;
     $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/mod_blog/blog/delete/id/' . $blog->id;
 }
Example #2
0
 public function editAction()
 {
     $form = new Post_Form();
     $mdlBlog = new Blog_Blog();
     $mdlPost = new Blog_Post();
     if ($this->_request->isPost() && $form->isValid($_POST)) {
         $values = $form->getValues();
         $blog = $mdlPost->updatePost($values['id'], $values['title'], $values['teaser'], $values['content']);
         $post = $mdlPost->openPost($values['id']);
     } else {
         $id = $this->_request->getParam('id');
         $post = $mdlPost->openPost($id);
         $postArray['id'] = $post->id;
         $postArray['blog_id'] = $post->blogId;
         $postArray['title'] = $post->title;
         $postArray['teaser'] = $post->teaser;
         $postArray['content'] = $post->content;
         $form->populate($postArray);
     }
     $blog = $mdlBlog->find($post->blogId)->current();
     $form->setAction($this->baseUrl . '/mod_blog/post/edit');
     $submit = $form->getElement('submit');
     $submit->setLabel($this->view->getTranslation('Update Post'));
     $this->view->form = $form;
     $this->view->blog = $blog;
     $this->view->post = $post;
     $this->view->breadcrumbs[$blog->name] = $this->baseUrl . '/mod_blog/blog/edit/id/' . $blog->id;
     $this->view->breadcrumbs[$post->title] = $this->baseUrl . '/mod_blog/post/edit/id/' . $post->id;
     $this->view->toolbarLinks['Delete'] = $this->baseUrl . '/mod_blog/post/delete/id/' . $post->id;
 }