58 lines
1.3 KiB
Plaintext
58 lines
1.3 KiB
Plaintext
<?php
|
|
|
|
|
|
/**
|
|
* Implements hook_init().
|
|
*/
|
|
// function materio_user_init() {
|
|
// drupal_add_js(drupal_get_path('module', 'materio_user').'/js/materio_user.min.js');
|
|
// }
|
|
|
|
|
|
/**
|
|
* Implements hook_permission().
|
|
*/
|
|
function materio_display_permission() {
|
|
return array(
|
|
'view full materiau description' => array(
|
|
'title' => t('view full materiau description'),
|
|
'description' => t('view full materiau description'),
|
|
),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* Implements hook_preprocess().
|
|
*/
|
|
function materio_display_preprocess_field(&$vars, $hook) {
|
|
// dsm($vars);
|
|
$element = $vars['element'];
|
|
|
|
if($element['#field_name'] == 'field_description'){
|
|
// dsm($vars);
|
|
if(!user_access('view full materiau description')){
|
|
$value = $element['#items'][0]['value'];
|
|
|
|
switch ($element['#view_mode']) {
|
|
case 'cardbig':
|
|
case 'cardfull':
|
|
$limit = 210;
|
|
break;
|
|
default:
|
|
$limit = 130;
|
|
break;
|
|
}
|
|
$summary = truncate_utf8($value, $limit, TRUE, TRUE);
|
|
|
|
$summary .= '<div class="upgrade"><p>'
|
|
. t("In order to access full description, information about manufacturers and more, you need to upgrade your account.")
|
|
. l(t("Pricing"), 'node/11187')
|
|
. '</p></div>';
|
|
|
|
// dsm($summary);
|
|
$vars['items'][0]['#markup'] = $summary;
|
|
|
|
}
|
|
}
|
|
|
|
} |