}
priv->id = g_strdup (_id);
- g_hash_table_replace (priv->ht_label_attrs, "for", g_strdup (priv->id));
+
+ if (priv->ht_label_attrs == NULL)
+ {
+ priv->ht_label_attrs = g_hash_table_new (g_str_hash, g_str_equal);
+ }
+ g_hash_table_replace (priv->ht_label_attrs, g_strdup ("for"), g_strdup (priv->id));
g_free (_id);
}
va_start (ap, label);
priv->ht_label_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
- g_hash_table_replace (priv->ht_label_attrs, "zak-cgi-content", g_strdup (label));
- g_hash_table_replace (priv->ht_label_attrs, "for", priv->id != NULL ? g_strdup (priv->id) : g_strdup (""));
- g_hash_table_replace (priv->ht_label_attrs, "class", g_strdup ("control-label"));
+ g_hash_table_replace (priv->ht_label_attrs, g_strdup ("zak-cgi-content"), g_strdup (label));
+ g_hash_table_replace (priv->ht_label_attrs, g_strdup ("for"), priv->id != NULL ? g_strdup (priv->id) : g_strdup (""));
+ g_hash_table_replace (priv->ht_label_attrs, g_strdup ("class"), g_strdup ("control-label"));
if (zak_form_element_get_long_name (ZAK_FORM_ELEMENT (element)) == NULL)
{
if (priv->id == NULL
|| g_strcmp0 (g_strstrip (priv->id), "") == 0)
{
- priv->id = g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT));
+ zak_form_cgi_form_element_set_id (element, g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)));
}
str = g_string_new ("<div class=\"form-group");
priv->ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
}
- name = g_hash_table_lookup (priv->ht_attrs, "name");
- if (name == NULL
- || g_strcmp0 (g_strstrip (name), "") == 0)
+ name = zak_form_element_get_name (ZAK_FORM_ELEMENT (element));
+ if (name != NULL
+ && g_strcmp0 (g_strstrip (name), "") != 0)
{
- if (name != NULL)
- {
- g_free (name);
- }
+ g_hash_table_replace (priv->ht_attrs, g_strdup ("name"), g_strdup (name));
+ }
- name = zak_form_element_get_name (ZAK_FORM_ELEMENT (element));
- if (name != NULL
- && g_strcmp0 (g_strstrip (name), "") != 0)
- {
- g_hash_table_insert (priv->ht_attrs, g_strdup ("name"), g_strdup (name));
- }
- if (name != NULL)
- {
- g_free (name);
- }
+ if (name != NULL)
+ {
+ g_free (name);
}
attr_class = g_hash_table_lookup (priv->ht_attrs, "class");
{
if (g_strstr_len (attr_class, -1, "form-control") == NULL)
{
- g_hash_table_insert (priv->ht_attrs, "class", g_strdup_printf ("%s form-control", attr_class));
- g_free (attr_class);
+ g_hash_table_insert (priv->ht_attrs, g_strdup ("class"), g_strdup_printf ("%s form-control", attr_class));
}
}
else
{
- g_hash_table_insert (priv->ht_attrs, "class", g_strdup ("form-control"));
+ g_hash_table_insert (priv->ht_attrs, g_strdup ("class"), g_strdup ("form-control"));
}
if (!zak_form_element_get_editable (ZAK_FORM_ELEMENT (element)))
{
- g_hash_table_insert (priv->ht_attrs, (gpointer)"readonly", (gpointer)"readonly");
+ g_hash_table_insert (priv->ht_attrs, (gpointer)g_strdup ("readonly"), (gpointer)g_strdup ("readonly"));
}
g_string_append (str, ZAK_FORM_CGI_FORM_ELEMENT_GET_CLASS (element)->render (element));
str = NULL;
- if (priv->ht_label_attrs != NULL)
+ if (priv->ht_label_attrs != NULL
+ && g_hash_table_lookup (priv->ht_label_attrs, "zak-cgi-content") != NULL)
{
str = g_string_new ("");
if (g_strcmp0 (g_hash_table_lookup (priv->ht_label_attrs, "for"), "") == 0)
{
- g_hash_table_replace (priv->ht_label_attrs, "for", g_strdup (priv->id));
+ g_hash_table_replace (priv->ht_label_attrs, g_strdup ("for"), g_strdup (priv->id));
}
lbl_id = g_strdup_printf ("lbl_%s", priv->id);
priv = ZAK_FORM_CGI_FORM_ELEMENT_GET_PRIVATE (element);
- priv->id = g_strdup (id);
+ zak_form_cgi_form_element_set_id (element, id);
priv->ht_attrs = ht_attrs;
if (g_hash_table_lookup (priv->ht_attrs, "name") == NULL)
{
- g_hash_table_insert (priv->ht_attrs, "name", g_strdup (id));
+ g_hash_table_insert (priv->ht_attrs, g_strdup ("name"), g_strdup (id));
}
zak_form_element_set_name (ZAK_FORM_ELEMENT (element), g_hash_table_lookup (priv->ht_attrs, "name"));
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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
ZakFormCgiFormElement
*zak_form_cgi_form_element_check_new ()
{
- ZakFormCgiFormElementCheck *zak_form_cgi_form_element_check;
-
- zak_form_cgi_form_element_check = ZAK_FORM_CGI_FORM_ELEMENT_CHECK (g_object_new (zak_form_cgi_form_element_check_get_type (), NULL));
-
- return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_check);
+ return zak_form_cgi_form_element_check_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
}
/**
ZakFormCgiFormElement *zak_form_cgi_form_element_check;
- zak_form_cgi_form_element_check = zak_form_cgi_form_element_check_new ();
+ zak_form_cgi_form_element_check = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_check_get_type (), NULL));
va_start (ap, id);
ht_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
- g_hash_table_replace (ht_attrs, "type", "checkbox");
+ g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("checkbox"));
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_check_parent_class)->construct (zak_form_cgi_form_element_check,
id,
id = NULL;
ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_replace (ht_attrs, "type", "checkbox");
+ g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("checkbox"));
cur = xmlnode->children;
while (cur != NULL)
ht_attrs = klass->get_ht_attrs (element);
ht_label_attrs = klass->get_ht_label_attrs (element);
- if (ht_label_attrs != NULL)
+ if (ht_label_attrs != NULL
+ && g_hash_table_lookup (ht_label_attrs, "zak-cgi-content") != NULL)
{
str = g_string_new ("<br/>\n");
}
if (value != NULL
&& zak_utils_string_to_boolean (value))
{
- g_hash_table_insert (ht_attrs, (gpointer)"checked", (gpointer)"checked");
+ g_hash_table_insert (ht_attrs, g_strdup ("checked"), g_strdup ("checked"));
}
attr_class = g_hash_table_lookup (ht_attrs, "class");
if (attr_class != NULL)
{
- g_hash_table_insert (ht_attrs, "class", g_strjoinv ("", g_strsplit (attr_class, "form-control", -1)));
+ g_hash_table_insert (ht_attrs, g_strdup ("class"), g_strjoinv ("", g_strsplit (attr_class, "form-control", -1)));
g_free (attr_class);
}
zak_form_cgi_form_element_check_get_text (ZAK_FORM_CGI_FORM_ELEMENT_CHECK (element)),
priv->in_line ? "" : "\n</div><br/>");
- if (ht_label_attrs != NULL)
+ if (ht_label_attrs != NULL
+ && g_hash_table_lookup (ht_label_attrs, "zak-cgi-content") != NULL)
{
g_string_append (str, "<br/><br/>\n");
}
/*
- * Copyright (C) 2016-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2016-2019 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
static gchar *zak_form_cgi_form_element_email_render (ZakFormCgiFormElement *element);
static void zak_form_cgi_form_element_email_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_email_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_email_dispose (GObject *gobject);
static void zak_form_cgi_form_element_email_finalize (GObject *gobject);
ZakFormCgiFormElement
*zak_form_cgi_form_element_email_new ()
{
- ZakFormCgiFormElementEmail *zak_form_cgi_form_element_email;
-
- zak_form_cgi_form_element_email = ZAK_FORM_CGI_FORM_ELEMENT_EMAIL (g_object_new (zak_form_cgi_form_element_email_get_type (), NULL));
-
- return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_email);
+ return zak_form_cgi_form_element_email_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
}
/**
*/
ZakFormCgiFormElement
*zak_form_cgi_form_element_email_new_attrs (const gchar *id,
- ...)
+ ...)
{
va_list ap;
ZakFormCgiFormElement *zak_form_cgi_form_element_email;
- zak_form_cgi_form_element_email = zak_form_cgi_form_element_email_new ();
+ zak_form_cgi_form_element_email = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_email_get_type (), NULL));
va_start (ap, id);
ht_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
- g_hash_table_replace (ht_attrs, "type", "email");
+ g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("email"));
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_email_parent_class)->construct (zak_form_cgi_form_element_email,
- id,
- ht_attrs);
+ id,
+ ht_attrs);
return zak_form_cgi_form_element_email;
}
id = NULL;
ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_replace (ht_attrs, "type", "email");
+ g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("email"));
cur = xmlnode->children;
while (cur != NULL)
}
else
{
- g_hash_table_replace (ht_attrs, g_strdup (cur->name), (gchar *)xmlNodeGetContent (cur));
+ g_hash_table_replace (ht_attrs, g_strdup ((gchar *)cur->name), (gchar *)xmlNodeGetContent (cur));
}
cur = cur->next;
if (id != NULL)
{
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_email_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
- id,
- ht_attrs);
+ id,
+ ht_attrs);
}
}
value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
if (value != NULL)
{
- g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
+ g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("value"), (gpointer)g_strdup (value));
}
ret = zak_cgi_tag_tag_ht ("input", zak_form_cgi_form_element_get_id (element), ht_attrs);
/* PRIVATE */
static void
zak_form_cgi_form_element_email_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
ZakFormCgiFormElementEmail *zak_form_cgi_form_element_email = (ZakFormCgiFormElementEmail *)object;
ZakFormCgiFormElementEmailPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_EMAIL_GET_PRIVATE (zak_form_cgi_form_element_email);
static void
zak_form_cgi_form_element_email_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
ZakFormCgiFormElementEmail *zak_form_cgi_form_element_email = (ZakFormCgiFormElementEmail *)object;
ZakFormCgiFormElementEmailPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_EMAIL_GET_PRIVATE (zak_form_cgi_form_element_email);
/*
- * Copyright (C) 2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2017-2019 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
ZakFormCgiFormElement
*zak_form_cgi_form_element_file_new ()
{
- ZakFormCgiFormElementFile *zak_form_cgi_form_element_file;
-
- zak_form_cgi_form_element_file = ZAK_FORM_CGI_FORM_ELEMENT_FILE (g_object_new (zak_form_cgi_form_element_file_get_type (), NULL));
-
- g_signal_connect (G_OBJECT (zak_form_cgi_form_element_file), "after-validating",
- G_CALLBACK (zak_form_cgi_form_element_file_after_validating), NULL);
-
- return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_file);
+ return zak_form_cgi_form_element_file_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
}
/**
ZakFormCgiFormElement *zak_form_cgi_form_element_file;
- zak_form_cgi_form_element_file = zak_form_cgi_form_element_file_new ();
+ zak_form_cgi_form_element_file = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_file_get_type (), NULL));
+
+ g_signal_connect (G_OBJECT (zak_form_cgi_form_element_file), "after-validating",
+ G_CALLBACK (zak_form_cgi_form_element_file_after_validating), NULL);
va_start (ap, id);
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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
#endif
#include <libzakcgi/libzakcgi.h>
+
#include "formelementhidden.h"
static void zak_form_cgi_form_element_hidden_class_init (ZakFormCgiFormElementHiddenClass *class);
static gchar *zak_form_cgi_form_element_hidden_render (ZakFormCgiFormElement *element);
static void zak_form_cgi_form_element_hidden_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_hidden_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_hidden_dispose (GObject *gobject);
static void zak_form_cgi_form_element_hidden_finalize (GObject *gobject);
ZakFormCgiFormElement
*zak_form_cgi_form_element_hidden_new ()
{
- ZakFormCgiFormElementHidden *zak_form_cgi_form_element_hidden;
-
- zak_form_cgi_form_element_hidden = ZAK_FORM_CGI_FORM_ELEMENT_HIDDEN (g_object_new (zak_form_cgi_form_element_hidden_get_type (), NULL));
-
- return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_hidden);
+ return zak_form_cgi_form_element_hidden_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
}
/**
*/
ZakFormCgiFormElement
*zak_form_cgi_form_element_hidden_new_attrs (const gchar *id,
- ...)
+ ...)
{
va_list ap;
ZakFormCgiFormElement *zak_form_cgi_form_element_hidden;
- zak_form_cgi_form_element_hidden = zak_form_cgi_form_element_hidden_new ();
+ zak_form_cgi_form_element_hidden = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_hidden_get_type (), NULL));
va_start (ap, id);
ht_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
- g_hash_table_replace (ht_attrs, "type", "hidden");
+ g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("hidden"));
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_hidden_parent_class)->construct (zak_form_cgi_form_element_hidden,
- id,
- ht_attrs);
+ id,
+ ht_attrs);
return zak_form_cgi_form_element_hidden;
}
id = NULL;
ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_replace (ht_attrs, "type", "hidden");
+ g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("hidden"));
cur = xmlnode->children;
while (cur != NULL)
}
else
{
- g_hash_table_replace (ht_attrs, g_strdup (cur->name), (gchar *)xmlNodeGetContent (cur));
+ g_hash_table_replace (ht_attrs, g_strdup ((gchar *)cur->name), (gchar *)xmlNodeGetContent (cur));
}
cur = cur->next;
if (id != NULL)
{
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_hidden_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
- id,
- ht_attrs);
+ id,
+ ht_attrs);
}
}
value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
if (value != NULL)
{
- g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
+ g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("value"), (gpointer)g_strdup (value));
}
ret = zak_cgi_tag_tag_ht ("input", zak_form_cgi_form_element_get_id (element), ht_attrs);
/* PRIVATE */
static void
zak_form_cgi_form_element_hidden_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec)
{
ZakFormCgiFormElementHidden *zak_form_cgi_form_element_hidden = (ZakFormCgiFormElementHidden *)object;
ZakFormCgiFormElementHiddenPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_HIDDEN_GET_PRIVATE (zak_form_cgi_form_element_hidden);
static void
zak_form_cgi_form_element_hidden_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec)
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec)
{
ZakFormCgiFormElementHidden *zak_form_cgi_form_element_hidden = (ZakFormCgiFormElementHidden *)object;
ZakFormCgiFormElementHiddenPrivate *priv = ZAK_FORM_CGI_FORM_ELEMENT_HIDDEN_GET_PRIVATE (zak_form_cgi_form_element_hidden);
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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
#endif
#include <libzakcgi/libzakcgi.h>
+
#include "formelementpassword.h"
static void zak_form_cgi_form_element_password_class_init (ZakFormCgiFormElementPasswordClass *class);
static gchar *zak_form_cgi_form_element_password_render (ZakFormCgiFormElement *element);
static void zak_form_cgi_form_element_password_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_password_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_password_dispose (GObject *gobject);
static void zak_form_cgi_form_element_password_finalize (GObject *gobject);
ZakFormCgiFormElement
*zak_form_cgi_form_element_password_new ()
{
- ZakFormCgiFormElementPassword *zak_form_cgi_form_element_password;
-
- zak_form_cgi_form_element_password = ZAK_FORM_CGI_FORM_ELEMENT_PASSWORD (g_object_new (zak_form_cgi_form_element_password_get_type (), NULL));
-
- return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_password);
+ return zak_form_cgi_form_element_password_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
}
/**
*/
ZakFormCgiFormElement
*zak_form_cgi_form_element_password_new_attrs (const gchar *id,
- ...)
+ ...)
{
va_list ap;
ZakFormCgiFormElement *zak_form_cgi_form_element_password;
- zak_form_cgi_form_element_password = zak_form_cgi_form_element_password_new ();
+ zak_form_cgi_form_element_password = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_password_get_type (), NULL));
va_start (ap, id);
ht_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
- g_hash_table_replace (ht_attrs, "type", "password");
+ g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("password"));
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_password_parent_class)->construct (zak_form_cgi_form_element_password,
- id,
- ht_attrs);
+ id,
+ ht_attrs);
return zak_form_cgi_form_element_password;
}
id = NULL;
ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_replace (ht_attrs, "type", "password");
+ g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("password"));
cur = xmlnode->children;
while (cur != NULL)
}
else
{
- g_hash_table_replace (ht_attrs, g_strdup (cur->name), (gchar *)xmlNodeGetContent (cur));
+ g_hash_table_replace (ht_attrs, g_strdup ((gchar *)cur->name), (gchar *)xmlNodeGetContent (cur));
}
cur = cur->next;
if (id != NULL)
{
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_password_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
- id,
- ht_attrs);
+ id,
+ ht_attrs);
}
}
value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
if (value != NULL)
{
- g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
+ g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("value"), (gpointer)g_strdup (value));
}
ret = zak_cgi_tag_tag_ht ("input", zak_form_cgi_form_element_get_id (element), ht_attrs);
/*
- * Copyright (C) 2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2017-2019 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
#include <libzakutils/libzakutils.h>
#include <libzakcgi/libzakcgi.h>
+
#include "formelementradio.h"
static void zak_form_cgi_form_element_radio_class_init (ZakFormCgiFormElementRadioClass *class);
ZakFormCgiFormElement
*zak_form_cgi_form_element_radio_new ()
{
- ZakFormCgiFormElementRadio *zak_form_cgi_form_element_radio;
-
- zak_form_cgi_form_element_radio = ZAK_FORM_CGI_FORM_ELEMENT_RADIO (g_object_new (zak_form_cgi_form_element_radio_get_type (), NULL));
-
- return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_radio);
+ return zak_form_cgi_form_element_radio_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
}
/**
ZakFormCgiFormElement *zak_form_cgi_form_element_radio;
- zak_form_cgi_form_element_radio = zak_form_cgi_form_element_radio_new ();
+ zak_form_cgi_form_element_radio = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_radio_get_type (), NULL));
va_start (ap, id);
ht_attrs = zak_cgi_commons_valist_to_ghashtable (ap);
- g_hash_table_replace (ht_attrs, "type", "radio");
+ g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("radio"));
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_radio_parent_class)->construct (zak_form_cgi_form_element_radio,
id,
id = NULL;
ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
- g_hash_table_replace (ht_attrs, "type", "radio");
+ g_hash_table_replace (ht_attrs, g_strdup ("type"), g_strdup ("radio"));
cur = xmlnode->children;
while (cur != NULL)
attr_class = g_hash_table_lookup (ht_attrs, "class");
if (attr_class != NULL)
{
- g_hash_table_insert (ht_attrs, "class", g_strjoinv ("", g_strsplit (attr_class, "form-control", -1)));
+ g_hash_table_insert (ht_attrs, g_strdup ("class"), g_strjoinv ("", g_strsplit (attr_class, "form-control", -1)));
g_free (attr_class);
}
ht_attrs_option = g_hash_table_new (g_str_hash, g_str_equal);
zak_utils_ghashtable_copy (ht_attrs, ht_attrs_option);
- g_hash_table_insert (ht_attrs_option, (gpointer)"value", (gpointer)g_strdup (opt->value));
+ g_hash_table_insert (ht_attrs_option, (gpointer)g_strdup ("value"), (gpointer)g_strdup (opt->value));
if (element_value != NULL
&& g_strcmp0 (element_value, opt->value) == 0)
{
- g_hash_table_insert (ht_attrs_option, (gpointer)"checked", (gpointer)"checked");
+ g_hash_table_insert (ht_attrs_option, (gpointer)g_strdup ("checked"), (gpointer)g_strdup ("checked"));
}
g_string_append_printf (ret, "\n%s<label%s>\n%s %s</label>%s",
#endif
#include <libzakcgi/libzakcgi.h>
+
#include "formelementselect.h"
static void zak_form_cgi_form_element_select_class_init (ZakFormCgiFormElementSelectClass *class);
ZakFormCgiFormElement
*zak_form_cgi_form_element_select_new ()
{
- ZakFormCgiFormElementSelect *zak_form_cgi_form_element_select;
-
- zak_form_cgi_form_element_select = ZAK_FORM_CGI_FORM_ELEMENT_SELECT (g_object_new (zak_form_cgi_form_element_select_get_type (), NULL));
-
- return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_select);
+ return zak_form_cgi_form_element_select_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
}
/**
ZakFormCgiFormElement *zak_form_cgi_form_element_select;
- zak_form_cgi_form_element_select = zak_form_cgi_form_element_select_new ();
+ zak_form_cgi_form_element_select = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_select_get_type (), NULL));
va_start (ap, id);
{
ht_attrs = g_hash_table_new (g_str_hash, g_str_equal);
}
- g_hash_table_replace (ht_attrs, "zak-cgi-content", g_strdup (content));
- g_hash_table_replace (ht_attrs, "value", g_strdup (value));
+ g_hash_table_replace (ht_attrs, g_strdup ("zak-cgi-content"), g_strdup (content));
+ g_hash_table_replace (ht_attrs, g_strdup ("value"), g_strdup (value));
g_ptr_array_add (priv->ar_options, ht_attrs);
}
{
if (g_strcmp0 (gval, (gchar *)g_hash_table_lookup (ht_options_attrs, "value")) == 0)
{
- g_hash_table_replace (ht_options_attrs, "selected", g_strdup ("selected"));
+ g_hash_table_replace (ht_options_attrs, g_strdup ("selected"), g_strdup ("selected"));
}
}
if (!zak_form_element_get_editable (ZAK_FORM_ELEMENT (element)))
{
- g_hash_table_insert (ht_attrs, (gpointer)"disabled", (gpointer)"disabled");
+ g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("disabled"), (gpointer)g_strdup ("disabled"));
}
- g_hash_table_replace (ht_attrs, "zak-cgi-content", g_strdup (options->str));
+ g_hash_table_replace (ht_attrs, g_strdup ("zak-cgi-content"), g_strdup (options->str));
ret = zak_cgi_tag_tag_ht ("select", zak_form_cgi_form_element_get_id (element), ht_attrs);
g_string_free (options, TRUE);
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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
#endif
#include <libzakcgi/libzakcgi.h>
+
#include "formelementsubmit.h"
static void zak_form_cgi_form_element_submit_class_init (ZakFormCgiFormElementSubmitClass *class);
static gchar *zak_form_cgi_form_element_submit_render (ZakFormCgiFormElement *element);
static void zak_form_cgi_form_element_submit_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_submit_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_submit_dispose (GObject *gobject);
static void zak_form_cgi_form_element_submit_finalize (GObject *gobject);
ZakFormCgiFormElement
*zak_form_cgi_form_element_submit_new ()
{
- ZakFormCgiFormElementSubmit *zak_form_cgi_form_element_submit;
-
- zak_form_cgi_form_element_submit = ZAK_FORM_CGI_FORM_ELEMENT_SUBMIT (g_object_new (zak_form_cgi_form_element_submit_get_type (), NULL));
-
- return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_submit);
+ return zak_form_cgi_form_element_submit_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
}
/**
*/
ZakFormCgiFormElement
*zak_form_cgi_form_element_submit_new_attrs (const gchar *id,
- ...)
+ ...)
{
va_list ap;
ZakFormCgiFormElement *zak_form_cgi_form_element_submit;
- zak_form_cgi_form_element_submit = zak_form_cgi_form_element_submit_new ();
+ zak_form_cgi_form_element_submit = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_submit_get_type (), NULL));
va_start (ap, id);
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_submit_parent_class)->construct (zak_form_cgi_form_element_submit,
- id,
- zak_cgi_commons_valist_to_ghashtable (ap));
+ id,
+ zak_cgi_commons_valist_to_ghashtable (ap));
return zak_form_cgi_form_element_submit;
}
if (id != NULL)
{
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_submit_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
- id,
- ht_attrs);
+ id,
+ ht_attrs);
}
}
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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
#endif
#include <libzakcgi/libzakcgi.h>
+
#include "formelementtext.h"
static void zak_form_cgi_form_element_text_class_init (ZakFormCgiFormElementTextClass *class);
static gchar *zak_form_cgi_form_element_text_render (ZakFormCgiFormElement *element);
static void zak_form_cgi_form_element_text_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_text_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_text_dispose (GObject *gobject);
static void zak_form_cgi_form_element_text_finalize (GObject *gobject);
ZakFormCgiFormElement
*zak_form_cgi_form_element_text_new ()
{
- ZakFormCgiFormElementText *zak_form_cgi_form_element_text;
-
- zak_form_cgi_form_element_text = ZAK_FORM_CGI_FORM_ELEMENT_TEXT (g_object_new (zak_form_cgi_form_element_text_get_type (), NULL));
- return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_text);
+ return zak_form_cgi_form_element_text_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
}
/**
*/
ZakFormCgiFormElement
*zak_form_cgi_form_element_text_new_attrs (const gchar *id,
- ...)
+ ...)
{
va_list ap;
ZakFormCgiFormElement *zak_form_cgi_form_element_text;
- zak_form_cgi_form_element_text = zak_form_cgi_form_element_text_new ();
+ zak_form_cgi_form_element_text = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_text_get_type (), NULL));
va_start (ap, id);
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_text_parent_class)->construct (zak_form_cgi_form_element_text,
- id,
- zak_cgi_commons_valist_to_ghashtable (ap));
+ id,
+ zak_cgi_commons_valist_to_ghashtable (ap));
return zak_form_cgi_form_element_text;
}
if (id != NULL)
{
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_text_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
- id,
- ht_attrs);
+ id,
+ ht_attrs);
}
}
value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
if (value != NULL)
{
- g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
+ g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("value"), (gpointer)g_strdup (value));
}
ret = zak_cgi_tag_text_ht (zak_form_cgi_form_element_get_id (element), ht_attrs);
/*
- * Copyright (C) 2015-2017 Andrea Zagli <azagli@libero.it>
+ * Copyright (C) 2015-2019 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
#endif
#include <libzakcgi/libzakcgi.h>
+
#include "formelementtextarea.h"
static void zak_form_cgi_form_element_text_area_class_init (ZakFormCgiFormElementTextAreaClass *class);
static gchar *zak_form_cgi_form_element_text_area_render (ZakFormCgiFormElement *element);
static void zak_form_cgi_form_element_text_area_set_property (GObject *object,
- guint property_id,
- const GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ const GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_text_area_get_property (GObject *object,
- guint property_id,
- GValue *value,
- GParamSpec *pspec);
+ guint property_id,
+ GValue *value,
+ GParamSpec *pspec);
static void zak_form_cgi_form_element_text_area_dispose (GObject *gobject);
static void zak_form_cgi_form_element_text_area_finalize (GObject *gobject);
ZakFormCgiFormElement
*zak_form_cgi_form_element_text_area_new ()
{
- ZakFormCgiFormElementTextArea *zak_form_cgi_form_element_text_area;
-
- zak_form_cgi_form_element_text_area = ZAK_FORM_CGI_FORM_ELEMENT_TEXT_AREA (g_object_new (zak_form_cgi_form_element_text_area_get_type (), NULL));
-
- return ZAK_FORM_CGI_FORM_ELEMENT (zak_form_cgi_form_element_text_area);
+ return zak_form_cgi_form_element_text_area_new_attrs (g_strdup_printf ("id_%d", g_random_int_range (0, G_MAXINT)), NULL);
}
/**
ZakFormCgiFormElement *zak_form_cgi_form_element_text_area;
- zak_form_cgi_form_element_text_area = zak_form_cgi_form_element_text_area_new ();
+ zak_form_cgi_form_element_text_area = ZAK_FORM_CGI_FORM_ELEMENT (g_object_new (zak_form_cgi_form_element_text_area_get_type (), NULL));
va_start (ap, id);
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_text_area_parent_class)->construct (zak_form_cgi_form_element_text_area,
- id,
- zak_cgi_commons_valist_to_ghashtable (ap));
+ id,
+ zak_cgi_commons_valist_to_ghashtable (ap));
return zak_form_cgi_form_element_text_area;
}
if (id != NULL)
{
ZAK_FORM_CGI_FORM_ELEMENT_CLASS (zak_form_cgi_form_element_text_area_parent_class)->construct (ZAK_FORM_CGI_FORM_ELEMENT (element),
- id,
- ht_attrs);
+ id,
+ ht_attrs);
}
}
value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
if (value != NULL)
{
- g_hash_table_insert (ht_attrs, (gpointer)"zak-cgi-content", (gpointer)g_strdup (value));
+ g_hash_table_insert (ht_attrs, (gpointer)g_strdup ("zak-cgi-content"), (gpointer)g_strdup (value));
}
ret = zak_cgi_tag_tag_ht ("textarea", zak_form_cgi_form_element_get_id (element), ht_attrs);