Commit 1298d2b9 authored by Steven Wittens's avatar Steven Wittens

Modified version of #10230: Put placement of filter format selector in a...

Modified version of #10230: Put placement of filter format selector in a module's hands, and move it below the relevant textarea.
parent 60f945bc
......@@ -211,6 +211,7 @@ function blog_form(&$node) {
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
return $output;
}
......
......@@ -211,6 +211,7 @@ function blog_form(&$node) {
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
return $output;
}
......
......@@ -212,6 +212,7 @@ function book_form(&$node) {
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
$output .= form_textarea(t('Log message'), 'log', $node->log, 60, 5, t('An explanation of the additions or updates being made to help the group understand your motivations.'));
if (user_access('administer nodes')) {
......
......@@ -212,6 +212,7 @@ function book_form(&$node) {
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
$output .= form_textarea(t('Log message'), 'log', $node->log, 60, 5, t('An explanation of the additions or updates being made to help the group understand your motivations.'));
if (user_access('administer nodes')) {
......
......@@ -1435,12 +1435,12 @@ function theme_comment_form($edit, $title) {
$form .= form_textfield(t('Subject'), 'subject', $edit['subject'], 50, 64);
}
// format selector
$form .= filter_form('format', $edit['format']);
// comment field:
$form .= form_textarea(t('Comment'), 'comment', $edit['comment'] ? $edit['comment'] : $user->signature, 70, 10, '', NULL, TRUE);
// format selector
$form .= filter_form('format', $edit['format']);
// preview button:
$form .= form_hidden('cid', $edit['cid']);
$form .= form_hidden('pid', $edit['pid']);
......
......@@ -1435,12 +1435,12 @@ function theme_comment_form($edit, $title) {
$form .= form_textfield(t('Subject'), 'subject', $edit['subject'], 50, 64);
}
// format selector
$form .= filter_form('format', $edit['format']);
// comment field:
$form .= form_textarea(t('Comment'), 'comment', $edit['comment'] ? $edit['comment'] : $user->signature, 70, 10, '', NULL, TRUE);
// format selector
$form .= filter_form('format', $edit['format']);
// preview button:
$form .= form_hidden('cid', $edit['cid']);
$form .= form_hidden('pid', $edit['pid']);
......
......@@ -6,6 +6,9 @@
* Framework for handling filtering of content.
*/
// This is a special format ID which means "use the default format". This value
// can be passed to the filter APIs as a format ID: this is equivalent to not
// passing an explicit format at all.
define('FILTER_FORMAT_DEFAULT', 0);
define('FILTER_HTML_STRIP', 1);
......@@ -619,7 +622,7 @@ function check_output($text, $format = FILTER_FORMAT_DEFAULT) {
* @return
* HTML for the form element.
*/
function filter_form($name, $value = FILTER_FORMAT_DEFAULT) {
function filter_form($name = 'format', $value = FILTER_FORMAT_DEFAULT) {
if ($value == FILTER_FORMAT_DEFAULT) {
$value = variable_get('filter_default_format', 1);
}
......@@ -655,7 +658,7 @@ function filter_form($name, $value = FILTER_FORMAT_DEFAULT) {
* Returns true if the user is allowed to access this format.
*/
function filter_access($format) {
if (user_access('administer filters') || ($format == variable_get('filter_default_format', 1))) {
if (user_access('administer filters') || ($format == FILTER_FORMAT_DEFAULT) || ($format == variable_get('filter_default_format', 1))) {
return true;
}
else {
......
......@@ -6,6 +6,9 @@
* Framework for handling filtering of content.
*/
// This is a special format ID which means "use the default format". This value
// can be passed to the filter APIs as a format ID: this is equivalent to not
// passing an explicit format at all.
define('FILTER_FORMAT_DEFAULT', 0);
define('FILTER_HTML_STRIP', 1);
......@@ -619,7 +622,7 @@ function check_output($text, $format = FILTER_FORMAT_DEFAULT) {
* @return
* HTML for the form element.
*/
function filter_form($name, $value = FILTER_FORMAT_DEFAULT) {
function filter_form($name = 'format', $value = FILTER_FORMAT_DEFAULT) {
if ($value == FILTER_FORMAT_DEFAULT) {
$value = variable_get('filter_default_format', 1);
}
......@@ -655,7 +658,7 @@ function filter_form($name, $value = FILTER_FORMAT_DEFAULT) {
* Returns true if the user is allowed to access this format.
*/
function filter_access($format) {
if (user_access('administer filters') || ($format == variable_get('filter_default_format', 1))) {
if (user_access('administer filters') || ($format == FILTER_FORMAT_DEFAULT) || ($format == variable_get('filter_default_format', 1))) {
return true;
}
else {
......
......@@ -293,6 +293,7 @@ function forum_form(&$node) {
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '');
$output .= filter_form('format', $node->format);
return $output;
}
......
......@@ -293,6 +293,7 @@ function forum_form(&$node) {
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '');
$output .= filter_form('format', $node->format);
return $output;
}
......
......@@ -1009,7 +1009,16 @@ function node_feed($nodes = 0, $channel = array()) {
// Load the specified node:
$item = node_load(array('nid' => $node->nid));
$link = url("node/$node->nid", NULL, NULL, 1);
$items .= format_rss_item($item->title, $link, check_output($item->teaser ? $item->teaser : $item->body, $item->format), array('pubDate' => date('r', $item->changed)));
// Filter and prepare node teaser
if (node_hook($item, 'view')) {
node_invoke($item, 'view', TRUE, FALSE);
}
else {
$item = node_prepare($item, TRUE);
}
$items .= format_rss_item($item->title, $link, $item->teaser, array('pubDate' => date('r', $item->changed)));
}
$channel_defaults = array(
......@@ -1148,7 +1157,6 @@ function node_form($edit) {
$output .= '<input type="hidden" name="op" value="'. check_form(t('Preview')) ."\" />\n";
// Add the admin-specific parts.
if (user_access('administer nodes')) {
$output .= '<div class="admin">';
......@@ -1174,20 +1182,13 @@ function node_form($edit) {
}
// Add the default fields.
$output .= '<div class="standard">';
$output .= form_textfield(t('Title'), 'title', $edit->title, 60, 128, NULL, NULL, TRUE);
// Add filter format selector / filter tips
$output .= filter_form('format', $edit->format);
// Add the node-type-specific fields.
$output .= $form;
// Add the hidden fields.
if ($edit->nid) {
$output .= form_hidden('nid', $edit->nid);
}
......@@ -1205,7 +1206,6 @@ function node_form($edit) {
$output .= form_hidden('type', $edit->type);
// Add the buttons.
$output .= form_submit(t('Preview'));
if (!form_get_errors()) {
......
......@@ -1009,7 +1009,16 @@ function node_feed($nodes = 0, $channel = array()) {
// Load the specified node:
$item = node_load(array('nid' => $node->nid));
$link = url("node/$node->nid", NULL, NULL, 1);
$items .= format_rss_item($item->title, $link, check_output($item->teaser ? $item->teaser : $item->body, $item->format), array('pubDate' => date('r', $item->changed)));
// Filter and prepare node teaser
if (node_hook($item, 'view')) {
node_invoke($item, 'view', TRUE, FALSE);
}
else {
$item = node_prepare($item, TRUE);
}
$items .= format_rss_item($item->title, $link, $item->teaser, array('pubDate' => date('r', $item->changed)));
}
$channel_defaults = array(
......@@ -1148,7 +1157,6 @@ function node_form($edit) {
$output .= '<input type="hidden" name="op" value="'. check_form(t('Preview')) ."\" />\n";
// Add the admin-specific parts.
if (user_access('administer nodes')) {
$output .= '<div class="admin">';
......@@ -1174,20 +1182,13 @@ function node_form($edit) {
}
// Add the default fields.
$output .= '<div class="standard">';
$output .= form_textfield(t('Title'), 'title', $edit->title, 60, 128, NULL, NULL, TRUE);
// Add filter format selector / filter tips
$output .= filter_form('format', $edit->format);
// Add the node-type-specific fields.
$output .= $form;
// Add the hidden fields.
if ($edit->nid) {
$output .= form_hidden('nid', $edit->nid);
}
......@@ -1205,7 +1206,6 @@ function node_form($edit) {
$output .= form_hidden('type', $edit->type);
// Add the buttons.
$output .= form_submit(t('Preview'));
if (!form_get_errors()) {
......
......@@ -123,6 +123,7 @@ function page_form(&$node) {
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
$output .= form_textfield(t('Link name'), 'link', $node->link, 60, 64, t('To make the page show up in the navigation links, enter the name of the link. Otherwise, leave this blank.'));
$output .= form_textfield(t('Link description'), 'description', $node->description, 60, 64, t("The description displayed when hovering over the page's link. Leave blank when you don't want a description."));
......
......@@ -123,6 +123,7 @@ function page_form(&$node) {
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
$output .= form_textfield(t('Link name'), 'link', $node->link, 60, 64, t('To make the page show up in the navigation links, enter the name of the link. Otherwise, leave this blank.'));
$output .= form_textfield(t('Link description'), 'description', $node->description, 60, 64, t("The description displayed when hovering over the page's link. Leave blank when you don't want a description."));
......
......@@ -626,8 +626,16 @@ function statistics_summary($dbfield, $dbrows) {
$content = node_load(array('nid' => $nid['nid']));
$links = link_node($content, 1);
// Filter and prepare node teaser
if (node_hook($content, 'view')) {
node_invoke($content, 'view', TRUE, FALSE);
}
else {
$content = node_prepare($content, TRUE);
}
$output .= '<tr><td><strong>'. l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))) .'</strong></td><td style="text-align: right;"><small>'. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .'</small></td></tr>';
$output .= '<tr><td colspan="2"><div style="margin-left: 20px;">'. check_output($content->teaser, $content->format) .'</div></td></tr>';
$output .= '<tr><td colspan="2"><div style="margin-left: 20px;">'. $content->teaser .'</div></td></tr>';
$output .= '<tr><td style="text-align: right;" colspan="2">[ '. theme('links', $links) .' ]<br /><br /></td></tr>';
}
......
......@@ -626,8 +626,16 @@ function statistics_summary($dbfield, $dbrows) {
$content = node_load(array('nid' => $nid['nid']));
$links = link_node($content, 1);
// Filter and prepare node teaser
if (node_hook($content, 'view')) {
node_invoke($content, 'view', TRUE, FALSE);
}
else {
$content = node_prepare($content, TRUE);
}
$output .= '<tr><td><strong>'. l($nid['title'], 'node/'. $nid['nid'], array('title' => t('View this posting.'))) .'</strong></td><td style="text-align: right;"><small>'. t('Submitted by %a on %b', array('%a' => format_name($content), '%b' => format_date($content->created, 'large'))) .'</small></td></tr>';
$output .= '<tr><td colspan="2"><div style="margin-left: 20px;">'. check_output($content->teaser, $content->format) .'</div></td></tr>';
$output .= '<tr><td colspan="2"><div style="margin-left: 20px;">'. $content->teaser .'</div></td></tr>';
$output .= '<tr><td style="text-align: right;" colspan="2">[ '. theme('links', $links) .' ]<br /><br /></td></tr>';
}
......
......@@ -123,6 +123,7 @@ function story_form(&$node) {
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
return $output;
}
......
......@@ -123,6 +123,7 @@ function story_form(&$node) {
}
$output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
$output .= filter_form('format', $node->format);
return $output;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment