function echo_themed_page in Echo 7
Same name and namespace in other branches
- 8 echo.module \echo_themed_page()
- 6 echo.module \echo_themed_page()
Returns a page themed for the anonymous user.
Generates the text of a fully-themed Drupal page. The rendered page is returned as a text string instead of being sent to the browser. The theme system can thus be used to style any HTML message as if it had been generated by the live website.
Parameters
$title: The text to display as the page title.
$content: The text to display as the page body.
$theme: The machine-readable name of the theme to use.
Return value
A string containing the fully-themed html page.
1 call to echo_themed_page()
- echo_requirements in ./
echo.install - Implements hook_requirements().
File
- ./
echo.module, line 28 - The echo module converts text into a fully-themed page.
Code
function echo_themed_page($title, $content, $theme) {
$url = url('echo', array(
'absolute' => TRUE,
));
// Store a hash of the arguments in the cache, which will be checked by
// _echo_access() to ensure that the request originated from this function
// and not from an external source.
$key = variable_get('echo_key');
$token = sha1($title . $content . $theme . $key);
// Thirty seconds ought to be enough for anyone.
$options = array(
'method' => 'POST',
'data' => 'title=' . rawurlencode($title) . '&content=' . rawurlencode($content) . '&theme=' . rawurlencode($theme) . '&token=' . $token,
'headers' => array(
'Content-Type' => 'application/x-www-form-urlencoded',
),
);
$return = '';
// Turn off maintenance mode so that anonymous page views work.
if ($maintenance_mode = variable_get('maintenance_mode', 0)) {
variable_set('maintenance_mode', 0);
}
if (($response = drupal_http_request($url, $options)) && isset($response->data)) {
$return = $response->data;
}
if ($maintenance_mode) {
variable_set('maintenance_mode', $maintenance_mode);
}
return $return;
}