Exemplo n.º 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();
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Loads all needed controllers from the layout into the correct sectors.
  *
  * @param object $layout
  * @return int
  */
 public function loadLayout(Layout $layout)
 {
     // Work out what file the modules output will be wrapped in
     $moduleWrapFile = $this->getDetail('path') . '/module_wrap.html';
     if (($style = $this->getDetail('style')) != false) {
         $tmpFile = $this->getDetail('path') . '/styles/' . $style . '/module_wrap.html';
         if (file_exists($tmpFile)) {
             $moduleWrapFile = $tmpFile;
         }
     }
     // Load all of the controllers into the correct sector
     $cntrlrCount = 0;
     foreach ($this->getSectors() as $sector) {
         foreach ($layout->getControllers($sector['id']) as $cntrlr) {
             if ($cntrlr['sector'] == 'SC') {
                 continue;
             }
             $resource = 'layout_controller_' . $cntrlr['id'];
             if (_ACL_ENABLED && ($this->_acl->resourceExists($resource) && !$this->_acl->check($resource, null, false))) {
                 continue;
             }
             $cntrlrOutput = false;
             try {
                 $module = new Module($cntrlr['mod']);
                 $ident = $cntrlr['mod'] . '::' . $cntrlr['con'] . '::' . $cntrlr['sec'];
                 $tmpCntrlr = $module->loadController($cntrlr['con'], $cntrlr['sec'], $cntrlr['config'], $sector['id']);
                 if ($tmpCntrlr['output'] !== false) {
                     /**
                      * Wrap the cntrlr in the module_wrap.html file
                      */
                     if ($cntrlr['config']['displayTitle'] === 'custom' && !empty($cntrlr['config']['customTitle'])) {
                         $title = $cntrlr['config']['customTitle'];
                     } else {
                         $title = isset($tmpCntrlr['title']) ? $tmpCntrlr['title'] : t('Oops!', I18n::_DTD);
                     }
                     $wrap = new View($moduleWrapFile);
                     $wrap->assign(array('ID' => $cntrlr['id'], 'TITLE' => $title, 'DISPLAY_TITLE' => !empty($cntrlr['config']['displayTitle']), 'WRAP_CLASS' => $cntrlr['config']['htmlWrapClass']));
                     $wrap->assignHtml(array('CONTENT' => $tmpCntrlr['output']));
                     $this->loadIntoSector($cntrlr['sector'], $wrap->getOutput());
                     ++$cntrlrCount;
                 }
             } catch (Module_NoExist $e) {
                 $this->_log->message('sector module "' . (isset($ident) ? $ident : $cntrlr['mod']) . '" does not exist', Log::L_WARNING);
             } catch (Module_ControllerNoExist $e) {
                 $this->_log->message($e->getMessage(), Log::L_WARNING);
             } catch (Module_UnableToLoad $e) {
                 // Could also be a Module_NoPermission
             }
         }
         if (!$this->isAssigned($sector['id'])) {
             $this->loadIntoSector($sector['id'], '');
         }
     }
     return $cntrlrCount;
 }