/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2020 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
priv->enabled = enabled;
}
+/**
+ * zak_form_validator_get_xml
+ * @validator:
+ * @version: not used.
+ *
+ * Returns: the xml for the filter.
+ */
+xmlNode
+*zak_form_validator_get_xml (ZakFormValidator *validator, const gchar *version)
+{
+ xmlNode *xnode;
+
+ xnode = xmlNewNode (NULL, (xmlChar *)"validator");
+
+ if (zak_form_validator_get_id (validator) != NULL
+ && g_strcmp0 (zak_form_validator_get_id (validator), "") != 0)
+ {
+ xmlSetProp (xnode, (const xmlChar *)"id", (xmlChar *)zak_form_validator_get_id (validator));
+ }
+
+ if (!zak_form_validator_get_enabled (validator))
+ {
+ xmlSetProp (xnode, (const xmlChar *)"disabled", (xmlChar *)"disabled");
+ }
+
+ if (zak_form_validator_get_message (validator) != NULL
+ && g_strcmp0 (zak_form_validator_get_id (validator), "") != 0
+ && g_strcmp0 (zak_form_validator_get_id (validator), _("Invalid value")) != 0)
+ {
+ xmlSetProp (xnode, (const xmlChar *)"id", (xmlChar *)zak_form_validator_get_id (validator));
+ }
+
+ if (ZAK_FORM_VALIDATOR_GET_CLASS (validator)->get_xml!= NULL)
+ {
+ ZAK_FORM_VALIDATOR_GET_CLASS (validator)->get_xml (validator, version, xnode);
+ }
+
+ return xnode;
+}
+
/* PRIVATE */
static void
zak_form_validator_set_property (GObject *object,
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2020 Andrea Zagli <azagli@libero.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
gboolean (*xml_parsing) (ZakFormValidator *self, xmlNode *xnode, gpointer zakform);
gboolean (*validate) (ZakFormValidator *self);
+
+ void (*get_xml) (ZakFormValidator *self, const gchar *version, xmlNode *xnode);
};
gboolean zak_form_validator_xml_parsing (ZakFormValidator *validator, xmlNode *xnode, gpointer zakform);
gboolean zak_form_validator_get_enabled (ZakFormValidator *validator);
void zak_form_validator_set_enabled (ZakFormValidator *validator, gboolean enabled);
+xmlNode *zak_form_validator_get_xml (ZakFormValidator *validator, const gchar *version);
+
+
G_END_DECLS
static gboolean zak_form_validator_compare_xml_parsing (ZakFormValidator *validator, xmlNode *xnode, gpointer form);
static gboolean zak_form_validator_compare_validate (ZakFormValidator *validator_notempty);
+static void zak_form_validator_compare_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode);
struct _ZakFormValidatorCompare
{
parent_class->xml_parsing = zak_form_validator_compare_xml_parsing;
parent_class->validate = zak_form_validator_compare_validate;
+ parent_class->get_xml = zak_form_validator_compare_get_xml;
g_type_class_add_private (object_class, sizeof (ZakFormValidatorComparePrivate));
}
return ret;
}
+
+static void
+zak_form_validator_compare_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode)
+{
+ ZakFormValidatorCompare *validator_compare = ZAK_FORM_VALIDATOR_COMPARE (validator);
+ ZakFormValidatorComparePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_GET_PRIVATE (validator_compare);
+
+ xmlSetProp (xnode, (const xmlChar *)"type", (const xmlChar *)"zak_form_validator_compare");
+
+ xmlSetProp (xnode, (const xmlChar *)"type_comp", (const xmlChar *)zak_form_validator_compare_get_compare_type (validator_compare));
+
+ xmlSetProp (xnode, (const xmlChar *)"element1", (const xmlChar *)zak_form_validator_compare_get_element1 (validator_compare));
+
+ xmlSetProp (xnode, (const xmlChar *)"element2", (const xmlChar *)zak_form_validator_compare_get_element2 (validator_compare));
+}
static gboolean zak_form_validator_compare_date_xml_parsing (ZakFormValidator *validator, xmlNode *xnode, gpointer form);
static gboolean zak_form_validator_compare_date_validate (ZakFormValidator *validator_notempty);
+static void zak_form_validator_compare_date_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode);
struct _ZakFormValidatorCompareDate
{
parent_class->xml_parsing = zak_form_validator_compare_date_xml_parsing;
parent_class->validate = zak_form_validator_compare_date_validate;
+ parent_class->get_xml = zak_form_validator_compare_date_get_xml;
g_type_class_add_private (object_class, sizeof (ZakFormValidatorCompareDatePrivate));
}
return ret;
}
+
+static void
+zak_form_validator_compare_date_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode)
+{
+ ZakFormValidatorCompareDate *validator_compare_date = ZAK_FORM_VALIDATOR_COMPARE_DATE (validator_compare_date);
+ ZakFormValidatorCompareDatePrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_DATE_GET_PRIVATE (validator_compare_date);
+
+ xmlSetProp (xnode, (const xmlChar *)"type", (const xmlChar *)"zak_form_validator_compare_date");
+
+ xmlSetProp (xnode, (const xmlChar *)"type_comp", (const xmlChar *)zak_form_validator_compare_date_get_compare_type (validator_compare_date));
+
+ xmlSetProp (xnode, (const xmlChar *)"element1", (const xmlChar *)zak_form_validator_compare_date_get_element1 (validator_compare_date));
+
+ xmlSetProp (xnode, (const xmlChar *)"format1", (const xmlChar *)zak_form_validator_compare_date_get_element1_format (validator_compare_date));
+
+ xmlSetProp (xnode, (const xmlChar *)"element2", (const xmlChar *)zak_form_validator_compare_date_get_element2 (validator_compare_date));
+
+ xmlSetProp (xnode, (const xmlChar *)"format2", (const xmlChar *)zak_form_validator_compare_date_get_element2_format (validator_compare_date));
+}
static gboolean zak_form_validator_compare_number_xml_parsing (ZakFormValidator *validator, xmlNode *xnode, gpointer form);
static gboolean zak_form_validator_compare_number_validate (ZakFormValidator *validator_notempty);
+static void zak_form_validator_compare_number_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode);
struct _ZakFormValidatorCompareNumber
{
parent_class->xml_parsing = zak_form_validator_compare_number_xml_parsing;
parent_class->validate = zak_form_validator_compare_number_validate;
+ parent_class->get_xml = zak_form_validator_compare_number_get_xml;
g_type_class_add_private (object_class, sizeof (ZakFormValidatorCompareNumberPrivate));
}
return ret;
}
+
+static void
+zak_form_validator_compare_number_get_xml (ZakFormValidator *validator, const gchar *version, xmlNode *xnode)
+{
+ ZakFormValidatorCompareNumber *validator_compare_number = ZAK_FORM_VALIDATOR_COMPARE_NUMBER (validator_compare_number);
+ ZakFormValidatorCompareNumberPrivate *priv = ZAK_FORM_VALIDATOR_COMPARE_NUMBER_GET_PRIVATE (validator_compare_number);
+
+ xmlSetProp (xnode, (const xmlChar *)"type", (const xmlChar *)"zak_form_validator_compare_number");
+
+ xmlSetProp (xnode, (const xmlChar *)"type_comp", (const xmlChar *)zak_form_validator_compare_number_get_compare_type (validator_compare_number));
+
+ xmlSetProp (xnode, (const xmlChar *)"element1", (const xmlChar *)zak_form_validator_compare_number_get_element1 (validator_compare_number));
+
+ xmlSetProp (xnode, (const xmlChar *)"element2", (const xmlChar *)zak_form_validator_compare_number_get_element2 (validator_compare_number));
+}