Ejemplo n.º 1
0
function tbxGenericCustomFieldEdit($phase)
{
    switch ($phase) {
        case Phase::PRE_VALIDATE:
            $v = Validator::Create();
            $v->Register(is_writeable(INCLUDES_DIR . '/database.xml'), Validator_Type::IS_TRUE, 'The includes/database.xml file is not writeable; change permissions to 666');
            break;
        case Phase::PRE_UPDATE:
            $validators = array('type' => array(), 'message' => array(), 'extras' => array());
            foreach ($_REQUEST['validator']['type'] as $i => $type) {
                if ($type != Validator_Type::NONE) {
                    $validators['type'][] = $_REQUEST['validator']['type'][$i];
                    $validators['message'][] = $_REQUEST['validator']['message'][$i];
                    $validators['extras'][] = $_REQUEST['validator']['extras'][$i];
                }
            }
            $_REQUEST['validators'] = serialize($validators);
            if ($_REQUEST['type'] == Form_Field::CHECKBOX) {
                $_REQUEST['tag_attributes'] = Form_Field::ParseAttributes($_REQUEST['tag_attributes'], 'value', true);
            }
            break;
        case Phase::POST_UPDATE:
            break;
    }
}