--- mod_archive_webview.erl 2009-09-23 18:30:00.000000000 +0400 +++ mod_archive_webview.erl.my 2009-09-24 18:33:34.000000000 +0400 @@ -29,6 +29,29 @@ [calendar:local_time(), ?MODULE, ?LINE] ++ Args)). +xic([XX|T]) -> + if XX < 0 -> false; + XX > 255 -> false; + true -> xic(T) + end; +xic([]) -> + true. + +xis(XY) -> + case is_list(XY) of + false -> false; + true -> xic(XY) + end. + +xstoi(S) -> + case xis(S) of + true -> + {I, _} = string:to_integer(S); + false -> + I = S + end, + I. + %%%---------------------------------------------------------------------- %%% REQUEST HANDLERS %%%---------------------------------------------------------------------- @@ -102,7 +125,7 @@ make_xhtml(?T("Chat with ") ++ Jid, contact_config(Jid,US,Lang) ++ [?XE("ul", lists:map( fun({Id, Node, Server, Resource, Utc, Subject }) -> With = jlib:jid_to_string({Node,Server,Resource}), - ?LI([?AC(?LINK("show/" ++ integer_to_list(Id)), "On " ++ Utc ++ " with " ++ With ++ " -> " ++ escape_str(Subject) )] ) end, + ?LI([?AC(?LINK("show/" ++ integer_to_list(xstoi(Id))), "On " ++ Utc ++ " with " ++ With ++ " -> " ++ escape_str(Subject) )] ) end, get_collection_list(jlib:string_to_jid(Jid), US))) ], Lang); @@ -207,7 +230,7 @@ %------------------------ format_message({ Utc, Dir, Body } ,{WithU,WithS,WithR}, {LUser,LServer} ) -> - {From, Class} = case Dir of + {From, Class} = case xstoi(Dir) of 0 -> { jlib:jid_to_string({WithU,WithS,WithR}) , "message_from" } ; 1 -> { jlib:jid_to_string({LUser,LServer,""}) , "message_to" } end, @@ -411,7 +434,7 @@ format_search_result( {Id,Subject,User,Server,Resource,Utc,Body} ,_Lang) -> ?XAE("p",[{"class","search_result"}], - [?AC(?LINK("show/" ++ integer_to_list(Id)), jlib:jid_to_string({User,Server,Resource}) ++ " : " ++ escape_str(Subject)), + [?AC(?LINK("show/" ++ integer_to_list(xstoi(Id))), jlib:jid_to_string({User,Server,Resource}) ++ " : " ++ escape_str(Subject)), ?C(Body), ?XE("em",[?C(Utc)]) ] ). links_previous_next({PrevId,NextId},Lang) -> @@ -420,9 +443,9 @@ links_previous_next_aux("link_next", ?T("Next"), NextId))]. links_previous_next_aux(Class, Text, Id) -> - case Id of + case xstoi(Id) of -1 -> []; - _ -> [?XAE("a",[{"href",?LINK("show/" ++ integer_to_list(Id))},{"class",Class}], [?C(Text)])] + _ -> [?XAE("a",[{"href",?LINK("show/" ++ integer_to_list(xstoi(Id)))},{"class",Class}], [?C(Text)])] end. %------------------------