Commit 7b18a4b4 authored by Carsten  Rose's avatar Carsten Rose
Browse files

*: Moved to Typo3 Extension structure.

parent 398440c4
......@@ -7,4 +7,8 @@
# Created by .ignore support plugin (hsz.mobi)
/.phpdocinstall
/qfq.flowchart.dia.autosave
/extension/qfq.ini
/support
/extension/Resources/Public/fonts
/extension/Resources/Public/JavaScript
/extension/Resources/Public/Css
......@@ -72,3 +72,7 @@ Typo3
$contentObject = $this->configurationManager->getContentObject();
$configuration = $contentObject->data['bodytext'];
* Verzeichnisstruktur Extension: https://docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/FilesAndLocations/Index.html
* http://api.typo3.org/
* http://api.typo3.org/typo3cms/62/html/index.html
* https://docs.typo3.org/typo3cms/CoreApiReference/Introduction/Index.html
\ No newline at end of file
module.exports = function (grunt) {
var typo3_css = 'extension/Resources/Public/Css/';
var typo3_js = 'extension/Resources/Public/JavaScript/';
var typo3_fonts = 'extension/Resources/Public/fonts/';
// Project configuration.
grunt.initConfig({
......@@ -12,7 +15,7 @@ module.exports = function (grunt) {
'bootstrap.min.css',
'bootstrap-theme.min.css'
],
dest: 'packages/bootstrap/css/',
dest: typo3_css,
filter: 'isFile',
expand: true,
flatten: true
......@@ -22,7 +25,7 @@ module.exports = function (grunt) {
src: [
'bootstrap.min.js'
],
dest: 'packages/bootstrap/js/',
dest: typo3_js,
expand: true,
flatten: true
},
......@@ -32,7 +35,7 @@ module.exports = function (grunt) {
src: [
'*'
],
dest: 'packages/bootstrap/fonts/',
dest: typo3_fonts,
flatten: true
}
]
......@@ -45,7 +48,7 @@ module.exports = function (grunt) {
'jquery.min.js'
],
expand: true,
dest: 'packages/jquery/js/',
dest: typo3_js,
flatten: true
}
]
......@@ -58,7 +61,7 @@ module.exports = function (grunt) {
'jqx-all.js'
],
expand: true,
dest: 'packages/jqwidgets/js/',
dest: typo3_js,
flatten: true
},
{
......@@ -68,7 +71,7 @@ module.exports = function (grunt) {
'jqx.darkblue.css'
],
expand: true,
dest: 'packages/jqwidgets/css/',
dest: typo3_css,
flatten: true
},
{
......@@ -77,7 +80,7 @@ module.exports = function (grunt) {
'images/**'
],
expand: true,
dest: 'packages/jqwidgets/css/'
dest: typo3_css
}
]
}
......
<?php
/**
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
namespace IMATHUZH\Qfq\Controller;
use qfq;
require_once(__DIR__ . '/../../qfq/qfq/QuickFormQuery.php');
require_once(__DIR__ . '/../../qfq/qfq/exceptions/UserException.php');
require_once(__DIR__ . '/../../qfq/qfq/exceptions/CodeException.php');
require_once(__DIR__ . '/../../qfq/qfq/exceptions/DbException.php');
class QfqController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
public function showAction() {
try {
$contentObject = $this->configurationManager->getContentObject();
$qfq = new \qfq\QuickFormQuery($contentObject->data);
$html = $qfq->process();
} catch (qfq\UserException $e) {
$html = $e->formatMessage();
} catch (qfq\CodeException $e) {
$html = $e->formatMessage();
} catch (qfq\DbException $e) {
$html = $e->formatMessage();
} catch (\Exception $e) {
$html = "Generic Exception: " . $e->getMessage();
}
$this->view->assign('qfqOutput', $html);
return $this->view->render();
}
}
\ No newline at end of file
mod.wizards.newContentElement
{
wizardItems
{
special.elements
{
sampleextension_element
{
icon = icon
goes
here
title = Sample
Content
Element
description = More
info
goes
here
tt_content_defValues
{
CType = sampleextension_samplepluginname
}
}
}
special.show
:
= addToList(sampleextension_element)
}
}
<p>
<f:format.raw value="{qfqOutput}"/>
</p>
\ No newline at end of file
<?php
/**
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
$EM_CONF[$_EXTKEY] = array(
'title' => 'QFQ Extension',
'description' => 'Quick Form Query Extension',
'category' => 'Frontend',
'author' => 'Rafael Ostertag',
'dependencies' => 'fluid,extbase',
'clearcacheonload' => true,
'state' => 'alpha',
'version' => '0.1.0'
);
\ No newline at end of file
<?php
/**
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
'IMATHUZH.' . $_EXTKEY,
'Qfq',
array('Qfq' => 'show'),
array('Qfq' => 'show'), // put here as well, if controller output must not be cached
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::PLUGIN_TYPE_CONTENT_ELEMENT
);
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPageTSConfig('<INCLUDE_TYPOSCRIPT: source="FILE:EXT:qfq/Configuration/PageTSconfig/PageTSconfig.ts">');
$addLine = '
tt_content.qfq_qfq = COA
tt_content.qfq_qfq {
10 >
}
';
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTypoScript($_EXTKEY, 'setup', '# Setting ' . $_EXTKEY . $addLine . '', 'defaultContentRendering');
<?php
/**
* @author Rafael Ostertag <rafael.ostertag@math.uzh.ch>
*/
if (!defined('TYPO3_MODE')) {
die ('Access denied.');
}
\TYPO3\CMS\Extbase\Utility\ExtensionUtility::registerPlugin(
'IMATHUZH.' . $_EXTKEY,
'Qfq',
'QFQ Element',
'[none]'
);
/*
* The type name is generated by combining the extension key and plugin name, all lowercase and concatenated with `_'
*/
$GLOBALS['TCA']['tt_content']['types']['qfq_qfq'] = array(
'showitem' => 'CType, header, bodytext'
);
This diff is collapsed.
......@@ -210,7 +210,7 @@ abstract class AbstractBuildForm {
*/
public function getEncType() {
$result = $this->db->sql("SELECT id FROM FormElement AS fe WHERE fe.formId=? AND fe.type='upload' LIMIT 1", ROW_EMPTY_IS_OK, [$this->formSpec['id']], 'Look for Formelement.type="upload"');
$result = $this->db->sql("SELECT id FROM FormElement AS fe WHERE fe.formId=? AND fe.type='upload' LIMIT 1", ROW_REGULAR, [$this->formSpec['id']], 'Look for Formelement.type="upload"');
return (count($result) === 1) ? 'multipart/form-data' : 'application/x-www-form-urlencoded';
}
......@@ -1054,13 +1054,18 @@ abstract class AbstractBuildForm {
}
}
Support::appendTypo3ParameterToArray($queryStringArray);
// If there is a specific targetpage defined, take it.
if (isset($formElement['page']) && $formElement['page'] !== '') {
$queryStringArray['id'] = $formElement['page'];
}
//-----------------
$queryString = Support::arrayToQueryString($queryStringArray);
$sip = $this->store->getSipInstance();
$url = $formElement['page'] . $sip->queryStringToSip($queryString);
$url = $sip->queryStringToSip($queryString);
return "<a href='$url'><span class='glyphicon glyphicon-pencil'></span></a>";
......
......@@ -46,8 +46,10 @@ const WRAP_SETUP_END = 'end';
// dbQuerySimple
const ROW_REGULAR = "regular";
const ROW_IMPLODE_ALL = "implode_all";
const ROW_EXACT_1 = "exact_1";
const ROW_EMPTY_IS_OK = "empty_is_ok";
const ROW_EXPECT_0 = "expect_0";
const ROW_EXPECT_1 = "expect_1";
const ROW_EXPECT_0_1 = "expect_0_1";
const ROW_EXPECT_GE_1 = "expect_ge_1";
// KeyValueParser
const IF_VALUE_EMPTY_COPY_KEY = 'if_value_empty_copy_key';
......@@ -116,6 +118,7 @@ const ERROR_MISSING_FORMELEMENT = 1049;
const ERROR_DB_GENERIC_CHECK = 2001;
const ERROR_DB_TOO_FEW_ROWS = 2002;
const ERROR_DB_TOO_MANY_ROWS = 2003;
const ERROR_DB_COUNT_DO_NOT_MATCH = 2004;
//
// Store Names: Identifier
//
......
......@@ -208,21 +208,44 @@ class Database {
return $this->fetchAll();
}
if ($count < 1) {
if ($mode === ROW_EMPTY_IS_OK) {
return array();
}
throw new DbException($specificMessage . "Expected one row, got nothing: $sql", ERROR_DB_TOO_FEW_ROWS);
switch ($mode) {
case ROW_IMPLODE_ALL:
return $this->fetchAll(ROW_IMPLODE_ALL);
break;
case ROW_REGULAR:
return $this->fetchAll();
break;
case ROW_EXPECT_0:
if ($count === 0)
return array();
throw new DbException($specificMessage . "Expected no row, got $count rows: $sql", ERROR_DB_TOO_MANY_ROWS);
break;
case ROW_EXPECT_1:
if ($count === 1)
return $this->fetchOne();
throw new DbException($specificMessage . "Expected one row, got 0 or more than 1: $sql", ERROR_DB_COUNT_DO_NOT_MATCH);
break;
case ROW_EXPECT_0_1:
if ($count === 1)
return $this->fetchOne();
if ($count === 0)
return array();
throw new DbException($specificMessage . "Expected no row, got $count rows: $sql", ERROR_DB_TOO_MANY_ROWS);
break;
// case ROW_EXPECT_GE_0:
// if ($count === 0)
// return array();
// return $this->fetchAll();
// break;
case ROW_EXPECT_GE_1:
if ($count > 0)
return $this->fetchAll();
throw new DbException($specificMessage . "Expected at least one row, got nothing: $sql", ERROR_DB_TOO_FEW_ROWS);
break;
default:
throw new DbException($specificMessage . "Unknown mode: $mode", ERROR_UNKNOWN_MODE);
}
if ($count > 1) {
throw new DbException($specificMessage . "Expected one row, got $count rows: $sql", ERROR_DB_TOO_MANY_ROWS);
}
// ROW_EXACT_1
return $this->fetchOne();
}
/**
......
......@@ -31,6 +31,7 @@ require_once(__DIR__ . '/../qfq/helper/HelperFormElement.php');
require_once(__DIR__ . '/../qfq/exceptions/UserException.php');
require_once(__DIR__ . '/../qfq/exceptions/CodeException.php');
require_once(__DIR__ . '/../qfq/exceptions/DbException.php');
require_once(__DIR__ . '/../qfq/exceptions/ErrorHandler.php');
require_once(__DIR__ . '/../qfq/Database.php');
require_once(__DIR__ . '/../qfq/Evaluate.php');
require_once(__DIR__ . '/../qfq/BuildFormPlain.php');
......@@ -55,7 +56,6 @@ require_once(__DIR__ . '/../qfq/report/Report.php');
* @package qfq
*/
class QuickFormQuery {
/**
* @var \qfq\Store instantiated class
*/
......@@ -68,10 +68,13 @@ class QuickFormQuery {
* @var Evaluate instantiated class
*/
protected $eval = null;
protected $formSpec = array(); // Form Definition: copy of the loaded form
protected $feSpecAction = array(); // FormEelement Definition: all formElement.class='action' of the loaded form
protected $feSpecNative = array(); // FormEelement Definition: all formElement.class='native' of the loaded form
protected $formSpec = array();
protected $feSpecAction = array(); // Form Definition: copy of the loaded form
protected $feSpecNative = array(); // FormEelement Definition: all formElement.class='action' of the loaded form
/**
* @var array
*/
private $t3data = array(); // FormEelement Definition: all formElement.class='native' of the loaded form
/*
* TODO:
......@@ -85,10 +88,6 @@ class QuickFormQuery {
* doActions 'After'
*/
//TODO: remove this as soon as Report use STORE_TYPO3 to transfer the bodytext.
private $bodytext = '';
/**
* Construct the Form Class and Store too. This is the base initialization moment.
*
......@@ -97,31 +96,16 @@ class QuickFormQuery {
*
* @param string $bodytext
*/
public function __construct($bodytext = '', $phpUnit = false) {
try {
//TODO: remove this as soon as Report use STORE_TYPO3 to transfer the bodytext.
$this->bodytext = $bodytext;
$this->store = Store::getInstance($bodytext, $phpUnit);
$this->db = new Database();
$this->eval = new Evaluate($this->store, $this->db);
} catch (UserException $e) {
echo $e->formatMessage();
exit;
} catch (CodeException $e) {
echo $e->formatMessage();
exit;
} catch (DbException $e) {
echo $e->formatMessage();
exit;
} catch (\Exception $e) {
echo "Generic Exception: " . $e->getMessage();
exit;
}
public function __construct($t3data = array(), $phpUnit = false) {
$this->t3data = $t3data;
set_error_handler("\\qfq\\ErrorHandler::exception_error_handler");
$bodytext = $this->t3data['bodytext'];
$this->store = Store::getInstance($bodytext, $phpUnit);
$this->db = new Database();
$this->eval = new Evaluate($this->store, $this->db);
}
/**
......@@ -134,20 +118,9 @@ class QuickFormQuery {
mb_internal_encoding("UTF-8");
try {
$html .= $this->doForm();
// $html .= $this->doReport();
} catch (UserException $e) {
echo $e->formatMessage();
} catch (CodeException $e) {
echo $e->formatMessage();
} catch (DbException $e) {
echo $e->formatMessage();
} catch (\Exception $e) {
echo "Generic Exception: " . $e->getMessage();
}
$html .= $this->doForm();
$html .= $this->doReport();
return $html;
}
......@@ -223,7 +196,7 @@ class QuickFormQuery {
}
$this->store->setVar(SYSTEM_FORM, $formName, STORE_SYSTEM);
$form = $this->db->sql("SELECT * FROM Form AS f WHERE f.name LIKE ? AND f.deleted='no'", ROW_EXACT_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);
HelperFormElement::explodeFieldParameter($this->formSpec);
......@@ -315,10 +288,13 @@ class QuickFormQuery {
return $sipFound;
}
/**
* @return string
*/
private function doReport() {
$report = new Report();
$html = $report->process($this->bodytext);
$html = $report->process($this->t3data);
return $html;
......
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