? .cvsignore ? truncation_setting.patch ? truncation_setting2.patch Index: userpoints.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/userpoints/Attic/userpoints.admin.inc,v retrieving revision 1.1.2.12 diff -u -p -r1.1.2.12 userpoints.admin.inc --- userpoints.admin.inc 30 Jan 2011 17:44:26 -0000 1.1.2.12 +++ userpoints.admin.inc 30 Jan 2011 20:50:47 -0000 @@ -809,6 +809,14 @@ function userpoints_admin_settings($form '#description' => t('When listing !points by user limit how many users are displayed on a single page', userpoints_translation()), ); + $form[$group]['userpoints_truncate'] = array( + '#type' => 'textfield', + '#title' => t('Truncation length for the "Reason" column in transaction listings'), + '#description' => t('Choose the truncation length in characters for the "Reason" column in transaction listings. The reason is not truncated on the transaction details page.'), + '#default_value' => variable_get('userpoints_truncate', 30), + '#size' => 5, + '#maxlength' => 5, + ); // Categories will only appear if the taxonomy module is enabled as // the module is required for this functionality but not necessarily Index: userpoints.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/userpoints/userpoints.module,v retrieving revision 1.68.2.24 diff -u -p -r1.68.2.24 userpoints.module --- userpoints.module 30 Jan 2011 17:44:26 -0000 1.68.2.24 +++ userpoints.module 30 Jan 2011 20:50:48 -0000 @@ -1313,11 +1313,27 @@ function userpoints_get_info($operation * * description of the transaction. * * name of the operation. * + * @param $transaction + * The transaction object for which the description shall be generated. + * + * @param $options + * Array of options: + * - link: If FALSE, no link is generated to the linked entity even if there + * were one. Defaults to TRUE. + * - truncate: Define if the reason should be truncated. Defaults to TRUE. + * * @return * The reason for that transaction, linked to the referenced * entity if available. */ function userpoints_create_description($transaction, array $options = array()) { + + // Default options. + $options += array( + 'link' => TRUE, + 'truncate' => TRUE, + ); + // Check if there is a valid entity referenced and which can be linked to. $entity = NULL; if ($transaction->entity_type && entity_get_info($transaction->entity_type)) { @@ -1345,11 +1361,21 @@ function userpoints_create_description($ if (empty($description)) { $description = $transaction->operation; } + + // Truncate description. + $attributes = array(); + if ($options['truncate'] && drupal_strlen($description) > variable_get('userpoints_truncate', 30) + 3) { + // The title attribute will be check_plain()'d again drupal_attributes(), + // avoid double escaping. + $attributes['title'] = html_entity_decode($description, ENT_QUOTES); + $description = truncate_utf8(strip_tags($description), variable_get('userpoints_truncate', 30), FALSE, TRUE); + } + // Link to the referenced entity, if available. - if ($entity && (!isset($options['link']) || $options['link'] != FALSE)) { + if ($entity && $options['link']) { $uri = entity_uri($transaction->entity_type, $entity); if ($uri) { - $description = l($description, $uri['path'], $uri['options'] + array('html' => $safe)); + $description = l($description, $uri['path'], $uri['options'] + array('html' => $safe, 'attributes' => $attributes)); } } if ((empty($entity) || empty($uri)) && !$safe) { Index: userpoints.pages.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/userpoints/Attic/userpoints.pages.inc,v retrieving revision 1.1.2.7 diff -u -p -r1.1.2.7 userpoints.pages.inc --- userpoints.pages.inc 19 Nov 2010 00:47:21 -0000 1.1.2.7 +++ userpoints.pages.inc 30 Jan 2011 20:50:48 -0000 @@ -247,7 +247,7 @@ function userpoints_view_transaction($tr $content['details']['reason'] = array( '#theme' => 'userpoints_view_item', '#title' => t('Reason'), - '#value' => userpoints_create_description($transaction), + '#value' => userpoints_create_description($transaction, array('truncate' => FALSE)), '#weight' => 40, '#attributes' => array('class' => array('userpoints-item-reason')), ); @@ -373,7 +373,7 @@ function userpoints_view_transaction($tr $content['admin']['description_generated'] = array( '#theme' => 'userpoints_view_item', '#title' => t('Description (auto generated)'), - '#value' => userpoints_create_description($transaction, array('skip_description' => TRUE)), + '#value' => userpoints_create_description($transaction, array('skip_description' => TRUE, 'truncate' => FALSE)), '#weight' => 20, '#attributes' => array('class' => array('userpoints-item-description-generated')), );