In function _restricted_text_replace_callback the following code:

  if ($reduced) {
    return $interior;
  }
  else {
    return '';
  }

becomes:

  if ($reduced) {
    $formatted_restricted_text = theme('restricted_text_format', $m['key'], $m['params'], $m['interior']);
    return $formatted_restricted_text;    
  }
  else {
    return '';
  }

plus the following functions:

/**
 * Implementation of hook_theme().
 */
function restricted_text_theme() {
  return array(
    'restricted_text_format' => array(
      'arguments' => array('key' => NULL, 'params' => NULL, 'interior' => NULL),
    ),
  );
}

function theme_restricted_text_format($key, $params, $interior) {
  return $interior;
}

From my own custom module (or template)

function phptemplate_restricted_text_format($key, $params, $interior) {
  return '<div style=background-color:#FFF4C8;><u>'.t('Restricted').': '.$key.'</u><br><i>'.$interior.'</i></div>';
}

You need to clear the cache to see it in effect. See http://drupal.org/node/173880

To clear the theme registry, do one of the following things:

>> On the "Administer > Site configuration > Performance" page, click on the "Clear cached data" button.
>> With devel block enabled (comes with devel module), click the "Empty cache" link.
>> The API function drupal_rebuild_theme_registry.

CommentFileSizeAuthor
#2 restricted_text-1013608.patch2.92 KBudvranto

Comments

udvranto’s picture

Better yet. Let's put the entire formatting logic to the theming function:

/**
 * Implementation of hook_theme().
 */
function restricted_text_theme() {
  return array(
    'restricted_text_format' => array(
      'arguments' => array('allowed' => true, 'key' => NULL, 'params' => NULL, 'interior' => NULL),
    ),
  );
}

function theme_restricted_text_format($allowed, $key, $params, $interior) {
  if($allowed)
    return $interior;
  else
    return '';
}

In function _restricted_text_replace_callback the following code:

  if ($reduced) {
    return $interior;
  }
  else {
    return '';
  }

Becomes:

  $formatted_restricted_text = theme('restricted_text_format', $reduced, $m['key'], $m['params'], $m['interior']);
  return $formatted_restricted_text;    

From my own custom module (or template)

function phptemplate_restricted_text_format($allowed, $key, $params, $interior) {
  if($allowed)
  {
    $param_exist = (count($params)>1?true:false);
    if(count($params) == 1)
      $param_exist = ($params[0]==''?false:true);

    if($param_exist)
      $param_display = implode(',',$params);
    else
      $param_display = $key; 

    $restricted = t('Restricted');    
    return '<div style=background-color:#FFF4C8;><u>'.$restricted.': '.$param_display.'</u><br><i>'.$interior.'</i></div>';
  }
  else
    return '';
}

You need to clear the cache to see it in effect. See http://drupal.org/node/173880

To clear the theme registry, do one of the following things:

>> On the "Administer > Site configuration > Performance" page, click on the "Clear cached data" button.
>> With devel block enabled (comes with devel module), click the "Empty cache" link.
>> The API function drupal_rebuild_theme_registry.

udvranto’s picture

Version: 6.x-1.0 » master
Status: Needs review » Needs work
StatusFileSize
new2.92 KB

Patch

pukku’s picture

Status: Needs work » Closed (won't fix)