Page MenuHomeIn-Portal Phabricator

serialized_formatter.php
No OneTemporary

File Metadata

Created
Sun, Mar 9, 6:59 PM

serialized_formatter.php

<?php
/**
* @version $Id: serialized_formatter.php 13086 2010-01-12 19:47:40Z alex $
* @package In-Portal
* @copyright Copyright (C) 1997 - 2009 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
class kSerializedFormatter extends kFormatter {
function Parse($value, $field_name, &$object)
{
$options = $object->GetFieldOptions($field_name);
$value = array_merge_recursive2(unserialize($options['default']), $value);
return serialize($value);
}
function Format($value, $field_name, $object, $format=null)
{
$data = unserialize($value);
$format = explode('.', $format);
$format = '\''.implode('\', \'', $format).'\'';
return eval('return getArrayValue($data, '.$format.');');
}
}

Event Timeline