public static function convertInternalLinks($wiki, $page, $content) { $masks = sfConfig::get('app_nahoWikiPlugin_internal_links', array('[[%name% %title%]]', '[[%name%]]')); $pcre_masks = array('name' => nahoWikiPagePeer::pageNameFormat() . '(?:#[A-Za-z0-9_\\-]+)?', 'title' => '.*?'); $replaces = self::extractLinkReplacements($content, $masks, $pcre_masks); // Extract names and complete the replacements array $names = array(); $controller = sfContext::getInstance()->getController(); foreach ($replaces as &$replace) { // Full name $replace['name'] = $page->resolveAbsoluteName($replace['name']); // Title if (!$replace['title']) { $replace['title'] = nahoWikiPagePeer::getBasename($replace['name']); } // Link $url = '@wiki_view?slug=' . $wiki . '&page=' . $replace['name']; if (@$replace['anchor']) { $url .= '#' . $replace['anchor']; } $replace['link'] = $controller->genUrl($url, false); // Store name $names[] = $replace['name']; } // Find all existing pages $existing_page = array(); $pages = nahoWikiPagePeer::retrieveByNames($names); foreach ($pages as $page) { $existing_page[$page->getName()] = true; } $link_model = sfConfig::get('app_nahoWikiPlugin_internal_link_model', '[%title%](%link%)'); $broken_link_model = sfConfig::get('app_nahoWikiPlugin_internal_link_broken_model', '[%title%(?)](%link%)'); return self::makeLinkReplacements($content, $replaces, $link_model, $existing_page, $broken_link_model); }