Index: Cite.i18n.php =================================================================== --- Cite.i18n.php (revision 41903) +++ Cite.i18n.php (working copy) @@ -44,6 +44,8 @@ 'cite_error_references_no_text' => 'Invalid <ref> tag; no text was provided for refs named $1', 'cite_error_included_ref' => 'Closing </ref> missing for <ref> tag', + 'cite_error_unvisible_ref' => 'Invalid <ref> tag; +unvisible refs must have name and content', /* Output formatting @@ -92,6 +94,7 @@ It is not possible to make a clickable link to this message. "nowiki" is mandatory around [[MediaWiki:Cite references link many format backlink labels]].', 'cite_error_references_no_text' => 'Cite extension. This error occurs when the tag <ref name="something" /> is used with the name-option specified and no other tag specifies a cite-text for this name.', 'cite_error_included_ref' => 'Error message shown if the <ref> tag is unbalanced, that means a <ref> is not followed by a </ref>', + 'cite_error_unvisible_ref' => 'Cite extension. Error message shown if re tag has no name or no content (or both), and visible=no, that means for example <ref visible="no" /> or maybe AAA<ref name="aaa" visible="no"/>', ); /** Aragonese (Aragonés) Index: Cite_body.php =================================================================== --- Cite_body.php (revision 41903) +++ Cite_body.php (working copy) @@ -124,11 +124,11 @@ } } - function guardedRef( $str, $argv, $parser, $default_group=CITE_DEFAULT_GROUP ) { + function guardedRef( $str, $argv, $parser, $default_group=CITE_DEFAULT_GROUP, $defaut_visibility=CITE_DEFAULT_VISIBILITY ) { $this->mParser = $parser; # The key here is the "name" attribute. - list($key,$group) = $this->refArg( $argv ); + list($key,$group,$visible) = $this->refArg( $argv ); if( $str === '' ) { # . This construct is invalid if @@ -180,18 +180,29 @@ $group = $default_group; } + # visibility + if( $visible === null ) { + $visible = $defaut_visibility; + } + + # if there's no key or content, it doesn't make sense not to show the + # reference. + if( $visible === 'no' and ( $key === null or $str === null ) ) { + return $this->error( 'cite_error_unvisible_ref' ); + } + if( is_string( $key ) or is_string( $str ) ) { # We don't care about the content: if the key exists, the ref # is presumptively valid. Either it stores a new ref, or re- # fers to an existing one. If it refers to a nonexistent ref, # we'll figure that out later. Likewise it's definitely valid # if there's any content, regardless of key. - return $this->stack( $str, $key, $group ); + return $this->stack( $str, $key, $group, $visible ); } # Not clear how we could get here, but something is probably # wrong with the types. Let's fail fast. - $this->croak( 'cite_error_key_str_invalid', serialize( "$str; $key" ) ); + $this->croak( 'cite_error_key_str_invalid', serialize( "$str; $key; $visible" ) ); } /** @@ -208,9 +219,10 @@ $cnt = count( $argv ); $group = null; $key = null; + $visible = null; - if ( $cnt > 2 ) - // There should only be one key and one group + if ( $cnt > 3 ) + // There should only be: key, group, visible return false; else if ( $cnt >= 1 ) { if ( isset( $argv['name'] ) ) { @@ -226,16 +238,22 @@ unset( $argv['group']); --$cnt; } + if ( isset( $argv['visible'] ) ) { + // Visible given. + $visible = Sanitizer::escapeId( $argv['visible'] ); + unset( $argv['visible']); + --$cnt; + } if ( $cnt == 0) - return array ($key,$group); + return array ($key,$group,$visible); else // Invalid key - return array(false,false); + return array(false,false,false); } else // No key - return array(null,$group); + return array(null,$group,$visible); } /** @@ -245,7 +263,7 @@ * @param mixed $key Argument to the tag as returned by $this->refArg() * @return string */ - function stack( $str, $key = null, $group ) { + function stack( $str, $key = null, $group, $visible ) { if (! isset($this->mRefs[$group])) $this->mRefs[$group]=array(); if (! isset($this->mGroupCnt[$group])) @@ -268,6 +286,11 @@ 'number' => ++$this->mGroupCnt[$group] ); $this->mInCnt++; + + if( $visible === 'no') { + return ''; + } + return $this->linkRef( $group, @@ -282,6 +305,10 @@ // If no text found before, use this text $this->mRefs[$group][$key]['text'] = $str; }; + if( $visible === 'no') { + return ''; + } + return $this->linkRef( $group, @@ -289,7 +316,8 @@ $this->mRefs[$group][$key]['key']."-".++$this->mRefs[$group][$key]['count'], $this->mRefs[$group][$key]['number'], "-".$this->mRefs[$group][$key]['key'] - ); } + ); + } } else @@ -356,7 +384,7 @@ $ent = array(); foreach ( $this->mRefs[$group] as $k => $v ) $ent[] = $this->referencesFormatEntry( $k, $v ); - + $prefix = wfMsgForContentNoTrans( 'cite_references_prefix' ); $suffix = wfMsgForContentNoTrans( 'cite_references_suffix' ); $content = implode( "\n", $ent ); Index: Cite.php =================================================================== --- Cite.php (revision 41903) +++ Cite.php (working copy) @@ -39,6 +39,7 @@ $wgSpecialPageGroups['Cite'] = 'pagetools'; define( 'CITE_DEFAULT_GROUP', ''); +define( 'CITE_DEFAULT_VISIBILITY', 'yes'); /** * The emergency shut-off switch. Override in local settings to disable * groups; or remove all references from this file to enable unconditionally