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() "
Version: unspecified
Severity: enhancement