Commit dd585891 authored by Carsten  Rose's avatar Carsten Rose
Browse files

AbstractBuildForm, BuildFormPlain, BuildFromTable: implemented...

AbstractBuildForm, BuildFormPlain, BuildFromTable: implemented 'form.parameter:class' to be user supplied
parent be1abdf2
...@@ -24,6 +24,26 @@ Installation ...@@ -24,6 +24,26 @@ Installation
* Insert a new content record of type `qfq`. * Insert a new content record of type `qfq`.
* As a test, insert: `sql1 = SELECT 'Hello World'`. View the page in browser. * As a test, insert: `sql1 = SELECT 'Hello World'`. View the page in browser.
Bootstrap: include by TypoScript
---------
page.includeCSS {
file1 = typo3conf/ext/qfq/Resources/Public/Css/bootstrap.min.css
file2 = typo3conf/ext/qfq/Resources/Public/Css/bootstrap-theme.min.css
file3 = typo3conf/ext/qfq/Resources/Public/Css/jqx.base.css
file4 = typo3conf/ext/qfq/Resources/Public/Css/jqx.darkblue.css
file5 = typo3conf/ext/qfq/Resources/Public/Css/qfq-jqw.css
}
page.includeJS {
file1 = typo3conf/ext/qfq/Resources/Public/JavaScript/jquery.min.js
file2 = typo3conf/ext/qfq/Resources/Public/JavaScript/bootstrap.min.js
file3 = typo3conf/ext/qfq/Resources/Public/JavaScript/jqx-all.js
file4 = typo3conf/ext/qfq/Resources/Public/JavaScript/qfq-jqw.debug.js
}
Usage Usage
----- -----
* https://wikiit.math.uzh.ch/it/projekt/qfq/qfq-jqwidgets * https://wikiit.math.uzh.ch/it/projekt/qfq/qfq-jqwidgets
......
...@@ -134,7 +134,10 @@ abstract class AbstractBuildForm { ...@@ -134,7 +134,10 @@ abstract class AbstractBuildForm {
public function head() { public function head() {
$html = ''; $html = '';
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything
$html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true); $html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true);
$html .= $this->getFormTag(); $html .= $this->getFormTag();
return $html; return $html;
...@@ -405,7 +408,7 @@ abstract class AbstractBuildForm { ...@@ -405,7 +408,7 @@ abstract class AbstractBuildForm {
* @param bool|false $flagOmitEmpty * @param bool|false $flagOmitEmpty
* @return string * @return string
*/ */
private function getAttribute($type, $value, $flagOmitEmpty = true) { public function getAttribute($type, $value, $flagOmitEmpty = true) {
if ($flagOmitEmpty && $value === "") if ($flagOmitEmpty && $value === "")
return ''; return '';
...@@ -1211,7 +1214,7 @@ abstract class AbstractBuildForm { ...@@ -1211,7 +1214,7 @@ abstract class AbstractBuildForm {
// child FE's // child FE's
$sql = SQL_FORM_ELEMENT_SPECIFIC_CONTAINER; $sql = SQL_FORM_ELEMENT_SPECIFIC_CONTAINER;
$this->feSpecNative = $this->db->sql($sql, ROW_REGULAR, ['yes', $this->formSpec["id"], 'native,container', $formElement['id']]); $this->feSpecNative = $this->db->sql($sql, ROW_REGULAR, ['yes', $this->formSpec["id"], 'native,container', $formElement['id']]);
HelperFormElement::explodeFieldParameter($this->feSpecNative); HelperFormElement::explodeParameterInArrayElements($this->feSpecNative);
$html .= $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE_SUBRECORD); $html .= $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE_SUBRECORD);
......
...@@ -32,6 +32,11 @@ class BuildFormBootstrap extends AbstractBuildForm { ...@@ -32,6 +32,11 @@ class BuildFormBootstrap extends AbstractBuildForm {
public function __construct(array $formSpec, array $feSpecAction, array $feSpecNative) { public function __construct(array $formSpec, array $feSpecAction, array $feSpecNative) {
parent::__construct($formSpec, $feSpecAction, $feSpecNative); parent::__construct($formSpec, $feSpecAction, $feSpecNative);
$this->isFirstPill = true; $this->isFirstPill = true;
// Set some defaults
if(!isset($this->formSpec['class'])) {
$this->formSpec['class'] = 'container';
}
} }
/** /**
...@@ -85,8 +90,8 @@ class BuildFormBootstrap extends AbstractBuildForm { ...@@ -85,8 +90,8 @@ class BuildFormBootstrap extends AbstractBuildForm {
public function head() { public function head() {
$html = ''; $html = '';
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything, Whole FORM; class="container" or class="container-fluid"
$html .= '<div class="container-fluid">'; //Whole FORM
$html .= '<div class="row hidden-xs"><div class="col-md-12"><h2>' . $this->formSpec['title'] . '</h2></div></div>'; // Form Title $html .= '<div class="row hidden-xs"><div class="col-md-12"><h2>' . $this->formSpec['title'] . '</h2></div></div>'; // Form Title
$pill = $this->buildPillNavigation(OnArray::filter($this->feSpecNative, 'type', 'pill')); $pill = $this->buildPillNavigation(OnArray::filter($this->feSpecNative, 'type', 'pill'));
...@@ -241,7 +246,7 @@ BUTTONS; ...@@ -241,7 +246,7 @@ BUTTONS;
}) })
</script> </script>
EOF; EOF;
$html .= '</div>'; // <div class="container-fluid"> $html .= '</div>'; // <div class="container-fluid"> === main <div class=...> around everything
return $html; return $html;
} }
...@@ -260,7 +265,7 @@ EOF; ...@@ -260,7 +265,7 @@ EOF;
// child FE's // child FE's
$sql = SQL_FORM_ELEMENT_SPECIFIC_CONTAINER; $sql = SQL_FORM_ELEMENT_SPECIFIC_CONTAINER;
$this->feSpecNative = $this->db->sql($sql, ROW_REGULAR, ['yes', $this->formSpec["id"], 'native,container', $formElement['id']]); $this->feSpecNative = $this->db->sql($sql, ROW_REGULAR, ['yes', $this->formSpec["id"], 'native,container', $formElement['id']]);
HelperFormElement::explodeFieldParameter($this->feSpecNative); HelperFormElement::explodeParameterInArrayElements($this->feSpecNative);
$html = $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE_SUBRECORD); $html = $this->elements($this->store->getVar(SIP_RECORD_ID, STORE_SIP), FORM_ELEMENTS_NATIVE_SUBRECORD);
// restore parent processed FE's // restore parent processed FE's
......
...@@ -90,6 +90,7 @@ class BuildFormPlain extends AbstractBuildForm { ...@@ -90,6 +90,7 @@ class BuildFormPlain extends AbstractBuildForm {
$html .= $this->wrapItem(WRAP_SETUP_INPUT, '<input type="submit" value="Submit">'); $html .= $this->wrapItem(WRAP_SETUP_INPUT, '<input type="submit" value="Submit">');
$html = $this->wrapItem(WRAP_SETUP_ELEMENT, $html); $html = $this->wrapItem(WRAP_SETUP_ELEMENT, $html);
$html .= '</form>'; $html .= '</form>';
$html .= '</div>'; // main <div class=...> around everything
return $html; return $html;
} }
......
...@@ -63,6 +63,7 @@ class BuildFormTable extends AbstractBuildForm { ...@@ -63,6 +63,7 @@ class BuildFormTable extends AbstractBuildForm {
public function head() { public function head() {
$html = ''; $html = '';
$html .= '<div ' . $this->getAttribute('class', $this->formSpec['class'], TRUE) . '>'; // main <div class=...> around everything
$html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true); $html .= $this->wrapItem(WRAP_SETUP_TITLE, $this->formSpec['title'], true);
$html .= $this->getFormTag(); $html .= $this->getFormTag();
$html .= '<table>'; $html .= '<table>';
...@@ -118,6 +119,8 @@ class BuildFormTable extends AbstractBuildForm { ...@@ -118,6 +119,8 @@ class BuildFormTable extends AbstractBuildForm {
$html .= '</table>'; $html .= '</table>';
$html .= $this->builtNewSip(); $html .= $this->builtNewSip();
$html .= '</form>'; $html .= '</form>';
$html .= '</div>'; // main <div class=...> around everything
return $html; return $html;
} }
......
...@@ -211,14 +211,14 @@ class QuickFormQuery { ...@@ -211,14 +211,14 @@ class QuickFormQuery {
$form = $this->db->sql("SELECT * FROM Form AS f WHERE f.name LIKE ? AND f.deleted='no'", ROW_EXPECT_1, [$formName], 'Form not found or multiple forms with the same name.'); $form = $this->db->sql("SELECT * FROM Form AS f WHERE f.name LIKE ? AND f.deleted='no'", ROW_EXPECT_1, [$formName], 'Form not found or multiple forms with the same name.');
$this->formSpec = $this->eval->parseArray($form); $this->formSpec = $this->eval->parseArray($form);
HelperFormElement::explodeFieldParameter($this->formSpec); HelperFormElement::explodeParameter($this->formSpec);
// Clear // Clear
$this->store->setVar(SYSTEM_FORM_ELEMENT, '', STORE_SYSTEM); $this->store->setVar(SYSTEM_FORM_ELEMENT, '', STORE_SYSTEM);
// FE: Action // FE: Action
$this->feSpecAction = $this->eval->parseArray($this->db->sql(SQL_FORM_ELEMENT_ALL_CONTAINER, ROW_REGULAR, ['no', $this->formSpec["id"], 'action'])); $this->feSpecAction = $this->eval->parseArray($this->db->sql(SQL_FORM_ELEMENT_ALL_CONTAINER, ROW_REGULAR, ['no', $this->formSpec["id"], 'action']));
HelperFormElement::explodeFieldParameter($this->feSpecAction); HelperFormElement::explodeParameterInArrayElements($this->feSpecAction);
// FE: Native & Container // FE: Native & Container
// "SELECT *, ? AS 'nestedInFieldSet' FROM FormElement AS fe WHERE fe.formId = ? AND fe.deleted = 'no' AND FIND_IN_SET(fe.class, ? ) AND fe.feIdContainer = ? AND fe.enabled='yes' ORDER BY fe.ord, fe.id"; // "SELECT *, ? AS 'nestedInFieldSet' FROM FormElement AS fe WHERE fe.formId = ? AND fe.deleted = 'no' AND FIND_IN_SET(fe.class, ? ) AND fe.feIdContainer = ? AND fe.enabled='yes' ORDER BY fe.ord, fe.id";
...@@ -234,7 +234,7 @@ class QuickFormQuery { ...@@ -234,7 +234,7 @@ class QuickFormQuery {
default: default:
} }
HelperFormElement::explodeFieldParameter($this->feSpecNative); HelperFormElement::explodeParameterInArrayElements($this->feSpecNative);
return $formName; return $formName;
} }
......
...@@ -18,13 +18,13 @@ class HelperFormElementTest extends \PHPUnit_Framework_TestCase { ...@@ -18,13 +18,13 @@ class HelperFormElementTest extends \PHPUnit_Framework_TestCase {
public function testExplodeFieldParameter() { public function testExplodeFieldParameter() {
$a = array(); $a = array();
HelperFormElement::explodeFieldParameter($a); HelperFormElement::explodeParameterInArrayElements($a);
$this->assertEquals(array(), $a, "Both arrays should be equal and empty"); $this->assertEquals(array(), $a, "Both arrays should be equal and empty");
$a = [0 => ['id' => 100, 'parameter' => "work=12\nlist=1:new,2:edit,3:delete"]]; $a = [0 => ['id' => 100, 'parameter' => "work=12\nlist=1:new,2:edit,3:delete"]];
$b = [0 => ['id' => 100, 'parameter' => "work=12\nlist=1:new,2:edit,3:delete", 'work' => 12, 'list' => '1:new,2:edit,3:delete']]; $b = [0 => ['id' => 100, 'parameter' => "work=12\nlist=1:new,2:edit,3:delete", 'work' => 12, 'list' => '1:new,2:edit,3:delete']];
HelperFormElement::explodeFieldParameter($a); HelperFormElement::explodeParameterInArrayElements($a);
$this->assertEquals($b, $a, "Both arrays should be equal"); $this->assertEquals($b, $a, "Both arrays should be equal");
} }
...@@ -35,7 +35,7 @@ class HelperFormElementTest extends \PHPUnit_Framework_TestCase { ...@@ -35,7 +35,7 @@ class HelperFormElementTest extends \PHPUnit_Framework_TestCase {
public function testExplodeFieldParameterException() { public function testExplodeFieldParameterException() {
$a = [0 => ['id' => 111, 'name' => 'hello', 'collision' => 'dummy', 'parameter' => "work=12\ncollision=1:new,2:edit,3:delete"]]; $a = [0 => ['id' => 111, 'name' => 'hello', 'collision' => 'dummy', 'parameter' => "work=12\ncollision=1:new,2:edit,3:delete"]];
HelperFormElement::explodeFieldParameter($a); HelperFormElement::explodeParameterInArrayElements($a);
} }
......
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