public function smartBlockGenerateAction() { $request = $this->getRequest(); $params = $request->getPost(); //make sure block exists try { $bl = new Application_Model_Block($params['obj_id']); $form = new Application_Form_SmartBlockCriteria(); $form->startForm($params['obj_id']); if ($form->isValid($params)) { $result = $bl->generateSmartBlock($params['data']); $this->_helper->json->sendJson(array("result" => 0, "html" => $this->createFullResponse($bl, true, true))); } else { $this->view->obj = $bl; $this->view->id = $bl->getId(); $this->view->form = $form; $viewPath = 'playlist/smart-block.phtml'; $result['html'] = $this->view->render($viewPath); $result['result'] = 1; $this->_helper->json->sendJson($result); } } catch (BlockNotFoundException $e) { $this->playlistNotFound('block', true); } catch (Exception $e) { Logging::info($e); $this->playlistUnknownError($e); } }