Commit f0206254 authored by Matthias Hutterer's avatar Matthias Hutterer
Browse files

code style cleanup

parent b856d449
<?php
// $Id$
/**
* @file
* Defines schema for email fields
*/
/**
* Implements hook_field_schema().
*/
......
......@@ -37,7 +37,7 @@ function email_field_validate($obj_type, $object, $field, $instance, $langcode,
/**
* Implements of hook_content_is_empty().
* Implements hook_content_is_empty().
*/
function email_field_is_empty($item, $field) {
if (empty($item['email'])) {
......@@ -87,7 +87,7 @@ function email_field_formatter_view($object_type, $object, $field, $instance, $l
switch ($display['type']) {
case 'email_default':
foreach ($items as $delta => $item) {
$output = l($item['email'], 'mailto:'. $item['email']);
$output = l($item['email'], 'mailto:' . $item['email']);
$element[$delta] = array('#markup' => $output);
}
break;
......@@ -95,8 +95,8 @@ function email_field_formatter_view($object_type, $object, $field, $instance, $l
case 'email_contact':
$ids = entity_extract_ids($object_type, $object);
foreach ($items as $delta => $item) {
$element[$delta] = array('#markup' => l(t('Contact person by email'), 'email/'. $object_type .'/'. $ids[0] .'/'. $instance['field_name']));
// since email is always sent to first item's email, break after any email address found
$element[$delta] = array('#markup' => l(t('Contact person by email'), 'email/' . $object_type . '/' . $ids[0] . '/' . $instance['field_name']));
// Since email is always sent to first item's email, break after any email address found.
break;
}
break;
......@@ -113,7 +113,7 @@ function email_field_formatter_view($object_type, $object, $field, $instance, $l
$element[$delta] = spamspan($item['email']);
}
else {
$output = l($item['email'], 'mailto:'. $item['email']);
$output = l($item['email'], 'mailto:' . $item['email']);
$element[$delta] = array('#markup' => $output);
}
}
......@@ -169,7 +169,7 @@ function email_field_widget_form(&$form, &$form_state, $field, $instance, $langc
}
/**
* Implementation of hook_menu().
* Implements hook_menu().
*/
function email_menu() {
$items['email/%/%/%'] = array(
......@@ -244,10 +244,10 @@ function email_mail_page($object_type, $object_id, $field_name) {
$entity_info = entity_extract_ids($object_type, $object);
$settings = field_info_instance($object_type, $field_name, $entity_info[2]);
$found = false;
$found = FALSE;
foreach ($settings['display'] as $display_name => $display_data) {
if (isset($display_data['type']) && ($display_data['type'] === 'email_contact')) {
$found = true;
$found = TRUE;
break;
}
}
......@@ -328,7 +328,7 @@ function email_mail_page_form_validate($form, &$form_state) {
}
if (preg_match("/\r|\n/", $form_state['values']['subject'])) {
form_set_error('subject', t('The subject cannot contain linebreaks.'));
watchdog('mail', 'Email injection exploit attempted in email form subject: '. check_plain($form_state['values']['subject']), WATCHDOG_NOTICE);
watchdog('mail', 'Email injection exploit attempted in email form subject: ' . check_plain($form_state['values']['subject']), WATCHDOG_NOTICE);
}
}
......@@ -341,7 +341,7 @@ function email_mail_page_form_submit($form, &$form_state) {
$field_name = $form_state['values']['field_name'];
$email = $form_state['values']['email'];
//load entity
// Load entity
$objects = entity_load($object_type, array($object_id));
$object = $objects[$object_id];
$object_info = entity_get_info($object_type);
......@@ -374,21 +374,21 @@ function email_mail_page_form_submit($form, &$form_state) {
}
/**
* Implementation of hook_mail()
* Implements hook_mail().
*/
function email_mail($key, &$message, $params) {
$language = $message['language'];
switch($key) {
switch ($key) {
case 'contact':
// Compose the body:
$message['body'][] = t('@name sent a message using the contact form at @url.', array('@name' => $params['name'], '@url' => $params['url']), array('langcode' =>$language->language));
$message['body'][] = $params['message'];
$message['subject'] = "";
//include the title of the entity, if one exists
// Include the title of the entity, if one exists
$object = $params['object'];
if (isset($object->title) && !empty($object->title)) {
$message['subject'] = "[". check_plain(preg_replace("/\r|\n/",'', $object->title)) ."]";
$message['subject'] = "[" . check_plain(preg_replace("/\r|\n/", '', $object->title)) . "]";
}
$message['subject'] .= " " . check_plain($params['subject']);
break;
......@@ -399,7 +399,7 @@ function email_mail($key, &$message, $params) {
//TODO Token support
/**
* Implements of hook_token_list()
* Implements hook_token_list().
*
function email_token_list($type = 'all') {
if ($type == 'field' || $type == 'all') {
......@@ -410,7 +410,7 @@ function email_token_list($type = 'all') {
}
/**
* Implements of hook token_values().
* Implements hook token_values().
*
function email_token_values($type, $object = NULL, $options = array()) {
if ($type == 'field') {
......@@ -420,7 +420,8 @@ function email_token_values($type, $object = NULL, $options = array()) {
return $tokens;
}
}
*/
*/
/**
* Settings for contact form
*/
......
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