/** * formatValue * * @param string $field field name * @param mixed $value value of field * * @return string HTML code for row */ function formatValue($field, $value) { global $wgRequest; switch ($field) { case "task_status": $taskId = $this->mCurrentRow->task_id; $name = BatchTask::getStatusName($value); $offset = $wgRequest->getVal("offset", 0); $return = sprintf("<a href=\"%s\">%s</a>", $this->mTitle->getLocalUrl("action=log&id={$taskId}&offset={$offset}"), $name); // also, stuff to make a link for restore task as per #2478 $taskType = $this->mCurrentRow->task_type; if (TASK_FINISHED_SUCCESS == $value && 'multidelete' == $taskType) { $return .= sprintf("<br /><a href=\"%s\">undo</a>", $this->mTitle->getLocalUrl("action=undo&id={$taskId}")); } return $return; break; case "task_actions": $iTaskID = $this->mCurrentRow->task_id; $iTaskStatus = $this->mCurrentRow->task_status; $sRetval = ""; global $wgUser; if (!$wgUser->isAllowed('taskmanager-action')) { return ""; } $offset = $wgRequest->getVal("offset", ""); if ($offset !== "") { $offset = "&offset={$offset}"; } switch ($iTaskStatus) { case TASK_WAITING: $sRetval .= sprintf("<a href=\"%s\">\n\t\t\t\t\t\t\t\t<img src=\"/skins/common/images/media-playback-start.png\" title=\"Start\" />\n\t\t\t\t\t\t\t</a>", $this->mTitle->getLocalUrl("action=start&id={$iTaskID}{$offset}")); break; case TASK_STARTED: $sRetval .= sprintf("<a href=\"%s\">\n\t\t\t\t\t\t\t<img src=\"/skins/common/images/media-playback-stop.png\" title=\"Stop\" />\n\t\t\t\t\t\t</a>", $this->mTitle->getLocalUrl("action=finish&id={$iTaskID}{$offset}")); break; case TASK_QUEUED: $sRetval .= sprintf("<a href=\"%s\">\n\t\t\t\t\t\t\t<img src=\"/skins/common/images/media-playback-pause.png\" title=\"Stop\" />\n\t\t\t\t\t\t</a>", $this->mTitle->getLocalUrl("action=stop&id={$iTaskID}{$offset}")); break; case TASK_FINISHED_SUCCESS: break; case TASK_FINISHED_ERROR: break; case TASK_FINISHED_UNDO: break; } $sRetval .= sprintf("<a href=\"%s\">\n\t\t\t\t\t\t<img src=\"/skins/common/images/process-stop.png\" title=\"Remove\" />\n\t\t\t\t\t</a>", $this->mTitle->getLocalUrl("action=remove&id={$iTaskID}{$offset}")); return $sRetval; break; case "task_added": case "task_started": case "task_finished": if (empty($value)) { return "<em>not yet</em>"; } else { return wfTimestamp(TS_EXIF, $value); } break; case "task_type": $Task = BatchTask::newFromID($this->mCurrentRow->task_id); if (is_null($Task)) { $description = Xml::element("span", null, "Unknown type"); } else { $description = "<span>" . $Task->getDescription() . "</span>"; } return $description; break; case "task_user_id": if ($value) { $oUser = User::newFromId($value); $label = sprintf("<a href=\"%s\">%s</a>", $oUser->getUserPage()->getLocalUrl(), $oUser->getName()); } else { $label = "<b>Anonymous</b>"; } return $label; break; default: return $value; } }