use_smilies = (boolean) $v;
}
function setSmiliesPath($p,$url)
{
$this->smilies_path = $p;
$this->smilies_url = $url;
# Tableau des smilies
$def_path = $this->smilies_path.'/smilies.txt';
if ($this->use_smilies && file_exists($def_path))
{
$def = file($def_path);
$this->arry_smilies = array();
foreach($def as $v)
{
$v = trim($v);
if (preg_match('|^([^\t]*)[\t]+(.*)$|',$v,$matches))
{
$r = '/(\A|[\s]+|>)('.preg_quote($matches[1],'/').')([\s]+|[<]|\Z)/ms';
$s = '$1$3';
$this->arry_smilies[$r] = $s;
}
}
}
}
function addSmilies($str)
{
if (!empty($this->arry_smilies) && is_array($this->arry_smilies))
{
return preg_replace(array_keys($this->arry_smilies),array_values($this->arry_smilies),$str);
}
else
{
return $str;
}
}
function xCalendar($year,$month,$day,$cat_id,$lang,
$block='
')
{
$arry_months = $GLOBALS['arry_months'];
$comp_url = '';
if ($lang) {
$comp_url .= $lang.'/';
}
if($cat_id) {
$comp_url .= $cat_id.'/';
}
if($month == '' || $year == '') {
$recent = $this->getEarlierDate($cat_id);
$actual_month = date('m',strtotime($recent));
$actual_year = date('Y',strtotime($recent));
} else {
$actual_month = $month;
$actual_year = $year;
}
$days = $this->getAllDates('d',$actual_year,$actual_month,'',$cat_id);
$ts = strtotime($actual_year.'-'.$actual_month.'-01');
$first = date('w',$ts);
$first = ($first == 0) ? 6 : ($first-1);
# Limite de fin du mois
$limit = date('t',$ts);
# Mois suivant / précédent
$link_next = $link_prev = '';
if (($l_next = util::getNextPrev($arry_months,$ts,'prev')) !== NULL) {
$ts_next = key($l_next);
$m_next = date('m',$ts_next);
$y_next = date('Y',$ts_next);
$link_next = ' »';
}
if (($l_prev = util::getNextPrev($arry_months,$ts,'next')) !== NULL) {
$ts_prev = key($l_prev);
$m_prev = date('m',$ts_prev);
$y_prev = date('Y',$ts_prev);
$link_prev = '« ';
}
$d=1; $i=0; $dstart=false;
$res = "\n".$link_prev.dt::str('%B %Y',$ts).$link_next.'';
$res .= '';
$monday_ts = strtotime('2003-01-06 00:00:00');
$sunday_ts = strtotime('2003-01-12 00:00:00');
for($j=$monday_ts;$j<=$sunday_ts;$j=$j+86400) {
$res .= ''.
dt::str('%a',$j).' | ';
}
$res .= "
\n";
$res .= '';
while($i<42)
{
if($i%7 == 0)
$res .= '';
if($i == $first) {
$dstart = true;
}
if($dstart && !checkdate($actual_month,$d,$actual_year)) {
$dstart = false;
}
if(!empty($days[strtotime($actual_year.'-'.$actual_month.'-'.$d)])) {
$url = sprintf($this->front_url['day'],$comp_url.$actual_year,$actual_month,$d);
$link = '%s';
} else {
$link = '%s';
}
$class = ($day == $d && $dstart) ? ' class="active"' : '';
$res .= '';
$res .= ($dstart) ? sprintf($link,$d) : ' ';
$res .= ' | ';
if(($i+1)%7 == 0)
{
$res .= '
'."\n";
if ($d>=$limit) { $i=42; }
}
$i++;
if($dstart) { $d++; }
}
$res .= "\n";
return sprintf($block,$res);
}
}
?>