function get_pagelinks() { if (!is_object($this->cache)) { $this->cache = new Cache_text('pagelinks'); } if ($this->cache->exists($this->page->name)) { $links = $this->cache->fetch($this->page->name); if ($links !== false) { return $links; } } $links = get_pagelinks($this, $this->page->_get_raw_body()); return $links; }
} set_time_limit(0); $cache = new Cache_Text('pagelinks'); $bc = new Cache_Text('backlinks'); $ii = 1; while (($file = readdir($handle)) !== false) { if (is_dir($DBInfo->text_dir . "/" . $file)) { continue; } $pagename = $DBInfo->keyToPagename($file); print "* [{$ii}] {$pagename} "; $ii++; $p = $DBInfo->getPage($pagename); $formatter->page = $p; $raw = $p->_get_raw_body(); $pagelinks = get_pagelinks($formatter, $raw); $cache->update($pagename, $pagelinks); foreach ($pagelinks as $a) { if (!isset($a[0])) { continue; } $bl = $bc->fetch($a); if (!is_array($bl)) { $bl = array(); } $bl = array_merge($bl, array($pagename)); $bc->update($a, $bl); } print ' ' . count($pagelinks) . "\n"; //if ($ii == 1000) break; }