https://bugzilla.wikimedia.org/show_bug.cgi?id=27976
Summary: please correct method "getBaseText()" and
"getSubpageText()" to return the actual name of the
pages
Product: MediaWiki
Version: wikimedia-deployment
Platform: All
OS/Version: All
Status: NEW
Severity: enhancement
Priority: Normal
Component: General/Unknown
AssignedTo: [email protected]
ReportedBy: [email protected]
these two methods has serious problems, because it returns the correct name of
the sub pages and base pages, for exemple
Guia do Linux/Avançado/Personalização do Sistema/Arquivo /etc/profile
the subpage would be correctly defined to "Arquivo /etc/profile" instead of
"profile". In this example, the last "/" is part of the chapter name, which is
"Arquivo /etc/profile", and not a separator. the same goes for base pages.
Note that by default, MediaWiki shows below the title of a page (in a span
inside of the element with id="contentSub") the names of "existing pages above"
each page in a namespace with subpages enabled.
for this reason (with the help of my friend Helder.wiki) made a code that
corrects this failure and expect that we deserve some attention.
here is the code :
/**
* Get the name of the lowest-level parent page which exists and returns
the real subpage or basepage
*
* @return String Base page name or Sub page name
*/
private function CheckExistence($type = null){
if ( !MWNamespace::hasSubpages( $this->mNamespace ) ) {
return $this->getText();
}
$defaultpage = $this->mTextform;
$page = $this->mTextform;
for( $i = 1; $i <= 25; $i++ ){
$pos = strrpos( $page, '/' );
if ( $pos ) {
$page = substr( $page, 0, $pos );
if( Title::newFromText( $page )->exists() ){
switch( $type ){
case 'subpage' :
return (substr( $defaultpage, $pos+1 ));
case 'basepage':
return ($page);
default:
return( $defaultpage);
}
}
}
else{
return( $defaultpage );
}
}
return '';
}
/**
* Get the base name, i.e. the leftmost parts before the /
*
* @return String Base name
*/
public function getBaseText() {
$page = $this->mTextform;
if($this->CheckExistence('basepage')){
return $this->CheckExistence('basepage');
}
return substr( $page, 0, strrpos( $page, '/' ) );
}
/**
* Get the lowest-level subpage name, i.e. the rightmost part after /
*
* @return String Subpage name
*/
public function getSubpageText() {
$page = $this->mTextform;
if($this->CheckExistence('subpage')){
return $this->CheckExistence('subpage');
}
return substr( $page, strrpos( $page, '/' )+1 );
}
This code needs to be added "Title.php" for replace the "getSubpageText()"
getBaseText() "and added the private method "CheckExistence() "
--
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l