コード例 #1
0
 public function view()
 {
     $this->setPageType('table');
     $this->appendSubheading(__('Templated Text Formatters'), Widget::Anchor(__('Create New'), URL . '/symphony/extension/templatedtextformatters/edit/', __('Create a new hub'), 'create button'));
     $aTableHead = array(array(__('Title'), 'col'), array(__('Type'), 'col'), array(__('Description'), 'col'));
     $aTableBody = array();
     $formatters = $this->_driver->listAll();
     if (!is_array($formatters) || empty($formatters)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead)))));
     } else {
         $tfm = new TextformatterManager($this->_Parent);
         foreach ($formatters as $id => $data) {
             $formatter = $tfm->create($id);
             $about = $formatter->about();
             $td1 = Widget::TableData(Widget::Anchor($about['name'], URL . "/symphony/extension/templatedtextformatters/edit/{$id}/", $about['name']));
             $td2 = Widget::TableData($about['templatedtextformatters-type']);
             $td3 = Widget::TableData($about['description']);
             $td1->appendChild(Widget::Input('items[' . $id . ']', NULL, 'checkbox'));
             // Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody));
     $this->Form->appendChild($table);
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete')));
     $div->appendChild(Widget::Select('with-selected', $options));
     $div->appendChild(Widget::Input('action[apply]', __('Apply'), 'submit'));
     $this->Form->appendChild($div);
 }
コード例 #2
0
 protected function __applyFormatting($data, $validate = false, &$errors = NULL)
 {
     if ($this->get('formatter')) {
         $tfm = new TextformatterManager($this->_engine);
         $formatter = $tfm->create($this->get('formatter'));
         $result = $formatter->run($data);
     }
     if ($validate === true) {
         include_once TOOLKIT . '/class.xsltprocess.php';
         if (!General::validateXML($result, $errors, false, new XsltProcess())) {
             $result = html_entity_decode($result, ENT_QUOTES, 'UTF-8');
             $result = $this->__replaceAmpersands($result);
             if (!General::validateXML($result, $errors, false, new XsltProcess())) {
                 return false;
             }
         }
     }
     return $result;
 }
コード例 #3
0
 function view()
 {
     if (!$this->_context[0]) {
         echo __('Error: No formatter selected.');
         exit;
     }
     $value = $_POST['data'];
     if (!$value) {
         exit;
     }
     $tm = new TextformatterManager($this->_Parent);
     $formatter = $tm->create($this->_context[0]);
     if (!$formatter) {
         echo __('Error: %s text formatter does not exist.', array($this->_context[0]));
         exit;
     }
     echo $formatter->run($value);
     exit;
 }
コード例 #4
0
 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);
 }
コード例 #5
0
 public function view()
 {
     $this->setPageType('table');
     $this->setTitle(__('%1$s – %2$s', array(__('Templated Text Formatters'), __('Symphony'))));
     $this->appendSubheading(__('Templated Text Formatters'), Widget::Anchor(__('Create New'), URL . '/symphony/extension/templatedtextformatters/edit/', __('Create a new formatter'), 'create button', NULL, array('accesskey' => 'c')));
     $aTableHead = array(array(__('Name'), 'col'), array(__('Type'), 'col'), array(__('Description'), 'col'));
     $aTableBody = array();
     $formatters = $this->_driver->listAll();
     if (!is_array($formatters) || empty($formatters)) {
         $aTableBody = array(Widget::TableRow(array(Widget::TableData(__('None found.'), 'inactive', NULL, count($aTableHead))), 'odd'));
     } else {
         foreach ($formatters as $id => $data) {
             $formatter = TextformatterManager::create($id);
             $about = $formatter->about();
             $td1 = Widget::TableData(Widget::Anchor($about['name'], URL . "/symphony/extension/templatedtextformatters/edit/{$id}/", $about['name']));
             $td2 = Widget::TableData($about['templatedtextformatters-type']);
             $td3 = Widget::TableData(General::sanitize($about['description']));
             $td1->appendChild(Widget::Label(__('Select Text Formatter %s', array($about['name'])), null, 'accessible', null, array('for' => 'ttf-' . $id)));
             $td1->appendChild(Widget::Input('items[' . $id . ']', 'on', 'checkbox', array('id' => 'ttf-' . $id)));
             // Add a row to the body array, assigning each cell to the row
             $aTableBody[] = Widget::TableRow(array($td1, $td2, $td3));
         }
     }
     $table = Widget::Table(Widget::TableHead($aTableHead), NULL, Widget::TableBody($aTableBody), 'selectable', null, array('role' => 'directory', 'aria-labelledby' => 'symphony-subheading', 'data-interactive' => 'data-interactive'));
     $this->Form->appendChild($table);
     $version = new XMLElement('p', 'Symphony ' . Symphony::Configuration()->get('version', 'symphony'), array('id' => 'version'));
     $this->Form->appendChild($version);
     $div = new XMLElement('div');
     $div->setAttribute('class', 'actions');
     $options = array(array(NULL, false, __('With Selected...')), array('delete', false, __('Delete'), 'confirm', null, array('data-message' => __('Are you sure you want to delete the selected text formatters?'))));
     Symphony::ExtensionManager()->notifyMembers('AddCustomActions', '/templatedtextformatters/', array('options' => &$options));
     if (!empty($options)) {
         $div->appendChild(Widget::Apply($options));
         $this->Form->appendChild($div);
     }
 }
コード例 #6
0
ファイル: field.textbox.php プロジェクト: brendo/textboxfield
 public function applyFormatting($data)
 {
     if ($this->get('text_formatter') != 'none') {
         if (isset($this->_ParentCatalogue['entrymanager'])) {
             $tfm = $this->_ParentCatalogue['entrymanager']->formatterManager;
         } else {
             $tfm = new TextformatterManager($this->_engine);
         }
         $formatter = $tfm->create($this->get('text_formatter'));
         $formatted = $formatter->run($data);
         $formatted = preg_replace('/&(?![a-z]{0,4}\\w{2,3};|#[x0-9a-f]{2,6};)/i', '&', $formatted);
         return $formatted;
     }
     return General::sanitize($data);
 }
コード例 #7
0
 function insertComment($comment, $isSpam = false)
 {
     $comment['author_id'] = NULL;
     $author_id = $this->_parent->isLoggedIn();
     if ($author_id !== false) {
         $comment['author_id'] = $author_id;
     }
     $comment['author_ip'] = $_SERVER['REMOTE_ADDR'];
     ####
     # Delegate: CommentPreProcess
     # Description: Just before the comment is processed and saved. Good place to manipulate the data.
     $this->_parent->_CampfireManager->notifyMembers('CommentPreProcess', '/frontend/', array('isSpam' => &$isSpam, 'comment' => &$comment));
     $this->isLastCommentSpam = $isSpam;
     unset($comment['remember']);
     $section = $this->_db->fetchRow(0, "SELECT * FROM tbl_sections WHERE `handle` = '" . $comment['section'] . "' LIMIT 1");
     if (!is_array($section) || empty($section)) {
         $this->_notices[] = 'Invalid section specified.';
         return false;
     }
     unset($comment['section']);
     if (isset($comment['entry_handle'])) {
         include_once TOOLKIT . "/class.entrymanager.php";
         $entryManager = new EntryManager($this->_parent);
         $entry_id = $entryManager->fetchEntryIDFromPrimaryFieldHandle($section['id'], $comment['entry_handle']);
         $comment['entry_id'] = $entry_id[0];
         unset($comment['entry_handle']);
     }
     if (!($entry = $entryManager->fetchEntriesByID($comment['entry_id'], false, true))) {
         $this->_notices[] = 'Invalid entry handle specified.';
         return false;
     }
     if ($section['commenting'] == 'off') {
         return false;
     }
     $this->_notices = array();
     $valid = $this->__validateComment($comment);
     if (!isset($this->_options['override-automatic-spam-detection']) || $this->_options['override-automatic-spam-detection'] == false) {
         $spam = $this->__isSpam($comment) || $this->__isBlackListed($comment['author_ip']);
     } else {
         $spam = $isSpam || $this->__isBlackListed($comment['author_ip']) ? true : false;
     }
     $comment = array_map(array($this, "__doBanWords"), $comment);
     $options = $this->_options;
     require_once LIBRARY . "/core/class.textformattermanager.php";
     $TFM = new TextformatterManager(array('parent' => &$this->_parent));
     if ($options['formatting-type'] != NULL && ($formatter = $TFM->create($options['formatting-type']))) {
         $comment['body'] = $formatter->run($comment['body']);
     } else {
         $comment['body'] = strip_tags($comment['body']);
     }
     $comment['author_url'] = General::validateUrl($comment['author_url']);
     $comment['spam'] = $spam ? "yes" : "no";
     ##Check the comment body for well-formedness
     $xml_errors = array();
     General::validateXML($comment['body'], $xml_errors, false);
     if (!empty($xml_errors)) {
         $xml_errors = array();
         $comment['body'] = str_replace(array('<', '>', '&'), array('&lt;', '&gt;', '&amp;'), $comment['body']);
         General::validateXML($comment['body'], $xml_errors, false, new XsltProcess());
         if (!empty($xml_errors)) {
             $this->_notices[] = "Comment contains invalid text or markup.";
             return false;
         }
     }
     ##
     ##Check the comment name field for well-formedness
     $xml_errors = array();
     General::validateXML($comment['author_name'], $xml_errors, false);
     if (!empty($xml_errors)) {
         $this->_notices[] = "Author name contains invalid text or markup.";
     }
     ##
     $dupe = $options['allow-duplicates'] == "on" ? false : $this->__isDuplicateComment($comment);
     $nuke_comment = !empty($xml_errors) || $spam && $options['nuke-spam'] == 'on';
     ####
     # Delegate: CommentPreSave
     # Description: Just before the comment is inserted into the database. Also, final checks
     #              of its validity have been performed. Good place to manipulate the data and check values
     $this->_parent->_CampfireManager->notifyMembers('CommentPreSave', '/frontend/', array('nuke' => &$nuke_comment, 'dupe' => &$dupe, 'comment' => &$comment));
     if (!$nuke_comment && $valid && !$dupe) {
         if ($spam) {
             $this->isLastCommentSpam = true;
         }
         unset($comment['author_ip']);
         if ($this->_db->insert($comment, "tbl_comments")) {
             $comment_id = $this->_db->getInsertID();
             $this->_parent->updateMetadata("comment", $comment_id);
             ####
             # Delegate: CommentPostSave
             # Description: After inserting comment into database. Comment ID is provided
             $this->_parent->_CampfireManager->notifyMembers('CommentPostSave', '/frontend/', array('id' => $comment_id));
             if ($options['email-notify'] == 'on' && !$spam) {
                 $this->__emailEntryAuthor($comment, $entry);
             }
             return true;
         } else {
             $this->_notices[] = 'Comment not successfully saved. An unknown error has occurred.';
         }
     } else {
         if (!$valid || $nuke_comment) {
             $this->_notices[] = 'Comment flagged as spam and has not been saved.';
             $this->isLastCommentSpam = true;
         } else {
             if ($dupe) {
                 $this->_notices[] = 'Duplicate post detected.';
             }
         }
     }
     ####
     # Delegate: CommentFailedInsert
     # Description: After a failed insert. Notices are provided
     $this->_parent->_CampfireManager->notifyMembers('CommentFailedInsert', '/frontend/', array('notices' => $this->_notices));
     return false;
 }
コード例 #8
0
ファイル: class.field.php プロジェクト: readona/symphonyno5
 /**
  * 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 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)));
 }
コード例 #10
0
 public function getFormatter($name)
 {
     $tfm = new TextformatterManager($this->_Parent);
     $formatter = $tfm->create($name);
     return array('about' => $formatter->about(), 'options' => $formatter->options());
 }
コード例 #11
0
 function applyFormatting($data)
 {
     if ($this->get('formatter')) {
         if (isset($this->_ParentCatalogue['entrymanager'])) {
             $tfm = $this->_ParentCatalogue['entrymanager']->formatterManager;
         } else {
             $tfm = new TextformatterManager($this->_engine);
         }
         $formatter = $tfm->create($this->get('formatter'));
         return $formatter->run($data);
     }
     return NULL;
 }
コード例 #12
0
 public function getFormatters()
 {
     $TFM = new TextformatterManager($this->_Parent);
     return $TFM->listAll();
 }
コード例 #13
0
 $dump = new MySQLDump($DB);
 $data .= $dump->takeDump($Admin->getConfigVar("tbl_prefix", "database") . "entries", "DATA_ONLY");
 $data .= $dump->takeDump($Admin->getConfigVar("tbl_prefix", "database") . "comments", "DATA_ONLY");
 $data .= $dump->takeDump($Admin->getConfigVar("tbl_prefix", "database") . "metadata", "DATA_ONLY", "`class` IN('entry','comment')");
 unset($dump);
 if (!@file_put_contents(TMP . "/migration-backup.sql", $data)) {
     define("__SYM_MIGRATION_ERRORS__", true);
     $Admin->log->pushToLog("Failed.", SYM_LOG_NOTICE, true, true, true);
 } else {
     $Admin->log->pushToLog("Done.", SYM_LOG_NOTICE, true, true, true);
 }
 ##Entries
 if (!defined("__SYM_MIGRATION_ERRORS__")) {
     $Admin->log->pushToLog("Migrating Entries Table", SYM_LOG_NOTICE, true, true);
     //---------------------
     $TFM = new TextformatterManager(array('parent' => &$Admin));
     $sql = "SELECT `id`, `title`, `body_raw`, `formatter` FROM `tbl_entries`";
     if (!($entries = $DB->fetch($sql))) {
         $error = true;
         $Admin->log->pushToLog("Could not get entry records from database", SYM_LOG_ERROR, true, true);
     }
     if (!$error && is_array($entries) && !empty($entries)) {
         foreach ($entries as $e) {
             $error = false;
             $Admin->log->pushToLog("Converting '" . $e['title'] . "' ... ", SYM_LOG_NOTICE, true, false);
             $fields = array();
             if ($e['formatter'] && !($formatter = $TFM->create($e['formatter'], array(), true))) {
                 $error = true;
                 $Admin->log->pushToLog("Failed (Could not create formatter '" . $e['formatter'] . "')", SYM_LOG_NOTICE, true, true, true);
             } else {
                 if ($e['formatter'] != NULL) {
コード例 #14
0
 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);
 }
コード例 #15
0
 *
 * 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"];
?>
コード例 #16
0
 public function applyFormatting($data)
 {
     if ($this->get('formatter') != 'none') {
         $tfm = new TextformatterManager(Symphony::Engine());
         $formatter = $tfm->create($this->get('formatter'));
         $formatted = $formatter->run($data);
         return preg_replace('/&(?![a-z]{0,4}\\w{2,3};|#[x0-9a-f]{2,6};)/i', '&amp;', $formatted);
     }
     return null;
 }
コード例 #17
0
ファイル: class.form.php プロジェクト: symphonists/documenter
 function applyFormatting($data, $validate = false, &$errors = NULL)
 {
     include_once TOOLKIT . '/class.textformattermanager.php';
     $text_formatter = Symphony::Configuration()->get('text-formatter', 'documentation');
     if ($text_formatter != 'none') {
         $formatter = TextformatterManager::create($text_formatter);
         $result = $formatter->run($data);
     } else {
         $result = $data;
     }
     if ($validate === true) {
         include_once TOOLKIT . '/class.xsltprocess.php';
         if ($text_formatter == 'none') {
             $result = DocumentationForm::__replaceAmpersands($result);
         } else {
             if (!General::validateXML($result, $errors, false, new XsltProcess())) {
                 $result = html_entity_decode($result, ENT_QUOTES, 'UTF-8');
                 $result = DocumentationForm::__replaceAmpersands($result);
                 if (!General::validateXML($result, $errors, false, new XsltProcess())) {
                     $result = $formatter->run(General::sanitize($data));
                     if (!General::validateXML($result, $errors, false, new XsltProcess())) {
                         return false;
                     }
                 }
             }
         }
     }
     return $result;
 }
コード例 #18
0
 public function render_panel($context)
 {
     $config = $context['config'];
     switch ($context['type']) {
         case 'datasource_to_table':
             $ds = DatasourceManager::create($config['datasource'], NULL, false);
             if (!$ds) {
                 $context['panel']->appendChild(new XMLElement('div', __('The Data Source with the name <code>%s</code> could not be found.', array($config['datasource']))));
                 return;
             }
             $param_pool = array();
             $xml = $ds->grab($param_pool);
             if (!$xml) {
                 return;
             }
             $xml = $xml->generate();
             require_once TOOLKIT . '/class.xsltprocess.php';
             $proc = new XsltProcess();
             $data = $proc->process($xml, file_get_contents(EXTENSIONS . '/dashboard/lib/datasource-to-table.xsl'));
             $context['panel']->appendChild(new XMLElement('div', $data));
             break;
         case 'rss_reader':
             require_once TOOLKIT . '/class.gateway.php';
             require_once CORE . '/class.cacheable.php';
             $cache_id = md5('rss_reader_cache' . $config['url']);
             $cache = new Cacheable(Administration::instance()->Database());
             $data = $cache->check($cache_id);
             if (!$data) {
                 $ch = new Gateway();
                 $ch->init();
                 $ch->setopt('URL', $config['url']);
                 $ch->setopt('TIMEOUT', 6);
                 $new_data = $ch->exec();
                 $writeToCache = true;
                 if ((int) $config['cache'] > 0) {
                     $cache->write($cache_id, $new_data, $config['cache']);
                 }
                 $xml = $new_data;
                 if (empty($xml) && $data) {
                     $xml = $data['data'];
                 }
             } else {
                 $xml = $data['data'];
             }
             if (!$xml) {
                 $xml = '<error>' . __('Error: could not retrieve panel XML feed.') . '</error>';
             }
             require_once TOOLKIT . '/class.xsltprocess.php';
             $proc = new XsltProcess();
             $data = $proc->process($xml, file_get_contents(EXTENSIONS . '/dashboard/lib/rss-reader.xsl'), array('show' => $config['show']));
             $context['panel']->appendChild(new XMLElement('div', $data));
             break;
         case 'html_block':
             require_once TOOLKIT . '/class.gateway.php';
             require_once CORE . '/class.cacheable.php';
             $cache_id = md5('html_block_' . $config['url']);
             $cache = new Cacheable(Administration::instance()->Database());
             $data = $cache->check($cache_id);
             if (!$data) {
                 $ch = new Gateway();
                 $ch->init();
                 $ch->setopt('URL', $config['url']);
                 $ch->setopt('TIMEOUT', 6);
                 $new_data = $ch->exec();
                 $writeToCache = true;
                 if ((int) $config['cache'] > 0) {
                     $cache->write($cache_id, $new_data, $config['cache']);
                 }
                 $html = $new_data;
                 if (empty($html) && $data) {
                     $html = $data['data'];
                 }
             } else {
                 $html = $data['data'];
             }
             if (!$html) {
                 $html = '<p class="invalid">' . __('Error: could not retrieve panel HTML.') . '</p>';
             }
             $context['panel']->appendChild(new XMLElement('div', $html));
             break;
         case 'symphony_overview':
             $container = new XMLElement('div');
             $dl = new XMLElement('dl');
             $dl->appendChild(new XMLElement('dt', __('Website Name')));
             $dl->appendChild(new XMLElement('dd', Symphony::Configuration()->get('sitename', 'general')));
             $current_version = Symphony::Configuration()->get('version', 'symphony');
             require_once TOOLKIT . '/class.gateway.php';
             $ch = new Gateway();
             $ch->init();
             $ch->setopt('URL', 'https://api.github.com/repos/symphonycms/symphony-2/tags');
             $ch->setopt('TIMEOUT', $timeout);
             $repo_tags = $ch->exec();
             // tags request found
             if (is_array($repo_tags)) {
                 $repo_tags = json_decode($repo_tags);
                 $tags = array();
                 foreach ($repo_tags as $tag) {
                     // remove tags that contain strings
                     if (preg_match('/[a-zA]/i', $tag->name)) {
                         continue;
                     }
                     $tags[] = $tag->name;
                 }
                 natsort($tags);
                 rsort($tags);
                 $latest_version = reset($tags);
             } else {
                 $latest_version = $current_version;
             }
             $needs_update = version_compare($latest_version, $current_version, '>');
             $dl->appendChild(new XMLElement('dt', __('Version')));
             $dl->appendChild(new XMLElement('dd', $current_version . ($needs_update ? ' (<a href="http://getsymphony.com/download/releases/version/' . $latest_version . '/">' . __('Latest is %s', array($latest_version)) . "</a>)" : '')));
             $container->appendChild(new XMLElement('h4', __('Configuration')));
             $container->appendChild($dl);
             $entries = 0;
             foreach (SectionManager::fetch() as $section) {
                 $entries += EntryManager::fetchCount($section->get('id'));
             }
             $dl = new XMLElement('dl');
             $dl->appendChild(new XMLElement('dt', __('Sections')));
             $dl->appendChild(new XMLElement('dd', (string) count(SectionManager::fetch())));
             $dl->appendChild(new XMLElement('dt', __('Entries')));
             $dl->appendChild(new XMLElement('dd', (string) $entries));
             $dl->appendChild(new XMLElement('dt', __('Data Sources')));
             $dl->appendChild(new XMLElement('dd', (string) count(DatasourceManager::listAll())));
             $dl->appendChild(new XMLElement('dt', __('Events')));
             $dl->appendChild(new XMLElement('dd', (string) count(EventManager::listAll())));
             $dl->appendChild(new XMLElement('dt', __('Pages')));
             $dl->appendChild(new XMLElement('dd', (string) count(PageManager::fetch())));
             $container->appendChild(new XMLElement('h4', __('Statistics')));
             $container->appendChild($dl);
             $context['panel']->appendChild($container);
             break;
         case 'markdown_text':
             $formatter = TextformatterManager::create($config['formatter']);
             $html = $formatter->run($config['text']);
             $context['panel']->appendChild(new XMLElement('div', $html));
             break;
     }
 }
コード例 #19
0
ファイル: class.field.php プロジェクト: bauhouse/sym-spectrum
 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;
 }
コード例 #20
0
}
if (isset($_GET['_f'])) {
    switch ($_GET['_f']) {
        case "saved":
            $Admin->pageAlert("saved-time", array("Entry", date("h:i:sa", $date->get(true, false))));
            break;
    }
}
if (defined("__SYM_ENTRY_MISSINGFIELDS__")) {
    $Admin->pageAlert("required", array(@implode(", ", $entryManager->fetchEntryRequiredFields($section_id, true))), false, 'error');
} elseif (defined("__SYM_ENTRY_VALIDATION_ERROR__")) {
    $Admin->pageAlert("validation", __SYM_ENTRY_VALIDATION_ERROR__, false, 'error');
} elseif (defined("__SYM_ENTRY_FIELD_XSLT_ERROR__")) {
    $Admin->pageAlert("xslt-validation", __SYM_ENTRY_FIELD_XSLT_ERROR__, false, 'error');
} else {
    $TFM = new TextformatterManager(array('parent' => &$Admin));
    $about = $TFM->about($fields['formatter']);
    $entry_formatter = $about['name'];
    $about = $TFM->about($Admin->getAuthorTextFormatter());
    $author_formatter = $about['name'];
    unset($TFM);
    if ($entry_formatter != $author_formatter) {
        $Admin->pageAlert("diff-formatter", array($entry_formatter ? $entry_formatter : "raw XHTML", $author_formatter ? $author_formatter : "raw XHTML"), false, 'error');
    }
}
if (!empty($_POST['fields'])) {
    $fields = $_POST['fields'];
    $date->set(strtotime($fields["time"] . " " . $fields['publish_date']));
} else {
    $date->set($fields['timestamp_gmt'], false);
}
コード例 #21
0
ファイル: field.textbox.php プロジェクト: hotdoy/EDclock
 public function applyFormatting($data)
 {
     if ($this->get('text_formatter') != 'none') {
         $formatter = TextformatterManager::create($this->get('text_formatter'));
         $formatted = $formatter->run($data);
         $formatted = preg_replace('/&(?![a-z]{0,4}\\w{2,3};|#[x0-9a-f]{2,6};)/i', '&amp;', $formatted);
         return trim($formatted);
     }
     return General::sanitize(trim($data));
 }
コード例 #22
0
 public function save()
 {
     $about = array();
     if ($this->_context[0] && !is_object($this->formatter)) {
         $this->formatter = TextformatterManager::create($this->_context[0]);
     }
     if (is_object($this->formatter)) {
         $about = TextformatterManager::about($this->_context[0]);
     }
     $fields = $_POST['fields'];
     $driverAbout = ExtensionManager::about('templatedtextformatters');
     $types = $this->_driver->listTypes();
     if (strlen(trim($fields['name'])) < 1) {
         $this->_errors['name'] = __('You have to specify name for text formatter');
         return;
     }
     if ($about['templatedtextformatters-type'] && $about['templatedtextformatters-type'] != $fields['type']) {
         $this->_errors['type'] = __('Changing type of already existing formatter is not allowed');
         return;
     }
     if (!$fields['type'] || !is_array($types[$fields['type']]) || !isset($types[$fields['type']]['path'])) {
         $this->_errors['type'] = __('There is no <code>%s</code> type available', array($fields['type']));
         return;
     }
     $tplfile = $types[$fields['type']]['path'] . '/formatter.' . $fields['type'] . '.tpl';
     if (!@is_file($tplfile)) {
         $this->_errors['type'] = __('Wrong type of text formatter');
         return;
     }
     $classname = 'ttf_' . Lang::createHandle(trim($fields['name']), NULL, '_', false, true, array('@^[^a-z]+@i' => '', '/[^\\w-\\.]/i' => ''));
     $file = TEXTFORMATTERS . '/formatter.' . $classname . '.php';
     $isDuplicate = false;
     $queueForDeletion = NULL;
     if (!$about['handle'] && @is_file($file)) {
         $isDuplicate = true;
     } else {
         if ($about['handle']) {
             if ($classname != $about['handle'] && @is_file($file)) {
                 $isDuplicate = true;
             } elseif ($classname != $about['handle']) {
                 $queueForDeletion = TEXTFORMATTERS . '/formatter.' . $about['handle'] . '.php';
             }
         }
     }
     // Duplicate
     if ($isDuplicate) {
         $this->_errors['name'] = __('Text formatter with the name <code>%s</code> already exists', array($classname));
     }
     if (!empty($this->_errors)) {
         return;
     }
     $description = trim($fields['description']);
     if (empty($description)) {
         $description = __('N/A');
     }
     // https://github.com/symphonycms/symphony-2/wiki/Migration-Guide-to-2.5-for-Developers#properties
     if (is_callable(array('Symphony', 'Author'))) {
         $author = Symphony::Author();
     } else {
         $author = Administration::instance()->Author;
     }
     $tokens = array('___' . $fields['type'] . '/* CLASS NAME */' => $classname, '/* NAME */' => preg_replace('/[^\\w\\s\\.-_\\&\\;]/i', '', trim($fields['name'])), '/* AUTHOR NAME */' => self::cleanupString($author->getFullName()), '/* AUTHOR WEBSITE */' => self::cleanupString(URL), '/* AUTHOR EMAIL */' => self::cleanupString($author->get('email')), '/* RELEASE DATE */' => DateTimeObj::getGMT('c'), '/* DESCRIPTION */' => self::cleanupString($description), '/* TEMPLATEDTEXTFORMATTERS VERSION */' => $driverAbout['version'], '/* TEMPLATEDTEXTFORMATTERS TYPE */' => $fields['type']);
     if (!is_object($this->formatter)) {
         include_once $tplfile;
         $temp = 'formatter___' . $fields['type'];
         $temp = new $temp();
         if (method_exists($temp, 'ttf_tokens')) {
             $tokens = array_merge($tokens, $temp->ttf_tokens());
         }
     } else {
         if (method_exists($this->formatter, 'ttf_tokens')) {
             $tokens = array_merge($tokens, $this->formatter->ttf_tokens());
         }
     }
     $ttfShell = file_get_contents($tplfile);
     $ttfShell = str_replace(array_keys($tokens), $tokens, $ttfShell);
     $ttfShell = str_replace('/* CLASS NAME */', $classname, $ttfShell);
     // Write the file
     if (!is_writable(dirname($file)) || !($write = General::writeFile($file, $ttfShell, Symphony::Configuration()->get('write_mode', 'file')))) {
         $this->pageAlert(__('Failed to write Text Formatter source to <code>%s</code>. Please check permissions.', array($file)), Alert::ERROR);
     } else {
         if ($queueForDeletion || !$about['name']) {
             if ($queueForDeletion) {
                 General::deleteFile($queueForDeletion);
             }
             // TODO: Find a way to make formatted fields update their content
             $_SESSION['templatedtextformatters-alert'] = 'created';
             redirect(URL . '/symphony/extension/templatedtextformatters/edit/' . $classname);
         } else {
             // Update current data
             $_SESSION['templatedtextformatters-alert'] = 'saved';
             $_POST['fields']['name'] = $tokens['/* NAME */'];
             $_POST['fields']['description'] = $tokens['/* DESCRIPTION */'];
         }
     }
 }