Commit 2bf7c1c0 authored by Dries's avatar Dries

- Patch #147662 by Gordon et al: add new #pre_render callback to drupal_render().

parent ef9f10db
......@@ -403,6 +403,7 @@ function drupal_http_request($url, $headers = array(), $method = 'GET', $data =
// Parse the URL, and make sure we can handle the schema.
$uri = parse_url($url);
switch ($uri['scheme']) {
case 'http':
$port = isset($uri['port']) ? $uri['port'] : 80;
......@@ -2483,6 +2484,25 @@ function drupal_render(&$elements) {
return NULL;
}
// If the default values for this element haven't been loaded yet, populate
// them.
if (!isset($elements['#defaults_loaded']) || !$elements['#defaults_loaded']) {
if ((!empty($elements['#type'])) && ($info = _element_info($elements['#type']))) {
$elements += $info;
}
}
// Make any final changes to the element before it is rendered. This means
// that the $element or the chilren can be altered or corrected before the
// element is rendered into the final text.
if (isset($elements['#pre_render'])) {
foreach ($elements['#pre_render'] as $function) {
if (function_exists($function)) {
$elements = $function($elements);
}
}
}
$content = '';
// Either the elements did not go through form_builder or one of the children
// has a #weight.
......@@ -2534,6 +2554,16 @@ function drupal_render(&$elements) {
}
if (isset($content) && $content !== '') {
// Filter the outputed content and make any last changes before the
// content is sent to the browser. The changes are made on $content
// which allows the output'ed text to be filtered.
if (isset($elements['#post_render'])) {
foreach ($elements['#post_render'] as $function) {
if (function_exists($function)) {
$content = $function($content, $elements);
}
}
}
$prefix = isset($elements['#prefix']) ? $elements['#prefix'] : '';
$suffix = isset($elements['#suffix']) ? $elements['#suffix'] : '';
return $prefix . $content . $suffix;
......@@ -2835,7 +2865,7 @@ function drupal_delete_add_query($query) {
* 'question' => Optional. The question for the confirm form.
* 'destination' => Optional. The destination path for form submissions and form cancellations.
*
* Also, any valid options from the $options argument of confirm_form() may
* Also, any valid options from the $options argument of confirm_form() may
* be passed, and they will be passed through to the confirm form.
*/
function drupal_delete_confirm($confirm) {
......@@ -3450,4 +3480,3 @@ function watchdog_severity_levels() {
WATCHDOG_DEBUG => t('debug'),
);
}
......@@ -699,6 +699,7 @@ function form_builder($form_id, $form, &$form_state) {
if (isset($form['#input']) && $form['#input']) {
_form_builder_handle_input_element($form_id, $form, $form_state);
}
$form['#defaults_loaded'] = TRUE;
// We start off assuming all form elements are in the correct order.
$form['#sorted'] = TRUE;
......
......@@ -1726,7 +1726,7 @@ function _locale_export_get_strings($language = NULL, $group = 'default') {
/**
* Generates the PO(T) file contents for given strings.
*
*
* @param $language
* Language object to generate the output for, or NULL if generating
* translation template.
......@@ -1739,7 +1739,7 @@ function _locale_export_get_strings($language = NULL, $group = 'default') {
*/
function _locale_export_po_generate($language = NULL, $strings = array(), $header = NULL) {
global $user;
if (!isset($header)) {
if (isset($language)) {
$header = '# '. $language->name .' translation of '. variable_get('site_name', 'Drupal') ."\n";
......@@ -1776,9 +1776,9 @@ function _locale_export_po_generate($language = NULL, $strings = array(), $heade
$header .= "\"Plural-Forms: nplurals=INTEGER; plural=EXPRESSION;\\n\"\n";
}
}
$output = $header ."\n";
foreach ($strings as $lid => $string) {
// Only process non-children, children are output below their parent.
if (!isset($string['child'])) {
......
......@@ -277,7 +277,7 @@ function drupal_html_to_text($string, $allowed_tags = NULL) {
}
// Process blocks of text.
else {
// Convert inline HTML text to plain text.
// Convert inline HTML text to plain text.
$value = trim(preg_replace('/\s+/', ' ', decode_entities($value)));
if (strlen($value)) {
$chunk = $value;
......@@ -295,7 +295,7 @@ function drupal_html_to_text($string, $allowed_tags = NULL) {
// Remove non-quotation markers from indentation.
$indent = array_map('_drupal_html_to_text_clean', $indent);
}
$tag = !$tag;
}
......
......@@ -3091,7 +3091,7 @@ function node_content_access($op, $node) {
return TRUE;
}
}
if ($op == 'delete') {
if (user_access('delete '. $type .' content') || (user_access('delete own '. $type .' content') && ($user->uid == $node->uid))) {
return TRUE;
......
......@@ -522,13 +522,13 @@ function user_search($op = 'search', $keys = NULL, $skip_access_check = FALSE) {
// Administrators can also search in the otherwise private email field.
$result = pager_query("SELECT name, uid, mail FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%') OR LOWER(mail) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys, $keys);
while ($account = db_fetch_object($result)) {
$find[] = array('title' => $account->name .' ('. $account->mail .')', 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
$find[] = array('title' => $account->name .' ('. $account->mail .')', 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
}
}
else {
$result = pager_query("SELECT name, uid FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys);
$result = pager_query("SELECT name, uid FROM {users} WHERE LOWER(name) LIKE LOWER('%%%s%%')", 15, 0, NULL, $keys);
while ($account = db_fetch_object($result)) {
$find[] = array('title' => $account->name, 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
$find[] = array('title' => $account->name, 'link' => url('user/'. $account->uid, array('absolute' => TRUE)));
}
}
return $find;
......
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