0917d3 | 2013-03-04 | Anders Johansson | |
|
f02502 | 2005-12-17 | Jonas Wallden | |
|
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 | |
|
a84029 | 2017-06-02 | Pontus Östlund | | #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;
|
db7f38 | 2013-07-02 | Pontus Rodling | | while(!(< "", "/" >)[d] && !Stdio.is_file( 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 | | }
|
f02502 | 2005-12-17 | Jonas Wallden | | string get_method(RequestID id)
|
f26aee | 2000-01-31 | Per Hedbor | | {
|
f02502 | 2005-12-17 | Jonas Wallden | |
|
d6b1b5 | 2005-12-17 | Jonas Wallden | | string method =
id->variables->method ||
replace(config_setting( "addmodulemethod" ), " ", "_");
|
f02502 | 2005-12-17 | Jonas Wallden | | if (has_value(method, "\0"))
method = (method / "\0")[0];
if (method == "fast")
method = "normal";
id->variables->method = method;
return method;
}
|
a84029 | 2017-06-02 | Pontus Östlund | | bool show_deprecated(RequestID id)
{
return !!((int)id->variables->deprecated);
|
f26aee | 2000-01-31 | Per Hedbor | | }
|
157724 | 2000-08-19 | Per Hedbor | |
|
a84029 | 2017-06-02 | Pontus Östlund | | string page_base(RequestID id, string content, int|void noform,
int|void show_search_form)
{
string method = get_method(id);
string tmpl = Stdio.read_file(combine_path(__DIR__, "add_module.mu"));
mapping ctx = ([
"title" : LOCALE(251,"Add Module"),
"noform" : noform,
"list_type_title" : LOCALE(421, "List Type"),
"method" : method,
"search_form" : show_search_form,
"content" : content,
"list_types" : ([
"normal" : LOCALE(280, "Normal"),
"faster" : LOCALE(284, "Faster"),
"compact" : LOCALE(286, "Compact"),
"rcompact" : LOCALE(531, "Really Compact")
]),
"button" : ([
"reload" : LOCALE(272,"Reload Module List"),
"cancel" : LOCALE(202,"Cancel"),
])
]);
return Mustache()->render(tmpl, ctx);
}
|
157724 | 2000-08-19 | Per Hedbor | |
string module_name_from_file( string file )
{
string data, name;
catch(data = Stdio.read_bytes( file ));
|
a84029 | 2017-06-02 | Pontus Östlund | |
|
157724 | 2000-08-19 | Per Hedbor | | 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 )
|
a84029 | 2017-06-02 | Pontus Östlund | | {
|
157724 | 2000-08-19 | Per Hedbor | | 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" )
|
a84029 | 2017-06-02 | Pontus Östlund | | return "<span class='notify warn inline'>"+what+"</span>";
|
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..]*"/";
};
|
a84029 | 2017-06-02 | Pontus Östlund | | #define RELOAD(X) sprintf("<link-gbutton " \
"type='reload' " \
|
80cd68 | 2003-11-17 | Anders Johansson | | "href='add_module.pike?config=&form.config:http;" \
|
a84029 | 2017-06-02 | Pontus Östlund | | "&method=&form.method;" \
"&random=%d&only=%s" \
"&reload_module_list=yes" \
"&&usr.set-wiz-id;" \
"#errors_and_warnings'>%s</link-gbutton>", \
|
80cd68 | 2003-11-17 | Anders Johansson | | random(4711111), \
(X), \
|
157724 | 2000-08-19 | Per Hedbor | | LOCALE(253, "Reload"))
if( !header_added++ )
|
a84029 | 2017-06-02 | Pontus Östlund | | da_string +=
|
80cd68 | 2003-11-17 | Anders Johansson | | "<p><a name='errors_and_warnings'></a><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 )
|
a84029 | 2017-06-02 | Pontus Östlund | | 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>";
|
a84029 | 2017-06-02 | Pontus Östlund | |
|
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 "";
|
a84029 | 2017-06-02 | Pontus Östlund | |
|
e4445e | 2002-02-26 | Marcus Wellhardh | | return
|
a84029 | 2017-06-02 | Pontus Östlund | | "<p class='large'>Locked modules</p>\n"
"<p>These modules are locked and can not be enabled because they are "
"not part of the license key for this configuration.</p>\n"
"<div class='notify error'>"+
(((array(string))locked_modules->get_name())*"<br />\n")+"</div>";
|
157724 | 2000-08-19 | Per Hedbor | | }
|
ab9b6d | 2000-02-11 | Per Hedbor | | array(string) get_module_list( function describe_module,
function class_visible,
|
a84029 | 2017-06-02 | Pontus Östlund | | RequestID id,
void|bool fast)
|
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();
|
a84029 | 2017-06-02 | Pontus Östlund | | foreach( mods, ModuleInfo m ) {
if (m->deprecated && !show_deprecated(id)) {
TRACE("::: DEPRECATED ModuleInfo: %O\n", m);
mods -= ({ m });
}
if( module_nomore( m->sname, m, conf ) ) {
|
f599d9 | 2000-09-03 | Per Hedbor | | mods -= ({ m });
|
a84029 | 2017-06-02 | Pontus Östlund | | }
}
|
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":({}) ]);
|
07fe27 | 2008-10-01 | Jonas Wallden | | classes[r[0]]->modules += ({ mods[i] });
|
ab9b6d | 2000-02-11 | Per Hedbor | | }
|
f02502 | 2005-12-17 | Jonas Wallden | | multiset(ModuleInfo) search_modules;
if (string mod_query = id->variables->mod_query) {
array(string) mod_query_words = (lower_case(mod_query) / " ") - ({ "" });
search_modules = (< >);
foreach(mods, ModuleInfo m) {
string compare =
|
a84029 | 2017-06-02 | Pontus Östlund | | lower_case(((string) m->get_name() || "") + "\0" +
m->sname + "\0" +
m->filename + "\0" +
Roxen.html_decode_string((string) m->get_description() ||
LOCALE(1023, "Undocumented")));
|
f02502 | 2005-12-17 | Jonas Wallden | | search_miss:
{
|
a84029 | 2017-06-02 | Pontus Östlund | | foreach(mod_query_words, string w)
if (!has_value(compare, w))
break search_miss;
search_modules[m] = 1;
|
f02502 | 2005-12-17 | Jonas Wallden | | }
}
}
|
e4445e | 2002-02-26 | Marcus Wellhardh | | License.Key license_key = conf->getvar("license")->get_key();
array(RoxenModule) locked_modules = ({});
|
a84029 | 2017-06-02 | Pontus Östlund | |
|
ab9b6d | 2000-02-11 | Per Hedbor | | foreach( sort(indices(classes)), string c )
{
mixed r;
|
d39c49 | 2000-03-28 | Per Hedbor | | if( c == "" )
continue;
|
a84029 | 2017-06-02 | Pontus Östlund | | if( (r = class_visible( c, classes[c]->doc, sizeof(classes[c]->modules), id, fast)) &&
r[0] &&
(!search_modules ||
sizeof(classes[c]->modules & indices(search_modules))))
|
ab9b6d | 2000-02-11 | Per Hedbor | | {
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;
|
a84029 | 2017-06-02 | Pontus Östlund | | if (search_modules && !search_modules[q])
continue;
|
ab9b6d | 2000-02-11 | Per Hedbor | | object b = module_nomore(q->sname, q, conf);
|
a84029 | 2017-06-02 | Pontus Östlund | | if( !b && q->locked &&
(!license_key || !q->unlocked(license_key, conf)) )
{
locked_modules += ({ q });
continue;
}
|
ab9b6d | 2000-02-11 | Per Hedbor | | res += describe_module( q, b );
}
|
f02502 | 2005-12-17 | Jonas Wallden | | } else {
if (!search_modules)
|
a84029 | 2017-06-02 | Pontus Östlund | | res += r[1];
|
f02502 | 2005-12-17 | Jonas Wallden | | }
|
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;
}
|
a84029 | 2017-06-02 | Pontus Östlund | | function describe_module_normal(void|bool faster)
|
f26aee | 2000-01-31 | Per Hedbor | | {
|
a84029 | 2017-06-02 | Pontus Östlund | | return lambda(object module, object block)
|
f26aee | 2000-01-31 | Per Hedbor | | {
|
a84029 | 2017-06-02 | Pontus Östlund | | if (!block) {
string tmpl = #"
<div class='module{{#deprecated}} deprecated{{/deprecated}}'>
<div class='flex-row header'>
<div class='flex flex-grow'><h3>{{ name }}</h3></div>
<div class='flex flex-shrink'><span class='dim'>({{ sname }})</span></div>
</div>
<div class='row'>
<div class='float-right'>
{{ #faster }}
<label for='mod-{{ sname }}' class='module-checkbox' tabindex='0'
data-toggle-cb-event=''>
<input type='checkbox' value='{{ sname }}' name='module_to_add'
id='mod-{{ sname }}' data-toggle-cb=''>
<span>Select</span>
</label>
{{ /faster }}
{{ ^faster }}
<form method='post' action='add_module.pike'>
<roxen-automatic-charset-variable/>
<roxen-wizard-id-variable />
<input type='hidden' name='module_to_add' value='{{ sname }}'>
<input type='hidden' name='config' value='&form.config;'>
<submit-gbutton type='add'>{{ add_label }}</submit-gbutton>
</form>
{{ /faster }}
</div>
<div class='doc'>
{{ &doc }}
<p class='dim'>{{ load_path }}</p>
</div>
</div>
</div>";
string doc = module->get_description();
if (doc) {
if (objectp(doc)) {
doc = (string) doc;
}
doc = String.trim_all_whites(doc);
if (search(doc, "<p") == -1) {
doc = "<p>" + doc + "</p>";
}
}
else {
doc = "<p>" + ((string)LOCALE(1023, "Undocumented")) + "</p>";
}
mapping ctx = ([
"name" : module->get_name(),
"sname" : module->sname,
"add_label" : LOCALE(251, "Add Module"),
"doc" : doc,
"load_path" : LOCALE(266, "Will be loaded from: ")+module->filename,
"faster" : faster,
"deprecated" : module->deprecated
]);
return Mustache()->render(tmpl, ctx);
|
f26aee | 2000-01-31 | Per Hedbor | | }
|
a84029 | 2017-06-02 | Pontus Östlund | |
return "";
|
f26aee | 2000-01-31 | Per Hedbor | | };
}
|
a84029 | 2017-06-02 | Pontus Östlund | | array(int|string) class_visible_normal(string c, string d, int size,
RequestID id, void|bool fast)
|
ab9b6d | 2000-02-11 | Per Hedbor | | {
|
0b0429 | 2000-07-23 | Martin Nilsson | | int x;
|
f02502 | 2005-12-17 | Jonas Wallden | | string method = get_method(id);
|
a84029 | 2017-06-02 | Pontus Östlund | | string header;
array(array(string)) qs = ({
({ "config", "&form.config;" }),
({ "method", "&form.method;" })
});
|
0b0429 | 2000-07-23 | Martin Nilsson | |
|
f02502 | 2005-12-17 | Jonas Wallden | | if (id->variables->mod_query) {
x = 1;
|
a84029 | 2017-06-02 | Pontus Östlund | | }
else if( id->variables->unfolded == c) {
x = 1;
}
else {
qs += ({ ({ "unfolded", Roxen.http_encode_url(c) }) });
|
f02502 | 2005-12-17 | Jonas Wallden | | }
|
0b0429 | 2000-07-23 | Martin Nilsson | |
|
a84029 | 2017-06-02 | Pontus Östlund | | if (show_deprecated(id)) {
qs += ({ ({ "deprecated", "1" }) });
}
string qss = sprintf("%{%s=%s&%}", qs);
qss += "&usr.set-wiz-id;#" + Roxen.http_encode_url(c);
string content = sprintf("<a href='add_module.pike?%s'><dl><dt>%s</dt>",
qss, c);
if (d && sizeof(String.trim_all_whites(d))) {
content += "<dd>" + d + "</dd>";
}
content += "</dl></a>";
if (x && fast) {
content =
"<div class='float-right select-multiple'>"
"<submit-gbutton2 type='add'>Add modules</submit-gbutton2>"
"</div>" +
content;
}
header = sprintf("<div class='group-header action-group%s' id='%s'>%s</div>\n",
x ? " open" : " closed",
Roxen.html_encode_string(c),
content);
|
0b0429 | 2000-07-23 | Martin Nilsson | |
return ({ x, header });
|
ab9b6d | 2000-02-11 | Per Hedbor | | }
|
f02502 | 2005-12-17 | Jonas Wallden | |
|
a84029 | 2017-06-02 | Pontus Östlund | | string page_normal_low(RequestID id, int|void fast)
|
f26aee | 2000-01-31 | Per Hedbor | | {
string desc, err;
|
a84029 | 2017-06-02 | Pontus Östlund | | [desc,err] = get_module_list(describe_module_normal(fast),
class_visible_normal, id, fast);
string ret = "<div class='add-modules-wrapper'>";
if (fast) {
ret += "<input type='hidden' name='config' value='&form.config;'>";
}
return ret + desc + "</div>" + err;
|
f02502 | 2005-12-17 | Jonas Wallden | | }
|
a84029 | 2017-06-02 | Pontus Östlund | | string page_normal_search(RequestID id, void|bool fast)
|
f02502 | 2005-12-17 | Jonas Wallden | | {
return
"<use file='/template-insert' />\n"
"<tmpl>" +
|
a84029 | 2017-06-02 | Pontus Östlund | | page_normal_low(id, fast) +
|
f02502 | 2005-12-17 | Jonas Wallden | | "</tmpl>";
}
|
a84029 | 2017-06-02 | Pontus Östlund | | string page_normal( RequestID id, void|bool fast )
|
f02502 | 2005-12-17 | Jonas Wallden | | {
string content =
"<div id='mod_results' style='display: none'>"
"</div>"
"<div id='mod_default'>" +
|
a84029 | 2017-06-02 | Pontus Östlund | | page_normal_low(id, fast) +
|
f02502 | 2005-12-17 | Jonas Wallden | | "</div>";
return page_base( id, content, 1, 1);
|
f26aee | 2000-01-31 | Per Hedbor | | }
string page_fast( RequestID id )
{
|
a84029 | 2017-06-02 | Pontus Östlund | | return page_normal(id);
|
f26aee | 2000-01-31 | Per Hedbor | | }
|
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%%'>
|
a84029 | 2017-06-02 | Pontus Östlund | | <td>#FASTER#<font size='+2'>%s</font></td>
|
f02502 | 2005-12-17 | Jonas Wallden | | <td align='right'><span class='dimtext'>(%s)</span> %s</td></table>
</td></tr>
<tr><td valign='top'><select multiple='multiple' size='1'
name='module_to_add'>
|
5876e8 | 2000-04-01 | Martin Bähr | | <option value='%s'>%s</option></select>
|
f02502 | 2005-12-17 | Jonas Wallden | | </td><td valign='top'>%s<p class='dimtext'>%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()),
|
82c020 | 2009-03-17 | Jonas Wallden | | module->get_description() || LOCALE(1023, "Undocumented"),
|
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 "";
}
}
|
f33575 | 2003-09-04 | Anders Johansson | | array(int|string) class_visible_faster( string c, string d, int size,
|
a84029 | 2017-06-02 | Pontus Östlund | | RequestID id )
|
5876e8 | 2000-04-01 | Martin Bähr | | {
|
0b0429 | 2000-07-23 | Martin Nilsson | | int x;
|
f02502 | 2005-12-17 | Jonas Wallden | | string method = get_method(id);
|
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;'>"
|
f02502 | 2005-12-17 | Jonas Wallden | | "<tr><td nowrap='nowrap' valign='top'>");
if (id->variables->mod_query) {
|
3ffadc | 2005-12-19 | Jonas Wallden | | header+=("<gbutton hspace='5' vspace='5' dim='1'> "+LOCALE(267, "View")+
|
a84029 | 2017-06-02 | Pontus Östlund | | " </gbutton><br>"
"<submit-gbutton hspace='5' vspace='2'> "+LOCALE(200, "Add Modules")+
" </submit-gbutton>");
|
f02502 | 2005-12-17 | Jonas Wallden | | x = 1;
} else if( id->variables->unfolded == c ) {
|
f49131 | 2004-10-11 | Martin Stjernholm | | header+=("<a name='"+Roxen.html_encode_string(c)+
|
a84029 | 2017-06-02 | Pontus Östlund | | "'></a><gbutton hspace='5' vspace='5' dim='1'> "+LOCALE(267, "View")+
" </gbutton><br>"
"<submit-gbutton hspace='5' vspace='2'> "+LOCALE(200, "Add Modules")+
" </submit-gbutton>");
|
0b0429 | 2000-07-23 | Martin Nilsson | | x=1;
}
else
|
f49131 | 2004-10-11 | Martin Stjernholm | | header+=("<a name='"+Roxen.html_encode_string(c)+
|
a84029 | 2017-06-02 | Pontus Östlund | | "'></a><gbutton hspace='5' vspace='5' "
"href='add_module.pike?config=&form.config;"
"&method=" + method +
"&unfolded="+Roxen.http_encode_url(c)+
"&&usr.set-wiz-id;#"+Roxen.http_encode_url(c)+"' > "+
LOCALE(267, "View")+" </gbutton>");
|
0b0429 | 2000-07-23 | Martin Nilsson | |
header+=("</td><td width='100%'>"
|
a84029 | 2017-06-02 | Pontus Östlund | | "<font color='&usr.content-titlefg;' size='+2'>"+c+"</font>"
"<br />"+d+"</td></tr></table></td></tr>\n");
|
0b0429 | 2000-07-23 | Martin Nilsson | |
return ({ x, header });
|
5876e8 | 2000-04-01 | Martin Bähr | | }
|
f02502 | 2005-12-17 | Jonas Wallden | | string page_faster_low(RequestID id)
|
5876e8 | 2000-04-01 | Martin Bähr | | {
string desc, err;
[desc,err] = get_module_list( describe_module_faster,
class_visible_faster, id );
|
f02502 | 2005-12-17 | Jonas Wallden | | return
"<form method='post' action='add_module.pike'>"
"<input type='hidden' name='config' value='&form.config;'>"
|
e1fff7 | 2016-01-15 | Henrik Grubbström (Grubba) | | "<roxen-wizard-id-variable />"
|
f02502 | 2005-12-17 | Jonas Wallden | | "<table cellspacing='3' cellpadding='0' border='0' width='100%'>" +
desc +
"</table>"
"</form>" +
err;
}
string page_faster_search(RequestID id)
{
return
"<use file='/template-insert' />\n"
"<tmpl>" +
page_faster_low(id) +
"</tmpl>";
}
string page_faster( RequestID id )
{
string content =
"<div id='mod_results' style='display: none'>"
"</div>"
"<div id='mod_default'>" +
|
a84029 | 2017-06-02 | Pontus Östlund | | page_normal_low(id, true) +
|
f02502 | 2005-12-17 | Jonas Wallden | | "</div>";
return page_base( id, content, 0, 1);
|
5876e8 | 2000-04-01 | Martin Bähr | | }
|
ab9b6d | 2000-02-11 | Per Hedbor | | int first;
|
f33575 | 2003-09-04 | Anders Johansson | | array(int|string) class_visible_compact( string c, string d, int size,
|
a84029 | 2017-06-02 | Pontus Östlund | | RequestID id )
|
ab9b6d | 2000-02-11 | Per Hedbor | | {
string res="";
if(first++)
|
f02502 | 2005-12-17 | Jonas Wallden | | res = "</select><br /><submit-gbutton vspace='3'> "+
|
eabb19 | 2006-01-25 | Anders Johansson | | LOCALE(200, "Add Modules")+ " </submit-gbutton> ";
|
f49131 | 2004-10-11 | Martin Stjernholm | | res += "<p><a name='"+Roxen.html_encode_string(c)+
"'></a><font size='+2'>"+c+"</font><br />"+d+"<p>"
|
80cd68 | 2003-11-17 | Anders Johansson | | "<select size='"+size+"' multiple name='module_to_add' class='add-module-select'>";
|
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+"'>"+
|
f33575 | 2003-09-04 | Anders Johansson | | Roxen.html_encode_string(modname)
+ " " * max (0, (int) ((49 - sizeof (modname)))) +
" (" + Roxen.html_encode_string(module->sname) + ")"+
|
8183cc | 2001-08-09 | Martin Stjernholm | | "</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'>"
|
a84029 | 2017-06-02 | Pontus Östlund | | "<roxen-wizard-id-variable />"
|
9e4a01 | 2000-04-06 | Per Hedbor | | "<input type='hidden' name='config' value='&form.config;'>"+
|
f02502 | 2005-12-17 | Jonas Wallden | | desc+"</select><br /><submit-gbutton vspace='3'> "
|
eabb19 | 2006-01-25 | Anders Johansson | | +LOCALE(200, "Add Modules")+" </submit-gbutton><p>"
|
157724 | 2000-08-19 | Per Hedbor | | +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) {
|
a84029 | 2017-06-02 | Pontus Östlund | | in = lower_case((string)in);
return in;
}), 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 = ({});
|
a84029 | 2017-06-02 | Pontus Östlund | |
|
eabb19 | 2006-01-25 | Anders Johansson | | if( (r = class_visible_compact( LOCALE(200,"Add Modules"),
|
a84029 | 2017-06-02 | Pontus Östlund | | LOCALE(273,"Select one or several modules to add."),
sizeof(mods), 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() ||
|
a84029 | 2017-06-02 | Pontus Östlund | | (q->get_description() == "Undocumented")) &&
q->type == 0 )
continue;
|
17041f | 2000-03-01 | Martin Nilsson | | object b = module_nomore(q->sname, q, conf);
|
9af9a5 | 2008-04-08 | Henrik Grubbström (Grubba) | | if( !b && q->locked &&
|
a84029 | 2017-06-02 | Pontus Östlund | | (!license_key || !q->unlocked(license_key, conf)) )
|
e4445e | 2002-02-26 | Marcus Wellhardh | | {
|
a84029 | 2017-06-02 | Pontus Östlund | | locked_modules += ({ q });
continue;
|
e4445e | 2002-02-26 | Marcus Wellhardh | | }
|
17041f | 2000-03-01 | Martin Nilsson | | res += describe_module_compact( q, b );
}
|
f02502 | 2005-12-17 | Jonas Wallden | | } else {
|
17041f | 2000-03-01 | Martin Nilsson | | res += r[1];
|
f02502 | 2005-12-17 | Jonas Wallden | | }
|
17041f | 2000-03-01 | Martin Nilsson | |
master()->set_inhibit_compile_errors( 0 );
return page_base(id,
"<form action=\"add_module.pike\" method=\"post\">"
|
a84029 | 2017-06-02 | Pontus Östlund | | "<roxen-wizard-id-variable />"
|
17041f | 2000-03-01 | Martin Nilsson | | "<input type=\"hidden\" name=\"config\" value=\"&form.config;\" />"+
|
ad2808 | 2000-11-18 | Martin Nilsson | | res+"</select><br /><submit-gbutton> "
|
eabb19 | 2006-01-25 | Anders Johansson | | +LOCALE(200, "Add Modules")+" </submit-gbutton><br />"
|
e4445e | 2002-02-26 | Marcus Wellhardh | | +pafeaw(ec->get(),ec->get_warnings(),
|
a84029 | 2017-06-02 | Pontus Östlund | | locked_modules)+"</form>",
|
17041f | 2000-03-01 | Martin Nilsson | | );
}
|
9ba17a | 2000-03-24 | Per Hedbor | | string decode_site_name( string what )
{
|
a84029 | 2017-06-02 | Pontus Östlund | | if( (int)what )
|
9ba17a | 2000-03-24 | Per Hedbor | | 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 ")+
|
a84029 | 2017-06-02 | Pontus Östlund | |
Roxen.html_encode_string(mi->get_name())
+"</h2></td></tr>"
|
d672ca | 2001-01-29 | Per Hedbor | | "<emit source='module-variables' "
|
a84029 | 2017-06-02 | Pontus Östlund | | " configuration=\""+conf->name+"\""
|
d672ca | 2001-01-29 | Per Hedbor | | " module=\""+mod+#"\"/>
<emit noset='1' source='module-variables' "
|
a84029 | 2017-06-02 | Pontus Östlund | | " 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>
|
06fbff | 2002-09-26 | Anders Johansson | | <tr><td colspan='3'><img src='/internal-roxen-unit' height='18' /></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 )
{
|
a84029 | 2017-06-02 | Pontus Östlund | | 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] )
{
|
a84029 | 2017-06-02 | Pontus Östlund | | report_error(LOCALE(382,"Failed to enable %s")+"\n");
return Roxen.http_redirect( site_url(id,conf->name), id );
}
conf->call_low_start_callbacks( mm,
roxen.find_module( (mod/"!")[0] ),
|
f599d9 | 2000-09-03 | Per Hedbor | | conf->modules[ mod ] );
|
10745b | 2001-01-29 | Per Hedbor | | modules = replace( modules, mod,
|
a84029 | 2017-06-02 | Pontus Östlund | | (already_added[mod]=(mod/"!")[0]+"!"+
(conf->otomod[mm]/"#")[-1]) );
|
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 )
|
79538a | 2002-12-10 | Martin Stjernholm | | conf->call_high_start_callbacks( conf->find_module( replace(mod,"!","#") ),
|
a84029 | 2017-06-02 | Pontus Östlund | | roxen.find_module( (mod/"!")[0] ),
1);
|
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+"' />";
|
a84029 | 2017-06-02 | Pontus Östlund | | } )*"\n"
|
cc75f5 | 2000-10-21 | Martin Nilsson | | +"<input type='hidden' name='config' "
|
a84029 | 2017-06-02 | Pontus Östlund | | "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) {
|
e4345e | 2006-01-19 | Jonas Wallden | | if (conf = roxen.find_configuration( config )) {
|
a115b8 | 2002-03-06 | Henrik Grubbström (Grubba) | | id->variables->config = config;
break;
}
}
|
f599d9 | 2000-09-03 | Per Hedbor | |
|
e0e533 | 2002-08-12 | Henrik Grubbström (Grubba) | | if (!conf) {
|
e165eb | 2002-08-16 | Anders Johansson | | return sprintf(LOCALE(356, "Configuration %O not found."),
|
a84029 | 2017-06-02 | Pontus Östlund | | id->variables->config);
|
e0e533 | 2002-08-12 | Henrik Grubbström (Grubba) | | }
|
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 | |
|
a0dc3f | 2016-02-12 | Henrik Grubbström (Grubba) | | if (!id->variables->config) {
return Roxen.http_redirect("/sites/", id);
}
if( id->variables->module_to_add )
|
f26aee | 2000-01-31 | Per Hedbor | | return do_it( id );
|
a115b8 | 2002-03-06 | Henrik Grubbström (Grubba) | | Configuration conf;
foreach(id->variables->config/"\0", string config) {
|
f02502 | 2005-12-17 | Jonas Wallden | | if (conf = roxen.find_configuration(config)) {
|
a115b8 | 2002-03-06 | Henrik Grubbström (Grubba) | | 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();
|
f02502 | 2005-12-17 | Jonas Wallden | | string method = get_method(id);
if (id->variables->mod_query) {
|
57e6f0 | 2006-02-07 | Jonas Wallden | |
id->set_output_charset && id->set_output_charset("UTF-8");
|
a84029 | 2017-06-02 | Pontus Östlund | |
|
f02502 | 2005-12-17 | Jonas Wallden | |
return (method == "faster" ?
|
a84029 | 2017-06-02 | Pontus Östlund | | page_faster_search(id) :
page_normal_search(id));
|
f02502 | 2005-12-17 | Jonas Wallden | | }
|
a84029 | 2017-06-02 | Pontus Östlund | |
|
d6b1b5 | 2005-12-17 | Jonas Wallden | | return this_object()["page_" + method]( id );
|
f26aee | 2000-01-31 | Per Hedbor | | }
|