Exemplo n.º 1
0
 /**
  * Displays all layouts for a site type
  *
  * @param string $siteType
  * @return string
  */
 public function indexSection($siteType = null)
 {
     $this->setOutputType(self::_OT_CONFIG);
     // Check if there is a specified site type to manage layout for
     if (empty($siteType)) {
         try {
             $siteType = $this->_input->get('type');
         } catch (Input_KeyNoExist $e) {
             $siteType = $this->_router->getDefaultSiteType();
         }
     }
     $siteType = strtolower($siteType);
     if (!$this->_router->siteTypeExists($siteType)) {
         $this->_event->error(t('Selected site type does not exist'));
         return zula_redirect($this->_router->makeUrl('content_layout'));
     }
     $this->setTitle(sprintf(t('"%s" content layouts'), ucfirst($siteType)), false);
     // Find out what module is being used in the fpsc layout
     $fpsc = new Layout('fpsc-' . $siteType);
     $cntrlrs = $fpsc->getControllers('SC');
     $fpscCntrlr = reset($cntrlrs);
     // Get all modules for the user to choose from, with title
     $modules = array();
     foreach (Module::getModules() as $mod) {
         $modObj = new Module($mod);
         $modules[$modObj->name] = $modObj->title;
     }
     // Gather all layouts and build view
     $view = $this->loadView('index/main.html');
     $view->assign(array('SITE_TYPE' => $siteType, 'LAYOUTS' => Layout::getAll($siteType), 'FPSC_MODULE' => $fpscCntrlr['mod'], 'MODULES' => $modules));
     $view->assignHtml(array('CSRF' => $this->_input->createToken(true)));
     return $view->getOutput();
 }
Exemplo n.º 2
0
 * not enough data simply use the frontpage sc layout for the current site type
 */
Hooks::notifyAll('bootstrap_pre_request');
$dispatcher = new Dispatcher();
$dispatcher->setDisplayErrors($zula->getMode() == 'normal')->setStatusHeader($zula->getMode() != 'cli');
Registry::register('dispatcher', $dispatcher);
# For compatibility, not sure if we should still have this
$requestedUrl = $router->getParsedUrl();
if ($requestedUrl->module == null) {
    // Load data fron the fpsc (Front Page Sector Content) layout
    if ($zula->getState() == 'setup') {
        $fpsc = new Layout($zula->getDir('setup') . '/layout-fpsc.xml');
    } else {
        $fpsc = new Layout('fpsc-' . $requestedUrl->siteType);
    }
    $fpscCntrlr = $fpsc->getControllers('SC');
    $fpscCntrlr = array_shift($fpscCntrlr);
    $requestedUrl->module($fpscCntrlr['mod'])->controller($fpscCntrlr['con'])->section($fpscCntrlr['sec']);
    $dispatchConfig = (array) $fpscCntrlr['config'];
} else {
    $dispatchConfig = array();
}
if ($zula->getMode() == 'normal' && $config->get('theme/use_global')) {
    if ($zula->getState() == 'setup') {
        $themeName = 'purity';
    } else {
        $themeName = $config->get('theme/' . $router->getSiteType() . '_default');
    }
    define('_THEME_NAME', $themeName);
    try {
        $theme = new Theme($themeName);
Exemplo n.º 3
0
    /**
     * Upgrades to 2.6.0-alpha1 (2.5.60)
     *
     * @return bool|string
     */
    protected function upgradeTo_260_alpha1()
    {
        switch ($this->version) {
            case '2.5.0':
            case '2.5.1':
            case '2.5.2':
            case '2.5.3':
            case '2.5.4':
            case '2.5.5':
            case '2.5.6':
            case '2.5.50':
                foreach (array('main', 'admin') as $siteType) {
                    $layout = new Layout($siteType . '-default');
                    $sc = $layout->getControllers('SC');
                    $sc = array_shift($sc);
                    $layout->detachController($sc['id']);
                    $layout->save();
                    // Create the new FPSC (FrontPage Sector Content) layout
                    $layout = new Layout('fpsc-' . $siteType);
                    $layout->addController('SC', $sc, $sc['id']);
                    $layout->save();
                }
            case '2.5.51':
                $this->sqlFile('2.6.0-alpha1/2.5.52.sql');
            case '2.5.52':
                $this->sqlFile('2.6.0-alpha1/2.5.53.sql');
            case '2.5.53':
                $this->_config_sql->add('media/wm_position', 'bl');
            case '2.5.54':
                /**
                 * Update the ACL resources for the page changes (#247)
                 */
                $this->sqlFile('2.6.0-alpha1/2.5.55.sql');
                $addRoles = $editRoles = $manageRoles = array();
                foreach ($this->_acl->getAllRoles() as $role) {
                    if ($this->_acl->check('page_delete', $role['id'])) {
                        $editRoles[] = $role['name'];
                        $manageRoles[] = $role['name'];
                    } else {
                        if ($this->_acl->check('page_edit', $role['id'])) {
                            $editRoles[] = $role['name'];
                        }
                    }
                    if ($this->_acl->check('page_add', $role['id'])) {
                        $addRoles[] = $role['name'];
                    }
                }
                // Add in the new resources
                $query = $this->_sql->query('SELECT SUBSTRING(name, 11) AS pid FROM {PREFIX}acl_resources
													WHERE name LIKE "page-view_%"');
                foreach ($query->fetchAll(PDO::FETCH_COLUMN) as $pid) {
                    $this->_acl->allowOnly('page-edit_' . $pid, $editRoles);
                    $this->_acl->allowOnly('page-manage_' . $pid, $manageRoles);
                }
                $this->_acl->deleteResource(array('page_add', 'page_edit', 'page_delete'));
                $this->_acl->allowOnly('page_manage', $addRoles);
            case '2.5.55':
                $this->sqlFile('2.6.0-alpha1/2.5.56.sql');
            case '2.5.56':
            default:
                return '2.5.60';
        }
    }
Exemplo n.º 4
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;
 }
Exemplo n.º 5
0
 /**
  * Updates which module to use in the FPSC layout (module used in the homepage)
  *
  * @return bool
  */
 public function fpscSection()
 {
     try {
         $siteType = $this->_input->post('content_layout/siteType');
         $module = $this->_input->post('content_layout/module');
         if ($this->_router->siteTypeExists($siteType)) {
             $layout = new Layout('fpsc-' . $siteType);
             $fpscCntrlr = $layout->getControllers('SC');
             $fpscCntrlr = reset($fpscCntrlr);
             if ($module != $fpscCntrlr['mod']) {
                 // User is changing the module, remove and add new
                 $layout->detachController($fpscCntrlr['id']);
                 $cntrlrId = $layout->addController('SC', array('mod' => $module));
                 $layout->save();
                 $this->_event->success(t('Updated homepage module'));
             } else {
                 $cntrlrId = $fpscCntrlr['id'];
             }
             return zula_redirect($this->_router->makeUrl('content_layout', 'edit', 'fpsc-' . $siteType, null, array('id' => $cntrlrId)));
         } else {
             $this->_event->error(t('Selected site type does not exist'));
         }
     } catch (Input_KeyNoExist $e) {
     }
     return zula_redirect($this->_router->makeUrl('content_layout'));
 }