f26aee | 2000-01-31 | Per Hedbor | | #include <config_interface.h>
#include <module.h>
|
f0a70e | 2000-07-21 | Martin Nilsson | | #include <module_constants.h>
|
0c694f | 2000-07-23 | Martin Nilsson | | #include <roxen.h>
|
10745b | 2001-01-29 | Per Hedbor | | int no_reload()
{
if( sizeof( already_added ) )
return 1;
}
|
0c694f | 2000-07-23 | Martin Nilsson | |
#define LOCALE(X,Y) _STR_LOCALE("roxen_config",X,Y)
|
f26aee | 2000-01-31 | Per Hedbor | |
|
ab9b6d | 2000-02-11 | Per Hedbor | |
|
c2b272 | 2000-05-22 | Martin Nilsson | | array(string) class_description( string d, RequestID id )
|
ab9b6d | 2000-02-11 | Per Hedbor | | {
string name, doc;
|
14bc71 | 2000-02-11 | Henrik Grubbström (Grubba) | | while(!(< "", "/" >)[d] && !file_stat( d+"/INFO" ))
|
ab9b6d | 2000-02-11 | Per Hedbor | | d = dirname(d);
|
14bc71 | 2000-02-11 | Henrik Grubbström (Grubba) | | if((< "", "/" >)[d])
|
ab9b6d | 2000-02-11 | Per Hedbor | | return ({"Local modules", "" });
string n = Stdio.read_bytes( d+"/INFO" );
sscanf( n, "<"+id->misc->config_locale+">%s"
"</"+id->misc->config_locale+">", n );
sscanf( n, "%*s<name>%s</name>", name );
sscanf( n, "%*s<doc>%s</doc>", doc );
|
d39c49 | 2000-03-28 | Per Hedbor | | if( search(n, "<noshow/>" ) != -1 )
return ({ "", "" });
|
ab9b6d | 2000-02-11 | Per Hedbor | |
if(!name)
return ({"Local modules", "" });
if(!doc)
doc ="";
return ({ name, doc });
}
|
c2b272 | 2000-05-22 | Martin Nilsson | | array(string) module_class( object m, RequestID id )
|
ab9b6d | 2000-02-11 | Per Hedbor | | {
return class_description( m->filename, id );
}
|
f26aee | 2000-01-31 | Per Hedbor | | object module_nomore(string name, object modinfo, object conf)
{
mapping module;
object o;
if(!modinfo)
return 0;
if(!modinfo->multiple_copies && (module = conf->modules[name]) &&
sizeof(module->copies) )
return modinfo;
if(((modinfo->type & MODULE_DIRECTORIES) && (o=conf->dir_module))
|| ((modinfo->type & MODULE_AUTH) && (o=conf->auth_module))
|| ((modinfo->type & MODULE_TYPES) && (o=conf->types_module)))
|
a38da1 | 2000-08-20 | Per Hedbor | | return roxen.find_module( conf->otomod[o] );
|
f26aee | 2000-01-31 | Per Hedbor | | }
string site_url( RequestID id, string site )
{
|
c170ce | 2001-01-28 | Per Hedbor | | return "/sites/site.html/"+site+"/";
|
f26aee | 2000-01-31 | Per Hedbor | | }
|
a115b8 | 2002-03-06 | Henrik Grubbström (Grubba) | | string page_base( RequestID id, string content, int|void noform )
|
f26aee | 2000-01-31 | Per Hedbor | | {
|
10745b | 2001-01-29 | Per Hedbor | | return sprintf( "<use file='/template' />\n"
|
a115b8 | 2002-03-06 | Henrik Grubbström (Grubba) | | "<tmpl title=' %s'%s>"
|
10745b | 2001-01-29 | Per Hedbor | | "<topmenu base='/' selected='sites'/>\n"
|
ab9b6d | 2000-02-11 | Per Hedbor | | "<content><cv-split>"
|
9e4a01 | 2000-04-06 | Per Hedbor | | "<subtablist width='100%%'>"
|
f26aee | 2000-01-31 | Per Hedbor | | "<st-tabs></st-tabs>"
"<st-page>"
|
cc75f5 | 2000-10-21 | Martin Nilsson | | "<if not='1' variable='form.initial'>"
|
b411b3 | 2000-08-25 | Andreas Lange | | "<gbutton href='add_module.pike?config=&form.config:http;"
"&reload_module_list=yes' > %s </gbutton> "
"<gbutton href='site.html/&form.config;'> %s </gbutton>"
|
f599d9 | 2000-09-03 | Per Hedbor | | "<p>\n</if>%s\n</p>\n"
|
f26aee | 2000-01-31 | Per Hedbor | | "</st-page></subtablist></td></tr></table>"
|
e3aab7 | 2000-07-25 | Andreas Lange | | "</cv-split></content></tmpl>",
|
a115b8 | 2002-03-06 | Henrik Grubbström (Grubba) | | LOCALE(258,"Add module"),
noform?" noform='noform'":"",
|
f599d9 | 2000-09-03 | Per Hedbor | | LOCALE(272,"Reload module list"),
|
b411b3 | 2000-08-25 | Andreas Lange | | LOCALE(202,"Cancel"), content );
|
f26aee | 2000-01-31 | Per Hedbor | | }
|
157724 | 2000-08-19 | Per Hedbor | |
string module_name_from_file( string file )
{
string data, name;
catch(data = Stdio.read_bytes( file ));
if( data
&& sscanf( data, "%*smodule_name%*s=%[^;];", name )
&& sscanf( name, "%*[^\"]\"%s\"", name ) )
|
6b394a | 2000-10-13 | Martin Nilsson | | return Roxen.html_encode_string(name);
return Roxen.html_encode_string(((file/"/")[-1]/".")[0]);
|
157724 | 2000-08-19 | Per Hedbor | | }
|
e4445e | 2002-02-26 | Marcus Wellhardh | | string pafeaw( string errors, string warnings, array(ModuleInfo) locked_modules)
|
157724 | 2000-08-19 | Per Hedbor | |
{
mapping by_module = ([]);
int cnt = 0;
foreach( (errors+warnings)/"\n", string e )
{
string file;
int row;
string type, error;
sscanf( e, "%s:%d%s", file, row, error );
if( error )
{
sscanf( error, "%*[ \t]%s", error );
sscanf( error, "%s: %s", type, error );
if( by_module[ file ] )
by_module[ file ] += ({ ({ row*10000 + cnt++, row, type, error }) });
else
by_module[ file ] = ({ ({ row*10000 + cnt++, row, type, error }) });
}
}
string da_string = "";
int header_added;
foreach( sort((array)by_module), [string module, array errors] )
{
array res = ({ });
int remove_suspicious = 0;
sort( errors );
foreach( errors, array e )
{
if( e[2] == "Error" )
{
remove_suspicious = 1;
switch( e[3] )
{
case "Must return a value for a non-void function.":
case "Class definition failed.":
case "Illegal program pointer.":
case "Illegal program identifier":
continue;
}
}
res += ({ e });
}
if( sizeof( res ) )
{
string he( string what )
{
if( what == "Error" )
|
ab05fb | 2000-08-23 | Per Hedbor | | return "<font color='&usr.warncolor;'>"+what+"</font>";
|
157724 | 2000-08-19 | Per Hedbor | | return what;
};
string hc( string what )
{
return what;
};
string trim_name( string what )
{
array q = (what / "/");
return q[sizeof(q)-2..]*"/";
};
#define RELOAD(X) sprintf("<gbutton " \
"href='add_module.pike?config=&form.config:http;" \
|
7efa4d | 2000-08-20 | Per Hedbor | | "&random=%d&only=%s&reload_module_list=yes#" \
|
157724 | 2000-08-19 | Per Hedbor | | "errors_and_warnings'> %s </gbutton>", \
random(4711111), \
|
7efa4d | 2000-08-20 | Per Hedbor | | (X), \
|
157724 | 2000-08-19 | Per Hedbor | | LOCALE(253, "Reload"))
if( !header_added++ )
da_string +=
"<p><a name='errors_and_warnings'><br />"
|
cc75f5 | 2000-10-21 | Martin Nilsson | | "<font size='+2'><b><font color='&usr.warncolor;'>"
|
157724 | 2000-08-19 | Per Hedbor | | "Compile errors and warnings</font></b><br />"
"<table width=100% cellpadding='3' cellspacing='0' border='0'>";
da_string += "<tr><td></td>"
|
cc75f5 | 2000-10-21 | Martin Nilsson | | "<td colspan='3' bgcolor='&usr.content-titlebg;'>"
|
157724 | 2000-08-19 | Per Hedbor | | + "<b><font color='&usr.content-titlefg;' size='+1'>"
+ module_name_from_file(module)+"</font></b></td>"
+ "<td align='right' bgcolor='&usr.content-titlebg;'>"
"<font color='&usr.content-titlefg;' size='+1'>"
+ trim_name(module)
+ "</font> "+RELOAD(module)+"</td><td></td></tr>";
foreach( res, array e )
da_string +=
|
99710c | 2000-12-18 | Martin Nilsson | | "<tr valign='top'><td></td><td><img src='/internal-roxen-unit' width='30' height='1' alt='' />"
|
cc75f5 | 2000-10-21 | Martin Nilsson | | "</td><td align='right'>"
"<tt>"+e[1]+":</tt></td><td align='right'><tt>"+
|
157724 | 2000-08-19 | Per Hedbor | | he(e[2])+":</tt></td><td><tt>"+hc(e[3])+"</tt></td></tr>\n";
|
cc75f5 | 2000-10-21 | Martin Nilsson | | da_string += "<tr valign='top'><td colspan='5'> </td><td></td></tr>\n";
|
157724 | 2000-08-19 | Per Hedbor | |
}
}
if( strlen( da_string ) )
da_string += "</table>";
|
e4445e | 2002-02-26 | Marcus Wellhardh | |
return da_string + format_locked_modules(locked_modules);
}
string format_locked_modules(array(ModuleInfo) locked_modules)
{
if(!sizeof(locked_modules))
return "";
return
"<font size='+1'>Locked modules</font><br />\n"
"These modules are locked and can not be enabled because they are "
"not part of the license key for this configuration.<br />\n"
"<blockquote><font color='darkred'>"+
|
6e4229 | 2002-02-26 | Marcus Wellhardh | | (((array(string))locked_modules->get_name())*"<br />\n")+"</font></blockquote>";
|
157724 | 2000-08-19 | Per Hedbor | | }
|
ab9b6d | 2000-02-11 | Per Hedbor | | array(string) get_module_list( function describe_module,
function class_visible,
RequestID id )
|
f26aee | 2000-01-31 | Per Hedbor | | {
object conf = roxen.find_configuration( id->variables->config );
object ec = roxenloader.LowErrorContainer();
|
f15025 | 2000-04-04 | Per Hedbor | | int do_reload;
|
f26aee | 2000-01-31 | Per Hedbor | | master()->set_inhibit_compile_errors( ec );
|
f15025 | 2000-04-04 | Per Hedbor | | if( id->variables->reload_module_list )
roxen->clear_all_modules_cache();
|
f599d9 | 2000-09-03 | Per Hedbor | | array(ModuleInfo) mods;
|
f26aee | 2000-01-31 | Per Hedbor | | roxenloader.push_compile_error_handler( ec );
mods = roxen->all_modules();
roxenloader.pop_compile_error_handler();
|
f599d9 | 2000-09-03 | Per Hedbor | | foreach( mods, ModuleInfo m )
if( module_nomore( m->sname, m, conf ) )
mods -= ({ m });
|
ab9b6d | 2000-02-11 | Per Hedbor | |
|
f599d9 | 2000-09-03 | Per Hedbor | | string res = "";
|
f26aee | 2000-01-31 | Per Hedbor | | string doubles="", already="";
|
ab9b6d | 2000-02-11 | Per Hedbor | | array w = map(mods, module_class, id);
|
ad2808 | 2000-11-18 | Martin Nilsson | | mapping classes = ([]);
|
ab9b6d | 2000-02-11 | Per Hedbor | | sort(w,mods);
for(int i=0; i<sizeof(w); i++)
|
f26aee | 2000-01-31 | Per Hedbor | | {
|
ab9b6d | 2000-02-11 | Per Hedbor | | mixed r = w[i];
if(!classes[r[0]])
classes[r[0]] = ([ "doc":r[1], "modules":({}) ]);
|
4d32e5 | 2001-07-31 | Per Hedbor | | if( mods[i]->get_description() )
classes[r[0]]->modules += ({ mods[i] });
|
ab9b6d | 2000-02-11 | Per Hedbor | | }
|
e4445e | 2002-02-26 | Marcus Wellhardh | | License.Key license_key = conf->getvar("license")->get_key();
array(RoxenModule) locked_modules = ({});
|
ab9b6d | 2000-02-11 | Per Hedbor | | foreach( sort(indices(classes)), string c )
{
mixed r;
|
d39c49 | 2000-03-28 | Per Hedbor | | if( c == "" )
continue;
|
ab9b6d | 2000-02-11 | Per Hedbor | | if( (r = class_visible( c, classes[c]->doc, id )) && r[0] )
{
res += r[1];
|
157724 | 2000-08-19 | Per Hedbor | | array m = classes[c]->modules;
array q = m->get_name();
sort( q, m );
foreach(m, object q)
|
ab9b6d | 2000-02-11 | Per Hedbor | | {
if( q->get_description() == "Undocumented" &&
q->type == 0 )
continue;
object b = module_nomore(q->sname, q, conf);
|
e4445e | 2002-02-26 | Marcus Wellhardh | | if( !b && q->locked && (!license_key || !q->unlocked(license_key)) )
{
locked_modules += ({ q });
continue;
}
|
ab9b6d | 2000-02-11 | Per Hedbor | | res += describe_module( q, b );
}
} else
res += r[1];
|
f26aee | 2000-01-31 | Per Hedbor | | }
|
5704c2 | 2000-02-02 | Per Hedbor | | master()->set_inhibit_compile_errors( 0 );
|
e4445e | 2002-02-26 | Marcus Wellhardh | | return ({ res, pafeaw( ec->get(), ec->get_warnings(), locked_modules) });
|
f26aee | 2000-01-31 | Per Hedbor | | }
string module_image( int type )
{
return "";
}
|
94ebf5 | 2001-03-04 | Per Hedbor | |
string strip_leading( LocaleString what )
|
f7bd0d | 2001-03-03 | Per Hedbor | | {
|
94ebf5 | 2001-03-04 | Per Hedbor | | if( !what ) return 0;
|
8183cc | 2001-08-09 | Martin Stjernholm | | sscanf( (string)what, "%*s:%*[ \t]%s", what );
|
f7bd0d | 2001-03-03 | Per Hedbor | | return what;
}
|
f26aee | 2000-01-31 | Per Hedbor | |
function describe_module_normal( int image )
{
return lambda( object module, object block)
{
if(!block)
{
|
4ab2c2 | 2002-01-28 | Martin Stjernholm | | return sprintf(
#"
|
9e4a01 | 2000-04-06 | Per Hedbor | | <tr>
<td colspan='2'>
<table width='100%%'>
<tr>
<td><font size='+2'>%s</font></td>
|
8183cc | 2001-08-09 | Martin Stjernholm | | <td align='right'>(%s) %s</td>
|
9e4a01 | 2000-04-06 | Per Hedbor | | </tr>
</table>
</td>
</tr>
<tr>
<td valign='top'>
<form method='post' action='add_module.pike'>
|
a115b8 | 2002-03-06 | Henrik Grubbström (Grubba) | | <roxen-automatic-charset-variable/>
|
9e4a01 | 2000-04-06 | Per Hedbor | | <input type='hidden' name='module_to_add' value='%s'>
<input type='hidden' name='config' value='&form.config;'>
|
cc75f5 | 2000-10-21 | Martin Nilsson | | <submit-gbutton preparse='1'>%s</submit-gbutton>
|
9e4a01 | 2000-04-06 | Per Hedbor | | </form>
</td>
|
cc75f5 | 2000-10-21 | Martin Nilsson | | <td valign='top'>
|
9e4a01 | 2000-04-06 | Per Hedbor | | %s
<p>
%s
</p>
</td>
</tr>
|
f26aee | 2000-01-31 | Per Hedbor | | ",
|
4ab2c2 | 2002-01-28 | Martin Stjernholm | |
Roxen.html_encode_string(module->get_name()),
Roxen.html_encode_string (module->sname),
(image?module_image(module->type):""),
|
f26aee | 2000-01-31 | Per Hedbor | | module->sname,
|
e3aab7 | 2000-07-25 | Andreas Lange | | LOCALE(251, "Add Module"),
|
4d32e5 | 2001-07-31 | Per Hedbor | | module->get_description(),
|
e3aab7 | 2000-07-25 | Andreas Lange | | LOCALE(266, "Will be loaded from: ")+module->filename
|
f26aee | 2000-01-31 | Per Hedbor | | );
} else {
if( block == module )
return "";
|
ab9b6d | 2000-02-11 | Per Hedbor | | return "";
|
f26aee | 2000-01-31 | Per Hedbor | | }
};
}
|
c2b272 | 2000-05-22 | Martin Nilsson | | array(int|string) class_visible_normal( string c, string d, RequestID id )
|
ab9b6d | 2000-02-11 | Per Hedbor | | {
|
0b0429 | 2000-07-23 | Martin Nilsson | | int x;
|
9e4a01 | 2000-04-06 | Per Hedbor | | string header = ("<tr><td colspan='2'><table width='100%' "
"cellspacing='0' border='0' cellpadding='3' "
|
0b0429 | 2000-07-23 | Martin Nilsson | | "bgcolor='&usr.content-titlebg;'><tr><td>");
if( id->variables->unfolded == c ) {
|
86e5a4 | 2001-08-28 | Per Hedbor | | header+=("<a name="+Roxen.http_encode_string(c)+
"></a><gbutton "
|
10745b | 2001-01-29 | Per Hedbor | | "href='add_module.pike?config=&form.config;"
"#"+Roxen.http_encode_string(c)+"' > "+
|
615097 | 2001-01-29 | Per Hedbor | | LOCALE(168, "Hide")+" </gbutton>");
|
0b0429 | 2000-07-23 | Martin Nilsson | | x=1;
}
else
|
86e5a4 | 2001-08-28 | Per Hedbor | | header+=("<a name="+Roxen.http_encode_string(c)+
"></a><gbutton "
|
0b0429 | 2000-07-23 | Martin Nilsson | | "href='add_module.pike?config=&form.config;"
"&unfolded="+Roxen.http_encode_string(c)+
"#"+Roxen.http_encode_string(c)+"' > "+
|
e3aab7 | 2000-07-25 | Andreas Lange | | LOCALE(267, "View")+" </gbutton>");
|
0b0429 | 2000-07-23 | Martin Nilsson | |
header+=("</td><td width='100%'>"
"<font color='&usr.content-titlefg;' size='+2'>"+c+"</font>"
"<br />"+d+"</td></tr></table></td></tr>\n");
return ({ x, header });
|
ab9b6d | 2000-02-11 | Per Hedbor | | }
|
f26aee | 2000-01-31 | Per Hedbor | | string page_normal( RequestID id, int|void noimage )
{
|
ab9b6d | 2000-02-11 | Per Hedbor | | string content = "";
content += "<table>";
|
f26aee | 2000-01-31 | Per Hedbor | | string desc, err;
|
ab9b6d | 2000-02-11 | Per Hedbor | | [desc,err] = get_module_list( describe_module_normal(!noimage),
class_visible_normal, id );
|
157724 | 2000-08-19 | Per Hedbor | | content += (desc+"</table>"+err);
|
a115b8 | 2002-03-06 | Henrik Grubbström (Grubba) | | return page_base( id, content, 1 );
|
f26aee | 2000-01-31 | Per Hedbor | | }
string page_fast( RequestID id )
{
return page_normal( id, 1 );
}
|
5876e8 | 2000-04-01 | Martin Bähr | | string describe_module_faster( object module, object block)
{
if(!block)
{
return sprintf(
|
4ab2c2 | 2002-01-28 | Martin Stjernholm | | #"
|
8183cc | 2001-08-09 | Martin Stjernholm | | <tr><td colspan='2'><table width='100%%'>
<td><font size='+2'>%s</font></td>
<td align='right'>(%s) %s</td></table></td></tr>
|
0b0429 | 2000-07-23 | Martin Nilsson | | <tr><td valign='top'><select multiple='multiple' name='module_to_add'>
|
5876e8 | 2000-04-01 | Martin Bähr | | <option value='%s'>%s</option></select>
|
9e4a01 | 2000-04-06 | Per Hedbor | | </td><td valign='top'>%s<p>%s</p></td>
|
5876e8 | 2000-04-01 | Martin Bähr | | </tr>
",
|
4ab2c2 | 2002-01-28 | Martin Stjernholm | |
Roxen.html_encode_string(module->get_name()),
|
8183cc | 2001-08-09 | Martin Stjernholm | | Roxen.html_encode_string (module->sname),
|
5876e8 | 2000-04-01 | Martin Bähr | | module_image(module->type),
module->sname,
|
4ab2c2 | 2002-01-28 | Martin Stjernholm | |
Roxen.html_encode_string(module->get_name()),
|
5876e8 | 2000-04-01 | Martin Bähr | | module->get_description(),
|
e3aab7 | 2000-07-25 | Andreas Lange | | LOCALE(266, "Will be loaded from: ")+module->filename
|
5876e8 | 2000-04-01 | Martin Bähr | | );
} else {
if( block == module )
return "";
return "";
}
}
|
c2b272 | 2000-05-22 | Martin Nilsson | | array(int|string) class_visible_faster( string c, string d, RequestID id )
|
5876e8 | 2000-04-01 | Martin Bähr | | {
|
0b0429 | 2000-07-23 | Martin Nilsson | | int x;
|
9e4a01 | 2000-04-06 | Per Hedbor | | string header = ("<tr><td colspan='2'><table width='100%' cellspacing='0' "
"border='0' cellpadding='3' bgcolor='&usr.content-titlebg;'>"
|
0b0429 | 2000-07-23 | Martin Nilsson | | "<tr><td>");
if( id->variables->unfolded == c ) {
header+=("<a name="+Roxen.http_encode_string(c)+
|
cc75f5 | 2000-10-21 | Martin Nilsson | | "></a><gbutton dim='1'> "+LOCALE(267, "View")+" </gbutton>"
|
e3aab7 | 2000-07-25 | Andreas Lange | | "<tr><td><submit-gbutton> "+LOCALE(251, "Add Module")+
|
0b0429 | 2000-07-23 | Martin Nilsson | | " </submit-gbutton></td></tr>");
x=1;
}
else
|
86e5a4 | 2001-08-28 | Per Hedbor | | header+=("<a name="+Roxen.http_encode_string(c)+
"></a><gbutton "
|
0b0429 | 2000-07-23 | Martin Nilsson | | "href='add_module.pike?config=&form.config;"
"&unfolded="+Roxen.http_encode_string(c)+
"#"+Roxen.http_encode_string(c)+"' > "+
|
e3aab7 | 2000-07-25 | Andreas Lange | | LOCALE(267, "View")+" </gbutton>");
|
0b0429 | 2000-07-23 | Martin Nilsson | |
header+=("</td><td width='100%'>"
"<font color='&usr.content-titlefg;' size='+2'>"+c+"</font>"
"<br />"+d+"</td></tr></table></td></tr>\n");
return ({ x, header });
|
5876e8 | 2000-04-01 | Martin Bähr | | }
string page_faster( RequestID id )
{
string content = "";
|
9e4a01 | 2000-04-06 | Per Hedbor | | content += "<form method='post' action='add_module.pike'>"
"<input type='hidden' name='config' value='&form.config;'>"
|
5876e8 | 2000-04-01 | Martin Bähr | | "<table>";
string desc, err;
[desc,err] = get_module_list( describe_module_faster,
class_visible_faster, id );
|
157724 | 2000-08-19 | Per Hedbor | | content += (desc+"</table></form>"+err);
|
5876e8 | 2000-04-01 | Martin Bähr | | return page_base( id, content );
}
|
ab9b6d | 2000-02-11 | Per Hedbor | | int first;
|
c2b272 | 2000-05-22 | Martin Nilsson | | array(int|string) class_visible_compact( string c, string d, RequestID id )
|
ab9b6d | 2000-02-11 | Per Hedbor | | {
string res="";
if(first++)
|
e3aab7 | 2000-07-25 | Andreas Lange | | res = "</select><br /><submit-gbutton> "+LOCALE(251, "Add Module")+" </submit-gbutton> ";
|
86e5a4 | 2001-08-28 | Per Hedbor | | res += "<p><a name="+Roxen.http_encode_string(c)+
"></a><font size='+2'>"+c+"</font><br />"+d+"<p><select multiple name='module_to_add'>";
|
ab9b6d | 2000-02-11 | Per Hedbor | | return ({ 1, res });
}
string describe_module_compact( object module, object block )
{
|
8183cc | 2001-08-09 | Martin Stjernholm | | if(!block) {
|
4ab2c2 | 2002-01-28 | Martin Stjernholm | |
string modname = module->get_name();
|
8183cc | 2001-08-09 | Martin Stjernholm | | return "<option value='"+module->sname+"'>"+
Roxen.html_encode_string(
modname + "\0240" * max (0, (int) ((40 - sizeof (modname)) * 1.4)) +
" (" + module->sname + ")")+
"</option>\n";
}
|
59d5e6 | 2000-02-23 | Martin Nilsson | | return "";
|
ab9b6d | 2000-02-11 | Per Hedbor | | }
|
f26aee | 2000-01-31 | Per Hedbor | | string page_compact( RequestID id )
{
|
ab9b6d | 2000-02-11 | Per Hedbor | | first=0;
string desc, err;
[desc,err] = get_module_list( describe_module_compact,
class_visible_compact, id );
return page_base(id,
|
9e4a01 | 2000-04-06 | Per Hedbor | | "<form action='add_module.pike' method='POST'>"
"<input type='hidden' name='config' value='&form.config;'>"+
desc+"</select><br /><submit-gbutton> "
|
157724 | 2000-08-19 | Per Hedbor | | +LOCALE(251, "Add Module")+" </submit-gbutton><p>"
+err+"</form>",
|
ab9b6d | 2000-02-11 | Per Hedbor | | );
|
f26aee | 2000-01-31 | Per Hedbor | | }
|
17041f | 2000-03-01 | Martin Nilsson | | string page_really_compact( RequestID id )
{
first=0;
object conf = roxen.find_configuration( id->variables->config );
object ec = roxenloader.LowErrorContainer();
master()->set_inhibit_compile_errors( ec );
|
958ad8 | 2000-08-15 | Martin Stjernholm | | if( id->variables->reload_module_list )
|
7efa4d | 2000-08-20 | Per Hedbor | | {
if( id->variables->only )
{
master()->clear_compilation_failures();
m_delete( roxen->modules, (((id->variables->only/"/")[-1])/".")[0] );
roxen->all_modules_cache = 0;
}
else
roxen->clear_all_modules_cache();
}
|
958ad8 | 2000-08-15 | Martin Stjernholm | |
|
17041f | 2000-03-01 | Martin Nilsson | | array mods;
roxenloader.push_compile_error_handler( ec );
mods = roxen->all_modules();
roxenloader.pop_compile_error_handler();
|
8a4cef | 2001-04-10 | Martin Nilsson | | sort(map(mods->get_name(), lambda(LocaleString in) {
in = lower_case((string)in);
|
4ab2c2 | 2002-01-28 | Martin Stjernholm | |
|
8a4cef | 2001-04-10 | Martin Nilsson | | return in;
|
979e80 | 2000-11-26 | Martin Nilsson | | }), mods);
|
17041f | 2000-03-01 | Martin Nilsson | | string res = "";
mixed r;
|
e4445e | 2002-02-26 | Marcus Wellhardh | | License.Key license_key = conf->getvar("license")->get_key();
array(RoxenModule) locked_modules = ({});
|
e3aab7 | 2000-07-25 | Andreas Lange | | if( (r = class_visible_compact( LOCALE(258,"Add module"),
LOCALE(273,"Select one or several modules to add.")
, id )) && r[0] ) {
|
17041f | 2000-03-01 | Martin Nilsson | | res += r[1];
foreach(mods, object q) {
|
4d32e5 | 2001-07-31 | Per Hedbor | | if( (!q->get_description() ||
(q->get_description() == "Undocumented")) &&
|
17041f | 2000-03-01 | Martin Nilsson | | q->type == 0 )
continue;
object b = module_nomore(q->sname, q, conf);
|
e4445e | 2002-02-26 | Marcus Wellhardh | | if( !b && q->locked && (!license_key || !q->unlocked(license_key)) )
{
locked_modules += ({ q });
continue;
}
|
17041f | 2000-03-01 | Martin Nilsson | | res += describe_module_compact( q, b );
}
} else
res += r[1];
master()->set_inhibit_compile_errors( 0 );
return page_base(id,
"<form action=\"add_module.pike\" method=\"post\">"
"<input type=\"hidden\" name=\"config\" value=\"&form.config;\" />"+
|
ad2808 | 2000-11-18 | Martin Nilsson | | res+"</select><br /><submit-gbutton> "
|
157724 | 2000-08-19 | Per Hedbor | | +LOCALE(251, "Add Module")+" </submit-gbutton><br />"
|
e4445e | 2002-02-26 | Marcus Wellhardh | | +pafeaw(ec->get(),ec->get_warnings(),
locked_modules)+"</form>",
|
17041f | 2000-03-01 | Martin Nilsson | | );
}
|
9ba17a | 2000-03-24 | Per Hedbor | | string decode_site_name( string what )
{
if( (int)what )
return (string)((array(int))(what/","-({""})));
return what;
}
|
f26aee | 2000-01-31 | Per Hedbor | |
|
2e07c3 | 2000-03-09 | Martin Stjernholm | |
|
f599d9 | 2000-09-03 | Per Hedbor | | array initial_form( RequestID id, Configuration conf, array modules )
{
|
10745b | 2001-01-29 | Per Hedbor | | id->variables->initial = "1";
id->real_variables->initial = ({ "1" });
|
f599d9 | 2000-09-03 | Per Hedbor | | string res = "";
int num;
|
10745b | 2001-01-29 | Per Hedbor | |
|
f599d9 | 2000-09-03 | Per Hedbor | | foreach( modules, string mod )
|
157724 | 2000-08-19 | Per Hedbor | | {
|
f599d9 | 2000-09-03 | Per Hedbor | | ModuleInfo mi = roxen.find_module( (mod/"!")[0] );
RoxenModule moo = conf->find_module( replace(mod,"!","#") );
foreach( indices(moo->query()), string v )
|
157724 | 2000-08-19 | Per Hedbor | | {
|
f599d9 | 2000-09-03 | Per Hedbor | | if( moo->getvar( v )->get_flags() & VAR_INITIAL )
{
num++;
res += "<tr><td colspan='3'><h2>"
|
c18318 | 2000-09-09 | Andreas Lange | | +LOCALE(1,"Initial variables for ")+
|
4ab2c2 | 2002-01-28 | Martin Stjernholm | |
Roxen.html_encode_string(mi->get_name())
|
f7bd0d | 2001-03-03 | Per Hedbor | | +"</h2></td></tr>"
|
d672ca | 2001-01-29 | Per Hedbor | | "<emit source='module-variables' "
" configuration=\""+conf->name+"\""
" module=\""+mod+#"\"/>
<emit noset='1' source='module-variables' "
" configuration=\""+conf->name+"\""
|
f599d9 | 2000-09-03 | Per Hedbor | | " module=\""+mod+#"\">
|
d672ca | 2001-01-29 | Per Hedbor | | <tr>
<td width='150' valign='top' colspan='2'><b>&_.name;</b></td>
<td valign='top'><eval>&_.form:none;</eval></td></tr>
<tr>
<td width='30'><img src='/internal-roxen-unit' width=50 height=1 alt='' /></td>
<td colspan=2>&_.doc:none;</td></tr>
|
f599d9 | 2000-09-03 | Per Hedbor | | </emit>";
break;
}
|
a38da1 | 2000-08-20 | Per Hedbor | | }
|
c2b272 | 2000-05-22 | Martin Nilsson | | }
|
f599d9 | 2000-09-03 | Per Hedbor | | return ({res,num});
}
|
f26aee | 2000-01-31 | Per Hedbor | |
|
10745b | 2001-01-29 | Per Hedbor | | mapping already_added = ([]);
|
f599d9 | 2000-09-03 | Per Hedbor | | mixed do_it_pass_2( array modules, Configuration conf,
RequestID id )
{
id->misc->do_not_goto = 1;
foreach( modules, string mod )
|
a38da1 | 2000-08-20 | Per Hedbor | | {
|
10745b | 2001-01-29 | Per Hedbor | | if( already_added[mod] )
mod = already_added[ mod ];
|
f599d9 | 2000-09-03 | Per Hedbor | | if( !has_value(mod, "!") || !conf->find_module( replace(mod,"!","#") ) )
|
a38da1 | 2000-08-20 | Per Hedbor | | {
|
f599d9 | 2000-09-03 | Per Hedbor | | RoxenModule mm = conf->enable_module( mod,0,0,1 );
|
eac60f | 2001-01-26 | Per Hedbor | | if( !mm || !conf->otomod[mm] )
{
|
c96d64 | 2001-03-05 | Martin Nilsson | | report_error(LOCALE(382,"Failed to enable %s")+"\n");
|
eac60f | 2001-01-26 | Per Hedbor | | return Roxen.http_redirect( site_url(id,conf->name), id );
}
|
f599d9 | 2000-09-03 | Per Hedbor | | conf->call_low_start_callbacks( mm,
roxen.find_module( (mod/"!")[0] ),
conf->modules[ mod ] );
|
10745b | 2001-01-29 | Per Hedbor | | modules = replace( modules, mod,
(already_added[mod]=(mod/"!")[0]+"!"+
(conf->otomod[mm]/"#")[-1]) );
|
a38da1 | 2000-08-20 | Per Hedbor | | }
|
f599d9 | 2000-09-03 | Per Hedbor | | remove_call_out( roxen.really_save_it );
|
a38da1 | 2000-08-20 | Per Hedbor | | }
|
f599d9 | 2000-09-03 | Per Hedbor | |
[string cf_form, int num] = initial_form( id, conf, modules );
if( !num || id->variables["ok.x"] )
{
if( num ) Roxen.parse_rxml( cf_form, id );
foreach( modules, string mod )
conf->call_start_callbacks( conf->find_module( replace(mod,"!","#") ),
roxen.find_module( (mod/"!")[0] ),
conf->modules[ mod ] );
|
10745b | 2001-01-29 | Per Hedbor | | already_added = ([ ]);
|
f599d9 | 2000-09-03 | Per Hedbor | | conf->save( );
|
3aa50f | 2001-12-19 | Anders Johansson | | conf->forcibly_added = ([]);
|
2df921 | 2001-10-08 | Per Hedbor | | return Roxen.http_redirect(
site_url(id,conf->name)+"-!-/"+modules[-1]+"/" ,
id);
|
f599d9 | 2000-09-03 | Per Hedbor | | }
return page_base(id,"<table>"+
map( modules, lambda( string q ) {
|
cc75f5 | 2000-10-21 | Martin Nilsson | | return "<input type='hidden' "
|
f599d9 | 2000-09-03 | Per Hedbor | | "name='module_to_add' "
"value='"+q+"' />";
} )*"\n"
|
cc75f5 | 2000-10-21 | Martin Nilsson | | +"<input type='hidden' name='config' "
|
10745b | 2001-01-29 | Per Hedbor | | "value='"+conf->name+"' />"+cf_form+"</table><p><cf-ok />");
|
f599d9 | 2000-09-03 | Per Hedbor | | }
mixed do_it( RequestID id )
{
if( id->variables->encoded )
id->variables->config = decode_site_name( id->variables->config );
|
a115b8 | 2002-03-06 | Henrik Grubbström (Grubba) | | Configuration conf;
foreach(id->variables->config/"\0", string config) {
if (conf = roxen.find_configuration( id->variables->config )) {
id->variables->config = config;
break;
}
}
|
f599d9 | 2000-09-03 | Per Hedbor | |
if( !conf->inited )
conf->enable_all_modules();
|
10745b | 2001-01-29 | Per Hedbor | |
|
f599d9 | 2000-09-03 | Per Hedbor | | array modules = (id->variables->module_to_add/"\0")-({""});
if( !sizeof( modules ) )
return Roxen.http_redirect( site_url(id,conf->name ), id );
return do_it_pass_2( modules, conf, id );
|
f26aee | 2000-01-31 | Per Hedbor | | }
mixed parse( RequestID id )
{
if( !config_perm( "Add Module" ) )
|
e3aab7 | 2000-07-25 | Andreas Lange | | return LOCALE(226, "Permission denied");
|
f26aee | 2000-01-31 | Per Hedbor | |
if( id->variables->module_to_add )
return do_it( id );
|
a115b8 | 2002-03-06 | Henrik Grubbström (Grubba) | | Configuration conf;
foreach(id->variables->config/"\0", string config) {
if (conf = roxen.find_configuration( id->variables->config )) {
id->variables->config = config;
break;
}
}
|
62e1bb | 2000-11-08 | Per Hedbor | | if( !config_perm( "Site:"+conf->name ) )
return LOCALE(226,"Permission denied");
|
f15025 | 2000-04-04 | Per Hedbor | | if( !conf->inited )
conf->enable_all_modules();
|
17041f | 2000-03-01 | Martin Nilsson | | return this_object()["page_"+replace(config_setting( "addmodulemethod" )," ","_")]( id );
|
f26aee | 2000-01-31 | Per Hedbor | | }
|