| // +---------------------------------------------------------------------------+ // $Id$ require_once 'DB/DataObject.php'; /** * Allow users to see FAQs. * * @package faq * @author Demian Turner * @version $Revision: 1.26 $ * @since PHP 4.1 */ class FaqMgr extends SGL_Manager { function FaqMgr() { SGL::logMessage(null, PEAR_LOG_DEBUG); parent::SGL_Manager(); $this->pageTitle = 'FAQs'; $this->template = 'faqList.html'; $this->_aActionsMapping = array( 'list' => array('list'), ); // enable comments if configured if (SGL::moduleIsEnabled('comment')) { require_once SGL_MOD_DIR . '/comment/classes/CommentDAO.php'; require_once SGL_CORE_DIR . '/Delegator.php'; $dao = &CommentDAO::singleton(); $this->da = new SGL_Delegator(); $this->da->add($dao); } } function validate($req, &$input) { SGL::logMessage(null, PEAR_LOG_DEBUG); $this->validated = true; $input->error = array(); $input->pageTitle = $this->pageTitle; $input->masterTemplate = $this->masterTemplate; $input->template = $this->template; $input->action = ($req->get('action')) ? $req->get('action') : 'list'; } function _cmd_list(&$input, &$output) { SGL::logMessage(null, PEAR_LOG_DEBUG); $faqList = DB_DataObject::factory($this->conf['table']['faq']); $faqList->orderBy('item_order'); $result = $faqList->find(); $aFaqs = array(); if ($result > 0) { while ($faqList->fetch()) { $faqList->question = $faqList->question; $faqList->answer = nl2br($faqList->answer); $aFaqs[] = clone($faqList); } } $output->results = $aFaqs; // display comments? if (SGL::moduleIsEnabled('comment') && !empty($this->conf['FaqMgr']['commentsEnabled'])) { $aComments = (SGL_Session::getUid() == 1) ? $this->da->getCommentsByEntityId('faq', null, -1) : $this->da->getCommentsByEntityId('faq'); foreach ($aComments as $key => $oComment) { $oComment->isApproved = ($oComment->status_id == SGL_COMMENT_APPROVED) ? true : false; $oComment->isSpam = ($oComment->status_id == SGL_COMMENT_AKISMET_FAILED) ? true : false; $aComments[$key] = $oComment; } $output->aComments = $aComments; $output->frmRefererUrl = $_SERVER['HTTP_REFERER']; // with akismet if ($this->conf['FaqMgr']['useAkismet']) { $output->useAkismet = true; } // with captcha? if ($this->conf['FaqMgr']['useCaptcha']) { require_once SGL_CORE_DIR . '/Captcha.php'; $captcha = new SGL_Captcha(); $output->captcha = $captcha->generateCaptcha(); $output->useCaptcha = true; } // comments require approval? if ($this->conf['FaqMgr']['moderationEnabled']) { $output->moderationEnabled = true; } } } } ?>