Пример #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;
 }
Пример #2
0
 public function indexAction()
 {
     $blogForm = new Blog_Form();
     $blogForm->setAction($this->baseUrl . '/mod_blog/blog/create');
     $submit = $blogForm->getElement('submit');
     $submit->setLabel($this->view->getTranslation('Create Blog'));
     $this->view->form = $blogForm;
     $mdlBlog = new Blog_Blog();
     $this->view->blogs = $mdlBlog->getBlogs();
 }