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