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

Db, Link, Report, Utils: renamed FALSE to false

Link: replaced TYPO3_CONF_VARS by STORE_SYSTEM
Sip, Store: PhpDoc
AbstractBuildForm, BuildFormBootstrap, Constants: implemented constant SYSTEM_SHOW_DEBUG_INFO
Database: rewrote errormessage
parent 56e470b2
...@@ -10,3 +10,6 @@ SESSIONNAME = qfq ...@@ -10,3 +10,6 @@ SESSIONNAME = qfq
; auto|yes|no. 'auto': if BE User is loggend in 'true', else 'false' ; auto|yes|no. 'auto': if BE User is loggend in 'true', else 'false'
SHOW_DEBUG_INFO = auto SHOW_DEBUG_INFO = auto
CSS_LINK_CLASS_INTERNAL = internal
CSS_LINK_CLASS_EXTERNAL = external
\ No newline at end of file
...@@ -178,7 +178,7 @@ abstract class AbstractBuildForm { ...@@ -178,7 +178,7 @@ abstract class AbstractBuildForm {
*/ */
public function createFormEditUrl() { public function createFormEditUrl() {
if ($this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) !== 'yes') { if ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) !== 'yes') {
return ''; return '';
} }
...@@ -331,7 +331,7 @@ abstract class AbstractBuildForm { ...@@ -331,7 +331,7 @@ abstract class AbstractBuildForm {
$elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value, $debugStack); $elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value, $debugStack);
// debugStack as Tooltip // debugStack as Tooltip
if ($this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) === 'yes' && count($debugStack) > 0) { if ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes' && count($debugStack) > 0) {
$elementHtml = Support::appendTooltip($elementHtml, implode("\n", OnArray::htmlentitiesOnArray($debugStack))); $elementHtml = Support::appendTooltip($elementHtml, implode("\n", OnArray::htmlentitiesOnArray($debugStack)));
} }
......
...@@ -192,7 +192,7 @@ class BuildFormBootstrap extends AbstractBuildForm { ...@@ -192,7 +192,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
</div> </div>
BUTTONS; BUTTONS;
$formEditButton = ($this->store->getVar('SHOW_DEBUG_INFO', STORE_SYSTEM) === 'yes') ? $tmp : ''; $formEditButton = ($this->store->getVar(SYSTEM_SHOW_DEBUG_INFO, STORE_SYSTEM) === 'yes') ? $tmp : '';
$html = <<<BUTTONS $html = <<<BUTTONS
......
...@@ -207,6 +207,11 @@ const SYSTEM_DB = 'DB'; ...@@ -207,6 +207,11 @@ const SYSTEM_DB = 'DB';
const SYSTEM_TESTDB = 'TESTDB'; const SYSTEM_TESTDB = 'TESTDB';
const SYSTEM_SESSIONNAME = 'SESSIONNAME'; const SYSTEM_SESSIONNAME = 'SESSIONNAME';
const SYSTEM_SQL_LOG = 'SQLLOG'; // Logging to file const SYSTEM_SQL_LOG = 'SQLLOG'; // Logging to file
const SYSTEM_SHOW_DEBUG_INFO = 'SHOW_DEBUG_INFO';
const SYSTEM_CSS_LINK_CLASS_INTERNAL = 'CSS_LINK_CLASS_INTERNAL';
const SYSTEM_CSS_LINK_CLASS_EXTERNAL = 'CSS_LINK_CLASS_EXTERNAL';
// Information for: Log / Debug / Exception // Information for: Log / Debug / Exception
const SYSTEM_SQL_RAW = 'sqlRaw'; // Type: SANITIZE_ALL / String. SQL Query (before substitute). Useful for error reporting. const SYSTEM_SQL_RAW = 'sqlRaw'; // Type: SANITIZE_ALL / String. SQL Query (before substitute). Useful for error reporting.
const SYSTEM_SQL_FINAL = 'sqlFinal'; // Type: SANITIZE_ALL / String. SQL Query (after substitute). Useful for error reporting. const SYSTEM_SQL_FINAL = 'sqlFinal'; // Type: SANITIZE_ALL / String. SQL Query (after substitute). Useful for error reporting.
...@@ -248,3 +253,5 @@ const API_ANSWER_STATUS_ERROR = 'error'; ...@@ -248,3 +253,5 @@ const API_ANSWER_STATUS_ERROR = 'error';
const API_ANSWER_REDIRECT_CLIENT = 'client'; const API_ANSWER_REDIRECT_CLIENT = 'client';
const API_ANSWER_REDIRECT_NO = 'no'; const API_ANSWER_REDIRECT_NO = 'no';
const API_ANSWER_REDIRECT_URL = 'url'; const API_ANSWER_REDIRECT_URL = 'url';
...@@ -240,7 +240,7 @@ class Database { ...@@ -240,7 +240,7 @@ class Database {
if ($count === 1) if ($count === 1)
$result = $this->fetchAll($mode)[0]; $result = $this->fetchAll($mode)[0];
else else
throw new DbException($specificMessage . "Expected one row, got 0 or more than 1: $sql", ERROR_DB_COUNT_DO_NOT_MATCH); throw new DbException($specificMessage . "Expected one row, got $count: $sql", ERROR_DB_COUNT_DO_NOT_MATCH);
break; break;
case ROW_EXPECT_0_1: case ROW_EXPECT_0_1:
if ($count === 1) if ($count === 1)
......
...@@ -150,7 +150,7 @@ class Db { ...@@ -150,7 +150,7 @@ class Db {
default: default:
if ($expect == EXPECT_SQL_OR_STRING) { if ($expect == EXPECT_SQL_OR_STRING) {
$result = $sql; $result = $sql;
return (FALSE); // nothing bad, just to indicate $sql was not a SQL statement. return (false); // nothing bad, just to indicate $sql was not a SQL statement.
} else } else
throw new SyntaxReportException ("Unexpected SQL Statement: '$action'", "", __FILE__, __LINE__, array("DB:$dbAlias", "SQL:$sql"), $this->fr_error); throw new SyntaxReportException ("Unexpected SQL Statement: '$action'", "", __FILE__, __LINE__, array("DB:$dbAlias", "SQL:$sql"), $this->fr_error);
} }
...@@ -200,15 +200,15 @@ class Db { ...@@ -200,15 +200,15 @@ class Db {
return ($num_rows == 0); return ($num_rows == 0);
break; break;
case ROW_EXPECT_1: case ROW_EXPECT_1:
if ($num_rows != 1) return (FALSE); if ($num_rows != 1) return (false);
break; break;
case ROW_EXPECT_0_1: case ROW_EXPECT_0_1:
if ($num_rows > 1) return (FALSE); if ($num_rows > 1) return (false);
break; break;
// case ROW_EXPECT_GE_0: // case ROW_EXPECT_GE_0:
// break; // break;
case ROW_EXPECT_GE_1: case ROW_EXPECT_GE_1:
if ($num_rows == 0) return (FALSE); if ($num_rows == 0) return (false);
break; break;
case EXPECT_SQL_OR_STRING: case EXPECT_SQL_OR_STRING:
break; break;
......
...@@ -28,6 +28,8 @@ namespace qfq; ...@@ -28,6 +28,8 @@ namespace qfq;
require_once(__DIR__ . '/Define.php'); require_once(__DIR__ . '/Define.php');
require_once(__DIR__ . '/Utils.php'); require_once(__DIR__ . '/Utils.php');
require_once(__DIR__ . '/../store/Store.php');
require_once(__DIR__ . '/../store/Sip.php');
/* /*
* u:url * u:url
...@@ -66,16 +68,21 @@ require_once(__DIR__ . '/Utils.php'); ...@@ -66,16 +68,21 @@ require_once(__DIR__ . '/Utils.php');
class Link { class Link {
private $mailto = "", $url = "", $image = "", $text = "", $altText = "", $imageTitle = "", $question = "", $target = "", $formName = "", $additionalUrlParams = ""; private $mailto = "", $url = "", $image = "", $text = "", $altText = "", $imageTitle = "", $question = "", $target = "", $formName = "", $additionalUrlParams = "";
private $toolTip = array(), $modeRender = 0, $picturePosition = "l", $modeHash = FALSE, $recordId = -1, $encryption = 1; private $toolTip = array(), $modeRender = 0, $picturePosition = "l", $modeHash = false, $recordId = -1, $encryption = 1;
private $linkClass = "", $defaultLinkClass = ""; private $linkClass = "", $defaultLinkClass = "";
private $linkClassSelector = array("i" => "internal", "e" => "external"); private $linkClassSelector = array("i" => "internal", "e" => "external");
private $renderControl, $link = "", $tableName = ""; private $renderControl, $link = "", $tableName = "";
/** /**
* @var SIP * @var Sip
*/ */
private $sip = null; private $sip = null;
/**
* @var Store
*/
private $store = null;
// Simulate global variable: will be set much earlier in other functions. Will be shown in error messages. // Simulate global variable: will be set much earlier in other functions. Will be shown in error messages.
private $fr_error; private $fr_error;
...@@ -89,6 +96,9 @@ class Link { ...@@ -89,6 +96,9 @@ class Link {
*/ */
private $pageAlias = ''; private $pageAlias = '';
private $cssLinkClassInternal = '';
private $cssLinkClassExternal = '';
/** /**
* __construct * __construct
* *
...@@ -105,7 +115,10 @@ class Link { ...@@ -105,7 +115,10 @@ class Link {
$this->fr_error = $fr_error; $this->fr_error = $fr_error;
$this->dbAlias = $dbAlias; $this->dbAlias = $dbAlias;
$this->sip = $sip; $this->sip = $sip;
$this->store = Store::getInstance();
$this->cssLinkClassInternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_INTERNAL, STORE_SYSTEM);
$this->cssLinkClassExternal = $this->store->getVar(SYSTEM_CSS_LINK_CLASS_EXTERNAL, STORE_SYSTEM);
$this->initRenderControl(); $this->initRenderControl();
} // __construct } // __construct
...@@ -234,7 +247,7 @@ class Link { ...@@ -234,7 +247,7 @@ class Link {
$this->link = $extraSpan[0] . $this->text . $extraSpan[1]; $this->link = $extraSpan[0] . $this->text . $extraSpan[1];
break; break;
case '11': case '11':
$this->link = $extraSpan[0] . $this->encryptMailtoJS($this->mailto, $this->text, $this->linkClass, FALSE) . $extraSpan[1]; $this->link = $extraSpan[0] . $this->encryptMailtoJS($this->mailto, $this->text, $this->linkClass, false) . $extraSpan[1];
break; break;
// 2: 'url' // 2: 'url'
...@@ -242,7 +255,7 @@ class Link { ...@@ -242,7 +255,7 @@ class Link {
$this->link = $extraSpan[0] . $this->url . $extraSpan[1]; $this->link = $extraSpan[0] . $this->url . $extraSpan[1];
break; break;
case '12': case '12':
$this->link = $extraSpan[0] . $this->encryptMailtoJS($this->mailto, $this->text, $this->linkClass, FALSE) . $extraSpan[1]; $this->link = $extraSpan[0] . $this->encryptMailtoJS($this->mailto, $this->text, $this->linkClass, false) . $extraSpan[1];
break; break;
// 3: <a href=url>url</a> // 3: <a href=url>url</a>
...@@ -279,7 +292,6 @@ class Link { ...@@ -279,7 +292,6 @@ class Link {
* @throws SyntaxReportException * @throws SyntaxReportException
*/ */
private function parseItem($key, $value) { private function parseItem($key, $value) {
global $TYPO3_CONF_VARS;
$_EXTKEY = FORMREPORT; $_EXTKEY = FORMREPORT;
...@@ -288,18 +300,18 @@ class Link { ...@@ -288,18 +300,18 @@ class Link {
case "u": case "u":
if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
$this->url = $value; $this->url = $value;
$this->defaultLinkClass = $TYPO3_CONF_VARS[$_EXTKEY]['css_class']['external']; $this->defaultLinkClass = $this->cssLinkClassExternal;
break; break;
case "m": case "m":
if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
$this->mailto = $value; $this->mailto = $value;
$this->defaultLinkClass = $TYPO3_CONF_VARS[$_EXTKEY]['css_class']['external']; $this->defaultLinkClass = $this->cssLinkClassExternal;
break; break;
case "p": case "p":
if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error); if ($this->url || $this->mailto) throw new SyntaxReportException ("Multiple URL, PAGE or MAILTO defined : '$key'", "", __FILE__, __LINE__, "Column: " . $this->fr_error["columnIndex"], $this->fr_error);
$this->pageAlias = $value ? $value : $GLOBALS["TSFE"]->id; // If no pageid|pagealias ist defined, take current page $this->pageAlias = $value ? $value : $GLOBALS["TSFE"]->id; // If no pageid|pagealias ist defined, take current page
$this->url = "?" . $this->pageAlias; $this->url = "?" . $this->pageAlias;
$this->defaultLinkClass = $TYPO3_CONF_VARS[$_EXTKEY]['css_class']['internal']; $this->defaultLinkClass = $this->cssLinkClassInternal;
break; break;
// Text // Text
case "t": case "t":
...@@ -506,6 +518,8 @@ class Link { ...@@ -506,6 +518,8 @@ class Link {
/** /**
* Build the URL and/or Hash * Build the URL and/or Hash
* *
* @param $count
* @param $hash
* @return string The complete Link * @return string The complete Link
*/ */
private function buildHash($count, &$hash) { private function buildHash($count, &$hash) {
...@@ -568,7 +582,7 @@ class Link { ...@@ -568,7 +582,7 @@ class Link {
* @param string $mailto Email address to encrypt. * @param string $mailto Email address to encrypt.
* @param string $text Text to wrap <a href..>, </a> around. * @param string $text Text to wrap <a href..>, </a> around.
* @param string $class Optional class definition * @param string $class Optional class definition
* @param bool $href TRUE: create a '<a>', FALSE: just encrypt or show the email, no link. * @param bool $href TRUE: create a '<a>', false: just encrypt or show the email, no link.
* *
* @return string The complete Link * @return string The complete Link
*/ */
......
...@@ -125,7 +125,6 @@ class Report { ...@@ -125,7 +125,6 @@ class Report {
/** /**
* Main function. Parses bodytext and iterates over all queries. * Main function. Parses bodytext and iterates over all queries.
* *
* @param array $t3data
* @return string * @return string
*/ */
public function process() { public function process() {
...@@ -579,7 +578,7 @@ class Report { ...@@ -579,7 +578,7 @@ class Report {
#debug(array('columnIndex'=>$columnIndex, 'columnName'=>$columnName, 'columnValue'=>$columnValue,'full_level'=>$full_level,"rowIndex"=>$rowIndex)); #debug(array('columnIndex'=>$columnIndex, 'columnName'=>$columnName, 'columnValue'=>$columnValue,'full_level'=>$full_level,"rowIndex"=>$rowIndex));
$show = TRUE; $show = TRUE;
if (substr($columnName, 0, 1) == "_") { if (substr($columnName, 0, 1) == "_") {
$show = FALSE; $show = false;
$columnName = substr($columnName, 1); $columnName = substr($columnName, 1);
} }
...@@ -702,7 +701,7 @@ class Report { ...@@ -702,7 +701,7 @@ class Report {
$newColumnName = ""; $newColumnName = "";
$newFinalColumnName = ""; $newFinalColumnName = "";
$remain = array(); $remain = array();
$striptags = FALSE; $striptags = false;
$tag = ""; $tag = "";
# 'Q:mailto|Z|V:mail_first|support@example.com' # 'Q:mailto|Z|V:mail_first|support@example.com'
...@@ -716,7 +715,7 @@ class Report { ...@@ -716,7 +715,7 @@ class Report {
if ($newColumnName == 'F') throw new SyntaxReportException ("Not allowed: 'F' as 'reserved column name' for parameter 'Q': $columnValue", "", __FILE__, __LINE__, $this->fr_error); if ($newColumnName == 'F') throw new SyntaxReportException ("Not allowed: 'F' as 'reserved column name' for parameter 'Q': $columnValue", "", __FILE__, __LINE__, $this->fr_error);
break; break;
case "Z": case "Z":
$show = FALSE; $show = false;
break; break;
case "T": case "T":
$striptags = TRUE; $striptags = TRUE;
......
...@@ -166,7 +166,7 @@ class Utils { ...@@ -166,7 +166,7 @@ class Utils {
* Create a new _unique_ (max 20 tries, else breaks) hash string and saves it in $_SESSION[FORMREPORT][$hash] * Create a new _unique_ (max 20 tries, else breaks) hash string and saves it in $_SESSION[FORMREPORT][$hash]
* *
* @return string A random alphanumeric hash, or * @return string A random alphanumeric hash, or
* FALSE if it was not possible to create a unique hash. * false if it was not possible to create a unique hash.
*/ */
public function randomAlphaNumUnique() { public function randomAlphaNumUnique() {
...@@ -180,7 +180,7 @@ class Utils { ...@@ -180,7 +180,7 @@ class Utils {
} }
} }
// Too much tries without success // Too much tries without success
return (FALSE); return (false);
} // randomAlphaNum () } // randomAlphaNum ()
/** /**
......
...@@ -235,6 +235,8 @@ class Sip { ...@@ -235,6 +235,8 @@ class Sip {
} }
/** /**
* Returns the sip for the given querystring. The querystring has to be sorted.
*
* @param $queryString * @param $queryString
* @return mixed * @return mixed
*/ */
...@@ -246,12 +248,14 @@ class Sip { ...@@ -246,12 +248,14 @@ class Sip {
} }
/** /**
* @param $queryString * Returns the querystring for the given $sip
* @return mixed *
* @param $sip
* @return bool
*/ */
public function getQueryStringFromSip($s) { public function getQueryStringFromSip($sip) {
if (isset($_SESSION[$s])) { if (isset($_SESSION[$sip])) {
return $_SESSION[$s]; return $_SESSION[$sip];
} }
return false; return false;
} }
......
...@@ -175,7 +175,9 @@ class Store { ...@@ -175,7 +175,9 @@ class Store {
/** /**
* @param array $dataArray * @param array $dataArray
* @param $store * @param $store
* @throws CodeException * @param bool|false $flagOverwrite
* @throws UserException
* @throws \qfq\CodeException
*/ */
public function setVarArray(array $dataArray, $store, $flagOverwrite = false) { public function setVarArray(array $dataArray, $store, $flagOverwrite = false) {
// Check valid Storename // Check valid Storename
......
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