diff --git a/plugins/php.inc b/plugins/php.inc index 6c99d96..e685790 100644 --- a/plugins/php.inc +++ b/plugins/php.inc @@ -12,6 +12,13 @@ $plugin = array( 'category' => 'Other', ); +/** + * Implements hook_form(). + * @param unknown $importer + * @param unknown $element_key + * @param unknown $settings + * @return multitype:multitype:string Ambigous The Ambigous + */ function feeds_tamper_php_form($importer, $element_key, $settings) { $form = array(); @@ -19,21 +26,31 @@ function feeds_tamper_php_form($importer, $element_key, $settings) { '#type' => 'textarea', '#title' => t('PHP code'), '#default_value' => isset($settings['php']) ? $settings['php'] : '', - '#description' => t('This code will be executed. Use $field as value of this field. Do not use < ?php and ? >.
For example, use: return substr($field, 0, 10);'), + '#description' => check_plain('This code will be executed. Use $field as value of this field. Do not use < ?php and ? >.
For example, use: return substr($field, 0, 10);'), ); return $form; } +/** + * @param unknown $source + * @param unknown $item_key + * @param unknown $element_key + * @param unknown $field + * @param unknown $settings + */ function feeds_tamper_php_callback($source, $item_key, $element_key, &$field, $settings) { - $field = feeds_tamper_php_value($settings['php'], $field); + $field = feeds_tamper_php_value($settings['php'], $field, $source->items[$item_key]); } -function feeds_tamper_php_value($code, $field) { - ob_start(); +/** + * @param unknown $code + * @param unknown $field + * @param unknown $item + * @return unknown + */ +function feeds_tamper_php_value($code, $field, $item) { + ob_start(); $code = eval($code); - ob_end_clean(); + ob_end_clean(); return $code; -} - - - +} \ No newline at end of file