sub MacroSubst { ... ### 다음 라인 추가 $txt =~ s/\&__LT__;orphanedpages\(([-+])?(\d+)\)\&__GT__;/&MacroOrphanedPages($1, $2)/gei; ### return $txt; }
### 다음 함수를 통채로 추가 sub MacroOrphanedPages { my ($less_or_more, $criterion) = @_; my (@allPages, $page, $pageline, @pages, $id, @x); my %numOfReverse; my $txt; @allPages = &AllPagesList(); foreach $page (@allPages) { $numOfReverse{$page} = 0; } foreach $pageline (&GetFullLinkList("exists=1&sort=0")) { my @links = split(' ', $pageline); my $id = shift(@links); my $link; foreach $link (@links) { $link = (split('/',$id))[0]."$link" if ($link =~ /^\//); next if ($id eq $link); $numOfReverse{$link}++; } } foreach $page (@allPages) { next if (($less_or_more eq "-") && ($numOfReverse{$page} > $criterion)); next if (($less_or_more eq "+") && ($numOfReverse{$page} < $criterion)); next if (($less_or_more eq "") && ($numOfReverse{$page} != $criterion)); $txt .= ".... " if ($page =~ m|/|); $txt .= &GetPageLink($page) . "<br>"; } return $txt; }
Wow, the first comments from a foreigner.. :-)
$criterion is the lexical variable that used in MacroOrphanedPages(). It stores the parameter "number" of <orphanedpage([+|-]number)>. For example, <orphanedpage(2)> prints the list of the pages that have 2 reverse-links. Most frequent parameter may be "0", which makes the macro print the pages with no reverse-link, that is, none of other pages has a link to the page.
I tried to include only sub MacroOrphanedPages (in usemod pachted script for me). I must learn more about your sub MacroSubst. I suppose all this depends of other subs of usemodkr script. (in usemod based script seems works fine without $criterion, isn't it? just including sub MacroOrphanedPages alone - for only orphan purpose).
Yes, i am a foreigner but a wikizen, hehe.
-- http://www.usemod.org/cgi-bin/wiki.pl?JuanmaMP
Thanks!
s/$ISBNPattern/&StoreISBN($1)/geo; s/CD:\s*(\d+)/&StoreHotTrack($1)/geo; s/<orphanedpages>/&MacroOrphanedPages()/gei; # here, or you can choose any appropriate position
sub MacroOrphanedPages { my ($less_or_more, $criterion) = ("", 0); # modify this line my (@allPages, $page, $pageline); # the rest of codes are same as the above code }
Hi, Raymundo:
Rigth, now i understand better ... thanks to:
my ($less_or_more, $criterion) = ("", 0);
it works fine, I like usemodkr because search into DatarDir/link (not always trough &OpenPage($name);
This patch works for me, I patched more subs from usemodkr. ( It's right than any "other patches that this patch depends on"):
- in usemodkr: GetFullLinkList (usemodkr) > GetPageFromFile > GetLinkFile or GetPageLinks if (!status)
- in usemod: GetFullLinkList (usemodkr) > GetPageLinks.
At least, I added in
sub DoOtherRequest {
...
elsif ($action eq 'orphan') {
&DoOrphanList();
...
not in s/<orphanedpages>/&MacroOrphanedPages()/gei;
(I suppose none side effect)
It's all. Thanks.
-- JuanmaMP
i wanted to say:
(">" is "depends on")
- in usemodkr: GetFullLinkList > GetPageFromFile > GetLinkFile or GetPageLinks if (!status)
- in usemod: GetFullLinkList > GetPageLinks.
Maybe, before, it was confused.
-- JuanmaMP