2007-08-23 02:51:54 +02:00
|
|
|
%%%----------------------------------------------------------------------
|
2007-12-24 14:57:53 +01:00
|
|
|
%%%
|
2013-01-24 15:25:13 +01:00
|
|
|
%%% ejabberd, Copyright (C) 2002-2013 ProcessOne
|
2007-12-24 14:57:53 +01:00
|
|
|
%%%
|
|
|
|
%%% 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.
|
2009-01-12 15:44:42 +01:00
|
|
|
%%%
|
2007-12-24 14:57:53 +01:00
|
|
|
%%% 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
|
|
|
|
%%%
|
2007-08-23 02:51:54 +02:00
|
|
|
%%%----------------------------------------------------------------------
|
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-define(X(Name),
|
|
|
|
#xmlel{name = Name, attrs = [], children = []}).
|
|
|
|
|
|
|
|
-define(XA(Name, Attrs),
|
|
|
|
#xmlel{name = Name, attrs = Attrs, children = []}).
|
|
|
|
|
|
|
|
-define(XE(Name, Els),
|
|
|
|
#xmlel{name = Name, attrs = [], children = Els}).
|
|
|
|
|
|
|
|
-define(XAE(Name, Attrs, Els),
|
|
|
|
#xmlel{name = Name, attrs = Attrs, children = Els}).
|
|
|
|
|
2007-08-23 02:51:54 +02:00
|
|
|
-define(C(Text), {xmlcdata, Text}).
|
2013-03-14 10:33:02 +01:00
|
|
|
|
2007-08-23 02:51:54 +02:00
|
|
|
-define(XC(Name, Text), ?XE(Name, [?C(Text)])).
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-define(XAC(Name, Attrs, Text),
|
|
|
|
?XAE(Name, Attrs, [?C(Text)])).
|
2007-08-23 02:51:54 +02:00
|
|
|
|
|
|
|
-define(T(Text), translate:translate(Lang, Text)).
|
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-define(CT(Text), ?C((?T(Text)))).
|
|
|
|
|
|
|
|
-define(XCT(Name, Text), ?XC(Name, (?T(Text)))).
|
|
|
|
|
|
|
|
-define(XACT(Name, Attrs, Text),
|
|
|
|
?XAC(Name, Attrs, (?T(Text)))).
|
|
|
|
|
|
|
|
-define(LI(Els), ?XE(<<"li">>, Els)).
|
|
|
|
|
|
|
|
-define(A(URL, Els),
|
|
|
|
?XAE(<<"a">>, [{<<"href">>, URL}], Els)).
|
|
|
|
|
2007-08-23 02:51:54 +02:00
|
|
|
-define(AC(URL, Text), ?A(URL, [?C(Text)])).
|
2013-03-14 10:33:02 +01:00
|
|
|
|
|
|
|
-define(ACT(URL, Text), ?AC(URL, (?T(Text)))).
|
|
|
|
|
|
|
|
-define(P, ?X(<<"p">>)).
|
|
|
|
|
|
|
|
-define(BR, ?X(<<"br">>)).
|
|
|
|
|
2007-08-23 02:51:54 +02:00
|
|
|
-define(INPUT(Type, Name, Value),
|
2013-03-14 10:33:02 +01:00
|
|
|
?XA(<<"input">>,
|
|
|
|
[{<<"type">>, Type}, {<<"name">>, Name},
|
|
|
|
{<<"value">>, Value}])).
|
|
|
|
|
|
|
|
-define(INPUTT(Type, Name, Value),
|
|
|
|
?INPUT(Type, Name, (?T(Value)))).
|
|
|
|
|
2007-08-23 02:51:54 +02:00
|
|
|
-define(INPUTS(Type, Name, Value, Size),
|
2013-03-14 10:33:02 +01:00
|
|
|
?XA(<<"input">>,
|
|
|
|
[{<<"type">>, Type}, {<<"name">>, Name},
|
|
|
|
{<<"value">>, Value}, {<<"size">>, Size}])).
|
|
|
|
|
|
|
|
-define(INPUTST(Type, Name, Value, Size),
|
|
|
|
?INPUT(Type, Name, (?T(Value)), Size)).
|
|
|
|
|
|
|
|
-define(ACLINPUT(Text),
|
|
|
|
?XE(<<"td">>,
|
|
|
|
[?INPUT(<<"text">>, <<"value", ID/binary>>, Text)])).
|
2009-01-07 01:55:02 +01:00
|
|
|
|
2009-01-12 22:48:34 +01:00
|
|
|
-define(TEXTAREA(Name, Rows, Cols, Value),
|
2013-03-14 10:33:02 +01:00
|
|
|
?XAC(<<"textarea">>,
|
|
|
|
[{<<"name">>, Name}, {<<"rows">>, Rows},
|
|
|
|
{<<"cols">>, Cols}],
|
2009-01-12 22:48:34 +01:00
|
|
|
Value)).
|
|
|
|
|
|
|
|
%% Build an xmlelement for result
|
2013-03-14 10:33:02 +01:00
|
|
|
-define(XRES(Text),
|
|
|
|
?XAC(<<"p">>, [{<<"class">>, <<"result">>}], Text)).
|
2009-01-12 22:48:34 +01:00
|
|
|
|
2009-01-07 01:55:02 +01:00
|
|
|
%% Guide Link
|
2013-03-14 10:33:02 +01:00
|
|
|
-define(XREST(Text), ?XRES((?T(Text)))).
|
2009-01-07 01:55:02 +01:00
|
|
|
|
2013-03-14 10:33:02 +01:00
|
|
|
-define(GL(Ref, Title),
|
|
|
|
?XAE(<<"div">>, [{<<"class">>, <<"guidelink">>}],
|
|
|
|
[?XAE(<<"a">>,
|
|
|
|
[{<<"href">>, <<"/admin/doc/guide.html#", Ref/binary>>},
|
|
|
|
{<<"target">>, <<"_blank">>}],
|
|
|
|
[?C(<<"[Guide: ", Title/binary, "]">>)])])).
|
2009-01-07 01:55:02 +01:00
|
|
|
|
|
|
|
%% h1 with a Guide Link
|
2013-03-14 10:33:02 +01:00
|
|
|
-define(H1GL(Name, Ref, Title),
|
|
|
|
[?XC(<<"h1">>, Name), ?GL(Ref, Title)]).
|