/** * Load our item and do our thing */ public function submit($data) { $id = $data['item']; $dbr = wfGetDB(DB_SLAVE); $row = $dbr->selectRow('moodbar_feedback', '*', array('mbf_id' => $id), __METHOD__); if (!$row) { return wfMessage('moodbar-invalid-item')->parse(); } $feedbackItem = MBFeedbackItem::load($row); $this->manipulateItem($feedbackItem, $data); return true; }
function formatRow($row) { $out = ''; $data = MBFeedbackItem::load($row); $outData = null; foreach (SpecialMoodBar::$fields as $field) { $outData = MoodBarFormatter::getHTMLRepresentation($data, $field); $out .= Xml::tags('td', null, $outData); } $out = Xml::tags('tr', $this->getRowAttrs($row), $out) . "\n"; return $out; }
protected function outputRow($fh, $row) { //if there is an exception when setting this single record //record it so it won't stop the outputting of other records try { $item = MBFeedbackItem::load($row); $user = User::newFromRow($row); $outData = array(); foreach ($this->fields as $field) { $outData[] = MoodBarFormatter::getInternalRepresentation($item, $field); } } catch (Exception $e) { $outData[] = wfMessage('moodbar-feedback-load-record-error')->escaped(); } fputcsv($fh, $outData); }
/** * Format a single list item from a database row. * @param $row Database row object * @param $params An array of flags. Valid flags: * * admin (user can show/hide feedback items) * * show-anyway (user has asked to see this hidden item) * @param $response An array of response for feedback * @return string HTML */ public static function formatListItem($row, $params = array(), $response = array()) { global $wgLang, $wgUser; $classes = array('fbd-item'); $toolLinks = array(); //in case there is an error constructing the feedbackitem object, //we don't want to throw an error for the entire page. try { $feedbackItem = MBFeedbackItem::load($row); } catch (Exception $e) { $classes = Sanitizer::encodeAttribute(implode(' ', $classes)); $error_message = wfMessage('moodbar-feedback-load-record-error')->escaped(); return <<<HTML \t\t\t<li class="{$classes}"> \t\t\t\t<div class="fbd-item-message" dir="auto">{$error_message}</div> \t\t\t\t<div style="clear:both"></div> \t\t\t</li> HTML; } // Type $type = $feedbackItem->getProperty('type'); $typeMsg = wfMessage("moodbar-type-{$type}")->params($feedbackItem->getProperty('user'))->escaped(); // Timestamp $timestamp = wfTimestamp(TS_UNIX, $feedbackItem->getProperty('timestamp')); $timeMsg = wfMessage('ago')->params(MoodBarUtil::formatTimeSince($timestamp))->escaped(); // Comment $comment = htmlspecialchars($feedbackItem->getProperty('comment')); // User information $userInfo = self::buildUserInfo($feedbackItem); // Tool links $toolLinks[] = self::getPermalink($feedbackItem); // Continuation data $id = $feedbackItem->getProperty('id'); $continueData = wfTimestamp(TS_MW, $timestamp) . '|' . intval($id); // Now handle hiding, showing, etc if ($feedbackItem->getProperty('hidden-state') > 0) { $toolLinks = array(); if (!in_array('show-anyway', $params)) { $userInfo = wfMessage('moodbar-user-hidden')->escaped(); $comment = wfMessage('moodbar-comment-hidden')->escaped(); $type = 'hidden'; $typeMsg = ''; $classes[] = 'fbd-hidden'; } if (in_array('admin', $params)) { if (in_array('show-anyway', $params)) { $toolLinks[] = self::getHiddenFooter($feedbackItem, 'shown'); } else { $toolLinks[] = self::getHiddenFooter($feedbackItem, 'hidden'); } } } elseif (in_array('admin', $params)) { $toolLinks[] = self::getHideLink($feedbackItem); } $responseElements = self::buildResponseElement($feedbackItem, $response); $classes = Sanitizer::encodeAttribute(implode(' ', $classes)); $toolLinks = implode("\n", $toolLinks); return <<<HTML \t\t<li class="{$classes}" data-mbccontinue="{$continueData}"> \t\t\t<div class="fbd-item-emoticon fbd-item-emoticon-{$type}"> \t\t\t\t<span class="fbd-item-emoticon-label">{$typeMsg}</span> \t\t\t</div> \t\t\t<div class="fbd-item-time">{$timeMsg}</div> \t\t\t{$userInfo} \t\t\t<div class="fbd-item-message" dir="auto">{$comment}</div> \t\t\t{$toolLinks} \t\t\t{$responseElements} \t\t\t<div style="clear:both"></div> \t\t</li> HTML; }
/** * Set the Feedback Item this Response is associated to * @param $mbf_id mbfr_mbf_id in moodbar_feedback_response table * @return bool */ protected function setFeedbackItem($mbf_id) { $dbr = wfGetDB(DB_SLAVE); $row = $dbr->selectRow('moodbar_feedback', '*', array('mbf_id' => $mbf_id), __METHOD__); if ($row !== false) { $this->setProperties(array('feedbackitem' => MBFeedbackItem::load($row))); return true; } else { return false; } }