| [ 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 /** 32 * Small note on design: 33 * 34 * Both links and categories are stored in the same database table. 35 * The difference is that 'label' and 'href' fields are empty for categories. 36 * 37 * This is quite hacky but perfectly fits a simple two level design. 38 * 39 */ 40 $m->l10n->loadPlugin($m->user->lang, 'link'); 41 42 require dirname(__FILE__).'/class.link.php'; 43 Hook::register('onPrintHeaderManagerPage', 'Link', 'insertHeader'); 44 45 if (!isset($con)) { 46 $con =& pxDBConnect(); 47 } 48 49 $url = 'tools.php?p=link'; 50 $icon = 'tools/link/themes/'.$_px_theme.'/icon_small.png'; 51 52 $link = new link($_SESSION['website_id']); 53 54 if(!$link->isRunning()) { 55 $_REQUEST['action']='install'; 56 } 57 58 $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : NULL; 59 $page = !empty($_REQUEST['page']) ? $_REQUEST['page'] : NULL; 60 $err = ''; 61 62 if ($action == 'install') { 63 include dirname(__FILE__).'/dbinstall.php'; 64 } 65 66 if ($page == 'edit_link' && !empty($_REQUEST['id'])) 67 { 68 include dirname(__FILE__).'/edit_link.php'; 69 } 70 elseif ($page == 'edit_cat' && !empty($_REQUEST['id'])) 71 { 72 include dirname(__FILE__).'/edit_cat.php'; 73 } 74 else 75 { 76 $l_label = $l_title = $l_href = $l_lang = ''; 77 $c_title = ''; 78 79 # Ajout d'un lien 80 if ($action == 'add_link') 81 { 82 $l_label = trim($_POST['l_label']); 83 $l_title = trim($_POST['l_title']); 84 $l_href = trim($_POST['l_href']); 85 $l_lang = trim($_POST['l_lang']); 86 $l_cat = trim($_POST['l_cat']); 87 88 if (!$l_label || !$l_href) 89 { 90 $err = __('You must provide at least a label and an URL'); 91 } 92 elseif (!$link->isURI($l_href, array('domain_check' => false, 'allowed_schemes' => $link->protocols))) { 93 $err = __('You must provide a valid URL'); 94 } 95 else 96 { 97 if ($link->addLink($l_label,$l_href,$l_title,$l_lang,$l_cat) == false) { 98 $err = $link->con->error(); 99 } else { 100 header('Location: '.$url); 101 exit; 102 } 103 } 104 } 105 # Ajout d'une catégorie 106 elseif ($action == 'add_cat') 107 { 108 $c_title = trim($_POST['c_title']); 109 110 if ($c_title) 111 { 112 if ($link->addCat($c_title) == false) { 113 $err = $link->con->error(); 114 } else { 115 header('Location: '.$url); 116 exit; 117 } 118 } 119 } 120 # Suppression 121 elseif ($action == 'delete' && !empty($_GET['id'])) 122 { 123 if ($link->delEntry($_GET['id']) == false) { 124 $err = $link->con->error(); 125 } else { 126 header('Location: '.$url.'#link'); 127 exit; 128 } 129 } 130 # Classic ord 131 if (isset($_POST['linkOrd']) && is_array($_POST['linkOrd'])) 132 { 133 if ($link->ordEntries($_POST['linkOrd']) === false) { 134 $err = $link->con->error(); 135 } else { 136 header('Location: '.$url); 137 exit; 138 } 139 } 140 # DragNdrop 141 if (!empty($_POST['dndSort'])) 142 { 143 $linkOrd = array(); 144 foreach (explode(';',$_POST['dndSort']) as $k => $v) { 145 $linkOrd[substr($v,3)] = $k; 146 } 147 148 if ($link->ordEntries($linkOrd) === false) { 149 $err = $link->con->error(); 150 } else { 151 header('Location: '.$url); 152 exit; 153 } 154 } 155 # Monter / descendre un lien 156 elseif (($action == 'up_link' || $action == 'down_link') && !empty($_GET['id'])) 157 { 158 $dir = ($action == 'up_link') ? '+' : '-'; 159 160 if ($link->ordLink($_GET['id'],$dir) == false) { 161 $err = $link->con->error(); 162 } else { 163 header('Location: '.$url.'#link'); 164 exit; 165 } 166 } 167 # Monter / descendre une catégorie 168 elseif (($action == 'up_cat' || $action == 'down_cat') && !empty($_GET['id'])) 169 { 170 $dir = ($action == 'up_cat') ? '+' : '-'; 171 172 if ($link->ordCat($_GET['id'],$dir) == false) { 173 $err = $link->con->error(); 174 } else { 175 header('Location: '.$url.'#link'); 176 exit; 177 } 178 } 179 180 # Affichage --- 181 echo('<h2>'.__('Links manager').'</h2>'); 182 183 if ($err != '') { 184 echo( 185 '<div class="erreur"><p><strong>'.__('Error(s)').' :</strong></p>'. 186 '<p>'.$err.'</p>'. 187 '</div>' 188 ); 189 } 190 191 $rs =& $link->getEntries(); 192 193 echo( 194 '<p>'.__('Drag items to change their positions.').'</p>'. 195 '<form action="'.$url.'" method="post">'. 196 '<div id="sortlinks">' 197 ); 198 while (!$rs->EOF()) 199 { 200 $link_id = $rs->f('link_id'); 201 $link_ord = $rs->f('position'); 202 203 $is_cat = !$rs->f('label') && !$rs->f('href'); 204 205 $i_label = ($is_cat) ? $rs->f('title') : $rs->f('label'); 206 207 if ($is_cat) { 208 $del_msg = __('Are you sure you want to delete this category?'); 209 } else { 210 $del_msg = sprintf(__('Are you sure you want to delete this %s?'),__('link')); 211 } 212 213 echo('<div class="sort" id="dnd'.$link_id.'">'); 214 215 echo( 216 '<p>'.($is_cat ? '<strong>' : ''). 217 '<a href="'.$url.'&action=delete&id='.$link_id.'" '. 218 'onclick="return window.confirm(\''.addslashes($del_msg).'\')">'. 219 '<img src="themes/'.$_px_theme.'/images/delete.png" alt="'.__('delete').'" '. 220 'title="'.__('delete').'" class="status" /></a>' 221 ); 222 223 224 if ($is_cat) { 225 echo('<a href="'.$url.'&id='.$link_id.'&page=edit_cat">'. 226 $i_label.'</a>'); 227 } else { 228 echo('<a href="'.$url.'&id='.$link_id.'&page=edit_link">'. 229 $i_label.'</a>'); 230 } 231 232 echo(($is_cat ? '</strong>' : '').'</p>'); 233 234 if (!$is_cat) 235 { 236 echo( 237 '<p>'. 238 htmlspecialchars($rs->f('href')). 239 ' - '.$rs->f('title'). 240 ' ('.$rs->f('lang').')'. 241 '</p>' 242 ); 243 } 244 245 echo('<p class="nojsfield">'); 246 247 if ($rs->int_index > 0) { 248 echo( 249 '<a href="'.$url.'&id='.$link_id.'&action=up_'.($is_cat ? 'cat' : 'link').'">'. 250 '<img src="tools/link/themes/'.$_px_theme.'/images/arrow_up.png" '. 251 'alt="'.sprintf(__('Move %s up'), $i_label).'" /></a>' 252 ); 253 } else { 254 echo('<img src="themes/'.$_px_theme.'/images/empty.png" alt="" width="12" />'); 255 } 256 257 if ($rs->int_index+1 < $rs->nbRow()) { 258 echo( 259 '<a href="'.$url.'&id='.$link_id.'&action=down_'.($is_cat ? 'cat' : 'link').'">'. 260 '<img src="tools/link/themes/'.$_px_theme.'/images/arrow_down.png" '. 261 'alt="'.sprintf(__('Move %s down'),$i_label).'" /></a>' 262 ); 263 } else { 264 echo('<img src="themes/'.$_px_theme.'/images/empty.png" alt="" width="12" />'); 265 } 266 267 echo('</p>'); 268 269 echo('</div>'); 270 271 $rs->moveNext(); 272 } 273 echo( 274 '</div>'. 275 '<p><input type="hidden" id="dndSort" name="dndSort" value="" />'. 276 '<input type="submit" class="submit" value="'.__('save order').'" /></p>'. 277 '</form>' 278 ); 279 280 echo( 281 '<form action="'.$url.'" method="post">'. 282 '<fieldset><legend>'.__('New link').'</legend>'. 283 '<p class="field"><strong>'. 284 '<label for="l_label" class="float">'.__('Label').' : </label></strong>'. 285 form::textField('l_label', 40, 255, $l_label).'</p>'. 286 287 '<p class="field"><strong>'. 288 '<label for="l_href" class="float">'.__('URL').' : </label></strong>'. 289 form::textField('l_href', 40, 255, $l_href).'</p>'. 290 291 '<p class="field">'. 292 '<label for="l_title" class="float">'.__('Description').' ('.__('optional').') : </label>'. 293 form::textField('l_title', 40, 255, $l_title).'</p>'. 294 295 '<p class="field">'. 296 '<label for="l_lang" class="float">'.__('Language').' ('.__('optional').') : </label>'. 297 form::textField('l_lang', 2, 2, $l_lang) . '</p>'. 298 299 '<p>'.form::hidden('action','add_link',false). 300 '<input type="submit" class="submit" value="'.__('save').'"/></p>'. 301 '</fieldset>'. 302 '</form>' 303 ); 304 305 echo( 306 '<form action="'.$url.'" method="post">'. 307 '<fieldset><legend>'.__('New rubric').'</legend>'. 308 '<p class="field"><strong>'. 309 '<label for="c_title" class="float">'.__('Title').' : </label></strong>'. 310 form::textField('c_title', 40, 255, $c_title).'</p>'. 311 312 '<p>'.form::hidden('action','add_cat',false). 313 '<input type="submit" class="submit" value="'.__('save').'"/></p>'. 314 '</fieldset>'. 315 '</form>' 316 ); 317 318 echo( 319 '<h3>'.__('Usage').'</h3>'. 320 '<p>'.__('To replace your static links list by this one, just put the following code in your template:').'</p>'. 321 '<pre><?php pxLink::linkList(); ?></pre>' 322 ); 323 } 324 ?>
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 |
|