[ Index ] |
|
Code source de Plume CMS 1.2.2 |
1 <?php 2 /* 3 # ***** BEGIN LICENSE BLOCK ***** 4 # This file is part of Plume CMS, a website management application. 5 # Copyright (C) 2001-2005 Loic d'Anterroches and contributors. 6 # 7 # Plume CMS is free software; you can redistribute it and/or modify 8 # it under the terms of the GNU General Public License as published by 9 # the Free Software Foundation; either version 2 of the License, or 10 # (at your option) any later version. 11 # 12 # Plume CMS is distributed in the hope that it will be useful, 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 # GNU General Public License for more details. 16 # 17 # The Initial Developer of the Original Code is 18 # Olivier Meunier. 19 # Portions created by the Initial Developer are Copyright (C) 2003 20 # the Initial Developer. All Rights Reserved. 21 # 22 # Contributor(s): 23 # - Sebastien Fievet 24 # 25 # You should have received a copy of the GNU General Public License 26 # along with this program; if not, write to the Free Software 27 # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 28 # 29 # ***** END LICENSE BLOCK ***** */ 30 31 class pxLink { 32 33 /** 34 * Cette fonction affiche la liste des liens 35 * 36 * @param string SQL query 37 * @param string Substitution string for the category ('<h3>%s</h3>') 38 * @param string Substitution string for the list ('<ul>%s</ul>') 39 * @param string Substitution string for each link ('<li>%s</li>') 40 */ 41 function _linkList($sql, $category='<h3>%s</h3>', $block='<ul>%s</ul>', 42 $item='<li>%s</li>') 43 { 44 $con =& pxDBConnect(); 45 if (($rs_link = $con->select($sql)) !== false) { 46 $res = ''; 47 while (!$rs_link->EOF()) { 48 $label = $rs_link->f('label'); 49 $href = $rs_link->f('href'); 50 $title = $rs_link->f('title'); 51 $lang = $rs_link->f('lang'); 52 $rel = $rs_link->f('rel'); 53 54 if (! $label && ! $href) { 55 if ('' != $res) { 56 printf($block, $res); 57 } 58 printf($category, $title); 59 $res = ''; 60 } else { 61 $link = 62 '<a href="'.htmlspecialchars($href).'"'. 63 ((!$lang) ? '' : ' hreflang="'.htmlspecialchars($lang).'"'). 64 ((!$title) ? '' : ' title="'.htmlspecialchars($title).'"'). 65 ((!$rel) ? '' : ' rel="'.htmlspecialchars($rel).'"'). 66 '>'. 67 htmlspecialchars($label). 68 '</a>'; 69 70 $res .= sprintf($item,$link); 71 } 72 $rs_link->moveNext(); 73 } 74 if ('' != $res) { 75 printf($block,$res); 76 } 77 } 78 } 79 80 /** 81 * Cette fonction affiche la liste de tous les liens 82 * 83 * @proto function linkList 84 * @param string category Chaine de substitution pour une catégorie ('<h3>%s</h3>') 85 * @param string block Chaine de substitution pour la liste ('<ul>%s</ul>') 86 * @param string item Chaine de substitution pour un élément ('<li>%s</li>') 87 */ 88 function linkList($category='<h3>%s</h3>',$block='<ul>%s</ul>',$item='<li>%s</li>') 89 { 90 $sql = 'SELECT label, href, title, lang, rel FROM '.$GLOBALS['_PX_config']['db']['table_prefix'].'links '; 91 $sql.= 'WHERE website_id=\''.$GLOBALS['_PX_website_config']['website_id'].'\' '; 92 $sql.= 'ORDER BY position'; 93 94 pxLink::_linkList($sql, $category, $block, $item); 95 } 96 97 /** 98 * Cette fonction affiche la liste des liens d'une catégorie donnée 99 * 100 * @proto function linkListByCategory 101 * @param string category_name Nom de la catégorie 102 * @param string category Chaine de substitution pour une catégorie ('<h3>%s</h3>') 103 * @param string block Chaine de substitution pour la liste ('<ul>%s</ul>') 104 * @param string item Chaine de substitution pour un élément ('<li>%s</li>') 105 */ 106 function linkListByCategory($category_name, $category='<h3>%s</h3>',$block='<ul>%s</ul>',$item='<li>%s</li>') 107 { 108 global $con; 109 if (!isset($con)) $con =& pxDBConnect(); 110 111 //-- Recupération de la position de la catégorie 112 $sql = 'SELECT position FROM '.$GLOBALS['_PX_config']['db']['table_prefix'].'links '; 113 $sql.= 'WHERE website_id=\''.$GLOBALS['_PX_website_config']['website_id'].'\' '; 114 $sql.= 'AND title = \''.$category_name.'\''; 115 116 if (($rs_category = $con->select($sql)) === false) { 117 return false; 118 } 119 120 $category_position = $rs_category->f('position'); 121 122 //-- Récupération de la position de la catégorie suivante 123 $sql = 'SELECT position FROM '.$GLOBALS['_PX_config']['db']['table_prefix'].'links '; 124 $sql.= 'WHERE website_id=\''.$GLOBALS['_PX_website_config']['website_id'].'\' '; 125 $sql.= 'AND position > '.$category_position.' '; 126 $sql.= 'AND href = \'\' '; 127 $sql.= 'LIMIT 1'; 128 129 if (($rs_next_category = $con->select($sql)) === false) { 130 return false; 131 } 132 133 $next_category_position = $rs_next_category->f('position'); 134 135 //-- Affichage des liens 136 $sql = 'SELECT label, href, title, lang, rel FROM '.$GLOBALS['_PX_config']['db']['table_prefix'].'links '; 137 $sql.= 'WHERE website_id=\''.$GLOBALS['_PX_website_config']['website_id'].'\' '; 138 $sql.= 'AND position >= '.$category_position.' '; 139 if (!empty($next_category_position)) { 140 $sql.= 'AND position < '.$next_category_position.' '; 141 } 142 $sql.= 'ORDER BY position'; 143 144 pxLink::_linkList($sql, $category, $block, $item); 145 } 146 } 147 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 11:57:01 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |