'./', 'text' => 'Advanced Customization', }); my $err = sub { $title = "Error"; $body = shift; return; }; my $pub = LJ::S2::get_public_layers(); my $id; if ($GET{'id'} =~ /^\d+$/) { # numeric $id = $GET{'id'}; } elsif ($GET{'id'}) { # redist_uniq $id = $pub->{$GET{'id'}}->{'s2lid'}; } my $dbr = LJ::get_db_reader(); my $remote = LJ::get_remote(); # show the public layers unless ($id) { $title = "Public Layers"; my %layerinfo; my @to_load = grep { /^\d+$/ } keys %$pub; LJ::S2::load_layer_info(\%layerinfo, \@to_load); my $recurse = sub { my $self = shift; my $lid = shift; # layer id my $lay = $pub->{$lid}; return unless $lay; # set to true if the layer is not core and is not a layout my $is_child = $lay->{'type'} ne 'core' && $lay->{'type'} ne 'layout'; my $typedes = " ($lay->{'type'}" . (! $is_child ? ": $lid" : '') . ")"; # show link to detailed view $body .= "
  • " . LJ::ehtml($layerinfo{$lid}->{'name'}); $body .= "$typedes
  • "; # done unless there are children to recurse through return unless ! $is_child && $lay->{'children'}; # if we're not expanding these children, stop and show a link if ($lay->{'type'} eq 'layout' && $GET{'expand'} != $lid) { $body .= ""; return; } # expand children $body .= ""; return; }; # iterate through core layers $body .= ""; return; } ### details on a specific layer ### my $xlink = sub { my $r = shift; $$r =~ s/\[class\[(\w+)\]\]/$1<\/a>/g; $$r =~ s/\[method\[(.+?)\]\]/$1<\/a>/g; $$r =~ s/\[function\[(.+?)\]\]/$1<\/a>/g; $$r =~ s/\[member\[(.+?)\]\]/$1<\/a>/g; }; # load layer info my $layer = defined $pub->{$id} ? $pub->{$id} : LJ::S2::load_layer($id); return $err->("The specified layer does not exist.") unless $layer; my $layerinfo = {}; LJ::S2::load_layer_info($layerinfo, [ $id ]); my $srcview = exists $layerinfo->{$id}->{'source_viewable'} ? $layerinfo->{$id}->{'source_viewable'} : undef; # do they have access? my $isadmin = !defined $pub->{$id} && # public styles are pulled from the system (LJ::check_priv($remote, 'canview', 'styles') || # account, so we don't want to check privileges LJ::check_priv($remote, 'canview', '*')); # in case they're private styles return $err->("You are not authorized to view this layer.") unless defined $pub->{$id} || $srcview == 1 || LJ::can_manage($remote, $layer->{'userid'}) || $isadmin; LJ::S2::load_layers($id); my $s2info = S2::get_layer_all($id); my $class = $s2info->{'class'} || {}; my $xlink_args = sub { my $r = shift; return unless $$r =~ /^(.+?\()(.*)\)$/; my ($new, @args) = ($1, split(/\s*\,\s*/, $2)); foreach (@args) { s/^(\w+)/defined $class->{$1} ? "[class[$1]]" : $1/eg; } $new .= join(", ", @args) . ")"; $$r = $new; $xlink->($r); }; $body .= "
    "; # link to layer list if this is a public layer, otherwise user's layer list if (defined $pub->{$id}) { $body .= BML::ml('Backlink', { 'link' => 'layerbrowse.bml', 'text' => 'Public Layers' }) . "\n"; } else { $body .= BML::ml('Backlink', { 'link' => "layers.bml", 'text' => 'Your Layers' }) . "\n"; $body .= BML::ml('Actionlink', { 'link' => "
    Edit Layer" }) . "\n"; } if ($layer->{'b2lid'}) { $body .= "[{'b2lid'}\">Parent Layer]\n"; } if (defined $pub->{$id} && (! defined $srcview || $srcview != 0) || $srcview == 1 || LJ::can_manage($remote, $layer->{'userid'}) || $isadmin) { $body .= "[Download]\n"; $body .= "[View as HTML]\n"; } # layerinfo if (my $info = $s2info->{'info'}) { $body .= ""; $body .= ""; foreach my $k (sort keys %$info) { my ($ek, $ev) = map { LJ::ehtml($_) } ($k, $info->{$k}); $title = $ev if $k eq "name"; $body .= "\n"; } $body .= "
    $ek$ev
    "; } # sets if (my $set = $s2info->{'set'}) { $body .= ""; $body .= ""; foreach my $k (sort keys %$set) { my $v = $set->{$k}; if (ref $v eq "HASH") { if ($v->{'_type'} eq "Color") { $v = "{'as_string'}\"> $v->{'as_string'}"; } else { $v = "[unknown object type]"; } } elsif (ref $v eq "ARRAY") { $v = "List: (" . join(", ", map { LJ::ehtml($_) } @$v) . ")"; } else { $v = LJ::ehtml($v); } $body .= "\n"; } $body .= "
    $k$v
    "; } # global functions my $gb = $s2info->{'global'}; if (ref $gb eq "HASH" && %$gb) { $body .= ""; $body .= ""; foreach my $fname (sort keys %$gb) { my $rt = $gb->{$fname}->{'returntype'}; if (defined $class->{$rt}) { $rt = "[class[$rt]]"; } $xlink->(\$rt); my $ds = LJ::ehtml($gb->{$fname}->{'docstring'}); $xlink->(\$ds); my $args = $gb->{$fname}->{'args'}; $xlink_args->(\$args); $body .= ""; } $body .= "
    $args : $rt$ds
    "; } if (%$class) { # class index $body .= ""; $body .= ""; $body .= ""; $body .= "
    Alphabetical"; $body .= "
      "; foreach my $cname (sort { lc($a) cmp lc($b) } keys %$class) { $body .= "
    • $cname
    • \n"; } $body .= "
    "; $body .= "
    Hierarchical"; my $dumpsub = sub { my $self = shift; my $parent = shift; $body .= "
  • $parent
  • \n" if $parent; my $didul = 0; foreach my $cname (sort { lc($a) cmp lc($b) } keys %$class) { next unless $class->{$cname}->{'parent'} eq $parent; unless ($didul++) { $body .= "
      "; } $self->($self, $cname); } if ($didul) { $body .= "
    "; } }; $dumpsub->($dumpsub, ""); $body .= "
    "; # classes foreach my $cname (sort { lc($a) cmp lc($b) } keys %$class) { $body .= ""; my $ds = LJ::ehtml($class->{$cname}->{'docstring'}); if ($class->{$cname}->{'parent'}) { $ds = "Child class of [class[$class->{$cname}->{'parent'}]]. $ds"; } if ($ds) { $xlink->(\$ds); $body .= ""; } # build functions & methods my (%func, %var); my $add = sub { my ($self, $aname) = @_; foreach (keys %{$class->{$aname}->{'funcs'}}) { $func{$_} = $class->{$aname}->{'funcs'}->{$_}; $func{$_}->{'_declclass'} = $aname; } foreach (keys %{$class->{$aname}->{'vars'}}) { $var{$_} = $class->{$aname}->{'vars'}->{$_}; $var{$_}->{'_declclass'} = $aname; } my $parent = $class->{$aname}->{'parent'}; $self->($self, $parent) if $parent; }; $add->($add, $cname); $body .= "" if %var; foreach (sort keys %var) { my $type = $var{$_}->{'type'}; $type =~ s/(\w+)/defined $class->{$1} ? "[class[$1]]" : $1/eg; $xlink->(\$type); my $ds = LJ::ehtml($var{$_}->{'docstring'}); $xlink->(\$ds); if ($var{$_}->{'readonly'}) { $ds = "(Read-only) $ds"; } $body .= ""; } $body .= "
    $type $_$ds
    " if %var; $body .= "" if %func; foreach (sort keys %func) { my $rt = $func{$_}->{'returntype'}; if (defined $class->{$rt}) { $rt = "[class[$rt]]"; } $xlink->(\$rt); my $ds = LJ::ehtml($func{$_}->{'docstring'}); $xlink->(\$ds); my $args = $_; $xlink_args->(\$args); $body .= ""; } $body .= "
    $args : $rt$ds
    " if %func; } } return; } _code?> body=> page?>