Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
typo3
qfq
Commits
b2563c47
Commit
b2563c47
authored
Aug 28, 2020
by
Marc Egger
Browse files
Refs #11035 move path setting into try statements
parent
03729ec6
Pipeline
#3729
failed with stages
in 2 minutes and 11 seconds
Changes
14
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
extension/Classes/Api/delete.php
View file @
b2563c47
...
...
@@ -14,8 +14,6 @@ use IMATHUZH\Qfq\Core\Helper\Path;
use
IMATHUZH\Qfq\Core\QuickFormQuery
;
use
IMATHUZH\Qfq\Core\Store\Store
;
Path
::
setCwdToApp
(
Path
::
API_TO_APP
);
/**
* delete: success
* SIP_MODE_ANSWER: MODE_HTML
...
...
@@ -75,6 +73,7 @@ $flagSuccess = false;
try
{
try
{
Path
::
setMainPaths
(
Path
::
API_TO_APP
);
$qfq
=
new
QuickFormQuery
([
'bodytext'
=>
''
]);
$answer
=
$qfq
->
delete
();
...
...
extension/Classes/Api/dirty.php
View file @
b2563c47
...
...
@@ -13,13 +13,12 @@ require_once(__DIR__ . '/../../vendor/autoload.php');
use
IMATHUZH\Qfq\Core\Form\Dirty
;
use
IMATHUZH\Qfq\Core\Helper\Path
;
Path
::
setCwdToApp
(
Path
::
API_TO_APP
);
/**
* Return JSON encoded answer
*
*/
try
{
Path
::
setMainPaths
(
Path
::
API_TO_APP
);
$dirty
=
new
Dirty
();
$answer
=
$dirty
->
process
();
...
...
extension/Classes/Api/download.php
View file @
b2563c47
...
...
@@ -15,8 +15,6 @@ require_once(__DIR__ . '/../../vendor/autoload.php');
use
IMATHUZH\Qfq\Core\Helper\Path
;
use
IMATHUZH\Qfq\Core\Report\Download
;
Path
::
setCwdToApp
(
Path
::
API_TO_APP
);
set_error_handler
(
"
\\
IMATHUZH
\\
Qfq
\\
Core
\\
Exception
\\
ErrorHandler::exception_error_handler"
);
...
...
@@ -24,6 +22,7 @@ $output = '';
try
{
try
{
Path
::
setMainPaths
(
Path
::
API_TO_APP
);
$download
=
new
Download
();
// If all is fine: process() will output file via print() !!
...
...
extension/Classes/Api/dragAndDrop.php
View file @
b2563c47
...
...
@@ -13,7 +13,6 @@ require_once(__DIR__ . '/../../vendor/autoload.php');
use
IMATHUZH\Qfq\Core\Helper\Path
;
use
IMATHUZH\Qfq\Core\QuickFormQuery
;
Path
::
setCwdToApp
(
Path
::
API_TO_APP
);
/**
* Return JSON encoded answer
...
...
@@ -52,6 +51,7 @@ $answer[API_MESSAGE] = '';
try
{
try
{
Path
::
setMainPaths
(
Path
::
API_TO_APP
);
$qfq
=
new
QuickFormQuery
([
'bodytext'
=>
''
]);
$data
=
$qfq
->
dragAndDrop
();
...
...
extension/Classes/Api/file.php
View file @
b2563c47
...
...
@@ -13,8 +13,6 @@ require_once(__DIR__ . '/../../vendor/autoload.php');
use
IMATHUZH\Qfq\Core\File
;
use
IMATHUZH\Qfq\Core\Helper\Path
;
Path
::
setCwdToApp
(
Path
::
API_TO_APP
);
/**
* Process File Upload - immediately when the the user selects a file.
* Return JSON encoded answer
...
...
@@ -40,7 +38,7 @@ $answer[API_MESSAGE] = '';
try
{
try
{
Path
::
setMainPaths
(
Path
::
API_TO_APP
);
$fileUpload
=
new
File
();
$fileUpload
->
process
();
...
...
extension/Classes/Api/load.php
View file @
b2563c47
...
...
@@ -14,8 +14,6 @@ use IMATHUZH\Qfq\Core\Helper\Path;
use
IMATHUZH\Qfq\Core\Store\Store
;
use
IMATHUZH\Qfq\Core\QuickFormQuery
;
Path
::
setCwdToApp
(
Path
::
API_TO_APP
);
/**
* Return JSON encoded answer
...
...
@@ -54,6 +52,7 @@ $answer[API_MESSAGE] = '';
try
{
try
{
Path
::
setMainPaths
(
Path
::
API_TO_APP
);
$qfq
=
new
QuickFormQuery
([
'bodytext'
=>
''
]);
$data
=
$qfq
->
updateForm
();
...
...
extension/Classes/Api/print.php
View file @
b2563c47
...
...
@@ -14,12 +14,12 @@ require_once(__DIR__ . '/../../vendor/autoload.php');
use
IMATHUZH\Qfq\Core\Helper\Path
;
use
IMATHUZH\Qfq\Core\Report\Html2Pdf
;
Path
::
setCwdToApp
(
Path
::
API_TO_APP
);
/**
* Main
*/
try
{
Path
::
setMainPaths
(
Path
::
API_TO_APP
);
$html2pdf
=
new
Html2Pdf
();
$html2pdf
->
outputHtml2Pdf
();
...
...
extension/Classes/Api/rest.php
View file @
b2563c47
...
...
@@ -15,8 +15,6 @@ use IMATHUZH\Qfq\Core\QuickFormQuery;
use
IMATHUZH\Qfq\Core\Helper\OnString
;
Path
::
setCwdToApp
(
Path
::
API_TO_APP
);
$restId
=
array
();
$restForm
=
array
();
...
...
@@ -25,6 +23,7 @@ $data = array();
try
{
try
{
Path
::
setMainPaths
(
Path
::
API_TO_APP
);
$form
=
OnString
::
splitPathInfoToIdForm
(
$_SERVER
[
'PATH_INFO'
]
??
''
,
$restId
,
$restForm
);
// get latest `ìd`
...
...
extension/Classes/Api/save.php
View file @
b2563c47
...
...
@@ -15,8 +15,6 @@ use IMATHUZH\Qfq\Core\QuickFormQuery;
use
IMATHUZH\Qfq\Core\Store\Store
;
use
IMATHUZH\Qfq\Core\Helper\Support
;
Path
::
setCwdToApp
(
Path
::
API_TO_APP
);
/**
* Return JSON encoded answer
*
...
...
@@ -54,6 +52,7 @@ $answer[API_MESSAGE] = '';
try
{
try
{
Path
::
setMainPaths
(
Path
::
API_TO_APP
);
$qfq
=
new
QuickFormQuery
([
'bodytext'
=>
""
]);
$data
=
$qfq
->
saveForm
();
...
...
extension/Classes/Api/setting.php
View file @
b2563c47
...
...
@@ -13,8 +13,6 @@ require_once(__DIR__ . '/../../vendor/autoload.php');
use
IMATHUZH\Qfq\Core\Helper\Path
;
use
IMATHUZH\Qfq\Core\QuickFormQuery
;
Path
::
setCwdToApp
(
Path
::
API_TO_APP
);
/**
* Return JSON encoded answer
*
...
...
@@ -38,6 +36,7 @@ $status = HTTP_400_BAD_REQUEST;
try
{
try
{
Path
::
setMainPaths
(
Path
::
API_TO_APP
);
$qfq
=
new
QuickFormQuery
([
'bodytext'
=>
''
]);
$qfq
->
setting
();
...
...
extension/Classes/Api/typeahead.php
View file @
b2563c47
...
...
@@ -14,13 +14,12 @@ require_once(__DIR__ . '/../../vendor/autoload.php');
use
IMATHUZH\Qfq\Core\Form\TypeAhead
;
use
IMATHUZH\Qfq\Core\Helper\Path
;
Path
::
setCwdToApp
(
Path
::
API_TO_APP
);
/**
* Return JSON encoded answer
*
*/
try
{
Path
::
setMainPaths
(
Path
::
API_TO_APP
);
$typeAhead
=
new
TypeAhead
();
$answer
=
$typeAhead
->
process
();
...
...
extension/Classes/Controller/QfqController.php
View file @
b2563c47
...
...
@@ -9,6 +9,7 @@ require_once(__DIR__ . '/../../vendor/autoload.php');
use
http\Exception
;
use
IMATHUZH\Qfq\Core\Helper\Path
;
use
IMATHUZH\Qfq\Core\QuickFormQuery
;
...
...
@@ -43,6 +44,7 @@ class QfqController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
$origErrorReporting
=
error_reporting
();
error_reporting
(
$origErrorReporting
|
E_NOTICE
);
Path
::
setMainPaths
(
''
);
$qfq
=
new
QuickFormQuery
(
$contentObject
->
data
);
$html
=
$qfq
->
process
();
$flagOk
=
true
;
...
...
extension/Classes/Core/Helper/Path.php
View file @
b2563c47
...
...
@@ -99,86 +99,51 @@ class Path
const
APP_TO_SYSTEM_THUMBNAIL_DIR_PUBLIC_DEFAULT
=
'typo3temp/qfqThumbnail'
;
const
APP_TO_THUMBNAIL_UNKNOWN_TYPE
=
'typo3/sysext/frontend/Resources/Public/Icons/FileIcons/'
;
public
static
function
setPaths
(
string
$cwdToApp
)
/**
* @param string $cwdToApp
* @throws \CodeException
* @throws \UserFormException
*/
public
static
function
setMainPaths
(
string
$cwdToApp
)
{
self
::
setCwdToApp
(
$cwdToApp
);
self
::
findAndSetProjectPath
();
self
::
findAndSetLogPath
();
}
/**
* @param string $newPath
* @return string
*/
public
static
function
setCwdToLog
(
string
$newPath
)
{
self
::
$cwdToLog
=
$newPath
;
}
/**
* @return string
* @throws \UserFormException
* @throws \CodeException
*/
public
static
function
cwdToLog
(
/* path parts to append */
):
string
{
if
(
is_null
(
self
::
$cwdToLog
))
{
return
self
::
cwdToProject
(
self
::
PROJECT_TO_LOG_DEFAULT
);
}
// TODO: findCwdTolog in try, catch exception and add: exception: could not write logs.
self
::
enforcePathIsSet
(
self
::
$cwdToApp
);
return
self
::
join
(
self
::
$cwdToLog
,
func_get_args
());
}
/**
* @param string $newPath
*/
public
static
function
setCwdToApp
(
string
$newPath
)
{
self
::
$cwdToApp
=
$newPath
;
}
/**
* @return string
* @throws \UserFormException
*/
public
static
function
cwdToApp
(
/* path parts to append */
):
string
{
self
::
enforcePathIsSet
(
self
::
$cwdToApp
);
return
self
::
join
(
self
::
$cwdToApp
,
func_get_args
());
}
/**
* @param string $newPath
*/
private
static
function
setAppToProject
(
string
$newPath
)
{
self
::
$appToProject
=
$newPath
;
}
/**
* @return string
* @throws \CodeException
* @throws \UserFormException
*/
public
static
function
appToProject
(
/* path parts to append */
):
string
{
// set path if not set
static
$firstRun
=
true
;
// protect from recursive call
if
(
is_null
(
self
::
$appToProject
))
{
if
(
$firstRun
)
{
$firstRun
=
false
;
self
::
findAndSetProjectPath
();
}
else
{
Thrower
::
userFormException
(
'Unexpected recursion.'
,
'Recursive call of function appToProject(). This should not happen.'
);
}
}
self
::
enforcePathIsSet
(
self
::
$appToProject
);
return
self
::
join
(
self
::
$appToProject
,
func_get_args
());
}
/**
* @return string
* @throws \UserFormException
* @throws \CodeException
*/
public
static
function
cwdToProject
(
/* path parts to append */
):
string
{
...
...
@@ -256,7 +221,31 @@ class Path
/////////////////////////////////////////////////// Private //////////////////////////////////////////////////////
/**
* @throws \CodeException
* @param string $newPath
*/
private
static
function
setCwdToApp
(
string
$newPath
)
{
self
::
$cwdToApp
=
$newPath
;
}
/**
* @param string $newPath
*/
private
static
function
setAppToProject
(
string
$newPath
)
{
self
::
$appToProject
=
$newPath
;
}
/**
* @param string $newPath
* @return string
*/
private
static
function
setCwdToLog
(
string
$newPath
)
{
self
::
$cwdToLog
=
$newPath
;
}
/**
* @throws \UserFormException
*/
private
static
function
findAndSetLogPath
()
...
...
@@ -306,7 +295,6 @@ class Path
/**
* Write the project path configuration file to the project directory.
*
* @throws \CodeException
* @throws \UserFormException
*/
private
static
function
writeProjectPathPhp
()
...
...
@@ -329,4 +317,14 @@ return '$appToProject'; // path relative to app directory (i.e. location of this
EOF;
HelperFile
::
file_put_contents
(
self
::
cwdToApp
(
PROJECT_PATH_PHP_FILE
),
$fileContent
);
}
/**
* @param $path
* @throws \UserFormException
*/
private
static
function
enforcePathIsSet
(
$path
)
{
if
(
is_null
(
$path
))
{
Thrower
::
userFormException
(
'Path accessed before set.'
,
'Make sure Path::setMainPaths() is called before.'
);
}
}
}
\ No newline at end of file
extension/NoT3Page/index.php
View file @
b2563c47
...
...
@@ -38,8 +38,6 @@ use IMATHUZH\Qfq\Core\QuickFormQuery;
////
Path
::
setCwdToApp
(
'../../../../'
);
class
User
{
public
$user
;
public
function
__construct
()
...
...
@@ -393,6 +391,7 @@ try {
$origErrorReporting
=
error_reporting
();
error_reporting
(
$origErrorReporting
|
E_NOTICE
);
Path
::
setMainPaths
(
'../../../../'
);
$qfq
=
new
QuickFormQuery
(
$t3data
);
$html
=
$qfq
->
process
();
$flagOk
=
true
;
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment