[ Index ]
 

Code source de Dotclear 2.0-beta6

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/plugins/blogroll/ -> edit.php (source)

   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  $id = $_REQUEST['id'];
  25  
  26  try {
  27      $rs = $blogroll->getLink($id);
  28  } catch (Exception $e) {
  29      $core->error->add($e->getMessage());
  30  }
  31  
  32  if (!$core->error->flag() && $rs->isEmpty()) {
  33      $core->error->add(__('No such link or title'));
  34  } else {
  35      $link_title = $rs->link_title;
  36      $link_href = $rs->link_href;
  37      $link_desc = $rs->link_desc;
  38      $link_lang = $rs->link_lang;
  39      $link_xfn = $rs->link_xfn;
  40  }
  41  
  42  # Update a link
  43  if (isset($rs) && !$rs->is_cat && !empty($_POST['edit_link']))
  44  {
  45      $link_title = $_POST['link_title'];
  46      $link_href = $_POST['link_href'];
  47      $link_desc = $_POST['link_desc'];
  48      $link_lang = $_POST['link_lang'];
  49      
  50      $link_xfn = '';
  51          
  52      if (!empty($_POST['identity']))
  53      {
  54          $link_xfn .= $_POST['identity'];
  55      }
  56      else
  57      {
  58          if(!empty($_POST['friendship']))    {
  59              $link_xfn .= ' '.$_POST['friendship'];
  60          }
  61          if(!empty($_POST['physical'])) {
  62              $link_xfn .= ' met';
  63          }
  64          if(!empty($_POST['professional'])) {
  65              $link_xfn .= ' '.implode(' ',$_POST['professional']);
  66          }
  67          if(!empty($_POST['geographical'])) {
  68              $link_xfn .= ' '.$_POST['geographical'];
  69          }
  70          if(!empty($_POST['family'])) {
  71              $link_xfn .= ' '.$_POST['family'];
  72          }
  73          if(!empty($_POST['romantic'])) {
  74              $link_xfn .= ' '.implode(' ',$_POST['romantic']);
  75          }
  76      }
  77      
  78      try {
  79          $blogroll->updateLink($id,$link_title,$link_href,$link_desc,$link_lang,trim($link_xfn));
  80          http::redirect($p_url.'&edit=1&id='.$id.'&upd=1');
  81      } catch (Exception $e) {
  82          $core->error->add($e->getMessage());
  83      }
  84  }
  85  
  86  
  87  # Update a category
  88  if (isset($rs) && $rs->is_cat && !empty($_POST['edit_cat']))
  89  {
  90      $link_desc = $_POST['link_desc'];
  91      
  92      try {
  93          $blogroll->updateCategory($id,$link_desc);
  94          http::redirect($p_url.'&edit=1&id='.$id.'&upd=1');
  95      } catch (Exception $e) {
  96          $core->error->add($e->getMessage());
  97      }
  98  }
  99  
 100  ?>
 101  <html>
 102  <head>
 103    <title>Blogroll</title>
 104  </head>
 105  
 106  <body>
 107  <?php echo '<p><a href="'.$p_url.'">'.__('Return to blogroll').'</a></p>'; ?>
 108  
 109  <?php
 110  if (isset($rs) && $rs->is_cat)
 111  {
 112      if (!empty($_GET['upd'])) {
 113          echo '<p class="message">'.__('Category has been successfully updated').'</p>';
 114      }
 115      
 116      echo
 117      '<form action="'.$p_url.'" method="post">'.
 118      '<fieldset><legend>'.__('Edit category').'</legend>'.
 119      
 120      '<p><label class="required classic" title="'.__('Required field').'">'.__('Title:').' '.
 121      form::field('link_desc',30,255,html::escapeHTML($link_desc)).'</label> '.
 122      
 123      form::hidden('edit',1).
 124      form::hidden('id',$id).
 125      '<input type="submit" name="edit_cat" class="submit" value="'.__('save').'"/></p>'.
 126      '</fieldset>'.
 127      '</form>';
 128  }
 129  if (isset($rs) && !$rs->is_cat)
 130  {
 131      if (!empty($_GET['upd'])) {
 132          echo '<p class="message">'.__('Link has been successfully updated').'</p>';
 133      }
 134      
 135      echo
 136      '<form action="plugin.php" method="post">'.
 137      '<fieldset class="two-cols"><legend>'.__('Edit link').'</legend>'.
 138      
 139      '<p class="col"><label class="required" title="'.__('Required field').'">'.__('Title:').' '.
 140      form::field('link_title',30,255,html::escapeHTML($link_title)).'</label></p>'.
 141      
 142      '<p class="col"><label class="required" title="'.__('Required field').'">'.__('URL:').' '.
 143      form::field('link_href',30,255,html::escapeHTML($link_href)).'</label></p>'.
 144      
 145      '<p class="col"><label>'.__('Description:').' '.
 146      form::field('link_desc',30,255,html::escapeHTML($link_desc)).'</label></p>'.
 147      
 148      '<p class="col"><label>'.__('Language:').' '.
 149      form::field('link_lang',5,5,html::escapeHTML($link_lang)).'</label></p>'.
 150      
 151      '<p>'.form::hidden('p','blogroll').
 152      form::hidden('edit',1).
 153      form::hidden('id',$id).
 154      '<input type="submit" name="edit_link" class="submit" value="'.__('save').'"/></p>'.
 155      '</fieldset>'.
 156      
 157      
 158      # XFN nightmare
 159      '<fieldset><legend>'.__('XFN').'</legend>'.
 160      '<table class="noborder">'.
 161      
 162      '<tr>'.
 163      '<th>'.__('_xfn_Me').'</th>'.
 164      '<td><p>'.'<label class="classic">'.
 165      form::checkbox(array('identity'), 'me', ($link_xfn == 'me')).' '.
 166      __('_xfn_Another link for myself').'</label></p></td>'.
 167      '</tr>'.
 168      
 169      '<tr>'.
 170      '<th>'.__('_xfn_Friendship').'</th>'.
 171      '<td><p>'.
 172      '<label class="classic">'.form::radio(array('friendship'),'contact',
 173      strpos($link_xfn,'contact') !== false).__('_xfn_Contact').'</label> '.
 174      '<label class="classic">'.form::radio(array('friendship'),'acquaintance',
 175      strpos($link_xfn,'acquaintance') !== false).__('_xfn_Acquaintance').'</label> '.
 176      '<label class="classic">'.form::radio(array('friendship'),'friend',
 177      strpos($link_xfn,'friend') !== false).__('_xfn_Friend').'</label> '.
 178      '<label class="classic">'.form::radio(array('friendship'),'').__('None').'</label>'.
 179      '</p></td>'.
 180      '</tr>'.
 181      
 182      '<tr>'.
 183      '<th>'.__('_xfn_Physical').'</th>'.
 184      '<td><p>'.
 185      '<label class="classic">'.form::checkbox(array('physical'),'met',
 186      strpos($link_xfn,'met') !== false).__('_xfn_Met').'</label>'.
 187      '</p></td>'.
 188      '</tr>'.
 189      
 190      '<tr>'.
 191      '<th>'.__('_xfn_Professional').'</th>'.
 192      '<td><p>'.
 193      '<label class="classic">'.form::checkbox(array('professional[]'),'co-worker',
 194      strpos($link_xfn,'co-worker') !== false).__('_xfn_Co-worker').'</label> '.
 195      '<label class="classic">'.form::checkbox(array('professional[]'),'colleague',
 196      strpos($link_xfn,'colleague') !== false).__('_xfn_Colleague').'</label>'.
 197      '</p></td>'.
 198      '</tr>'.
 199      
 200      '<tr>'.
 201      '<th>'.__('_xfn_Geographical').'</th>'.
 202      '<td><p>'.
 203      '<label class="classic">'.form::radio(array('geographical'),'co-resident',
 204      strpos($link_xfn,'co-resident') !== false).__('_xfn_Co-resident').'</label> '.
 205      '<label class="classic">'.form::radio(array('geographical'),'neighbor',
 206      strpos($link_xfn,'neighbor') !== false).__('_xfn_Neighbor').'</label> '.
 207      '<label class="classic">'.form::radio(array('geographical'),'').__('None').'</label>'.
 208      '</p></td>'.
 209      '</tr>'.
 210      
 211      '<tr>'.
 212      '<th>'.__('_xfn_Family').'</th>'.
 213      '<td><p>'.
 214      '<label class="classic">'.form::radio(array('family'),'child',
 215      strpos($link_xfn,'child') !== false).__('_xfn_Child').'</label> '.
 216      '<label class="classic">'.form::radio(array('family'),'parent',
 217      strpos($link_xfn,'parent') !== false).__('_xfn_Parent').'</label> '.
 218      '<label class="classic">'.form::radio(array('family'),'sibling',
 219      strpos($link_xfn, 'sibling') !== false).__('_xfn_Sibling').'</label> '.
 220      '<label class="classic">'.form::radio(array('family'),'spouse',
 221      strpos($link_xfn, 'spouse') !== false).__('_xfn_Spouse').'</label> '.
 222      '<label class="classic">'.form::radio(array('family'),'kin',
 223      strpos($link_xfn, 'kin') !== false).__('_xfn_Kin').'</label> '.
 224      '<label class="classic">'.form::radio(array('family'),'').__('None').'</label>'.
 225      '</p></td>'.
 226      '</tr>'.
 227      
 228      '<tr>'.
 229      '<th>'.__('_xfn_Romantic').'</th>'.
 230      '<td><p>'.
 231      '<label class="classic">'.form::checkbox(array('romantic[]'),'muse',
 232      strpos($link_xfn,'muse') !== false).__('_xfn_Muse').'</label> '.
 233      '<label class="classic">'.form::checkbox(array('romantic[]'),'crush',
 234      strpos($link_xfn,'crush') !== false).__('_xfn_Crush').'</label> '.
 235      '<label class="classic">'.form::checkbox(array('romantic[]'),'date',
 236      strpos($link_xfn,'date') !== false).__('_xfn_Date').'</label> '.
 237      '<label class="classic">'.form::checkbox(array('romantic[]'),'sweetheart',
 238      strpos($link_xfn,'sweetheart') !== false).__('_xfn_Sweetheart').'</label> '.
 239      '</p></td>'.
 240      '</tr>'.
 241      '</table>'.
 242      
 243      '</fieldset>'.
 244  
 245      '</form>';
 246  }
 247  ?>
 248  </body>
 249  </html>


Généré le : Fri Feb 23 22:16:06 2007 par Balluche grâce à PHPXref 0.7