本文整理汇总了PHP中Widget::Submit方法的典型用法代码示例。如果您正苦于以下问题:PHP Widget::Submit方法的具体用法?PHP Widget::Submit怎么用?PHP Widget::Submit使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Widget
的用法示例。
在下文中一共展示了Widget::Submit方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __form
public function __form(Entry $existing = NULL)
{
$callback = Administration::instance()->getPageCallback();
$section = Section::load(sprintf('%s/%s.xml', SECTIONS, $callback['context']['section_handle']));
// Check that a layout and fields exist
if (isset($section->fields)) {
$this->alerts()->append(__('It looks like you\'re trying to create an entry. Perhaps you want fields first? <a href="%s">Click here to create some.</a>', array(ADMIN_URL . '/blueprints/sections/edit/' . $section->handle . '/')), AlertStack::ERROR);
}
$this->Form->setAttribute('enctype', 'multipart/form-data');
$this->setTitle(__('%1$s – %2$s', array(__('Symphony'), $section->name)));
$subheading = __('New Entry');
if (!is_null($existing) && $existing instanceof Entry) {
if (is_null($this->entry) || !$this->entry instanceof Entry) {
$this->entry = $existing;
}
// Grab the first field in the section
$first_field = $section->fields[0];
$field_data = (object) array();
if (!is_null($existing->data()->{$first_field->{'element-name'}})) {
$field_data = $existing->data()->{$first_field->{'element-name'}};
}
$subheading = $first_field->prepareTableValue($field_data);
}
if (is_null($this->entry) || !$this->entry instanceof Entry) {
$this->entry = new Entry();
}
$this->entry->section = $callback['context']['section_handle'];
$this->appendSubheading($subheading);
$this->entry->findDefaultFieldData();
$this->Form->appendChild(Widget::Input('MAX_FILE_SIZE', Symphony::Configuration()->core()->symphony->{'maximum-upload-size'}, 'hidden'));
// Check if there is a field to prepopulate
if (isset($_REQUEST['prepopulate']) && strlen(trim($_REQUEST['prepopulate'])) > 0) {
$field_handle = key($_REQUEST['prepopulate']);
$value = stripslashes(rawurldecode($_REQUEST['prepopulate'][$field_handle]));
$prepopulate_filter = "?prepopulate[{$field_handle}]=" . rawurlencode($value);
$this->Form->setAttribute('action', Administration::instance()->getCurrentPageURL() . $prepopulate_filter);
if (is_null($existing)) {
$this->entry->data()->{$field_handle}->value = $value;
}
}
// Status message:
if (isset($callback['flag']) and !is_null($callback['flag'])) {
switch ($callback['flag']) {
case 'saved':
$this->alerts()->append(__('Entry updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Entries</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/publish/' . $callback['context']['section_handle'] . '/new/' . $prepopulate_filter, ADMIN_URL . '/publish/' . $callback['context']['section_handle'] . '/')), AlertStack::SUCCESS);
break;
case 'created':
$this->alerts()->append(__('Entry created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Entries</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/publish/' . $callback['context']['section_handle'] . '/new/' . $prepopulate_filter, ADMIN_URL . '/publish/' . $callback['context']['section_handle'] . '/')), AlertStack::SUCCESS);
break;
}
}
// Load all the fields for this section
$section_fields = array();
foreach ($section->fields as $index => $field) {
$section_fields[$field->{'element-name'}] = $field;
}
$layout = new Layout();
if (is_array($section->layout) && !empty($section->layout)) {
foreach ($section->layout as $data) {
$column = $layout->createColumn($data->size);
foreach ($data->fieldsets as $data) {
$fieldset = $this->createElement('fieldset');
if (isset($data->collapsed) && $data->collapsed == 'yes') {
$fieldset->setAttribute('class', 'collapsed');
}
if (isset($data->name) && strlen(trim($data->name)) > 0) {
$fieldset->appendChild($this->createElement('h3', $data->name));
}
foreach ($data->fields as $handle) {
$field = $section_fields[$handle];
if (!$field instanceof Field) {
continue;
}
$div = $this->createElement('div', NULL, array('class' => trim(sprintf('field field-%s %s %s', $field->handle(), $this->__calculateWidth($field->width), $field->required == 'yes' ? 'required' : ''))));
$field->displayPublishPanel($div, isset($this->errors->{$field->{'element-name'}}) ? $this->errors->{$field->{'element-name'}} : new MessageStack(), $this->entry, $this->entry->data()->{$field->{'element-name'}});
$fieldset->appendChild($div);
}
$column->appendChild($fieldset);
}
$layout->appendTo($this->Form);
}
} else {
$this->alerts()->append(__('You haven\'t set any section layout rules. <a href="%s">Click here to define a layout.</a>', array(ADMIN_URL . '/blueprints/sections/layout/' . $section->handle . '/')), AlertStack::ERROR);
$column = $layout->createColumn(Layout::LARGE);
$fieldset = $this->createElement('fieldset');
$header = $this->createElement('h3', __('Untitled'));
$fieldset->appendChild($header);
if (is_array($section->fields)) {
foreach ($section->fields as $field) {
$div = $this->createElement('div', NULL, array('class' => trim(sprintf('field field-%s %s %s', $field->handle(), $this->__calculateWidth($field->width), $field->required == 'yes' ? 'required' : 'optional'))));
$field->displayPublishPanel($div, isset($this->errors->{$field->{'element-name'}}) ? $this->errors->{$field->{'element-name'}} : new MessageStack(), $this->entry, $this->entry->data()->{$field->{'element-name'}});
$fieldset->appendChild($div);
}
}
$column->appendChild($fieldset);
$layout->appendTo($this->Form);
}
$div = $this->createElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Submit('action[save]', $existing ? __('Save Changes') : __('Create Entry'), array('accesskey' => 's')));
//.........这里部分代码省略.........
示例2: __form
private function __form(Section $existing = null)
{
// Status message:
$callback = Administration::instance()->getPageCallback();
if (isset($callback['flag']) && !is_null($callback['flag'])) {
switch ($callback['flag']) {
case 'saved':
$this->alerts()->append(__('Section updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/sections/new/', ADMIN_URL . '/blueprints/sections/')), AlertStack::SUCCESS);
break;
case 'created':
$this->alerts()->append(__('Section created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/sections/new/', ADMIN_URL . '/blueprints/sections/')), AlertStack::SUCCESS);
break;
}
}
if (!$this->alerts()->valid() and $existing instanceof Section) {
$this->appendSyncAlert();
}
$layout = new Layout();
$left = $layout->createColumn(Layout::SMALL);
$right = $layout->createColumn(Layout::LARGE);
$this->setTitle(__('%1$s – %2$s', array(__('Symphony'), __('Sections'))));
$this->appendSubheading($existing instanceof Section ? $existing->name : __('New Section'));
if ($existing instanceof Section) {
$this->appendViewOptions();
}
// Essentials:
$fieldset = $this->createElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild($this->createElement('h3', __('Essentials')));
$label = Widget::Label('Name');
$label->appendChild(Widget::Input('essentials[name]', $this->section->name));
$fieldset->appendChild(isset($this->errors->name) ? Widget::wrapFormElementWithError($label, $this->errors->name) : $label);
$label = Widget::Label(__('Navigation Group'));
$label->appendChild($this->createElement('em', __('Created if does not exist')));
$label->appendChild(Widget::Input('essentials[navigation-group]', $this->section->{"navigation-group"}));
$fieldset->appendChild(isset($this->errors->{'navigation-group'}) ? Widget::wrapFormElementWithError($label, $this->errors->{'navigation-group'}) : $label);
$navigation_groups = Section::fetchUsedNavigationGroups();
if (is_array($navigation_groups) && !empty($navigation_groups)) {
$ul = $this->createElement('ul', NULL, array('class' => 'tags singular'));
foreach ($navigation_groups as $g) {
$ul->appendChild($this->createElement('li', $g));
}
$fieldset->appendChild($ul);
}
$input = Widget::Input('essentials[hidden-from-publish-menu]', 'yes', 'checkbox', $this->section->{'hidden-from-publish-menu'} == 'yes' ? array('checked' => 'checked') : array());
$label = Widget::Label(__('Hide this section from the Publish menu'));
$label->prependChild($input);
$fieldset->appendChild($label);
$left->appendChild($fieldset);
// Fields
$fieldset = $this->createElement('fieldset');
$fieldset->setAttribute('class', 'settings');
$fieldset->appendChild($this->createElement('h3', __('Fields')));
$div = $this->createElement('div');
$h3 = $this->createElement('h3', __('Fields'));
$h3->setAttribute('class', 'label');
$div->appendChild($h3);
$duplicator = new Duplicator(__('Add Field'));
$duplicator->setAttribute('id', 'section-duplicator');
$fields = $this->section->fields;
$types = array();
foreach (new FieldIterator() as $pathname) {
$type = preg_replace(array('/^field\\./', '/\\.php$/'), NULL, basename($pathname));
$types[$type] = Field::load($pathname);
}
// To Do: Sort this list based on how many times a field has been used across the system
uasort($types, create_function('$a, $b', 'return strnatcasecmp($a->name(), $b->name());'));
if (is_array($types)) {
foreach ($types as $type => $field) {
$defaults = array();
$field->findDefaultSettings($defaults);
$field->section = $this->section->handle;
foreach ($defaults as $key => $value) {
$field->{$key} = $value;
}
$item = $duplicator->createTemplate($field->name());
$field->displaySettingsPanel($item, new MessageStack());
}
}
if (is_array($fields)) {
foreach ($fields as $position => $field) {
$field->sortorder = $position;
if ($this->errors->{"field::{$position}"}) {
$messages = $this->errors->{"field::{$position}"};
} else {
$messages = new MessageStack();
}
$item = $duplicator->createInstance($field->name, $field->name());
$field->displaySettingsPanel($item, $messages);
}
}
$duplicator->appendTo($fieldset);
$right->appendChild($fieldset);
$layout->appendTo($this->Form);
$div = $this->createElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Submit('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : 'Create Section', array('accesskey' => 's')));
if ($this->_context[0] == 'edit') {
$div->appendChild(Widget::Submit('action[delete]', __('Delete'), array('class' => 'confirm delete', 'title' => __('Delete this section'))));
}
//.........这里部分代码省略.........
示例3: __viewExtensions
public function __viewExtensions()
{
$this->appendSubheading(__('Settings'));
$this->appendTabs();
$path = ADMIN_URL . '/symphony/system/settings/';
// No settings for extensions here
if (Extension::delegateSubscriptionCount('AddSettingsFieldsets', '/system/settings/extensions/') <= 0) {
redirect($path);
}
// Status message:
$callback = Administration::instance()->getPageCallback();
if (isset($callback['flag']) && !is_null($callback['flag'])) {
switch ($callback['flag']) {
case 'saved':
$this->alerts()->append(__('System settings saved at %1$s.', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__))), AlertStack::SUCCESS);
break;
}
}
$extension_fieldsets = array();
###
# Delegate: AddSettingsFieldsets
# Description: Add Extension settings fieldsets. Append fieldsets to the array provided. They will be distributed evenly accross the 3 columns
Extension::notify('AddSettingsFieldsets', '/system/settings/extensions/', array('fieldsets' => &$extension_fieldsets));
if (empty($extension_fieldsets)) {
redirect($path);
}
$layout = new Layout();
$left = $layout->createColumn(Layout::LARGE);
$center = $layout->createColumn(Layout::LARGE);
$right = $layout->createColumn(Layout::LARGE);
foreach ($extension_fieldsets as $index => $fieldset) {
$index += 1;
if ($index % 3 == 0) {
$right->appendChild($fieldset);
} elseif ($index % 2 == 0) {
$center->appendChild($fieldset);
} else {
$left->appendChild($fieldset);
}
}
$layout->appendTo($this->Form);
$div = $this->createElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Submit('action[save]', __('Save Changes'), array('accesskey' => 's')));
$this->Form->appendChild($div);
}
示例4: __form
//.........这里部分代码省略.........
}
$isOwner = false;
/*if(isset($_POST['fields']))
$user = $this->user;
elseif($this->_context[0] == 'edit'){
if(!$user_id = $this->_context[1]) redirect(ADMIN_URL . '/system/users/');
if(!$user = UserManager::fetchByID($user_id)){
throw new SymphonyErrorPage('The user profile you requested does not exist.', 'User not found');
}
}
else */
if ($this->_context[0] == 'edit' && $this->user->id == Administration::instance()->User->id) {
$isOwner = true;
}
$this->setTitle(__($this->_context[0] == 'new' ? '%1$s – %2$s – Untitled' : '%1$s – %2$s – %3$s', array(__('Symphony'), __('Users'), $this->user->getFullName())));
$this->appendSubheading($this->_context[0] == 'new' ? __('New User') : $this->user->getFullName());
### Essentials ###
$fieldset = Widget::Fieldset(__('Essentials'));
$label = Widget::Label(__('First Name'));
$label->appendChild(Widget::Input('fields[first_name]', $this->user->{'first_name'}));
$fieldset->appendChild(isset($this->errors->{'first-name'}) ? Widget::wrapFormElementWithError($label, $this->errors->{'first-name'}) : $label);
$label = Widget::Label(__('Last Name'));
$label->appendChild(Widget::Input('fields[last_name]', $this->user->{'last_name'}));
$fieldset->appendChild(isset($this->errors->{'last-name'}) ? Widget::wrapFormElementWithError($label, $this->errors->{'last-name'}) : $label);
$label = Widget::Label(__('Email Address'));
$label->appendChild(Widget::Input('fields[email]', $this->user->email));
$fieldset->appendChild(isset($this->errors->email) ? Widget::wrapFormElementWithError($label, $this->errors->email) : $label);
$left->appendChild($fieldset);
###
### Login Details ###
$fieldset = Widget::Fieldset(__('Login Details'));
$label = Widget::Label(__('Username'));
$label->appendChild(Widget::Input('fields[username]', $this->user->username, NULL));
$fieldset->appendChild(isset($this->errors->username) ? Widget::wrapFormElementWithError($label, $this->errors->username) : $label);
if ($this->_context[0] == 'edit') {
$fieldset->setAttribute('id', 'change-password');
}
$label = Widget::Label($this->_context[0] == 'edit' ? __('New Password') : __('Password'));
$label->appendChild(Widget::Input('fields[password]', NULL, 'password'));
$fieldset->appendChild(isset($this->errors->password) ? Widget::wrapFormElementWithError($label, $this->errors->password) : $label);
$label = Widget::Label($this->_context[0] == 'edit' ? __('Confirm New Password') : __('Confirm Password'));
if (isset($this->errors->{'password-confirmation'})) {
$label->setAttributeArray(array('class' => 'contains-error', 'title' => $this->errors->{'password-confirmation'}));
}
$label->appendChild(Widget::Input('fields[password-confirmation]', NULL, 'password'));
$fieldset->appendChild($label);
if ($this->_context[0] == 'edit') {
$fieldset->appendChild($this->createElement('p', __('Leave password fields blank to keep the current password'), array('class' => 'help')));
}
$label = Widget::Label();
$input = Widget::Input('fields[auth_token_active]', 'yes', 'checkbox');
if ($this->user->auth_token_active == 'yes') {
$input->setAttribute('checked', 'checked');
}
$temp = ADMIN_URL . '/login/' . $this->user->createAuthToken() . '/';
$label->appendChild($input);
$label->appendChild(new DOMText(__('Allow remote login via ')));
$label->appendChild(Widget::Anchor($temp, $temp));
$fieldset->appendChild($label);
$center->appendChild($fieldset);
### Default Section ###
$fieldset = Widget::Fieldset(__('Custom Preferences'));
$label = Widget::Label(__('Default Section'));
//$sections = SectionManager::instance()->fetch(NULL, 'ASC', 'sortorder');
$options = array();
//if(is_array($sections) && !empty($sections))
foreach (new SectionIterator() as $s) {
$options[] = array($s->handle, $this->user->default_section == $s->handle, $s->name);
}
$label->appendChild(Widget::Select('fields[default_section]', $options));
$fieldset->appendChild($label);
### Custom Language Selection ###
$languages = Lang::getAvailableLanguages(true);
if (count($languages > 1)) {
// Get language names
asort($languages);
$label = Widget::Label(__('Language'));
$options = array(array(NULL, is_null($this->user->language), __('System Default')));
foreach ($languages as $code => $name) {
$options[] = array($code, $code == $this->user->language, $name);
}
$select = Widget::Select('fields[language]', $options);
$label->appendChild($select);
$fieldset->appendChild($label);
$right->appendChild($fieldset);
$layout->appendTo($this->Form);
}
###
$div = $this->createElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Submit('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create User'), array('accesskey' => 's')));
if ($this->_context[0] == 'edit' && !$isOwner) {
$div->appendChild(Widget::Submit('action[delete]', __('Delete'), array('class' => 'confirm delete', 'title' => __('Delete this user'))));
}
$this->Form->appendChild($div);
}
示例5: __viewEdit
public function __viewEdit()
{
$layout = new Layout();
$left = $layout->createColumn(Layout::LARGE);
$right = $layout->createColumn(Layout::SMALL);
$this->_existing_file = isset($this->_context[1]) ? $this->_context[1] . '.xsl' : NULL;
## Handle unknown context
if (!in_array($this->_context[0], array('new', 'edit'))) {
throw new AdministrationPageNotFoundException();
}
## Edit Utility context
if ($this->_context[0] == 'edit') {
$file_abs = UTILITIES . '/' . $this->_existing_file;
$filename = $this->_existing_file;
if (!is_file($file_abs) && !is_readable($file_abs)) {
redirect(ADMIN_URL . '/blueprints/utilities/new/');
}
$fields['name'] = $filename;
$fields['template'] = file_get_contents($file_abs);
$this->Form->setAttribute('action', ADMIN_URL . '/blueprints/utilities/edit/' . $this->_context[1] . '/');
} else {
$fields['name'] = '';
$fields['template'] = file_get_contents(TEMPLATES . '/template.utility.txt');
$filename = '';
}
$formHasErrors = $this->errors->valid();
if ($formHasErrors) {
$this->alerts()->append(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), AlertStack::ERROR);
}
if (isset($this->_context[2])) {
switch ($this->_context[2]) {
case 'saved':
$this->alerts()->append(__('Utility updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/utilities/new/', ADMIN_URL . '/blueprints/utilities/')), AlertStack::SUCCESS);
break;
case 'created':
$this->alerts()->append(__('Utility created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/utilities/new/', ADMIN_URL . '/blueprints/utilities/')), AlertStack::SUCCESS);
break;
}
}
$this->setTitle(__($this->_context[0] == 'new' ? '%1$s – %2$s' : '%1$s – %2$s – %3$s', array(__('Symphony'), __('Utilities'), $filename)));
$this->appendSubheading($this->_context[0] == 'new' ? __('New Utility') : $filename);
if (!empty($_POST)) {
$fields = $_POST['fields'];
}
$fieldset = Widget::Fieldset(__('Essentials'));
$label = Widget::Label(__('Name'));
$label->appendChild(Widget::Input('fields[name]', $fields['name']));
$fieldset->appendChild(isset($this->errors->name) ? Widget::wrapFormElementWithError($label, $this->errors->name) : $label);
$label = Widget::Label(__('XSLT'));
$label->appendChild(Widget::Textarea('fields[template]', $fields['template'], array('rows' => 30, 'cols' => 80, 'class' => 'code')));
$fieldset->appendChild(isset($this->errors->template) ? Widget::wrapFormElementWithError($label, $this->errors->template) : $label);
$left->appendChild($fieldset);
$utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES);
$utilities = $utilities['filelist'];
if (is_array($utilities) && !empty($utilities)) {
$fieldset = Widget::Fieldset(__('Utilities'));
$ul = $this->createElement('ul');
$ul->setAttribute('id', 'utilities');
$i = 0;
foreach ($utilities as $util) {
$li = $this->createElement('li');
if ($i++ % 2 != 1) {
$li->setAttribute('class', 'odd');
}
$li->appendChild(Widget::Anchor($util, ADMIN_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', array()));
$ul->appendChild($li);
}
$fieldset->appendChild($ul);
$right->appendChild($fieldset);
}
$layout->appendTo($this->Form);
$div = $this->createElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Submit('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Utility'), array('accesskey' => 's')));
if ($this->_context[0] == 'edit') {
$div->appendChild(Widget::Submit('action[delete]', __('Delete'), array('class' => 'confirm delete', 'title' => __('Delete this utility'))));
}
$this->Form->appendChild($div);
}
示例6: __viewForm
protected function __viewForm()
{
// Show page alert:
if ($this->failed) {
$this->alerts()->append(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), AlertStack::ERROR);
} else {
if (!is_null($this->status)) {
switch ($this->status) {
case 'saved':
$this->alerts()->append(__('Data source updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/datasources/new/', ADMIN_URL . '/blueprints/datasources/')), AlertStack::SUCCESS);
break;
case 'created':
$this->alerts()->append(__('Data source created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/blueprints/datasources/new/', ADMIN_URL . '/blueprints/datasources/')), AlertStack::SUCCESS);
break;
}
}
}
if (!$this->datasource instanceof Datasource || is_null($this->datasource->about()->name) || strlen(trim($this->datasource->about()->name)) == 0) {
$this->setTitle(__('%1$s – %2$s – %3$s', array(__('Symphony'), __('Data Sources'), __('Untitled'))));
$this->appendSubheading(General::sanitize(__('Data Source')));
} else {
$this->setTitle(__('%1$s – %2$s – %3$s', array(__('Symphony'), __('Data Sources'), $this->datasource->about()->name)));
$this->appendSubheading(General::sanitize($this->datasource->about()->name));
}
// Track type with a hidden field:
if ($this->editing || $this->editing && isset($_POST['type'])) {
$input = Widget::Input('type', $this->type, 'hidden');
$this->Form->appendChild($input);
} else {
$header = $this->xpath('//h2')->item(0);
$options = array();
foreach ($this->types as $type) {
$options[] = array($type->class, $this->type == $type->class, $type->name);
}
usort($options, 'General::optionsSort');
$select = Widget::Select('type', $options);
$header->prependChild($select);
$header->prependChild(new DOMText(__('New')));
}
if ($this->datasource instanceof Datasource) {
$this->datasource->view($this->Form, $this->errors);
}
$actions = $this->createElement('div');
$actions->setAttribute('class', 'actions');
$save = Widget::Submit('action[save]', $this->editing ? __('Save Changes') : __('Create Data Source'), array('accesskey' => 's'));
if (!$this->datasource instanceof Datasource) {
$save->setAttribute('disabled', 'disabled');
}
$actions->appendChild($save);
if ($this->editing == true) {
$actions->appendChild(Widget::Submit('action[delete]', __('Delete'), array('class' => 'confirm delete', 'title' => __('Delete this data source'))));
}
$this->Form->appendChild($actions);
}
示例7: __form
//.........这里部分代码省略.........
$td1 = Widget::TableData(__('Global Permissions'));
$td2 = Widget::TableData(
Widget::Input('global-add', '1', 'checkbox'),
array('class' => 'checkbox')
);
$td3 = Widget::TableData(NULL, array('class' => 'edit'));
$td3->appendChild($this->createElement('p', NULL, array('class' => 'global-slider')));
$td3->appendChild($this->createElement('span', 'n/a'));
$tbody[] = Widget::TableRow(array($td1, $td2, $td3), array('class' => 'global'));
*/
foreach ($sections as $section) {
$td1 = Widget::TableData($section->name);
// TODO: Remove this and implement sliders
$td2 = Widget::TableData();
$td2->appendChild(Widget::Input("fields[permissions][publish::{$section->handle}][create]", '0', 'checkbox', array('checked' => 'checked', 'style' => 'display: none;')));
$td2->appendChild(Widget::Input("fields[permissions][publish::{$section->handle}][create]", '1', 'checkbox', (int) $this->role->permissions()->{"publish::{$section->handle}.create"} > 0 ? array('checked' => 'checked') : NULL));
$edit_level = (int) $this->role->permissions()->{"publish::{$section->handle}.edit"};
$td3 = Widget::TableData(Widget::Select("fields[permissions][publish::{$section->handle}][edit]", array(array('0', false, 'None'), array(1, $edit_level == 1, 'Own'), array(2, $edit_level == 2, 'All'))));
/*
$td2 = Widget::TableData(
Widget::Input(
"fields[permissions][{$section->handle}][create]",
'1',
'checkbox',
($permissions['create'] == 1 ? array('checked' => 'checked') : array())
),
array('class' => 'checkbox')
);
$td3 = Widget::TableData(NULL, array('class' => 'edit'));
$td3->appendChild($this->createElement('p', NULL, array('class' => 'slider')));
$td3->appendChild(
$this->createElement('span', '')
);
$td3->appendChild(
Widget::Input('fields[permissions][' . $section->handle .'][edit]',
(isset($permissions['edit']) ? $permissions['edit'] : '0'),
'hidden'
)
);
*/
$tbody[] = Widget::TableRow(array($td1, $td2, $td3));
}
$table = Widget::Table(Widget::TableHead($thead), NULL, Widget::TableBody($tbody), array('id' => 'role-permissions'));
$fieldset->appendChild($table);
$right->appendChild($fieldset);
}
/// BLUEPRINTS PERMISSIONS
$fieldset = Widget::Fieldset(__('Blueprints Permissions'));
$thead = array(array(__('Area'), 'col'), array(__('Create'), 'col', array('class' => 'checkbox')), array(__('Edit'), 'col', array('class' => 'checkbox')));
$tbody = array();
$areas = array('sections' => 'Sections', 'datasources' => 'Data Sources', 'events' => 'Events', 'views' => 'Views', 'utilities' => 'Utilities');
foreach ($areas as $key => $name) {
$td1 = Widget::TableData($name);
$td2 = Widget::TableData(Widget::Input("fields[permissions][blueprints::{$key}][create]", '1', 'checkbox', (int) $this->role->permissions()->{"blueprints::{$key}.create"} > 0 ? array('checked' => 'checked') : NULL));
$td3 = Widget::TableData(Widget::Input("fields[permissions][blueprints::{$key}][edit]", '1', 'checkbox', (int) $this->role->permissions()->{"blueprints::{$key}.edit"} > 0 ? array('checked' => 'checked') : NULL));
$tbody[] = Widget::TableRow(array($td1, $td2, $td3));
}
$table = Widget::Table(Widget::TableHead($thead), NULL, Widget::TableBody($tbody), array('id' => 'role-permissions'));
$fieldset->appendChild($table);
$middle->appendChild($fieldset);
/// SYSTEM PERMISSIONS
$fieldset = Widget::Fieldset(__('System Permissions'));
$tbody = array();
$items = array('Access Settings' => array('settings', 'access', 1), 'Access Extensions' => array('extensions', 'access', 1), 'Create New Users' => array('users', 'create', 1));
foreach ($items as $name => $item) {
list($key, $type, $level) = $item;
$td1 = Widget::TableData($name);
$td2 = Widget::TableData(Widget::Input("fields[permissions][system::{$key}][{$type}]", (string) $level, 'checkbox', (int) $this->role->permissions()->{"system::{$key}.{$type}"} > 0 ? array('checked' => 'checked') : NULL));
$tbody[] = Widget::TableRow(array($td1, $td2));
}
$user_edit_level = (int) $this->role->permissions()->{"system::users.edit"};
$td1 = Widget::TableData('Edit User Profiles');
$td2 = Widget::TableData(Widget::Select("fields[permissions][system::users][edit]", array(array('0', false, 'None'), array(1, $user_edit_level == 1, 'Own'), array(2, $user_edit_level == 2, 'All'))));
$tbody[] = Widget::TableRow(array($td1, $td2));
$td1 = Widget::TableData('Change Users Role');
$td2 = Widget::TableData(Widget::Input("fields[permissions][system::users][change-role]", (string) $level, 'checkbox', (int) $this->role->permissions()->{"system::users.change-role"} > 0 ? array('checked' => 'checked') : NULL));
$tbody[] = Widget::TableRow(array($td1, $td2));
$table = Widget::Table(NULL, NULL, Widget::TableBody($tbody), array('id' => 'role-permissions'));
$fieldset->appendChild($table);
$middle->appendChild($fieldset);
/**********
BUILD view list and set up permissions interface
**********/
$layout->appendTo($this->Form);
/** FORM ACTIONS **/
$div = $this->createElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Submit('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Role'), array('accesskey' => 's')));
if ($this->_context[0] == 'edit' && !$isOwner) {
$div->appendChild(Widget::Submit('action[delete]', __('Delete'), array('class' => 'confirm delete', 'title' => __('Delete this role'))));
}
$this->Form->appendChild($div);
}
示例8: __form
//.........这里部分代码省略.........
$title = null;
if (isset($fields['title'])) {
$title = $fields['title'];
}
if (strlen(trim($title)) == 0) {
$title = $existing instanceof View ? $existing->title : 'New View';
}
$this->setTitle(__($title ? '%1$s – %2$s – %3$s' : '%1$s – %2$s', array(__('Symphony'), __('Views'), $title)));
if ($existing instanceof View) {
$template_name = $fields['handle'];
$this->appendSubheading(__($title ? $title : __('New View')));
$viewoptions = array(__('Configuration') => Administration::instance()->getCurrentPageURL(), __('Template') => sprintf('%s/blueprints/views/template/%s/', ADMIN_URL, $view_pathname));
$this->appendViewOptions($viewoptions);
} else {
$this->appendSubheading($title ? $title : __('Untitled'));
}
// Fieldset -----------------------------------------------------------
$fieldset = Widget::Fieldset(__('Essentials'));
// Title --------------------------------------------------------------
$label = Widget::Label(__('Title'));
$label->appendChild(Widget::Input('fields[title]', isset($fields['title']) ? $fields['title'] : null));
if (isset($this->errors->title)) {
$label = Widget::wrapFormElementWithError($label, $this->errors->title);
}
$fieldset->appendChild($label);
// Type ---------------------------------------------------------------
$container = $this->createElement('div');
$label = Widget::Label(__('View Type'));
$label->appendChild(Widget::Input('fields[types]', isset($fields['types']) ? $fields['types'] : null));
if (isset($this->errors->types)) {
$label = Widget::wrapFormElementWithError($label, $this->errors->types);
}
$tags = $this->createElement('ul');
$tags->setAttribute('class', 'tags');
foreach (self::__fetchAvailableViewTypes() as $t) {
$tags->appendChild($this->createElement('li', $t));
}
$container->appendChild($label);
$container->appendChild($tags);
$fieldset->appendChild($container);
$left->appendChild($fieldset);
// Fieldset -----------------------------------------------------------
$fieldset = Widget::Fieldset(__('URL Settings'));
// Parent -------------------------------------------------------------
$label = Widget::Label(__('Parent'));
$options = array(array(NULL, false, '/'));
foreach (new ViewIterator() as $v) {
// Make sure the current view cannot be set as either a child of itself, or a child of
// another view that is already at child of the current view.
if (isset($existing) && $existing instanceof View && ($v->isChildOf($existing) || $v->guid == $existing->guid)) {
continue;
}
$options[] = array($v->path, isset($fields['parent']) and $fields['parent'] == $v->path, "/{$v->path}");
}
$label->appendChild(Widget::Select('fields[parent]', $options));
$fieldset->appendChild($label);
// Handle -------------------------------------------------------------
$label = Widget::Label(__('Handle'));
$label->appendChild(Widget::Input('fields[handle]', isset($fields['handle']) ? $fields['handle'] : null));
if (isset($this->errors->handle)) {
$label = Widget::wrapFormElementWithError($label, $this->errors->handle);
}
$fieldset->appendChild($label);
// Parameters ---------------------------------------------------------
$label = Widget::Label(__('Parameters'));
$label->appendChild(Widget::Input('fields[url-parameters]', isset($fields['url-parameters']) ? $fields['url-parameters'] : null));
$fieldset->appendChild($label);
$center->appendChild($fieldset);
// Fieldset -----------------------------------------------------------
$fieldset = Widget::Fieldset(__('Resources'));
$label = Widget::Label(__('Events'));
$options = array();
foreach (new EventIterator() as $pathname) {
$event = Event::load($pathname);
$handle = Event::getHandleFromFilename($pathname);
$options[] = array($handle, in_array($handle, (array) $fields['events']), $event->about()->name);
}
$label->appendChild(Widget::Select('fields[events][]', $options, array('multiple' => 'multiple')));
$fieldset->appendChild($label);
// Data Sources -------------------------------------------------------
$label = Widget::Label(__('Data Sources'));
$options = array();
foreach (new DataSourceIterator() as $pathname) {
$ds = DataSource::load($pathname);
$handle = DataSource::getHandleFromFilename($pathname);
$options[] = array($handle, in_array($handle, (array) $fields['data-sources']), $ds->about()->name);
}
$label->appendChild(Widget::Select('fields[data-sources][]', $options, array('multiple' => 'multiple')));
$fieldset->appendChild($label);
$right->appendChild($fieldset);
$layout->appendTo($this->Form);
// Controls -----------------------------------------------------------
$div = $this->createElement('div');
$div->setAttribute('class', 'actions');
$div->appendChild(Widget::Submit('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create View'), array('accesskey' => 's')));
if ($this->_context[0] == 'edit') {
$div->appendChild(Widget::Submit('action[delete]', __('Delete'), array('class' => 'confirm delete', 'title' => __('Delete this view'))));
}
$this->Form->appendChild($div);
}