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
......@@ -9,4 +9,7 @@ TESTDB = <TESTDB>
SESSIONNAME = qfq
; auto|yes|no. 'auto': if BE User is loggend in 'true', else 'false'
SHOW_DEBUG_INFO = auto
\ No newline at end of file
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 {
*/
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 '';
}
......@@ -331,7 +331,7 @@ abstract class AbstractBuildForm {
$elementHtml = $this->$buildElementFunctionName($formElement, $htmlFormElementId, $value, $debugStack);
// 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)));
}
......
......@@ -192,7 +192,7 @@ class BuildFormBootstrap extends AbstractBuildForm {
</div>
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
......
......@@ -207,6 +207,11 @@ const SYSTEM_DB = 'DB';
const SYSTEM_TESTDB = 'TESTDB';
const SYSTEM_SESSIONNAME = 'SESSIONNAME';
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
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.
......@@ -248,3 +253,5 @@ const API_ANSWER_STATUS_ERROR = 'error';
const API_ANSWER_REDIRECT_CLIENT = 'client';
const API_ANSWER_REDIRECT_NO = 'no';
const API_ANSWER_REDIRECT_URL = 'url';
......@@ -240,7 +240,7 @@ class Database {
if ($count === 1)
$result = $this->fetchAll($mode)[0];
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;
case ROW_EXPECT_0_1:
if ($count === 1)
......
......@@ -150,7 +150,7 @@ class Db {
default:
if ($expect == EXPECT_SQL_OR_STRING) {
$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
throw new SyntaxReportException ("Unexpected SQL Statement: '$action'", "", __FILE__, __LINE__, array("DB:$dbAlias", "SQL:$sql"), $this->fr_error);
}
......@@ -200,15 +200,15 @@ class Db {
return ($num_rows == 0);
break;
case ROW_EXPECT_1:
if ($num_rows != 1) return (FALSE);
if ($num_rows != 1) return (false);
break;
case ROW_EXPECT_0_1:
if ($num_rows > 1) return (FALSE);
if ($num_rows > 1) return (false);
break;
// case ROW_EXPECT_GE_0:
// break;
case ROW_EXPECT_GE_1:
if ($num_rows == 0) return (FALSE);
if ($num_rows == 0) return (false);
break;
case EXPECT_SQL_OR_STRING:
break;
......
......@@ -28,6 +28,8 @@ namespace qfq;
require_once(__DIR__ . '/Define.php');
require_once(__DIR__ . '/Utils.php');
require_once(__DIR__ . '/../store/Store.php');
require_once(__DIR__ . '/../store/Sip.php');
/*
* u:url
......@@ -66,16 +68,21 @@ require_once(__DIR__ . '/Utils.php');
class Link {
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 $linkClassSelector = array("i" => "internal", "e" => "external");
private $renderControl, $link = "", $tableName = "";
/**
* @var SIP
* @var Sip
*/
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.
private $fr_error;
......@@ -89,6 +96,9 @@ class Link {
*/
private $pageAlias = '';
private $cssLinkClassInternal = '';
private $cssLinkClassExternal = '';
/**
* __construct
*
......@@ -105,7 +115,10 @@ class Link {
$this->fr_error = $fr_error;
$this->dbAlias = $dbAlias;
$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();
} // __construct
......@@ -234,7 +247,7 @@ class Link {
$this->link = $extraSpan[0] . $this->text . $extraSpan[1];
break;
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;
// 2: 'url'
......@@ -242,7 +255,7 @@ class Link {
$this->link = $extraSpan[0] . $this->url . $extraSpan[1];
break;
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;
// 3: <a href=url>url</a>
......@@ -279,7 +292,6 @@ class Link {
* @throws SyntaxReportException
*/
private function parseItem($key, $value) {
global $TYPO3_CONF_VARS;
$_EXTKEY = FORMREPORT;
......@@ -288,18 +300,18 @@ class Link {
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);
$this->url = $value;
$this->defaultLinkClass = $TYPO3_CONF_VARS[$_EXTKEY]['css_class']['external'];
$this->defaultLinkClass = $this->cssLinkClassExternal;
break;
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);
$this->mailto = $value;
$this->defaultLinkClass = $TYPO3_CONF_VARS[$_EXTKEY]['css_class']['external'];
$this->defaultLinkClass = $this->cssLinkClassExternal;
break;
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);
$this->pageAlias = $value ? $value : $GLOBALS["TSFE"]->id; // If no pageid|pagealias ist defined, take current page
$this->url = "?" . $this->pageAlias;
$this->defaultLinkClass = $TYPO3_CONF_VARS[$_EXTKEY]['css_class']['internal'];
$this->defaultLinkClass = $this->cssLinkClassInternal;
break;
// Text
case "t":
......@@ -506,7 +518,9 @@ class Link {
/**
* Build the URL and/or Hash
*
* @return string The complete Link
* @param $count
* @param $hash
* @return string The complete Link
*/
private function buildHash($count, &$hash) {
......@@ -568,7 +582,7 @@ class Link {
* @param string $mailto Email address to encrypt.
* @param string $text Text to wrap <a href..>, </a> around.
* @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
*/
......
......@@ -125,7 +125,6 @@ class Report {
/**
* Main function. Parses bodytext and iterates over all queries.
*
* @param array $t3data
* @return string
*/
public function process() {
......@@ -579,7 +578,7 @@ class Report {
#debug(array('columnIndex'=>$columnIndex, 'columnName'=>$columnName, 'columnValue'=>$columnValue,'full_level'=>$full_level,"rowIndex"=>$rowIndex));
$show = TRUE;
if (substr($columnName, 0, 1) == "_") {
$show = FALSE;
$show = false;
$columnName = substr($columnName, 1);
}
......@@ -702,7 +701,7 @@ class Report {
$newColumnName = "";
$newFinalColumnName = "";
$remain = array();
$striptags = FALSE;
$striptags = false;
$tag = "";
# 'Q:mailto|Z|V:mail_first|support@example.com'
......@@ -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);
break;
case "Z":
$show = FALSE;
$show = false;
break;
case "T":
$striptags = TRUE;
......
......@@ -166,7 +166,7 @@ class Utils {
* 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
* 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() {
......@@ -180,7 +180,7 @@ class Utils {
}
}
// Too much tries without success
return (FALSE);
return (false);
} // randomAlphaNum ()
/**
......
......@@ -235,6 +235,8 @@ class Sip {
}
/**
* Returns the sip for the given querystring. The querystring has to be sorted.
*
* @param $queryString
* @return mixed
*/
......@@ -246,12 +248,14 @@ class Sip {
}
/**
* @param $queryString
* @return mixed
* Returns the querystring for the given $sip
*
* @param $sip
* @return bool
*/
public function getQueryStringFromSip($s) {
if (isset($_SESSION[$s])) {
return $_SESSION[$s];
public function getQueryStringFromSip($sip) {
if (isset($_SESSION[$sip])) {
return $_SESSION[$sip];
}
return false;
}
......
......@@ -175,7 +175,9 @@ class Store {
/**
* @param array $dataArray
* @param $store
* @throws CodeException
* @param bool|false $flagOverwrite
* @throws UserException
* @throws \qfq\CodeException
*/
public function setVarArray(array $dataArray, $store, $flagOverwrite = false) {
// Check valid Storename
......
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