Commit abbb3bb0 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

Merge remote-tracking branch 'origin/crose_work' into raos_work

parents 5d09a4fe fd044a58
......@@ -10,7 +10,7 @@ Neue Versionsnummer
2) Im Projectverzeichnis:
make t3sphinx (nicht sicher ob das noetig ist)
3) Neuen Tag vergeben: git tag v0.4
3) Neuen Tag vergeben: git tag v0.5
4) Alle Files, inkl. Tags, in GIT einchecken.
......
......@@ -6,8 +6,8 @@
conf.py:
copyright: 2016
project: QFQ Extension
version: 0.4
release: 0.4.0
version: 0.5
release: 0.5.0
latex_documents:
- - Index
- qfq.tex
......
......@@ -57,9 +57,9 @@ copyright = u'2016, Carsten Rose'
# built documents.
#
# The short X.Y version.
version = '0.4'
version = '0.5'
# The full version, including alpha/beta/rc tags.
release = '0.4.0'
release = '0.5.0'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
......
......@@ -10,5 +10,5 @@ $EM_CONF[$_EXTKEY] = array(
'dependencies' => 'fluid,extbase',
'clearcacheonload' => true,
'state' => 'alpha',
'version' => '0.4'
'version' => '0.5'
);
\ No newline at end of file
......@@ -1980,6 +1980,9 @@ abstract class AbstractBuildForm {
}
/**
* Build a HTML 'textarea' element which becomes a TinyMCE Editor.
* List of possible plugins: https://www.tinymce.com/docs/plugins/
*
* @param array $formElement
* @param $htmlFormElementId
* @param $value
......@@ -1990,20 +1993,25 @@ abstract class AbstractBuildForm {
*/
public function buildEditor(array $formElement, $htmlFormElementId, $value, array &$json, $mode = FORM_LOAD) {
//TODO plugin autoresize nutzen um Editorgroesse anzugeben
$this->adjustMaxLength($formElement);
$attribute = Support::doAttribute('name', $htmlFormElementId);
// $attribute = Support::doAttribute('name', 'rte');
$attribute .= Support::doAttribute('id', $htmlFormElementId);
$attribute .= Support::doAttribute('class', 'qfq-tinymce');
$attribute .= Support::doAttribute('data-control-name', "$htmlFormElementId");
$attribute .= Support::doAttribute('data-placeholder', $formElement['placeholder']);
// $attribute .= Support::doAttribute('data-value', htmlentities($value), false);
// $attribute .= Support::doAttribute('data-autofocus', $formElement['autofocus']);
$attribute .= Support::doAttribute('data-load', ($formElement['dynamicUpdate'] === 'yes') ? 'data-load' : '');
$attribute .= Support::doAttribute('data-title', $formElement['tooltip']);
$attribute .= Support::doAttribute('data-config', $this->getPrefixedElementsAsJSON(FE_EDITOR_PREFIX, $formElement));
$formElement = $this->setEditorConfig($formElement, $htmlFormElementId);
// $formElement['editor-plugins']='autoresize code'
// $formElement['editor-contextmenu']='link image | cell row column'
$json = $this->getPrefixedElementsAsJSON(FE_EDITOR_PREFIX, $formElement);
$attribute .= Support::doAttribute('data-config', $json, true, ESCAPE_WITH_HTML_QUOTE);
$attribute .= $this->getAttributeFeMode($formElement[FE_MODE]);
......@@ -2015,6 +2023,54 @@ abstract class AbstractBuildForm {
return $element . $this->getHelpBlock();
}
/**
* @param array $formElement
* @param $htmlFormElementId
* @return array
*/
private function setEditorConfig(array $formElement, $htmlFormElementId) {
$flagMaxHeight = false;
// plugins
if (!isset($formElement[FE_EDITOR_PREFIX . 'plugins'])) {
$formElement[FE_EDITOR_PREFIX . 'plugins'] = 'code link searchreplace table textcolor textpattern visualchars';
}
// toolbar: https://www.tinymce.com/docs/advanced/editor-control-identifiers/#toolbarcontrols
if (!isset($formElement[FE_EDITOR_PREFIX . 'toolbar'])) {
$formElement[FE_EDITOR_PREFIX . 'toolbar'] = 'code searchreplace undo redo | ' .
'styleselect link table | fontselect fontsizeselect | ' .
'bullist numlist outdent indent | forecolor backcolor bold italic';
}
// menubar
if (!isset($formElement[FE_EDITOR_PREFIX . 'menubar'])) {
$formElement[FE_EDITOR_PREFIX . 'menubar'] = 'false';
}
// autofocus
if (isset($formElement['autofocus']) && $formElement['autofocus'] == 'yes') {
$formElement[FE_EDITOR_PREFIX . 'auto_focus'] = $htmlFormElementId;
}
// Check for min_height, max_height
$minMax = explode(',', $formElement['size'], 2);
if (isset($minMax[0]) && ctype_digit($minMax[0]) && !isset($formElement[FE_EDITOR_PREFIX . 'min_height'])) {
$formElement[FE_EDITOR_PREFIX . 'min_height'] = $minMax[0];
}
if (isset($minMax[1]) && ctype_digit($minMax[1]) && !isset($formElement[FE_EDITOR_PREFIX . 'max_height'])) {
$formElement[FE_EDITOR_PREFIX . 'max_height'] = $minMax[1];
$flagMaxHeight = true;
}
// statusbar: disable if not user defined and if no max_height is given.
if (!$flagMaxHeight && !isset($formElement[FE_EDITOR_PREFIX . 'statusbar'])) {
$formElement[FE_EDITOR_PREFIX . 'statusbar'] = 'false';
}
return $formElement;
}
/**
* Searches for '$prefix*' elements in $formElement. Collect all found elements, strip $prefix (=$keyName) and
* returns keys/values JSON encoded.
......@@ -2035,11 +2091,15 @@ abstract class AbstractBuildForm {
$keyName = substr($key, strlen($prefix));
if ($keyName == '' || !ctype_alpha($keyName)) {
throw new UserFormException("Empty '" . $prefix . "*' keyname or invalid characters: '" . $keyName . "'", ERROR_INVALID_EDITOR_PROPERTY_NAME);
if ($keyName == '') {
throw new UserFormException("Empty '" . $prefix . "*' keyname: '" . $keyName . "'", ERROR_INVALID_EDITOR_PROPERTY_NAME);
}
if ($value != '') {
// $value might be boolean false, which should be used! Do not compare with ''.
if (isset($value)) {
// real boolean are important for TinyMCE config 'statusbar', 'menubar', ...
if ($value === 'false') $value = false;
if ($value === 'true') $value = true;
$settings[$keyName] = $value;
}
}
......
......@@ -149,6 +149,8 @@ const ERROR_MISSING_TABLE_NAME = 1064;
const ERROR_MISSING_TABLE = 1065;
const ERROR_RECORD_NOT_FOUND = 1066;
const ERROR_INVALID_EDITOR_PROPERTY_NAME = 1067;
const ERROR_UNKNOWN_ESCAPE_MODE = 1068;
// Subrecord
const ERROR_SUBRECORD_MISSING_COLUMN_ID = 1100;
......@@ -481,6 +483,8 @@ const ACTION_KEYWORD_SLAVE_ID = 'slaveId';
// SUPPORT
const PARAM_T3_ALL = 't3 all';
const PARAM_T3_NO_ID = "t3 no id";
const ESCAPE_WITH_BACKSLASH = 'backslash';
const ESCAPE_WITH_HTML_QUOTE = 'htmlquote';
// AbstractBuildForm
const FLAG_ALL = 'flagAll';
......
......@@ -92,7 +92,7 @@ class Support {
* @param bool $flagOmitEmpty
* @return string
*/
public static function doAttribute($type, $value, $flagOmitEmpty = true) {
public static function doAttribute($type, $value, $flagOmitEmpty = true, $modeEscape = ESCAPE_WITH_BACKSLASH) {
if ($flagOmitEmpty && $value === "") {
return '';
}
......@@ -114,23 +114,39 @@ class Support {
break;
}
$value = self::escapeDoubleTick(trim($value));
$value = self::escapeDoubleTick(trim($value), $modeEscape);
return $type . '="' . $value . '" ';
}
/**
* Escapes Double Ticks ("), which are not already escaped.
* modeEscape: ESCAPE_WITH_BACKSLASH | ESCAPE_WITH_HTML_QUOTE
*
* TinyMCE: Encoding JS Attributes (keys & values) for TinyMCE needs to be encapsulated in '"' instead of '\"'.
*
* @param $str
* @param string $modeEscape
* @return string
* @throws CodeException
*/
public static function escapeDoubleTick($str) {
public static function escapeDoubleTick($str, $modeEscape = ESCAPE_WITH_BACKSLASH) {
$newStr = '';
for ($ii = 0; $ii < strlen($str); $ii++) {
if ($str[$ii] === '"') {
if ($ii === 0 || $str[$ii - 1] != '\\') {
$newStr .= '\\';
switch ($modeEscape) {
case ESCAPE_WITH_BACKSLASH:
$newStr .= '\\';
break;
case ESCAPE_WITH_HTML_QUOTE:
$newStr .= '&quot;';
continue 2;
default:
throw new CodeException('Unknown modeEscape=' . $modeEscape, ERROR_UNKNOWN_ESCAPE_MODE);
}
}
}
$newStr .= $str[$ii];
......
......@@ -112,6 +112,8 @@ class Report {
$this->sip = new Sip($phpUnit);
if ($phpUnit) {
$this->sip->sipUniqId('badcaffee1234');
//TODO Webserver Umgebung besser faken
$_SERVER['REQUEST_URI'] = 'localhost';
}
$this->link = new Link($this->sip, $phpUnit);
......
......@@ -90,7 +90,7 @@ class DeleteTest extends \AbstractDatabaseTest {
$this->assertEquals(false, $rc);
$expect = ['content' => "Record 100 not found in table 'Person'.", 'errorCode' => 1065];
$expect = ['content' => "Record 100 not found in table 'Person'.", 'errorCode' => 1066];
$this->assertEquals($expect, $msg);
}
......
......@@ -66,6 +66,9 @@ class StoreTest extends \PHPUnit_Framework_TestCase {
public function testSetVarStoreSystem() {
// set new Sessionname
$this->store->setVar(SYSTEM_SQL_LOG_MODE, "all", STORE_SYSTEM);
// Sessionname: default value
$this->assertEquals('all', $this->store->getVar(SYSTEM_SQL_LOG_MODE, STORE_SYSTEM), "System: SQL_LOG");
......
......@@ -68,16 +68,29 @@
<div class="form-group">
<div class="col-md-2">
<label for="text:2" class="control-label">Rich Text Editor (plugins, autofocus)</label>
<label for="text:2" class="control-label">Rich Text Editor (plugins, autofocus, no statusbar)</label>
</div>
<div class="col-md-6">
<textarea id="text:2" class="qfq-tinymce" name="rte"
data-config="{ &quot;plugins&quot;: &quot;advlist autolink link image lists charmap print preview&quot;, &quot;auto_focus&quot;: &quot;text:2&quot;}">Input
data-config="{ &quot;plugins&quot;: &quot;advlist autolink link image lists charmap print preview&quot;, &quot;auto_focus&quot;: &quot;text:2&quot;, &quot;statusbar&quot;: false }">Input
</textarea>
</div>
</div>
<div class="form-group">
<div class="col-md-2">
<label for="text:3" class="control-label">Rich Text Editor (min_height, max_height)</label>
</div>
<div class="col-md-6">
<textarea id="text:3" class="qfq-tinymce" name="rte"
data-config="{ &quot;min_height&quot;: &quot;200&quot;, &quot;max_height&quot;: &quot;400&quot; }">Input
</textarea>
</div>
</div>
<button type="submit">Do</button>
</form>
......
Supports Markdown
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