public function testGetLicenseTextLink() { $id = 432; $shortName = "<shortName>"; $fullName = "<fullName>"; $licenseRef = M::mock(LicenseRef::classname()); $licenseRef->shouldReceive("getId")->once()->withNoArgs()->andReturn($id); $licenseRef->shouldReceive("getShortName")->once()->withNoArgs()->andReturn($shortName); $licenseRef->shouldReceive("getFullName")->once()->withNoArgs()->andReturn($fullName); $linkUrl = $this->urlBuilder->getLicenseTextUrl($licenseRef); assertThat($linkUrl, is("<a title=\"{$fullName}\" href=\"javascript:;\" " . "onclick=\"javascript:window.open('http://localhost/repo?mod=popup-license&rf={$id}'," . "'License text','width=600,height=400,toolbar=no,scrollbars=yes,resizable=yes');\">{$shortName}</a>")); }
/** * @param ItemTreeBounds $itemTreeBounds * @param int $groupId * @param boolean $orderAscending * @return array */ protected function getCurrentSelectedLicensesTableData(ItemTreeBounds $itemTreeBounds, $groupId, $orderAscending) { $uploadTreeId = $itemTreeBounds->getItemId(); $uploadId = $itemTreeBounds->getUploadId(); $uberUri = Traceback_uri() . "?mod=view-license" . Traceback_parm_keep(array('upload', 'folder')); list($addedClearingResults, $removedLicenses) = $this->clearingDecisionEventProcessor->getCurrentClearings($itemTreeBounds, $groupId, LicenseMap::CONCLUSION); $licenseEventTypes = new ClearingEventTypes(); $mainLicIds = $this->clearingDao->getMainLicenseIds($uploadId, $groupId); $table = array(); /* @var $clearingResult ClearingResult */ foreach ($addedClearingResults as $licenseShortName => $clearingResult) { $licenseId = $clearingResult->getLicenseId(); $types = $this->getAgentInfo($clearingResult, $uberUri, $uploadTreeId); $reportInfo = ""; $comment = ""; if ($clearingResult->hasClearingEvent()) { $licenseDecisionEvent = $clearingResult->getClearingEvent(); $types[] = $this->getEventInfo($licenseDecisionEvent, $uberUri, $uploadTreeId, $licenseEventTypes); $reportInfo = $licenseDecisionEvent->getReportinfo(); $comment = $licenseDecisionEvent->getComment(); } $licenseShortNameWithLink = $this->urlBuilder->getLicenseTextUrl($clearingResult->getLicenseRef()); $actionLink = "<a href=\"javascript:;\" onclick=\"removeLicense({$uploadId}, {$uploadTreeId}, {$licenseId});\"><img class=\"delete\" src=\"images/space_16.png\" alt=\"\"/></a>"; if (in_array($clearingResult->getLicenseId(), $mainLicIds)) { $tooltip = _('This is a main license for the upload. Click to discard selection.'); $actionLink .= " <a href=\"javascript:;\" onclick=\"removeMainLicense({$uploadId}, {$licenseId});\"><img src=\"images/icons/star_filled_16.png\" alt=\"mainLicense\" title=\"{$tooltip}\" border=\"0\"/></a>"; } else { $tooltip = _('Click to select this as a main license for the upload.'); $actionLink .= " <a href=\"javascript:;\" onclick=\"makeMainLicense({$uploadId}, {$licenseId});\"><img src=\"images/icons/star_16.png\" alt=\"noMainLicense\" title=\"{$tooltip}\" border=\"0\"/></a>"; } $reportInfoField = nl2br(htmlspecialchars($reportInfo)); $commentField = nl2br(htmlspecialchars($comment)); $id = "{$uploadTreeId},{$licenseId}"; $table[$licenseShortName] = array('DT_RowId' => $id, '0' => $licenseShortNameWithLink, '1' => implode("<br/>", $types), '2' => $reportInfoField, '3' => $commentField, '4' => $actionLink); } foreach ($removedLicenses as $licenseShortName => $clearingResult) { if ($clearingResult->getAgentDecisionEvents()) { $agents = $this->getAgentInfo($clearingResult, $uberUri, $uploadTreeId); $licenseShortNameWithLink = $this->urlBuilder->getLicenseTextUrl($clearingResult->getLicenseRef()); $licenseId = $clearingResult->getLicenseId(); $actionLink = "<a href=\"javascript:;\" onclick=\"addLicense({$uploadId}, {$uploadTreeId}, {$licenseId});\"><img class=\"add\" src=\"images/space_16.png\" alt=\"\"/></a>"; $filled = in_array($clearingResult->getLicenseId(), $mainLicIds) ? 'filled_' : ''; $actionLink .= ' <img src="images/icons/star_' . $filled . '16.png" alt="mainLicense"/>'; $idArray = array($uploadTreeId, $licenseId); $id = implode(',', $idArray); $table[$licenseShortName] = array('DT_RowId' => $id, 'DT_RowClass' => 'removed', '0' => $licenseShortNameWithLink, '1' => implode("<br/>", $agents), '2' => "-", '3' => "-", '4' => $actionLink); } } $valueTable = array_values($this->sortByKeys($table, $orderAscending)); return $valueTable; }