ed12fd | 2000-02-08 | Henrik Grubbström (Grubba) | | |
0917d3 | 2013-03-04 | Anders Johansson | | * $Id$
|
ed12fd | 2000-02-08 | Henrik Grubbström (Grubba) | | */
|
23414a | 2000-07-21 | Andreas Lange | | #include <roxen.h>
|
bebbad | 2000-08-16 | Andreas Lange | |
#define LOCALE(X,Y) _STR_LOCALE("admin_tasks",X,Y)
|
23414a | 2000-07-21 | Andreas Lange | |
|
48ad1f | 2000-09-19 | Per Hedbor | | constant action = "status";
|
bebbad | 2000-08-16 | Andreas Lange | |
string name= LOCALE(10, "List fonts");
string doc = LOCALE(11, "List all available fonts");
|
09348f | 2000-02-04 | Per Hedbor | |
|
23414a | 2000-07-21 | Andreas Lange | |
|
89b41a | 2000-02-04 | Per Hedbor | | string versions(string font)
{
array res=({ });
array b = available_font_versions(font,32);
|
fc8ffc | 2017-05-23 | Pontus Östlund | | if (!b || !sizeof(b))
return "<b>"+LOCALE("dH","Not available.")+"</b>";
|
09348f | 2000-02-04 | Per Hedbor | | array a = map(b,describe_font_type);
|
89b41a | 2000-02-04 | Per Hedbor | | mapping m = mkmapping(b,a);
foreach(sort(indices(m)), string t)
|
fc8ffc | 2017-05-23 | Pontus Östlund | | res += ({ m[t] });
|
89b41a | 2000-02-04 | Per Hedbor | | return String.implode_nicely(res);
}
|
261716 | 2001-02-05 | Per Hedbor | |
|
1e6b54 | 2000-09-04 | Per Hedbor | | mapping info;
|
89b41a | 2000-02-04 | Per Hedbor | | string list_font(string font)
{
|
1e6b54 | 2000-09-04 | Per Hedbor | | string fn = replace(lower_case( font ), " ", "_" );
|
fc8ffc | 2017-05-23 | Pontus Östlund | |
string tmpl = #"
{{ #name }}
<h3 class='section{{^do_info}} no-margin-bottom{{/do_info}}'>{{ name }}
<small>– {{ versions }}</small></h3>
{{ /name }}
{{ #do_info }}
<table class='auto indent extra'>
{{ #info }}
<tr>
<th>{{ key }}:</th>
<td>{{ value }}
</tr>
{{ /info }}
</table>
{{ /do_info }}";
mapping data = ([
"name" : map(replace(font,"_"," ")/" ", capitalize)*" ",
"versions" : versions(font),
"info" : ({})
]);
if (mapping m = info[fn]) {
data->do_info = true;
foreach( sort( indices( m ) - ({"name","versions"}) ), string i ) {
if (intp(m[i]) || (stringp(m[i]) && sizeof(m[i]))) {
data->info += ({ ([ "key" : i, "value" : (string)m[i] ]) });
}
}
|
1e6b54 | 2000-09-04 | Per Hedbor | | }
|
fc8ffc | 2017-05-23 | Pontus Östlund | |
Mustache m = Mustache();
string res = m->render(tmpl, data);
destruct(m);
return res;
|
89b41a | 2000-02-04 | Per Hedbor | | }
|
8c3d91 | 2000-09-04 | Per Hedbor | | string font_loaders( )
{
|
fc8ffc | 2017-05-23 | Pontus Östlund | | string res ="";
|
261716 | 2001-02-05 | Per Hedbor | | foreach( roxen.fonts.font_handlers, FontHandler fl )
|
8c3d91 | 2000-09-04 | Per Hedbor | | {
int nf = sizeof( fl->available_fonts() );
|
fc8ffc | 2017-05-23 | Pontus Östlund | | res += "<dl><dt>"+fl->name+" ("+nf
+" font"+(nf==1?"":"s")+")</dt>"
"<dd>"+fl->doc+"</dd></dl>";
|
8c3d91 | 2000-09-04 | Per Hedbor | | }
|
fc8ffc | 2017-05-23 | Pontus Östlund | | return res;
|
8c3d91 | 2000-09-04 | Per Hedbor | | }
|
bebbad | 2000-08-16 | Andreas Lange | | string page_0(RequestID id)
|
89b41a | 2000-02-04 | Per Hedbor | | {
|
dcf3ff | 2011-12-28 | Martin Stjernholm | | array fonts = roxen.fonts.available_fonts(1);
|
261716 | 2001-02-05 | Per Hedbor | | array q = roxen.fonts.get_font_information();
|
1e6b54 | 2000-09-04 | Per Hedbor | | info = mkmapping( q->name, q );
|
bebbad | 2000-08-16 | Andreas Lange | | string res=("<input type='hidden' name='action' value='listfonts.pike'/>"
"<input type='hidden' name='doit' value='indeed'/>\n"
|
fc8ffc | 2017-05-23 | Pontus Östlund | | "<h2 class='no-margin-top'>" +
LOCALE(58,"Available font loaders") + "</h2><p>"+
font_loaders()+"<h3 class='section'>" +
LOCALE("dI","All available fonts") + "</h3><p>");
foreach(sort(fonts), string font) {
res += list_font(font);
}
res += ("</p><hr class='section'><p>" + LOCALE(236,"Example text") + ": "
"<input name=text size=46 value='" +
LOCALE(237,"Jackdaws love my big sphinx of quartz.") +
"'></p><hr class='section'>"
"<table><tr><td>"
"<cf-cancel href='?class=status&&usr.set-wiz-id;'/></td>"
"<td class='text-right'>"
"<cf-next/></td></tr></table>");
|
89b41a | 2000-02-04 | Per Hedbor | | return res;
}
|
bebbad | 2000-08-16 | Andreas Lange | | string page_1(RequestID id)
|
89b41a | 2000-02-04 | Per Hedbor | | {
string res="";
|
261716 | 2001-02-05 | Per Hedbor | | mapping v = id->real_variables;
|
f671c2 | 2001-08-27 | Per Hedbor | | string txt = v->text && v->text[0];
|
261716 | 2001-02-05 | Per Hedbor | | foreach(roxen.fonts.available_fonts(), string fn)
res += Roxen.html_encode_string( fn )+":<br />\n"
|
f671c2 | 2001-08-27 | Per Hedbor | | "<gtext fontsize=16 align='top' font='"+fn+"'>"+Roxen.html_encode_string(txt)+"</gtext><br>"
"<gtext fontsize=32 align='top' font='"+fn+"'>"+Roxen.html_encode_string(lower_case(txt))+"</gtext><br>"
"<gtext fontsize=48 align='top' font='"+fn+"'>"+Roxen.html_encode_string(upper_case(txt))+"</gtext><p>";
|
bebbad | 2000-08-16 | Andreas Lange | | return res+"<br /></p><p>\n<cf-ok/></p>";
|
89b41a | 2000-02-04 | Per Hedbor | | }
|
23414a | 2000-07-21 | Andreas Lange | | mixed parse( RequestID id )
|
89b41a | 2000-02-04 | Per Hedbor | | {
|
4f2757 | 2000-02-04 | Per Hedbor | | if( id->variables->doit )
return page_1( id );
return page_0( id );
|
89b41a | 2000-02-04 | Per Hedbor | | }
|