'. $output .''; } /** * Generate some charts using a pre defined method. * * @param $title * String. The chart title * @param $sql * String. The SQL statement to be executed * @param $callback * String (optional). When a string is given, use it as the * parser of the results from SQL. Its important when the * results are coded in to DB to ocupy less space, and should * be decoded. * @return * String. The HTML chart when all data is fine or a blank string */ function _charts_system_generate($title, $sql, $callback = NULL) { $results = db_query($sql); while ($result = db_fetch_array($results)) { if (!empty($callback)) { $result['name'] = $callback($result['name']); } $data[] = array( '#value' => $result['count'], '#label' => $result['name'] .': '. $result['count'] ); } if (!empty($data)) { $chart = array(); $chart[0] = $data; $chart['#title'] = $title; $chart['#type'] = 'pie2D'; return charts_chart($chart); } return ''; } /** * Show which kind of node type was created in the current month. * * @return * String. The HTML chart when all data is fine or a blank string */ function _charts_system_node_activity() { $now = time(); $results = db_query('SELECT type, created FROM {node} WHERE created < %d AND created > %d ORDER BY created', $now, mktime(0, 0, 0, date('m', $now), 1, date('Y', $now)) ); $max = array(); $counts = array(); $types = array(); while ($result = db_fetch_array($results)) { $day = ltrim(date('d', $result['created']), '0'); $types[$result['type']] = $type++; $counts[$day][$result['type']]++; } // Generate data and labels if (!empty($counts)) { foreach ($types as $type => $index) { $chart[$type]['#legend'] = $type; for ($i = 1; $i <= date('d', $now); $i++) { $chart[$type][] = array( '#value' => empty($counts[$i][$type]) ? 0 : $counts[$i][$type], '#label' => $i ); } } $chart['#title'] = t('Activity for !date', array('!date' => date('F Y', $now))); $chart['#type'] = 'line2D'; return charts_chart($chart); } return ''; } /** * Translate the user status label code to a string * * @param status * Number. 1 for Active and 0 for Blocked * @return * String. The given status */ function _charts_system_user_status_label($status) { return $status ? t('Active') : t('Blocked'); } /** * Translate the message severity label code to a string * * @param status * Number. According to watchdog constants, the severity level * @return * String. The given severity */ function _charts_system_watchdog_severity_label($severity) { switch ($severity) { case WATCHDOG_NOTICE: return t('Notice'); case WATCHDOG_WARNING: return t('Warning'); case WATCHDOG_ERROR: return t('Error'); } }