/** * Fetch the html code to display the field value in tooltip * * @param Tracker_Artifact $artifact The artifact * @param Tracker_ChangesetValue_File $value The changeset value of this field * * @return string The html code to display the field value in tooltip */ protected function fetchTooltipValue(Tracker_Artifact $artifact, Tracker_Artifact_ChangesetValue $value = null) { $html = ''; if ($value) { $files_info = $value->getFiles(); if (count($files_info)) { $hp = Codendi_HTMLPurifier::instance(); $added = array(); foreach ($files_info as $file_info) { $add = ''; if ($file_info->isImage()) { $query = $this->getFileHTMLPreviewUrl($file_info); $add .= '<img src="' . $query . '" alt="' . $hp->purify($file_info->getDescription(), CODENDI_PURIFIER_CONVERT_HTML) . '" style="vertical-align:middle;" />'; } else { if ($file_info->getDescription()) { $add .= $hp->purify($file_info->getDescription(), CODENDI_PURIFIER_CONVERT_HTML); } else { $add .= $hp->purify($file_info->getFilename(), CODENDI_PURIFIER_CONVERT_HTML); } } $added[] = $add; } $html .= implode('<br />', $added); } } return $html; }
/** * Fetch the html code to display the field value in tooltip * * @param Tracker_Artifact $artifact The artifact * @param Tracker_ChangesetValue_File $value The changeset value of this field * * @return string The html code to display the field value in tooltip */ protected function fetchTooltipValue(Tracker_Artifact $artifact, Tracker_Artifact_ChangesetValue $value = null) { $html = ''; if ($value) { $files_info = $value->getFiles(); if (count($files_info)) { $hp = Codendi_HTMLPurifier::instance(); $added = array(); foreach ($files_info as $file_info) { $add = ''; if ($file_info->isImage()) { $query = http_build_query(array('aid' => $artifact->id, 'field' => $this->id, 'func' => 'preview-attachment', 'attachment' => $file_info->getId())); $add .= '<img src="' . TRACKER_BASE_URL . '/?' . $query . '" alt="' . $hp->purify($file_info->getDescription(), CODENDI_PURIFIER_CONVERT_HTML) . '" style="vertical-align:middle;" />'; } else { if ($file_info->getDescription()) { $add .= $hp->purify($file_info->getDescription(), CODENDI_PURIFIER_CONVERT_HTML); } else { $add .= $hp->purify($file_info->getFilename(), CODENDI_PURIFIER_CONVERT_HTML); } } $added[] = $add; } $html .= implode('<br />', $added); } } return $html; }