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 {
* @return string
*/
private function doReport() {
$report = new Report();
$report = new Report($this->t3data);
$html = $report->process($this->t3data);
$html = $report->process();
return $html;
......
......@@ -11,7 +11,6 @@ namespace qfq;
//use qfq;
require_once(__DIR__ . '/Define.php');
require_once(__DIR__ . '/Utils.php');
require_once(__DIR__ . '/Variables.php');
......@@ -22,21 +21,7 @@ require_once(__DIR__ . '/Link.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 {
// 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
......@@ -49,8 +34,10 @@ class Report {
// frArray[10.50.5.sql][select ...]
private $frArray = array();
// $indexArray[10][50][5] one entry per 'sql' statement
private $indexArray = array();
// TODO to explain
// private $resultArray = array();
private $levelCount = 0;
......@@ -59,18 +46,17 @@ class Report {
* @var Variables
*/
private $variables = null;
// private $saveFile;
//class with util functions
/**
* @var Utils
*/
private $utils = null;
//TODO: wo wird die initialisiert? Im Original suchen.
/**
* @var Db
*/
private $db = null;
/**
* @var Sendmail
*/
......@@ -81,18 +67,16 @@ class Report {
// 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' => '');
//TODO:here: FAKE. Known inside Typo3 and should be transfered to Report somehow
private $cObj;
private $t3data = array();
/**
* __construct
* Report constructor.
*
* @param array $t3data
*/
public function __construct() {
public function __construct(array $t3data) {
//TODO: Fake
// $this->cObj = new cObj();
// $this->cObj->data['uid'] = 1;
$this->t3data = $t3data;
$this->page_control["msgbox"]["pagec"] = "Please confirm!";
......@@ -108,55 +92,44 @@ class Report {
$this->page_control["icon"]["pages"] = "S";
$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->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.
$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["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.
$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.
$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);
// Iteration over Bodytext
$ttLineArray = explode("\n", $t3data['bodytext']);
$ttLineArray = explode("\n", $this->t3data['bodytext']);
foreach ($ttLineArray as $index => $line) {
// Fill $frArray, $indexArray, $resultArray
$this->parseFRLine($line);
}
// Sort array
$this->sortIndexArray($this->indexArray, $this->generateSortArg());
......@@ -170,7 +143,7 @@ class Report {
}
return $content;
} // main()
}
/**
* Split line in level, command, content and fill 'frArray', 'levelCount', 'indexArray'
......@@ -215,9 +188,13 @@ class Report {
// fill Array
$this->setLine($level, $frCmd, $value);
}
} // form2hash()
}
/**
* @param $level
* @param $frCmd
* @param $value
*/
private function setLine($level, $frCmd, $value) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
......@@ -236,16 +213,16 @@ class Report {
// $indexArray[10][50][5]
$this->indexArray[] = explode(".", $level);
}
} // triggerReport()
}
/**
* Sorts the associative 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 array $ary : The unsorted Level Array
* @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
*/
private function sortIndexArray(&$ary, $clause, $ascending = true) {
private function sortIndexArray(array &$ary, $clause, $ascending = true) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
// debug(array('function' => 'sortIndexArray'));
......@@ -296,9 +273,13 @@ class Report {
$sortFn = create_function('$a,$b', $fnBody);
usort($ary, $sortFn);
}
} // collectRow()
}
/**
* generateSortArg
*
* @return string
*/
private function generateSortArg() {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
......@@ -312,7 +293,7 @@ class Report {
}
$sortArg = substr($sortArg, 0, strlen($sortArg) - 2);
return $sortArg;
} // composeLinkPart()
}
/**
* Executes the queries recursive. This Method is called for each Sublevel.
......@@ -540,7 +521,7 @@ class Report {
}
return $content;
} // doPage()
}
/**
* Determine value:
......@@ -574,7 +555,7 @@ class Report {
$this->variables->resultArray[$full_level . ".line."][$level_key] = $value;
return ($value);
} // doFixColPosPage()
}
/**
* Prepare Session Array with Hash Entry: Only for form
......@@ -599,7 +580,7 @@ class Report {
}
return ($hash);
} // renderColumn()
}
/**
* Steps through 'row' and collects all columns
......@@ -636,29 +617,19 @@ class Report {
}
}
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)
*
* @param string $columnIndex : column index of recent row
* @param string $columnName : columnname
* @param string $columnValue : content of column
* @param string $full_level : position to be processed
* @param string $rowIndex : index of row of resultset to be processed
* @param bool $show : RC: 'TRUE' content will be printed on screen
*
* @return string rendered column
*
* @param string $columnIndex
* @param string $columnName
* @param string $columnValue
* @param string $full_level
* @param string $rowIndex
* @param bool $show
* @return string rendered column
* @throws SyntaxReportException
*/
private function renderColumn($columnIndex, $columnName, $columnValue, $full_level, $rowIndex, &$show) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
......@@ -858,7 +829,7 @@ class Report {
$this->variables->resultArray[$full_level . "."][$columnName] = $content;
return $content;
} // getResultArrayIndex()
}
/**
* The main method of the PlugIn
......@@ -889,7 +860,7 @@ class Report {
$output = $rc . " - " . $output;
return ($output);
} // compareArraystart()
}
/**
* The main method of the PlugIn
......@@ -956,7 +927,7 @@ class Report {
if ($this->page_control["icon"][$columnName]) $link .= $this->page_control["icon"][$columnName] . "|";
return ($link);
} // compareArraylength()
}
/**
* If there is a value (or a defaultValue): compose it together with qualifier and delimiter.
......@@ -980,17 +951,8 @@ class Report {
return ($qualifier . ":" . $value . "|");
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
*
......@@ -1047,16 +1009,14 @@ class Report {
#debug($columnValue);
return ($columnValue);
} // setLine()
}
/**
* Generate SortArgument
*
* @param void
* @return string: sortArg
* @param $variable
* @return string
*/
//Hier wird das Sortierargument generiert
private function getResultArrayIndex($variable) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
......@@ -1066,9 +1026,13 @@ class Report {
$variable = substr($variable, 1, strlen($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) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
......@@ -1081,9 +1045,13 @@ class Report {
}
}
return true;
} // sortIndexArray()
}
/**
* @param $arr1
* @param $arr2
* @return bool
*/
private function compareArraylength($arr1, $arr2) {
if ($this->fr_error["debug_level"] >= DEBUG_EXTREME) {
// T3 function: debug()
......@@ -1094,6 +1062,5 @@ class Report {
return true;
}
return false;
} // myExec()
} // tx_formreport_pi1
}
}
......@@ -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 $value
......
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