A proposed function to replace ednsection, a subroutine of Everything Developer, in order to make it useable within other nodelets. The changes made are minor, and are marked with bold text.
my ($pref,$field) = @_;
my $param = $pref.'_hide'.$field;
my $v;
if(defined ($v=$query->param($param))) {
if($v) {
$$VARS{$param}=1; #previously: $$VARS{$param}=$v;
} else {
$$VARS{$param}=0; #why doesn't this work: delete $$VARS{$param};
}
}
if($$VARS{$param}) {
return '('.linkNode($NODE, 'show '.$field, {$param => 0}).')<br />';
} else {
return '('.linkNode($NODE,'hide',{$param => 1}).") <b>$field</b><br />"
.htmlcode($pref."section_$field",'');
}
Implementing this in the Everything Developer nodelet should require only the following changes, and would keep it fully compatible with every user's current open/close preferences:
11: .htmlcode('nodeletsection','edn','edev');
12: $str.=htmlcode('nodeletsection','edn','cgiparam')
13: .htmlcode('nodeletsection','edn','everydevel')
14: .htmlcode('nodeletsection','edn','documents');
15: $str.= '<br />'.htmlcode('nodeletsection','edn','globals');
With these changes, the nodeletsection function could be easily and cleanly integrated into other nodelets without adding unnecessary code.
N-Wing says: this part is done; due to the way htmlcodes are called, however, the 2nd argument should be a text string, with each argument separated by commas (for example: htmlcode('nodeletsection','edn,edev') instead of (bad) htmlcode('nodeletsection','edn','edev')