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); $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 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 __viewIndex() { $this->appendSubheading(__('Settings')); $this->appendTabs(); if (!is_writable(CONF . '/core.xml')) { $this->alerts()->append(__('The core Symphony configuration file, /manifest/conf/core.xml, is not writable. You will not be able to save any changes.'), AlertStack::ERROR); } // 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; } } // SETUP PAGE $layout = new Layout(); $left = $layout->createColumn(Layout::LARGE); $center = $layout->createColumn(Layout::LARGE); $right = $layout->createColumn(Layout::LARGE); // SITE SETUP $helptext = 'Symphony version: ' . Symphony::Configuration()->core()->symphony->version; $fieldset = Widget::Fieldset(__('Site Setup'), $helptext); $label = Widget::Label(__('Site Name')); $input = Widget::Input('settings[symphony][sitename]', Symphony::Configuration()->core()->symphony->sitename); $label->appendChild($input); if (isset($this->errors->{'symphony::sitename'})) { $label = Widget::wrapFormElementWithError($label, $this->errors->{'symphony::sitename'}); } $fieldset->appendChild($label); // Get available languages $languages = Lang::getAvailableLanguages(true); if (count($languages) > 1) { // Create language selection $label = Widget::Label(__('Default Language')); // Get language names asort($languages); foreach ($languages as $code => $name) { $options[] = array($code, $code == Symphony::Configuration()->core()->symphony->lang, $name); } $select = Widget::Select('settings[symphony][lang]', $options); unset($options); $label->appendChild($select); //$group->appendChild(new XMLElement('p', __('Users can set individual language preferences in their profiles.'), array('class' => 'help'))); // Append language selection $fieldset->appendChild($label); } $left->appendChild($fieldset); // REGIONAL SETTINGS $fieldset = Widget::Fieldset(__('Date & Time Settings')); // Date and Time Settings $label = Widget::Label(__('Date Format')); $input = Widget::Input('settings[region][date-format]', Symphony::Configuration()->core()->region->{'date-format'}); $label->appendChild($input); if (isset($this->errors->{'region::date-format'})) { $label = Widget::wrapFormElementWithError($label, $this->errors->{'region::date-format'}); } $fieldset->appendChild($label); $label = Widget::Label(__('Time Format')); $input = Widget::Input('settings[region][time-format]', Symphony::Configuration()->core()->region->{'time-format'}); $label->appendChild($input); if (isset($this->errors->{'region::time-format'})) { $label = Widget::wrapFormElementWithError($label, $this->errors->{'region::time-format'}); } $fieldset->appendChild($label); $label = Widget::Label(__('Timezone')); $timezones = timezone_identifiers_list(); foreach ($timezones as $timezone) { $options[] = array($timezone, $timezone == Symphony::Configuration()->core()->region->timezone, $timezone); } $select = Widget::Select('settings[region][timezone]', $options); unset($options); $label->appendChild($select); $fieldset->appendChild($label); $center->appendChild($fieldset); // PERMISSIONS $fieldset = Widget::Fieldset(__('Permissions')); $permissions = array('0777', '0775', '0755', '0666', '0644'); $fileperms = Symphony::Configuration()->core()->symphony->{'file-write-mode'}; $dirperms = Symphony::Configuration()->core()->symphony->{'directory-write-mode'}; $label = Widget::Label(__('File Permissions')); foreach ($permissions as $p) { $options[] = array($p, $p == $fileperms, $p); } if (!in_array($fileperms, $permissions)) { $options[] = array($fileperms, true, $fileperms); } $select = Widget::Select('settings[symphony][file-write-mode]', $options); unset($options); $label->appendChild($select); $fieldset->appendChild($label); $label = Widget::Label(__('Directory Permissions')); foreach ($permissions as $p) { $options[] = array($p, $p == $dirperms, $p); } if (!in_array($dirperms, $permissions)) { $options[] = array($dirperms, true, $dirperms); } $select = Widget::Select('settings[symphony][directory-write-mode]', $options); unset($options); $label->appendChild($select); $fieldset->appendChild($label); $right->appendChild($fieldset); $layout->appendTo($this->Form); $div = $this->createElement('div'); $div->setAttribute('class', 'actions'); $attr = array('accesskey' => 's'); if (!is_writable(CONF)) { $attr['disabled'] = 'disabled'; } $div->appendChild(Widget::Submit('action[save]', __('Save Changes'), $attr)); $this->Form->appendChild($div); }
private function __layout(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; } } if (!$this->alerts()->valid() and $existing instanceof Section) { $this->appendSyncAlert(); } $layout = new Layout(); $content = $layout->createColumn(Layout::LARGE); $fieldset = Widget::Fieldset(__('Layout')); if (!$this->section instanceof Section) { $this->section = new Section(); } $this->setTitle(__('%1$s – %2$s', array(__('Symphony'), __('Sections')))); $this->appendSubheading($existing instanceof Section ? $existing->name : __('Untitled')); $this->appendViewOptions(); $widget = $this->createElement('div'); $widget->setAttribute('id', 'section-layout'); $layouts = $this->createElement('ol'); $layouts->setAttribute('class', 'layouts'); $templates = $this->createElement('ol'); $templates->setAttribute('class', 'templates'); $columns = new Layout('ol', 'li'); // Load fields: $fields = $this->section->fields; foreach ($fields as $index => $field) { $name = $field->{'element-name'}; $fields[$name] = $field; unset($fields[$index]); } // Layouts: $layout_options = array(array(Layout::LARGE), array(Layout::LARGE, Layout::LARGE), array(Layout::LARGE, Layout::SMALL), array(Layout::SMALL, Layout::LARGE), array(Layout::LARGE, Layout::LARGE, Layout::LARGE), array(Layout::LARGE, Layout::LARGE, Layout::LARGE, Layout::LARGE)); foreach ($layout_options as $layout_columns) { $item = $this->createElement('li'); $mini_layout = new Layout(); foreach ($layout_columns as $index => $size) { $column = $mini_layout->createColumn($size); $text = $this->createTextNode(chr(97 + $index)); $column->appendChild($text); } $mini_layout->appendTo($item); $layouts->appendChild($item); } // Current columns: foreach ($this->section->layout as $data) { $column = $columns->createColumn($data->size); if (!empty($data->fieldsets)) { foreach ($data->fieldsets as $data) { $this->appendFieldset($column, $data, $fields); } } } // Templates: if (is_array($fields)) { foreach ($fields as $position => $field) { $this->appendField($templates, $field); } } $widget->appendChild($layouts); $widget->appendChild($templates); $columns->appendTo($widget); $fieldset->appendChild($widget); $content->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'))); 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 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); }
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); }
protected function appendSidebar(DOMElement $wrapper) { $sidebar = parent::appendSidebar($wrapper); $fieldset = $sidebar->lastChild; $list = $this->document->createElement('ul'); $url = clone $this->url; $url->parameters()->{'debug'} = 'source'; if (isset($_GET['debug-state'])) { $url->parameters()->{'debug-state'} = $this->state; } $this->appendLink($list, __('View Source'), (string) $url, $this->show == 'source'); $url->parameters()->debug = 'output'; $this->appendLink($list, __('View Output'), (string) $url, $this->show == 'output'); $url->parameters()->debug = 'params'; $this->appendLink($list, __('View Parameters'), (string) $url, $this->show == 'params'); $url->parameters()->debug = 'frontend'; $this->appendLink($list, __('View Frontend'), (string) $url, $this->show == 'frontend'); $fieldset->appendChild($list); $fieldset = Widget::Fieldset(__('Templates')); $fieldset->addClass('templates'); $list = $this->document->createElement('ul'); $url->parameters()->debug = 'template'; $item = $this->appendLink($list, basename($this->view->templatePathname()), (string) $url, $this->show == 'template'); $this->appendUtilityLinks($item, $this->utilities); $fieldset->appendChild($list); $sidebar->appendChild($fieldset); $fieldset = Widget::Fieldset(__('Saved States')); $fieldset->addClass('states'); $this->appendStateLinks($fieldset, $this->states); $sidebar->appendChild($fieldset); return $sidebar; }
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); }
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); }
protected function appendSidebar(DOMElement $wrapper) { $container = $this->document->createElement('div'); $container->setAttribute('id', 'sidebar'); // Header: $header = $this->document->createElement('h1'); $header->appendChild(Widget::Anchor($this->view->title, (string) $this->url)); $container->appendChild($header); $list = $this->document->createElement('ul'); $list->setAttribute('class', 'menu'); $root = $this->document->createElement('navigation'); #### # Delegate: DevKiAppendtMenuItem # Description: Allow navigation XML to be manipulated before it is rendered. # Global: Yes #$this->_page->ExtensionManager->notifyMembers( Extension::notify('DevKiAppendtMenuItem', '/frontend/', array('wrapper' => $root)); if ($root->hasChildNodes()) { foreach ($root->childNodes as $node) { if ($node->getAttribute('active') == 'yes') { $item = $this->document->createElement('li', $node->getAttribute('name')); } else { $handle = $node->getAttribute('handle'); $url = clone $this->url; $url->parameters()->{$handle} = null; $item = $this->document->createElement('li'); $item->appendChild(Widget::Anchor($node->getAttribute('name'), '?' . (string) $url)); } $list->appendChild($item); } } $item = $this->document->createElement('li'); $item->appendChild(Widget::Anchor(__('Edit'), ADMIN_URL . '/blueprints/views/edit/' . $this->view->handle . '/')); $list->prependChild($item); $container->appendChild($list); // Main: $fieldset = Widget::Fieldset(__('Pages')); $container->appendChild($fieldset); $wrapper->appendChild($container); return $container; }
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); }
protected function appendSidebar(DOMElement $wrapper) { $sidebar = parent::appendSidebar($wrapper); $fieldset = $sidebar->lastChild; $list = $this->document->createElement('ul'); $url = clone $this->url; $url->parameters()->debug = 'source'; $url->parameters()->{'debug-state'} = $this->state; $this->appendLink($list, __('View Source'), (string) $url, $this->show == 'source'); $url->parameters()->debug = 'output'; $this->appendLink($list, __('View Output'), (string) $url, $this->show == 'output'); $url->parameters()->debug = 'params'; $this->appendLink($list, __('View Parameters'), (string) $url, $this->show == 'params'); $url->parameters()->debug = 'frontend'; $this->appendLink($list, __('View Frontend'), (string) $url, $this->show == 'frontend'); $fieldset->appendChild($list); $fieldset = Widget::Fieldset(__('Templates')); $list = $this->document->createElement('ul'); $url->parameters()->debug = 'template'; $item = $this->appendLink($list, basename($this->view->templatePathname()), (string) $url, $this->show == 'template'); $this->appendUtilityLinks($item, $this->utilities); $fieldset->appendChild($list); $sidebar->appendChild($fieldset); $fieldset = Widget::Fieldset(__('XPath Search')); $search = Widget::Input('search'); $search->setAttribute('id', 'search'); $fieldset->appendChild($search); $sidebar->appendChild($fieldset); return $sidebar; }