// Is it a bug report?
if ($isBugReport === TRUE) {
// Then add a reply-to line back to the author (me)
- $mailHeader = 'Reply-To: webmaster@mxchange.org' . chr(10);
+ $mailHeader = 'Reply-To: webmaster@mxchange.org' . PHP_EOL;
} // END - if
// Load all admin email addresses
}
// List all given rows (callback function from XML)
-function doGenericListEntries ($tableTemplate, $rowTemplate, $noEntryMessageId, $tableName, $columns, $whereColumns, $orderByColumns, $callbackColumns, $extraParameters = array(), $conditions = array()) {
+function doGenericListEntries ($tableTemplate, $rowTemplate, $noEntryMessageId, $tableName, $columns, $whereColumns, $orderByColumns, $callbackColumns, $extraParameters = array(), $conditions = array(), $content = array()) {
// Verify that tableName and columns are not empty
if ((!is_array($tableName)) || (count($tableName) != 1)) {
// No tableName specified
} // END - if
// Now handle all over to the inner function which will execute the listing
- doListEntries($sql, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters);
+ doListEntries($sql, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters, $content);
}
// Do the listing of entries
-function doListEntries ($sql, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters = array()) {
+function doListEntries ($sql, $tableTemplate, $noEntryMessageId, $rowTemplate, $callbackColumns, $extraParameters = array(), $content = array()) {
// Run the SQL query
$result = SQL_QUERY($sql, __FUNCTION__, __LINE__);
if (!SQL_HASZERONUMS($result)) {
// List all URLs
$OUT = '';
- while ($content = SQL_FETCHARRAY($result)) {
+ while ($row = SQL_FETCHARRAY($result)) {
// "Translate" content
foreach ($callbackColumns as $columnName => $callbackName) {
// Fill the callback arguments
- $args = array($content[$columnName]);
+ $args = array($row[$columnName]);
// Is there more to add?
if (isset($extraParameters[$columnName])) {
// Call the callback-function
//* NOISY-DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'callbackFunction=' . $callbackName . ',args=<pre>'.print_r($args, TRUE).'</pre>');
// @TODO If we can rewrite the EL sub-system to support more than one parameter, this call_user_func_array() can be avoided
- $content[$columnName] = call_user_func_array($callbackName, $args);
+ $row[$columnName] = call_user_func_array($callbackName, $args);
} // END - foreach
// Load row template
- $OUT .= loadTemplate(trim($rowTemplate[0]), TRUE, $content);
+ $OUT .= loadTemplate(trim($rowTemplate[0]), TRUE, $row);
} // END - while
+ // Is at least one entry set in content?
+ if ((is_array($content)) && (count($content) > 0)) {
+ // Then add generic 'rows' element
+ $content['rows'] = $OUT;
+ } else {
+ // Direct output is content
+ $content = $OUT;
+ }
+
// Load main template
- loadTemplate(trim($tableTemplate[0]), FALSE, $OUT);
+ loadTemplate(trim($tableTemplate[0]), FALSE, $content);
} else {
// No URLs in surfbar
displayMessage('{--' .$noEntryMessageId[0] . '--}');
}
// Build a special template list
-function doGenericListBuilder ($prefix, $listType, $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId = array('userid')) {
+// @TODO cacheFiles is not yet supported
+function doGenericListBuilder ($prefix, $listType, $tableName, $columns, $filterFunctions, $extraValues, $idColumn, $userIdColumn, $rawUserId = array('userid'), $content = array()) {
// $tableName and $idColumn must bove be arrays!
if ((!is_array($tableName)) || (count($tableName) != 1)) {
// $tableName is no array
// Is there one entry?
if (SQL_NUMROWS($result) == 1) {
// Load all data
- $content = SQL_FETCHARRAY($result);
+ $row = SQL_FETCHARRAY($result);
// Filter all data
- foreach ($content as $key => $value) {
+ foreach ($row as $key => $value) {
// Search index
$idx = searchXmlArray($key, $columns, 'column');
if ($key == $userIdColumn[0]) {
// Add it again as raw id
//* DEBUG: */ reportBug(__FUNCTION__, __LINE__, 'key=' . $key . ',userIdColumn=' . $userIdColumn[0]);
- $content[$userIdColumn[0]] = convertZeroToNull($value);
- $content[$userIdColumn[0] . '_raw'] = $content[$userIdColumn[0]];
+ $row[$userIdColumn[0]] = convertZeroToNull($value);
+ $row[$userIdColumn[0] . '_raw'] = $row[$userIdColumn[0]];
} // END - if
// If the key matches the idColumn variable, we need to temporary remember it
} // END - if
// Try to handle call-back functions and/or extra values
- $content[$key] = doHandleExtraValues($filterFunctions, $extraValues, $idx, $content[$key], $userIdColumn, $idx);
+ //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'idx=' . $idx . ',row[' . $key . ']=' . $row[$key]);
+ $row[$key] = doHandleExtraValues($filterFunctions, $extraValues, $idx, $row[$key], $userIdColumn, $key);
} // END - foreach
// Then list it
$prefix,
$listType,
$tableName[0]
- ), TRUE, $content
+ ), TRUE, $row
);
} // END - if
SQL_FREERESULT($result);
} // END - foreach
+ // Is there an entry in $content?
+ if ((is_array($content)) && (count($content) > 0)) {
+ // Use generic 'rows'
+ $content['rows'] = $OUT;
+ } else {
+ // Use direct output
+ $content = $OUT;
+ }
+
// Load master template
loadTemplate(sprintf("%s_%s_%s",
$prefix,
$listType,
$tableName[0]
- ), FALSE, $OUT
+ ), FALSE, $content
);
}