AddCSSFile('tools/bazar/presentation/styles/damier.css');
/*******************************************************************************
* Here starts the code
******************************************************************************/
/*******************************************************************************
* As parameter ordreaffichage allows for changing of field display order,
* one must use functions to describe how to display each specific field.
* Those functions are
* - montrer_bouton to display the button
* - montrer_date to display the date
* - montrer_image to display the image
* - montrer_lieu to display the location
* - montrer_texte to display the text
* - montrer_titre to display the title
* - jolie_date called by montrer_date to convert dates into French
* - jolie_heure called by montrer_date to properly display time
******************************************************************************/
if (!function_exists('montrer_bouton'))
{
function montrer_bouton($tabfiche, $creerstylebtn, $couleur)
{
$btn_class='btn-reverse-'.$tabfiche[1];
if ($creerstylebtn){
if ($tabfiche[1] == "couleur"){
$btnstyle=' style="border-color: #ffffff; background-color: #ffffff; color: ' . $couleur . ';"';
} else {
$btnstyle=' style="border-color: ' . $couleur . '; background-color: ' . $couleur . '; color: #ffffff;"';
}
} else {
$btnstyle='';
}
$libelle_bouton=$tabfiche[0]['bf_bouton']; // button label
/* If the record stores a link, then the button activates it
* else if the record stores a file, then the button downloads it
* else there is no button */
if (isset($tabfiche[0]['bf_lien']) && ($tabfiche[0]['bf_lien']!='')){
if (ctype_alnum($tabfiche[0]['bf_lien'])) { // text link is alphanum only, therefore a page of the current wiki
$lien= $base_url . $tabfiche[0]['bf_lien'];
} else {
$lien= $tabfiche[0]['bf_lien'];
}
$button = 1;
} elseif (isset($tabfiche[0]['fichierbf_fichier']) && ($tabfiche[0]['fichierbf_fichier']!='')) {
$lien= 'files/' . $tabfiche[0]['fichierbf_fichier'];
$button = 1;
} else {
$button = 0;
}
if ($button){
$output='
';
echo $output;
}
}
}
if (!function_exists('montrer_date'))
{
function montrer_date($tabfiche, $tabordreaffichage)
{
if (isset($tabfiche[0]['bf_debut']) && ($tabfiche[0]['bf_debut']!='')){
// Only if there is a start date
// Setting a few variables
if (array_search('lieu',$tabordreaffichage)){ // there is also a location
switch (array_search('lieu',$tabordreaffichage) - array_search('date',$tabordreaffichage)) {
case -1:
// display location before date
$lieu = 1; // before
break;
case 1:
// display date before location
$lieu = 2; // after
break;
default:
// separate display of location and date
$lieu = 3; // no
break;
}
}
$moment_debut = explode('T', $tabfiche[0]['bf_debut']);
if (isset($moment_debut[1]) && ($moment_debut[1]!='')) {
$start_time = 1; // There is a time set for start date
} else {
$start_time = 0; // There isn't any time set for start date
}
if (isset($tabfiche[0]['bf_fin']) && ($tabfiche[0]['bf_fin']!='')){
$moment_fin = explode('T', $tabfiche[0]['bf_fin']);
if ($moment_debut[0] == $moment_fin[0]) {
// start and end date are the same
$same_date = 1;
} else {
$same_date = 0;
}
if (isset($moment_fin[1]) && ($moment_fin[1]!='')) {
$end_time = 1; // There is a time set for end date
if ($moment_debut[1] == $moment_fin[1]) {
// start and end time are the same
$same_time = 1;
} else {
$same_time = 0;
}
} else {
$end_time = 0; // There isn't any time set for end date
}
} else {
$moment_fin[0] = 0; // There isn't any end date (set to false)
}
// Computing the display
if ($moment_fin[0] == 0) { // no end date
$date = ($lieu == 1 ? $tabfiche[0]['bf_lieu'].', l' : 'L') . 'e ' . jolie_date($moment_debut[0]);
if ($start_time) {// start time set
$date .= ' à ' . jolie_heure($moment_debut[1]);
}
} else { // end date set
if ($same_date) { // same date
$date = ($lieu == 1 ? $tabfiche[0]['bf_lieu'].', l' : 'L') . 'e ' . jolie_date($moment_debut[0]);
if ($start_time == 0) { // There isn't any start time set
$date .= '';
} elseif ($end_time == 0) { // There isn't any end time set
$date .= ' à ' . jolie_heure($moment_debut[1]);
} elseif ($same_time == 0) { // both times exist and are different
$date .= ' – ' . jolie_heure($moment_debut[1]) .' - ' . jolie_heure($moment_fin[1]);
} else { // same times
$date .= ' à ' . jolie_heure($moment_debut[1]);
}
} else { // different dates
if ($start_time == 0) { // no start time
$date = ($lieu == 1 ? $tabfiche[0]['bf_lieu'].', d' : 'D') . 'u ' . jolie_date($moment_debut[0]) . ' au ' . jolie_date($moment_fin[0]);
} elseif ($end_time == 0) { // start time set but no end time (stupid?)
$date = ($lieu == 1 ? $tabfiche[0]['bf_lieu'].', d' : 'D') . 'u ' . jolie_date($moment_debut[0]) . ', ' . jolie_heure($moment_debut[1]) . ' au ' . jolie_date($moment_fin[0]);
} else { // both times exist
$date = ($lieu == 1 ? $tabfiche[0]['bf_lieu'].', d' : 'D') . 'u ' . jolie_date($moment_debut[0]) . ', ' . jolie_heure($moment_debut[1]) . ' au ' . jolie_date($moment_fin[0]) . ', ' . jolie_heure($moment_fin[1]);
}
}
}
if (($lieu == 2) && isset($tabfiche[0]['bf_lieu']) && ($tabfiche[0]['bf_lieu']!='')) { // display location after dates
$date .= ' – ' . $tabfiche[0]['bf_lieu'];
}
$output = '';
$output .= $date;
$output .= '
';
echo $output;
}
}
}
if (!function_exists('montrer_image'))
{
function montrer_image($tabfiche)
{
if (isset($tabfiche[0]['imagebf_image']) && ($tabfiche[0]['imagebf_image']!='')){
// Only if there is an image
$image = redimensionner_image(
'files/' . $tabfiche[0]['imagebf_image'],
'cache/image_209x209_' . $tabfiche[0]['imagebf_image'],
209,
209,
'fit'
);
$output = '';
$output .= '

';
$output .= '
';
echo $output;
}
}
}
if (!function_exists('montrer_lieu'))
{
function montrer_lieu($tabfiche, $tabordreaffichage)
{
if (isset($tabfiche[0]['bf_lieu']) && ($tabfiche[0]['bf_lieu']!='')){
// Only if there is a location
// Checking if there is work to do
if (array_search('date',$tabordreaffichage)){ // there is also a date
switch (array_search('lieu',$tabordreaffichage) - array_search('date',$tabordreaffichage)) {
case -1:
// display location before date and it's done by montrer_date
$lieu = 0; // no
break;
case 1:
// display date before location and it's done by montrer_date
$lieu = 0; // no
break;
default:
// separate display of location and date, we got to do something
$lieu = 1; // yes
break;
}
}
if ($lieu){
$output = '';
$output .= $tabfiche[0]['bf_lieu'];
$output .= '
';
echo $output;
}
}
}
}
if (!function_exists('montrer_texte'))
{
function montrer_texte($tabfiche)
{
if (isset($tabfiche[0]['bf_description']) && ($tabfiche[0]['bf_description']!='')){
// Only if there is a text
$output = '';
$output .= $tabfiche[0]['bf_description'];
$output .= '
';
echo $output;
}
}
}
if (!function_exists('montrer_titre'))
{
function montrer_titre($tabfiche)
{
$output = '';
$output .= $tabfiche[0]['bf_titre'];
$output .= '
';
echo $output;
}
}
if (!function_exists('jolie_date'))
{
function jolie_date($date_string)
{
$date = explode('-', $date_string);
$moisnoms = array('janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre');
$moisnum = array('01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12');
if ($date[2] == '01'){
$date[2] = '1er';
}
$date[1]=str_replace($moisnum, $moisnoms, $date[1]);
// $result = '' . ltrim($date[2],'0') . '' . " " . $date[1] . " " . '' . $date[0] . '';
$result=ltrim($date[2],'0')." ".$date[1]." ".$date[0];
return $result;
}
}
if (!function_exists('jolie_heure'))
{
function jolie_heure($time_string)
{
$hour = explode(':', $time_string);
// $result = '' . ltrim($hour[0],'0') . '' . 'h' . '' . ltrim($hour[1],'0') . '';
$result = ltrim($hour[0],'0') . 'h' . ltrim($hour[1],'0');
return $result;
}
}
/*******************************************************************************
* Get template parameters
******************************************************************************/
// With or without an included page above?
$pageDessus = ''; // empty char string set
$pageDessus = $GLOBALS['wiki']->GetParameter('pageDessus');
if (empty($pageDessus)) {
$pageDessus = "non"; // default value
}
// With or without an included page bellow?
$pageDessous = ''; // empty char string set
$pageDessous = $GLOBALS['wiki']->GetParameter('pageDessous');
if (empty($pageDessous)) {
$pageDessous = "non"; // default value
}
/* Cols number
* We are dealing with bootstrap grids hereafter
* So, we divide 12 by the number of cols
* Meanwhile, we need to take care of numbers of cols bigger than 12
* (then we set it back to 12)
* if $nbcol = 1 then colsize should be 12
* 2 6
* 3 4
* 4 3
* 5 2
* 6 2
* 7 - 12 1
* 12 + 1
* Therefore, before computing col width ($largeur), we "correct" $nbcol,
* (we need a proper value of $nbcol later on to compute the number of rows) */
$nbcol = $GLOBALS['wiki']->GetParameter('nbcol');
if (empty($nbcol)) {
$nbcol = 4; // default value
}
if ($nbcol > 6) {
$nbcol = 12;
}elseif ($nbcol == 5) {
$nbcol = 6;
}
$largeur=floor(12 / $nbcol);
// $$ordreaffichage specifies in wich order fields are displayed
$ordreaffichage = ''; // empty char string set
$ordreaffichage = $GLOBALS['wiki']->GetParameter('ordreaffichage');
if (empty($ordreaffichage)) {
$ordreaffichage = "image, titre, date, lieu, texte, bouton"; // default value
}
$tabordreaffichage = explode(",", $ordreaffichage);
$tabordreaffichage = array_map('trim', $tabordreaffichage);
// color used for half the tiles and buttons
$couleur = $GLOBALS['wiki']->GetParameter('couleur');
if (!empty($couleur)) {
$stylecouleur = ' style="border-color: ' . $couleur . '; background-color: ' . $couleur . '"';
$creerstylebtn = 1;
} else {
$stylecouleur = ''; // default value
$creerstylebtn = 0;
}
// base url
$base_url = $GLOBALS['wiki']->GetParameter('urldebase');
if (empty($base_url)) {
$base_url = ''; // default value
}
// value to seek in bf_exergue field to know if a record must be highlighted
$valeur_exergue = $GLOBALS['wiki']->GetParameter('valeurexergue');
if (empty($valeur_exergue)) {
$valeur_exergue=''; // default value
}
// Is each record/tile displayed with a shadow and rounded corners
$ombre_portee = $GLOBALS['wiki']->GetParameter('ombreportee');
if ($ombre_portee == 'non') {
$ombre_portee='';
} else { // default value
$ombre_portee = 'border-radius: 5px;';
$ombre_portee .= 'box-shadow: 10px 10px 5px #aaaaaa;';
}
/*******************************************************************************
* End of the parameters section
******************************************************************************/
?>
Format($includePage);
?>
0) : // We need at least one record to display it
$nb = 0;
$nblignes=ceil($nbfiches / $nbcol); // getting rows number from number of cell and of cols
/* Building an array to store required data to compute each record display
* each value of the array will contain:
* - the record itself
* - the relevant class dependant of the position of the tile on the display
* - a boolean
* true if the record/tile is to be highlighted,
* false otherwise
* - a boolean
* true if we start a line of tiles before the current record/tile,
* false otherwise
* - a boolean
* true if we end a line of tiles after the current record/tile,
* false otherwise
*/
$tabfiches = array();
foreach ($fiches as $fiche) :
// computing the position, and therefore tile color
$nb++;
$row=ceil($nb / $nbcol);
$col=$nb-($nbcol*($row-1));
if (($row + $col) % 2 == 0){
$class="couleur";
} else {
$class="blanc";
}
// Should we highlight the tile/record?
if (($valeur_exergue!='') && ($fiche['bf_exergue']==$valeur_exergue)){
$exergue=1;
} else {
$exergue=0;
}
// Should we start a grid (line) before the tile/record?
if ($col == 1) {
$start_grid = 1; // start a new grid on first col
} else {
$start_grid = 0; // nope
}
// Should we end a grid (line) after the tile/record?
if ($nb == $nbfiches) {
$end_grid = 1; // end the grid after the last record
} elseif ($col == $nbcol) {
$end_grid = 1; // end the grid after the last col
} else {
$end_grid = 0; // nope
}
$tabfiches[$nb] = array($fiche,$class,$exergue,$start_grid,$end_grid);
endforeach; //$fiches as $fiche
foreach ($tabfiches as $tabfiche):
if ($tabfiche[3]) { // first col -> start a grid
echo ' ';
}
?>
end a grid
echo '
';
echo '
';
}
endforeach; //$tabfiches as $tabfiche
endif; //$nbfiches>0
?>
Format($includePage);
?>