Projet

Général

Profil

Paste
Télécharger (895 octets) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / feeds_tamper / plugins / sprintf.inc @ d808fa20

1
<?php
2

    
3
/**
4
 * @file
5
 * Format a string with printf format.
6
 */
7

    
8
$plugin = array(
9
  'form' => 'feeds_tamper_sprintf_form',
10
  'callback' => 'feeds_tamper_sprintf_callback',
11
  'name' => 'Format string',
12
  'multi' => 'loop',
13
  'category' => 'Text',
14
);
15

    
16
function feeds_tamper_sprintf_form($importer, $element_key, $settings) {
17
  $form = array();
18
  $form['format'] = array(
19
    '#type' => 'textfield',
20
    '#title' => t('Format'),
21
    '#default_value' => isset($settings['format']) ? $settings['format'] : '%s',
22
    '#size' => 60,
23
    '#maxlength' => 128,
24
    '#required' => FALSE,
25
    '#description' => t('See the <a href="http://www.php.net/manual/en/function.sprintf.php">sprintf</a> documentation for more details.'),
26
  );
27
  return $form;
28
}
29

    
30
function feeds_tamper_sprintf_callback($result, $item_key, $element_key, &$field, $settings, $source) {
31
  $field = sprintf($settings['format'], $field);
32
}