コード例 #1
0
 /**
  * Validate form param by ajax
  *
  */
 public function validateAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $table = new Users_Model_User_Table();
     $row = null;
     if ($id = $this->_getParam('id')) {
         $row = $table->getById($id);
     }
     if (!$row) {
         $row = $table->createRow();
         $form = new Users_Form_Users_Create();
     } else {
         $form = new Users_Form_Users_Edit();
         $form->populate($row->toArray());
     }
     $form->populate($this->_getAllParams());
     if ($field = $this->_getParam('validateField')) {
         $element = $form->getElement($field);
         $response = array('success' => $element->isValid($this->_getParam($field)), 'message' => $this->view->formErrors($element->getMessages()));
     } else {
         $response = array('success' => $form->isValid($this->_getAllParams()), 'message' => $this->view->formErrors($form->getMessages()));
     }
     if (APPLICATION_ENV != 'production') {
         $response['params'] = $this->_getAllParams();
     }
     echo $this->_helper->json($response);
 }
コード例 #2
0
 /**
  * The default action - show the home page
  */
 public function editAction()
 {
     $identity = Zend_Auth::getInstance()->getIdentity();
     $users = new Users_Model_User_Table();
     $row = $users->getById($identity->id);
     $form = new Users_Form_Users_Profile();
     $form->setUser($row);
     if ($this->_request->isPost() && $form->isValid($this->_getAllParams())) {
         $row->setFromArray($form->getValues());
         $row->save();
         $row->login(false);
         $this->_helper->flashMessenger('Profile Updated');
         $this->_helper->redirector('index');
     }
     $this->view->form = $form;
 }
コード例 #3
0
ファイル: PostController.php プロジェクト: shahmaulik/zfcore
 /**
  * View post
  *
  * @throws Zend_Controller_Action_Exception
  */
 public function indexAction()
 {
     if (!($postId = $this->_getParam('id'))) {
         $this->_forwardNotFound();
         return;
     }
     $posts = new Forum_Model_Post_Table();
     if (!($post = $posts->getById($postId))) {
         $this->_forwardNotFound();
         return;
     }
     $users = new Users_Model_User_Table();
     $this->view->author = $users->getById($post->userId);
     $categories = new Categories_Model_Category_Table();
     $this->view->category = $categories->getById($post->categoryId);
     /** update count view */
     $post->incViews();
     $this->view->post = $post;
 }
コード例 #4
0
ファイル: PostController.php プロジェクト: shahmaulik/zfcore
 /**
  * View post
  *
  * @throws Zend_Controller_Action_Exception
  */
 public function indexAction()
 {
     if (!($alias = $this->_getParam('alias'))) {
         $this->_forwardNotFound();
         return;
     }
     $posts = new Blog_Model_Post_Table();
     if (!($row = $posts->getByAlias($alias))) {
         $this->_forwardNotFound();
         return;
     }
     $users = new Users_Model_User_Table();
     $this->view->user = $users->getById($row->userId);
     $categories = new Categories_Model_Category_Table();
     $this->view->category = $categories->getById($row->categoryId);
     /** update count view */
     $row->incViews();
     $this->view->row = $row;
     $this->view->page = $this->_getParam('page');
 }