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

Report: moved some initialization from process() to __construct(). Cleaned up phpdoc.

Sip: Cleaned up phpdoc.
QuickFormQuery: rearranged initialization from Report.
parent 119c1c5b
...@@ -319,9 +319,9 @@ class QuickFormQuery { ...@@ -319,9 +319,9 @@ class QuickFormQuery {
* @return string * @return string
*/ */
private function doReport() { private function doReport() {
$report = new Report(); $report = new Report($this->t3data);
$html = $report->process($this->t3data); $html = $report->process();
return $html; return $html;
......
...@@ -11,7 +11,6 @@ namespace qfq; ...@@ -11,7 +11,6 @@ namespace qfq;
//use qfq; //use qfq;
require_once(__DIR__ . '/Define.php'); require_once(__DIR__ . '/Define.php');
require_once(__DIR__ . '/Utils.php'); require_once(__DIR__ . '/Utils.php');
require_once(__DIR__ . '/Variables.php'); require_once(__DIR__ . '/Variables.php');
...@@ -22,21 +21,7 @@ require_once(__DIR__ . '/Link.php'); ...@@ -22,21 +21,7 @@ require_once(__DIR__ . '/Link.php');
require_once(__DIR__ . '/Sendmail.php'); require_once(__DIR__ . '/Sendmail.php');
//class cObj {
// public $data = array();
//}
/**
* Plugin 'FormReport' for the 'formreport' extension.
*
* @author Glowbase GmbH <support@glowbase.com>
* @package TYPO3
* @subpackage tx_formreport
*/
class Report { class Report {
// var $prefixId = 'tx_formreport_pi1'; // Same as class name
// var $scriptRelPath = 'pi1/class.tx_formreport_pi1.php'; // Path to this script relative to the extension dir.
// var $pi_checkCHash = true;
/** /**
* @var string * @var string
...@@ -49,8 +34,10 @@ class Report { ...@@ -49,8 +34,10 @@ class Report {
// frArray[10.50.5.sql][select ...] // frArray[10.50.5.sql][select ...]
private $frArray = array(); private $frArray = array();
// $indexArray[10][50][5] one entry per 'sql' statement // $indexArray[10][50][5] one entry per 'sql' statement
private $indexArray = array(); private $indexArray = array();
// TODO to explain // TODO to explain
// private $resultArray = array(); // private $resultArray = array();
private $levelCount = 0; private $levelCount = 0;
...@@ -59,18 +46,17 @@ class Report { ...@@ -59,18 +46,17 @@ class Report {
* @var Variables * @var Variables
*/ */
private $variables = null; private $variables = null;
// private $saveFile;
//class with util functions
/** /**
* @var Utils * @var Utils
*/ */
private $utils = null; private $utils = null;
//TODO: wo wird die initialisiert? Im Original suchen.
/** /**
* @var Db * @var Db
*/ */
private $db = null; private $db = null;
/** /**
* @var Sendmail * @var Sendmail
*/ */
...@@ -81,18 +67,16 @@ class Report { ...@@ -81,18 +67,16 @@ class Report {
// Emulate global variable: will be set much earlier in other functions. Will be shown in error messages. // Emulate global variable: will be set much earlier in other functions. Will be shown in error messages.
private $fr_error = array('uid' => '', 'pid' => '', 'row' => '', 'debug_level' => '0', 'full_level' => ''); private $fr_error = array('uid' => '', 'pid' => '', 'row' => '', 'debug_level' => '0', 'full_level' => '');
//TODO:here: FAKE. Known inside Typo3 and should be transfered to Report somehow private $t3data = array();
private $cObj;
/** /**
* __construct * Report constructor.
* *
* @param array $t3data
*/ */
public function __construct() { public function __construct(array $t3data) {
//TODO: Fake $this->t3data = $t3data;
// $this->cObj = new cObj();
// $this->cObj->data['uid'] = 1;
$this->page_control["msgbox"]["pagec"] = "Please confirm!"; $this->page_control["msgbox"]["pagec"] = "Please confirm!";
...@@ -108,55 +92,44 @@ class Report { ...@@ -108,55 +92,44 @@ class Report {
$this->page_control["icon"]["pages"] = "S"; $this->page_control["icon"]["pages"] = "S";
$this->db = new Database(); $this->db = new Database();
} // __construct
/**
* @param $content
* @param $conf
* @return string Rendered code of the queries
* @throws userException
*/
public function process(array $t3data) {
$this->utils = new Utils(); $this->utils = new Utils();
$this->variables = new Variables($t3data["uid"]); $this->variables = new Variables($t3data["uid"]);
// Sanitize function for POST and GET Parameters.
// Merged URL-Parameter (key1, id etc...) in resultArray.
$this->variables->resultArray = array_merge($this->variables->resultArray, array("url." => $this->utils->sanitize()), array("global." => $this->variables->collectGlobalVariables()));
// Set static values, which won't change during this run. // Set static values, which won't change during this run.
$this->fr_error["pid"] = $this->variables->resultArray['global.']['page_id']; $this->fr_error["pid"] = $this->variables->resultArray['global.']['page_id'];
// $this->fr_error["pid"] = $this->variables->get('resultArray', 'global.', 'page_id');
$this->fr_error["uid"] = $t3data["uid"]; $this->fr_error["uid"] = $t3data["uid"];
$this->fr_error["debug_level"] = 0; $this->fr_error["debug_level"] = 0;
// Sanatize function for POST and GET Parameters.
// Merged URL-Parameter (key1, id etc...) in resultArray.
$this->variables->resultArray = array_merge($this->variables->resultArray, array("url." => $this->utils->sanitize()),
array("global." => $this->variables->collectGlobalVariables()));
// Create Logclass. // Create Logclass.
$this->log = new Log($this->variables->resultArray['global.']); $this->log = new Log($this->variables->resultArray['global.']);
// $this->log = new Log($this->variables->get('resultArray', 'global.'));
// Create DB Class. Take care to prepare a fr_log instance.
//TODO implement logging
// $this->db = new Db($this->log);
// Create sendmail Class. Take care to prepare a fr_log instance. // Create sendmail Class. Take care to prepare a fr_log instance.
$this->sendmail = new Sendmail($this->log); $this->sendmail = new Sendmail($this->log);
}
/**
* Main function. Parses bodytext and iterates over all queries.
*
* @param array $t3data
* @return string
*/
public function process() {
// Setter function to emulate global variables.
//TODO implement logging
// $this->db->set_fr_error($this->fr_error);
$this->log->set_fr_error($this->fr_error); $this->log->set_fr_error($this->fr_error);
// Iteration over Bodytext // Iteration over Bodytext
$ttLineArray = explode("\n", $t3data['bodytext']); $ttLineArray = explode("\n", $this->t3data['bodytext']);
foreach ($ttLineArray as $index => $line) { foreach ($ttLineArray as $index => $line) {
// Fill $frArray, $indexArray, $resultArray // Fill $frArray, $indexArray, $resultArray
$this->parseFRLine($line); $this->parseFRLine($line);
} }
// Sort array // Sort array
$this->sortIndexArray($this->indexArray, $this->generateSortArg()); $this->sortIndexArray($this->indexArray, $this->generateSortArg());
...@@ -170,7 +143,7 @@ class Report { ...@@ -170,7 +143,7 @@ class Report {
} }
return $content; return $content;
} // main() }
/** /**
* Split line in level, command, content and fill 'frArray', 'levelCount', 'indexArray' * Split line in level, command, content and fill 'frArray', 'levelCount', 'indexArray'
...@@ -215,9 +188,13 @@ class Report { ...@@ -215,9 +188,13 @@ class Report {
// fill Array // fill Array
$this->setLine($level, $frCmd, $value); $this->setLine($level, $frCmd, $value);
} }
} // form2hash() }
/**
* @param $level
* @param $frCmd
* @param $value
*/
private function setLine($level, $frCmd, $value) { private function setLine($level, $frCmd, $value) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) { if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug() // T3 function: debug()
...@@ -236,16 +213,16 @@ class Report { ...@@ -236,16 +213,16 @@ class Report {
// $indexArray[10][50][5] // $indexArray[10][50][5]
$this->indexArray[] = explode(".", $level); $this->indexArray[] = explode(".", $level);
} }
} // triggerReport() }
/** /**
* Sorts the associative array. * Sorts the associative array.
* *
* @param Array $ary : The unsorted Level Array * @param array $ary : The unsorted Level Array
* @param String $clause : the sort argument 0 ASC, 1 ASC... according to the number of columns * @param string $clause : the sort argument 0 ASC, 1 ASC... according to the number of columns
* @return The content that is displayed on the website * @return The content that is displayed on the website
*/ */
private function sortIndexArray(&$ary, $clause, $ascending = true) { private function sortIndexArray(array &$ary, $clause, $ascending = true) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) { if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug() // T3 function: debug()
// debug(array('function' => 'sortIndexArray')); // debug(array('function' => 'sortIndexArray'));
...@@ -296,9 +273,13 @@ class Report { ...@@ -296,9 +273,13 @@ class Report {
$sortFn = create_function('$a,$b', $fnBody); $sortFn = create_function('$a,$b', $fnBody);
usort($ary, $sortFn); usort($ary, $sortFn);
} }
} // collectRow() }
/**
* generateSortArg
*
* @return string
*/
private function generateSortArg() { private function generateSortArg() {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) { if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug() // T3 function: debug()
...@@ -312,7 +293,7 @@ class Report { ...@@ -312,7 +293,7 @@ class Report {
} }
$sortArg = substr($sortArg, 0, strlen($sortArg) - 2); $sortArg = substr($sortArg, 0, strlen($sortArg) - 2);
return $sortArg; return $sortArg;
} // composeLinkPart() }
/** /**
* Executes the queries recursive. This Method is called for each Sublevel. * Executes the queries recursive. This Method is called for each Sublevel.
...@@ -540,7 +521,7 @@ class Report { ...@@ -540,7 +521,7 @@ class Report {
} }
return $content; return $content;
} // doPage() }
/** /**
* Determine value: * Determine value:
...@@ -574,7 +555,7 @@ class Report { ...@@ -574,7 +555,7 @@ class Report {
$this->variables->resultArray[$full_level . ".line."][$level_key] = $value; $this->variables->resultArray[$full_level . ".line."][$level_key] = $value;
return ($value); return ($value);
} // doFixColPosPage() }
/** /**
* Prepare Session Array with Hash Entry: Only for form * Prepare Session Array with Hash Entry: Only for form
...@@ -599,7 +580,7 @@ class Report { ...@@ -599,7 +580,7 @@ class Report {
} }
return ($hash); return ($hash);
} // renderColumn() }
/** /**
* Steps through 'row' and collects all columns * Steps through 'row' and collects all columns
...@@ -636,29 +617,19 @@ class Report { ...@@ -636,29 +617,19 @@ class Report {
} }
} }
return ($content); return ($content);
} // getValueParentDefault() }
/**
* The main method of the PlugIn
*
* @param string $content : The PlugIn content
* @param array $conf : The PlugIn configuration
* @return string The content that is displayed on the website
*/
//Liefert für ~1.1.name -> [1.1][name] zurück
/** /**
* Renders column depending of column name (if name is a reserved column name) * Renders column depending of column name (if name is a reserved column name)
* *
* @param string $columnIndex : column index of recent row * @param string $columnIndex
* @param string $columnName : columnname * @param string $columnName
* @param string $columnValue : content of column * @param string $columnValue
* @param string $full_level : position to be processed * @param string $full_level
* @param string $rowIndex : index of row of resultset to be processed * @param string $rowIndex
* @param bool $show : RC: 'TRUE' content will be printed on screen * @param bool $show
* * @return string rendered column
* @return string rendered column * @throws SyntaxReportException
*
*/ */
private function renderColumn($columnIndex, $columnName, $columnValue, $full_level, $rowIndex, &$show) { private function renderColumn($columnIndex, $columnName, $columnValue, $full_level, $rowIndex, &$show) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) { if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
...@@ -858,7 +829,7 @@ class Report { ...@@ -858,7 +829,7 @@ class Report {
$this->variables->resultArray[$full_level . "."][$columnName] = $content; $this->variables->resultArray[$full_level . "."][$columnName] = $content;
return $content; return $content;
} // getResultArrayIndex() }
/** /**
* The main method of the PlugIn * The main method of the PlugIn
...@@ -889,7 +860,7 @@ class Report { ...@@ -889,7 +860,7 @@ class Report {
$output = $rc . " - " . $output; $output = $rc . " - " . $output;
return ($output); return ($output);
} // compareArraystart() }
/** /**
* The main method of the PlugIn * The main method of the PlugIn
...@@ -956,7 +927,7 @@ class Report { ...@@ -956,7 +927,7 @@ class Report {
if ($this->page_control["icon"][$columnName]) $link .= $this->page_control["icon"][$columnName] . "|"; if ($this->page_control["icon"][$columnName]) $link .= $this->page_control["icon"][$columnName] . "|";
return ($link); return ($link);
} // compareArraylength() }
/** /**
* If there is a value (or a defaultValue): compose it together with qualifier and delimiter. * If there is a value (or a defaultValue): compose it together with qualifier and delimiter.
...@@ -980,17 +951,8 @@ class Report { ...@@ -980,17 +951,8 @@ class Report {
return ($qualifier . ":" . $value . "|"); return ($qualifier . ":" . $value . "|");
return ''; return '';
} // parseFRLine() }
/**
* Store level, frCmd, value
*
* @param string $level : 10.50.5
* @param string $frCmd : sql
* @param string $value : select ...
* @return void
*/
//Füllt frArray und indexArray
/** /**
* Renders pageX: extract token and determine if any default value has be applied * Renders pageX: extract token and determine if any default value has be applied
* *
...@@ -1047,16 +1009,14 @@ class Report { ...@@ -1047,16 +1009,14 @@ class Report {
#debug($columnValue); #debug($columnValue);
return ($columnValue); return ($columnValue);
} // setLine() }
/** /**
* Generate SortArgument * Generate SortArgument
* *
* @param void * @param $variable
* @return string: sortArg * @return string
*/ */
//Hier wird das Sortierargument generiert
private function getResultArrayIndex($variable) { private function getResultArrayIndex($variable) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) { if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug() // T3 function: debug()
...@@ -1066,9 +1026,13 @@ class Report { ...@@ -1066,9 +1026,13 @@ class Report {
$variable = substr($variable, 1, strlen($variable)); $variable = substr($variable, 1, strlen($variable));
return "[" . preg_replace_callback("/[a-z]/", "replaceToIndex", $variable) . "][" . preg_replace_callback("/[^a-z]/", "replaceToIndex", $variable) . "]"; return "[" . preg_replace_callback("/[a-z]/", "replaceToIndex", $variable) . "][" . preg_replace_callback("/[^a-z]/", "replaceToIndex", $variable) . "]";
} // generateSortArg() }
/**
* @param $arr1
* @param $arr2
* @return bool
*/
private function compareArraystart($arr1, $arr2) { private function compareArraystart($arr1, $arr2) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) { if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug() // T3 function: debug()
...@@ -1081,9 +1045,13 @@ class Report { ...@@ -1081,9 +1045,13 @@ class Report {
} }
} }
return true; return true;
} // sortIndexArray() }
/**
* @param $arr1
* @param $arr2
* @return bool
*/
private function compareArraylength($arr1, $arr2) { private function compareArraylength($arr1, $arr2) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) { if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug() // T3 function: debug()
...@@ -1094,6 +1062,5 @@ class Report { ...@@ -1094,6 +1062,5 @@ class Report {
return true; return true;
} }
return false; return false;
} // myExec() }
}
} // tx_formreport_pi1
...@@ -161,7 +161,7 @@ class Sip { ...@@ -161,7 +161,7 @@ class Sip {
} }
/** /**
* Special fucntion to fix first parameter mix of hostname / script / Get parameter and optional missing keyname * Fix first parameter mix of hostname / script / Get parameter and optional missing keyname
* *
* @param $key * @param $key
* @param $value * @param $value
......
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