Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Little optimization to delete one if condition.

  • Loading branch information...
commit 7c53b6d7e339627e41a729bc701acb101a9b43e9 1 parent 6cd0f5d
@i02sopop i02sopop authored
Showing with 5 additions and 14 deletions.
  1. +5 −14 lib/Lampcms/Answers.php
View
19 lib/Lampcms/Answers.php
@@ -67,7 +67,6 @@
*/
class Answers extends LampcmsObject
{
-
/**
* Mongo cursor
*
@@ -75,12 +74,10 @@ class Answers extends LampcmsObject
*/
protected $Cursor;
-
public function __construct(Registry $Registry){
$this->Registry = $Registry;
}
-
/**
* Get html div with answers for this one question,
* sorted according to param passed in request
@@ -118,9 +115,8 @@ public function getAnswers(Question $Question, $result = 'html'){
* anything in Mongo methods directly from
* user input
*/
- if(!in_array($cond, array('i_ts', 'i_votes', 'i_lm_ts'))){
+ if(!in_array($cond, array('i_ts', 'i_votes', 'i_lm_ts')))
throw new Exception('invalid value of param "cond" was: '.$cond);
- }
$where = array('i_qid' => $qid);
if(!$this->Registry->Viewer->isModerator()){
@@ -150,7 +146,6 @@ public function getAnswers(Question $Question, $result = 'html'){
'append' => false)); //, 'fileName' => '&pageID=%d'
$pagerLinks = $oPager->getLinks();
-
$func = null;
$ownerId = $Question['i_uid'];
$showLink = (($ownerId > 0) && ($this->Registry->Viewer->isModerator() || $ownerId == $this->Registry->Viewer->getUid()) );
@@ -173,13 +168,10 @@ public function getAnswers(Question $Question, $result = 'html'){
* Don't show Accept link for
* already accepted answer
*/
- if(!($a['accepted'])){
- if($showLink){
- $a['accept_link'] = '<a class="accept ttt" title="'.$alt.'" href="/accept/'.$a['_id'].'">'.$accept.'</a>';
- }
- } else {
- $a['accepted'] = '<img src="/images/accepted.png" alt="Best answer" class="ttt" title="'.$alt2.'">';
- }
+ if(($a['accepted']))
+ $a['accepted'] = '<img src="/images/accepted.png" alt="Best answer" class="ttt" title="'.$alt2.'">';
+ else if($showLink)
+ $a['accept_link'] = '<a class="accept ttt" title="'.$alt.'" href="/accept/'.$a['_id'].'">'.$accept.'</a>';
$a['add_comment'] = $addcomment;
$a['nocomments'] = $noComments;
@@ -195,6 +187,5 @@ public function getAnswers(Question $Question, $result = 'html'){
$answers = \tplAnswer::loop($cursor, true, $func).$pagerLinks;
return $answers;
-
}
}
Please sign in to comment.
Something went wrong with that request. Please try again.