] * B:bullet * c:class [n|i|e|] * C:checkbox [name] * d:download * D:delete * e:encryption 0|1 * E:edit * f: * F:File * g:target * G:Glyph * h: * H:Help * i: * I:information * j: * J: * k: * K: * l: * L: * m:mailto * M:Mode * n: * N:new * o:ToolTip * O:Monitor * p:page * P:picture [file] * q:question * Q: * r:render * R:right * s:sip * S:Show * t:text * T:Thumbnail * u:url * U:URL Param * v: * V: * w: * W:Dimension * x:Delete * X: * y:Copy to clipboard * Y: * z:DropDown Menu * Z: * */ const NAME_URL = 'url'; const NAME_MAIL = 'mail'; const NAME_PAGE = 'page'; const NAME_UID = 'uid'; const NAME_TEXT = 'text'; const NAME_DROPDOWN = 'dropdown'; const NAME_DOWNLOAD = DOWNLOAD_EXPORT_FILENAME; const NAME_COLLECT_ELEMENTS = 'downloadElements'; // array with element sources const NAME_DOWNLOAD_MODE = 'mode'; const NAME_BOOTSTRAP_BUTTON = 'bootstrapButton'; const NAME_ALT_TEXT = 'altText'; const NAME_TOOL_TIP = 'toolTip'; const NAME_TOOL_TIP_JS = 'toolTipJs'; const NAME_IMAGE = 'image'; const NAME_IMAGE_TITLE = 'imageTitle'; const NAME_GLYPH = 'glyph'; const NAME_GLYPH_TITLE = 'glyphTitle'; const NAME_DELETE = 'delete'; const NAME_RENDER = 'render'; const NAME_TARGET = 'target'; const NAME_LINK_CLASS = 'linkClass'; const NAME_LINK_CLASS_DEFAULT = 'linkClassDefault'; const NAME_QUESTION = 'question'; const NAME_ENCRYPTION = 'encryption'; const NAME_SIP = 'sip'; const NAME_URL_PARAM = 'param'; const NAME_RIGHT = 'picturePositionRight'; const NAME_ACTION_DELETE = 'actionDelete'; const NAME_EXTRA_CONTENT_WRAP = 'extraContentWrap'; const NAME_FILE = 'file'; const NAME_THUMBNAIL = 'thumbnail'; const NAME_THUMBNAIL_DIMENSION = 'thumbnailDimension'; const NAME_COPY_TO_CLIPBOARD = 'copyToClipBoard'; const NAME_MONITOR = 'monitor'; const NAME_ATTRIBUTE = 'attribute'; const FINAL_HREF = 'finalHref'; const FINAL_ANCHOR = 'finalAnchor'; const FINAL_CONTENT = 'finalContent'; const FINAL_CONTENT_PURE = 'finalContentPure'; const FINAL_SYMBOL = 'finalSymbol'; const FINAL_TOOL_TIP = 'finalToolTip'; const FINAL_CLASS = 'finalClass'; const FINAL_QUESTION = 'finalQuestion'; const FINAL_THUMBNAIL = 'finalThumbnail'; const LINK_ANCHOR = 'linkAnchor'; const LINK_PICTURE = 'linkPicture'; const NO_CLASS = 'no_class'; const DEFAULT_BULLET_COLOR = 'green'; const DEFAULT_CHECK_COLOR = 'green'; const DEFAULT_RENDER_MODE = '0'; const DEFAULT_QUESTION_TEXT = 'Please confirm'; const DEFAULT_QUESTION_LEVEL = 'info'; const DEFAULT_ACTION_DELETE = 'r'; const QUESTION_INDEX_TEXT = 0; const QUESTION_INDEX_LEVEL = 1; const QUESTION_INDEX_BUTTON_OK = 2; const QUESTION_INDEX_BUTTON_FALSE = 3; const QUESTION_INDEX_TIMEOUT = 4; const QUESTION_INDEX_FLAG_MODAL = 5; /** * Class Link * @package qfq */ class Link { /** * @var Sip */ private $sip = null; /** * @var Store */ private $store = null; /** * @var Thumbnail */ private $thumbnail = null; private $dbIndexData = false; private $phpUnit; private $renderControl = array(); // private $linkClassSelector = array(TOKEN_CLASS_INTERNAL => "internal ", TOKEN_CLASS_EXTERNAL => "external "); // private $cssLinkClassInternal = ''; // private $cssLinkClassExternal = ''; private $ttContentUid = ''; private $callTable = [ TOKEN_URL => 'buildUrl', TOKEN_MAIL => 'buildMail', TOKEN_PAGE => 'buildPage', TOKEN_COPY_TO_CLIPBOARD => 'buildCopyToClipboard', TOKEN_DOWNLOAD => 'buildDownload', TOKEN_DROPDOWN => 'buildDropdown', TOKEN_TOOL_TIP => 'buildToolTip', TOKEN_PICTURE => 'buildPicture', TOKEN_BULLET => 'buildBullet', TOKEN_CHECK => 'buildCheck', TOKEN_DELETE => 'buildDeleteIcon', TOKEN_ACTION_DELETE => 'buildActionDelete', TOKEN_EDIT => 'buildEdit', TOKEN_HELP => 'buildHelp', TOKEN_INFO => 'buildInfo', TOKEN_NEW => 'buildNew', TOKEN_SHOW => 'buildShow', TOKEN_FILE => 'buildFile', TOKEN_FILE_DEPRECATED => 'buildFile', TOKEN_GLYPH => 'buildGlyph', TOKEN_BOOTSTRAP_BUTTON => 'buildBootstrapButton', ]; private $tableVarName = [ TOKEN_URL => NAME_URL, TOKEN_MAIL => NAME_MAIL, TOKEN_PAGE => NAME_PAGE, TOKEN_UID => NAME_UID, TOKEN_DROPDOWN => NAME_DROPDOWN, TOKEN_DOWNLOAD => NAME_DOWNLOAD, TOKEN_DOWNLOAD_MODE => NAME_DOWNLOAD_MODE, TOKEN_TEXT => NAME_TEXT, TOKEN_ALT_TEXT => NAME_ALT_TEXT, TOKEN_BOOTSTRAP_BUTTON => NAME_BOOTSTRAP_BUTTON, TOKEN_TOOL_TIP => NAME_TOOL_TIP, TOKEN_PICTURE => NAME_IMAGE, TOKEN_BULLET => NAME_IMAGE, TOKEN_CHECK => NAME_IMAGE, TOKEN_DELETE => NAME_IMAGE, TOKEN_EDIT => NAME_IMAGE, TOKEN_HELP => NAME_IMAGE, TOKEN_INFO => NAME_IMAGE, TOKEN_NEW => NAME_IMAGE, TOKEN_SHOW => NAME_IMAGE, TOKEN_GLYPH => NAME_IMAGE, TOKEN_RENDER => NAME_RENDER, TOKEN_TARGET => NAME_TARGET, TOKEN_CLASS => NAME_LINK_CLASS, TOKEN_QUESTION => NAME_QUESTION, TOKEN_ENCRYPTION => NAME_ENCRYPTION, TOKEN_SIP => NAME_SIP, TOKEN_URL_PARAM => NAME_URL_PARAM, TOKEN_RIGHT => NAME_RIGHT, TOKEN_ACTION_DELETE => NAME_ACTION_DELETE, TOKEN_FILE => NAME_FILE, TOKEN_FILE_DEPRECATED => NAME_FILE, TOKEN_THUMBNAIL => NAME_THUMBNAIL, TOKEN_THUMBNAIL_DIMENSION => NAME_THUMBNAIL_DIMENSION, TOKEN_COPY_TO_CLIPBOARD => NAME_COPY_TO_CLIPBOARD, TOKEN_ATTRIBUTE => NAME_ATTRIBUTE, TOKEN_MONITOR => NAME_MONITOR, // The following don't need a renaming: already 'long' TOKEN_L_FILE => TOKEN_L_FILE, TOKEN_L_TAIL => TOKEN_L_TAIL, TOKEN_L_APPEND => TOKEN_L_APPEND, TOKEN_L_INTERVAL => TOKEN_L_INTERVAL, TOKEN_L_HTML_ID => TOKEN_L_HTML_ID, ]; // Used to find double definitions. private $tokenMapping = [ TOKEN_URL => LINK_ANCHOR, TOKEN_MAIL => LINK_ANCHOR, TOKEN_PAGE => LINK_ANCHOR, TOKEN_UID => LINK_ANCHOR, TOKEN_DOWNLOAD => LINK_ANCHOR, TOKEN_FILE => NAME_FILE, TOKEN_COPY_TO_CLIPBOARD => LINK_ANCHOR, TOKEN_PICTURE => LINK_PICTURE, TOKEN_BULLET => LINK_PICTURE, TOKEN_CHECK => LINK_PICTURE, TOKEN_DELETE => LINK_PICTURE, TOKEN_EDIT => LINK_PICTURE, TOKEN_HELP => LINK_PICTURE, TOKEN_INFO => LINK_PICTURE, TOKEN_NEW => LINK_PICTURE, TOKEN_SHOW => LINK_PICTURE, TOKEN_GLYPH => LINK_PICTURE, ]; /** * __construct * * @param Sip $sip * @param string $dbIndexData * @param bool $phpUnit * @throws CodeException * @throws UserFormException * @throws UserReportException */ public function __construct(Sip $sip, $dbIndexData = DB_INDEX_DEFAULT, $phpUnit = false) { $this->phpUnit = $phpUnit; if ($phpUnit) { $_SERVER['REQUEST_URI'] = 'localhost'; } $this->sip = $sip; $this->store = Store::getInstance('', $phpUnit); // $this->cssLinkClassInternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_INTERNAL, STORE_SYSTEM); // $this->cssLinkClassExternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_EXTERNAL, STORE_SYSTEM); $this->ttContentUid = $this->store->getVar(TYPO3_TT_CONTENT_UID, STORE_TYPO3); $this->dbIndexData = $dbIndexData; /* * mode: * 0: no output * 1: text (no href) * 2: url (no href) * 3: url * 4: Text * 5: text * 6: url * 8: SIP only - 's=badcaffee1234' * * r=render mode, u=url, t:text and/or image. * * [r][u][t] = mode */ $this->renderControl[0][0][0] = 0; $this->renderControl[0][0][1] = 0; $this->renderControl[0][1][0] = 3; $this->renderControl[0][1][1] = 4; $this->renderControl[1][0][0] = 0; $this->renderControl[1][0][1] = 1; $this->renderControl[1][1][0] = 3; $this->renderControl[1][1][1] = 4; $this->renderControl[2][0][0] = 0; $this->renderControl[2][0][1] = 0; $this->renderControl[2][1][0] = 0; $this->renderControl[2][1][1] = 4; $this->renderControl[3][0][0] = 0; $this->renderControl[3][0][1] = 1; $this->renderControl[3][1][0] = 2; $this->renderControl[3][1][1] = 1; $this->renderControl[4][0][0] = 0; $this->renderControl[4][0][1] = 1; $this->renderControl[4][1][0] = 2; $this->renderControl[4][1][1] = 2; $this->renderControl[5][0][0] = 0; $this->renderControl[5][0][1] = 0; $this->renderControl[5][1][0] = 0; $this->renderControl[5][1][1] = 0; $this->renderControl[6][0][0] = 0; $this->renderControl[6][0][1] = 5; $this->renderControl[6][1][0] = 0; $this->renderControl[6][1][1] = 5; $this->renderControl[7][0][0] = 0; $this->renderControl[7][0][1] = 0; $this->renderControl[7][1][0] = 6; $this->renderControl[7][1][1] = 6; $this->renderControl[8][0][0] = 0; $this->renderControl[8][0][1] = 0; $this->renderControl[8][1][0] = 8; $this->renderControl[8][1][1] = 8; } /** * In render mode 3,4,5 there is no ''. Nevertheless, tooltip and BS Button should be displayed. * Do this by applying a '' attribute around the text. * * @param array $vars * @param $keyName * * @return string * @throws CodeException */ private function wrapLinkTextOnly(array $vars, $keyName) { $text = $vars[$keyName]; if ($vars[NAME_BOOTSTRAP_BUTTON] == '' && $vars[FINAL_TOOL_TIP] == '' && $vars[NAME_ATTRIBUTE] == '') { return $text; } $attributes = Support::doAttribute('title', $vars[FINAL_TOOL_TIP]); if ($vars[NAME_ATTRIBUTE] != '') { $attributes .= $vars[NAME_ATTRIBUTE] . ' '; } if ($vars[NAME_BOOTSTRAP_BUTTON] != '') { $attributes .= Support::doAttribute('class', [$vars[NAME_BOOTSTRAP_BUTTON], 'disabled']); } return Support::wrapTag("", $text); } /** * @param string $str * * @return string * @throws CodeException * @throws UserFormException * @throws UserReportException */ private function processDropdown($str) { $menuHtml = ''; $menuEntryStrArr = array(); $menuEntryLinkArr = array(); $tokenCollect = array(); $dropdownStr = null; $paramArr = KeyValueStringParser::explodeEscape(PARAM_DELIMITER, $str); // Iterate over token. Find delimiter to separate dropdown definition and all menu entries. foreach ($paramArr as $tokenStr) { $tokenArr = explode(PARAM_TOKEN_DELIMITER, $tokenStr, 2); switch ($tokenArr[0] ?? '') { // No further need: skip case TOKEN_DROPDOWN: break; // Indicator to start menu entry: force a flush of existing token and start a new round. case TOKEN_URL: case TOKEN_MAIL: case TOKEN_PAGE: case TOKEN_DOWNLOAD: case TOKEN_COPY_TO_CLIPBOARD: case '': // New menu entry $menuEntryStrArr[] = implode(PARAM_DELIMITER, $tokenCollect); $tokenCollect = array(); $tokenCollect[] = $tokenStr; break; default: $tokenCollect[] = $tokenStr; } } // Flush remaining element $menuEntryStrArr[] = implode(PARAM_DELIMITER, $tokenCollect); $dropdownStr = array_shift($menuEntryStrArr); // For each menu entry get the link foreach ($menuEntryStrArr as $str) { $menuEntryLinkArr[] = $this->renderLink($str); } return $this->renderDropdown($dropdownStr, $menuEntryLinkArr); } /** * Start * * * * * * End * * @param $dropdownStr * @param $menuEntryLinkArr * @return string */ private function renderDropdown($dropdownStr, $menuEntryLinkArr) { static $count = 0; $time = microtime(false); if (defined('PHPUNIT_QFQ')) { $time = '0.123 1234'; } $htmlId = $time . $count++; $tmp = ''; foreach ($menuEntryLinkArr as $link) { $tmp .= '
  • ' . $link . '
  • '; } $ul = Support::wrapTag('