populate related PTVs

master
Fabien Benetou 14 years ago committed by utopiah
parent 47be424726
commit 92f5bd949d
  1. 22
      cookbook/groupkeypages.php

@ -2,11 +2,17 @@
# return the "key pages" of a group # return the "key pages" of a group
# todo # todo
# explicit importance via PTVs
# existing PTVs startrecall, recall, startprepare, ... (cf MemoryHandling)
# dedicated PTV
# http://phpir.com/pagerank-in-php # http://phpir.com/pagerank-in-php
# http://faculty.ucr.edu/~hanneman/nettext/C10_Centrality.html#Betweenness # http://faculty.ucr.edu/~hanneman/nettext/C10_Centrality.html#Betweenness
# check if isset() really is necessary, seems it was avoided in Coeditions # check if isset() really is necessary, seems it was avoided in Coeditions
# transform as an extension of http://www.pmwiki.org/wiki/PmWiki/CustomPagelistSortOrder
# would produce much better integration
function GroupKeyPages($groupname,$selectionmechanism=""){ function GroupKeyPages($groupname,$selectionmechanism=""){
# XXX if the groupname does not exist then should return an empty array
$pages = ListPages("/$groupname\./e"); $pages = ListPages("/$groupname\./e");
//note that this could be replaced by proper ListPages call //note that this could be replaced by proper ListPages call
@ -24,14 +30,25 @@ function GroupKeyPages($groupname,$selectionmechanism=""){
break; break;
default: default:
$keypages = NetworkDegree($b,8); # degree threshold $keypages = NetworkDegree($b,8); # degree threshold
} } # XXX none of those methods leverage PTVs so far
return array_unique($keypages); return array_unique($keypages);
} }
function GenerateNetworkFromList($pagelist){ function GenerateNetworkFromList($pagelist){
$b = array();
foreach ($pagelist as $page) { foreach ($pagelist as $page) {
$content = ReadPage($page,$since=0); //$content = ReadPage($page,$since=0);
$content = ReadPage($page,READPAGE_CURRENT);
# check if it has PTVs :
$relatedPTVs = array( "startrecall", "recall", "startprepare" );
foreach ($relatedPTVs as $PTV){
# if so, add the value
$PTV_value = PageTextVar($page,$PTV);
if ($PTV_value) {
$b["$page"]["$PTV"] = $PTV_value;
}
} # XXX somehow seems to parse the list of pages twice
$links = $content["targets"]; $links = $content["targets"];
$links_array = explode(",",$links); $links_array = explode(",",$links);
foreach ($links_array as $link) { foreach ($links_array as $link) {
@ -122,6 +139,7 @@ function GroupDegreeDistribution($groupname){
$pages = CleanPageList($pages,$groupname); $pages = CleanPageList($pages,$groupname);
$b = GenerateNetworkFromList($pages); $b = GenerateNetworkFromList($pages);
if (empty($b)) return array();
$distribution = array_fill(1,10,0); $distribution = array_fill(1,10,0);
// has no effect // has no effect

Loading…
Cancel
Save