本文整理汇总了PHP中Layout::getName方法的典型用法代码示例。如果您正苦于以下问题:PHP Layout::getName方法的具体用法?PHP Layout::getName怎么用?PHP Layout::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Layout
的用法示例。
在下文中一共展示了Layout::getName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: addSection
/**
* Provides ability to add a new content layout. The user will
* be redirect to the page, as if they had gone 'Edit' on the
* layout once it has been created.
*
* @return string
*/
public function addSection()
{
$this->setTitle(t('Add new layout'));
$this->setOutputType(self::_OT_CONFIG);
try {
$cloner = $this->_router->getArgument('clone');
$cloner = new Layout($cloner);
if ($cloner->exists()) {
$cloneName = $cloner->getName();
$cloneRegex = $cloner->getRegex();
$this->setTitle(sprintf(t('Clone layout "%1$s"'), $cloneName));
} else {
throw new Exception();
}
} catch (Exception $e) {
$cloneName = null;
$cloneRegex = null;
}
// Build and check form
$form = new View_Form('index/form_layout.html', 'content_layout');
$form->action($this->_router->makeUrl('content_layout', 'index', 'add'));
$form->addElement('content_layout/name', null, t('Name'), array(new Validator_Alphanumeric('-'), new Validator_Length(2, 225)));
$form->addElement('content_layout/regex', $cloneRegex, t('URL/Regex'), new Validator_Length(2, 255));
$form->addElement('content_layout/site_type', $this->_router->getDefaultSiteType(), t('Site type'), new Validator_InArray($this->_router->getSiteTypes()));
$form->addElement('content_layout/clone', $cloneName, t('Clone'), array(new Validator_Alphanumeric('-'), new Validator_Length(0, 225)));
if ($form->hasInput() && $form->isValid()) {
$fd = $form->getValues('content_layout');
// Check if we are cloning a layout
if ($fd['clone']) {
$layout = new Layout($fd['clone']);
$layout->setName($fd['site_type'] . '-' . $fd['name']);
} else {
$layout = new Layout($fd['site_type'] . '-' . $fd['name']);
}
$layout->setRegex($fd['regex']);
$path = $this->_zula->getDir('config') . '/layouts/' . $layout->getName() . '.xml';
if ($layout->save($path)) {
$this->_event->success(t('Added new content layout'));
return zula_redirect($this->_router->makeUrl('content_layout', 'manage', $layout->getName()));
}
$this->_event->error(t('Unable to save content layout'));
}
return $form->getOutput();
}
示例3: setLayout
public function setLayout(Layout $imgGen)
{
$this->imgGen = $imgGen;
$this->layout = $imgGen->getName();
}
示例4: updateOrder
/**
* Changes the order and placement of the controllers by
* post data that was submitted a long with the form
*
* @return bool
*/
protected function updateOrder()
{
try {
$layout = new Layout($this->_input->post('content_layout_name'));
// Update all of the controllers attributes
$updated = 0;
foreach ($this->_input->post('content_layout') as $cid => $details) {
try {
$cntrlr = $layout->getControllerDetails($cid);
$cntrlr['order'] = abs($details['order']);
$cntrlr['sector'] = $details['sector'];
$layout->editController($cntrlr['id'], $cntrlr);
$updated++;
} catch (Layout_ControllerNoExist $e) {
}
}
if ($layout->save()) {
if ($updated > 0) {
$this->_event->success(sprintf(t('Updated order and placement for layout "%s"'), $layout->getName()));
}
} else {
$this->_event->error(t('Unable to save layout, ensure file is writable'));
}
} catch (Input_KeyNoExist $e) {
}
return true;
}