本文整理汇总了PHP中Layout::addController方法的典型用法代码示例。如果您正苦于以下问题:PHP Layout::addController方法的具体用法?PHP Layout::addController怎么用?PHP Layout::addController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layout
的用法示例。
在下文中一共展示了Layout::addController方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __call
/**
* Displays form for attaching a module to the provied
* layout name.
*
* @param string $name
* @param array $args
* @return mixed
*/
public function __call($name, $args)
{
$this->setTitle(t('Attach new module'));
$this->setOutputType(self::_OT_CONFIG);
if (!$this->_acl->check('content_layout_attach_module')) {
throw new Module_NoPermission();
}
/**
* Create the layout object and get all sectors from the theme of
* the site type of this layout
*/
$layout = new Layout(substr($name, 0, -7));
$siteType = substr($layout->getName(), 0, strpos($layout->getName(), '-'));
$theme = new Theme($this->_config->get('theme/' . $siteType . '_default'));
// Build the form with validation
$form = new View_form('attach/attach.html', 'content_layout');
$form->action($this->_router->makeUrl('content_layout', 'attach', $layout->getName()));
$form->addElement('content_layout/module', null, t('Module'), new Validator_InArray(Module::getModules()));
$form->addElement('content_layout/sector', null, t('Sector'), new Validator_InArray(array_keys($theme->getSectors())));
if ($form->hasInput() && $form->isValid()) {
$fd = $form->getValues('content_layout');
// Attach the new module to the correct sector
try {
$cntrlrId = $layout->addController($fd['sector'], array('mod' => $fd['module']));
if ($layout->save()) {
$this->_event->success(t('Successfully added module'));
return zula_redirect($this->_router->makeUrl('content_layout', 'edit', $layout->getName(), null, array('id' => $cntrlrId)));
} else {
$this->_event->error(t('Unable to save content layout file'));
}
} catch (Theme_SectorNoExist $e) {
$this->_event->error(sprintf(t('Unable to attach module. Sector "%s" does not exist'), $fd['sector']));
}
}
// Assign additional data
$form->assign(array('SECTORS' => $theme->getSectors(), 'LAYOUT' => $layout->getName()));
return $form->getOutput();
}
示例2: upgradeTo_260_alpha1
/**
* 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';
}
}
示例3: fpscSection
/**
* 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'));
}