* @param $options mixed String or array of strings:
* 'known': Page is known to exist, so don't check if it does.
* 'broken': Page is known not to exist, so don't check if it does.
- * 'noclasses': Don't add any classes automatically (includes "new", "stub", "mw-redirect"). Only use the class attribute provided, if any.
+ * 'noclasses': Don't add any classes automatically (includes "new",
+ * "stub", "mw-redirect"). Only use the class attribute provided, if
+ * any.
* @return string HTML <a> attribute
*/
public function link( $target, $text = null, $customAttribs = array(), $query = array(), $options = array() ) {
$query['action'] = 'edit';
$query['redlink'] = '1';
}
-
- return $target->getLocalURL( wfArrayToCGI( $query ) );
+ $ret = $target->getLocalURL( $query );
+ if( $target->getFragment() !== '' ) {
+ $ret .= '#'.$target->getFragment();
+ }
+ return $ret;
}
private function linkAttribs( $target, $attribs, $options ) {
$sectionTitle = Title::newFromText( '#' . $section);
} else {
$sectionTitle = wfClone( $title );
- $sectionTitle->mFragment = $section;
+ $sectionTitle->setFragment( $section );
}
$link = $this->link( $sectionTitle, wfMsgForContent( 'sectionlink' ) );
}
* Get a real URL referring to this title, with interwiki link and
* fragment
*
- * @param string $query an optional query string, not used
- * for interwiki links
+ * @param array $query an optional query string, not used for interwiki
+ * links. Can be specified as an associative array as well, e.g.,
+ * array( 'action' => 'edit' ) (keys and values will be URL-escaped).
* @param string $variant language variant of url (for sr, zh..)
* @return string the URL
*/
public function getFullURL( $query = '', $variant = false ) {
global $wgContLang, $wgServer, $wgRequest;
+ if( is_array( $query ) ) {
+ $query = wfArrayToCGI( $query );
+ }
+
if ( '' == $this->mInterwiki ) {
$url = $this->getLocalUrl( $query, $variant );
/**
* Get a URL with no fragment or server name. If this page is generated
* with action=render, $wgServer is prepended.
- * @param string $query an optional query string; if not specified,
- * $wgArticlePath will be used.
+ * @param mixed $query an optional query string; if not specified,
+ * $wgArticlePath will be used. Can be specified as an associative array
+ * as well, e.g., array( 'action' => 'edit' ) (keys and values will be
+ * URL-escaped).
* @param string $variant language variant of url (for sr, zh..)
* @return string the URL
*/
global $wgArticlePath, $wgScript, $wgServer, $wgRequest;
global $wgVariantArticlePath, $wgContLang, $wgUser;
+ if( is_array( $query ) ) {
+ $query = wfArrayToCGI( $query );
+ }
+
// internal links should point to same variant as current page (only anonymous users)
if($variant == false && $wgContLang->hasVariants() && !$wgUser->isLoggedIn()){
$pref = $wgContLang->getPreferredVariant(false);