Permalink
Browse files

some work on dykbox

  • Loading branch information...
1 parent 879f81c commit f86b5314b40f83cb2772cd65ff10a455d8763423 @JeroenDeDauw committed May 6, 2012
Showing with 41 additions and 0 deletions.
  1. +41 −0 includes/DYKBox.php
View
@@ -31,6 +31,15 @@ public function getHTML() {
$html .= $this->msg( 'didyouknow-header' )->escaped();
+ $title = $this->getArticleTitle();
+
+ if ( $title === false ) {
+ return 'TODO'; // TODO
+ }
+ else {
+ $html .= $this->getArticleContent( $title );
+ }
+
$html = Html::rawElement(
'div',
array( 'class' => 'didyouknow' ),
@@ -51,4 +60,36 @@ public function display() {
$this->getOutput()->addModules( $this->getModules() );
}
+ /**
+ * @param Title $title
+ *
+ * @return string
+ */
+ protected function getArticleContent( Title $title ) {
+ $article = new Article( $title, 0 );
+ $content = $article->fetchContent();
+ return is_string( $content ) ? $content : '';
+ }
+
+ /**
+ * @return Title|false
+ */
+ protected function getArticleTitle() {
+ $titles = array();
+
+ if ( $this->specificCategory !== false ) {
+ $titles = $this->getArticlesInCategory( $this->specificCategory );
+ }
+
+ if ( empty( $titles ) ) {
+ $titles = $this->getArticlesInCategory( $this->mainCategory );
+ }
+
+ return empty( $titles ) ? false : $titles[array_rand( $titles )];
+ }
+
+ protected function getArticlesInCategory( $categoryName ) {
+
+ }
+
}

0 comments on commit f86b531

Please sign in to comment.