function claro_html_date_form($dayFieldName, $monthFieldName, $yearFieldName, $unixDate = 0, $formatMonth = 'numeric') { if ($unixDate == 0) { $selectedDate = date('Y-m-d'); } else { $selectedDate = date('Y-m-d', $unixDate); } // split selectedDate list($selYear, $selMonth, $selDay) = explode('-', $selectedDate); // day field for ($dayCounter = 1; $dayCounter <= 31; $dayCounter++) { $available_days[$dayCounter] = $dayCounter; } $dayField = claro_html_form_select($dayFieldName, $available_days, $selDay, array('id' => $dayFieldName)); // month field if ($formatMonth == 'numeric') { for ($monthCounter = 1; $monthCounter <= 12; $monthCounter++) { $available_months[$monthCounter] = $monthCounter; } } elseif ($formatMonth == 'long') { $langMonthNames['long'] = get_lang_month_name_list('long'); for ($monthCounter = 1; $monthCounter <= 12; $monthCounter++) { $available_months[$langMonthNames['long'][$monthCounter - 1]] = $monthCounter; } } elseif ($formatMonth == 'short') { $langMonthNames['short'] = get_lang_month_name_list('short'); for ($monthCounter = 1; $monthCounter <= 12; $monthCounter++) { $available_months[$langMonthNames['short'][$monthCounter - 1]] = $monthCounter; } } $monthField = claro_html_form_select($monthFieldName, $available_months, $selMonth, array('id' => $monthFieldName)); // year field $thisYear = date('Y'); for ($yearCounter = $thisYear - 2; $yearCounter <= $thisYear + 5; $yearCounter++) { $available_years[$yearCounter] = $yearCounter; } $yearField = claro_html_form_select($yearFieldName, $available_years, $selYear, array('id' => $yearFieldName)); return $dayField . ' ' . $monthField . ' ' . $yearField; }
function claro_html_localised_date($formatOfDate, $timestamp = -1) { $langDay_of_weekNames['long'] = get_lang_weekday_name_list('long'); $langDay_of_weekNames['short'] = get_lang_weekday_name_list('short'); $langMonthNames['short'] = get_lang_month_name_list('short'); $langMonthNames['long'] = get_lang_month_name_list('long'); if ($timestamp == -1) { $timestamp = claro_time(); } // with the ereg we replace %aAbB of date format //(they can be done by the system when locale date aren't aivailable $formatOfDate = preg_replace('/%[A]/', $langDay_of_weekNames['long'][(int) strftime('%w', $timestamp)], $formatOfDate); $formatOfDate = preg_replace('/%[a]/', $langDay_of_weekNames['short'][(int) strftime('%w', $timestamp)], $formatOfDate); $formatOfDate = preg_replace('/%[B]/', $langMonthNames['long'][(int) strftime('%m', $timestamp) - 1], $formatOfDate); $formatOfDate = preg_replace('/%[b]/', $langMonthNames['short'][(int) strftime('%m', $timestamp) - 1], $formatOfDate); return strftime($formatOfDate, $timestamp); }
protected function renderContent() { $courseAccess = $this->prepareContent(); $html = ''; $html = '<table class="claroTable emphaseLine" cellpadding="2" cellspacing="1" border="0" align="center" style="width: 99%;">' . "\n" . '<thead>' . "\n" . '<tr class="headerX">' . "\n" . '<th>' . get_lang('Month') . '</th>' . "\n" . '<th>' . get_lang('Number of access') . '</th>' . "\n" . '</tr>' . "\n" . '</thead>' . "\n"; $total = 0; if (!empty($courseAccess) && is_array($courseAccess)) { $langLongMonthNames = get_lang_month_name_list('long'); $_html = ""; foreach ($courseAccess as $access) { $_html .= '<tr>' . "\n" . '<td>' . "\n" . $langLongMonthNames[date('n', $access['unix_date']) - 1] . ' ' . date('Y', $access['unix_date']) . "\n" . '</td>' . "\n" . '<td valign="top" align="right">' . (int) $access['nbr_access'] . '</td>' . "\n" . '</tr>' . "\n"; $total += (int) $access['nbr_access']; } $html .= '<tfoot>' . "\n" . '<tr>' . "\n" . '<td>' . get_lang('Total') . '</td>' . "\n" . '<td align="right">' . $total . '</td>' . "\n" . '</tr>' . "\n" . '</tfoot>' . "\n" . '<tbody>' . "\n" . $_html . '</tbody>' . "\n"; } else { $html .= '<tfoot>' . "\n" . '<tr>' . "\n" . '<td colspan="2">' . "\n" . '<center>' . get_lang('No result') . '</center>' . "\n" . '</td>' . "\n" . '</tr>' . "\n" . '</tfoot>' . "\n"; } $html .= '</table>' . "\n"; return $html; }
/** * Return an assoc array. Keys are the days, values are * the number of time this hours was found. * key 'total' return the sum of all number of time days * appear * * @param string sql query * * @return array month * */ function monthTab($sql) { $langMonthNames = get_lang_month_name_list('long'); // init tab with all month for ($i = 0; $i < 12; $i++) { $month_array[$langMonthNames[$i]] = 0; } // and with total $month_array['total'] = 0; $query = claro_sql_query($sql); while ($row = @mysql_fetch_row($query)) { $date_array = getdate($row[0]); $month_array[$langMonthNames[$date_array['mon'] - 1]]++; $month_array['total']++; } return $month_array; }