public function view() { // Determine which formatter to use // The textarea keeps this info in its class attribute, but sometimes there might be additional classes. // We'll grab one that matches the installed formatters. $fM = new TextformatterManager($this); $formatter_handle = array_pop(array_intersect(array_keys($fM->listAll()), explode(' ', $_POST['formatter']))); // We pass the full formatter name back for use in the preview display $format_name = new XMLElement('formatter'); $preview = new XMLElement('preview'); if (empty($formatter_handle)) { $format_name->setValue('None'); $preview->setValue($_POST['formatText']); } else { $formatter = $fM->create($formatter_handle); $formatter_about = $formatter->about(); $format_name->setValue($formatter_about['name']); $preview->setValue($formatter->run($_POST['formatText'])); } $this->_Result->appendChild($format_name); $this->_Result->appendChild($preview); }
public function getFormatters($column = 'name', $direction = 'asc', $page = 1, $length = 10000, $full = false) { $tfm = new TextformatterManager($this->_Parent); $results = array(); foreach ($tfm->listAll() as $handle => $about) { if (!isset($about['html-formatter-editable'])) { continue; } if (!$full) { $about['handle'] = $handle; $results[] = $about; } else { $formatter = $tfm->create($handle); $about = $formatter->about(); $about['handle'] = $handle; $results[] = array('about' => $about, 'options' => $formatter->options()); } } // Sorting: if ($column == 'name') { usort($results, array($this, 'getFormattersSortByName')); } else { if ($column == 'modified') { usort($results, array($this, 'getFormattersSortByModified')); } else { if ($column == 'author') { usort($results, array($this, 'getFormattersSortByAuthor')); } } } if ($direction != 'asc') { $results = array_reverse($results); } // Pagination: $results = array_slice($results, ($page - 1) * $length, $length); return $results; }
/** * Construct the html widget for selecting a text formatter for this field. * * @param string $selected (optional) * the currently selected text formatter name if there is one. this defaults * to null. * @param string $name (optional) * the name of this field in the form. this is optional and defaults to * "fields[format]". * @param string $label_value * the default label for the widget to construct. if null is passed in then * this defaults to the localization of "Formatting". * @return XMLElement * An XMLElement representing a `<select>` field containing the options. */ public function buildFormatterSelect($selected = null, $name = 'fields[format]', $label_value) { require_once TOOLKIT . '/class.textformattermanager.php'; $formatters = TextformatterManager::listAll(); if (!$label_value) { $label_value = __('Formatting'); } $label = Widget::Label($label_value); $label->setAttribute('class', 'column'); $options = array(); $options[] = array('none', false, __('None')); if (!empty($formatters) && is_array($formatters)) { foreach ($formatters as $handle => $about) { $options[] = array($handle, $selected == $handle, $about['name']); } } $label->appendChild(Widget::Select($name, $options)); return $label; }
public function buildFormatterSelect($selected = NULL, $name = 'fields[format]', $label_value) { include_once TOOLKIT . '/class.textformattermanager.php'; $TFM = new TextformatterManager($this->_engine); $formatters = $TFM->listAll(); if (!$label_value) { $label_value = __('Formatting'); } $label = Widget::Label($label_value); $options = array(); $options[] = array('none', false, __('None')); if (!empty($formatters) && is_array($formatters)) { foreach ($formatters as $handle => $about) { $options[] = array($handle, $selected == $handle, $about['name']); } } $label->appendChild(Widget::Select($name, $options)); return $label; }
public function ttf_tokens($update = true) { $description = ''; if ($update) { $formatters = TextformatterManager::listAll(); // Reconstruct our current formatters array, so it's up-to-date when form is viewed right after save, without refresh/redirect $this->_formatters = array(); if (is_array($_POST['fields']['formatters'])) { $this->_formatters = array_intersect_key($_POST['fields']['formatters'], $formatters); $description = implode(' → ', $this->_formatters); } } else { if (is_array($this->_formatters) && !empty($this->_formatters)) { $description = implode(' → ', $this->_formatters); } } if (empty($description)) { $description = __('N/A'); } else { $description = __('Formatting text in the following order: %s', array($description)); } return array('/*' . ' DESCRIPTION */' => preg_replace('/^\'|\'$/', '', var_export($description, true)), '/*' . ' FORMATTERS */' => '$this->_formatters = ' . preg_replace(array("/\n /", "/\n\\)\\s*\$/"), array("\n\t\t\t\t", "\n\t\t\t);"), var_export($this->_formatters, true))); }
* Copyright 2004–2006 Twenty One Degrees Pty. Ltd. * * @version 1.7 * @licence https://github.com/symphonycms/symphony-1.7/blob/master/LICENCE * ***/ $GLOBALS['pageTitle'] = "Authors > Untitled"; $fields = $_POST['fields']; if (!$Admin->authorIsSuper()) { $Admin->fatalError("Access Denied", "<p>Access denied. You are not authorised to access this page.</p>", true, true); } if (defined("__SYM_ENTRY_MISSINGFIELDS__")) { $Admin->pageAlert("required", array(@implode(", ", $required)), false, 'error'); } $TFM = new TextformatterManager(array('parent' => &$Admin)); $formatters = $TFM->listAll(); $sections = $DB->fetch("SELECT * FROM `tbl_sections`"); $authors = $DB->fetch("SELECT * FROM `tbl_authors` WHERE `superuser` != '1' && `id` != '" . addslashes($_GET['id']) . "'"); ?> <form id="settings" action="<?php print $Admin->getCurrentPageURL(); ?> " method="post"> <h2>Untitled</h2> <fieldset> <fieldset id="login-details"> <legend>Login Details</legend> <label>Username <input name="fields[username]" value="<?php print $fields["username"]; ?> " /></label>
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 getFormatters() { $TFM = new TextformatterManager($this->_Parent); return $TFM->listAll(); }
public function appendPreferences($context) { include_once TOOLKIT . '/class.textformattermanager.php'; $group = new XMLElement('fieldset'); $group->setAttribute('class', 'settings'); $group->appendChild(new XMLElement('legend', __('Documentation'))); $div = new XMLElement('div'); $div->setAttribute('class', 'group'); // Input for button text $label = Widget::Label(__('Button Text')); $input = Widget::Input('settings[documentation][button-text]', Symphony::Configuration()->get('button-text', 'documentation'), 'text'); $label->appendChild($input); $div->appendChild($label); $formatters = TextformatterManager::listAll(); // Text formatter select $label = Widget::Label(__('Text Formatter')); $options = array(); $options[] = array('none', false, __('None')); if (!empty($formatters) && is_array($formatters)) { foreach ($formatters as $handle => $about) { $options[] = array($handle, Symphony::Configuration()->get('text-formatter', 'documentation') == $handle, $about['name']); } } $input = Widget::Select('settings[documentation][text-formatter]', $options); $label->appendChild($input); $div->appendChild($label); $group->appendChild($div); $context['wrapper']->appendChild($group); }