dd2f1d | 1999-11-17 | Per Hedbor | | #include <config.h>
#include <roxen.h>
|
cf2dec | 2000-07-11 | Martin Nilsson | |
|
23414a | 2000-07-21 | Andreas Lange | |
#define LOCALE(X,Y) _STR_LOCALE("roxen_config",X,Y)
#define CALL(X,Y) _LOCALE_FUN("roxen_config",X,Y)
|
cf2dec | 2000-07-11 | Martin Nilsson | |
|
dd2f1d | 1999-11-17 | Per Hedbor | | int __lt;
string describe_time(int t)
{
int full;
if(localtime(__lt)->yday != localtime(t)->yday)
{
__lt = t;
full=1;
}
if(full)
|
b9a702 | 2000-07-15 | Andreas Lange | | return capitalize(roxen->language(roxen.locale->get(),"date")(t));
|
dd2f1d | 1999-11-17 | Per Hedbor | | else
return sprintf("%02d:%02d",localtime(t)->hour,localtime(t)->min);
}
|
3e3bab | 2001-01-19 | Per Hedbor | | string _units(string unit, int num)
{
|
715d3c | 2000-07-11 | Martin Nilsson | | if(num==1) return "one "+unit;
return num+" "+unit+"s";
}
|
dd2f1d | 1999-11-17 | Per Hedbor | | string describe_interval(int i)
{
|
715d3c | 2000-07-11 | Martin Nilsson | | switch(i) {
case 0..50:
|
1c783c | 2000-07-15 | Andreas Lange | | return CALL("units", _units)("second", i);
|
715d3c | 2000-07-11 | Martin Nilsson | | case 51..3560:
|
1c783c | 2000-07-15 | Andreas Lange | | return CALL("units", _units)("minute", ((i+20)/60));
|
715d3c | 2000-07-11 | Martin Nilsson | | default:
|
1c783c | 2000-07-15 | Andreas Lange | | return CALL("units", _units)("hour", ((i+300)/3600));
|
dd2f1d | 1999-11-17 | Per Hedbor | | }
}
string describe_times(array (int) times)
{
__lt=0;
if(sizeof(times) < 6)
|
3e3bab | 2001-01-19 | Per Hedbor | | return String.implode_nicely(map(times, describe_time),
LOCALE("cw", "and"));
|
dd2f1d | 1999-11-17 | Per Hedbor | |
int d, every=1;
int ot = times[0];
foreach(times[1..], int t)
if(d)
{
if(abs(t-ot-d)>(d/4))
{
every=0;
break;
}
ot=t;
} else
d = t-ot;
if(every && (times[-1]+d) >= time(1)-10)
|
23414a | 2000-07-21 | Andreas Lange | | return (LOCALE(207, "every") +" "
+describe_interval(d)+" "+LOCALE(208, "since")+" "+
|
dd2f1d | 1999-11-17 | Per Hedbor | | describe_time(times[0]));
return String.implode_nicely(map(times[..4], describe_time)+({"..."})+
map(times[sizeof(times)-3..], describe_time),
|
ea0a98 | 2000-07-17 | Andreas Lange | | LOCALE("cw", "and"));
|
dd2f1d | 1999-11-17 | Per Hedbor | | }
string fix_err(string s)
{
sscanf(reverse(s), "%*[ \t\n]%s", s);
s=reverse(s);
if(s=="")
return s;
if(!(<'.','!','?'>)[s[-1]]) s+=".";
|
715d3c | 2000-07-11 | Martin Nilsson | | return Roxen.html_encode_string(capitalize(s));
|
dd2f1d | 1999-11-17 | Per Hedbor | | }
int last_time;
|
c60cae | 2000-02-02 | Johan Sundström | | string describe_error(string err, array (int) times,
string lang, int|void no_links)
|
dd2f1d | 1999-11-17 | Per Hedbor | | {
int code, nt;
|
c60cae | 2000-02-02 | Johan Sundström | | string links = "", reference, server;
|
23414a | 2000-07-21 | Andreas Lange | | array(string) codetext=({ LOCALE(209, "Notice"),
LOCALE(210, "Warning"),
LOCALE(211, "Error") });
|
c60cae | 2000-02-02 | Johan Sundström | |
|
dd2f1d | 1999-11-17 | Per Hedbor | | if(sizeof(times)==1 && times[0]/60==last_time) nt=1;
last_time=times[0]/60;
|
c60cae | 2000-02-02 | Johan Sundström | | sscanf(err, "%d,%[^,],%s", code, reference, err);
switch(no_links)
{
Configuration conf;
RoxenModule module;
case 2:
sscanf(reference, "%[^/]", server);
if(conf = roxen->find_configuration( server ))
links += sprintf("<a href=\"%s\">%s</a> : ",
@get_conf_url_to_virtual_server( conf, lang ));
case 1:
|
715d3c | 2000-07-11 | Martin Nilsson | | if(module = Roxen.get_module( reference ))
|
c60cae | 2000-02-02 | Johan Sundström | | links += sprintf("<a href=\"%s\">%s</a> : ",
@get_conf_url_to_module( module, lang ));
}
|
0420e3 | 2014-12-02 | Jonas Walldén | | return "<table class='logitems'><tr><td><img src=&usr.err-"+code+"; \n"
|
2bf336 | 2000-02-16 | Martin Nilsson | | "alt=\"" + codetext[code-1] + "\" />"
"</td><td>" + links + (nt?"":describe_times(times)+"<br />") +
replace(fix_err(err), "\n", "<br />\n") + "</table>";
|
c60cae | 2000-02-02 | Johan Sundström | | }
|
3e3bab | 2001-01-19 | Per Hedbor | | array(string) get_conf_url_to_module(string|RoxenModule m, string|void lang)
{
|
c60cae | 2000-02-02 | Johan Sundström | |
|
715d3c | 2000-07-11 | Martin Nilsson | | RoxenModule module = stringp(m) ? Roxen.get_module(m) : m;
|
c60cae | 2000-02-02 | Johan Sundström | | Configuration conf = module->my_configuration();
string url_modname = replace(conf->otomod[module], "#", "!"),
url_confname = conf->name;
|
9d477e | 2001-05-16 | Per Hedbor | | return ({ sprintf("/sites/site.html/%s/-!-/%s/?section=Information",
|
f49131 | 2004-10-11 | Martin Stjernholm | | Roxen.http_encode_url(url_confname),
Roxen.http_encode_url(url_modname)),
|
e15a7c | 2011-08-01 | Henrik Grubbström (Grubba) | | Roxen.html_encode_string(Roxen.get_modfullname(module)) });
|
c60cae | 2000-02-02 | Johan Sundström | | }
|
3e3bab | 2001-01-19 | Per Hedbor | | array(string) get_conf_url_to_virtual_server(string|Configuration conf,
|
51bfad | 2000-04-04 | Johan Sundström | | string|void lang)
|
3e3bab | 2001-01-19 | Per Hedbor | | {
|
c60cae | 2000-02-02 | Johan Sundström | | string url_confname;
if(stringp(conf))
conf = roxen->find_configuration(url_confname = conf);
else
url_confname = conf->name;
|
9d477e | 2001-05-16 | Per Hedbor | | return ({ sprintf("/sites/site.html/%s/",
|
e15a7c | 2011-08-01 | Henrik Grubbström (Grubba) | | Roxen.http_encode_url(url_confname)),
Roxen.html_encode_string(conf->query_name()) });
|
dd2f1d | 1999-11-17 | Per Hedbor | | }
|
9d477e | 2001-05-16 | Per Hedbor | |
|