diff --git a/php_errors.module b/php_errors.module
index 1118840..bf670b8 100644
--- a/php_errors.module
+++ b/php_errors.module
@@ -6,9 +6,7 @@
function php_errors_help($path='', $arg) {
switch ($path) {
case 'admin/modules#description':
- return t("This module helps to manage your site's PHP Errors. It performs 3 functions: it provides a summary page of the
- watchdog's PHP errors, it archive's this summary and it may be set to email a summary report to specific email addresses
- or roles.");
+ return '
' . t("This module helps to manage your site's PHP Errors. It performs 3 functions: it provides a summary page of the watchdog's PHP errors, it archive's this summary and it may be set to email a summary report to specific email addresses or roles.") . '
';
}
}
@@ -69,7 +67,9 @@ function php_errors_menu() {
return $items;
}
-
+/**
+ * Menu callback - admin settings form.
+ */
function php_errors_admin_settings() {
// system settings
$form['php_errors_notify_addresses'] = array(
@@ -96,18 +96,18 @@ function php_errors_admin_settings() {
return system_settings_form($form);
}
-function _php_errors_show($type = NULL) {
+/**
+ * Menu callback - show detail of the php error report.
+ */
+function _php_errors_show($type = null) {
$rows = array();
- $results = db_query("SELECT count(1) cnt, timestamp ts, message ms, variables v, location
+ $results = db_query("SELECT COUNT(wid) cnt, timestamp ts, message ms, variables v, location
FROM watchdog WHERE type = 'php'
GROUP by MID(v, 62, 30) ORDER BY timestamp DESC, cnt DESC");
// and if results - lets print them out in a nice table
if ($type == 'links') {
- $header = array(
- array('data' => t('Count')),
- array('data' => t('Location')),
- );
+ $header = array(t('Count'), t('Location'));
while ($result = db_fetch_object($results)) {
$row = array();
$row[] = $result->cnt;
@@ -116,15 +116,10 @@ function _php_errors_show($type = NULL) {
}
}
else {
- $header = array(
- array('data' => t('Count')),
- array('data' => t('Date')),
- array('data' => t('Error')),
- array('data' => t('Location')),
- );
+ $header = array(t('Count'), t('Date'), t('Error'), t('Location'));
while ($result = db_fetch_object($results)) {
$variables = unserialize($result->v);
- $error = str_replace(array('%message', '%file', '%line'), array($variables['%message'], $variables['%file'], $variables['%line']), "%message in %file on line %line.");
+ $error = t("%message in %file on line %line.", $variables);
$row = array();
$row[] = $result->cnt;
$row[] = date("m-d-Y", $result->ts);
@@ -137,8 +132,11 @@ function _php_errors_show($type = NULL) {
return theme('table', $header, $rows);
}
+/**
+ * Helper function for email report.
+ */
function _php_errors_email() {
- $results = db_query("SELECT count(1) cnt, timestamp ts, message ms, location
+ $results = db_query("SELECT COUNT(wid) cnt, timestamp ts, message ms, location
FROM watchdog WHERE type = 'php'
GROUP by LEFT(ms, 30) ORDER BY timestamp DESC, cnt DESC");
@@ -156,22 +154,21 @@ function _php_errors_email() {
$rows .= strip_tags(html_entity_decode($result->ms, ENT_QUOTES)) ."\n\n";
}
- $preamble = "The following is this weeks PHP Error Summary Report.\n\nRegards,\n\n" . variable_get('site_name', 'Your Site');
+ $preamble = t("The following is this weeks PHP Error Summary Report.") . "\n\n";
+ $preamble .= t("Regards,\n\n@sitename", array('@sitename' => variable_get('site_name', t('Your Site'))));
return $preamble . $header . $rows;
}
+/**
+ * Menu callback - show list of archived PHP reports.
+ */
function _php_errors_show_archive() {
$results = db_query("SELECT * FROM {php_errors_archive} ORDER BY created DESC");
- $header = array(
- array('data' => t('Archived Reports')),
- array('' => ""),
- array('' => ""),
- array('' => "")
- );
+ $header = array(t('Archived Reports'), '', '', '');
- $row = 1;
+ $row = 1;
$col = 1;
while ($report = db_fetch_object($results)) {
if ($col > 4) {
@@ -190,21 +187,31 @@ function _php_errors_show_archive() {
return theme('table', $header, $reports);
}
-// Show an archived report
+/**
+ * Show an archived report.
+ */
function _php_errors_archive_view($rid) {
- $report = db_fetch_object(db_query("SELECT * FROM {php_errors_archive} WHERE rid = %d", $rid));
-
- drupal_set_title(t("PHP Errors") ." - Archived Report for: ". date("M d, Y", $report->created) ."");
+ $output = '';
- $output = '';
- $output .= "