Permalink
Browse files

Se corrigieron bugs:

- Se corrigio el nombre de la variable $join_conds.
- Se corrigio el nombre de la variable $database.
- Se cambio el nombre de la tabla 'User' a 'user'.
- Se corrigio el nombre de la clase CommentsFunctions en el
autoloadClass.
- Se agrego la clase Comment al autoloadClass.
- Se movió el CheckDatabase hacia el CommentsParser.
  • Loading branch information...
1 parent 83ce555 commit 3de67a93f341d11510a32a7be4d7db19c155df1e @miguelerm committed Nov 2, 2011
Showing with 56 additions and 68 deletions.
  1. +6 −9 WikiComments.body.php
  2. +6 −48 includes/Comment.php
  3. +1 −1 includes/CommentsDB.php
  4. +38 −9 includes/CommentsFunctions.php
  5. +5 −1 includes/CommentsParser.php
View
@@ -4,14 +4,11 @@
$wgExtensionMessagesFiles['WikiComments'] = $dir . 'WikiComments.i18n.php';
-$wgAutoloadClasses['CommentsFunction'] = $dir . 'includes/CommentsFunctions.php';
-$wgAutoloadClasses['CommentsParser' ] = $dir . 'includes/CommentsParser.php';
-$wgAutoloadClasses['CommentsLanguage'] = $dir . 'includes/CommentsLanguage.php';
-$wgAutoloadClasses['CommentsDB' ] = $dir . 'includes/CommentsDB.php';
+$wgAutoloadClasses['Comment' ] = $dir . 'includes/Comment.php';
+$wgAutoloadClasses['CommentsFunctions'] = $dir . 'includes/CommentsFunctions.php';
+$wgAutoloadClasses['CommentsParser' ] = $dir . 'includes/CommentsParser.php';
+$wgAutoloadClasses['CommentsLanguage' ] = $dir . 'includes/CommentsLanguage.php';
+$wgAutoloadClasses['CommentsDB' ] = $dir . 'includes/CommentsDB.php';
$wgHooks['ParserFirstCallInit'][] = 'CommentsParser::FirstCallInit';
-$wgHooks['LanguageGetMagic'][] = 'CommentsLanguage::GetMagic';
-
-//CheckDatabase verifica si las tablas requeridas se encuentran en la base
-//de datos, de lo contrario las crea.
-CommentsDB::CheckDatabase();
+$wgHooks['LanguageGetMagic'][] = 'CommentsLanguage::GetMagic';
View
@@ -149,15 +149,15 @@ static public function getApproved($articleId){
global $wgDBprefix;
- $tables = array( $wgDBprefix . "WikiComments", $wgDBprefix . "User" );
- $fields = array( 'id', 'article_id', '`User`.`user_id`', 'text', 'UNIX_TIMESTAMP(creation_date) AS timestamp', 'parent_id', 'user_ip', 'user_name', 'user_real_name' );
+ $tables = array( "${wgDBprefix}WikiComments", "${wgDBprefix}user" );
+ $fields = array( 'id', 'article_id', "`${wgDBprefix}user`.`user_id`", 'text', 'UNIX_TIMESTAMP(creation_date) AS timestamp', 'parent_id', 'user_ip', 'user_name', 'user_real_name' );
$conds = array('article_id' => $articleId);
- $join_conds = array('WikiComments' => array('INNER JOIN', '`User`.`user_id` = `WikiComments`.`user_id`'));
+ $join_conds = array('WikiComments' => array('INNER JOIN', "`${wgDBprefix}user`.`user_id` = `${wgDBprefix}WikiComments`.`user_id`"));
$options['ORDER BY'] = 'parent_id ASC, creation_date DESC';
- $database =& wfGetDB( DB_SLAVE );
+ $database = wfGetDB( DB_SLAVE );
- $result = $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $joinConds );
+ $result = $database->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds );
$comments = array();
$commentsToReturn = array();
@@ -190,47 +190,5 @@ static public function getNotApproved(){
return null;
}
- static public function renderList(&$parser){
-
- global $wgTitle;
-
- $comments = Comment::getApproved($wgTitle->getArticleID());
-
- $content = '';
- $content .= '<div class="listaComentarios">';
-
- if(count($comments) > 0){
-
- $content .= '<ul>';
- foreach ($comments as $comment)
- {
- $content .= Comment::getCommentHtml($comment);
- }
- $content .= '</ul>';
- }
- else{
- $content .= '<span>No existe ning&uacute;n comentario para este art&iacute;culo.</span>';
- }
-
- return $content;
-
- }
-
- static private function getCommentHtml(Comment $comment){
- $content = '';
- $content .= '<li>';
- $content .= '<strong>' . $comment->getUserRealName() . '</strong> <em>' . date(DATE_RFC822, $comment->getDate()) . '</em>: <span>' . $comment->getText() . '</span>';
-
- if ($comment->hasChildComments()) {
- $content .= '<ul>';
-
- foreach ($comment->getChildComments() as $childComment)
- $content .= Comment::getCommentHtml($childComment);
-
- $content .= '</ul>';
- }
-
- $content .= '</li>';
- }
-
+
}
View
@@ -9,7 +9,7 @@ static function CheckDatabase(){
global $wgDBprefix;
- $dbr =& wfGetDB( DB_SLAVE );
+ $dbr = wfGetDB( DB_SLAVE );
// Check if 'WikiComments' database tables exists
if (!$dbr->tableExists('WikiComments'))
@@ -40,19 +40,48 @@ function renderForm(&$parser){
}
- function renderList(&$parser){
+ public function renderList(&$parser){
+
+ global $wgTitle;
+
+ $comments = Comment::getApproved($wgTitle->getArticleID());
+ $content = '';
$content .= '<div class="listaComentarios">';
- $content .= '<h3>Comentarios:</h3>';
- $content .= '<div class="comentario">';
- $content .= '<strong>Fulanito</strong> dijo el ' . date(DATE_RFC822) . ': <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sollicitudin aliquet lacus, id malesuada enim.</span>';
- $content .= '</div>';
- $content .= '<div class="comentario">';
- $content .= '<strong>Fulanito 2</strong> dijo el ' . date(DATE_RFC822) . ': <span>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Morbi sollicitudin aliquet lacus, id malesuada enim.</span>';
- $content .= '</div>';
- $content .= '</div>';
+
+ if(count($comments) > 0){
+
+ $content .= '<ul>';
+ foreach ($comments as $comment)
+ {
+ $content .= Comment::getCommentHtml($comment);
+ }
+ $content .= '</ul>';
+ }
+ else{
+ $content .= '<span>No existe ning&uacute;n comentario para este art&iacute;culo.</span>';
+ }
return $content;
+
}
+
+ private function getCommentHtml(Comment $comment){
+ $content = '';
+ $content .= '<li>';
+ $content .= '<strong>' . $comment->getUserRealName() . '</strong> <em>' . date(DATE_RFC822, $comment->getDate()) . '</em>: <span>' . $comment->getText() . '</span>';
+
+ if ($comment->hasChildComments()) {
+ $content .= '<ul>';
+
+ foreach ($comment->getChildComments() as $childComment)
+ $content .= Comment::getCommentHtml($childComment);
+
+ $content .= '</ul>';
+ }
+
+ $content .= '</li>';
+ }
+
}
@@ -7,7 +7,11 @@ static function FirstCallInit(){
$commentsFunction = new CommentsFunctions();
$wgParser->setFunctionHook('commentsform', array( &$commentsFunction, 'renderForm' ));
- $wgParser->setFunctionHook('commentslist', 'Comment::renderList');
+ $wgParser->setFunctionHook('commentslist', array( &$commentsFunction, 'renderList'));
+
+ //CheckDatabase verifica si las tablas requeridas se encuentran en la base
+ //de datos, de lo contrario las crea.
+ CommentsDB::CheckDatabase();
return true;

0 comments on commit 3de67a9

Please sign in to comment.