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() { $this->setTitle(__('Symphony – Indecent Filter')); $this->setPageType('form'); $this->Form->setAttribute('enctype', 'multipart/form-data'); $this->appendSubheading(__('Indecent Filter')); $words = extension_indecent::processFilterList(true); // Word List $container = new XMLElement('fieldset'); $container->setAttribute('class', 'settings'); $container->appendChild(new XMLElement('legend', __('Word Blacklist'))); $p = new XMLElement('p', __('Enter each of the terms on a new line.'), array('class' => 'help')); $container->appendChild($p); // Add last saved timestamp if (!empty($words)) { $p->setValue($p->getValue() . '<br / >' . __('Last updated: %s', array(extension_indecent::lastUpdateFilterList()))); } $container->appendChild(Widget::Textarea('fields[words]', 30, 30, $words)); $this->Form->appendChild($container); // Actions $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', 'Save', 'submit', array('accesskey' => 's'))); $this->Form->appendChild($div); }
/** * Append maintenance mode preferences * * @param array $context * delegate context */ public function appendPreferences($context) { // Create preference group $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', __('Maintenance Mode'))); // Append settings $label = Widget::Label(); $input = Widget::Input('settings[maintenance_mode][enabled]', 'yes', 'checkbox'); if (Symphony::Configuration()->get('enabled', 'maintenance_mode') === 'yes') { $input->setAttribute('checked', 'checked'); } $label->setValue($input->generate() . ' ' . __('Enable maintenance mode')); $group->appendChild($label); // Append help $group->appendChild(new XMLElement('p', __('Maintenance mode will redirect all visitors, other than developers, to the specified maintenance page. To specify a maintenance page, give a page a type of <code>maintenance</code>'), array('class' => 'help'))); // IP White list $label = Widget::Label(__('IP Whitelist')); $label->appendChild(Widget::Input('settings[maintenance_mode][ip_whitelist]', Symphony::Configuration()->get('ip_whitelist', 'maintenance_mode'))); $group->appendChild($label); // Append help $group->appendChild(new XMLElement('p', __('Any user that has an IP listed above will be granted access. This eliminates the need to allow a user backend access. Separate each with a space.'), array('class' => 'help'))); // Useragent White list $label = Widget::Label(__('Useragent Whitelist')); $whitelist = json_decode(Symphony::Configuration()->get('useragent_whitelist', 'maintenance_mode')); if (is_array($whitelist) && !empty($whitelist)) { $useragent = implode("\r\n", $whitelist); } $label->appendChild(Widget::Textarea('settings[maintenance_mode][useragent_whitelist]', 5, 50, $useragent)); $group->appendChild($label); // Append help $group->appendChild(new XMLElement('p', __('Any useragent that listed above will be granted access. This eliminates the need to allow a user backend access, useful when third party services need to access your site prior to launch. Insert in json array format eg ["useragent1","useragent2"].'), array('class' => 'help'))); // Append new preference group $context['wrapper']->appendChild($group); }
public function append_preferences($context) { # Add new fieldset $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', 'CacheLite')); # Add Site Reference field $label = Widget::Label('Cache Period'); $label->appendChild(Widget::Input('settings[cachelite][lifetime]', General::Sanitize($this->_get_lifetime()))); $group->appendChild($label); $group->appendChild(new XMLElement('p', 'Length of cache period in seconds.', array('class' => 'help'))); $label = Widget::Label('Excluded URLs'); $label->appendChild(Widget::Textarea('cachelite[excluded-pages]', 10, 50, $this->_get_excluded_pages())); $group->appendChild($label); $group->appendChild(new XMLElement('p', 'Add a line for each URL you want to be excluded from the cache. Add a <code>*</code> to the end of the URL for wildcard matches.', array('class' => 'help'))); $label = Widget::Label(); $input = Widget::Input('settings[cachelite][show-comments]', 'yes', 'checkbox'); if ($this->_Parent->Configuration->get('show-comments', 'cachelite') == 'yes') { $input->setAttribute('checked', 'checked'); } $label->setValue($input->generate() . ' Show comments in page source?'); $group->appendChild($label); $label = Widget::Label(); $input = Widget::Input('settings[cachelite][backend-delegates]', 'yes', 'checkbox'); if ($this->_Parent->Configuration->get('backend-delegates', 'cachelite') == 'yes') { $input->setAttribute('checked', 'checked'); } $label->setValue($input->generate() . ' Expire cache when entries are created/updated through the backend?'); $group->appendChild($label); $context['wrapper']->appendChild($group); }
public function displaySettingsPanel(&$wrapper, $errors = NULL) { parent::displaySettingsPanel($wrapper, $errors); $order = $this->get('sortorder'); # Panel $label = new XMLElement("label", "Note"); $label->appendChild(new XMLElement("i", "The raw output will be shown on the 'Publish' screen", array("class" => "help"))); $label->appendChild(Widget::Textarea("fields[{$order}][note]", 5, 40, $this->get('note'))); $wrapper->appendChild($label); }
public function appendPreferences($context) { $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', 'JIT Image Manipulation')); $label = Widget::Label('Trusted Sites'); $label->appendChild(Widget::Textarea('jit_image_manipulation[trusted_external_sites]', 10, 50, $this->trusted())); $group->appendChild($label); $group->appendChild(new XMLElement('p', 'Leave empty to disable external linking. Single rule per line. Add * at end for wild card matching.', array('class' => 'help'))); $context['wrapper']->appendChild($group); }
/** * Append preferences to the preferences page * * @param $context * The context */ public function appendPreferences($context) { $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', __('Force Download'))); $label = Widget::Label(__('Trusted Locations')); $locations = implode("\n", $this->getLocations()); $label->appendChild(Widget::Textarea('force_download[trusted_locations]', 5, 50, $locations)); $group->appendChild($label); $group->appendChild(new XMLElement('p', __('Relative from the root. Single path per line. Add * at end for wild card matching.'), array('class' => 'help'))); $context['wrapper']->appendChild($group); }
public function displaySettingsPanel(XMLElement &$wrapper, $errors = null) { parent::displaySettingsPanel($wrapper, $errors); $order = $this->get('sortorder'); # Value: Note $label = new XMLElement("label", __("Note")); $label->appendChild(new XMLElement("i", __("The raw output will be shown on the 'Publish' screen"), array("class" => "help"))); $label->appendChild(Widget::Textarea("fields[{$order}][note]", 5, 40, $this->get('note'))); $wrapper->appendChild($label); # Setting: Editable $div = new XMLElement('div', NULL, array('class' => 'compact')); $setting = new XMLElement('label', '<input name="fields[' . $order . '][editable]" value="1" type="checkbox"' . ($this->get('editable') == 0 ? '' : ' checked="checked"') . '/> ' . __('Allow note to be edited?')); $div->appendChild($setting); $wrapper->appendChild($div); }
public function addCustomPreferenceFieldsets($context) { $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', 'New Visiter')); $message = Widget::Label('Message'); $message->appendChild(Widget::Textarea('settings[newvisiter][message]', '5', '25', General::Sanitize($this->getMessage()))); $group->appendChild($message); $thresholds = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); $options = array(); foreach ($thresholds as $t) { $options[] = array($t, $t == $this->_Parent->Configuration->get('threshold', 'newvisiter'), $t); } $threshold = Widget::Label('Threshold'); $threshold->appendChild(Widget::Select('settings[newvisiter][threshold]', $options)); $group->appendChild($threshold); $context['wrapper']->appendChild($group); }
public function displaySettingsPanel(XMLElement &$wrapper, $errors = NULL) { parent::displaySettingsPanel($wrapper, $errors); // Disable/Enable publish filtering $label = Widget::Label(__('Expression')); $label->appendChild(new XMLElement('i', __('Optional'))); $input = Widget::Textarea('fields[' . $this->get('sortorder') . '][expression]', 6, 50, General::sanitize(stripslashes($this->get('expression'))), array('class' => 'code')); $label->appendChild($input); if (isset($errors['expression'])) { $wrapper->appendChild(Widget::Error($label, $errors['expression'])); } else { $wrapper->appendChild($label); } $wrapper->appendChild(new XMLElement('p', __('Default value of this field will be set to <code>yes</code>. If expression above will evaluate to <code>false</code>, value of this field will be set to <code>no</code>. Use <code>{XPath}</code> syntax to put values into expression before it will be evaluated, e.g., to make use of a value posted from HTML element called "<code>fields[published]</code>" enter "<code>{/data/post/published}</code>".'), array('class' => 'help'))); // Disable/Enable publish error when evaluated expression returns false $label = Widget::Label(); $input = Widget::Input('fields[' . $this->get('sortorder') . '][show_errors]', 'yes', 'checkbox'); if ($this->get('show_errors') == 'yes') { $input->setAttribute('checked', 'checked'); } $label->setValue(__('%s Show error when expression entered above evaluates to <code>false</code>', array($input->generate()))); $wrapper->appendChild($label); }
public function __viewEdit() { $this->addStylesheetToHead(URL . '/extensions/search_index/assets/search_index.css', 'screen', 100); // $this->addScriptToHead(URL . '/extensions/search_index/assets/search_index.js', 101); $this->setPageType('form'); $this->setTitle(__('Symphony') . ' – ' . __('Search Indexes')); $subheading = !empty($this->_synonym['word']) ? $this->_synonym['word'] : __('Untitled'); $this->appendSubheading($subheading); $this->insertBreadcrumbs(array(Widget::Anchor(__('Synonyms'), $this->_uri . '/synonyms/'))); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', __('Replacement word'))); $p = new XMLElement('p', __('Matching synonyms will be replaced with this word.')); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); $label = Widget::Label(__('Word')); $label->appendChild(Widget::Input('synonym[word]', $this->_synonym['word'])); $fieldset->appendChild($label); $fieldset->appendChild(new XMLElement('p', __('e.g. United Kingdom'), array('class' => 'help'))); $this->Form->appendChild($fieldset); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', __('Synonyms'))); $p = new XMLElement('p', __('These words will be replaced with the word above. Separate multiple words with commas.')); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); $label = Widget::Label(__('Synonyms')); $label->appendChild(Widget::Textarea('synonym[synonyms]', 5, 40, $this->_synonym['synonyms'])); $fieldset->appendChild($label); $fieldset->appendChild(new XMLElement('p', __('e.g. UK, Great Britain, GB'), array('class' => 'help'))); $this->Form->appendChild(new XMLElement('input', NULL, array('type' => 'hidden', 'name' => 'synonym[hash]', 'value' => $this->_hash))); $this->Form->appendChild($fieldset); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's'))); $this->Form->appendChild($div); }
function __form() { $this->setPageType('form'); $fields = array(); if ($this->_context[0] == 'edit') { if (!($page_id = $this->_context[1])) { redirect(URL . '/symphony/blueprints/pages/'); } if (!($existing = $this->_Parent->Database->fetchRow(0, "SELECT * FROM `tbl_pages` WHERE `id` = '{$page_id}' LIMIT 1"))) { $this->_Parent->customError(E_USER_ERROR, __('Page not found'), __('The page you requested to edit does not exist.'), false, true, 'error', array('header' => 'HTTP/1.0 404 Not Found')); } } if (isset($this->_context[2])) { switch ($this->_context[2]) { case 'saved': $this->pageAlert(__('Page updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Pages</a>', array(DateTimeObj::get(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/pages/new/', URL . '/symphony/blueprints/pages/')), Alert::SUCCESS); break; case 'created': $this->pageAlert(__('Page created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Pages</a>', array(DateTimeObj::get(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/pages/new/', URL . '/symphony/blueprints/pages/')), Alert::SUCCESS); break; } } if (isset($_POST['fields'])) { $fields = $_POST['fields']; } elseif ($this->_context[0] == 'edit') { $fields = $existing; $types = $this->_Parent->Database->fetchCol('type', "SELECT `type` FROM `tbl_pages_types` WHERE page_id = '{$page_id}' ORDER BY `type` ASC"); $fields['type'] = @implode(', ', $types); $fields['data_sources'] = preg_split('/,/i', $fields['data_sources'], -1, PREG_SPLIT_NO_EMPTY); $fields['events'] = preg_split('/,/i', $fields['events'], -1, PREG_SPLIT_NO_EMPTY); $fields['body'] = @file_get_contents(PAGES . '/' . trim(str_replace('/', '_', $fields['path'] . '_' . $fields['handle']), '_') . ".xsl"); } else { $fields['body'] = '<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="xml" doctype-public="-//W3C//DTD XHTML 1.0 Strict//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" omit-xml-declaration="yes" encoding="UTF-8" indent="yes" /> <xsl:template match="/"> </xsl:template> </xsl:stylesheet>'; } $title = $this->_context[0] == 'edit' ? $fields['title'] : NULL; if (trim($title) == '') { $title = $existing['title']; } $this->setTitle(__($title ? '%1$s – %2$s – %3$s' : '%1$s – %2$s', array(__('Symphony'), __('Pages'), $title))); $this->appendSubheading($title ? $title : __('Untitled')); $div = new XMLElement('div'); $div->setAttribute('id', 'configure'); $div->appendChild(new XMLElement('h3', __('URL Settings'))); $group = new XMLElement('div'); $group->setAttribute('class', 'triple group'); $pages = $this->_Parent->Database->fetch("SELECT * FROM `tbl_pages` " . ($this->_context[0] == 'edit' ? "WHERE `id` != '{$page_id}' " : '') . "ORDER BY `title` ASC"); $label = Widget::Label(__('Parent Page')); $options = array(array('', false, '/')); if (is_array($pages) and !empty($pages)) { if (!function_exists('__compare_pages')) { function __compare_pages($a, $b) { return strnatcasecmp($a[2], $b[2]); } } foreach ($pages as $page) { $options[] = array($page['id'], $fields['parent'] == $page['id'], '/' . $this->_Parent->resolvePagePath($page['id'])); } usort($options, '__compare_pages'); } $label->appendChild(Widget::Select('fields[parent]', $options)); $group->appendChild($label); $label = Widget::Label(__('URL Handle')); $label->appendChild(Widget::Input('fields[handle]', $fields['handle'])); $group->appendChild(isset($this->_errors['handle']) ? $this->wrapFormElementWithError($label, $this->_errors['handle']) : $label); $label = Widget::Label(__('URL Parameters')); $label->appendChild(Widget::Input('fields[params]', $fields['params'])); $group->appendChild($label); $div->appendChild($group); $div->appendChild(new XMLElement('h3', __('Page Metadata'))); $group = new XMLElement('div'); $group->setAttribute('class', 'triple group'); $label = Widget::Label(__('Events')); $EventManager = new EventManager($this->_Parent); $events = $EventManager->listAll(); $options = array(); if (is_array($events) && !empty($events)) { foreach ($events as $name => $about) { $options[] = array($name, @in_array($name, $fields['events']), $about['name']); } } $label->appendChild(Widget::Select('fields[events][]', $options, array('multiple' => 'multiple'))); $group->appendChild($label); $label = Widget::Label(__('Data Sources')); $DSManager = new DatasourceManager($this->_Parent); $datasources = $DSManager->listAll(); $options = array(); if (is_array($datasources) && !empty($datasources)) { foreach ($datasources as $name => $about) { $options[] = array($name, @in_array($name, $fields['data_sources']), $about['name']); } } $label->appendChild(Widget::Select('fields[data_sources][]', $options, array('multiple' => 'multiple'))); $group->appendChild($label); $div3 = new XMLElement('div'); $label = Widget::Label(__('Page Type')); $label->appendChild(Widget::Input('fields[type]', $fields['type'])); $div3->appendChild(isset($this->_errors['type']) ? $this->wrapFormElementWithError($label, $this->_errors['type']) : $label); $ul = new XMLElement('ul'); $ul->setAttribute('class', 'tags'); if ($types = $this->__fetchAvailablePageTypes()) { foreach ($types as $type) { $ul->appendChild(new XMLElement('li', $type)); } } $div3->appendChild($ul); $group->appendChild($div3); $div->appendChild($group); $this->Form->appendChild($div); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'primary'); $label = Widget::Label(__('Title')); $label->appendChild(Widget::Input('fields[title]', General::sanitize($fields['title']))); $fieldset->appendChild(isset($this->_errors['title']) ? $this->wrapFormElementWithError($label, $this->_errors['title']) : $label); $label = Widget::Label(__('Body')); $label->appendChild(Widget::Textarea('fields[body]', '25', '50', General::sanitize($fields['body']), array('class' => 'code'))); $fieldset->appendChild(isset($this->_errors['body']) ? $this->wrapFormElementWithError($label, $this->_errors['body']) : $label); $this->Form->appendChild($fieldset); $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES); $utilities = $utilities['filelist']; if (is_array($utilities) && !empty($utilities)) { $div = new XMLElement('div'); $div->setAttribute('class', 'secondary'); $h3 = new XMLElement('h3', __('Utilities')); $h3->setAttribute('class', 'label'); $div->appendChild($h3); $ul = new XMLElement('ul'); $ul->setAttribute('id', 'utilities'); foreach ($utilities as $util) { $li = new XMLElement('li'); $li->appendChild(Widget::Anchor($util, URL . '/symphony/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL)); $ul->appendChild($li); } $div->appendChild($ul); $this->Form->appendChild($div); } $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Page'), 'submit', array('accesskey' => 's'))); if ($this->_context[0] == 'edit') { $button = new XMLElement('button', __('Delete')); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this page'))); $div->appendChild($button); } $this->Form->appendChild($div); }
public function __form() { $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. See below for details.'), Alert::ERROR); // These alerts are only valid if the form doesn't have errors } elseif (isset($this->_context[2])) { $time = Widget::Time(); switch ($this->_context[2]) { case 'saved': $message = __('Data Source updated at %s.', array($time->generate())); break; case 'created': $message = __('Data Source created at %s.', array($time->generate())); } $this->pageAlert($message . ' <a href="' . SYMPHONY_URL . '/blueprints/datasources/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/datasources/" accesskey="a">' . __('View all Data Sources') . '</a>', Alert::SUCCESS); } $providers = Symphony::ExtensionManager()->getProvidersOf(iProvider::DATASOURCE); $isEditing = false; $about = $handle = null; $fields = array('name' => null, 'source' => null, 'filter' => null, 'required_url_param' => null, 'negate_url_param' => null, 'param' => null); if (isset($_POST['fields'])) { $fields = $_POST['fields']; if (!in_array($fields['source'], array('authors', 'navigation', 'static_xml')) && !empty($fields['filter']) && is_array($fields['filter'])) { $filters = array(); foreach ($fields['filter'] as $f) { foreach ($f as $key => $val) { $filters[$key] = $val; } } $fields['filter'][$fields['source']] = $filters; } if (!isset($fields['xml_elements']) || !is_array($fields['xml_elements'])) { $fields['xml_elements'] = array(); } if ($this->_context[0] == 'edit') { $isEditing = true; } } elseif ($this->_context[0] == 'edit') { $isEditing = true; $handle = $this->_context[1]; $existing = DatasourceManager::create($handle, array(), false); $order = isset($existing->dsParamORDER) ? $existing->dsParamORDER : 'asc'; if (!$existing->allowEditorToParse()) { redirect(SYMPHONY_URL . '/blueprints/datasources/info/' . $handle . '/'); } $about = $existing->about(); $fields['name'] = $about['name']; $fields['order'] = $order == 'rand' ? 'random' : $order; $fields['param'] = isset($existing->dsParamPARAMOUTPUT) ? $existing->dsParamPARAMOUTPUT : null; $fields['required_url_param'] = isset($existing->dsParamREQUIREDPARAM) ? trim($existing->dsParamREQUIREDPARAM) : null; $fields['negate_url_param'] = isset($existing->dsParamNEGATEPARAM) ? trim($existing->dsParamNEGATEPARAM) : null; if (isset($existing->dsParamINCLUDEDELEMENTS) && is_array($existing->dsParamINCLUDEDELEMENTS)) { $fields['xml_elements'] = $existing->dsParamINCLUDEDELEMENTS; } else { $fields['xml_elements'] = array(); } $fields['sort'] = isset($existing->dsParamSORT) ? $existing->dsParamSORT : null; $fields['paginate_results'] = isset($existing->dsParamPAGINATERESULTS) ? $existing->dsParamPAGINATERESULTS : 'yes'; $fields['page_number'] = isset($existing->dsParamSTARTPAGE) ? $existing->dsParamSTARTPAGE : '1'; $fields['group'] = isset($existing->dsParamGROUP) ? $existing->dsParamGROUP : null; $fields['html_encode'] = isset($existing->dsParamHTMLENCODE) ? $existing->dsParamHTMLENCODE : 'no'; $fields['associated_entry_counts'] = isset($existing->dsParamASSOCIATEDENTRYCOUNTS) ? $existing->dsParamASSOCIATEDENTRYCOUNTS : 'no'; $fields['redirect_on_empty'] = isset($existing->dsParamREDIRECTONEMPTY) ? $existing->dsParamREDIRECTONEMPTY : 'no'; $fields['redirect_on_forbidden'] = isset($existing->dsParamREDIRECTONFORBIDDEN) ? $existing->dsParamREDIRECTONFORBIDDEN : 'no'; $fields['redirect_on_required'] = isset($existing->dsParamREDIRECTONREQUIRED) ? $existing->dsParamREDIRECTONREQUIRED : 'no'; if (!isset($existing->dsParamFILTERS) || !is_array($existing->dsParamFILTERS)) { $existing->dsParamFILTERS = array(); } if (!empty($existing->dsParamFILTERS)) { $existing->dsParamFILTERS = array_map('stripslashes', $existing->dsParamFILTERS); } $fields['source'] = $existing->getSource(); $provided = false; if (!empty($providers)) { foreach ($providers as $providerClass => $provider) { if ($fields['source'] == call_user_func(array($providerClass, 'getClass'))) { $fields = array_merge($fields, $existing->settings()); $provided = true; break; } } } if ($provided === false) { switch ($fields['source']) { case 'authors': $fields['filter']['author'] = $existing->dsParamFILTERS; break; case 'navigation': $fields['filter']['navigation'] = $existing->dsParamFILTERS; break; case 'static_xml': // Symphony 2.3+ if (isset($existing->dsParamSTATIC)) { $fields['static_xml'] = trim($existing->dsParamSTATIC); // Handle Symphony 2.2.2 to 2.3 DS's } elseif (isset($existing->dsSTATIC)) { $fields['static_xml'] = trim($existing->dsSTATIC); // Handle pre Symphony 2.2.1 Static DS's } else { $fields['static_xml'] = trim($existing->grab()); } break; default: $fields['filter'][$fields['source']] = $existing->dsParamFILTERS; $fields['max_records'] = $existing->dsParamLIMIT; break; } } } else { $fields['max_records'] = '20'; $fields['page_number'] = '1'; $fields['order'] = 'desc'; } // Handle name on edited changes, or from reading an edited datasource if (isset($about['name'])) { $name = $about['name']; } elseif (isset($fields['name'])) { $name = $fields['name']; } $this->setPageType('form'); $this->setTitle(__($isEditing ? '%1$s – %2$s – %3$s' : '%2$s – %3$s', array($name, __('Data Sources'), __('Symphony')))); $this->appendSubheading($isEditing ? $name : __('Untitled')); $this->insertBreadcrumbs(array(Widget::Anchor(__('Data Sources'), SYMPHONY_URL . '/blueprints/datasources/'))); // Sources $sources = new XMLElement('div', null, array('class' => 'apply actions')); $div = new XMLElement('div'); $label = Widget::Label(__('Source'), null, 'apply-label-left'); $sources->appendChild($label); $sources->appendChild($div); $sections = SectionManager::fetch(null, 'ASC', 'name'); if (!is_array($sections)) { $sections = array(); } $field_groups = array(); foreach ($sections as $section) { $field_groups[$section->get('id')] = array('fields' => $section->fetchFields(), 'section' => $section); } $options = array(array('label' => __('System'), 'data-label' => 'system', 'options' => array(array('authors', $fields['source'] == 'authors', __('Authors'), null, null, array('data-context' => 'authors')), array('navigation', $fields['source'] == 'navigation', __('Navigation'), null, null, array('data-context' => 'navigation')))), array('label' => __('Custom XML'), 'data-label' => 'custom-xml', 'options' => array(array('static_xml', $fields['source'] == 'static_xml', __('Static XML'), null, null, array('data-context' => 'static-xml'))))); // Loop over the datasource providers if (!empty($providers)) { $p = array('label' => __('From extensions'), 'data-label' => 'from_extensions', 'options' => array()); foreach ($providers as $providerClass => $provider) { $p['options'][] = array($providerClass, $fields['source'] == $providerClass, $provider, null, null, array('data-context' => Lang::createHandle($provider))); } $options[] = $p; } // Add Sections if (is_array($sections) && !empty($sections)) { array_unshift($options, array('label' => __('Sections'), 'data-label' => 'sections', 'options' => array())); foreach ($sections as $s) { $options[0]['options'][] = array($s->get('id'), $fields['source'] == $s->get('id'), General::sanitize($s->get('name'))); } } $div->appendChild(Widget::Select('source', $options, array('id' => 'ds-context'))); $this->Context->prependChild($sources); $this->Form->appendChild(Widget::Input('fields[source]', null, 'hidden', array('id' => 'ds-source'))); // Name $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', __('Essentials'))); $group = new XMLElement('div'); $label = Widget::Label(__('Name')); $label->appendChild(Widget::Input('fields[name]', General::sanitize($fields['name']))); if (isset($this->_errors['name'])) { $group->appendChild(Widget::Error($label, $this->_errors['name'])); } else { $group->appendChild($label); } $fieldset->appendChild($group); $this->Form->appendChild($fieldset); // Conditions $fieldset = new XMLElement('fieldset'); $this->setContext($fieldset, array('sections', 'system', 'custom-xml')); $fieldset->appendChild(new XMLElement('legend', __('Conditions'))); $p = new XMLElement('p', __('Leaving these fields empty will always execute the data source.')); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); $group = new XMLElement('div'); $group->setAttribute('class', 'two columns'); $label = Widget::Label(__('Required Parameter')); $label->setAttribute('class', 'column ds-param'); $label->appendChild(new XMLElement('i', __('Optional'))); $input = Widget::Input('fields[required_url_param]', trim($fields['required_url_param']), 'text', array('placeholder' => __('$param'), 'data-search-types' => 'parameters', 'data-trigger' => '$')); $label->appendChild($input); $group->appendChild($label); $label = Widget::Label(__('Forbidden Parameter')); $label->setAttribute('class', 'column ds-param'); $label->appendChild(new XMLElement('i', __('Optional'))); $input = Widget::Input('fields[negate_url_param]', trim($fields['negate_url_param']), 'text', array('placeholder' => __('$param'), 'data-search-types' => 'parameters', 'data-trigger' => '$')); $label->appendChild($input); $group->appendChild($label); $fieldset->appendChild($group); $group = new XMLElement('div'); $group->setAttribute('class', 'two columns ds-param'); $label = Widget::Checkbox('fields[redirect_on_required]', $fields['redirect_on_required'], __('Redirect to 404 page when the required parameter is not present')); $label->setAttribute('class', 'column'); $group->appendChild($label); $label = Widget::Checkbox('fields[redirect_on_forbidden]', $fields['redirect_on_forbidden'], __('Redirect to 404 page when the forbidden parameter is present')); $label->setAttribute('class', 'column'); $group->appendChild($label); $fieldset->appendChild($group); $label = Widget::Checkbox('fields[redirect_on_empty]', $fields['redirect_on_empty'], __('Redirect to 404 page when no results are found')); $label->setAttribute('class', 'column'); $fieldset->appendChild($label); $this->Form->appendChild($fieldset); // Filters $fieldset = new XMLElement('fieldset'); $this->setContext($fieldset, array('sections', 'system')); $fieldset->appendChild(new XMLElement('legend', __('Filters'))); $p = new XMLElement('p', __('Use %s syntax to filter by page parameters. A default value can be set using %s.', array('<code>{' . __('$param') . '}</code>', '<code>{' . __('$param:default') . '}</code>'))); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); foreach ($field_groups as $section_id => $section_data) { $div = new XMLElement('div'); $div->setAttribute('class', 'contextual frame filters-duplicator'); $div->setAttribute('data-context', 'section-' . $section_id); $div->setAttribute('data-interactive', 'data-interactive'); $ol = new XMLElement('ol'); $ol->setAttribute('class', 'suggestable'); $ol->setAttribute('data-interactive', 'data-interactive'); $ol->setAttribute('data-add', __('Add filter')); $ol->setAttribute('data-remove', __('Remove filter')); // Add system:id filter if (isset($fields['filter'][$section_id]['system:id']) || isset($fields['filter'][$section_id]['id'])) { $id = isset($fields['filter'][$section_id]['system:id']) ? $fields['filter'][$section_id]['system:id'] : $fields['filter'][$section_id]['id']; $li = new XMLElement('li'); $li->setAttribute('class', 'unique'); $li->setAttribute('data-type', 'system:id'); $li->appendChild(new XMLElement('header', '<h4>' . __('System ID') . '</h4>')); $label = Widget::Label(__('Value')); $input = Widget::Input('fields[filter][' . $section_id . '][system:id]', General::sanitize($id)); $input->setAttribute('data-search-types', 'parameters'); $input->setAttribute('data-trigger', '{$'); $label->appendChild($input); $li->appendChild($label); $ol->appendChild($li); } $li = new XMLElement('li'); $li->setAttribute('class', 'unique template'); $li->setAttribute('data-type', 'system:id'); $li->appendChild(new XMLElement('header', '<h4>' . __('System ID') . '</h4>')); $label = Widget::Label(__('Value')); $input = Widget::Input('fields[filter][' . $section_id . '][system:id]', General::sanitize($id)); $input->setAttribute('data-search-types', 'parameters'); $input->setAttribute('data-trigger', '{$'); $label->appendChild($input); $li->appendChild($label); $ol->appendChild($li); // Add system:date filter if (isset($fields['filter'][$section_id]['system:creation-date']) || isset($fields['filter'][$section_id]['system:date'])) { $creation_date = isset($fields['filter'][$section_id]['system:creation-date']) ? $fields['filter'][$section_id]['system:creation-date'] : $fields['filter'][$section_id]['system:date']; $li = new XMLElement('li'); $li->setAttribute('class', 'unique'); $li->setAttribute('data-type', 'system:creation-date'); $li->appendChild(new XMLElement('header', '<h4>' . __('System Creation Date') . '</h4>')); $label = Widget::Label(__('Value')); $input = Widget::Input('fields[filter][' . $section_id . '][system:creation-date]', General::sanitize($creation_date)); $input->setAttribute('data-search-types', 'parameters'); $input->setAttribute('data-trigger', '{$'); $label->appendChild($input); $li->appendChild($label); $ol->appendChild($li); } $li = new XMLElement('li'); $li->setAttribute('class', 'unique template'); $li->setAttribute('data-type', 'system:creation-date'); $li->appendChild(new XMLElement('header', '<h4>' . __('System Creation Date') . '</h4>')); $label = Widget::Label(__('Value')); $input = Widget::Input('fields[filter][' . $section_id . '][system:creation-date]'); $input->setAttribute('data-search-types', 'parameters'); $input->setAttribute('data-trigger', '{$'); $label->appendChild($input); $li->appendChild($label); $ol->appendChild($li); if (isset($fields['filter'][$section_id]['system:modification-date'])) { $li = new XMLElement('li'); $li->setAttribute('class', 'unique'); $li->setAttribute('data-type', 'system:modification-date'); $li->appendChild(new XMLElement('header', '<h4>' . __('System Modification Date') . '</h4>')); $label = Widget::Label(__('Value')); $input = Widget::Input('fields[filter][' . $section_id . '][system:modification-date]', General::sanitize($fields['filter'][$section_id]['system:modification-date'])); $input->setAttribute('data-search-types', 'parameters'); $input->setAttribute('data-trigger', '{$'); $label->appendChild($input); $li->appendChild($label); $ol->appendChild($li); } $li = new XMLElement('li'); $li->setAttribute('class', 'unique template'); $li->setAttribute('data-type', 'system:modification-date'); $li->appendChild(new XMLElement('header', '<h4>' . __('System Modification Date') . '</h4>')); $label = Widget::Label(__('Value')); $input = Widget::Input('fields[filter][' . $section_id . '][system:modification-date]'); $input->setAttribute('data-search-types', 'parameters'); $input->setAttribute('data-trigger', '{$'); $label->appendChild($input); $li->appendChild($label); $ol->appendChild($li); if (is_array($section_data['fields']) && !empty($section_data['fields'])) { foreach ($section_data['fields'] as $field) { if (!$field->canFilter()) { continue; } if (isset($fields['filter'][$section_id], $fields['filter'][$section_id][$field->get('id')])) { $wrapper = new XMLElement('li'); $wrapper->setAttribute('class', 'unique'); $wrapper->setAttribute('data-type', $field->get('element_name')); $errors = isset($this->_errors[$field->get('id')]) ? $this->_errors[$field->get('id')] : array(); $field->displayDatasourceFilterPanel($wrapper, $fields['filter'][$section_id][$field->get('id')], $errors, $section_id); $ol->appendChild($wrapper); } $wrapper = new XMLElement('li'); $wrapper->setAttribute('class', 'unique template'); $wrapper->setAttribute('data-type', $field->get('element_name')); $field->displayDatasourceFilterPanel($wrapper, null, null, $section_id); $ol->appendChild($wrapper); } } $div->appendChild($ol); $fieldset->appendChild($div); } $div = new XMLElement('div'); $div->setAttribute('class', 'contextual frame filters-duplicator'); $div->setAttribute('data-context', 'authors'); $div->setAttribute('data-interactive', 'data-interactive'); $ol = new XMLElement('ol'); $ol->setAttribute('class', 'suggestable'); $ol->setAttribute('data-interactive', 'data-interactive'); $ol->setAttribute('data-add', __('Add filter')); $ol->setAttribute('data-remove', __('Remove filter')); if (!isset($fields['filter']['author'])) { $fields['filter']['author'] = array('id' => null, 'username' => null, 'first_name' => null, 'last_name' => null, 'email' => null, 'user_type' => null); } $this->__appendAuthorFilter($ol, __('ID'), 'id', $fields['filter']['author']['id'], !isset($fields['filter']['author']['id'])); $this->__appendAuthorFilter($ol, __('Username'), 'username', $fields['filter']['author']['username'], !isset($fields['filter']['author']['username'])); $this->__appendAuthorFilter($ol, __('First Name'), 'first_name', $fields['filter']['author']['first_name'], !isset($fields['filter']['author']['first_name'])); $this->__appendAuthorFilter($ol, __('Last Name'), 'last_name', $fields['filter']['author']['last_name'], !isset($fields['filter']['author']['last_name'])); $this->__appendAuthorFilter($ol, __('Email'), 'email', $fields['filter']['author']['email'], !isset($fields['filter']['author']['email'])); $this->__appendAuthorFilter($ol, __('User Type'), 'user_type', $fields['filter']['author']['user_type'], !isset($fields['filter']['author']['user_type'])); $div->appendChild($ol); $fieldset->appendChild($div); $div = new XMLElement('div'); $div->setAttribute('class', 'contextual frame filters-duplicator'); $div->setAttribute('data-context', 'navigation'); $div->setAttribute('data-interactive', 'data-interactive'); $ol = new XMLElement('ol'); $ol->setAttribute('class', 'suggestable'); $ol->setAttribute('data-interactive', 'data-interactive'); $ol->setAttribute('data-add', __('Add filter')); $ol->setAttribute('data-remove', __('Remove filter')); $ul = new XMLElement('ul'); $ul->setAttribute('class', 'tags'); $ul->setAttribute('data-interactive', 'data-interactive'); $pages = PageManager::fetch(false, array('*'), array(), 'title ASC'); foreach ($pages as $page) { $ul->appendChild(new XMLElement('li', preg_replace('/\\/{2,}/i', '/', '/' . $page['path'] . '/' . $page['handle']))); } if (isset($fields['filter']['navigation']['parent'])) { $li = new XMLElement('li'); $li->setAttribute('class', 'unique'); $li->setAttribute('data-type', 'parent'); $li->appendChild(new XMLElement('header', '<h4>' . __('Parent Page') . '</h4>')); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[filter][navigation][parent]', General::sanitize($fields['filter']['navigation']['parent']))); $li->appendChild($label); $li->appendChild($ul); $ol->appendChild($li); } $li = new XMLElement('li'); $li->setAttribute('class', 'unique template'); $li->setAttribute('data-type', 'parent'); $li->appendChild(new XMLElement('header', '<h4>' . __('Parent Page') . '</h4>')); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[filter][navigation][parent]')); $li->appendChild($label); $li->appendChild($ul); $ol->appendChild($li); $ul = new XMLElement('ul'); $ul->setAttribute('class', 'tags'); $ul->setAttribute('data-interactive', 'data-interactive'); if ($types = PageManager::fetchAvailablePageTypes()) { foreach ($types as $type) { $ul->appendChild(new XMLElement('li', $type)); } } if (isset($fields['filter']['navigation']['type'])) { $li = new XMLElement('li'); $li->setAttribute('class', 'unique'); $li->setAttribute('data-type', 'type'); $li->appendChild(new XMLElement('header', '<h4>' . __('Page Type') . '</h4>')); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[filter][navigation][type]', General::sanitize($fields['filter']['navigation']['type']))); $li->appendChild($label); $li->appendChild($ul); $ol->appendChild($li); } $li = new XMLElement('li'); $li->setAttribute('class', 'unique template'); $li->appendChild(new XMLElement('header', '<h4>' . __('Page Type') . '</h4>')); $li->setAttribute('data-type', 'type'); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[filter][navigation][type]')); $li->appendChild($label); $li->appendChild($ul); $ol->appendChild($li); $div->appendChild($ol); $fieldset->appendChild($div); $this->Form->appendChild($fieldset); // Sorting $fieldset = new XMLElement('fieldset'); $this->setContext($fieldset, array('sections', 'system')); $fieldset->appendChild(new XMLElement('legend', __('Sorting'))); $p = new XMLElement('p', __('Use %s syntax to order by page parameters.', array('<code>{' . __('$param') . '}</code>'))); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); $div = new XMLElement('div'); $label = Widget::Label(__('Sort By')); $options = array(array('label' => __('Authors'), 'data-label' => 'authors', 'options' => array(array('id', $fields['source'] == 'authors' && $fields['sort'] == 'id', __('Author ID')), array('username', $fields['source'] == 'authors' && $fields['sort'] == 'username', __('Username')), array('first-name', $fields['source'] == 'authors' && $fields['sort'] == 'first-name', __('First Name')), array('last-name', $fields['source'] == 'authors' && $fields['sort'] == 'last-name', __('Last Name')), array('email', $fields['source'] == 'authors' && $fields['sort'] == 'email', __('Email')), array('status', $fields['source'] == 'authors' && $fields['sort'] == 'status', __('Status')))), array('label' => __('Navigation'), 'data-label' => 'navigation', 'options' => array(array('id', $fields['source'] == 'navigation' && $fields['sort'] == 'id', __('Page ID')), array('handle', $fields['source'] == 'navigation' && $fields['sort'] == 'handle', __('Handle')), array('sortorder', $fields['source'] == 'navigation' && $fields['sort'] == 'sortorder', __('Sort Order'))))); foreach ($field_groups as $section_id => $section_data) { $optgroup = array('label' => General::sanitize($section_data['section']->get('name')), 'data-label' => 'section-' . $section_data['section']->get('id'), 'options' => array(array('system:id', $fields['source'] == $section_id && $fields['sort'] == 'system:id', __('System ID')), array('system:creation-date', $fields['source'] == $section_id && ($fields['sort'] == 'system:creation-date' || $fields['sort'] == 'system:date'), __('System Creation Date')), array('system:modification-date', $fields['source'] == $section_id && $fields['sort'] == 'system:modification-date', __('System Modification Date')))); if (is_array($section_data['fields']) && !empty($section_data['fields'])) { foreach ($section_data['fields'] as $input) { if (!$input->isSortable()) { continue; } $optgroup['options'][] = array($input->get('element_name'), $fields['source'] == $section_id && $input->get('element_name') == $fields['sort'], $input->get('label')); } } $options[] = $optgroup; } $label->appendChild(Widget::Select('fields[sort]', $options)); $div->appendChild($label); $label = Widget::Label(__('Sort Order')); $label->setAttribute('class', 'ds-param'); $input = Widget::Input('fields[order]', $fields['order'], 'text', array('placeholder' => __('{$param}'), 'data-search-types' => 'parameters', 'data-trigger' => '{$')); $label->appendChild($input); $div->appendChild($label); $orders = new XMLElement('ul'); $orders->setAttribute('class', 'tags singular'); $orders->setAttribute('data-interactive', 'data-interactive'); $orders->appendChild(new XMLElement('li', 'asc')); $orders->appendChild(new XMLElement('li', 'desc')); $orders->appendChild(new XMLElement('li', 'random')); $div->appendChild($orders); $fieldset->appendChild($div); $this->Form->appendChild($fieldset); // Grouping $fieldset = new XMLElement('fieldset'); $this->setContext($fieldset, array('sections', 'authors')); $fieldset->appendChild(new XMLElement('legend', __('Grouping'))); $label = Widget::Label(__('Group By')); $options = array(array('', null, __('None'))); foreach ($field_groups as $section_id => $section_data) { $optgroup = array('label' => $section_data['section']->get('name'), 'data-label' => 'section-' . $section_data['section']->get('id'), 'options' => array()); if (is_array($section_data['fields']) && !empty($section_data['fields'])) { foreach ($section_data['fields'] as $input) { if (!$input->allowDatasourceOutputGrouping()) { continue; } $optgroup['options'][] = array($input->get('id'), $fields['source'] == $section_id && $fields['group'] == $input->get('id'), $input->get('label')); } } $options[] = $optgroup; } $label->appendChild(Widget::Select('fields[group]', $options)); $fieldset->appendChild($label); $this->Form->appendChild($fieldset); // Pagination $fieldset = new XMLElement('fieldset'); $this->setContext($fieldset, array('sections')); $fieldset->appendChild(new XMLElement('legend', __('Pagination'))); $p = new XMLElement('p', __('Use %s syntax to limit by page parameters.', array('<code>{' . __('$param') . '}</code>'))); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); $group = new XMLElement('div'); $group->setAttribute('class', 'two columns pagination'); $label = Widget::Label(__('Entries per Page')); $label->setAttribute('class', 'column ds-param'); $input = Widget::Input('fields[max_records]', isset($fields['max_records']) ? $fields['max_records'] : '10', 'text', array('placeholder' => __('{$param}'), 'data-search-types' => 'parameters', 'data-trigger' => '{$')); $label->appendChild($input); $group->appendChild($label); $label = Widget::Label(__('Page Number')); $label->setAttribute('class', 'column ds-param'); $input = Widget::Input('fields[page_number]', $fields['page_number'], 'text', array('placeholder' => __('{$param}'), 'data-search-types' => 'parameters', 'data-trigger' => '{$')); $label->appendChild($input); $group->appendChild($label); $fieldset->appendChild($group); $label = Widget::Checkbox('fields[paginate_results]', $fields['paginate_results'], __('Enable pagination')); $fieldset->appendChild($label); $this->Form->appendChild($fieldset); // Content $fieldset = new XMLElement('fieldset'); $this->setContext($fieldset, array('sections', 'authors')); $fieldset->appendChild(new XMLElement('legend', __('Content'))); // XML $group = new XMLElement('div', null, array('class' => 'two columns')); $label = Widget::Label(__('Included Elements')); $label->setAttribute('class', 'column'); $options = array(array('label' => __('Authors'), 'data-label' => 'authors', 'options' => array(array('username', $fields['source'] == 'authors' && in_array('username', $fields['xml_elements']), 'username'), array('name', $fields['source'] == 'authors' && in_array('name', $fields['xml_elements']), 'name'), array('email', $fields['source'] == 'authors' && in_array('email', $fields['xml_elements']), 'email'), array('author-token', $fields['source'] == 'authors' && in_array('author-token', $fields['xml_elements']), 'author-token'), array('default-area', $fields['source'] == 'authors' && in_array('default-area', $fields['xml_elements']), 'default-area')))); foreach ($field_groups as $section_id => $section_data) { $optgroup = array('label' => General::sanitize($section_data['section']->get('name')), 'data-label' => 'section-' . $section_data['section']->get('id'), 'options' => array(array('system:pagination', $fields['source'] == $section_id && in_array('system:pagination', $fields['xml_elements']), 'system: pagination'), array('system:date', $fields['source'] == $section_id && in_array('system:date', $fields['xml_elements']), 'system: date'))); if (is_array($section_data['fields']) && !empty($section_data['fields'])) { foreach ($section_data['fields'] as $field) { $elements = $field->fetchIncludableElements(); if (is_array($elements) && !empty($elements)) { foreach ($elements as $name) { $selected = false; if ($fields['source'] == $section_id && in_array($name, $fields['xml_elements'])) { $selected = true; } $optgroup['options'][] = array($name, $selected, $name); } } } } $options[] = $optgroup; } $label->appendChild(Widget::Select('fields[xml_elements][]', $options, array('multiple' => 'multiple'))); $group->appendChild($label); // Support multiple parameters if (!isset($fields['param'])) { $fields['param'] = array(); } elseif (!is_array($fields['param'])) { $fields['param'] = array($fields['param']); } $label = Widget::Label(__('Parameters')); $label->setAttribute('class', 'column'); $prefix = '$ds-' . (isset($this->_context[1]) ? Lang::createHandle($fields['name']) : __('untitled')) . '.'; $options = array(array('label' => __('Authors'), 'data-label' => 'authors', 'options' => array())); foreach (array('id', 'username', 'name', 'email', 'user_type') as $p) { $options[0]['options'][] = array($p, $fields['source'] == 'authors' && in_array($p, $fields['param']), $prefix . $p, null, null, array('data-handle' => $p)); } foreach ($field_groups as $section_id => $section_data) { $optgroup = array('label' => $section_data['section']->get('name'), 'data-label' => 'section-' . $section_data['section']->get('id'), 'options' => array()); foreach (array('id', 'creation-date', 'modification-date', 'author') as $p) { $option = array('system:' . $p, $fields['source'] == $section_id && in_array('system:' . $p, $fields['param']), $prefix . 'system-' . $p, null, null, array('data-handle' => 'system-' . $p)); // Handle 'system:date' as an output paramater (backwards compatibility) if ($p === 'creation-date') { if ($fields['source'] == $section_id && in_array('system:date', $fields['param'])) { $option[1] = true; } } $optgroup['options'][] = $option; } if (is_array($section_data['fields']) && !empty($section_data['fields'])) { foreach ($section_data['fields'] as $input) { if (!$input->allowDatasourceParamOutput()) { continue; } $optgroup['options'][] = array($input->get('element_name'), $fields['source'] == $section_id && in_array($input->get('element_name'), $fields['param']), $prefix . $input->get('element_name'), null, null, array('data-handle' => $input->get('element_name'))); } } $options[] = $optgroup; } $label->appendChild(Widget::Select('fields[param][]', $options, array('multiple' => 'multiple'))); $group->appendChild($label); $fieldset->appendChild($group); // Associations $label = Widget::Checkbox('fields[associated_entry_counts]', $fields['associated_entry_counts'], __('Include a count of entries in associated sections')); $this->setContext($label, array('sections')); $fieldset->appendChild($label); // Encoding $label = Widget::Checkbox('fields[html_encode]', $fields['html_encode'], __('HTML-encode text')); $this->setContext($label, array('sections')); $fieldset->appendChild($label); $this->Form->appendChild($fieldset); // Static XML if (!isset($fields['static_xml'])) { $fields['static_xml'] = null; } $fieldset = new XMLElement('fieldset'); $this->setContext($fieldset, array('static-xml')); $fieldset->appendChild(new XMLElement('legend', __('Static XML'))); $p = new XMLElement('p', __('Enter valid XML, exclude XML declaration')); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); $label = Widget::Label(); $label->appendChild(Widget::Textarea('fields[static_xml]', 12, 50, General::sanitize(stripslashes($fields['static_xml'])), array('class' => 'code', 'placeholder' => '<static>content</static>'))); if (isset($this->_errors['static_xml'])) { $fieldset->appendChild(Widget::Error($label, $this->_errors['static_xml'])); } else { $fieldset->appendChild($label); } $this->Form->appendChild($fieldset); // Connections $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', __('Attach to Pages'))); $p = new XMLElement('p', __('The data will only be available on the selected pages.')); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); $div = new XMLElement('div'); $label = Widget::Label(__('Pages')); $pages = PageManager::fetch(); $ds_handle = str_replace('-', '_', Lang::createHandle($fields['name'])); $connections = ResourceManager::getAttachedPages(ResourceManager::RESOURCE_TYPE_DS, $ds_handle); $selected = array(); foreach ($connections as $connection) { $selected[] = $connection['id']; } $options = array(); foreach ($pages as $page) { $options[] = array($page['id'], in_array($page['id'], $selected), PageManager::resolvePageTitle($page['id'])); } $label->appendChild(Widget::Select('fields[connections][]', $options, array('multiple' => 'multiple'))); $div->appendChild($label); $fieldset->appendChild($div); $this->Form->appendChild($fieldset); // Call the provided datasources to let them inject their filters // @todo Ideally when a new Datasource is chosen an AJAX request will fire // to get the HTML from the extension. This is hardcoded for now into // creating a 'big' page and then hiding the fields with JS if (!empty($providers)) { foreach ($providers as $providerClass => $provider) { call_user_func_array(array($providerClass, 'buildEditor'), array($this->Form, &$this->_errors, $fields, $handle)); } } $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', $isEditing ? __('Save Changes') : __('Create Data Source'), 'submit', array('accesskey' => 's'))); if ($isEditing) { $button = new XMLElement('button', __('Delete')); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this data source'), 'type' => 'submit', 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this data source?'))); $div->appendChild($button); } $this->Form->appendChild($div); }
public function getExampleFormMarkup() { $label = Widget::Label($this->get('label')); $label->appendChild(Widget::Textarea('fields[' . $this->get('element_name') . ']', $this->get('size'), 50)); return $label; }
function __form() { $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR); } if (isset($this->_context[2])) { switch ($this->_context[2]) { case 'saved': $this->pageAlert(__('Data source updated at %1$s. <a href="%2$s">Create another?</a> <a href="%2$s">View all Data sources</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/datasources/new/', URL . '/symphony/blueprints/components/')), Alert::SUCCESS); break; case 'created': $this->pageAlert(__('Data source created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Data source</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/datasources/new/', URL . '/symphony/blueprints/components/')), Alert::SUCCESS); break; } } $sectionManager = new SectionManager($this->_Parent); if (isset($_POST['fields'])) { $fields = $_POST['fields']; if (!in_array($fields['source'], array('authors', 'navigation', 'dynamic_xml', 'static_xml')) && is_array($fields['filter']) && !empty($fields['filter'])) { $filters = array(); foreach ($fields['filter'] as $f) { foreach ($f as $key => $val) { $filters[$key] = $val; } } $fields['filter'][$fields['source']] = $filters; } } elseif ($this->_context[0] == 'edit') { $isEditing = true; $handle = $this->_context[1]; $datasourceManager = new DatasourceManager($this->_Parent); $existing =& $datasourceManager->create($handle, NULL, false); if (!$existing->allowEditorToParse()) { redirect(URL . '/symphony/blueprints/datasources/info/' . $handle . '/'); } $about = $existing->about(); $fields['name'] = $about['name']; $fields['order'] = $existing->dsParamORDER; $fields['param'] = $existing->dsParamPARAMOUTPUT; $fields['required_url_param'] = $existing->dsParamREQUIREDPARAM; $fields['xml_elements'] = $existing->dsParamINCLUDEDELEMENTS; $fields['sort'] = $existing->dsParamSORT; $fields['page_number'] = $existing->dsParamSTARTPAGE; $fields['limit_type'] = $existing->dsParamLIMITTYPE; $fields['group'] = $existing->dsParamGROUP; $fields['html_encode'] = $existing->dsParamHTMLENCODE; if ($existing->dsParamREDIRECTONEMPTY == 'yes') { $fields['redirect_on_empty'] = 'yes'; } $existing->dsParamFILTERS = @array_map('stripslashes', $existing->dsParamFILTERS); $fields['source'] = $existing->getSource(); switch ($fields['source']) { case 'authors': $fields['filter']['author'] = $existing->dsParamFILTERS; $fields['max_records'] = $existing->dsParamLIMIT; break; case 'navigation': $fields['filter']['navigation'] = $existing->dsParamFILTERS; break; case 'dynamic_xml': $namespaces = $existing->dsParamFILTERS; $fields['dynamic_xml'] = array('namespace' => array()); $fields['dynamic_xml']['namespace']['name'] = @array_keys($namespaces); $fields['dynamic_xml']['namespace']['uri'] = @array_values($namespaces); $fields['dynamic_xml']['url'] = $existing->dsParamURL; $fields['dynamic_xml']['xpath'] = $existing->dsParamXPATH; $fields['dynamic_xml']['cache'] = $existing->dsParamCACHE; break; case 'static_xml': $fields['static_xml'] = trim($existing->grab()); break; default: $fields['filter'][$fields['source']] = $existing->dsParamFILTERS; $fields['max_records'] = $existing->dsParamLIMIT; break; } } else { $fields['dynamic_xml']['url'] = 'http://'; $fields['dynamic_xml']['cache'] = '30'; $fields['dynamic_xml']['xpath'] = '/'; $fields['max_records'] = '20'; $fields['page_number'] = '1'; $fields['order'] = 'desc'; $fields['limit_type'] = 'entries'; } $this->setPageType('form'); $this->setTitle(__($isEditing ? '%1$s – %2$s – %3$s' : '%1$s – %2$s', array(__('Symphony'), __('Data Sources'), $about['name']))); $this->appendSubheading($isEditing ? $about['name'] : __('Untitled')); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings'); $fieldset->appendChild(new XMLElement('legend', __('Essentials'))); $div = new XMLElement('div'); $div->setAttribute('class', 'group'); $label = Widget::Label(__('Name')); $label->appendChild(Widget::Input('fields[name]', General::sanitize($fields['name']))); if (isset($this->_errors['name'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['name'])); } else { $div->appendChild($label); } $label = Widget::Label(__('Source')); $sections = $sectionManager->fetch(NULL, 'ASC', 'name'); foreach ($sections as $section) { $field_groups[$section->get('id')] = array('fields' => $section->fetchFields(), 'section' => $section); } $options = array(array('label' => __('System'), 'options' => array(array(__('authors'), $fields['source'] == __('authors'), __('Authors')), array(__('navigation'), $fields['source'] == __('navigation'), __('Navigation')))), array('label' => __('Custom XML'), 'options' => array(array(__('dynamic_xml'), $fields['source'] == __('dynamic_xml'), __('Dynamic XML')), array(__('static_xml'), $fields['source'] == __('static_xml'), __('Static XML'))))); if (is_array($sections) && !empty($sections)) { array_unshift($options, array('label' => __('Sections'), 'options' => array())); foreach ($sections as $s) { $options[0]['options'][] = array($s->get('id'), $fields['source'] == $s->get('id'), $s->get('name')); } } $label->appendChild(Widget::Select('fields[source]', $options, array('id' => 'context'))); $div->appendChild($label); $fieldset->appendChild($div); $this->Form->appendChild($fieldset); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings contextual ' . __('sections') . ' ' . __('authors') . ' ' . __('navigation') . ' ' . __('Sections') . ' ' . __('System')); $fieldset->appendChild(new XMLElement('legend', __('Filter Results'))); $p = new XMLElement('p', __('Use <code>{$param}</code> syntax to filter by page parameters.')); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); foreach ($field_groups as $section_id => $section_data) { $div = new XMLElement('div'); $div->setAttribute('class', 'subsection contextual ' . $section_data['section']->get('id')); $div->appendChild(new XMLElement('h3', __('Filter %s by', array($section_data['section']->get('name'))))); $ol = new XMLElement('ol'); if (isset($fields['filter'][$section_data['section']->get('id')]['id'])) { $li = new XMLElement('li'); $li->setAttribute('class', 'unique'); $li->appendChild(new XMLElement('h4', __('System ID'))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[filter][' . $section_data['section']->get('id') . '][id]', General::sanitize($fields['filter'][$section_data['section']->get('id')]['id']))); $li->appendChild($label); $ol->appendChild($li); } $li = new XMLElement('li'); $li->setAttribute('class', 'unique template'); $li->appendChild(new XMLElement('h4', __('System ID'))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[filter][' . $section_data['section']->get('id') . '][id]')); $li->appendChild($label); $ol->appendChild($li); foreach ($section_data['fields'] as $input) { if (!$input->canFilter()) { continue; } if (isset($fields['filter'][$section_data['section']->get('id')][$input->get('id')])) { $wrapper = new XMLElement('li'); $wrapper->setAttribute('class', 'unique'); $input->displayDatasourceFilterPanel($wrapper, $fields['filter'][$section_data['section']->get('id')][$input->get('id')], $this->_errors[$input->get('id')], $section_data['section']->get('id')); $ol->appendChild($wrapper); } $wrapper = new XMLElement('li'); $wrapper->setAttribute('class', 'unique template'); $input->displayDatasourceFilterPanel($wrapper, NULL, NULL, $section_data['section']->get('id')); $ol->appendChild($wrapper); } $div->appendChild($ol); $fieldset->appendChild($div); } $div = new XMLElement('div'); $div->setAttribute('class', 'subsection contextual ' . __('authors')); $div->appendChild(new XMLElement('h3', __('Filter Authors by'))); $ol = new XMLElement('ol'); $this->__appendAuthorFilter($ol, __('ID'), 'id', $fields['filter']['author']['id'], !isset($fields['filter']['author']['id'])); $this->__appendAuthorFilter($ol, __('Username'), 'username', $fields['filter']['author']['username'], !isset($fields['filter']['author']['username'])); $this->__appendAuthorFilter($ol, __('First Name'), 'first_name', $fields['filter']['author']['first_name'], !isset($fields['filter']['author']['first_name'])); $this->__appendAuthorFilter($ol, __('Last Name'), 'last_name', $fields['filter']['author']['last_name'], !isset($fields['filter']['author']['last_name'])); $this->__appendAuthorFilter($ol, __('Email'), 'email', $fields['filter']['author']['email'], !isset($fields['filter']['author']['email'])); $this->__appendAuthorFilter($ol, __('User Type'), 'user_type', $fields['filter']['author']['user_type'], !isset($fields['filter']['author']['user_type'])); $div->appendChild($ol); $fieldset->appendChild($div); $div = new XMLElement('div'); $div->setAttribute('class', 'subsection contextual ' . __('navigation')); $div->appendChild(new XMLElement('h3', __('Filter Navigation by'))); $ol = new XMLElement('ol'); $pages = $this->_Parent->Database->fetch("SELECT * FROM `tbl_pages` ORDER BY `title` ASC"); $ul = new XMLElement('ul'); $ul->setAttribute('class', 'tags'); foreach ($pages as $page) { $ul->appendChild(new XMLElement('li', preg_replace('/\\/{2,}/i', '/', '/' . $page['path'] . '/' . $page['handle']))); } if (isset($fields['filter']['navigation']['parent'])) { $li = new XMLElement('li'); $li->setAttribute('class', 'unique'); $li->appendChild(new XMLElement('h4', __('Parent Page'))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[filter][navigation][parent]', General::sanitize($fields['filter']['navigation']['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 Page'))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[filter][navigation][parent]')); $li->appendChild($label); $li->appendChild($ul); $ol->appendChild($li); $ul = new XMLElement('ul'); $ul->setAttribute('class', 'tags'); if ($types = $this->__fetchAvailablePageTypes()) { foreach ($types as $type) { $ul->appendChild(new XMLElement('li', $type)); } } if (isset($fields['filter']['navigation']['type'])) { $li = new XMLElement('li'); $li->setAttribute('class', 'unique'); $li->appendChild(new XMLElement('h4', __('Page Type'))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[filter][navigation][type]', General::sanitize($fields['filter']['navigation']['type']))); $li->appendChild($label); $li->appendChild($ul); $ol->appendChild($li); } $li = new XMLElement('li'); $li->setAttribute('class', 'unique template'); $li->appendChild(new XMLElement('h4', __('Page Type'))); $label = Widget::Label(__('Value')); $label->appendChild(Widget::Input('fields[filter][navigation][type]')); $li->appendChild($label); $li->appendChild($ul); $ol->appendChild($li); $div->appendChild($ol); $fieldset->appendChild($div); $this->Form->appendChild($fieldset); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings contextual inverse ' . __('static_xml') . ' ' . __('dynamic_xml')); $fieldset->appendChild(new XMLElement('legend', __('Sorting and Limiting'))); $p = new XMLElement('p', __('Use <code>{$param}</code> syntax to limit by page parameters.')); $p->setAttribute('class', 'help contextual inverse ' . __('navigation')); $fieldset->appendChild($p); $div = new XMLElement('div'); $div->setAttribute('class', 'group contextual ' . __('sections') . ' ' . __('Sections')); $label = Widget::Label(__('Sort By')); $options = array(array('label' => __('Authors'), 'options' => array(array('id', $fields['source'] == 'authors' && $fields['sort'] == 'id', __('Author ID')), array('username', $fields['source'] == 'authors' && $fields['sort'] == 'username', __('Username')), array('first-name', $fields['source'] == 'authors' && $fields['sort'] == 'first-name', __('First Name')), array('last-name', $fields['source'] == 'authors' && $fields['sort'] == 'last-name', __('Last Name')), array('email', $fields['source'] == 'authors' && $fields['sort'] == 'email', __('Email')), array('status', $fields['source'] == 'authors' && $fields['sort'] == 'status', __('Status')))), array('label' => __('Navigation'), 'options' => array(array('id', $fields['source'] == 'navigation' && $fields['sort'] == 'id', __('Page ID')), array('handle', $fields['source'] == 'navigation' && $fields['sort'] == 'handle', __('Handle')), array('sortorder', $fields['source'] == 'navigation' && $fields['sort'] == 'sortorder', __('Sort Order'))))); foreach ($field_groups as $section_id => $section_data) { $optgroup = array('label' => $section_data['section']->get('name'), 'options' => array(array('system:id', $fields['source'] == $section_data['section']->get('id') && $fields['sort'] == 'system:id', __('System ID')), array('system:date', $fields['source'] == $section_data['section']->get('id') && $fields['sort'] == 'system:date', __('System Date')))); foreach ($section_data['fields'] as $input) { if (!$input->isSortable()) { continue; } $optgroup['options'][] = array($input->get('element_name'), $fields['source'] == $section_data['section']->get('id') && $input->get('element_name') == $fields['sort'], $input->get('label')); } $options[] = $optgroup; } $label->appendChild(Widget::Select('fields[sort]', $options, array('class' => 'filtered'))); $div->appendChild($label); $label = Widget::Label(__('Sort Order')); $options = array(array('asc', 'asc' == $fields['order'], __('ascending')), array('desc', 'desc' == $fields['order'], __('descending')), array('rand', 'rand' == $fields['order'], __('random'))); $label->appendChild(Widget::Select('fields[order]', $options)); $div->appendChild($label); $fieldset->appendChild($div); $div = new XMLElement('div'); $div->setAttribute('class', 'group contextual inverse ' . __('navigation')); $label = Widget::Label(); $input = Widget::Input('fields[max_records]', $fields['max_records'], NULL, array('size' => '6')); $label->setValue(__('Show a maximum of %s results', array($input->generate(false)))); if (isset($this->_errors['max_records'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['max_records'])); } else { $div->appendChild($label); } $label = Widget::Label(); $input = Widget::Input('fields[page_number]', $fields['page_number'], NULL, array('size' => '6')); $label->setValue(__('Show page %s of results', array($input->generate(false)))); if (isset($this->_errors['page_number'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['page_number'])); } else { $div->appendChild($label); } $fieldset->appendChild($div); $label = Widget::Label(__('Required URL Parameter <i>Optional</i>')); $label->appendChild(Widget::Input('fields[required_url_param]', $fields['required_url_param'])); $fieldset->appendChild($label); $p = new XMLElement('p', __('An empty result will be returned when this parameter does not have a value.')); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); $label = Widget::Label(); $input = Widget::Input('fields[redirect_on_empty]', 'yes', 'checkbox', isset($fields['redirect_on_empty']) ? array('checked' => 'checked') : NULL); $label->setValue(__('%s Redirect to 404 page when no results are found', array($input->generate(false)))); $fieldset->appendChild($label); $this->Form->appendChild($fieldset); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings contextual inverse ' . __('navigation') . ' ' . __('static_xml') . ' ' . __('dynamic_xml')); $fieldset->appendChild(new XMLElement('legend', __('Output Options'))); $ul = new XMLElement('ul'); $ul->setAttribute('class', 'group'); $li = new XMLElement('li'); $li->appendChild(new XMLElement('h3', __('Parameter Output'))); $label = Widget::Label(__('Use Field')); $options = array(array('', false, __('None')), array('label' => __('Authors'), 'options' => array(array('id', $fields['source'] == 'authors' && $fields['param'] == 'id', __('Author ID')), array('username', $fields['source'] == 'authors' && $fields['param'] == 'username', __('Username')), array('name', $fields['source'] == 'authors' && $fields['param'] == 'name', __('Name')), array('email', $fields['source'] == 'authors' && $fields['param'] == 'email', __('Email')), array('user_type', $fields['source'] == 'authors' && $fields['param'] == 'user_type', __('User type'))))); foreach ($field_groups as $section_id => $section_data) { $optgroup = array('label' => $section_data['section']->get('name'), 'options' => array(array('system:id', $fields['source'] == $section_data['section']->get('id') && $fields['param'] == 'system:id', __('System ID')), array('system:date', $fields['source'] == $section_data['section']->get('id') && $fields['param'] == 'system:date', __('System Date')), array('system:author', $fields['source'] == $section_data['section']->get('id') && $fields['param'] == 'system:author', __('System Author')))); $authorOverride = false; foreach ($section_data['fields'] as $input) { if (!$input->allowDatasourceParamOutput()) { continue; } $optgroup['options'][] = array($input->get('element_name'), $fields['source'] == $section_data['section']->get('id') && $fields['param'] == $input->get('element_name'), $input->get('label')); } $options[] = $optgroup; } $label->appendChild(Widget::Select('fields[param]', $options, array('class' => 'filtered'))); $li->appendChild($label); $p = new XMLElement('p', __('The parameter <code id="output-param-name">$ds-%s</code> will be created with this field\'s value for XSLT or other data sources to use.', array($this->_context[0] == 'edit' ? $existing->dsParamROOTELEMENT : __('Untitled')))); $p->setAttribute('class', 'help'); $li->appendChild($p); $ul->appendChild($li); $li = new XMLElement('li'); $li->appendChild(new XMLElement('h3', __('XML Output'))); $label = Widget::Label(__('Group By')); $options = array(array('', NULL, __('None'))); foreach ($field_groups as $section_id => $section_data) { $optgroup = array('label' => $section_data['section']->get('name'), 'options' => array()); $authorOverride = false; foreach ($section_data['fields'] as $input) { if (!$input->allowDatasourceOutputGrouping()) { continue; } if ($input->get('element_name') == 'author') { $authorOverride = true; } $optgroup['options'][] = array($input->get('id'), $fields['source'] == $section_data['section']->get('id') && $fields['group'] == $input->get('id'), $input->get('label')); } if (!$authorOverride) { $optgroup['options'][] = array('author', $fields['source'] == $section_data['section']->get('id') && $fields['group'] == 'author', __('Author')); } $options[] = $optgroup; } $label->appendChild(Widget::Select('fields[group]', $options, array('class' => 'filtered'))); $li->appendChild($label); $label = Widget::Label(__('Included Elements')); $options = array(array('label' => __('Authors'), 'options' => array(array('username', $fields['source'] == 'authors' && in_array('username', $fields['xml_elements']), 'username'), array('name', $fields['source'] == 'authors' && in_array('name', $fields['xml_elements']), 'name'), array('email', $fields['source'] == 'authors' && in_array('email', $fields['xml_elements']), 'email'), array('author-token', $fields['source'] == 'authors' && in_array('author-token', $fields['xml_elements']), 'author-token'), array('default-section', $fields['source'] == 'authors' && in_array('default-section', $fields['xml_elements']), 'default-section'), array('formatting-preference', $fields['source'] == 'authors' && in_array('formatting-preference', $fields['xml_elements']), 'formatting-preference')))); foreach ($field_groups as $section_id => $section_data) { $optgroup = array('label' => $section_data['section']->get('name'), 'options' => array()); $optgroup['options'][] = array('system:pagination', $fields['source'] == $section_data['section']->get('id') && @in_array('system:pagination', $fields['xml_elements']), 'pagination'); foreach ($section_data['fields'] as $input) { $elements = $input->fetchIncludableElements(); foreach ($elements as $e) { $optgroup['options'][] = array($e, $fields['source'] == $section_data['section']->get('id') && @in_array($e, $fields['xml_elements']), $e); } } $options[] = $optgroup; } $label->appendChild(Widget::Select('fields[xml_elements][]', $options, array('multiple' => 'multiple', 'class' => 'filtered'))); $li->appendChild($label); $label = Widget::Label(); $label->setAttribute('class', 'contextual inverse ' . __('authors')); $input = Widget::Input('fields[html_encode]', 'yes', 'checkbox', isset($fields['html_encode']) ? array('checked' => 'checked') : NULL); $label->setValue(__('%s HTML-encode text', array($input->generate(false)))); $li->appendChild($label); $ul->appendChild($li); $fieldset->appendChild($ul); $this->Form->appendChild($fieldset); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings contextual ' . __('dynamic_xml')); $fieldset->appendChild(new XMLElement('legend', __('Dynamic XML'))); $label = Widget::Label(__('URL')); $label->appendChild(Widget::Input('fields[dynamic_xml][url]', General::sanitize($fields['dynamic_xml']['url']))); if (isset($this->_errors['dynamic_xml']['url'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['dynamic_xml']['url'])); } else { $fieldset->appendChild($label); } $p = new XMLElement('p', __('Use <code>{$param}</code> syntax to specify dynamic portions of the URL.')); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); $div = new XMLElement('div'); $div->setAttribute('class', 'subsection'); $div->appendChild(new XMLElement('h3', __('Namespace Declarations <i>Optional</i>'))); $ol = new XMLElement('ol'); if (is_array($fields['dynamic_xml']['namespace']['name'])) { $namespaces = $fields['dynamic_xml']['namespace']['name']; $uri = $fields['dynamic_xml']['namespace']['uri']; for ($ii = 0; $ii < count($namespaces); $ii++) { $li = new XMLElement('li'); $li->appendChild(new XMLElement('h4', 'Namespace')); $group = new XMLElement('div'); $group->setAttribute('class', 'group'); $label = Widget::Label(__('Name')); $label->appendChild(Widget::Input('fields[dynamic_xml][namespace][name][]', General::sanitize($namespaces[$ii]))); $group->appendChild($label); $label = Widget::Label(__('URI')); $label->appendChild(Widget::Input('fields[dynamic_xml][namespace][uri][]', General::sanitize($uri[$ii]))); $group->appendChild($label); $li->appendChild($group); $ol->appendChild($li); } } $li = new XMLElement('li'); $li->setAttribute('class', 'template'); $li->appendChild(new XMLElement('h4', __('Namespace'))); $group = new XMLElement('div'); $group->setAttribute('class', 'group'); $label = Widget::Label(__('Name')); $label->appendChild(Widget::Input('fields[dynamic_xml][namespace][name][]')); $group->appendChild($label); $label = Widget::Label(__('URI')); $label->appendChild(Widget::Input('fields[dynamic_xml][namespace][uri][]')); $group->appendChild($label); $li->appendChild($group); $ol->appendChild($li); $div->appendChild($ol); $fieldset->appendChild($div); $label = Widget::Label(__('Included Elements')); $label->appendChild(Widget::Input('fields[dynamic_xml][xpath]', General::sanitize($fields['dynamic_xml']['xpath']))); if (isset($this->_errors['dynamic_xml']['xpath'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['dynamic_xml']['xpath'])); } else { $fieldset->appendChild($label); } $p = new XMLElement('p', __('Use an XPath expression to select which elements from the source XML to include.')); $p->setAttribute('class', 'help'); $fieldset->appendChild($p); $label = Widget::Label(); $input = Widget::Input('fields[dynamic_xml][cache]', max(1, intval($fields['dynamic_xml']['cache'])), NULL, array('size' => '6')); $label->setValue('Update cached result every ' . $input->generate(false) . ' minutes'); if (isset($this->_errors['dynamic_xml']['cache'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['dynamic_xml']['cache'])); } else { $fieldset->appendChild($label); } $this->Form->appendChild($fieldset); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings contextual ' . __('static_xml')); $fieldset->appendChild(new XMLElement('legend', __('Static XML'))); $label = Widget::Label(__('Body')); $label->appendChild(Widget::Textarea('fields[static_xml]', 12, 50, General::sanitize($fields['static_xml']), array('class' => 'code'))); if (isset($this->_errors['static_xml'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['static_xml'])); } else { $fieldset->appendChild($label); } $this->Form->appendChild($fieldset); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', $isEditing ? __('Save Changes') : __('Create Data Source'), 'submit', array('accesskey' => 's'))); if ($isEditing) { $button = new XMLElement('button', 'Delete'); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this data source'))); $div->appendChild($button); } $this->Form->appendChild($div); }
function view() { $this->_existing_file = isset($this->_context[1]) ? $this->_context[1] . '.xsl' : NULL; ## Handle unknown context if (!in_array($this->_context[0], array('new', 'edit'))) { $this->_Parent->errorPageNotFound(); } ## Edit Utility context if ($this->_context[0] == 'edit') { $file_abs = UTILITIES . '/' . $this->_existing_file; $filename = $this->_existing_file; if (!@is_file($file_abs)) { redirect(URL . '/symphony/blueprints/utilities/new/'); } $fields['name'] = $filename; $fields['body'] = @file_get_contents($file_abs); $this->Form->setAttribute('action', URL . '/symphony/blueprints/utilities/edit/' . $this->_context[1] . '/'); } else { $fields['body'] = '<?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template name=""> </xsl:template> </xsl:stylesheet>'; } $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR); } if (isset($this->_context[2])) { switch ($this->_context[2]) { case 'saved': $this->pageAlert(__('Utility updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Utilities</a>', array(DateTimeObj::get(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/utilities/new/', URL . '/symphony/blueprints/components/')), Alert::SUCCESS); break; case 'created': $this->pageAlert(__('Utility created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Utilities</a>', array(DateTimeObj::get(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/utilities/new/', URL . '/symphony/blueprints/components/')), Alert::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' ? __('Untitled') : $filename); if (!empty($_POST)) { $fields = $_POST['fields']; } $fields['body'] = General::sanitize($fields['body']); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'primary'); $label = Widget::Label(__('Name')); $label->appendChild(Widget::Input('fields[name]', $fields['name'])); $fieldset->appendChild(isset($this->_errors['name']) ? $this->wrapFormElementWithError($label, $this->_errors['name']) : $label); $label = Widget::Label(__('Body')); $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code'))); $fieldset->appendChild(isset($this->_errors['body']) ? $this->wrapFormElementWithError($label, $this->_errors['body']) : $label); $this->Form->appendChild($fieldset); $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES); $utilities = $utilities['filelist']; if (is_array($utilities) && !empty($utilities)) { $div = new XMLElement('div'); $div->setAttribute('class', 'secondary'); $h3 = new XMLElement('h3', __('Utilities')); $h3->setAttribute('class', 'label'); $div->appendChild($h3); $ul = new XMLElement('ul'); $ul->setAttribute('id', 'utilities'); $i = 0; foreach ($utilities as $util) { $li = new XMLElement('li'); if ($i++ % 2 != 1) { $li->setAttribute('class', 'odd'); } $li->appendChild(Widget::Anchor($util, URL . '/symphony/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL)); $ul->appendChild($li); } $div->appendChild($ul); $this->Form->appendChild($div); } $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Utility'), 'submit', array('accesskey' => 's'))); if ($this->_context[0] == 'edit') { $button = new XMLElement('button', __('Delete')); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this utility'))); $div->appendChild($button); } $this->Form->appendChild($div); }
public function appendPreferences($context) { // Check if JIT configuration folder exists if (!file_exists(WORKSPACE . '/jit-image-manipulation/')) { Administration::instance()->Page->pageAlert(__('The JIT configuration folder, %s, does not exist. You will not be able to save recipes and trusted sites.', array('<code>/workspace/jit-image-manipulation/</code>')), Alert::ERROR); } // Alert messages for JIT configuration errors $errors = $context['errors']; if (isset($errors['jit-trusted-sites'])) { Administration::instance()->Page->pageAlert($errors['jit-trusted-sites'], Alert::ERROR); } if (isset($errors['jit-recipes'])) { Administration::instance()->Page->pageAlert($errors['jit-recipes'], Alert::ERROR); } // JavaScript for recipes duplicator Administration::instance()->Page->addScriptToHead(URL . '/extensions/jit_image_manipulation/assets/jit_image_manipulation.preferences.js', 3134); $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', __('JIT Image Manipulation'))); $group->appendChild(new XMLElement('p', __('Recipes are named rules for the JIT settings.'), array('class' => 'help'))); // recipes duplicator $group->appendChild(new XMLElement('p', __('Recipes'), array('class' => 'label'))); $div = new XMLElement('div', null, array('class' => 'frame jit-duplicator')); $duplicator = new XMLElement('ol'); $duplicator->setAttribute('data-add', __('Add recipe')); $duplicator->setAttribute('data-remove', __('Remove recipe')); $duplicator->appendChild(self::createRecipeDuplicatorTemplate('0')); $duplicator->appendChild(self::createRecipeDuplicatorTemplate('1')); $duplicator->appendChild(self::createRecipeDuplicatorTemplate('2')); $duplicator->appendChild(self::createRecipeDuplicatorTemplate('3')); $duplicator->appendChild(self::createRecipeDuplicatorTemplate('4')); $duplicator->appendChild(self::createRecipeDuplicatorTemplate('regex')); // use recipes POST datain case of an error $post_recipes = isset($_POST['jit_image_manipulation']['recipes']) ? $_POST['jit_image_manipulation']['recipes'] : array(); if (!empty($post_recipes) && !empty($this->recipes_errors)) { foreach ($post_recipes as $position => $recipe) { $duplicator->appendChild(self::createRecipeDuplicatorTemplate($recipe['mode'], $position, $recipe, $this->recipes_errors[$position])); } } else { file_exists(WORKSPACE . '/jit-image-manipulation/recipes.php') ? include WORKSPACE . '/jit-image-manipulation/recipes.php' : ($recipes = array()); if (is_array($recipes) && !empty($recipes)) { foreach ($recipes as $position => $recipe) { $duplicator->appendChild(self::createRecipeDuplicatorTemplate($recipe['mode'], $position, $recipe)); } } } $div->appendChild($duplicator); $group->appendChild($div); // checkbox to disable regular rules $label = Widget::Label(); $input = Widget::Input('settings[image][disable_regular_rules]', 'yes', 'checkbox'); if (Symphony::Configuration()->get('disable_regular_rules', 'image') == 'yes') { $input->setAttribute('checked', 'checked'); } $label->setValue($input->generate() . ' ' . __('Disable dynamic URLs and use named recipes only')); $group->appendChild($label); // checkbox to disable up-scaling $label = Widget::Label(); $input = Widget::Input('settings[image][disable_upscaling]', 'yes', 'checkbox'); if (Symphony::Configuration()->get('disable_upscaling', 'image') == 'yes') { $input->setAttribute('checked', 'checked'); } $label->setValue($input->generate() . ' ' . __('Disable upscaling of images beyond the original size')); $group->appendChild($label); // textarea for trusted sites $label = Widget::Label(__('Trusted Sites')); $label->appendChild(Widget::Textarea('jit_image_manipulation[trusted_external_sites]', 5, 50, $this->trusted())); $group->appendChild($label); $group->appendChild(new XMLElement('p', __('Leave empty to disable external linking. Single rule per line. Add * at end for wild card matching.'), array('class' => 'help'))); $context['wrapper']->appendChild($group); }
function view() { if (!($role_id = $this->_context[0])) { redirect(extension_members::baseURL()); } if (!($existing = $this->_driver->fetchRole($role_id, true))) { $this->_Parent->customError(E_USER_ERROR, 'Role not found', 'The role you requested to edit does not exist.', false, true, 'error', array('header' => 'HTTP/1.0 404 Not Found')); } if (isset($this->_context[1])) { switch ($this->_context[1]) { case 'saved': $this->pageAlert(__('%1$s updated successfully. <a href="%2$s">Create another?</a>', array('Role', extension_members::baseURL() . 'new/')), Alert::SUCCESS); break; case 'created': $this->pageAlert(__('%1$s created successfully. <a href="%2$s">Create another?</a>', array('Role', extension_members::baseURL() . 'new/')), Alert::SUCCESS); break; case 'moved': $this->pageAlert('All members have been successfully moved to new role.', Alert::SUCCESS); break; } } $this->_Parent->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 70); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert('An error occurred while processing this form. <a href="#error">See below for details.</a>', AdministrationPage::PAGE_ALERT_ERROR); } $this->setPageType('form'); $this->setTitle('Symphony – Member Roles – ' . $existing->name()); $this->appendSubheading($existing->name()); $fields = array(); if (isset($_POST['fields'])) { $fields = $_POST['fields']; } else { $fields['name'] = $existing->name(); $fields['permissions'] = $existing->eventPermissions(); $fields['page_access'] = $existing->forbiddenPages(); $fields['email_subject'] = $existing->email_subject(); $fields['email_body'] = $existing->email_body(); } $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-file'); $fieldset->appendChild(new XMLElement('legend', 'Essentials')); $label = Widget::Label('Name'); $label->appendChild(Widget::Input('fields[name]', General::sanitize($fields['name']))); if (isset($this->_errors['name'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['name'])); } else { $fieldset->appendChild($label); } $this->Form->appendChild($fieldset); $EventManager = new EventManager($this->_Parent); $events = $EventManager->listAll(); if (is_array($events) && !empty($events)) { foreach ($events as $handle => $e) { $show_in_role_permissions = method_exists("event{$handle}", 'showInRolePermissions') && call_user_func(array("event{$handle}", 'showInRolePermissions')) === true ? true : false; if (!$e['can_parse'] && !$show_in_role_permissions) { unset($events[$handle]); } } } if (is_array($events) && !empty($events)) { $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-file'); $fieldset->appendChild(new XMLElement('legend', 'Event Level Permissions')); $aTableHead = array(array('Event', 'col'), array('Add', 'col'), array('Edit', 'col'), array('Edit Own *', 'col'), array('Delete', 'col'), array('Delete Own *', 'col')); $aTableBody = array(); foreach ($events as $event_handle => $event) { $permissions = $fields['permissions'][$event_handle]; ## Setup each cell $td1 = Widget::TableData($event['name']); $td2 = Widget::TableData(Widget::Input('fields[permissions][' . $event_handle . '][add]', 'yes', 'checkbox', isset($permissions['add']) ? array('checked' => 'checked') : NULL)); $td3 = Widget::TableData(Widget::Input('fields[permissions][' . $event_handle . '][edit]', 'yes', 'checkbox', isset($permissions['edit']) ? array('checked' => 'checked') : NULL)); $td4 = Widget::TableData(Widget::Input('fields[permissions][' . $event_handle . '][edit_own]', 'yes', 'checkbox', isset($permissions['edit_own']) ? array('checked' => 'checked') : NULL)); $td5 = Widget::TableData(Widget::Input('fields[permissions][' . $event_handle . '][delete]', 'yes', 'checkbox', isset($permissions['delete']) ? array('checked' => 'checked') : NULL)); $td6 = Widget::TableData(Widget::Input('fields[permissions][' . $event_handle . '][delete_own]', 'yes', 'checkbox', isset($permissions['delete_own']) ? array('checked' => 'checked') : NULL)); ## Add a row to the body array, assigning each cell to the row $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4, $td5, $td6)); } $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'role-permissions'); $fieldset->appendChild($table); $fieldset->appendChild(new XMLElement('p', '* <em>Does not apply if global edit/delete is allowed</em>', array('class' => 'help'))); $this->Form->appendChild($fieldset); } #### # Delegate: MemberRolePermissionFieldsetsEdit # Description: Add custom fieldsets to the role page $ExtensionManager = new ExtensionManager($this->_Parent); $ExtensionManager->notifyMembers('MemberRolePermissionFieldsetsEdit', '/extension/members/edit/', array('form' => &$this->Form, 'permissions' => $fields['permissions'])); ##### $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-file'); $fieldset->appendChild(new XMLElement('legend', 'Page Level Permissions')); $pages = $this->_Parent->Database->fetch("SELECT * FROM `tbl_pages` " . ($this->_context[0] == 'edit' ? "WHERE `id` != '{$page_id}' " : '') . "ORDER BY `title` ASC"); $label = Widget::Label('Deny Access'); $options = array(); if (is_array($pages) && !empty($pages)) { foreach ($pages as $page) { $options[] = array($page['id'], in_array($page['id'], $fields['page_access']), '/' . $this->_Parent->resolvePagePath($page['id'])); //$page['title']); } } $label->appendChild(Widget::Select('fields[page_access][]', $options, array('multiple' => 'multiple'))); $fieldset->appendChild($label); $this->Form->appendChild($fieldset); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-file'); $fieldset->appendChild(new XMLElement('legend', 'Operations')); if ($role_id == 1) { $fieldset->appendChild(new XMLElement('p', 'The default role cannot be deleted', array('class' => 'help'))); } $aTableBody = array(); $roles = $this->_driver->fetchRoles(); $options = array(); foreach ($roles as $role) { if ($role_id == $role->id()) { continue; } $options[] = array($role->id(), false, $role->name()); } ## Setup each cell $td1 = Widget::TableData('Move'); $td2 = Widget::TableData(Widget::Select('fields[new_role]', $options)); $td3 = Widget::TableData(Widget::Input('action[move]', 'Move', 'submit', array('class' => 'confirm'))); ## Add a row to the body array, assigning each cell to the row $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3)); if ($role_id != 1) { ## Setup each cell $td1 = Widget::TableData('Move and Delete'); $td2 = Widget::TableData(Widget::Select('fields[replacement_role]', $options)); $td3 = Widget::TableData(Widget::Input('action[delete]', 'Delete', 'submit', array('class' => 'confirm'))); ## Add a row to the body array, assigning each cell to the row $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3)); } $table = Widget::Table(NULL, NULL, Widget::TableBody($aTableBody), NULL, 'role-operations'); $table->setAttributeArray(array('cellspacing' => '0', 'cellpadding' => '0')); $fieldset->appendChild($table); $this->Form->appendChild($fieldset); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-file'); $fieldset->appendChild(new XMLElement('legend', 'Email Template')); $fieldset->appendChild(new XMLElement('p', 'When adding a member, they will receive an email based on the template you specify. <br /><br />Leave everything blank if you do not wish for new members in this group to receive an email.', array('class' => 'help'))); $label = Widget::Label('Subject'); $label->appendChild(Widget::Input('fields[email_subject]', General::sanitize($fields['email_subject']))); if (isset($this->_errors['email_subject'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['email_subject'])); } else { $fieldset->appendChild($label); } $label = Widget::Label('Body'); $label->appendChild(Widget::Textarea('fields[email_body]', '25', '50', General::sanitize($fields['email_body']))); $fieldset->appendChild(isset($this->_errors['email_body']) ? $this->wrapFormElementWithError($label, $this->_errors['email_body']) : $label); $fieldset->appendChild(new XMLElement('p', 'You can add dynamic elements to the email by using <code>{$field-name}</code> syntax, where <code>field-name</code> corresponds to the fields of the new member.', array('class' => 'help'))); $this->Form->appendChild($fieldset); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', 'Save Changes', 'submit', array('accesskey' => 's'))); $this->Form->appendChild($div); }
function render() { $this->setPageType('form'); $fields = array(); // If we're editing, make sure the item exists if ($this->_context[0]) { if (!($doc_id = $this->_context[0])) { redirect(URL . '/symphony/extension/documenter/manage'); } $existing = Symphony::Database()->fetchRow(0, "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\td.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`tbl_documentation` AS d\n\t\t\t\t\tWHERE\n\t\t\t\t\t\td.id = '{$doc_id}'\n\t\t\t\t\tLIMIT 1\n\t\t\t\t"); if (!$existing) { $this->_Parent->customError(E_USER_ERROR, __('Documentation Item not found'), __('The documentation item you requested to edit does not exist.'), false, true, 'error', array('header' => 'HTTP/1.0 404 Not Found')); } } // Build the status message if (isset($this->_context[1])) { if ($this->_context[1] == 'saved') { $this->pageAlert(__('Documentation Item updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Documentation</a>', array(Widget::Time()->generate(__SYM_TIME_FORMAT__), URL . '/symphony/extension/documenter/new/', URL . '/symphony/extension/documenter/')), Alert::SUCCESS); } else { $this->pageAlert(__('Documentation Item created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Documentation</a>', array(Widget::Time()->generate(__SYM_TIME_FORMAT__), URL . '/symphony/extension/documenter/new/', URL . '/symphony/extension/documenter/')), Alert::SUCCESS); } } // Find values if (isset($_POST['fields'])) { $fields = $_POST['fields']; } else { if ($this->_context[0]) { $fields = $existing; $fields['content'] = General::sanitize($fields['content']); } } $title = $fields['title']; if (trim($title) == '') { $title = $existing['title']; } // Start building the page $this->setTitle(__($title ? '%1$s – %2$s – %3$s' : '%1$s – %2$s', array(__('Symphony'), __('Documentation'), $title))); $this->appendSubheading($title ? $title : __('Untitled')); // Start building the fieldsets $this->Form->setAttribute('class', 'two columns'); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'primary column'); // Title text input $label = Widget::Label(__('Title')); $label->appendChild(Widget::Input('fields[title]', General::sanitize($fields['title']))); if (isset($this->_errors['title'])) { $label = Widget::Error($label, $this->_errors['title']); } $fieldset->appendChild($label); // Content textarea $label = Widget::Label(__('Content')); $content = Widget::Textarea('fields[content]', 30, 80, $fields['content']); if (Symphony::Configuration()->get('text-formatter', 'documentation') != 'none') { $content->setAttribute('class', Symphony::Configuration()->get('text-formatter', 'documentation')); } $label->appendChild($content); $fieldset->appendChild(isset($this->_errors['content']) ? Widget::Error($label, $this->_errors['content']) : $label); $fieldset->appendChild(Widget::Input('autogenerate', __('Auto-generate content according to selected section(s)'), 'button', array('class' => 'button'))); $this->Form->appendChild($fieldset); // Pages multi-select $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'secondary column'); $label = Widget::Label(__('Pages')); if (!is_array($fields['pages'])) { $pages_array = explode(',', $fields['pages']); } else { $pages_array = $fields['pages']; } $options = array(); // Generate a list of sectionField-data for auto-generation of documentation: $arr = array(); // Build the options list using the navigation array foreach (Administration::instance()->Page->_navigation as $menu) { $items = array(); foreach ($menu['children'] as $item) { $items[] = array($item['link'], in_array($item['link'], $pages_array), $menu['name'] . " > " . $item['name']); // If it's a section, add New and Edit pages // NOTE: This will likely break when extensions add custom nav groups if ($menu['name'] != 'Blueprints' and $menu['name'] != 'System') { $items[] = array($item['link'] . 'new/', in_array($item['link'] . 'new/', $pages_array), $menu['name'] . " > " . $item['name'] . " New"); $items[] = array($item['link'] . 'edit/', in_array($item['link'] . 'edit/', $pages_array), $menu['name'] . " > " . $item['name'] . " Edit"); } // Generate a list of sectionField-data for auto-generation of documentation: if ($item['type'] == 'section') { $arr2 = array('name' => $item['name'], 'link' => $item['link'], 'items' => array()); $fields = FieldManager::fetch(null, $item['section']['id']); foreach ($fields as $field) { /* @var $field Field */ $arr2['items'][] = array('label' => $field->get('label')); } $arr[] = $arr2; } } $options[] = array('label' => $menu['name'], 'options' => $items); } Administration::instance()->Page->addElementToHead(new XMLElement('script', 'var sectionFields = ' . json_encode($arr) . ';', array('type' => 'text/javascript'))); $label->appendChild(Widget::Select('fields[pages][]', $options, array('multiple' => 'multiple', 'id' => 'documenter-pagelist'))); if (isset($this->_errors['pages'])) { $label = Widget::Error($label, $this->_errors['pages']); } $fieldset->appendChild($label); $this->Form->appendChild($fieldset); // Form actions $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', $this->_context[0] ? __('Save Changes') : __('Document It'), 'submit', array('accesskey' => 's'))); if ($this->_context[0]) { $button = new XMLElement('button', __('Delete')); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this template'))); $div->appendChild($button); } $this->Form->appendChild($div); }
public function view() { if (!($email_template_id = $this->_context[0])) { redirect(extension_members::baseURL()); } if (!($existing = EmailTemplate::loadFromID($email_template_id))) { throw new SymphonyErrorPage(__('The email template you requested to edit does not exist.'), __('Email Template not found'), 'error'); } if (isset($this->_context[1])) { switch ($this->_context[1]) { case 'saved': $this->pageAlert(__('Email Template updated at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Email Template</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), extension_members::baseURL() . 'email_templates_new/', extension_members::baseURL() . 'email_templates/')), Alert::SUCCESS); break; case 'created': $this->pageAlert(__('Email Template created at %1$s. <a href="%2$s">Create another?</a> <a href="%3$s">View all Email Template</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), extension_members::baseURL() . 'email_templates_new/', extension_members::baseURL() . 'email_templates/')), Alert::SUCCESS); break; } } Administration::instance()->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 9125341); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), AdministrationPage::PAGE_ALERT_ERROR); } $this->setPageType('form'); $this->setTitle('Symphony – Member Roles – ' . $existing->subject); $this->appendSubheading($existing->subject); $fields = array(); if (isset($_POST['fields'])) { $fields = $_POST['fields']; } else { $fields['subject'] = $existing->subject; $fields['body'] = $existing->body; $fields['type'] = $existing->type; $fields['roles'] = NULL; foreach ($existing->roles() as $role_id => $r) { $fields['roles'] .= $r->name() . ", "; } $fields['roles'] = trim($fields['roles'], ', '); } $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'primary'); $label = Widget::Label('Subject'); $label->appendChild(Widget::Input('fields[subject]', General::sanitize($fields['subject']))); if (isset($this->_errors['subject'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['subject'])); } else { $fieldset->appendChild($label); } $label = Widget::Label('Body'); $label->appendChild(Widget::Textarea('fields[body]', 15, 75, General::sanitize($fields['body']))); if (isset($this->_errors['body'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['body'])); } else { $fieldset->appendChild($label); } $fieldset->appendChild(new XMLElement('p', 'Dynamic fields and parameters can be included in the subject or body of the email using the <code>{$param}</code> syntax. Please see the <a href="http://github.com/symphony/members/blob/master/README.markdown">readme</a> for a complete list of available parameters.', array('class' => 'help'))); $this->Form->appendChild($fieldset); $sidebar = new XMLElement('fieldset'); $sidebar->setAttribute('class', 'secondary'); $label = Widget::Label('Type'); $options = array(array(NULL, false, NULL), array('reset-password', $fields['type'] == 'reset-password', 'Reset Password'), array('new-password', $fields['type'] == 'new-password', 'New Password'), array('activate-account', $fields['type'] == 'activate-account', 'Activate Account'), array('welcome', $fields['type'] == 'welcome', 'Welcome Email')); $label->appendChild(Widget::Select('fields[type]', $options)); if (isset($this->_errors['type'])) { $sidebar->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['type'])); } else { $sidebar->appendChild($label); } $label = Widget::Label('Roles'); $label->appendChild(Widget::Input('fields[roles]', $fields['roles'])); if (isset($this->_errors['roles'])) { $sidebar->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['roles'])); } else { $sidebar->appendChild($label); } $roles = DatabaseUtilities::resultColumn(ASDCLoader::instance()->query("SELECT `name` FROM `tbl_members_roles` ORDER BY `name` ASC"), 'name'); if (is_array($roles) && !empty($roles)) { $taglist = new XMLElement('ul'); $taglist->setAttribute('class', 'tags'); foreach ($roles as $tag) { $taglist->appendChild(new XMLElement('li', $tag)); } $sidebar->appendChild($taglist); } $this->Form->appendChild($sidebar); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', 'Save Changes', 'submit', array('accesskey' => 's'))); $button = new XMLElement('button', __('Delete')); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'confirm delete', 'title' => __('Delete this email template'))); $div->appendChild($button); $this->Form->appendChild($div); }
public function __viewTemplate() { $this->setPageType('form'); $this->Form->setAttribute('action', URL . '/symphony/blueprints/pages/template/' . $this->_context[1] . '/'); $filename = $this->_context[1] . '.xsl'; $file_abs = PAGES . '/' . $filename; if (!@is_file($file_abs)) { redirect(URL . '/symphony/blueprints/pages/'); } $fields['body'] = @file_get_contents($file_abs); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR); } // Status message: if (isset($this->_context[2])) { $this->pageAlert(__('%s %s at %s. <a href="%s">View all %s</a>', array(__('Page'), 'updated', DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), URL . '/symphony/blueprints/pages/', __('Pages'))), Alert::SUCCESS); } $this->setTitle(__($filename ? '%1$s – %2$s – %3$s' : '%1$s – %2$s', array(__('Symphony'), __('Pages'), $filename))); $this->appendSubheading($filename ? $filename : __('Untitled')); if (!empty($_POST)) { $fields = $_POST['fields']; } $fields['body'] = General::sanitize($fields['body']); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'primary'); $label = Widget::Label(__('Body')); $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code'))); if (isset($this->_errors['body'])) { $label = $this->wrapFormElementWithError($label, $this->_errors['body']); } $fieldset->appendChild($label); $this->Form->appendChild($fieldset); $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES); $utilities = $utilities['filelist']; if (is_array($utilities) && !empty($utilities)) { $div = new XMLElement('div'); $div->setAttribute('class', 'secondary'); $h3 = new XMLElement('h3', __('Utilities')); $h3->setAttribute('class', 'label'); $div->appendChild($h3); $ul = new XMLElement('ul'); $ul->setAttribute('id', 'utilities'); foreach ($utilities as $index => $util) { $li = new XMLElement('li'); if ($index % 2 != 1) { $li->setAttribute('class', 'odd'); } $li->appendChild(Widget::Anchor($util, URL . '/symphony/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL)); $ul->appendChild($li); } $div->appendChild($ul); $this->Form->appendChild($div); } $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's'))); $this->Form->appendChild($div); }
public function dashboard_panel_options($context) { $config = $context['existing_config']; switch ($context['type']) { case 'datasource_to_table': $datasources = array(); foreach (DatasourceManager::listAll() as $ds) { $datasources[] = array($ds['handle'], $config['datasource'] == $ds['handle'], $ds['name']); } $fieldset = new XMLElement('fieldset', NULL, array('class' => 'settings')); $fieldset->appendChild(new XMLElement('legend', __('Data Source to Table'))); $label = Widget::Label(__('Data Source'), Widget::Select('config[datasource]', $datasources)); $fieldset->appendChild($label); $context['form'] = $fieldset; break; case 'rss_reader': $fieldset = new XMLElement('fieldset', NULL, array('class' => 'settings')); $fieldset->appendChild(new XMLElement('legend', __('RSS Reader'))); $label = Widget::Label(__('Feed URL'), Widget::Input('config[url]', $config['url'])); $fieldset->appendChild($label); $label = Widget::Label(__('Items to display'), Widget::Select('config[show]', array(array('label' => __('Full view'), 'options' => array(array('full-all', $config['show'] == 'full-all', __('All items')), array('full-3', $config['show'] == 'full-3', '3 ' . __('items')), array('full-5', $config['show'] == 'full-5', '5 ' . __('items')), array('full-10', $config['show'] == 'full-10', '10 ' . __('items')))), array('label' => __('List view'), 'options' => array(array('list-all', $config['show'] == 'list-all', __('All items')), array('list-3', $config['show'] == 'list-3', '3 ' . __('items')), array('list-5', $config['show'] == 'list-5', '5 ' . __('items')), array('list-10', $config['show'] == 'list-10', '10 ' . __('items'))))))); $fieldset->appendChild($label); $label = Widget::Label(__('Cache (minutes)'), Widget::Input('config[cache]', (string) (int) $config['cache'])); $fieldset->appendChild($label); $context['form'] = $fieldset; break; case 'html_block': $fieldset = new XMLElement('fieldset', NULL, array('class' => 'settings')); $fieldset->appendChild(new XMLElement('legend', __('HTML Block'))); $label = Widget::Label(__('Page URL'), Widget::Input('config[url]', $config['url'])); $fieldset->appendChild($label); $label = Widget::Label(__('Cache (minutes)'), Widget::Input('config[cache]', (string) (int) $config['cache'])); $fieldset->appendChild($label); $context['form'] = $fieldset; break; case 'markdown_text': $fieldset = new XMLElement('fieldset', NULL, array('class' => 'settings')); $fieldset->appendChild(new XMLElement('legend', __('Markdown Text Block'))); $formatters = array(); foreach (TextformatterManager::listAll() as $tf) { $formatters[] = array($tf['handle'], $config['formatter'] == $tf['handle'], $tf['name']); } $fieldset = new XMLElement('fieldset', NULL, array('class' => 'settings')); $fieldset->appendChild(new XMLElement('legend', __('Markdown Text'))); $label = Widget::Label(__('Text Formatter'), Widget::Select('config[formatter]', $formatters)); $fieldset->appendChild($label); $label = Widget::Label(__('Text'), Widget::Textarea('config[text]', 6, 25, $config['text'])); $fieldset->appendChild($label); $context['form'] = $fieldset; break; } }
public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null) { Extension_TextBoxField::appendHeaders(Extension_TextBoxField::PUBLISH_HEADERS); $sortorder = $this->get('sortorder'); $element_name = $this->get('element_name'); $classes = array(); $label = Widget::Label($this->get('label')); $optional = ''; if ($this->get('required') != 'yes') { if ((int) $this->get('text_length') > 0) { $optional = __('$1 of $2 remaining') . ' – ' . __('Optional'); } else { $optional = __('Optional'); } } else { if ((int) $this->get('text_length') > 0) { $optional = __('$1 of $2 remaining'); } } if ($optional) { $label->appendChild(new XMLElement('i', $optional)); } // Input box: if ($this->get('text_size') == 'single') { $input = Widget::Input("fields{$fieldnamePrefix}[{$element_name}]{$fieldnamePostfix}", General::sanitize($data['value'])); ### # Delegate: ModifyTextBoxInlineFieldPublishWidget # Description: Allows developers modify the textbox before it is rendered in the publish forms $delegate = 'ModifyTextBoxInlineFieldPublishWidget'; } else { $input = Widget::Textarea("fields{$fieldnamePrefix}[{$element_name}]{$fieldnamePostfix}", 20, 50, General::sanitize($data['value'])); ### # Delegate: ModifyTextBoxFullFieldPublishWidget # Description: Allows developers modify the textbox before it is rendered in the publish forms $delegate = 'ModifyTextBoxFullFieldPublishWidget'; } // Add classes: $classes[] = 'size-' . $this->get('text_size'); if ($this->get('text_formatter') != 'none') { $classes[] = $this->get('text_formatter'); } $input->setAttribute('class', implode(' ', $classes)); $input->setAttribute('length', (int) $this->get('text_length')); Symphony::ExtensionManager()->notifyMembers($delegate, '/backend/', array('field' => $this, 'label' => $label, 'input' => $input, 'textarea' => $input)); if (is_null($label)) { return; } $label->appendChild($input); if ($flagWithError != null) { $label = Widget::Error($label, $flagWithError); } $wrapper->appendChild($label); }
public function __form() { $this->setPageType('form'); $this->_existing_file = isset($this->_context[1]) ? $this->_context[1] . '.xsl' : NULL; $this->Form->setAttribute('class', 'columns'); $filename = $this->_existing_file; // Handle unknown context if (!in_array($this->_context[0], array('new', 'edit'))) { Administration::instance()->errorPageNotFound(); } // Edit Utility context if ($this->_context[0] == 'edit') { $file_abs = UTILITIES . '/' . $this->_existing_file; if (!is_file($file_abs)) { redirect(SYMPHONY_URL . '/blueprints/utilities/new/'); } $fields['name'] = $filename; $fields['body'] = @file_get_contents($file_abs); $this->Form->setAttribute('action', SYMPHONY_URL . '/blueprints/utilities/edit/' . $this->_context[1] . '/'); } else { $fields['body'] = file_get_contents(PageManager::getTemplate('blueprints.utility')); } $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. See below for details.'), Alert::ERROR); } // These alerts are only valid if the form doesn't have errors if (isset($this->_context[2])) { switch ($this->_context[2]) { case 'saved': $this->pageAlert(__('Utility updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/utilities/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/utilities/" accesskey="a">' . __('View all Utilities') . '</a>', Alert::SUCCESS); break; case 'created': $this->pageAlert(__('Utility created at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/utilities/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/utilities/" accesskey="a">' . __('View all Utilities') . '</a>', Alert::SUCCESS); break; } } $this->setTitle(__($this->_context[0] == 'new' ? '%2$s – %3$s' : '%1$s – %2$s – %3$s', array($filename, __('Utilities'), __('Symphony')))); $this->appendSubheading($this->_context[0] == 'new' ? __('Untitled') : $filename); $this->insertBreadcrumbs(array(Widget::Anchor(__('Utilities'), SYMPHONY_URL . '/blueprints/utilities/'))); if (!empty($_POST)) { $fields = $_POST['fields']; } $fields['body'] = htmlentities($fields['body'], ENT_COMPAT, 'UTF-8'); $fields['name'] = isset($fields['name']) ? $fields['name'] : null; $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'primary column'); $label = Widget::Label(__('Name')); $label->appendChild(Widget::Input('fields[name]', $fields['name'])); $fieldset->appendChild(isset($this->_errors['name']) ? Widget::Error($label, $this->_errors['name']) : $label); $label = Widget::Label(__('Body')); $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code'))); $fieldset->appendChild(isset($this->_errors['body']) ? Widget::Error($label, $this->_errors['body']) : $label); $this->Form->appendChild($fieldset); $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES); $utilities = $utilities['filelist']; if (is_array($utilities) && !empty($utilities)) { $this->Form->setAttribute('class', 'two columns'); $div = new XMLElement('div'); $div->setAttribute('class', 'secondary column'); $p = new XMLElement('p', __('Utilities')); $p->setAttribute('class', 'label'); $div->appendChild($p); $frame = new XMLElement('div', null, array('class' => 'frame')); $ul = new XMLElement('ul'); $ul->setAttribute('id', 'utilities'); foreach ($utilities as $util) { $li = new XMLElement('li'); $li->appendChild(Widget::Anchor($util, SYMPHONY_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL)); $ul->appendChild($li); } $frame->appendChild($ul); $div->appendChild($frame); $this->Form->appendChild($div); } $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', $this->_context[0] == 'edit' ? __('Save Changes') : __('Create Utility'), 'submit', array('accesskey' => 's'))); if ($this->_context[0] == 'edit') { $button = new XMLElement('button', __('Delete')); $button->setAttributeArray(array('name' => 'action[delete]', 'class' => 'button confirm delete', 'title' => __('Delete this utility'), 'type' => 'submit', 'accesskey' => 'd', 'data-message' => __('Are you sure you want to delete this Utility?'))); $div->appendChild($button); } $this->Form->appendChild($div); }
public function __viewTemplate() { $this->setPageType('form'); $handle = isset($this->_context[1]) ? $this->_context[1] : null; $this->Form->setAttribute('action', SYMPHONY_URL . '/blueprints/pages/template/' . $handle . '/'); $this->Form->setAttribute('class', 'columns'); $filename = $handle . '.xsl'; $file_abs = PAGES . '/' . $filename; $is_child = strrpos($handle, '_'); $pagename = $is_child != false ? substr($handle, $is_child + 1) : $handle; $pagedata = PageManager::fetch(false, array('id'), array("p.handle = '{$pagename}'")); $pagedata = array_pop($pagedata); if (!is_file($file_abs)) { redirect(SYMPHONY_URL . '/blueprints/pages/'); } $fields['body'] = @file_get_contents($file_abs); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. See below for details.'), Alert::ERROR); } else { if (isset($this->_context[2])) { $this->pageAlert(__('Page updated at %s.', array(DateTimeObj::getTimeAgo())) . ' <a href="' . SYMPHONY_URL . '/blueprints/pages/new/" accesskey="c">' . __('Create another?') . '</a> <a href="' . SYMPHONY_URL . '/blueprints/pages/" accesskey="a">' . __('View all Pages') . '</a>', Alert::SUCCESS); } } $this->setTitle(__($filename ? '%1$s – %2$s – %3$s' : '%2$s – %3$s', array($filename, __('Pages'), __('Symphony')))); $this->appendSubheading(__($filename ? $filename : __('Untitled')), Widget::Anchor(__('Edit Page'), SYMPHONY_URL . '/blueprints/pages/edit/' . $pagedata['id'] . '/', __('Edit Page Configuration'), 'button', NULL, array('accesskey' => 't'))); $this->insertBreadcrumbsUsingPageIdentifier($pagedata['id']); if (!empty($_POST)) { $fields = $_POST['fields']; } $fields['body'] = htmlentities($fields['body'], ENT_COMPAT, 'UTF-8'); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'primary column'); $label = Widget::Label(__('Body')); $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code'))); if (isset($this->_errors['body'])) { $label = Widget::Error($label, $this->_errors['body']); } $fieldset->appendChild($label); $this->Form->appendChild($fieldset); $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES); $utilities = $utilities['filelist']; if (is_array($utilities) && !empty($utilities)) { $this->Form->setAttribute('class', 'two columns'); $div = new XMLElement('div'); $div->setAttribute('class', 'secondary column'); $p = new XMLElement('p', __('Utilities')); $p->setAttribute('class', 'label'); $div->appendChild($p); $frame = new XMLElement('div', null, array('class' => 'frame')); $ul = new XMLElement('ul'); $ul->setAttribute('id', 'utilities'); foreach ($utilities as $util) { $li = new XMLElement('li'); $li->appendChild(Widget::Anchor($util, SYMPHONY_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL)); $ul->appendChild($li); } $frame->appendChild($ul); $div->appendChild($frame); $this->Form->appendChild($div); } $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's'))); $this->Form->appendChild($div); }
public function __viewTemplate() { $this->setPageType('form'); $this->Form->setAttribute('action', SYMPHONY_URL . '/blueprints/pages/template/' . $this->_context[1] . '/'); $filename = $this->_context[1] . '.xsl'; $file_abs = PAGES . '/' . $filename; $is_child = strrpos($this->_context[1], '_'); $pagename = $is_child != false ? substr($this->_context[1], $is_child + 1) : $this->_context[1]; $pagedata = Symphony::Database()->fetchRow(0, "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tp.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`tbl_pages` AS p\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tp.handle = '{$pagename}'\n\t\t\t\t\tLIMIT 1\n\t\t\t\t"); if (!is_file($file_abs)) { redirect(SYMPHONY_URL . '/blueprints/pages/'); } $fields['body'] = @file_get_contents($file_abs); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), Alert::ERROR); } // Status message: if (isset($this->_context[2])) { $this->pageAlert(__('Page updated at %1$s. <a href="%2$s" accesskey="c">Create another?</a> <a href="%3$s" accesskey="a">View all Pages</a>', array(DateTimeObj::getTimeAgo(__SYM_TIME_FORMAT__), SYMPHONY_URL . '/blueprints/pages/new/' . $link_suffix, SYMPHONY_URL . '/blueprints/pages/' . $link_suffix)), Alert::SUCCESS); } $this->setTitle(__($filename ? '%1$s – %2$s – %3$s' : '%1$s – %2$s', array(__('Symphony'), __('Pages'), $filename))); $this->appendSubheading(__($filename ? $filename : __('Untitled')), Widget::Anchor(__('Edit Configuration'), SYMPHONY_URL . '/blueprints/pages/edit/' . $pagedata['id'], __('Edit Page Confguration'), 'button', NULL, array('accesskey' => 't'))); if (!empty($_POST)) { $fields = $_POST['fields']; } $fields['body'] = General::sanitize($fields['body']); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'primary'); $label = Widget::Label(__('Body')); $label->appendChild(Widget::Textarea('fields[body]', 30, 80, $fields['body'], array('class' => 'code'))); if (isset($this->_errors['body'])) { $label = $this->wrapFormElementWithError($label, $this->_errors['body']); } $fieldset->appendChild($label); $this->Form->appendChild($fieldset); $utilities = General::listStructure(UTILITIES, array('xsl'), false, 'asc', UTILITIES); $utilities = $utilities['filelist']; if (is_array($utilities) && !empty($utilities)) { $div = new XMLElement('div'); $div->setAttribute('class', 'secondary'); $p = new XMLElement('p', __('Utilities')); $p->setAttribute('class', 'label'); $div->appendChild($p); $ul = new XMLElement('ul'); $ul->setAttribute('id', 'utilities'); foreach ($utilities as $index => $util) { $li = new XMLElement('li'); if ($index % 2 != 1) { $li->setAttribute('class', 'odd'); } $li->appendChild(Widget::Anchor($util, SYMPHONY_URL . '/blueprints/utilities/edit/' . str_replace('.xsl', '', $util) . '/', NULL)); $ul->appendChild($li); } $div->appendChild($ul); $this->Form->appendChild($div); } $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', __('Save Changes'), 'submit', array('accesskey' => 's'))); $this->Form->appendChild($div); }
function view() { $this->_Parent->Page->addStylesheetToHead(URL . '/extensions/filemanager/assets/styles.css', 'screen', 70); $FileManager =& $this->_Parent->ExtensionManager->create('filemanager'); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert(__('An error occurred while processing this form. <a href="#error">See below for details.</a>'), AdministrationPage::PAGE_ALERT_ERROR); } $this->setPageType('form'); $type = array_shift($this->_context); $this->appendSubheading(trim($FileManager->getStartLocationLink(), '/') . $FileManager->buildBreadCrumbs($this->_context)); $this->Form->setAttribute('enctype', 'multipart/form-data'); $this->Form->prependChild(Widget::Input('MAX_FILE_SIZE', Administration::instance()->Configuration->get('max_upload_size', 'admin'), 'hidden')); $this->Form->prependChild(Widget::Input('type', $type, 'hidden')); $fields = array(); if (isset($_POST['fields'])) { $fields = $_POST['fields']; } else { $fields['file']['permissions'] = Administration::instance()->Configuration->get('write_mode', 'file'); $fields['upload']['permissions'] = Administration::instance()->Configuration->get('write_mode', 'file'); $fields['directory']['permissions'] = Administration::instance()->Configuration->get('write_mode', 'directory'); } switch ($type) { case 'upload': default: $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-upload'); $fieldset->appendChild(new XMLElement('legend', __('Upload Existing File'))); $div = new XMLElement('div'); $div->setAttribute('class', 'group'); $label = Widget::Label(__('File'), NULL, 'file'); $span = new XMLElement('span'); $span->appendChild(Widget::Input('fields[upload][file]', NULL, 'file')); $label->appendChild($span); if (isset($this->_errors['upload']['file'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['upload']['file'])); } else { $div->appendChild($label); } $label = Widget::Label(__('Permissions')); $label->appendChild(Widget::Input('fields[upload][permissions]', General::sanitize($fields['upload']['permissions']))); if (isset($this->_errors['upload']['permissions'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['upload']['permissions'])); } else { $div->appendChild($label); } $fieldset->appendChild($div); $this->Form->appendChild($fieldset); break; case 'directory': $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-directory'); $fieldset->appendChild(new XMLElement('legend', __('Create New Directory'))); $div = new XMLElement('div'); $div->setAttribute('class', 'group'); $label = Widget::Label(__('Name')); $label->appendChild(Widget::Input('fields[directory][name]', General::sanitize($fields['directory']['name']))); if (isset($this->_errors['directory']['name'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['directory']['name'])); } else { $div->appendChild($label); } $label = Widget::Label(__('Permissions')); $label->appendChild(Widget::Input('fields[directory][permissions]', General::sanitize($fields['directory']['permissions']))); if (isset($this->_errors['directory']['permissions'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['directory']['permissions'])); } else { $div->appendChild($label); } $fieldset->appendChild($div); $this->Form->appendChild($fieldset); break; case 'file': $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-file'); $fieldset->appendChild(new XMLElement('legend', __('Create New File'))); $div = new XMLElement('div'); $div->setAttribute('class', 'group'); $label = Widget::Label(__('Name')); $label->appendChild(Widget::Input('fields[file][name]', General::sanitize($fields['name']))); if (isset($this->_errors['file']['name'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['file']['name'])); } else { $div->appendChild($label); } $label = Widget::Label(__('Permissions')); $label->appendChild(Widget::Input('fields[file][permissions]', General::sanitize($fields['file']['permissions']))); if (isset($this->_errors['file']['permissions'])) { $div->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['file']['permissions'])); } else { $div->appendChild($label); } $fieldset->appendChild($div); $label = Widget::Label(__('Contents')); $label->appendChild(Widget::Textarea('fields[file][contents]', '25', '50', General::sanitize($fields['file']['contents']), array('class' => 'code'))); if (isset($this->_errors['file']['contents'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['file']['contents'])); } else { $fieldset->appendChild($label); } $this->Form->appendChild($fieldset); break; } $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', __('Create'), 'submit', array('accesskey' => 's'))); $this->Form->appendChild($div); }
public function viewForm() { $this->setPageType('form'); $this->appendSubheading(__('Roles')); // Create a group for the essential settings (for now, this is only the role name): $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', __('Essentials'))); $div = new XMLElement('div'); $div->setAttribute('class', 'group'); $label = Widget::Label(__('Role Name')); // The name input field: $label->appendChild(Widget::Input('name', $this->getValue('name'))); $div->appendChild($label); $group->appendChild($div); $this->Form->appendChild($group); // Create a group for the table (this is where the magic happens): $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', __('Sections'))); $div = new XMLElement('div'); $div->setAttribute('class', 'group'); // The main table: // Set the table head: $tableHead = array(array(__('Name'), null, array('class' => 'name')), array('<span rel="visible">' . __('Visible') . '</span>', null, array('class' => 'center')), array('<span rel="create">' . __('Create') . '</span>', null, array('class' => 'center')), array('<span rel="edit">' . __('Edit') . '</span>', null, array('class' => 'center')), array('<span rel="delete">' . __('Delete') . '</span>', null, array('class' => 'center')), array(__('Fields'), null, array('class' => 'center')), array(__('Entries'), null, array('class' => 'center'))); // Set the table body: $tableBody = array(); // Get the sections: $sections = SectionManager::fetch(); $i = 0; foreach ($sections as $section) { $id = $section->get('id'); $i++; $classArray = $i % 2 == 0 ? array('class' => 'even') : array(); // Create a row for each section, with a rowspan: $row = new XMLElement('tr', null, $classArray); $row->appendChild(new XMLElement('td', $section->get('name'), array('rowspan' => 2))); $row->appendChild($this->tdCheckBox('section[' . $id . '][visible]', $this->checkSection($id, 'visible') == 1)); $row->appendChild($this->tdCheckBox('section[' . $id . '][create]', $this->checkSection($id, 'create') == 1)); $row->appendChild($this->tdCheckBox('section[' . $id . '][edit]', $this->checkSection($id, 'edit') == 1)); $row->appendChild($this->tdCheckBox('section[' . $id . '][delete]', $this->checkSection($id, 'delete') == 1)); $row->appendChild(new XMLElement('td', '<a href="#" rel="fields">Edit</a>', array('class' => 'checkbox'))); $row->appendChild(new XMLElement('td', '<a href="#" rel="entries">Edit</a>', array('class' => 'checkbox'))); $tableBody[] = $row; // Extra row for the fields and entries options: $row = new XMLElement('tr'); $td = new XMLElement('td', null, array('colspan' => 6, 'class' => 'options')); $divFields = new XMLElement('div', null, array('class' => 'sub fields')); $divFields->appendChild(new XMLElement('h3', __('Fields'))); // Put all the fields in here: $thead = array(array(__('Name'), null, array('class' => 'name')), array(__('Hide'))); $tBody = array(); // Get the fields: $fields = FieldManager::fetch(null, $id); if ($fields != false) { foreach ($fields as $field) { $id_field = $field->get('id'); $required = $field->get('required'); $fieldRow = new XMLElement('tr'); $fieldRow->appendChild(new XMLElement('td', $field->get('label'))); if ($required == 'no') { $fieldRow->appendChild($this->tdCheckBox('section[' . $id . '][fields][' . $id_field . '][hidden]', $this->checkFields($id_field, 'hidden') == 1)); } else { $fieldRow->appendChild(new XMLElement('td', __('required') . ' *', array('class' => 'required'))); } $tBody[] = $fieldRow; } } $divFields->appendChild(Widget::Table(Widget::TableHead($thead), null, Widget::TableBody($tBody))); $divFields->appendChild(new XMLElement('p', '* ' . __('You cannot hide required fields'), array('class' => 'info'))); $td->appendChild($divFields); // Entry options: $divEntries = new XMLElement('div', null, array('class' => 'sub entries')); $label = Widget::Label(); // check if this checkbox is checked: $attributes = $this->checkSection($id, 'own_entries') == 1 ? array('checked' => 'checked') : null; $input = Widget::Input('section[' . $id . '][own_entries]', null, 'checkbox', $attributes); $label->setValue($input->generate() . ' ' . __('Author can view/edit own entries only')); $divEntries->appendChild($label); $label = Widget::Label(); $attributes = $this->checkSection($id, 'use_filter') == 1 ? array('checked' => 'checked') : null; $input = Widget::Input('section[' . $id . '][use_filter]', null, 'checkbox', $attributes); $label->setValue($input->generate() . ' ' . __('Use filter')); $divEntries->appendChild($label); $filterRule = new XMLElement('div', null, array('class' => 'filter')); $label = Widget::Label(__('Filter type')); $rule = explode(':', $this->_data['sections'][$id]['filter_rule']); $options = array(array('show', $rule[0] == 'show', 'show'), array('hide', $rule[0] == 'hide', 'hide')); $label->appendChild(Widget::Select('section[' . $id . '][filter_rule_type]', $options)); $filterRule->appendChild($label); $label = Widget::Label(__('ID\'s')); $rule = isset($rule[1]) ? $rule[1] : ''; $label->appendChild(Widget::Input('section[' . $id . '][filter_rule]', $rule)); $filterRule->appendChild($label); $filterRule->appendChild(new XMLElement('p', __('Enter a list of comma-seperated ID\'s. Define ranges with a hyphen.<br />Example: <code>2,3,6-11,13</code>'), array('class' => 'info'))); $divEntries->appendChild($filterRule); $td->appendChild($divEntries); $row->appendChild($td); $tableBody[] = $row; } // Create the table element: $table = Widget::Table(Widget::TableHead($tableHead), null, Widget::TableBody($tableBody), 'author_roles'); $div->appendChild($table); $group->appendChild($div); $this->Form->appendChild($group); // Add custom elements: $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', __('Custom links'))); $label = new XMLElement('label', __('Hide custom menu elements')); $label->appendChild(Widget::Textarea('custom_elements', 5, 15, $this->_data['custom_elements'])); $label->appendChild(new XMLElement('p', __('Enter the links of custom menu elements to exclude these links from the main navigation. You can use this to exclude extensions-driven menu-items like Dashboard or Search Index for example. Give one link per line, and enter the URL after the <code>/symphony/</code>-part. For example: <code>/extension/dashboard/index/</code>.'), array('class' => 'help'))); $group->appendChild($label); $this->Form->appendChild($group); // Add the actions: $actions = new XMLElement('div'); $actions->setAttribute('class', 'actions'); if ($this->_id_role == 0) { $buttonText = __('Create Role'); } else { $buttonText = __('Save Changes'); } // Add the ID: $actions->appendChild(Widget::Input('id_role', (string) $this->_id_role, 'hidden')); $actions->appendChild(Widget::Input('save', $buttonText, 'submit')); $this->Form->appendChild($actions); }
function view() { $this->_Parent->Page->addStylesheetToHead(URL . '/extensions/members/assets/styles.css', 'screen', 70); $formHasErrors = is_array($this->_errors) && !empty($this->_errors); if ($formHasErrors) { $this->pageAlert('An error occurred while processing this form. <a href="#error">See below for details.</a>', AdministrationPage::PAGE_ALERT_ERROR); } $this->setPageType('form'); $this->appendSubheading('Untitled'); $fields = array(); if (isset($_POST['fields'])) { $fields = $_POST['fields']; } $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-file'); $fieldset->appendChild(new XMLElement('legend', 'Essentials')); $label = Widget::Label('Name'); $label->appendChild(Widget::Input('fields[name]', General::sanitize($fields['name']))); if (isset($this->_errors['name'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['name'])); } else { $fieldset->appendChild($label); } $this->Form->appendChild($fieldset); $EventManager = new EventManager($this->_Parent); $events = $EventManager->listAll(); if (is_array($events) && !empty($events)) { foreach ($events as $handle => $e) { if (!$e['can_parse']) { unset($events[$handle]); } } } if (is_array($events) && !empty($events)) { $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-file'); $fieldset->appendChild(new XMLElement('legend', 'Event Level Permissions')); $aTableHead = array(array('Event', 'col'), array('Add', 'col'), array('Edit', 'col'), array('Delete', 'col')); $aTableBody = array(); foreach ($events as $event_handle => $event) { $permissions = $fields['permissions'][$event_handle]; ## Setup each cell $td1 = Widget::TableData($event['name']); $td2 = Widget::TableData(Widget::Input('fields[permissions][' . $event_handle . '][add]', 'yes', 'checkbox', isset($permissions['add']) ? array('checked' => 'checked') : NULL)); $td3 = Widget::TableData(Widget::Input('fields[permissions][' . $event_handle . '][edit]', 'yes', 'checkbox', isset($permissions['edit']) ? array('checked' => 'checked') : NULL)); $td4 = Widget::TableData(Widget::Input('fields[permissions][' . $event_handle . '][delete]', 'yes', 'checkbox', isset($permissions['delete']) ? array('checked' => 'checked') : NULL)); ## Add a row to the body array, assigning each cell to the row $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3, $td4)); } $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'role-permissions'); $fieldset->appendChild($table); $this->Form->appendChild($fieldset); } #### # Delegate: MemberRolePermissionFieldsetsNew # Description: Add custom fieldsets to the role page $ExtensionManager = new ExtensionManager($this->_Parent); $ExtensionManager->notifyMembers('MemberRolePermissionFieldsetsNew', '/extension/members/new/', array('form' => &$this->Form, 'permissions' => $fields['permissions'])); ##### $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-file'); $fieldset->appendChild(new XMLElement('legend', 'Page Level Permissions')); $pages = $this->_Parent->Database->fetch("SELECT * FROM `tbl_pages` " . ($this->_context[0] == 'edit' ? "WHERE `id` != '{$page_id}' " : '') . "ORDER BY `title` ASC"); $label = Widget::Label('Allow Access'); $options = array(); if (is_array($pages) && !empty($pages)) { foreach ($pages as $page) { $options[] = array($page['id'], in_array($page['id'], $fields['page_access']), '/' . $this->_Parent->resolvePagePath($page['id'])); //$page['title']); } } $label->appendChild(Widget::Select('fields[page_access][]', $options, array('multiple' => 'multiple'))); $fieldset->appendChild($label); $this->Form->appendChild($fieldset); $fieldset = new XMLElement('fieldset'); $fieldset->setAttribute('class', 'settings type-file'); $fieldset->appendChild(new XMLElement('legend', 'Email Template')); $fieldset->appendChild(new XMLElement('p', 'When adding a member, they will receive an email based on the template you specify. <br /><br />Leave everything blank if you do not wish for new members in this group to receive an email.', array('class' => 'help'))); $label = Widget::Label('Subject'); $label->appendChild(Widget::Input('fields[email_subject]', General::sanitize($fields['email_subject']))); if (isset($this->_errors['email_subject'])) { $fieldset->appendChild(Widget::wrapFormElementWithError($label, $this->_errors['email_subject'])); } else { $fieldset->appendChild($label); } $label = Widget::Label('Body'); $label->appendChild(Widget::Textarea('fields[email_body]', '25', '50', General::sanitize($fields['email_body']))); $fieldset->appendChild(isset($this->_errors['email_body']) ? $this->wrapFormElementWithError($label, $this->_errors['email_body']) : $label); $fieldset->appendChild(new XMLElement('p', 'You can add dynamic elements to the email by using <code>{$field-name}</code> syntax, where <code>field-name</code> corresponds to the fields of the new member.', array('class' => 'help'))); $this->Form->appendChild($fieldset); $div = new XMLElement('div'); $div->setAttribute('class', 'actions'); $div->appendChild(Widget::Input('action[save]', 'Create', 'submit', array('accesskey' => 's'))); $this->Form->appendChild($div); }
public function displayPublishPanel(&$wrapper, $data = null, $error = null, $prefix = null, $postfix = null) { $this->_driver->addPublishHeaders($this->_engine->Page); $sortorder = $this->get('sortorder'); $element_name = $this->get('element_name'); $classes = array(); $label = Widget::Label($this->get('label')); $optional = ''; if ($this->get('required') != 'yes') { if ((int) $this->get('text_length') > 0) { $optional = __('$1 of $2 remaining – Optional'); } else { $optional = __('Optional'); } } else { if ((int) $this->get('text_length') > 0) { $optional = __('$1 of $2 remaining'); } } if ($optional) { $label->appendChild(new XMLElement('i', $optional)); } // Input box: if ($this->get('text_size') == 'single') { $input = Widget::Input("fields{$prefix}[{$element_name}]{$postfix}", General::sanitize($data['value'])); ### # Delegate: ModifyTextBoxInlineFieldPublishWidget # Description: Allows developers modify the textbox before it is rendered in the publish forms $delegate = 'ModifyTextBoxInlineFieldPublishWidget'; } else { $input = Widget::Textarea("fields{$prefix}[{$element_name}]{$postfix}", '20', '50', General::sanitize($data['value'])); ### # Delegate: ModifyTextBoxFullFieldPublishWidget # Description: Allows developers modify the textbox before it is rendered in the publish forms $delegate = 'ModifyTextBoxFullFieldPublishWidget'; } // Add classes: $classes[] = 'size-' . $this->get('text_size'); if ($this->get('text_formatter') != 'none') { $classes[] = $this->get('text_formatter'); } $input->setAttribute('class', implode(' ', $classes)); $input->setAttribute('length', (int) $this->get('text_length')); $this->_engine->ExtensionManager->notifyMembers($delegate, '/backend/', array('field' => &$this, 'label' => &$label, 'input' => &$input)); if (is_null($label)) { return; } $label->appendChild($input); if ($error != null) { $label = Widget::wrapFormElementWithError($label, $error); } $wrapper->appendChild($label); }