$limit) { $output = new HtmlCutString($string, $limit); return ($output->cut()).'...'; } else { return $string; } } // Recupère le nom d'un coucours à partir de l'id function get_contest_name($id) { $contest = pwg_query("SELECT name FROM " . CR_TABLE_1 . " WHERE id = " . $id . ";"); if (pwg_db_num_rows($contest)) { $contest = pwg_db_fetch_assoc($contest); return $contest['name']; } else { return false; } } // Nombre de jours entre deux dates function date_diff($date2, $date1) { return ceil((strtotime($date2)-strtotime($date1))/(3600*24)); } // Date passée function is_date_passed($date) { if (time() > strtotime($date)) { return true; } else { return false; } } // Calcul le status d'un concours function get_contest_status($date_begin, $date_end) { if (!is_date_passed($date_begin)) { $contest['status'] = 'pending'; $contest['days'] = l10n_dec('CR_%d_days_to_begin', 'CR_%d_days_to_begin', date_diff($date_begin,date('Y-m-d'))); } else if (is_date_passed($date_end)) { $contest['status'] = 'finished'; $contest['days'] = l10n('CR_finished'); } else { $contest['status'] = 'running'; $contest['days'] = l10n_dec('CR_%d_days_to_end', 'CR_%d_days_to_end', date_diff($date_end,date('Y-m-d'))); } return $contest; } ?>