Пример #1
0
 /**
  * Méthode qui formate l'affichage d'une date
  *
  * @param	date	date/heure au format YYYYMMDDHHMM
  * @param	format	format d'affichage
  * @return	string	date/heure formatée
  * @author	Stephane F.
  **/
 public static function formatDate($date, $format = '#num_day/#num_month/#num_year(4)')
 {
     # On decoupe notre date
     $year4 = substr($date, 0, 4);
     $year2 = substr($date, 2, 2);
     $month = substr($date, 4, 2);
     $day = substr($date, 6, 2);
     $day_num = date('w', mktime(0, 0, 0, $month, $day, $year4));
     $hour = substr($date, 8, 2);
     $minute = substr($date, 10, 2);
     # On retourne notre date au format humain
     $format = str_replace('#time', $hour . ':' . $minute, $format);
     $format = str_replace('#minute', $minute, $format);
     $format = str_replace('#hour', $hour, $format);
     $format = str_replace('#day', plxDate::getCalendar('day', $day_num), $format);
     $format = str_replace('#short_month', plxDate::getCalendar('short_month', $month), $format);
     $format = str_replace('#month', plxDate::getCalendar('month', $month), $format);
     $format = str_replace('#num_day(1)', intval($day), $format);
     $format = str_replace('#num_day(2)', $day, $format);
     $format = str_replace('#num_day', $day, $format);
     $format = str_replace('#num_month', $month, $format);
     $format = str_replace('#num_year(2)', $year2, $format);
     $format = str_replace('#num_year(4)', $year4, $format);
     return $format;
 }
Пример #2
0
 /**
  * M�thode qui convertit une date ISO au format humain en tenant compte du formatage pass� en param�tre
  *
  * @param	date		date au format AAAAMMJJ
  * @param	format		format de la date de sortie (variable: #minute,#hour,#day,#month,#num_day,#num_month,#num_year(2),#num_year(4))
  * @return	date		date format�e au format humain 
  **/
 public static function dateIsoToHum($date, $format = '#day #num_day #month #num_year(4)')
 {
     # On decoupe notre date
     $year4 = substr($date, 0, 4);
     $year2 = substr($date, 2, 2);
     $month = substr($date, 5, 2);
     $day = substr($date, 8, 2);
     $day_num = @date('w', @mktime(0, 0, 0, $month, $day, $year4));
     $hour = substr($date, 11, 2);
     $minute = substr($date, 14, 2);
     # On retourne notre date au format humain
     $format = str_replace('#minute', $minute, $format);
     $format = str_replace('#hour', $hour, $format);
     $format = str_replace('#day', plxDate::getCalendar('day', $day_num), $format);
     $format = str_replace('#month', plxDate::getCalendar('month', $month), $format);
     $format = str_replace('#num_day', $day, $format);
     $format = str_replace('#num_month', $month, $format);
     $format = str_replace('#num_year(2)', $year2, $format);
     $format = str_replace('#num_year(4)', $year4, $format);
     return $format;
 }
Пример #3
0
 /**
  * Méthode qui affiche la liste des archives
  *
  * @param	format	format du texte pour l'affichage (variable : #archives_id, #archives_status, #archives_nbart, #archives_url, #archives_name, #archives_month, #archives_year)
  * @return	stdout
  * @scope	global
  * @author	Stephane F
  **/
 public function archList($format = '<li id="#archives_id"><a class="#archives_status" href="#archives_url" title="#archives_name">#archives_name</a></li>')
 {
     # Hook Plugins
     if (eval($this->plxMotor->plxPlugins->callHook('plxShowArchList'))) {
         return;
     }
     $curYear = date('Y');
     $array = array();
     $plxGlob_arts = clone $this->plxMotor->plxGlob_arts;
     if ($files = $plxGlob_arts->query('/^[0-9]{4}.(?:[0-9]|home|,)*(?:' . $this->plxMotor->activeCats . '|home)(?:[0-9]|home|,)*.[0-9]{3}.[0-9]{12}.[a-z0-9-]+.xml$/', 'art', 'rsort', 0, false, 'before')) {
         foreach ($files as $id => $filename) {
             if (preg_match('/([0-9]{4}).((?:[0-9]|home|,)*(?:' . $this->plxMotor->activeCats . '|home)(?:[0-9]|home|,)*).[0-9]{3}.([0-9]{4})([0-9]{2})([0-9]{6}).([a-z0-9-]+).xml$/', $filename, $capture)) {
                 if ($capture[3] == $curYear) {
                     if (!isset($array[$capture[3]][$capture[4]])) {
                         $array[$capture[3]][$capture[4]] = 1;
                     } else {
                         $array[$capture[3]][$capture[4]]++;
                     }
                 } else {
                     if (!isset($array[$capture[3]])) {
                         $array[$capture[3]] = 1;
                     } else {
                         $array[$capture[3]]++;
                     }
                 }
             }
         }
         krsort($array);
         # Affichage pour l'année en cours
         if (isset($array[$curYear])) {
             foreach ($array[$curYear] as $month => $nbarts) {
                 $name = str_replace('#archives_id', 'archives-' . $curYear . $month, $format);
                 $name = str_replace('#archives_name', plxDate::getCalendar('month', $month) . ' ' . $curYear, $name);
                 $name = str_replace('#archives_year', $curYear, $name);
                 $name = str_replace('#archives_month', plxDate::getCalendar('month', $month), $name);
                 $name = str_replace('#archives_url', $this->plxMotor->urlRewrite('?archives/' . $curYear . '/' . $month), $name);
                 $name = str_replace('#archives_nbart', $nbarts, $name);
                 $name = str_replace('#archives_status', ($this->plxMotor->mode == "archives" and $this->plxMotor->cible == $curYear . $month) ? 'active' : 'noactive', $name);
                 echo $name;
             }
         }
         # Affichage pour les années précédentes
         unset($array[$curYear]);
         foreach ($array as $year => $nbarts) {
             $name = str_replace('#archives_id', 'archives-' . $year, $format);
             $name = str_replace('#archives_name', $year, $name);
             $name = str_replace('#archives_year', $year, $name);
             $name = str_replace('#archives_month', $year, $name);
             $name = str_replace('#archives_url', $this->plxMotor->urlRewrite('?archives/' . $year), $name);
             $name = str_replace('#archives_nbart', $nbarts, $name);
             $name = str_replace('#archives_status', ($this->plxMotor->mode == "archives" and $this->plxMotor->cible == $year) ? 'active' : 'noactive', $name);
             echo $name;
         }
     }
 }