/FF2EE2

FieldFrame-to-EE2 Data Converter

Primary LanguagePHP

FF2EE2

FieldFrame-to-EE2 Data Converter

This class was made to be imported by an EE2 fieldtype within its install() function, to aid in converting its prior FieldFrame-based data over to the way EE2 expects.

TODO: Provide a second callback for converting array-based entry data which EE2’s field API does not support

Usage

If no changes will need to be made to your class name or individual field settings, you can simply run and return:

function install()
{
    if (! class_exists('FF2EE2')) require 'ff2ee2.php';
 
    $converter = new FF2EE2('class');
    return $converter->global_settings;
}

If your new class name differs from your old one, pass an array in the first parameter:

    $converter = new FF2EE2(array('old_class', 'new_class'));

If you need to make changes to individual field settings, pass a callback function in the second parameter:

    $converter = new FF2EE2('class', array(&$this, 'update_field_settings'));

The callback function you pass should accept two parameters, $field_settings and $field, and should return $field_settings

function update_field_settings($field_settings, $field)
{
    if (isset($field_settings['weblogs']))
    {
        $field_settings['channels'] = $field_settings['weblogs'];
        unset($field_settings['weblogs']);
    }
 
    return $field_settings;
}