mirror of
https://github.com/e107inc/e107.git
synced 2025-08-05 06:07:32 +02:00
Removed Months and Days from language files. Replaced with strftime() functions. New 'terms' method added to Date handler.
eg. e107::getDate()->terms('month'); returns an array of month names in the current language.
This commit is contained in:
@@ -24,6 +24,63 @@ class convert
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return an array of language terms representing months
|
||||
* @param $type string : month, month-short, day, day-short, day-shortest
|
||||
* @return array
|
||||
* TODO Cache!
|
||||
*/
|
||||
public function terms($type='month')
|
||||
{
|
||||
if($type == 'month' || $type == 'month-short')
|
||||
{
|
||||
$val = ($type == 'month-short') ? '%b' : '%B'; //eg. 'Aug' / 'August'
|
||||
$marray = array();
|
||||
for ($i=1; $i < 13; $i++)
|
||||
{
|
||||
$marray[] = strftime($val,mktime(1,1,1,$i,1,2000));
|
||||
}
|
||||
|
||||
return $marray;
|
||||
}
|
||||
|
||||
if(substr($type,0,3) == 'day')
|
||||
{
|
||||
$days = array();
|
||||
for ($i=2; $i < 9; $i++)
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case 'day-shortest': // eg. 'Tu'
|
||||
$days[] = substr(strftime('%a',mktime(1,1,1,6,$i,2014)),0,2);
|
||||
break;
|
||||
|
||||
case 'day-short': // eg. 'Tue'
|
||||
$days[] = strftime('%a',mktime(1,1,1,6,$i,2014));
|
||||
break;
|
||||
|
||||
default: // eg. 'Tuesday'
|
||||
$days[] = strftime('%A',mktime(1,1,1,6,$i,2014));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $days;
|
||||
}
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Convert datestamp to human readable date.
|
||||
* System time offset is considered.
|
||||
|
@@ -30,9 +30,10 @@ require_once(HEADERF);
|
||||
// ---------------------
|
||||
$bcSql = new db;
|
||||
$prefix = e_PLUGIN_ABS."blogcalendar_menu";
|
||||
$marray = array(BLOGCAL_M1, BLOGCAL_M2, BLOGCAL_M3, BLOGCAL_M4,
|
||||
BLOGCAL_M5, BLOGCAL_M6, BLOGCAL_M7, BLOGCAL_M8,
|
||||
BLOGCAL_M9, BLOGCAL_M10, BLOGCAL_M11, BLOGCAL_M12);
|
||||
$marray = e107::getDate()->terms('month');
|
||||
|
||||
|
||||
|
||||
// if nr of rows per month is not set, default to 3
|
||||
$months_per_row = $pref['blogcal_mpr']?$pref['blogcal_mpr']:
|
||||
"3";
|
||||
|
@@ -34,7 +34,11 @@ if(false === $cached)
|
||||
// initialization + fetch options
|
||||
// ------------------------------
|
||||
$prefix = e_PLUGIN_ABS."blogcalendar_menu";
|
||||
$marray = array(BLOGCAL_M1, BLOGCAL_M2, BLOGCAL_M3, BLOGCAL_M4, BLOGCAL_M5, BLOGCAL_M6, BLOGCAL_M7, BLOGCAL_M8, BLOGCAL_M9, BLOGCAL_M10, BLOGCAL_M11, BLOGCAL_M12);
|
||||
$marray = e107::getDate()->terms('month');
|
||||
|
||||
|
||||
|
||||
|
||||
$pref['blogcal_ws'] = "monday";
|
||||
|
||||
// ----------------------------------------------
|
||||
|
@@ -32,8 +32,8 @@ function calendar($req_day, $req_month, $req_year, $links = NULL, $ws = "sunday"
|
||||
$pref = e107::getPref();
|
||||
|
||||
// prepare the day array
|
||||
$darray = array(BLOGCAL_D1, BLOGCAL_D2, BLOGCAL_D3, BLOGCAL_D4, BLOGCAL_D5, BLOGCAL_D6, BLOGCAL_D7);
|
||||
$marray = array('',BLOGCAL_M1, BLOGCAL_M2, BLOGCAL_M3, BLOGCAL_M4, BLOGCAL_M5, BLOGCAL_M6, BLOGCAL_M7, BLOGCAL_M8, BLOGCAL_M9, BLOGCAL_M10, BLOGCAL_M11, BLOGCAL_M12);
|
||||
$darray = e107::getDate()->terms('day-shortest');
|
||||
$marray = e107::getDate()->terms('month');
|
||||
|
||||
// what day does the week start on?
|
||||
switch($ws)
|
||||
|
@@ -10,28 +10,6 @@
|
||||
|
||||
define("BLOGCAL_L1", "News by month");
|
||||
define("BLOGCAL_L2", "Archive");
|
||||
|
||||
define("BLOGCAL_D1", "Mo");
|
||||
define("BLOGCAL_D2", "Tu");
|
||||
define("BLOGCAL_D3", "We");
|
||||
define("BLOGCAL_D4", "Th");
|
||||
define("BLOGCAL_D5", "Fr");
|
||||
define("BLOGCAL_D6", "Sa");
|
||||
define("BLOGCAL_D7", "Su");
|
||||
|
||||
define("BLOGCAL_M1", "January");
|
||||
define("BLOGCAL_M2", "February");
|
||||
define("BLOGCAL_M3", "March");
|
||||
define("BLOGCAL_M4", "April");
|
||||
define("BLOGCAL_M5", "May");
|
||||
define("BLOGCAL_M6", "June");
|
||||
define("BLOGCAL_M7", "July");
|
||||
define("BLOGCAL_M8", "August");
|
||||
define("BLOGCAL_M9", "September");
|
||||
define("BLOGCAL_M10", "October");
|
||||
define("BLOGCAL_M11", "November");
|
||||
define("BLOGCAL_M12", "December");
|
||||
|
||||
define("BLOGCAL_1", "News Items");
|
||||
|
||||
define("BLOGCAL_CONF1", "Months/row");
|
||||
@@ -39,7 +17,6 @@ define("BLOGCAL_CONF2", "Cellpadding");
|
||||
//define("BLOGCAL_CONF3", "Update Menu Settings");
|
||||
define("BLOGCAL_CONF4", "BlogCal Menu Configuration");
|
||||
//define("BLOGCAL_CONF5", "BlogCal menu configuration saved");
|
||||
|
||||
define("BLOGCAL_ARCHIV1", "Select Archive");
|
||||
|
||||
?>
|
@@ -33,10 +33,7 @@ if(false === $cached)
|
||||
$tp = e107::getParser();
|
||||
$sql = e107::getDb();
|
||||
|
||||
$marray = array(BLOGCAL_M1, BLOGCAL_M2, BLOGCAL_M3, BLOGCAL_M4,
|
||||
BLOGCAL_M5, BLOGCAL_M6, BLOGCAL_M7, BLOGCAL_M8,
|
||||
BLOGCAL_M9, BLOGCAL_M10, BLOGCAL_M11, BLOGCAL_M12);
|
||||
|
||||
$marray = e107::getDate()->getTerms('month');
|
||||
|
||||
// TODO parms
|
||||
//$parms['year'] = "2011 0";
|
||||
|
Reference in New Issue
Block a user