public function view(SymphonyDOMElement $wrapper, MessageStack $errors) { $layout = new Layout(); $left = $layout->createColumn(Layout::SMALL); $right = $layout->createColumn(Layout::LARGE); // Essentials -------------------------------------------------------- $fieldset = Widget::Fieldset(__('Essentials')); // Name: $label = Widget::Label(__('Name')); $input = Widget::Input('fields[about][name]', General::sanitize($this->about()->name)); $label->appendChild($input); if (isset($errors->{'about::name'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'about::name'}); } $fieldset->appendChild($label); $left->appendChild($fieldset); $fieldset = Widget::Fieldset(__('Content')); $label = Widget::Label(__('Source XML')); $input = Widget::Textarea('fields[xml]', $this->parameters()->{'xml'}, array('rows' => '24', 'cols' => '50', 'class' => 'code')); $label->appendChild($input); if (isset($errors->{'xml'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'xml'}); } $fieldset->appendChild($label); $right->appendChild($fieldset); $layout->appendTo($wrapper); }
public function view(SymphonyDOMElement $wrapper, MessageStack $errors) { $page = $wrapper->ownerDocument; $page->insertNodeIntoHead($page->createScriptElement(URL . '/extensions/ds_sections/assets/view.js'), 55533140); $layout = new Layout(); $left = $layout->createColumn(Layout::SMALL); $middle = $layout->createColumn(Layout::LARGE); $right = $layout->createColumn(Layout::SMALL); // Essentials -------------------------------------------------------- $fieldset = Widget::Fieldset(__('Essentials'), null, array('class' => 'settings')); // Name: $label = Widget::Label(__('Name')); $input = Widget::Input('fields[about][name]', General::sanitize($this->about()->name)); $label->appendChild($input); if (isset($errors->{'about::name'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'about::name'}); } $fieldset->appendChild($label); $left->appendChild($fieldset); // Filtering --------------------------------------------------------- $fieldset = Widget::Fieldset(__('Filtering'), '<code>{$param}</code> or <code>Value</code>', array('class' => 'settings')); // Filters $duplicator = new Duplicator(__('Add Filter')); $filters = array('id' => __('ID'), 'username' => __('Username'), 'first-name' => __('First Name'), 'last-name' => __('Last Name'), 'email' => __('Email Address')); foreach ($filters as $handle => $name) { $this->appendFilter($duplicator, $handle, $name); if (is_array($this->parameters()->filters) && array_key_exists($handle, $this->parameters()->filters)) { $this->appendFilter($duplicator, $handle, $name, $this->parameters()->filters[$handle]); } } $duplicator->appendTo($fieldset); $middle->appendChild($fieldset); // Output options ---------------------------------------------------- $fieldset = Widget::Fieldset(__('Output Options')); $select = Widget::Select('fields[included-elements][]', array(array('username', in_array('username', $this->parameters()->{"included-elements"}), 'username'), array('name', in_array('name', $this->parameters()->{"included-elements"}), 'name'), array('email-address', in_array('email-address', $this->parameters()->{"included-elements"}), 'email-address'), array('language', in_array('language', $this->parameters()->{"included-elements"}), 'language'), array('authentication-token', in_array('authentication-token', $this->parameters()->{"included-elements"}), 'authentication-token'), array('default-section', in_array('default-section', $this->parameters()->{"included-elements"}), 'default-section'))); $select->setAttribute('class', 'filtered'); $select->setAttribute('multiple', 'multiple'); $label = Widget::Label(__('Included Elements')); $label->appendChild($select); $fieldset->appendChild($label); $right->appendChild($fieldset); $layout->appendTo($wrapper); }
public function view() { $this->lists = (object) array('status' => array(Extension::STATUS_ENABLED => array(), Extension::STATUS_DISABLED => array(), Extension::STATUS_NOT_INSTALLED => array(), Extension::STATUS_REQUIRES_UPDATE => array()), 'type' => array(), 'extensions' => array()); ## Setup page $filter = $this->_context[0] == 'type' || $this->_context[0] == 'status' ? $this->_context[0] : NULL; $value = isset($this->_context[1]) ? $this->_context[1] : NULL; $this->setTitle(__('%1$s – %2$s', array(__('Symphony'), __('Extensions')))); $this->appendSubheading(__('Extensions')); $path = ADMIN_URL . '/system/extensions/'; $this->Form->setAttribute('action', Administration::instance()->getCurrentPageURL()); ## Define layout $layout = new Layout(); $left = $layout->createColumn(Layout::SMALL); $left->setAttribute('class', 'column small filters'); $right = $layout->createColumn(Layout::LARGE); ## Process extensions and build lists foreach (new ExtensionIterator() as $extension) { $pathname = Extension::getPathFromClass(get_class($extension)); $handle = Extension::getHandleFromPath($pathname); $status = Extension::status($handle); // List of extensions $this->lists->extensions[$handle] = array('object' => $extension, 'path' => $path, 'handle' => $handle, 'status' => $status); // List of extension handles grouped by status if (!is_array($this->lists->status[$status])) { $this->lists->status[$status] = array(); } $this->lists->status[$status][] = $handle; // List of extension handles grouped by type if (isset($extension->about()->type) && is_array($extension->about()->type) && !empty($extension->about()->type)) { foreach ($extension->about()->type as $t) { if (!isset($this->lists->type[$t])) { $this->lists->type[$t] = array(); } $this->lists->type[$t][] = $handle; } } } ## Build status filter menu $h4 = $this->createElement('h4', __('Filter by Status')); $left->appendChild($h4); $ul = $this->createElement('ul'); ## Main status overview $li = $this->createElement('li', Widget::Anchor(__('Overview'), $path)); if (is_null($filter)) { $li->setAttribute('class', 'active'); } $ul->appendChild($li); foreach ($this->lists->status as $status => $extensions) { if (!empty($extensions)) { $li = $this->createElement('li', Widget::Anchor(self::$status_translation[$status], "{$path}status/{$status}")); if ($value == $status) { $li->setAttribute('class', 'active'); } $count = $this->createElement('span', (string) count($extensions)); $li->appendChild($count); $ul->appendChild($li); } } $left->appendChild($ul); ## Build type filter menu $h4 = $this->createElement('h4', __('Filter by Type')); $left->appendChild($h4); $ul = $this->createElement('ul'); foreach ($this->lists->type as $type => $extensions) { if (!empty($extensions)) { $li = $this->createElement('li', Widget::Anchor(ucwords($type), "{$path}type/{$type}")); if ($value == $type) { $li->setAttribute('class', 'active'); } $count = $this->createElement('span', (string) count($extensions)); $li->appendChild($count); $ul->appendChild($li); } } $left->appendChild($ul); ## If a filter and value are specified... if (!is_null($filter) && !is_null($value)) { ## If there are extensions in the list, build the table if (isset($this->lists->{$filter}[$value])) { $right->appendChild($this->buildTable($this->lists->{$filter}[$value])); } else { ## Otherwise pass an empty array so we get the ## 'No Records Found' message $right->appendChild($this->buildTable()); } ## and append table actions $tableActions = $this->createElement('div'); $tableActions->setAttribute('class', 'actions'); $options = array(array(NULL, false, __('With Selected...')), array('enable', false, __('Enable')), array('disable', false, __('Disable')), array('uninstall', false, __('Uninstall'), 'confirm')); $tableActions->appendChild(Widget::Select('with-selected', $options)); $tableActions->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit')); $right->appendChild($tableActions); ## Otherwise, build the overview } else { ## Requires Update if (!empty($this->lists->status[Extension::STATUS_REQUIRES_UPDATE])) { $count = count($this->lists->status[Extension::STATUS_REQUIRES_UPDATE]); $div = $this->createElement('div'); $div->setAttribute('class', 'tools'); $h4 = $this->createElement('h4', __('Updates')); $message = __('%s %s %s updates available.', array($count, $count > 1 ? 'extensions' : 'extension', $count > 1 ? 'have' : 'has')); $p = $this->createElement('p', $message); $view = Widget::Anchor(__('View Details'), sprintf('%sstatus/%s/', $path, Extension::STATUS_REQUIRES_UPDATE)); $view->setAttribute('class', 'button'); $div->appendChild($view); $div->appendChild($h4); $div->appendChild($p); $right->appendChild($div); } ## Not Installed if (!empty($this->lists->status[Extension::STATUS_NOT_INSTALLED])) { $count = count($this->lists->status[Extension::STATUS_NOT_INSTALLED]); $div = $this->createElement('div'); $div->setAttribute('class', 'tools'); $h4 = $this->createElement('h4', __('Not Installed')); $message = __('%s %s %s not installed.', array($count, $count > 1 ? 'extensions' : 'extension', $count > 1 ? 'are' : 'is')); $p = $this->createElement('p', $message); $install = $this->createElement('button', __('Install All')); $install->setAttribute('class', 'create'); $view = Widget::Anchor(__('View Details'), sprintf('%sstatus/%s/', $path, Extension::STATUS_NOT_INSTALLED)); $view->setAttribute('class', 'button'); $div->appendChild($install); $div->appendChild($view); $div->appendChild($h4); $div->appendChild($p); $right->appendChild($div); } ## Disabled if (!empty($this->lists->status[Extension::STATUS_DISABLED])) { $count = count($this->lists->status[Extension::STATUS_DISABLED]); $div = $this->createElement('div'); $div->setAttribute('class', 'tools'); $h4 = $this->createElement('h4', __('Disabled')); $message = __('%s %s %s disabled.', array($count, $count > 1 ? 'extensions' : 'extension', $count > 1 ? 'are' : 'is')); $p = $this->createElement('p', $message); $install = $this->createElement('button', __('Install All')); $install->setAttribute('class', 'create'); $uninstall = $this->createElement('button', __('Uninstall All')); $uninstall->setAttribute('class', 'delete'); $view = Widget::Anchor(__('View Details'), sprintf('%sstatus/%s/', $path, Extension::STATUS_DISABLED)); $view->setAttribute('class', 'button'); $div->appendChild($install); $div->appendChild($uninstall); $div->appendChild($view); $div->appendChild($h4); $div->appendChild($p); $right->appendChild($div); } ## Nothing to show if (empty($this->lists->status[Extension::STATUS_DISABLED]) && empty($this->lists->status[Extension::STATUS_NOT_INSTALLED])) { $div = $this->createElement('div'); $div->setAttribute('class', 'tools'); $p = $this->createElement('p', __('All of your extensions are installed and enabled.')); $view = $this->createElement('button', __('View Details')); $div->appendChild($view); $div->appendChild($p); $right->appendChild($div); } } $layout->appendTo($this->Form); }
public function view(SymphonyDOMElement $wrapper, MessageStack $errors) { $page = Administration::instance()->Page; $page->insertNodeIntoHead($page->createScriptElement(URL . '/extensions/bbcww_api_client/assets/view.js')); $layout = new Layout(); $left = $layout->createColumn(Layout::SMALL); $right = $layout->createColumn(Layout::LARGE); $fieldset = Widget::Fieldset(__('Essentials')); $label = Widget::Label(__('Name')); $label->appendChild(Widget::Input('fields[name]', General::sanitize($this->about()->name))); if (isset($errors->{'about::name'})) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $errors->{'about::name'})); } else { $fieldset->appendChild($label); } $field_groups = $options = array(); foreach ($this->driver->getMemberSections() as $section) { $source = $section->{'api-source'}; $field_groups[$section->handle] = array('fields' => $section->fields, 'section' => $section); if (!isset($options[$source])) { $options[$source] = array('label' => ucwords(strtr($source, '-', ' ')), 'options' => array()); } $options[$source]['options'][] = array($section->handle, $this->parameters()->section == $section->handle, $section->name); } $label = Widget::Label(__('Section')); $label->appendChild(Widget::Select('fields[section]', $options, array('id' => 'context'))); $fieldset->appendChild($label); $label = Widget::Label(); $input = Widget::Input('fields[create-cookie]', 'yes', 'checkbox'); if ($this->parameters()->{'create-cookie'} == true) { $input->setAttribute('checked', 'checked'); } $label->appendChild($input); $label->appendChild(new DOMText(__('Keep user logged in with a cookie?'))); $fieldset->appendChild($label); $left->appendChild($fieldset); $fieldset = Widget::Fieldset(__('Overrides & Defaults'), '{$param}'); foreach ($this->driver->getMemberSections() as $section) { $this->appendDuplicator($fieldset, $section, $this->parameters()->section == $section->handle ? array('overrides' => $this->parameters()->overrides, 'defaults' => $this->parameters()->defaults) : NULL); } $right->appendChild($fieldset); $layout->appendTo($wrapper); }
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); }
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')))); } $this->Form->appendChild($div); }
public function displayJoinedPublishPanel(SymphonyDOMElement $wrapper, Section $section, array $fields, MessageStack $errors, Entry $entry) { $document = $wrapper->ownerDocument; $layout = new Layout(); foreach ($section->layout as $data) { $column = $layout->createColumn($data->size); foreach ($data->fieldsets as $data) { $fieldset = $document->createElement('fieldset'); if (isset($data->collapsed) && $data->collapsed == 'yes') { $fieldset->setAttribute('class', 'collapsed'); } if (isset($data->name) && strlen(trim($data->name)) > 0) { $fieldset->appendChild($document->createElement('h3', $data->name)); } foreach ($data->fields as $handle) { $field = $fields[$handle]; if (!$field instanceof Field) { continue; } $div = $document->createElement('div', NULL, array('class' => trim(sprintf('field field-%s %s', $field->handle(), $field->required == 'yes' ? 'required' : '')))); $field->displayPublishPanel($div, isset($errors->{$field->{'element-name'}}) ? $errors->{$field->{'element-name'}} : new MessageStack(), $entry, $entry->data()->{$field->{'element-name'}}); $fieldset->appendChild($div); } $column->appendChild($fieldset); } } $layout->appendTo($wrapper); }
public function view(SymphonyDOMElement $wrapper, MessageStack $errors) { $page = Administration::instance()->Page; $layout = new Layout(); $left = $layout->createColumn(Layout::SMALL); $right = $layout->createColumn(Layout::LARGE); // Essentials -------------------------------------------------------- $fieldset = Widget::Fieldset(__('Essentials')); // Name: $label = Widget::Label(__('Name')); $input = Widget::Input('fields[about][name]', General::sanitize($this->about()->name)); $label->appendChild($input); if (isset($errors->{'about::name'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'about::name'}); } $fieldset->appendChild($label); $left->appendChild($fieldset); // Filtering --------------------------------------------------------- $p = $page->createElement('p'); $p->setAttribute('class', 'help'); $p->appendChild($page->createElement('code', '{$param}')); $p->setValue(' or '); $p->appendChild($page->createElement('code', 'Value')); $fieldset = Widget::Fieldset(__('Filtering'), $p); // Parent View: $label = Widget::Label(__('Parent View')); $input = Widget::Input('fields[parent]', General::sanitize($this->parameters()->parent)); $label->appendChild($input); if (isset($errors->{'parent'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'parent'}); } $fieldset->appendChild($label); $ul = $page->createElement('ul'); $ul->setAttribute('class', 'tags'); foreach (new ViewIterator() as $view) { $ul->appendChild($page->createElement('li', $view->path)); } $fieldset->appendChild($ul); // View Type: $label = Widget::Label(__('View Type')); $input = Widget::Input('fields[type]', General::sanitize($this->parameters()->type)); $label->appendChild($input); if (isset($errors->{'type'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'type'}); } $fieldset->appendChild($label); $ul = $page->createElement('ul'); $ul->setAttribute('class', 'tags'); foreach (View::fetchUsedTypes() as $type) { $ul->appendChild($page->createElement('li', $type)); } $fieldset->appendChild($ul); /* if (isset($this->parameters()->parent) && !is_null($this->parameters()->parent)){ $li = new XMLElement('li'); $li->setAttribute('class', 'unique'); $li->appendChild(new XMLElement('h4', __('Parent View'))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input( 'fields[parent]', General::sanitize($this->parameters()->parent) )); $li->appendChild($label); $li->appendChild($ul); $ol->appendChild($li); } $li = new XMLElement('li'); $li->setAttribute('class', 'unique template'); $li->appendChild(new XMLElement('h4', __('Parent View'))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[parent]')); $li->appendChild($label); $li->appendChild($ul); $ol->appendChild($li); $ul = new XMLElement('ul'); $ul->setAttribute('class', 'tags'); foreach(View::fetchUsedTypes() as $type) $ul->appendChild(new XMLElement('li', $type)); if (isset($this->parameters()->type) && !is_null($this->parameters()->type)){ $li = new XMLElement('li'); $li->setAttribute('class', 'unique'); $li->appendChild(new XMLElement('h4', __('View Type'))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input( 'fields[type]', General::sanitize($this->parameters()->type) )); $li->appendChild($label); $li->appendChild($ul); $ol->appendChild($li); } $li = new XMLElement('li'); $li->setAttribute('class', 'unique template'); $li->appendChild(new XMLElement('h4', __('View Type'))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[type]')); $li->appendChild($label); $li->appendChild($ul); $ol->appendChild($li); */ $right->appendChild($fieldset); $layout->appendTo($wrapper); }
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); }
public function view(SymphonyDOMElement $wrapper, MessageStack $errors) { $page = Administration::instance()->Page; $page->insertNodeIntoHead($page->createScriptElement(URL . '/extensions/ds_sections/assets/view.js')); $layout = new Layout(); $left = $layout->createColumn(Layout::SMALL); $right = $layout->createColumn(Layout::SMALL); // Essentials -------------------------------------------------------- $fieldset = Widget::Fieldset(__('Essentials')); // Name: $label = Widget::Label(__('Name')); $input = Widget::Input('fields[about][name]', General::sanitize($this->about()->name)); $label->appendChild($input); if (isset($errors->{'about::name'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'about::name'}); } $fieldset->appendChild($label); // Section: $field_groups = $options = array(); foreach (new SectionIterator() as $section) { $field_groups[$section->handle] = array('fields' => $section->fields, 'section' => $section); $options[] = array($section->handle, $this->parameters()->section == $section->handle, $section->name); } $label = Widget::Label(__('Section')); $label->appendChild(Widget::Select('fields[section]', $options, array('id' => 'context'))); $fieldset->appendChild($label); $left->appendChild($fieldset); // Conditions --------------------------------------------------------- $fieldset = Widget::Fieldset(__('Conditions'), '<code>$param</code>'); $duplicator = new Duplicator(__('Add Condition')); //$duplicator->setAttribute('class', 'conditions-duplicator'); // Templates: $this->appendCondition($duplicator); // Instances: if (is_array($this->parameters()->conditions) && !empty($this->parameters()->conditions)) { foreach ($this->parameters()->conditions as $condition) { $this->appendCondition($duplicator, $condition); } } $duplicator->appendTo($fieldset); $left->appendChild($fieldset); // Filtering --------------------------------------------------------- $fieldset = Widget::Fieldset(__('Filtering'), '<code>{$param}</code> or <code>Value</code>'); $container_filter_results = $page->createElement('div'); $fieldset->appendChild($container_filter_results); // Redirect/404 ------------------------------------------------------ /* $label = Widget::Label(__('Required URL Parameter <i>Optional</i>')); $label->appendChild(Widget::Input('fields[required_url_param]', $this->parameters()->required_url_param)); $fieldset->appendChild($label); $p = new XMLElement('p', __('An empty result will be returned when this parameter does not have a value. Do not wrap the parameter with curly-braces.')); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); */ $left->appendChild($fieldset); // Sorting ----------------------------------------------------------- $fieldset = Widget::Fieldset(__('Sorting')); $container_sort_by = $page->createElement('div'); $fieldset->appendChild($container_sort_by); $label = Widget::Label(__('Sort Order')); $options = array(array('asc', 'asc' == $this->parameters()->{'sort-order'}, __('Acending')), array('desc', 'desc' == $this->parameters()->{'sort-order'}, __('Descending')), array('random', 'random' == $this->parameters()->{'sort-order'}, __('Random'))); $label->appendChild(Widget::Select('fields[sort-order]', $options)); $fieldset->appendChild($label); $right->appendChild($fieldset); // Limiting ---------------------------------------------------------- $fieldset = Widget::Fieldset(__('Limiting'), '<code>{$param}</code> or <code>Value</code>'); // Show a maximum of # results $label = Widget::Label(__('Limit results per page')); $input = Widget::Input('fields[limit]', $this->parameters()->limit); $label->appendChild($input); if (isset($errors->limit)) { $label = Widget::wrapFormElementWithError($label, $errors->limit); } $fieldset->appendChild($label); // Show page # of results: $label = Widget::Label(__('Show page of results')); $input = Widget::Input('fields[page]', $this->parameters()->page); $label->appendChild($input); if (isset($errors->page)) { $label = Widget::wrapFormElementWithError($label, $errors->page); } $fieldset->appendChild($label); // Can redirect on empty: $fieldset->appendChild(Widget::Input('fields[redirect-404-on-empty]', 'no', 'hidden')); $label = Widget::Label(__('Redirect to 404 page when no results are found')); $input = Widget::Input('fields[redirect-404-on-empty]', 'yes', 'checkbox'); if ($this->parameters()->{'redirect-404-on-empty'} == true) { $input->setAttribute('checked', 'checked'); } $label->prependChild($input); $fieldset->appendChild($label); $right->appendChild($fieldset); // Output options ---------------------------------------------------- $fieldset = Widget::Fieldset(__('Output Options')); //$container_parameter_output = $page->createElement('div'); $context_content = $page->createElement('div'); $fieldset->appendChild($context_content); $fieldset->appendChild(Widget::Input('fields[append-pagination]', 'no', 'hidden')); $label = Widget::Label(__('Append pagination data')); $input = Widget::Input('fields[append-pagination]', 'yes', 'checkbox'); if ($this->parameters()->{'append-pagination'} == true) { $input->setAttribute('checked', 'checked'); } $label->prependChild($input); $fieldset->appendChild($label); $fieldset->appendChild(Widget::Input('fields[append-sorting]', 'no', 'hidden')); $label = Widget::Label(__('Append sorting data')); $input = Widget::Input('fields[append-sorting]', 'yes', 'checkbox'); if ($this->parameters()->{'append-sorting'} == true) { $input->setAttribute('checked', 'checked'); } $label->prependChild($input); $fieldset->appendChild($label); /* $fieldset->appendChild(Widget::Input('fields[append-associated-entry-count]', 'no', 'hidden')); $label = Widget::Label(__('Append entry count')); $input = Widget::Input('fields[append-associated-entry-count]', 'yes', 'checkbox'); if ($this->parameters()->{'append-associated-entry-count'} == true) { $input->setAttribute('checked', 'checked'); } $label->prependChild($input); $fieldset->appendChild($label); $label = Widget::Label(__('HTML-encode text')); $input = Widget::Input('fields[html-encode]', 'yes', 'checkbox'); if ($this->parameters()->{'html-encode'} == true) { $input->setAttribute('checked', 'checked'); } $label->prependChild($input); $fieldset->appendChild($label); */ $right->appendChild($fieldset); $layout->appendTo($wrapper); // Build contexts ---------------------------------------------------- foreach ($field_groups as $section_handle => $section_data) { $section = $section_data['section']; $section_active = $this->parameters()->section == $section_handle; $filter_data = $this->parameters()->filters; $fields = array(); $duplicator = new Duplicator(__('Add Filter')); $duplicator->addClass('filtering-duplicator context context-' . $section_handle); // System ID template: $item = $duplicator->createTemplate(__('System ID')); $type_label = Widget::Label(__('Type')); $type_label->setAttribute('class', 'small'); $type_label->appendChild(Widget::Select('type', array(array('is', false, 'Is'), array('is-not', false, 'Is not')))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('value')); $label->appendChild(Widget::Input('element-name', 'system:id', 'hidden')); $item->appendChild(Widget::Group($type_label, $label)); // Field templates: if (is_array($section_data['fields']) && !empty($section_data['fields'])) { foreach ($section_data['fields'] as $field) { if (!$field->canFilter()) { continue; } $element_name = $field->{'element-name'}; $fields[$element_name] = $field; $item = $duplicator->createTemplate($field->name, $field->name()); $field->displayDatasourceFilterPanel($item, null, null); } } // Field isntances: if (is_array($filter_data) && !empty($filter_data)) { foreach ($filter_data as $filter) { if (isset($fields[$filter['element-name']])) { $element_name = $filter['element-name']; $field = $fields[$element_name]; $item = $duplicator->createInstance($field->{'publish-label'}, $field->name()); $field->displayDatasourceFilterPanel($item, $filter, $errors->{$element_name}); } else { if ($filter['element-name'] == 'system:id') { $item = $duplicator->createInstance(__('System ID')); $type_label = Widget::Label(__('Type')); $type_label->appendChild(Widget::Select('type', array(array('is', false, 'Is'), array('is-not', $filter['type'] == 'is-not', 'Is not')))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input("value", $filter['value'])); $label->appendChild(Widget::Input('element-name', 'system:id', 'hidden')); $item->appendChild(Widget::Group($type_label, $label)); } } } } $duplicator->appendTo($container_filter_results); // Select boxes: $sort_by_options = array(array('system:id', $section_active and $this->parameters()->{'sort-field'} == 'system:id', __('System ID')), array('system:creation-date', $section_active and $this->parameters()->{'sort-field'} == 'system:creation-date', __('System Creation Date')), array('system:modification-date', $section_active and $this->parameters()->{'sort-field'} == 'system:modification-date', __('System Modification Date'))); $options_parameter_output = array(array('system:id', $section_active and in_array('system:id', $this->parameters()->{'parameter-output'}), __('$ds-?.system.id')), array('system:creation-date', $section_active and in_array('system:creation-date', $this->parameters()->{'parameter-output'}), __('$ds-?.system.creation-date')), array('system:modification-date', $section_active and in_array('system:modification-date', $this->parameters()->{'parameter-output'}), __('$ds-?.system.modification-date')), array('system:user', $section_active and in_array('system:user', $this->parameters()->{'parameter-output'}), __('$ds-?.system.user'))); $included_elements_options = array(array('system:creation-date', $section_active and in_array('system:creation-date', $this->parameters()->{'included-elements'}), __('System Creation Date')), array('system:modification-date', $section_active and in_array('system:modification-date', $this->parameters()->{'included-elements'}), __('System Modification Date')), array('system:user', $section_active and in_array('system:user', $this->parameters()->{'included-elements'}), __('System User'))); if (is_array($section_data['fields']) && !empty($section_data['fields'])) { foreach ($section_data['fields'] as $field) { $field_handle = $field->{'element-name'}; $field_label = $field->{'publish-label'}; $modes = $field->fetchIncludableElements(); if ($field->isSortable()) { $sort_by_options[] = array($field_handle, $section_active and $field_handle == $this->parameters()->{'sort-field'}, $field_label); } if ($field->allowDatasourceParamOutput()) { $options_parameter_output[] = array($field_handle, $section_active and in_array($field_handle, $this->parameters()->{'parameter-output'}), __('$ds-?.%s', array($field_handle))); } if (is_array($modes)) { foreach ($modes as $field_mode) { if (is_array($field_mode)) { $included_elements_options[] = array($field_mode['handle'], $section_active and in_array($field_mode['handle'], $this->parameters()->{'included-elements'}), $field_mode['name'] . (isset($field_mode['mode']) && strlen(trim($field_mode['mode'])) > 0 ? sprintf(" (%s)", $field_mode['mode']) : NULL)); } else { $included_elements_options[] = array($field_mode, $section_active and in_array($field_mode, $this->parameters()->{'included-elements'}), $field_mode); } } } } } $label = Widget::Label(__('Sort By')); $label->setAttribute('class', 'context context-' . $section_handle); $label->appendChild(Widget::Select('fields[sort-field]', $sort_by_options, array('class' => 'filtered'))); $container_sort_by->appendChild($label); $param_label = Widget::Label(__('Parameter Output')); $select = Widget::Select('fields[parameter-output][]', $options_parameter_output); $select->setAttribute('class', 'filtered'); $select->setAttribute('multiple', 'multiple'); $param_label->appendChild($select); $include_label = Widget::Label(__('Included Fields')); $select = Widget::Select('fields[included-elements][]', $included_elements_options); $select->setAttribute('class', 'filtered'); $select->setAttribute('multiple', 'multiple'); $include_label->appendChild($select); $group = Widget::Group($param_label, $include_label); $group->setAttribute('class', 'group context context-' . $section_handle); $context_content->parentNode->insertBefore($group, $context_content); } $context_content->remove(); }
public function view(SymphonyDOMElement $wrapper, MessageStack $errors) { $page = Administration::instance()->Page; $page->insertNodeIntoHead($page->createScriptElement(URL . '/extensions/ds_sections/assets/view.js')); $layout = new Layout(); $column_1 = $layout->createColumn(Layout::SMALL); $column_2 = $layout->createColumn(Layout::SMALL); $column_3 = $layout->createColumn(Layout::LARGE); $fieldset = Widget::Fieldset(__('Essentials')); $label = Widget::Label(__('Name')); $label->appendChild(Widget::Input('fields[name]', General::sanitize($this->about()->name))); if (isset($errors->{'about::name'})) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $errors->{'about::name'})); } else { $fieldset->appendChild($label); } $label = Widget::Label(__('Section')); $options = array(); foreach (new SectionIterator() as $section) { $options[] = array($section->handle, $this->parameters()->section == $section->handle, $section->name); } $label->appendChild(Widget::Select('fields[section]', $options, array('id' => 'context'))); $fieldset->appendChild($label); $column_1->appendChild($fieldset); $fieldset = Widget::Fieldset(__('Processing Options')); $label = Widget::Label(__('Filter Rules')); $filters = $this->parameters()->filters; if (!is_array($filters)) { $filters = array(); } $options = array(array('admin-only', in_array('admin-only', $filters), __('Admin Only')), array('send-email', in_array('send-email', $filters), __('Send Email')), array('expect-multiple', in_array('expect-multiple', $filters), __('Allow Multiple'))); ### # Delegate: AppendEventFilter # Description: Allows adding of new filter rules to the Event filter # rule select box. A reference to the $options array is provided, and selected filters Extension::notify('AppendEventFilter', '/blueprints/events/', array('selected' => $filters, 'options' => &$options)); $label->appendChild(Widget::Select('fields[filters][]', $options, array('multiple' => 'multiple'))); $fieldset->appendChild($label); $label = Widget::Label(); $input = Widget::Input('fields[output-id-on-save]', 'yes', 'checkbox'); if ($this->parameters()->{'output-id-on-save'} == true) { $input->setAttribute('checked', 'checked'); } $label->appendChild($input); $label->appendChild(new DOMText(__('Add entry ID to the parameter pool in the format of $this-name-id when saving is successful.'))); $fieldset->appendChild($label); $column_2->appendChild($fieldset); $fieldset = Widget::Fieldset(__('Overrides & Defaults'), '{$param}'); foreach (new SectionIterator() as $section) { $this->appendDuplicator($fieldset, $section, $this->parameters()->section == $section->handle ? array('overrides' => $this->parameters()->overrides, 'defaults' => $this->parameters()->defaults) : NULL); } $column_3->appendChild($fieldset); $layout->appendTo($wrapper); }
public function view(SymphonyDOMElement $wrapper, MessageStack $errors) { $page = $wrapper->ownerDocument; $page->insertNodeIntoHead($page->createScriptElement(URL . '/extensions/ds_sections/assets/view.js'), 55533140); $layout = new Layout(); $left = $layout->createColumn(Layout::SMALL); $right = $layout->createColumn(Layout::LARGE); // Essentials -------------------------------------------------------- $fieldset = Widget::Fieldset(__('Essentials')); // Name: $label = Widget::Label(__('Name')); $input = Widget::Input('fields[about][name]', General::sanitize($this->about()->name)); $label->appendChild($input); if (isset($errors->{'about::name'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'about::name'}); } $fieldset->appendChild($label); // Source ------------------------------------------------------------ $label = Widget::Label(__('Source URL')); $label->appendChild(Widget::Input('fields[url]', General::sanitize($this->parameters()->url))); if (isset($errors->url)) { $label = Widget::wrapFormElementWithError($label, $errors->url); } $fieldset->appendChild($label); $fragment = $page->createDocumentFragment(); $fragment->appendXML(__('Use <code>{$param}</code> syntax to specify dynamic portions of the URL.')); $fieldset->appendChild($page->createElement('p', $fragment, array('class' => 'help'))); $left->appendChild($fieldset); // Timeouts ------------------------------------------------------------ $fieldset = Widget::Fieldset(__('Time Limits')); $label = Widget::Label(__('Cache Limit')); $label->appendChild(Widget::Input('fields[cache-lifetime]', max(0, intval($this->parameters()->{'cache-lifetime'})))); if (isset($errors->{'cache-lifetime'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'cache-lifetime'}); } $fieldset->appendChild($label); $fragment = $page->createDocumentFragment(); $fragment->appendXML(__('How often to refresh the cache.')); $fieldset->appendChild($page->createElement('p', $fragment, array('class' => 'help'))); $label = Widget::Label(__('Gateway Timeout')); $label->appendChild(Widget::Input('fields[timeout]', max(1, intval($this->parameters()->{'timeout'})))); if (isset($errors->{'timeout'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'timeout'}); } $fieldset->appendChild($label); $fragment = $page->createDocumentFragment(); $fragment->appendXML(__('How long to wait for a response.')); $fieldset->appendChild($page->createElement('p', $fragment, array('class' => 'help'))); $left->appendChild($fieldset); // Included Elements $fieldset = Widget::Fieldset(__('XML Processing')); $label = Widget::Label(__('Included Elements')); $label->appendChild(Widget::Input('fields[xpath]', General::sanitize($this->parameters()->xpath))); if (isset($errors->xpath)) { $label = Widget::wrapFormElementWithError($label, $errors->xpath); } $fieldset->appendChild($label); $help = Symphony::Parent()->Page->createElement('p'); $help->setAttribute('class', 'help'); $help->setValue(__('Use an XPath expression to select which elements from the source XML to include.')); $fieldset->appendChild($help); $right->appendChild($fieldset); // Namespace Declarations $fieldset = Widget::Fieldset(__('Namespace Declarations'), $page->createElement('em', 'Optional')); $duplicator = new Duplicator(__('Add Namespace')); $this->appendNamespace($duplicator); if (is_array($this->parameters()->namespaces)) { foreach ($this->parameters()->namespaces as $index => $namespace) { $this->appendNamespace($duplicator, $namespace); } } $duplicator->appendTo($fieldset); $right->appendChild($fieldset); $layout->appendTo($wrapper); }
private function __form() { $this->insertNodeIntoHead($this->createStylesheetElement(URL . '/extensions/aac/assets/roles.css')); $this->insertNodeIntoHead($this->createScriptElement(URL . '/extensions/aac/assets/roles.js')); // The "symphony.selectable.js" messes up the checkboxes, so remove it foreach ($this->xpath("//head/script[contains(@src, 'symphony/assets/js/symphony.selectable.js')]") as $element) { $element->parentNode->removeChild($element); } if (!in_array($this->_context[0], array('new', 'edit'))) { throw new AdministrationPageNotFoundException(); } $callback = Administration::instance()->getPageCallback(); if (isset($callback['flag'])) { switch ($callback['flag']) { case 'saved': $this->alerts()->append(__('Role updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Roles</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/extension/aac/roles/new/', ADMIN_URL . '/extension/aac/roles/')), AlertStack::SUCCESS); break; case 'created': $this->alerts()->append(__('Role created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Roles</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), ADMIN_URL . '/extension/aac/roles/new/', ADMIN_URL . '/extension/aac/roles/')), AlertStack::SUCCESS); break; } } /********** INSERT logic for determining the current role and whether the user has permission to edit it **********/ $this->setTitle(__($this->_context[0] == 'new' ? '%1$s – %2$s – Untitled' : '%1$s – %2$s – %3$s', array(__('Symphony'), __('Roles'), $this->role->name))); $this->appendSubheading($this->_context[0] == 'new' ? __('Untitled') : $this->role->name); // SETUP PAGE $layout = new Layout(); $left = $layout->createColumn(Layout::SMALL); $middle = $layout->createColumn(Layout::LARGE); $right = $layout->createColumn(Layout::LARGE); /** ESSENTIALS **/ $fieldset = Widget::Fieldset(__('Essentials')); $label = Widget::Label(__('Name')); $label->appendChild(Widget::Input('fields[name]', $this->role->name)); $fieldset->appendChild(isset($this->errors->name) ? Widget::wrapFormElementWithError($label, $this->errors->name) : $label); $label = Widget::Label(__('Description')); $label->appendChild(Widget::Textarea('fields[description]', $this->role->description, array('rows' => 7, 'cols' => 50))); $fieldset->appendChild(isset($this->errors->description) ? Widget::wrapFormElementWithError($label, $this->errors->description) : $label); $left->appendChild($fieldset); /// PUBLISHING PERMISSIONS $fieldset = Widget::Fieldset(__('Publishing Permissions')); $sections = new SectionIterator(); if ($sections->length() <= 0) { $p = $this->createElement('p', 'No sections exist. '); $p->appendChild(Widget::Anchor(__('Create one'), ADMIN_URL . '/sections/new/')); $fieldset->appendChild($p); } else { $thead = array(array(__('Section'), 'col'), array(__('Create'), 'col', array('class' => 'checkbox')), array(__('Edit'), 'col', array('class' => 'checkbox'))); $tbody = array(); /* // TODO: Global permissions set all permissions $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); }
public function view(SymphonyDOMElement $wrapper, MessageStack $errors) { $page = $wrapper->ownerDocument; $layout = new Layout(); $left = $layout->createColumn(Layout::SMALL); $right = $layout->createColumn(Layout::LARGE); $fieldset = Widget::Fieldset(__('Essentials')); // Name: $label = Widget::Label(__('Name')); $input = Widget::Input('fields[about][name]', General::sanitize($this->about()->name)); $label->appendChild($input); if (isset($errors->{'about::name'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'about::name'}); } $fieldset->appendChild($label); $left->appendChild($fieldset); $fieldset = Widget::Fieldset(__('Gravatar'), '<code>{$param}</code> or <code>Value</code>'); $label = Widget::Label(__('Email Addresses')); $input = Widget::Input('fields[addresses]', $this->parameters()->{'addresses'}); $label->appendChild($input); if (isset($errors->{'addresses'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'addresses'}); } $help = $page->createElement('p'); $help->setAttribute('class', 'help'); $help->setValue(__('Enter email addresses separated by commas.')); $fieldset->appendChild($label); $fieldset->appendChild($help); $label = Widget::Label(__('Default Image')); $input = Widget::Input('fields[default]', $this->parameters()->{'default'}); $label->appendChild($input); if (isset($errors->{'default'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'default'}); } $help = $page->createElement('p'); $help->setAttribute('class', 'help'); $help->setValue(__('An image to use as a fallback, either identicon, monsterid, wavatar, 404 or a URL to your own image.')); $fieldset->appendChild($label); $fieldset->appendChild($help); $size = $page->createElement('div'); $label = Widget::Label(__('Size')); $input = Widget::Input('fields[size]', $this->parameters()->{'size'}); $label->appendChild($input); if (isset($errors->{'size'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'size'}); } $help = $page->createElement('p'); $help->setAttribute('class', 'help'); $help->setValue(__('Images sized from 1 to 512 pixels. Defaults to 80 pixels.')); $size->appendChild($label); $size->appendChild($help); $rating = $page->createElement('div'); $label = Widget::Label(__('Rating')); $input = Widget::Input('fields[rating]', $this->parameters()->{'rating'}); $label->appendChild($input); if (isset($errors->{'rating'})) { $label = Widget::wrapFormElementWithError($label, $errors->{'rating'}); } $help = $page->createElement('p'); $help->setAttribute('class', 'help'); $help->setValue(__('Specify a content rating of g, pg, r, or x. Defaults to g.')); $rating->appendChild($label); $rating->appendChild($help); $fieldset->appendChild(Widget::Group($size, $rating)); $right->appendChild($fieldset); $layout->appendTo($wrapper); }
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'))); if (!is_null($existing)) { $div->appendChild(Widget::Submit('action[delete]', __('Delete'), array('class' => 'confirm delete', 'title' => __('Delete this entry')))); } $this->Form->appendChild($div); }
private function __form() { $layout = new Layout(); $left = $layout->createColumn(Layout::SMALL); $center = $layout->createColumn(Layout::LARGE); $right = $layout->createColumn(Layout::SMALL); require_once LIB . '/class.field.php'; ## Handle unknow context if (!in_array($this->_context[0], array('new', 'edit'))) { throw new AdministrationPageNotFoundException(); } $callback = Administration::instance()->getPageCallback(); if (isset($callback['flag'])) { switch ($callback['flag']) { case 'saved': $this->alerts()->append(__('User 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 . '/system/users/new/', ADMIN_URL . '/system/users/')), AlertStack::SUCCESS); break; case 'created': $this->alerts()->append(__('User 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 . '/system/users/new/', ADMIN_URL . '/system/users/')), AlertStack::SUCCESS); break; } } $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); }
public function __form() { $layout = new Layout(); $left = $layout->createColumn(Layout::LARGE); $center = $layout->createColumn(Layout::LARGE); $right = $layout->createColumn(Layout::LARGE); $existing = null; $fields = array(); // Verify view exists: if ($this->_context[0] == 'edit') { if (!isset($this->_context[1]) || strlen(trim($this->_context[1])) == 0) { redirect(ADMIN_URL . '/blueprints/views/'); } $context = $this->_context; array_shift($context); $view_pathname = implode('/', $context); $existing = self::__loadExistingView($view_pathname); } // Status message: $callback = Administration::instance()->getPageCallback(); if (isset($callback['flag']) && !is_null($callback['flag'])) { switch ($callback['flag']) { case 'saved': $this->alerts()->append(__('View 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/views/new/', ADMIN_URL . '/blueprints/views/')), AlertStack::SUCCESS); break; case 'created': $this->alerts()->append(__('View 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/views/new/', ADMIN_URL . '/blueprints/views/')), AlertStack::SUCCESS); break; } } // Find values: if (isset($_POST['fields'])) { $fields = $_POST['fields']; } elseif ($this->_context[0] == 'edit') { $fields = (array) $existing->about(); // Flatten the types array: $fields['types'] = (isset($fields['types']) and is_array($fields['types'])) ? implode(', ', $fields['types']) : null; // Flatten the url-parameters array: $fields['url-parameters'] = (isset($fields['url-parameters']) and is_array($fields['url-parameters'])) ? implode('/', $fields['url-parameters']) : null; $fields['parent'] = $existing->parent() instanceof View ? $existing->parent()->path : NULL; $fields['handle'] = $existing->handle; } $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); }