public function replyAction() { $request = $this->getRequest(); $postId = $request->getParam('postid'); if (!isset($postId)) { echo '数据传送错误!'; exit; } $userName = RFLib_Core::getModel('Answer')->getUserNameById($postId); $url = $this->view->urlFor('question/reply'); if (!empty($userName)) { $replayForm = <<<EOD <div id="ajaxbox"> <h2 id="title">评论“{$userName}”的答案</h2> <div id="content"> <div style="display:none" class="poperror-msg" id="s_error_msg"></div> <div style="display:none" class="popsuccess-msg" id="s_success_msg"></div> <form method="post" action="question/reply" id="frm_q_detail"> <input type="hidden" value="{$postId}" name="parent_id" id="parent_id" /> <div>请输入评论内容:</div> <div><textarea style="width: 400px; height: 120px;" id="rp_content" name="rp_content"></textarea></div> <div><input type="button" onclick="post_reply('{$url}');" id="bt_submit_new_reply" value="发表评论"/> <a href="javascript:closeit()">取消</a></div> </form> </div> </div> EOD; echo $replayForm; } exit; }
public function init() { //get model and service $this->_model = RFLib_Core::getModel('User'); $this->_authService = RFLib_Core::getService('Authentication'); unset($this->view->errorMsg); }
public function indexAction() { $categories = RFLib_Core::getModel('Category')->getCached('rootcategory')->getRoot(); $firstCatId = isset($categories[0]) ? $categories[0]['id'] : 1; $qModel = RFLib_Core::getModel('Question'); $showTypes = array('unsolve', 'solve', 'zero'); $request = $this->getRequest(); $categoryId = $request->getParam('catalog', $firstCatId); $show = $request->getParam('show', $showTypes[0]); $page = $request->getParam('page', 1); switch ($show) { case 'solve': $this->view->questions = $qModel->getCached($categoryId . $page)->solves($categoryId, $page, self::PAGE_ROWS); break; case 'zero': $this->view->questions = $qModel->getCached($categoryId . $page)->zeros($categoryId, $page, self::PAGE_ROWS); break; case 'unsolve': default: $this->view->questions = $qModel->getCached($categoryId . $page)->unsolves($categoryId, $page, self::PAGE_ROWS); } $this->view->selCatId = $categoryId; $this->view->questionTab = $show; $this->view->hotKeywords = RFLib_Core::getModel('Keyword')->getCached($categoryId . 'keyword')->getHots($categoryId, 50); $this->view->topUsers = RFLib_Core::getModel('User')->getCached($categoryId . 'topusers')->getTopUsers($categoryId, 50); }
public function menuAction() { $categories = RFLib_Core::getModel('Category')->getCached('rootcategory')->getRoot(); $firstCatId = isset($categories[0]) ? $categories[0]['id'] : 1; $this->view->showCatTab = true; $this->view->showAsk = true; $controller = $this->_getParam('controller'); $action = $this->_getParam('action'); if ($controller == 'customer') { $this->view->showCatTab = false; } elseif ($controller == 'question') { switch ($action) { case 'show': case 'index': $firstCatId = null; break; case 'create': $this->view->selAsk = true; $firstCatId = null; break; } } $this->view->selCatId = $this->_getParam('catalog', $firstCatId); $this->view->categories = $categories; $this->_helper->viewRenderer->setResponseSegment($this->_getParam('responseSegment')); }
public function create($data, $form = null) { if (null === $form) { return false; } if ($this->_save($form, $data)) { if ($form instanceof Wenda_Form_Question_Answer) { return RFLib_Core::getModel('Question')->setAnswers($data['question_id']); } return true; } else { return false; } }
public function init() { parent::init(); // add path to custom validators $this->addElementPrefixPath('RFLib_Validate', LIBRARY_PATH . '/RFLib/Validate/', 'validate'); //add email element $this->addElement('text', 'email', array('filters' => array('StringTrim', 'StringToLower'), 'validators' => array(array('StringLength', true, array(6, 30)), array('EmailAddress')), 'required' => true, 'label' => '邮箱')); //add display name element $this->addElement('text', 'name', array('filters' => array('StringTrim'), 'validators' => array(array('Alnum'), array('StringLength', true, array(4, 12)), array('UniqueName', false, array(RFLib_Core::getModel('User')))), 'required' => true, 'label' => '姓名')); //add password element $this->addElement('password', 'password', array('filters' => array('StringTrim'), 'validators' => array(array('StringLength', true, array(4, 128))), 'required' => true, 'label' => '密码')); //add password verification element $this->addElement('password', 'password2', array('filters' => array('StringTrim'), 'validators' => array('PasswordVerification'), 'required' => true, 'label' => '密码确认')); //add gender element $this->addElement('radio', 'gender', array('required' => true, 'label' => '姓别', 'MultiOptions' => array('boy', 'girl'))); //add city element $this->addElement('text', 'city', array('filters' => array('StringTrim', 'StringToLower'), 'validators' => array(array('StringLength', true, array(1, 20))), 'required' => false, 'label' => '居住地区')); //add userId element $this->addElement('hidden', 'id', array('filters' => array('StringTrim'), 'required' => true)); //add submit button element $this->addElement('submit', 'submit', array('required' => false, 'ignore' => true, 'label' => 'Submit')); }
public function indexAction() { $request = $this->getRequest(); $scope = $request->getParam('scope', 'bbs'); $query = $request->getParam('q'); $page = $request->getParam('page', 1); $results = RFLib_Core::getModel('Question')->getCached(str_replace(' ', '', $query . $page))->getBySearchQuery($query, $page, 50); $words = explode(' ', $query); $patterns = array(); $replacements = array(); foreach ($words as $i => $word) { $patterns[] = '/' . preg_quote($word) . '/i'; $replacements[] = '<span class="highlight">\\0</span>'; } $arr = array(); $i = 0; foreach ($results as $row) { $arr[$i] = $row; $arr[$i]['subject'] = preg_replace($patterns, $replacements, $arr[$i]['subject']); $arr[$i]['content'] = preg_replace($patterns, $replacements, $arr[$i]['content']); $i++; } $this->view->results = $arr; }
/** * Construct * * @param null|Wenda_Model_User $userModel */ public function __construct(Wenda_Model_User $userModel = null) { $this->_userModel = null === $userModel ? RFLib_Core::getModel('User') : $userModel; }
public function indexAction() { $tag = $this->_getParam('tagname'); $this->view->tagname = $tag; $this->view->questionTab = $this->_getParam('show', 'unsolve'); $this->view->questions = RFLib_Core::getModel('Question')->getAllByKeywords($tag, 1, 50); }
/** * Create quesiton data * @param array $data * @return boolean; */ public function create($data) { //get keywords $keywords = array(); foreach ($data as $key => $value) { if (false !== strpos($key, 'tag') && !empty($value)) { $keywords[] = $value; } } $keywords = RFLib_Core::getModel('Keyword')->optimize($keywords); //set default value $data['finish'] = 'N'; $data['status'] = 'A'; if ($questionId = $this->_save($data)) { $this->getTable('Question')->setToken($questionId); RFLib_Core::getModel('Keyword')->create($data['category_id'], $keywords); $data['question_id'] = $questionId; $data['keywords'] = implode(' ', $keywords); if ($this->_saveContent($data)) { return $questionId; } } return false; }