.
*
* @file
* @ingroup Skins
*/
namespace Skins\Chameleon\Components;
use Skins\Chameleon\IdRegistry;
/**
* The MainContent class.
*
* @author Stephan Gambke
* @since 1.0
* @ingroup Skins
*/
class MainContent extends Component {
/**
* Builds the HTML code for this component
*
* @return String the HTML code
*/
public function getHtml() {
$skintemplate = $this->getSkinTemplate();
$idRegistry = IdRegistry::getRegistry();
// START content
$ret =
$this->indent() . '' .
$this->indent() . $idRegistry->openElement( 'div',
array( 'id' => 'content', 'class' => 'mw-body ' . $this->getClassString() )
) .
$idRegistry->element( 'a', array( 'id' => 'top' ) ) .
$this->indent(1) . $idRegistry->element( 'div', array( 'id' => 'mw-indicators', 'class' => 'mw-indicators', ), $this->buildMwIndicators() ) .
$this->indent() . '
$idRegistry->getId( 'mw-js-message' ),
'style' => 'display:none;'
)
) . $skintemplate->get( 'userlangattributes' ) . '>
';
$ret .= $this->buildContentHeader();
// if ( $skintemplate->get( 'subtitle' ) ) {
// TODO: should not use class 'small', better use class 'contentSub' and do styling in a less file
$ret .=
$this->indent() . '' .
$this->indent() . $idRegistry->element( 'div', array( 'id' => 'contentSub', 'class' => 'small' ), $skintemplate->get( 'subtitle' ) );
// }
if ( $skintemplate->get( 'undelete' ) ) {
// TODO: should not use class 'small', better use class 'contentSub2' and do styling in a less file
$ret .=
$this->indent() . '' .
$this->indent() . $idRegistry->element( 'div', array( 'id' => 'contentSub2', 'class' => 'small' ), $skintemplate->get( 'undelete' ) );
}
$ret .= $this->buildContentBody();
$ret .= $this->buildCategoryLinks();
$ret .= $this->indent( -1 ) . '';
// END content
return $ret;
}
/**
* @return string
*/
protected function buildContentHeader() {
$skintemplate = $this->getSkinTemplate();
$idRegistry = IdRegistry::getRegistry();
$ret = $this->indent() . '';
return $ret;
}
/**
* @return string
*/
protected function buildContentBody() {
return $this->indent() . IdRegistry::getRegistry()->element( 'div', array( 'id' => 'bodyContent' ),
$this->indent( 1 ) . '' . "\n" .
$this->indent() . $this->getSkinTemplate()->get( 'bodytext' ) .
$this->indent() . '' .
$this->buildDataAfterContent() .
$this->indent( -1 )
);
}
/**
* @return string
*/
protected function buildCategoryLinks() {
// TODO: Category links should be a separate component, but
// * dataAfterContent should come after the the category links.
// * only one extension is known to use it dataAfterContent and it is geared specifically towards MonoBook
// => provide an attribute hideCatLinks for the XML and -if present- hide category links and assume somebody knows what they are doing
return
$this->indent() . '' .
$this->indent() . $this->getSkinTemplate()->get( 'catlinks' );
}
/**
* @return string
*/
protected function buildDataAfterContent() {
$skinTemplate = $this->getSkinTemplate();
if ( $skinTemplate->get( 'dataAfterContent' ) ) {
return
$this->indent() . '' .
$this->indent() . $skinTemplate->get( 'dataAfterContent' );
}
return '';
}
/**
* @return string
*/
private function buildMwIndicators() {
$idRegistry = IdRegistry::getRegistry();
$indicators = $this->getSkinTemplate()->get( 'indicators' );
if ( !is_array( $indicators ) || count( $indicators ) === 0 ) {
return '';
}
$this->indent( 1 );
$ret = '';
foreach ( $indicators as $id => $content ) {
$id = \Sanitizer::escapeId( "mw-indicator-$id" );
$ret .=
$this->indent() .
$idRegistry->element( 'div',
array(
'id' => $id,
'class' => "mw-indicator $id",
),
$content
);
}
$ret .= $this->indent( -1 );
return $ret;
}
}