/** * Get link for a page in the wiki * * @param string $text text of the link (if null, we create it from the pagename+revision) * @param string $page_name * @param array $options params added to the link (you can add a 'revision' option to specifiy the revision of the page you want to link to) * * @return string */ function link_to_wiki($text, $page_name, $options = array()) { $url = 'nahoWiki/view?page=' . $page_name; if (isset($options['revision'])) { $url .= '&revision=' . $options['revision']; } if (is_null($text)) { $text = htmlspecialchars(nahoWikiPagePeer::getBasename($page_name)); if (isset($options['revision'])) { $text .= ' rev. ' . $options['revision']; } } return link_to($text, $url, $options); }
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); }
public function getBasename($page_name = null) { return nahoWikiPagePeer::getBasename($this->getName()); }