Inheritance: implements Frontend\Modules\Tags\Engine\TagsInterface
示例#1
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     $categories = FrontendFaqModel::getCategories();
     $limit = $this->get('fork.settings')->get('Faq', 'overview_num_items_per_category', 10);
     foreach ($categories as $item) {
         $item['questions'] = FrontendFaqModel::getAllForCategory($item['id'], $limit);
         // no questions? next!
         if (empty($item['questions'])) {
             continue;
         }
         // add the category item including the questions
         $this->items[] = $item;
     }
 }
示例#2
0
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // validate incoming parameters
     if ($this->URL->getParameter(1) === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get by URL
     $this->record = FrontendFaqModel::getCategory($this->URL->getParameter(1));
     // anything found?
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     $this->record['full_url'] = FrontendNavigation::getURLForBlock('Faq', 'Category') . '/' . $this->record['url'];
     $this->questions = FrontendFaqModel::getAllForCategory($this->record['id']);
 }
示例#3
0
 /**
  * Parse
  */
 private function parse()
 {
     $this->tpl->assign('widgetFaqCategory', FrontendFaqModel::getCategoryById($this->data['id']));
     $this->tpl->assign('widgetFaqCategoryList', FrontendFaqModel::getAllForCategory($this->data['id'], $this->get('fork.settings')->get('Faq', 'most_read_num_items', 10)));
 }
示例#4
0
 /**
  * Parse
  */
 private function parse()
 {
     $this->tpl->assign('widgetFaqCategories', FrontendFaqModel::getCategories());
 }
示例#5
0
 /**
  * Parse
  */
 private function parse()
 {
     $this->tpl->assign('widgetFaqMostRead', FrontendFaqModel::getMostRead($this->get('fork.settings')->get('Faq', 'most_read_num_items', 10)));
 }
示例#6
0
 /**
  * Validate the form
  */
 private function validateForm()
 {
     $feedbackAllowed = isset($this->settings['allow_feedback']) && $this->settings['allow_feedback'];
     if (!$feedbackAllowed) {
         return false;
     }
     if ($this->frm->isSubmitted()) {
         // reformat data
         $useful = $this->frm->getField('useful')->getValue() == 'Y';
         // the form has been sent
         $this->tpl->assign('hideFeedbackNoInfo', $useful);
         // cleanup the submitted fields, ignore fields that were added by hackers
         $this->frm->cleanupFields();
         // validate required fields
         if (!$useful) {
             $this->frm->getField('message')->isFilled(FL::err('FeedbackIsRequired'));
         }
         if ($this->frm->isCorrect()) {
             // reformat data
             $text = $this->frm->getField('message')->getValue();
             // get feedback in session
             $previousFeedback = \SpoonSession::exists('faq_feedback_' . $this->record['id']) ? \SpoonSession::get('faq_feedback_' . $this->record['id']) : null;
             // update counters
             FrontendFaqModel::updateFeedback($this->record['id'], $useful, $previousFeedback);
             // save feedback in session
             \SpoonSession::set('faq_feedback_' . $this->record['id'], $useful);
             // answer is yes so there's no feedback
             if (!$useful) {
                 // get module setting
                 $spamFilterEnabled = isset($this->settings['spamfilter']) && $this->settings['spamfilter'];
                 // build array
                 $variables['question_id'] = $this->record['id'];
                 $variables['sentOn'] = time();
                 $variables['text'] = $text;
                 // should we check if the item is spam
                 if ($spamFilterEnabled) {
                     // the comment is spam
                     if (FrontendModel::isSpam($text, $variables['question_link'])) {
                         // set the status to spam
                         $this->redirect($this->record['full_url'] . '/' . FL::getAction('Spam'));
                     }
                 }
                 // save the feedback
                 FrontendFaqModel::saveFeedback($variables);
                 // send email on new feedback?
                 if ($this->get('fork.settings')->get('Faq', 'send_email_on_new_feedback')) {
                     // add the question
                     $variables['question'] = $this->record['question'];
                     $to = $this->get('fork.settings')->get('Core', 'mailer_to');
                     $from = $this->get('fork.settings')->get('Core', 'mailer_from');
                     $replyTo = $this->get('fork.settings')->get('Core', 'mailer_reply_to');
                     $message = Message::newInstance(sprintf(FL::getMessage('FaqFeedbackSubject'), $this->record['question']))->setFrom(array($from['email'] => $from['name']))->setTo(array($to['email'] => $to['name']))->setReplyTo(array($replyTo['email'] => $replyTo['name']))->parseHtml('/Faq/Layout/Templates/Mails/Feedback.html.twig', $variables, true);
                     $this->get('mailer')->send($message);
                 }
             }
             // trigger event
             FrontendModel::triggerEvent('Faq', 'after_add_feedback', array('comment' => $text));
             // save status
             $this->redirect($this->record['full_url'] . '/' . FL::getAction('Success'));
         }
     } else {
         // form hasn't been sent
         $this->tpl->assign('hideFeedbackNoInfo', true);
     }
 }