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>
|
6647b5 | 2017-06-09 | Pontus Östlund | |
|
10745b | 2001-01-29 | Per Hedbor | |
|
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"),
])
]);
|
bf66c3 | 2018-02-28 | Pontus Östlund | | return Roxen.render_mustache(tmpl, ctx);
|
a84029 | 2017-06-02 | Pontus Östlund | | }
|
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 }) });
}
}
|
468b6c | 2017-10-04 | Pontus Östlund | | string da_string = "",
divider;
|
157724 | 2000-08-19 | Per Hedbor | |
int header_added;
foreach( sort((array)by_module), [string module, array errors] )
{
|
468b6c | 2017-10-04 | Pontus Östlund | | if (divider) {
da_string += divider;
divider = 0;
}
|
157724 | 2000-08-19 | Per Hedbor | | 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"))
|
1a5401 | 2017-07-25 | Pontus Östlund | | if( !header_added++ ) {
|
a84029 | 2017-06-02 | Pontus Östlund | | da_string +=
|
1a5401 | 2017-07-25 | Pontus Östlund | | "<hr><a name='errors_and_warnings'></a>"
"<h3>Compile errors and warnings</h3>"
"<table>";
}
|
157724 | 2000-08-19 | Per Hedbor | |
|
468b6c | 2017-10-04 | Pontus Östlund | | da_string += "<tr>"
"<td colspan='4'>"
"<div class='flex-row'>"
"<div class='flex col-6'>"
|
1a5401 | 2017-07-25 | Pontus Östlund | | + "<b>"
|
468b6c | 2017-10-04 | Pontus Östlund | | + module_name_from_file(module)+"</b></div>"
+ "<div class='flex col-6 text-right'>"
|
157724 | 2000-08-19 | Per Hedbor | | + trim_name(module)
|
468b6c | 2017-10-04 | Pontus Östlund | | + " "+RELOAD(module)+"</div>"
"</div></td></tr>";
|
157724 | 2000-08-19 | Per Hedbor | |
foreach( res, array e )
|
a84029 | 2017-06-02 | Pontus Östlund | | da_string +=
|
468b6c | 2017-10-04 | Pontus Östlund | | "<tr class='valign-top monospace'>"
"<td style='width:30px'> </td>"
"<td class='text-right'>"+e[1]+":</td>"
"<td class='text-right nowrap'>"+ he(e[2])+":</td>"
"<td>"+hc(e[3])+"</td></tr>\n";
|
157724 | 2000-08-19 | Per Hedbor | |
|
468b6c | 2017-10-04 | Pontus Östlund | | divider = "<tr><td colspan='4'><hr></td></tr>";
|
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
|
468b6c | 2017-10-04 | Pontus Östlund | | "<h3>Locked modules</h3>\n"
|
a84029 | 2017-06-02 | Pontus Östlund | | "<p>These modules are locked and can not be enabled because they are "
"not part of the license key for this configuration.</p>\n"
|
468b6c | 2017-10-04 | Pontus Östlund | | "<div class='notify error no-margin-top'>"+
|
a84029 | 2017-06-02 | Pontus Östlund | | (((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 ) {
|
60ecb8 | 2018-03-12 | Pontus Östlund | | if ((m->type & (MODULE_DEPRECATED | MODULE_DEPRECATED_SOFT)) &&
!show_deprecated(id))
{
|
a84029 | 2017-06-02 | Pontus Östlund | | 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 );
|
8f782d | 2017-06-07 | Pontus Östlund | | int hits = 0;
|
157724 | 2000-08-19 | Per Hedbor | | 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;
}
|
8f782d | 2017-06-07 | Pontus Östlund | | hits += 1;
|
ab9b6d | 2000-02-11 | Per Hedbor | | res += describe_module( q, b );
}
|
8f782d | 2017-06-07 | Pontus Östlund | |
if (!hits) {
|
6647b5 | 2017-06-09 | Pontus Östlund | | if (class_visible == class_visible_compact) {
TRACE("Do nothing\n");
}
else {
res +=
"<div class='module no-modules'>"
"<span class='notify info inline'>No available modules</span>"
"</div>";
}
|
8f782d | 2017-06-07 | Pontus Östlund | | }
|
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,
|
60ecb8 | 2018-03-12 | Pontus Östlund | | "deprecated" : (module->type & (MODULE_DEPRECATED | MODULE_DEPRECATED_SOFT))
|
a84029 | 2017-06-02 | Pontus Östlund | | ]);
|
bf66c3 | 2018-02-28 | Pontus Östlund | | return Roxen.render_mustache(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);
|
468b6c | 2017-10-04 | Pontus Östlund | | if (d && !sizeof(String.trim_all_whites(d))) {
d = 0;
}
if (fast && (x || d)) {
content += "<dd>" + (d||" ") + "</dd>";
|
a84029 | 2017-06-02 | Pontus Östlund | | }
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 | | {
|
8f782d | 2017-06-07 | Pontus Östlund | | TRACE("page_normal_low: %O : faster(%O)\n", id, 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) {
|
8f782d | 2017-06-07 | Pontus Östlund | | ret =
"<form method='post' action='add_module.pike'>"
"<input type='hidden' name='config' value='&form.config;'>"
"<roxen-wizard-id-variable/>" +
ret;
|
a84029 | 2017-06-02 | Pontus Östlund | | }
|
468b6c | 2017-10-04 | Pontus Östlund | | if (id->variables->mod_query && !sizeof(desc)) {
ret += sprintf(
"<div class='notify warn'>No modules matching \"%s\" were found</div>",
id->variables->mod_query);
}
|
8f782d | 2017-06-07 | Pontus Östlund | | return ret + desc + "</div>" + (fast ? "</form>" : "") + 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 =
|
8f782d | 2017-06-07 | Pontus Östlund | | "<form id='mod_results' method='post' action='add_module.pike' style='display: none'>"
"</form>"
|
f02502 | 2005-12-17 | Jonas Wallden | | "<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 | | }
|
f02502 | 2005-12-17 | Jonas Wallden | | string page_faster_search(RequestID id)
{
return
"<use file='/template-insert' />\n"
"<tmpl>" +
|
8f782d | 2017-06-07 | Pontus Östlund | | page_normal_low(id, true) +
|
f02502 | 2005-12-17 | Jonas Wallden | | "</tmpl>";
}
string page_faster( RequestID id )
{
string content =
|
6647b5 | 2017-06-09 | Pontus Östlund | | "<form id='mod_results' method='post' action='add_module.pike'"
" style='display: none'></form>"
|
f02502 | 2005-12-17 | Jonas Wallden | | "<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 | | }
|
6647b5 | 2017-06-09 | Pontus Östlund | | int first, skip_select;
|
ab9b6d | 2000-02-11 | Per Hedbor | |
|
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="";
|
6647b5 | 2017-06-09 | Pontus Östlund | |
if (first++ && !skip_select) {
res = "</select><br /><submit-gbutton>" +
LOCALE(200, "Add Modules")+ "</submit-gbutton><hr class='section'>";
}
res += "<h3 id='"+Roxen.html_encode_string(c)+"' class='no-margin-bottom'>"+c+"</h3>"
"<p class='no-margin-top'>"+d+"</p>";
if (size) {
skip_select = false;
res += "<select size='"+size+"' multiple name='module_to_add'"
" class='add-module-select'>";
}
else {
res += "<div class='notify info'>No available modules</div>";
skip_select = true;
}
|
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 | | }
|
6647b5 | 2017-06-09 | Pontus Östlund | |
|
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 = ({});
|
6647b5 | 2017-06-09 | Pontus Östlund | | array(string) mres = ({});
bool deprecated = show_deprecated(id);
mods = filter(mods, lambda (ModuleInfo m) {
|
60ecb8 | 2018-03-12 | Pontus Östlund | | if ((m->type & (MODULE_DEPRECATED | MODULE_DEPRECATED_SOFT)) &&
!deprecated)
{
|
6647b5 | 2017-06-09 | Pontus Östlund | | return 0;
}
if ((!m->get_description() ||
(m->get_description() == "Undocumented")) &&
m->type == 0)
{
return 0;
}
object b = module_nomore(m->sname, m, conf);
if (!b && m->locked &&
(!license_key || !m->unlocked(license_key, conf)))
{
locked_modules += ({ m });
return 0;
}
mres += ({ describe_module_compact(m, b) });
return 1;
});
mres -= ({ "" });
|
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."),
|
6647b5 | 2017-06-09 | Pontus Östlund | | sizeof(mres), id )) && r[0] )
{
res += r[1] + (mres*"");
}
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;\" />"+
|
6647b5 | 2017-06-09 | Pontus Östlund | | res+"</select><p><submit-gbutton> "
+LOCALE(200, "Add Modules")+" </submit-gbutton></p>"
|
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 | |
|
6647b5 | 2017-06-09 | Pontus Östlund | | string tmpl = #"
<div class='initial-module-conf'>
<h3>%s</h3>
<emit source='module-variables' configuration='%s' module='%s'/>
<emit noset='1' source='module-variables'
configuration='%[1]s' module='%[2]s'>
<dl class='config-var'>
<dt class='name small'>&_.name;</dt>
<dd class='value'>
<eval>&_.form:none;</eval>
</dd>
<dd class='doc'>&_.doc:none;</dd>
</dl>
</emit>
</div>";
|
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,"!","#") );
|
6647b5 | 2017-06-09 | Pontus Östlund | |
foreach( indices(moo->query()), string v ) {
if( moo->getvar( v )->get_flags() & VAR_INITIAL ) {
|
f599d9 | 2000-09-03 | Per Hedbor | | num++;
|
6647b5 | 2017-06-09 | Pontus Östlund | |
res +=
sprintf(tmpl,
LOCALE(1,"Initial variables for ") +
Roxen.html_encode_string(mi->get_name()),
conf->name, mod);
|
f599d9 | 2000-09-03 | Per Hedbor | | 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 | | }
|
6647b5 | 2017-06-09 | Pontus Östlund | | return page_base(id,
|
f599d9 | 2000-09-03 | Per Hedbor | | map( modules, lambda( string q ) {
|
6647b5 | 2017-06-09 | Pontus Östlund | | return "<input type='hidden'"
" name='module_to_add'"
" value='"+q+"' />";
|
a84029 | 2017-06-02 | Pontus Östlund | | } )*"\n"
|
cc75f5 | 2000-10-21 | Martin Nilsson | | +"<input type='hidden' name='config' "
|
6647b5 | 2017-06-09 | Pontus Östlund | | "value='"+conf->name+"' />"+cf_form+"<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);
}
|
8f782d | 2017-06-07 | Pontus Östlund | | if( id->variables->module_to_add && !id->variables->reload) {
|
f26aee | 2000-01-31 | Per Hedbor | | return do_it( id );
|
8f782d | 2017-06-07 | Pontus Östlund | | }
|
f26aee | 2000-01-31 | Per Hedbor | |
|
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 | | }
|