1 |
<?php |
2 |
/* This file is part of BBClone (A PHP based Web Counter on Steroids) |
3 |
* |
4 |
* SVN FILE $Id$ |
5 |
* |
6 |
* Copyright (C) 2001-2015, the BBClone Team (see doc/authors.txt for details) |
7 |
* |
8 |
* This program is free software: you can redistribute it and/or modify |
9 |
* it under the terms of the GNU General Public License as published by |
10 |
* the Free Software Foundation, either version 3 of the License, or |
11 |
* (at your option) any later version. |
12 |
* |
13 |
* This program is distributed in the hope that it will be useful, |
14 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16 |
* GNU General Public License for more details. |
17 |
* |
18 |
* See doc/copying.txt for details |
19 |
*/ |
20 |
|
21 |
//////////////////////////////// |
22 |
// Detection & Setup Language // |
23 |
//////////////////////////////// |
24 |
|
25 |
if (is_readable($BBC_LIB_PATH."html.php")) require_once($BBC_LIB_PATH."html.php"); |
26 |
else exit(bbc_msg($BBC_LIB_PATH."html.php")); |
27 |
|
28 |
// Initialising the HTML class |
29 |
$BBC_HTML = new BBC_HTML; |
30 |
|
31 |
if (is_readable($BBC_LANGUAGE_PATH.$BBC_HTML->lng.".php")) require_once($BBC_LANGUAGE_PATH.$BBC_HTML->lng.".php"); |
32 |
// When no detection, use English language as default |
33 |
elseif (is_readable($BBC_LANGUAGE_PATH."en.php")) { |
34 |
} |
35 |
else exit(bbc_msg($BBC_LANGUAGE_PATH."en.php")); |
36 |
|
37 |
/** |
38 |
* Format date/time according to given format string, in the selected language. |
39 |
* @param $format date format, as per PHP specs |
40 |
* @param $timestamp the timestamp to format |
41 |
* @return String with formatted timestamp |
42 |
*/ |
43 |
function date_format_translated($format, $timestamp) { |
44 |
global $translation; |
45 |
|
46 |
$day_name_short = array($translation['tstat_su'], $translation['tstat_mo'], $translation['tstat_tu'], $translation['tstat_we'], $translation['tstat_th'], $translation['tstat_fr'], $translation['tstat_sa']); |
47 |
$day_name_full = array($translation['tstat_full_su'], $translation['tstat_full_mo'], $translation['tstat_full_tu'], $translation['tstat_full_we'], $translation['tstat_full_th'], $translation['tstat_full_fr'], $translation['tstat_full_sa']); |
48 |
$month_name_short = array($translation['tstat_jan'], $translation['tstat_feb'], $translation['tstat_mar'], $translation['tstat_apr'], $translation['tstat_may'], $translation['tstat_jun'], |
49 |
$translation['tstat_jul'], $translation['tstat_aug'], $translation['tstat_sep'], $translation['tstat_oct'], $translation['tstat_nov'], $translation['tstat_dec']); |
50 |
$month_name_full = array($translation['tstat_full_jan'], $translation['tstat_full_feb'], $translation['tstat_full_mar'], $translation['tstat_full_apr'], $translation['tstat_full_may'], $translation['tstat_full_jun'], |
51 |
$translation['tstat_full_jul'], $translation['tstat_full_aug'], $translation['tstat_full_sep'], $translation['tstat_full_oct'], $translation['tstat_full_nov'], $translation['tstat_full_dec']); |
52 |
|
53 |
// Loop char by char through php date format string, cacth the ones which need translating |
54 |
//--- PHP 4 :-)-------------------------------- |
55 |
if(!function_exists('str_split')){ |
56 |
function str_split($str,$split_lengt=1){ |
57 |
|
58 |
$cnt = strlen($str); |
59 |
|
60 |
for ($i=0;$i<$cnt;$i+=$split_lengt) |
61 |
$rslt[]= substr($str,$i,$split_lengt); |
62 |
|
63 |
return $rslt; |
64 |
} |
65 |
} |
66 |
//---------------------------------------------- |
67 |
$result = ""; |
68 |
$format_chars = str_split($format, 1); |
69 |
foreach ($format_chars as $format_char) { |
70 |
if ($format_char == "l") { |
71 |
$day_index = date("w", $timestamp); |
72 |
$result = $result . $day_name_full[$day_index]; |
73 |
} else if ($format_char == "D") { |
74 |
$day_index = date("w", $timestamp); |
75 |
$result = $result . $day_name_short[$day_index]; |
76 |
} else if ($format_char == "F") { |
77 |
$month_index = date("n", $timestamp) - 1; |
78 |
$result = $result . $month_name_full[$month_index]; |
79 |
} else if ($format_char == "M") { |
80 |
$month_index = date("n", $timestamp) - 1; |
81 |
$result = $result . $month_name_short[$month_index]; |
82 |
} else { |
83 |
$result = $result . date($format_char, $timestamp); |
84 |
} |
85 |
} |
86 |
|
87 |
return $result; |
88 |
} |
89 |
?> |