Commit 1d54e375 authored by Carsten  Rose's avatar Carsten Rose
Browse files

F7783: FormElement Code Annotation - first implementation - does not run.

parent c6342699
...@@ -3142,11 +3142,11 @@ abstract class AbstractBuildForm { ...@@ -3142,11 +3142,11 @@ abstract class AbstractBuildForm {
$html = $this->buildAnnotateGraphic($formElement, $htmlFormElementName, $value, $json, $mode); $html = $this->buildAnnotateGraphic($formElement, $htmlFormElementName, $value, $json, $mode);
break; break;
case FE_ANNOTATE_TYPE_CODE: case FE_ANNOTATE_TYPE_TEXT:
$html = $this->buildAnnotateCode($formElement, $htmlFormElementName, $value, $json, $mode); $html = $this->buildAnnotateCode($formElement, $htmlFormElementName, $value, $json, $mode);
break; break;
default: default:
throw new UserFormException("Unkown " . FE_ANNOTATE_TYPE . "type: '" . $formElement[FE_ANNOTATE_TYPE] . "'", ERROR_UNKNOWN_MODE); throw new UserFormException("Unkown " . FE_ANNOTATE_TYPE . ": '" . $formElement[FE_ANNOTATE_TYPE] . "'", ERROR_UNKNOWN_MODE);
} }
return $html; return $html;
} }
...@@ -3164,37 +3164,38 @@ abstract class AbstractBuildForm { ...@@ -3164,37 +3164,38 @@ abstract class AbstractBuildForm {
private function buildAnnotateCode(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { private function buildAnnotateCode(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
//TODO: implement code annotation if there i s no file, but text, save in a specific column //TODO: implement code annotation if there i s no file, but text, save in a specific column
if ($mode == FORM_LOAD && !empty($formElement[FE_IMAGE_SOURCE])) { if (!isset($formElement[FE_TEXT_SOURCE])) {
if (!is_readable($formElement[FE_IMAGE_SOURCE])) { throw new UserFormException("Missing parameter '" . FE_TEXT_SOURCE . "'", ERROR_IO_READ_FILE);
throw new UserFormException("Error reading file: " . $formElement[FE_IMAGE_SOURCE], ERROR_IO_READ_FILE);
} }
if ($formElement[FE_TEXT_SOURCE] != '' && !is_readable($formElement[FE_TEXT_SOURCE])) {
throw new UserFormException("Error reading file: " . $formElement[FE_TEXT_SOURCE], ERROR_IO_READ_FILE);
} }
if (!empty($value) && json_decode($value) === null) { if (!empty($value) && json_decode($value) === null) {
throw new UserFormException("Annotate data: JSON structure not valid", ERROR_BROKEN_JSON_STRUCTURE); throw new UserFormException("Annotate data: JSON structure not valid", ERROR_BROKEN_JSON_STRUCTURE);
} }
Support::setIfNotSet($formElement, FE_ANNOTATE_USER_UID);
Support::setIfNotSet($formElement, FE_ANNOTATE_USER_NAME);
Support::setIfNotSet($formElement, FE_ANNOTATE_USER_NAME);
// <div class="codeCorrection" data-uid='{"uid": 1, "name": "Reginald Commenter", "avatar": "http://www"}' data-file="../javascript/src/CodeCorrection.js" data-target="codeCorrection-output1"> // <div class="codeCorrection" data-uid='{"uid": 1, "name": "Reginald Commenter", "avatar": "http://www"}' data-file="../javascript/src/CodeCorrection.js" data-target="codeCorrection-output1">
// </div> // </div>
// <input id="codeCorrection-output1" name="correction-data" type="hidden" // <input id="codeCorrection-output1" name="correction-data" type="hidden"
// value= // value='{ ... }'>
$jsonDataUid = json_encode([FE_ANNOTATE_USER_UID => $formElement[FE_ANNOTATE_USER_UID], FE_ANNOTATE_USER_NAME => $formElement[FE_ANNOTATE_USER_NAME], FE_ANNOTATE_USER_AVATAR => $formElement[FE_ANNOTATE_USER_AVATAR]]);
$jsonDataUid = json_encode(['uid' => $formElement[FE_ANNOTATE_USER_UID]
, 'name' => $formElement[FE_ANNOTATE_USER_NAME]
, 'avatar' => $formElement[FE_ANNOTATE_USER_AVATAR]], JSON_UNESCAPED_SLASHES);
$attributeFabric = Support::doAttribute('class', ANNOTATE_TEXT_CSS_CLASS); $attributeDiv = Support::doAttribute('class', ANNOTATE_TEXT_CSS_CLASS);
$attributeFabric .= Support::doAttribute('data-uid', $jsonDataUid); // $attributeDiv .= Support::doAttribute('data-uid', $jsonDataUid, true,ESCAPE_WITH_BACKSLASH);
$attributeFabric .= Support::doAttribute('data-file', $this->fileToSipUrl($formElement[FE_IMAGE_SOURCE])); $attributeDiv .= Support::doAttribute('data-file', $this->fileToSipUrl($formElement[FE_TEXT_SOURCE]));
$attributeDiv .= Support::doAttribute('data-target', $formElement[FE_HTML_ID]);
$attributeDiv .= $this->getAttributeFeMode($formElement[FE_MODE]);
$htmlAnnotate = Support::wrapTag('<div ' . $attributeDiv . ' data-uid=\''. $jsonDataUid . '\' >', '', false);
$attributeFabric .= Support::doAttribute('data-background-image', $this->fileToSipUrl($formElement[FE_IMAGE_SOURCE])); // $htmlAnnotate = Support::wrapTag('<div ' . $attributeDiv .'>', '', false);
$attributeFabric .= Support::doAttribute('data-control-name', $formElement[FE_HTML_ID]);
$attributeFabric .= Support::doAttribute('data-buttons', 'typo3conf/ext/qfq/Resources/Public/Json/fabric.buttons.json');
$attributeFabric .= Support::doAttribute('data-emojis', 'typo3conf/ext/qfq/Resources/Public/Json/qfq.emoji.json');
$attributeFabric .= Support::doAttribute('data-fabric-color', HelperFormElement::penColorToHex($formElement));
$attributeFabric .= $this->getAttributeFeMode($formElement[FE_MODE]);
$htmlFabric = Support::wrapTag('<div ' . $attributeFabric . ' >', '', false);
$attributeInput = Support::doAttribute('id', $formElement[FE_HTML_ID]); $attributeInput = Support::doAttribute('id', $formElement[FE_HTML_ID]);
$attributeInput .= Support::doAttribute('name', $htmlFormElementName); $attributeInput .= Support::doAttribute('name', $htmlFormElementName);
...@@ -3204,7 +3205,7 @@ abstract class AbstractBuildForm { ...@@ -3204,7 +3205,7 @@ abstract class AbstractBuildForm {
$htmlInput = Support::wrapTag('<input ' . $attributeInput . ' >', '', false); $htmlInput = Support::wrapTag('<input ' . $attributeInput . ' >', '', false);
$html = $htmlFabric . $htmlInput . $this->getHelpBlock(); $html = $htmlAnnotate . $htmlInput . $this->getHelpBlock();
// $json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement); // $json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement);
...@@ -3226,8 +3227,12 @@ abstract class AbstractBuildForm { ...@@ -3226,8 +3227,12 @@ abstract class AbstractBuildForm {
*/ */
private function buildAnnotateGraphic(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { private function buildAnnotateGraphic(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
if ($mode == FORM_LOAD && !empty($formElement[FE_IMAGE_SOURCE])) { if ($mode == FORM_LOAD) {
if (!is_readable($formElement[FE_IMAGE_SOURCE])) { if (!isset($formElement[FE_IMAGE_SOURCE])) {
throw new UserFormException("Missing parameter '" . FE_IMAGE_SOURCE . "'", ERROR_IO_READ_FILE);
}
if ($formElement[FE_IMAGE_SOURCE] != '' && !is_readable($formElement[FE_IMAGE_SOURCE])) {
throw new UserFormException("Error reading file: " . $formElement[FE_IMAGE_SOURCE], ERROR_IO_READ_FILE); throw new UserFormException("Error reading file: " . $formElement[FE_IMAGE_SOURCE], ERROR_IO_READ_FILE);
} }
} }
...@@ -3280,7 +3285,8 @@ abstract class AbstractBuildForm { ...@@ -3280,7 +3285,8 @@ abstract class AbstractBuildForm {
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
*/ */
public function buildImageCut(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public
function buildImageCut(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$htmlImage = ''; $htmlImage = '';
if ($mode == FORM_LOAD && !empty($formElement[FE_IMAGE_SOURCE])) { if ($mode == FORM_LOAD && !empty($formElement[FE_IMAGE_SOURCE])) {
...@@ -3350,7 +3356,8 @@ abstract class AbstractBuildForm { ...@@ -3350,7 +3356,8 @@ abstract class AbstractBuildForm {
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
*/ */
private function fileToSipUrl($pathFileName) { private
function fileToSipUrl($pathFileName) {
$param[DOWNLOAD_MODE] = DOWNLOAD_MODE_FILE; $param[DOWNLOAD_MODE] = DOWNLOAD_MODE_FILE;
$param[SIP_DOWNLOAD_PARAMETER] = base64_encode(TOKEN_FILE . PARAM_TOKEN_DELIMITER . $pathFileName); $param[SIP_DOWNLOAD_PARAMETER] = base64_encode(TOKEN_FILE . PARAM_TOKEN_DELIMITER . $pathFileName);
...@@ -3376,7 +3383,8 @@ abstract class AbstractBuildForm { ...@@ -3376,7 +3383,8 @@ abstract class AbstractBuildForm {
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public function buildDateTime(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public
function buildDateTime(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
$placeholder = ''; $placeholder = '';
...@@ -3498,7 +3506,8 @@ abstract class AbstractBuildForm { ...@@ -3498,7 +3506,8 @@ abstract class AbstractBuildForm {
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
*/ */
public function buildDateJQW(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public
function buildDateJQW(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$arrMinMax = null; $arrMinMax = null;
// if ($formElement[FE_PLACEHOLDER] == '') { // if ($formElement[FE_PLACEHOLDER] == '') {
...@@ -3583,7 +3592,8 @@ abstract class AbstractBuildForm { ...@@ -3583,7 +3592,8 @@ abstract class AbstractBuildForm {
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
public function buildEditor(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public
function buildEditor(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
//TODO plugin autoresize nutzen um Editorgroesse anzugeben //TODO plugin autoresize nutzen um Editorgroesse anzugeben
...@@ -3626,7 +3636,8 @@ abstract class AbstractBuildForm { ...@@ -3626,7 +3636,8 @@ abstract class AbstractBuildForm {
* *
* @return array * @return array
*/ */
private function setEditorConfig(array $formElement, $htmlFormElementName) { private
function setEditorConfig(array $formElement, $htmlFormElementName) {
$flagMaxHeight = false; $flagMaxHeight = false;
// plugins // plugins
...@@ -3681,7 +3692,8 @@ abstract class AbstractBuildForm { ...@@ -3681,7 +3692,8 @@ abstract class AbstractBuildForm {
* @return string * @return string
* @throws \qfq\UserFormException * @throws \qfq\UserFormException
*/ */
private function getPrefixedElementsAsJSON($prefix, array $formElement) { private
function getPrefixedElementsAsJSON($prefix, array $formElement) {
$settings = array(); $settings = array();
// E.g.: $key = editor-plugins // E.g.: $key = editor-plugins
...@@ -3718,7 +3730,8 @@ abstract class AbstractBuildForm { ...@@ -3718,7 +3730,8 @@ abstract class AbstractBuildForm {
* *
* @throws UserFormException * @throws UserFormException
*/ */
public function buildGridJQW(array $formElement, $htmlFormElementName, $value, $fake, $mode = FORM_LOAD) { public
function buildGridJQW(array $formElement, $htmlFormElementName, $value, $fake, $mode = FORM_LOAD) {
// TODO: implement // TODO: implement
throw new UserFormException("Not implemented yet: buildGridJQW()", ERROR_NOT_IMPLEMENTED); throw new UserFormException("Not implemented yet: buildGridJQW()", ERROR_NOT_IMPLEMENTED);
} }
...@@ -3736,7 +3749,8 @@ abstract class AbstractBuildForm { ...@@ -3736,7 +3749,8 @@ abstract class AbstractBuildForm {
* @throws CodeException * @throws CodeException
* @throws UserFormException * @throws UserFormException
*/ */
public function buildNote(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public
function buildNote(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement); $json = $this->getFormElementForJson($htmlFormElementName, $value, $formElement);
...@@ -3756,7 +3770,8 @@ abstract class AbstractBuildForm { ...@@ -3756,7 +3770,8 @@ abstract class AbstractBuildForm {
* *
* @return mixed * @return mixed
*/ */
public function buildPill(array $formElement, $htmlFormElementName, $value, array &$json) { public
function buildPill(array $formElement, $htmlFormElementName, $value, array &$json) {
return $value; return $value;
} }
...@@ -3779,7 +3794,8 @@ abstract class AbstractBuildForm { ...@@ -3779,7 +3794,8 @@ abstract class AbstractBuildForm {
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
public function buildFieldset(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public
function buildFieldset(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
// save parent processed FE's // save parent processed FE's
...@@ -3823,7 +3839,8 @@ abstract class AbstractBuildForm { ...@@ -3823,7 +3839,8 @@ abstract class AbstractBuildForm {
* *
* @return array * @return array
*/ */
private function fillFeSpecNativeCheckboxWithTgMax(array $formElementArr, $tgMaxCopies) { private
function fillFeSpecNativeCheckboxWithTgMax(array $formElementArr, $tgMaxCopies) {
foreach ($formElementArr as $key => $formElement) { foreach ($formElementArr as $key => $formElement) {
if ($formElement[FE_TYPE] == FE_TYPE_CHECKBOX) { if ($formElement[FE_TYPE] == FE_TYPE_CHECKBOX) {
...@@ -3854,7 +3871,8 @@ abstract class AbstractBuildForm { ...@@ -3854,7 +3871,8 @@ abstract class AbstractBuildForm {
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
public function buildTemplateGroup(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) { public
function buildTemplateGroup(array $formElement, $htmlFormElementName, $value, array &$json, $mode = FORM_LOAD) {
$attribute = ''; $attribute = '';
$html = ''; $html = '';
...@@ -3977,7 +3995,8 @@ EOT; ...@@ -3977,7 +3995,8 @@ EOT;
* @throws \PhpOffice\PhpSpreadsheet\Reader\Exception * @throws \PhpOffice\PhpSpreadsheet\Reader\Exception
* @throws \PhpOffice\PhpSpreadsheet\Writer\Exception * @throws \PhpOffice\PhpSpreadsheet\Writer\Exception
*/ */
private function templateGroupCollectFilledElements($max, $htmlDelete, array &$json) { private
function templateGroupCollectFilledElements($max, $htmlDelete, array &$json) {
$record = $this->store->getStore(STORE_RECORD); // current values $record = $this->store->getStore(STORE_RECORD); // current values
if ($record === false || count($record) === 0) { if ($record === false || count($record) === 0) {
...@@ -4063,7 +4082,8 @@ EOT; ...@@ -4063,7 +4082,8 @@ EOT;
* @throws UserFormException * @throws UserFormException
* @throws UserReportException * @throws UserReportException
*/ */
private function templateGroupDoValue() { private
function templateGroupDoValue() {
// Fire 'value' statement // Fire 'value' statement
$tgMax = 0; $tgMax = 0;
......
...@@ -1076,7 +1076,7 @@ const FE_IMAGE_SOURCE = 'imageSource'; // Image source for a fabric element ...@@ -1076,7 +1076,7 @@ const FE_IMAGE_SOURCE = 'imageSource'; // Image source for a fabric element
const FE_DEFAULT_PEN_COLOR = 'defaultPenColor'; // Default pen color for a fabric element const FE_DEFAULT_PEN_COLOR = 'defaultPenColor'; // Default pen color for a fabric element
const FE_ANNOTATE_TYPE = 'annotateType'; // Annotate type: graphic|code const FE_ANNOTATE_TYPE = 'annotateType'; // Annotate type: graphic|code
const FE_ANNOTATE_TYPE_GRAPHIC = 'graphic'; const FE_ANNOTATE_TYPE_GRAPHIC = 'graphic';
const FE_ANNOTATE_TYPE_CODE = 'code'; const FE_ANNOTATE_TYPE_TEXT = 'text';
const FE_ANNOTATE_USER_NAME = 'annotateUserName'; const FE_ANNOTATE_USER_NAME = 'annotateUserName';
const FE_ANNOTATE_USER_UID = 'annotateUserUid'; const FE_ANNOTATE_USER_UID = 'annotateUserUid';
const FE_ANNOTATE_USER_AVATAR = 'annotateUserAvatar'; const FE_ANNOTATE_USER_AVATAR = 'annotateUserAvatar';
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment