| [ Index ] |
|
Code source de Dotclear 2.0-beta6 |
1 <?php 2 # ***** BEGIN LICENSE BLOCK ***** 3 # This file is part of DotClear. 4 # Copyright (c) 2005 Olivier Meunier and contributors. All rights 5 # reserved. 6 # 7 # DotClear 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 # DotClear 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 # You should have received a copy of the GNU General Public License 18 # along with DotClear; if not, write to the Free Software 19 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 # 21 # ***** END LICENSE BLOCK ***** 22 if (!defined('DC_CONTEXT_ADMIN')) { exit; } 23 24 require dirname(__FILE__).'/class.dc.blogroll.php'; 25 26 $blogroll = new dcBlogroll($core->blog); 27 28 if (!empty($_REQUEST['edit']) && !empty($_REQUEST['id'])) { 29 include dirname(__FILE__).'/edit.php'; 30 return; 31 } 32 33 $default_tab = ''; 34 $link_title = $link_href = $link_desc = $link_lang = ''; 35 $cat_title = ''; 36 37 # Import links 38 if (!empty($_POST['import_links']) && !empty($_FILES['links_file'])) 39 { 40 $default_tab = 'import-links'; 41 42 try 43 { 44 files::uploadStatus($_FILES['links_file']); 45 require_once dirname(__FILE__).'/class.dc.importblogroll.php'; 46 47 $imported = dcImportBlogroll::loadFile($_FILES['links_file']['tmp_name']); 48 if (empty($imported)) { 49 unset($imported); 50 throw new Exception(__('Nothing to import')); 51 } 52 } 53 catch (Exception $e) 54 { 55 $core->error->add($e->getMessage()); 56 } 57 } 58 59 if (!empty($_POST['import_links_do'])) { 60 foreach ($_POST['entries'] as $idx) { 61 $link_title = $_POST['title'][$idx]; 62 $link_href = $_POST['url'][$idx]; 63 $link_desc = $_POST['desc'][$idx]; 64 try { 65 $blogroll->addLink($link_title,$link_href,$link_desc,''); 66 } catch (Exception $e) { 67 $core->error->add($e->getMessage()); 68 $default_tab = 'import-links'; 69 } 70 } 71 http::redirect($p_url.'&importlinks=1'); 72 } 73 74 if (!empty($_POST['cancel_import'])) { 75 $core->error->add(__('Import operation cancelled.')); 76 $default_tab = 'import-links'; 77 } 78 79 # Add link 80 if (!empty($_POST['add_link'])) 81 { 82 $link_title = $_POST['link_title']; 83 $link_href = $_POST['link_href']; 84 $link_desc = $_POST['link_desc']; 85 $link_lang = $_POST['link_lang']; 86 87 try { 88 $blogroll->addLink($link_title,$link_href,$link_desc,$link_lang); 89 http::redirect($p_url.'&addlink=1'); 90 } catch (Exception $e) { 91 $core->error->add($e->getMessage()); 92 $default_tab = 'add-link'; 93 } 94 } 95 96 # Add category 97 if (!empty($_POST['add_cat'])) 98 { 99 $cat_title = $_POST['cat_title']; 100 101 try { 102 $blogroll->addCategory($cat_title); 103 http::redirect($p_url.'&addcat=1'); 104 } catch (Exception $e) { 105 $core->error->add($e->getMessage()); 106 $default_tab = 'add-cat'; 107 } 108 } 109 110 # Delete link 111 if (!empty($_POST['removeaction']) && !empty($_POST['remove'])) { 112 foreach ($_POST['remove'] as $k => $v) 113 { 114 try { 115 $blogroll->delItem($v); 116 } catch (Exception $e) { 117 $core->error->add($e->getMessage()); 118 break; 119 } 120 } 121 122 if (!$core->error->flag()) { 123 http::redirect($p_url.'&removed=1'); 124 } 125 } 126 127 # Order links 128 $order = array(); 129 if (empty($_POST['links_order']) && !empty($_POST['order'])) { 130 $order = $_POST['order']; 131 asort($order); 132 $order = array_keys($order); 133 } elseif (!empty($_POST['links_order'])) { 134 $order = explode(',',$_POST['links_order']); 135 } 136 137 if (!empty($_POST['saveorder']) && !empty($order)) 138 { 139 foreach ($order as $pos => $l) { 140 $pos = ((integer) $pos)+1; 141 142 try { 143 $blogroll->updateOrder($l,$pos); 144 } catch (Exception $e) { 145 $core->error->add($e->getMessage()); 146 } 147 } 148 149 if (!$core->error->flag()) { 150 http::redirect($p_url.'&neworder=1'); 151 } 152 } 153 154 155 # Get links 156 try { 157 $rs = $blogroll->getLinks(); 158 } catch (Exception $e) { 159 $core->error->add($e->getMessage()); 160 } 161 162 ?> 163 <html> 164 <head> 165 <title>Blogroll</title> 166 <?php echo dcPage::jsToolMan(); ?> 167 <?php echo dcPage::jsConfirmClose('links-form','add-link-form','add-category-form'); ?> 168 <script type="text/javascript"> 169 //<![CDATA[ 170 171 var dragsort = ToolMan.dragsort(); 172 $(function() { 173 dragsort.makeTableSortable($("#links-list").get(0), 174 dotclear.sortable.setHandle,dotclear.sortable.saveOrder); 175 176 $('.checkboxes-helpers').each(function() { 177 dotclear.checkboxesHelpers(this); 178 }); 179 }); 180 181 dotclear.sortable = { 182 setHandle: function(item) { 183 var handle = $(item).find('td.handle').get(0); 184 while (handle.firstChild) { 185 handle.removeChild(handle.firstChild); 186 } 187 188 item.toolManDragGroup.setHandle(handle); 189 handle.className = handle.className+' handler'; 190 }, 191 192 saveOrder: function(item) { 193 var group = item.toolManDragGroup; 194 var order = document.getElementById('links_order'); 195 group.register('dragend', function() { 196 order.value = ''; 197 items = item.parentNode.getElementsByTagName('tr'); 198 199 for (var i=0; i<items.length; i++) { 200 order.value += items[i].id.substr(2)+','; 201 } 202 }); 203 } 204 }; 205 //]]> 206 </script> 207 <?php echo dcPage::jsPageTabs($default_tab); ?> 208 </head> 209 210 <body> 211 <h2><?php echo html::escapeHTML($core->blog->name); ?> > Blogroll</h2> 212 213 <?php 214 if (!empty($_GET['neworder'])) { 215 echo '<p class="message">'.__('Items order has been successfully updated').'</p>'; 216 } 217 218 if (!empty($_GET['removed'])) { 219 echo '<p class="message">'.__('Items have been successfully removed.').'</p>'; 220 } 221 222 if (!empty($_GET['addlink'])) { 223 echo '<p class="message">'.__('Link has been successfully created.').'</p>'; 224 } 225 226 if (!empty($_GET['addcat'])) { 227 echo '<p class="message">'.__('category has been successfully created.').'</p>'; 228 } 229 230 if (!empty($_GET['importlinks'])) { 231 echo '<p class="message">'.__('links have been successfully imported.').'</p>'; 232 } 233 ?> 234 235 <div class="multi-part" title="<?php echo __('Blogroll'); ?>"> 236 <form action="plugin.php" method="post" id="links-form"> 237 <table class="maximal dragable"> 238 <tr> 239 <th colspan="3"><?php echo __('Title'); ?></th> 240 <th><?php echo __('Description'); ?></th> 241 <th><?php echo __('URL'); ?></th> 242 <th><?php echo __('Lang'); ?></th> 243 244 </tr> 245 <tbody id="links-list"> 246 <?php 247 while ($rs->fetch()) 248 { 249 $position = (string) $rs->index()+1; 250 251 echo 252 '<tr class="line" id="l_'.$rs->link_id.'">'. 253 '<td class="handle minimal">'.form::field(array('order['.$rs->link_id.']'),2,5,$position).'</td>'. 254 '<td class="minimal">'.form::checkbox(array('remove[]'),$rs->link_id).'</td>'; 255 256 257 if ($rs->is_cat) 258 { 259 echo 260 '<td colspan="5"><strong><a href="'.$p_url.'&edit=1&id='.$rs->link_id.'">'. 261 html::escapeHTML($rs->link_desc).'</a></strong></td>'; 262 } 263 else 264 { 265 echo 266 '<td><a href="'.$p_url.'&edit=1&id='.$rs->link_id.'">'. 267 html::escapeHTML($rs->link_title).'</a></td>'. 268 '<td>'.html::escapeHTML($rs->link_desc).'</td>'. 269 '<td>'.html::escapeHTML($rs->link_href).'</td>'. 270 '<td>'.html::escapeHTML($rs->link_lang).'</td>'; 271 } 272 273 echo '</tr>'; 274 } 275 ?> 276 </tbody> 277 </table> 278 279 <div class="two-cols"> 280 <p class="col"><?php echo form::hidden('links_order',''); 281 echo form::hidden(array('p'),'blogroll'); ?> 282 <input type="submit" name="saveorder" value="<?php echo __('Save order'); ?>" /></p> 283 284 <p class="col right"><input type="submit" name="removeaction" 285 value="<?php echo __('Delete selected links'); ?>" 286 onclick="return window.confirm('<?php echo html::escapeJS( 287 __('Are you sure you you want to delete selected links?')); ?>');" /></p> 288 </div> 289 290 </form> 291 </div> 292 293 <?php 294 echo 295 '<div class="multi-part" id="add-link" title="'.__('Add a link').'">'. 296 '<form action="plugin.php" method="post" id="add-link-form">'. 297 '<fieldset class="two-cols"><legend>'.__('Add a new link').'</legend>'. 298 '<p class="col"><label class="required" title="'.__('Required field').'">'.__('Title:').' '. 299 form::field('link_title',30,255,$link_title,'',2). 300 '</label></p>'. 301 302 '<p class="col"><label class="required" title="'.__('Required field').'">'.__('URL:').' '. 303 form::field('link_href',30,255,$link_href,'',3). 304 '</label></p>'. 305 306 '<p class="col"><label>'.__('Description:').' '. 307 form::field('link_desc',30,255,$link_desc,'',4). 308 '</label></p>'. 309 310 '<p class="col"><label>'.__('Language:').' '. 311 form::field('link_lang',5,5,$link_lang,'',5). 312 '</label></p>'. 313 '<p>'.form::hidden(array('p'),'blogroll'). 314 '<input type="submit" name="add_link" value="'.__('save').'" tabindex="6" /></p>'. 315 '</fieldset>'. 316 '</form>'. 317 '</div>'; 318 319 echo 320 '<div class="multi-part" id="add-cat" title="'.__('Add a category').'">'. 321 '<form action="plugin.php" method="post" id="add-category-form">'. 322 '<fieldset><legend>'.__('Add a new category').'</legend>'. 323 '<p><label class=" classic required" title="'.__('Required field').'">'.__('Title:').' '. 324 form::field('cat_title',30,255,$cat_title,'',7).'</label> '. 325 form::hidden(array('p'),'blogroll'). 326 '<input type="submit" name="add_cat" value="'.__('save').'" tabindex="8" /></p>'. 327 '</fieldset>'. 328 '</form>'. 329 '</div>'; 330 331 echo 332 '<div class="multi-part" id="import-links" title="'.__('Import links').'">'; 333 if (!isset($imported)) { 334 echo 335 '<form action="plugin.php" method="post" id="import-links-form" enctype="multipart/form-data">'. 336 '<fieldset><legend>'.__('Import links').'</legend>'. 337 '<p><label class=" classic required" title="'.__('Required field').'">'.__('OPML or XBEL File :').' '. 338 '<input type="file" name="links_file" /></label></p>'. 339 '<p>'.form::hidden(array('p'),'blogroll'). 340 '<input type="submit" name="import_links" value="'.__('import').'" tabindex="10" /></p>'. 341 '</fieldset>'. 342 '</form>'; 343 } 344 else { 345 echo 346 '<form action="plugin.php" method="post" id="import-links-form">'. 347 '<fieldset><legend>'.__('Import links').'</legend>'; 348 if (empty($imported)) { 349 echo '<p>'.__('Nothing to import').'</p>'; 350 } 351 else { 352 echo 353 '<table class="clear maximal"><tr>'. 354 '<th colspan="2">'.__('Title').'</th>'. 355 '<th>'.__('Description').'</th>'. 356 '</tr>'; 357 358 $i = 0; 359 foreach ($imported as $entry) { 360 $url = html::escapeHTML($entry->link); 361 $title = html::escapeHTML($entry->title); 362 $desc = html::escapeHTML($entry->desc); 363 364 echo 365 '<tr><td>'.form::checkbox(array('entries[]'),$i,'','','').'</td>'. 366 '<td nowrap><a href="'.$url.'">'.$title.'</a>'. 367 '<input type="hidden" name="url['.$i.']" value="'.$url.'" />'. 368 '<input type="hidden" name="title['.$i.']" value="'.$title.'" />'. 369 '</td>'. 370 '<td>'.$desc. 371 '<input type="hidden" name="desc['.$i.']" value="'.$desc.'" />'. 372 '</td></tr>'."\n"; 373 $i++; 374 } 375 echo 376 '</table>'. 377 '<div class="two-cols">'. 378 '<p class="col checkboxes-helpers"></p>'. 379 380 '<p class="col right">'. 381 form::hidden(array('p'),'blogroll'). 382 '<input type="submit" name="cancel_import" value="'.__('cancel').'" tabindex="10" /> '. 383 '<input type="submit" name="import_links_do" value="'.__('import').'" tabindex="11" /></p>'. 384 '</div>'; 385 } 386 echo 387 '</fieldset>'. 388 '</form>'; 389 } 390 echo '</div>'; 391 ?> 392 393 </body> 394 </html>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
| Généré le : Fri Feb 23 22:16:06 2007 | par Balluche grâce à PHPXref 0.7 |