| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- /*
- * Copyright (C) 2000,2001 Florian Sander
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * of the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- */
- static void template_add_subcontent(struct template_content *content,
- struct llist_2string *params,
- char *included_text)
- {
- Assert(!content->subcontent);
- if (included_text)
- content->subcontent = templates_content_parse(included_text);
- }
- /* template_send_module_version():
- * sends the module version (surprise!)
- */
- static void template_send_module_version(int idx, struct template_content *tpc)
- {
- dprintf(idx, "%s", MODULE_VERSION);
- }
- /* <?slang #?>
- * outputs a line from the slangfile
- */
- static void template_send_slang(int idx, struct template_content *tpc)
- {
- dprintf(idx, "%s", getslang(tpc->intpar1));
- }
- static void template_add_cmd_slang(struct template_content *content,
- struct llist_2string *params,
- char *included_text)
- {
- for (; params; params = params->next)
- if (!strcasecmp(params->s1, "id"))
- content->intpar1 = atoi(params->s2);
- }
- static void template_add_cmd_template(struct template_content *content,
- struct llist_2string *params,
- char *included_text)
- {
- for (; params; params = params->next) {
- if (!strcasecmp(params->s1, "name")) {
- content->charpar1 = nmalloc(strlen(params->s2) + 1);
- strcpy(content->charpar1, params->s2);
- return;
- }
- }
- putlog(LOG_MISC, "*", "ERROR: missing parameter for template tag!");
- }
- static void template_send_template(int idx, struct template_content *tpc)
- {
- if (tpc->charpar1)
- template_send(glob_skin, tpc->charpar1, idx);
- }
- static void template_send_form_method(int idx, struct template_content *tpc)
- {
- if (get_param_value(idx, "dontpost"))
- dprintf(idx, "GET");
- else
- dprintf(idx, "POST");
- }
- static void template_send_if_dontpost(int idx, struct template_content *tpc)
- {
- if (get_param_value(idx, "dontpost"))
- templates_content_send(tpc->subcontent, idx);
- }
- static void template_send_botnick(int idx, struct template_content *tpc)
- {
- dprintf(idx, "%s", botname);
- }
- struct template_commands templates_standard_commands[] =
- {
- {"module_version", template_send_module_version, NULL},
- {"slang", template_send_slang, template_add_cmd_slang},
- {"template", template_send_template, template_add_cmd_template},
- {"form_method", template_send_form_method, NULL},
- {"if_dontpost", template_send_if_dontpost, template_add_subcontent},
- {"botnick", template_send_botnick, NULL},
- {0, 0, 0},
- };
|