Example #1
0
 /**
  * hook: module_output_bottom
  * Show comments and comments form
  *
  * @param array $msc
  * @param int $contentType
  * @param string $sector
  * @param string $title
  * @return mixed
  */
 public function hookModuleOutputBottom(array $mcs, $contentType, $sector, $title)
 {
     if ($sector == 'SC' && $contentType & Zula_ControllerBase::_OT_CONTENT_DYNAMIC && !($contentType & Zula_ControllerBase::_OT_CONFIG)) {
         $requestPath = $this->_router->getRequestPath(Router::_TRIM_ALL);
         $view = new View('display/linear.html', 'comments');
         $view->assign(array('TITLE' => $title));
         $view->assignHtml(array('COMMENTS' => $this->_model('comments', 'comments')->get($requestPath)));
         if ($this->_acl->check('comments_post')) {
             /**
              * Store the hash path as a valid comment path, then build the
              * form view and output both views
              */
             $hashPath = zula_hash($requestPath);
             $_SESSION['mod']['comments'][$hashPath] = array('path' => $requestPath, 'siteType' => $this->_router->getSiteType());
             $form = new View('form.html', 'comments');
             $form->assign(array('comments' => array('hash' => $hashPath, 'name' => $this->_session->getUser('username'), 'website' => null, 'body' => null)));
             // Antispam/Captcha
             $antispam = new Antispam();
             $form->assignHtml(array('CSRF' => $this->_input->createToken(true), 'ANTISPAM' => $antispam->create()));
             return $view->getOutput() . $form->getOutput();
         } else {
             return $view->getOutput();
         }
     }
 }
Example #2
0
 /**
  * Quickly adds in the antispam if needed
  *
  * @param bool $parseConfigTags
  * @return string
  */
 public function getOutput($parseConfigTags = false)
 {
     if ($this->antispam) {
         $antispam = new Antispam();
         if (($form = $antispam->create()) !== false) {
             $this->assignHtml(array('ANTISPAM' => $form));
         } else {
             $this->assignHtml(array('ANTISPAM' => ''));
             $this->_event->error(t('Unable to create antispam, please check the logs.', I18n::_DTD));
         }
     }
     $output = parent::getOutput($parseConfigTags);
     if ($this->csrfToken === true) {
         $output = preg_replace_callback('#</form>#i', array($this, 'csrfReplace'), $output);
     }
     return $output;
 }