Beispiel #1
0
 /**
  * Méthode qui affiche la liste des $max derniers articles.
  * Si la variable $cat_id est renseignée, seuls les articles de cette catégorie sont retournés.
  * On tient compte si la catégorie est active
  *
  * @param	format	format du texte pour chaque article
  * @param	max		nombre d'articles maximum
  * @param	cat_id	ids des catégories cible
  * @param   ending	texte à ajouter en fin de ligne
  * @param	sort	tri de l'affichage des articles (sort|rsort|alpha|random)
  * @return	stdout
  * @scope	global
  * @author	Florent MONTHEL, Stephane F
  **/
 public function lastArtList($format = '<li><a href="#art_url" title="#art_title">#art_title</a></li>', $max = 5, $cat_id = '', $ending = '', $sort = 'rsort')
 {
     # Hook Plugins
     if (eval($this->plxMotor->plxPlugins->callHook('plxShowLastArtList'))) {
         return;
     }
     # Génération de notre motif
     if (empty($cat_id)) {
         $motif = '/^[0-9]{4}.(?:[0-9]|home|,)*(?:' . $this->plxMotor->activeCats . '|home)(?:[0-9]|home|,)*.[0-9]{3}.[0-9]{12}.[a-z0-9-]+.xml$/';
     } else {
         $motif = '/^[0-9]{4}.((?:[0-9]|home|,)*(?:' . str_pad($cat_id, 3, '0', STR_PAD_LEFT) . ')(?:[0-9]|home|,)*).[0-9]{3}.[0-9]{12}.[a-z0-9-]+.xml$/';
     }
     # Nouvel objet plxGlob et récupération des fichiers
     $plxGlob_arts = clone $this->plxMotor->plxGlob_arts;
     if ($aFiles = $plxGlob_arts->query($motif, 'art', $sort, 0, $max, 'before')) {
         foreach ($aFiles as $v) {
             # On parcourt tous les fichiers
             $art = $this->plxMotor->parseArticle(PLX_ROOT . $this->plxMotor->aConf['racine_articles'] . $v);
             $num = intval($art['numero']);
             $date = $art['date'];
             if ($this->plxMotor->mode == 'article' and $art['numero'] == $this->plxMotor->cible) {
                 $status = 'active';
             } else {
                 $status = 'noactive';
             }
             # Mise en forme de la liste des catégories
             $catList = array();
             $catIds = explode(',', $art['categorie']);
             foreach ($catIds as $idx => $catId) {
                 if (isset($this->plxMotor->aCats[$catId])) {
                     # La catégorie existe
                     $catName = plxUtils::strCheck($this->plxMotor->aCats[$catId]['name']);
                     $catUrl = $this->plxMotor->aCats[$catId]['url'];
                     $catList[] = '<a title="' . $catName . '" href="' . $this->plxMotor->urlRewrite('?categorie' . intval($catId) . '/' . $catUrl) . '">' . $catName . '</a>';
                 } else {
                     $catList[] = L_UNCLASSIFIED;
                 }
             }
             # On modifie nos motifs
             $row = str_replace('#art_id', $num, $format);
             $row = str_replace('#cat_list', implode(', ', $catList), $row);
             $row = str_replace('#art_url', $this->plxMotor->urlRewrite('?article' . $num . '/' . $art['url']), $row);
             $row = str_replace('#art_status', $status, $row);
             $author = plxUtils::getValue($this->plxMotor->aUsers[$art['author']]['name']);
             $row = str_replace('#art_author', plxUtils::strCheck($author), $row);
             $row = str_replace('#art_title', plxUtils::strCheck($art['title']), $row);
             $strlength = preg_match('/#art_chapo\\(([0-9]+)\\)/', $row, $capture) ? $capture[1] : '100';
             $chapo = plxUtils::truncate($art['chapo'], $strlength, $ending, true, true);
             $row = str_replace('#art_chapo(' . $strlength . ')', '#art_chapo', $row);
             $row = str_replace('#art_chapo', $chapo, $row);
             $strlength = preg_match('/#art_content\\(([0-9]+)\\)/', $row, $capture) ? $capture[1] : '100';
             $content = plxUtils::truncate($art['content'], $strlength, $ending, true, true);
             $row = str_replace('#art_content(' . $strlength . ')', '#art_content', $row);
             $row = str_replace('#art_content', $content, $row);
             $row = str_replace('#art_date', plxDate::formatDate($date, '#num_day/#num_month/#num_year(4)'), $row);
             $row = str_replace('#art_hour', plxDate::formatDate($date, '#hour:#minute'), $row);
             $row = str_replace('#art_time', plxDate::formatDate($date, '#time'), $row);
             $row = plxDate::formatDate($date, $row);
             $row = str_replace('#art_nbcoms', $art['nb_com'], $row);
             $row = str_replace('#art_thumbnail', '<img class="art_thumbnail" src="#img_url" alt="#img_alt" title="#img_title" />', $row);
             $row = str_replace('#img_url', $this->plxMotor->urlRewrite($art['thumbnail']), $row);
             $row = str_replace('#img_title', $art['thumbnail_title'], $row);
             $row = str_replace('#img_alt', $art['thumbnail_alt'], $row);
             # Hook plugin
             eval($this->plxMotor->plxPlugins->callHook('plxShowLastArtListContent'));
             # On genère notre ligne
             echo $row;
         }
     }
 }