2 # SPDX-FileCopyrightText: © Fossology contributors
4 # SPDX-License-Identifier: GPL-2.0-only
6 namespace Fossology\Lib\UI\Component;
11 const VIEW_META =
'View-Meta';
13 const FORMAT_HEX =
'hex';
14 const FORMAT_TEXT =
'text';
15 const FORMAT_FLOW =
'flow';
17 const TARGET_DEFAULT =
'default';
18 const TARGET_VIEW =
'view';
20 private $formatOptions = array(self::FORMAT_FLOW, self::FORMAT_TEXT, self::FORMAT_HEX);
22 private $textFormats = array(self::FORMAT_HEX, self::FORMAT_TEXT, self::FORMAT_FLOW);
24 private $targets = array(
25 self::TARGET_DEFAULT => array(MicroMenu::VIEW_META, MicroMenu::VIEW),
26 self::TARGET_VIEW => array(MicroMenu::VIEW)
29 public function insert($groups, $name, $position, $module, $uri, $tooltip)
31 if (!is_array($groups)) {
32 $groups = $this->targets[$groups];
37 foreach ($groups as $group) {
55 if (in_array($selectedFormat, $this->formatOptions)) {
56 return $selectedFormat;
59 return self::FORMAT_FLOW;
62 list($type, $dummy) = explode(
"/", $mimeType, 2);
63 return $type ==
'text' ? self::FORMAT_TEXT : self::FORMAT_FLOW;
77 $uri = preg_replace(
"/&format=[a-zA-Z0-9]*/",
"", $uri);
78 $uri = preg_replace(
"/&page=[0-9]*/",
"", $uri);
80 $pageNumberHex =
null;
81 $pageNumberText =
null;
83 $tooltipTexts = array(
84 self::FORMAT_HEX => _(
"View as a hex dump"),
85 self::FORMAT_TEXT => _(
"View as unformatted text"),
86 self::FORMAT_FLOW => _(
"View as formatted text")
90 self::FORMAT_HEX =>
"Hex",
91 self::FORMAT_TEXT =>
"Text",
92 self::FORMAT_FLOW =>
"Formatted"
98 foreach ($this->textFormats as $currentFormat) {
100 if ($currentFormat == $selectedFormat) {
103 $targetPageNumber = $currentFormat == self::FORMAT_HEX ? $hexFactor * $pageNumberHex : $pageNumber;
104 menu_insert($menuName, $menuPosition--,
"$uri&format=$currentFormat&pageNumber=$targetPageNumber", $tooltipTexts[$currentFormat]);
Traceback_parm($ShowMod=1)
Get the URI query to this location.
GetParm($parameterName, $parameterType)
This function will retrieve the variables and check data types.
GetMimeType($Item)
Given an uploadtree_pk, return a string that describes the mime type.
list_t type structure used to keep various lists. (e.g. there are multiple lists).