30

Édition d'un fil

Créez site26 en copiant site25.

  1. /cms
    1. ...
    2. site25
    3. site26

Dans ce chapitre, nous allons créer l'éditeur de fils.

Pour tester le résultat en ligne, entrez http://www.frasq.org/cms/site26 dans la barre d'adresse de votre navigateur. Identifiez-vous avec le nom foobar et le mot de passe f00bar. Affichez puis éditez la page Informations légales. Cliquez sur le nom du fil dans le coin en haut à droite de la page.

NOTE : Dans cette version de démonstration, le contenu du site ne peut pas être modifié.

Commencez par créer l'action threadedit en ajoutant le fichier threadedit.php dans le dossier actions avec le contenu suivant :

  1. /cms/site26
    1. actions
      1. threadedit.php
  1. require_once 'userhasrole.php';
  2.  
  3. function threadedit($lang, $arglist=false) {
  4.     global $supported_languages;
  5.  
  6.     if (!user_has_role('writer')) {
  7.         return run('error/unauthorized', $lang);
  8.     }
  9.  
  10.     $thread=$node=false;
  11.  
  12.     if (is_array($arglist)) {
  13.         if (isset($arglist[0])) {
  14.             $thread=$arglist[0];
  15.         }
  16.         if (isset($arglist[1])) {
  17.             $node=$arglist[1];
  18.         }
  19.     }
  20.  
  21.     $clang=false;
  22.     foreach ($supported_languages as $slang) {
  23.         if (isset($_POST[$slang . '_x'])) {
  24.             $clang=$slang;
  25.             break;
  26.         }
  27.     }
  28.     if (!$clang) {
  29.         if (isset($_POST['clang'])) {
  30.             $clang = $_POST['clang'];
  31.         }
  32.         else if (isset($_GET['clang'])) {
  33.             $clang = $_GET['clang'];
  34.         }
  35.         else {
  36.             $clang=$lang;
  37.         }
  38.         if (!in_array($clang, $supported_languages)) {
  39.             return run('error/notfound', $lang);
  40.         }
  41.     }
  42.  
  43.     if (!$thread) {
  44.         return run('error/notfound', $lang);
  45.     }
  46.  
  47.     if (!$node) {
  48.         require_once 'actions/threadeditsummary.php';
  49.  
  50.         return threadeditsummary($lang, $clang, $thread);
  51.     }
  52.  
  53.     require_once 'actions/threadeditnode.php';
  54.  
  55.     return threadeditnode($lang, $clang, $thread, $node);
  56. }

Pour donner accès à l'action threadedit, ajoutez un alias par langue dans le fichier includes/aliases.inc :

  1.         'edition/fil'           => 'threadedit',
  1.         'edit/thread'           => 'threadedit',

Modifiez l'URL appelée pour éditer le contenu d'une page dans le fichier actions/page.php :

  1.     $edit=user_has_role('writer') ? url('threadedit', $_SESSION['user']['locale']) . '/'. $thread_id . '/'. $page_id . '?' . 'clang=' . $lang : false;
  1. require_once 'models/thread.inc';
  2.  
  3. require_once 'userhasrole.php';
  4. require_once 'readarg.php';
  5. require_once 'strtofname.php';
  6.  
  7. function threadeditnode($lang, $clang, $thread, $node) {
  8.     if (!user_has_role('writer')) {
  9.         return run('error/unauthorized', $lang);
  10.     }
  11.  
  12.     $thread_id = thread_id($thread);
  13.     if (!$thread_id) {
  14.         return run('error/notfound', $lang);
  15.     }
  16.  
  17.     $node_id = thread_node_id($thread_id, $node);
  18.     if (!$node_id) {
  19.         return run('error/notfound', $lang);
  20.     }
  21.  
  22.     $thread_name=$thread_title=$thread_abstract=$thread_cloud=false;
  23.     $r = thread_get($clang, $thread_id);
  24.     if (!$r) {
  25.         return run('error/notfound', $lang);
  26.     }
  27.     extract($r); /* thread_name thread_title thread_abstract thread_cloud */
  28.  
  29.     $node_editor = build('threadnodeeditor', $lang, $clang, $thread_id, $node_id);
  30.  
  31.     $node_title=false;
  32.     $r = thread_get_node($clang, $thread_id, $node_id, false);
  33.     $node_title = $r ? $r['node_title'] : $node_id;
  34.  
  35.     head('title', $thread_title);
  36.     head('description', false);
  37.     head('keywords', false);
  38.     head('robots', 'noindex, nofollow');
  39.  
  40.     $headline_text=$thread_title;
  41.     $headline_url=url('threadedit', $lang) . '/'. $thread_id . '?' . 'clang=' . $clang;
  42.     $headline = compact('headline_text', 'headline_url');
  43.     $view=url($thread_type, $clang) . '/'. $thread_id . '/'. $node_id;
  44.     $validate=url($thread_type, $clang) . '/'. $thread_name . '/'. $node_id;
  45.     $banner = build('banner', $lang, compact('headline', 'view', 'validate'));
  46.  
  47.     $prev_node_label=$prev_node_url=false;
  48.     $r=thread_node_prev($clang, $thread_id, $node_id, false);
  49.     if ($r) {
  50.         extract($r);
  51.         $prev_node_label = $prev_node_title ? $prev_node_title : $prev_node_number;
  52.         $prev_node_url=url('threadedit', $lang) . '/'. $thread_id . '/'. $prev_node_id . '?' . 'clang=' . $clang;
  53.     }
  54.  
  55.     $next_node_label=$next_node_url=false;
  56.     $r=thread_node_next($clang, $thread_id, $node_id, false);
  57.     if ($r) {
  58.         extract($r);
  59.         $next_node_label = $next_node_title ? $next_node_title : $next_node_number;
  60.         $next_node_url=url('threadedit', $lang) . '/'. $thread_id . '/'. $next_node_id . '?' . 'clang=' . $clang;
  61.     }
  62.  
  63.     $content = view('editing/threadeditnode', $lang, compact('node_editor', 'node_title', 'prev_node_url', 'prev_node_label', 'next_node_url', 'next_node_label'));
  64.  
  65.     $output = layout('editing', compact('banner', 'content'));
  66.  
  67.     return $output;
  68. }
  1. require_once 'models/node.inc';
  2.  
  3. function threadnodeeditor($lang, $clang, $thread_id, $node_id) {
  4.     $output = build('nodeeditor', $lang, $clang, $node_id);
  5.  
  6.     return $output;
  7. }
  1. <h3><?php echo htmlspecialchars($node_title, ENT_COMPAT, 'UTF-8'); ?></h3>
  2. <p id="threadnodenav" class="menubar">
  3. <?php if ($prev_node_url): ?>
  4. <a href="<?php echo $prev_node_url; ?>" title="Précédent"><?php echo htmlspecialchars($prev_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  5. <?php endif; ?>
  6. <?php if ($next_node_url and $prev_node_url): ?>
  7. &nbsp;|&nbsp;
  8. <?php endif; ?>
  9. <?php if ($next_node_url): ?>
  10. <a href="<?php echo $next_node_url; ?>" title="Suivant"><?php echo htmlspecialchars($next_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  11. <?php endif; ?>
  12. </p>
  13. <?php echo $node_editor; ?>
  1. <h3><?php echo htmlspecialchars($node_title, ENT_COMPAT, 'UTF-8'); ?></h3>
  2. <p id="threadnodenav" class="menubar">
  3. <?php if ($prev_node_url): ?>
  4. <a href="<?php echo $prev_node_url; ?>" title="Previous"><?php echo htmlspecialchars($prev_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  5. <?php endif; ?>
  6. <?php if ($next_node_url and $prev_node_url): ?>
  7. &nbsp;|&nbsp;
  8. <?php endif; ?>
  9. <?php if ($next_node_url): ?>
  10. <a href="<?php echo $next_node_url; ?>" title="Next"><?php echo htmlspecialchars($next_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  11. <?php endif; ?>
  12. </p>
  13. <?php echo $node_editor; ?>
  1.     $menu=$languages=$headline=false;
  1.                 case 'headline':
  2.                     if ($param) {
  3.                         $headline = view('headline', false, $param);
  4.                     }
  5.                     break;
  1.     $output = view('banner', false, compact('logo', 'menu', 'languages', 'headline'));
  1. <h4 id="headline"><?php if ($headline_url): ?><a href="<?php echo $headline_url; ?>"><?php endif; ?><?php echo htmlspecialchars($headline_text, ENT_NOQUOTES, 'UTF-8', false); ?><?php if ($headline_url): ?></a><?php endif; ?></h4>
  1. <?php if (isset($headline)): ?>
  2. <?php echo $headline; ?>
  3. <?php endif; ?>
  1. function thread_node_prev($lang, $thread_id, $node_id, $strict=true) {
  2.     $sqllang=db_sql_arg($lang, false);
  3.  
  4.     $join = $strict ? 'JOIN' : 'LEFT JOIN';
  5.  
  6.     $tabthreadnode=db_prefix_table('thread_node');
  7.     $tabnodelocale=db_prefix_table('node_locale');
  8.  
  9.     $sql="SELECT tn.node_id AS prev_node_id, nl.name AS prev_node_name, nl.title AS prev_node_title, tn.number AS prev_node_number FROM $tabthreadnode tn $join $tabnodelocale nl ON nl.node_id=tn.node_id AND nl.locale=$sqllang WHERE tn.thread_id=$thread_id AND tn.number < (SELECT number FROM $tabthreadnode WHERE thread_id=$thread_id AND node_id=$node_id) ORDER BY tn.number DESC LIMIT 1";
  10.  
  11.     $r = db_query($sql);
  12.  
  13.     return $r ? $r[0] : false;
  14. }
  1. function thread_node_next($lang, $thread_id, $node_id, $strict=true) {
  2.     $sqllang=db_sql_arg($lang, false);
  3.  
  4.     $join = $strict ? 'JOIN' : 'LEFT JOIN';
  5.  
  6.     $tabthreadnode=db_prefix_table('thread_node');
  7.     $tabnodelocale=db_prefix_table('node_locale');
  8.  
  9.     $sql="SELECT tn.node_id AS next_node_id, nl.name AS next_node_name, nl.title AS next_node_title, tn.number AS next_node_number FROM $tabthreadnode tn $join $tabnodelocale nl ON nl.node_id=tn.node_id AND nl.locale=$sqllang WHERE tn.thread_id=$thread_id AND tn.number > (SELECT number FROM $tabthreadnode WHERE thread_id=$thread_id AND node_id=$node_id) ORDER BY tn.number ASC LIMIT 1";
  10.  
  11.     $r = db_query($sql);
  12.  
  13.     return $r ? $r[0] : false;
  14. }
  1. function thread($lang, $arglist=false) {
  2.     $thread=$node=false;
  3.  
  4.     if (is_array($arglist)) {
  5.         if (isset($arglist[0])) {
  6.             $thread=$arglist[0];
  7.         }
  8.         if (isset($arglist[1])) {
  9.             $node=$arglist[1];
  10.         }
  11.     }
  12.  
  13.     if (!$thread) {
  14.         return run('error/notfound', $lang);
  15.     }
  16.  
  17.     if (!$node) {
  18.         require_once 'actions/threadsummary.php';
  19.  
  20.         return threadsummary($lang, $thread);
  21.  
  22.     }
  23.  
  24.     require_once 'actions/threadnode.php';
  25.  
  26.     return threadnode($lang, $thread, $node);
  27. }
  1. require_once 'userhasrole.php';
  2. require_once 'models/thread.inc';
  3.  
  4. function threadnode($lang, $thread, $node) {
  5.     $thread_id = thread_id($thread);
  6.     if (!$thread_id) {
  7.         return run('error/notfound', $lang);
  8.     }
  9.  
  10.     $r = thread_get($lang, $thread_id);
  11.     if (!$r) {
  12.         return run('error/notfound', $lang);
  13.     }
  14.     extract($r); /* thread_name thread_title thread_type thread_abstract thread_cloud thread_created thread_modified */
  15.  
  16.     $node_id = thread_node_id($thread_id, $node);
  17.     if (!$node_id) {
  18.         return run('error/notfound', $lang);
  19.     }
  20.  
  21.     $r = node_get($lang, $node_id);
  22.     if (!$r) {
  23.         return run('error/notfound', $lang);
  24.     }
  25.     extract($r); /* node_name node_title node_abstract node_cloud node_created node_modified */
  26.  
  27.     $node_contents = build('nodecontent', $lang, $node_id);
  28.  
  29.     $prev_node_label=$prev_node_url=false;
  30.     $r=thread_node_prev($lang, $thread_id, $node_id, false);
  31.     if ($r) {
  32.         extract($r);
  33.         $prev_node_label = $prev_node_title ? $prev_node_title : $prev_node_number;
  34.         $prev_node_url=url('thread', $lang) . '/'. $thread_name . '/'. $prev_node_name;
  35.     }
  36.  
  37.     $next_node_label=$next_node_url=false;
  38.     $r=thread_node_next($lang, $thread_id, $node_id, false);
  39.     if ($r) {
  40.         extract($r);
  41.         $next_node_label = $next_node_title ? $next_node_title : $next_node_number;
  42.         $next_node_url=url('thread', $lang) . '/'. $thread_name . '/'. $next_node_name;
  43.     }
  44.  
  45.     head('title', $thread_title);
  46.     head('description', $node_abstract);
  47.     head('keywords', $node_cloud);
  48.     head('robots', 'noindex, nofollow');
  49.  
  50.     $headline_text=$thread_title;
  51.     $headline_url=url('thread', $lang) . '/' . $thread_name;
  52.     $headline = compact('headline_text', 'headline_url');
  53.     $edit=user_has_role('writer') ? url('threadedit', $_SESSION['user']['locale']) . '/' . $thread_id . '/' . $node_id . '?' . 'clang=' . $lang : false;
  54.     $validate=url('thread', $lang) . '/'. $thread_id . '/'. $node_id;
  55.     $banner = build('banner', $lang, compact('headline', 'edit', 'validate'));
  56.  
  57.     $content = view('threadnode', $lang, compact('node_name', 'node_title', 'node_abstract', 'node_cloud', 'node_created', 'node_modified', 'node_contents', 'prev_node_url', 'prev_node_label', 'next_node_url', 'next_node_label'));
  58.  
  59.     $output = layout('standard', compact('banner', 'content'));
  60.  
  61.     return $output;
  62. }
  1. <h3><?php echo $node_title; ?></h3>
  2. <p id="threadnodenav" class="menubar">
  3. <?php if ($prev_node_url): ?>
  4. <a href="<?php echo $prev_node_url; ?>" title="Précédent"><?php echo htmlspecialchars($prev_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  5. <?php endif; ?>
  6. <?php if ($next_node_url and $prev_node_url): ?>
  7. &nbsp;|&nbsp;
  8. <?php endif; ?>
  9. <?php if ($next_node_url): ?>
  10. <a href="<?php echo $next_node_url; ?>" title="Suivant"><?php echo htmlspecialchars($next_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  11. <?php endif; ?>
  12. </p>
  13. <?php if ($node_abstract): ?>
  14. <h5>Extrait</h5>
  15. <p><?php echo $node_abstract; ?></p>
  16. <?php endif; ?>
  17. <?php if ($node_cloud): ?>
  18. <h6>Nuage</h6>
  19. <p class="smaller"><?php echo htmlspecialchars($node_cloud, ENT_COMPAT, 'UTF-8'); ?></p>
  20. <?php endif; ?>
  21. <?php if ($node_contents): ?>
  22. <h4>Contenu</h4>
  23. <?php echo $node_contents; ?>
  24. <?php endif; ?>
  1. <h3><?php echo $node_title; ?></h3>
  2. <p id="threadnodenav" class="menubar">
  3. <?php if ($prev_node_url): ?>
  4. <a href="<?php echo $prev_node_url; ?>" title="Previous"><?php echo htmlspecialchars($prev_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  5. <?php endif; ?>
  6. <?php if ($next_node_url and $prev_node_url): ?>
  7. &nbsp;|&nbsp;
  8. <?php endif; ?>
  9. <?php if ($next_node_url): ?>
  10. <a href="<?php echo $next_node_url; ?>" title="Next"><?php echo htmlspecialchars($next_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  11. <?php endif; ?>
  12. </p>
  13. <?php if ($node_abstract): ?>
  14. <h5>Abstract</h5>
  15. <p><?php echo $node_abstract; ?></p>
  16. <?php endif; ?>
  17. <?php if ($node_cloud): ?>
  18. <h6>Cloud</h6>
  19. <p class="smaller"><?php echo htmlspecialchars($node_cloud, ENT_COMPAT, 'UTF-8'); ?></p>
  20. <?php endif; ?>
  21. <?php if ($node_contents): ?>
  22. <h4>Content</h4>
  23. <?php echo $node_contents; ?>
  24. <?php endif; ?>
  1. require_once 'userhasrole.php';
  2. require_once 'models/thread.inc';
  3.  
  4. function threadsummary($lang, $thread) {
  5.     $thread_id = thread_id($thread);
  6.     if (!$thread_id) {
  7.         return run('error/notfound', $lang);
  8.     }
  9.  
  10.     $r = thread_get($lang, $thread_id);
  11.     if (!$r) {
  12.         return run('error/notfound', $lang);
  13.     }
  14.     extract($r); /* thread_name thread_title thread_abstract thread_cloud */
  15.  
  16.     $thread_contents = array();
  17.     $r = thread_get_contents($lang, $thread_id);
  18.     if ($r) {
  19.         $thread_url = url('thread', $lang) . '/'. $thread_name;
  20.         foreach ($r as $c) {
  21.             extract($c);    /* node_id node_name node_title node_number */
  22.             $node_url = $thread_url . '/' . $node_name;
  23.             $thread_contents[] = compact('node_title' , 'node_url');
  24.         }
  25.     }
  26.  
  27.     head('title', $thread_title);
  28.     head('description', $thread_abstract);
  29.     head('keywords', $thread_cloud);
  30.  
  31.     $edit=user_has_role('writer') ? url('threadedit', $_SESSION['user']['locale']) . '/'. $thread_id . '?' . 'clang=' . $lang : false;
  32.     $validate=url('thread', $lang) . '/'. $thread_name;
  33.     $banner = build('banner', $lang, compact('edit', 'validate'));
  34.  
  35.     $content = view('threadsummary', $lang, compact('thread_title', 'thread_abstract', 'thread_cloud', 'thread_contents'));
  36.  
  37.     $output = layout('standard', compact('banner', 'content'));
  38.  
  39.     return $output;
  40. }
  1. require_once 'models/thread.inc';
  2.  
  3. require_once 'userhasrole.php';
  4. require_once 'readarg.php';
  5. require_once 'strtofname.php';
  6.  
  7. function threadeditsummary($lang, $clang, $thread) {
  8.     global $supported_threads;
  9.  
  10.     if (!user_has_role('writer')) {
  11.         return run('error/unauthorized', $lang);
  12.     }
  13.  
  14.     $thread_id = thread_id($thread);
  15.     if (!$thread_id) {
  16.         return run('error/notfound', $lang);
  17.     }
  18.  
  19.     $action='init';
  20.     if (isset($_POST['thread_edit'])) {
  21.         $action='edit';
  22.     }
  23.  
  24.     $thread_type=$thread_name=$thread_title=$thread_abstract=$thread_cloud=false;
  25.  
  26.     switch($action) {
  27.         case 'init':
  28.         case 'reset':
  29.             $r = thread_get($clang, $thread_id, false);
  30.             if ($r) {
  31.                 extract($r); /* thread_type thread_name thread_title thread_abstract thread_cloud */
  32.             }
  33.  
  34.             break;
  35.         case 'edit':
  36.             if (isset($_POST['thread_type'])) {
  37.                 $thread_type=readarg($_POST['thread_type']);
  38.             }
  39.             if (isset($_POST['thread_title'])) {
  40.                 $thread_title=readarg($_POST['thread_title']);
  41.             }
  42.             if (isset($_POST['thread_name'])) {
  43.                 $thread_name=strtofname(readarg($_POST['thread_name']));
  44.             }
  45.             if (empty($thread_name) and !empty($thread_title)) {
  46.                 $thread_name = strtofname($thread_title);
  47.             }
  48.             if (isset($_POST['thread_abstract'])) {
  49.                 $thread_abstract=readarg($_POST['thread_abstract']);
  50.             }
  51.             if (isset($_POST['thread_cloud'])) {
  52.                 $thread_cloud=readarg($_POST['thread_cloud'], true, false); // trim but DON'T strip!
  53.                 preg_match_all('/(\S+)/', $thread_cloud, $r);
  54.                 $thread_cloud=implode(' ', array_unique($r[0]));
  55.             }
  56.             break;
  57.         default:
  58.             break;
  59.     }
  60.  
  61.     $missing_thread_title=false;
  62.     $missing_thread_name=false;
  63.     $bad_thread_name=false;
  64.     $missing_thread_type=false;
  65.     $bad_thread_type=false;
  66.  
  67.     switch($action) {
  68.         case 'edit':
  69.             if (empty($thread_title)) {
  70.                 $missing_thread_title = true;
  71.             }
  72.             if (empty($thread_name)) {
  73.                 $missing_thread_name = true;
  74.             }
  75.             else if (!preg_match('#^[\w-]{3,}$#', $thread_name)) {
  76.                 $bad_thread_name = true;
  77.             }
  78.             if (empty($thread_type)) {
  79.                 $missing_thread_type = true;
  80.             }
  81.             else if (!in_array($thread_type, $supported_threads)) {
  82.                 $bad_thread_type = true;
  83.             }
  84.             break;
  85.  
  86.         default:
  87.             break;
  88.     }
  89.  
  90.     switch($action) {
  91.         case 'edit':
  92.             if ($missing_thread_name or $bad_thread_name or $missing_thread_title or $missing_thread_type or $bad_thread_type) {
  93.                 break;
  94.             }
  95.  
  96.             $r = thread_set($clang, $thread_id, $thread_name, $thread_title, $thread_type, $thread_abstract, $thread_cloud);
  97.  
  98.             if (!$r) {
  99.                 break;
  100.             }
  101.  
  102.             break;
  103.  
  104.         default:
  105.             break;
  106.     }
  107.  
  108.     head('title', $thread_title);
  109.     head('description', false);
  110.     head('keywords', false);
  111.     head('robots', 'noindex, nofollow');
  112.  
  113.     $view=url($thread_type, $clang) . '/'. $thread_id;
  114.     $validate=url($thread_type, $clang) . '/'. $thread_id;
  115.     $banner = build('banner', $lang, compact('view', 'validate'));
  116.  
  117.     $errors = compact('missing_thread_name', 'bad_thread_name', 'missing_thread_title', 'missing_thread_type', 'bad_thread_type');
  118.  
  119.     $content = view('editing/threadeditsummary', $lang, compact('clang', 'thread_type', 'thread_name', 'thread_title', 'thread_abstract', 'thread_cloud', 'errors'));
  120.  
  121.     $output = layout('editing', compact('banner', 'content'));
  122.  
  123.     return $output;
  124. }
  1. function thread_set($lang, $thread_id, $thread_name, $thread_title, $thread_type, $thread_abstract, $thread_cloud) {
  2.     $sqltype=db_sql_arg($thread_type, false);
  3.  
  4.     $tabthread=db_prefix_table('thread');
  5.  
  6.     $sql="UPDATE $tabthread SET thread_type=$sqltype, modified=NOW() WHERE thread_id=$thread_id LIMIT 1";
  7.     $r = db_update($sql);
  8.  
  9.     if (!$r) {
  10.         return false;
  11.     }
  12.  
  13.     $sqllang=db_sql_arg($lang, false);
  14.     $sqlname=db_sql_arg($thread_name, true);
  15.     $sqltitle=db_sql_arg($thread_title, true);
  16.     $sqlabstract=db_sql_arg($thread_abstract, true, true);
  17.     $sqlcloud=db_sql_arg($thread_cloud, true, true);
  18.  
  19.     $tabthreadlocale=db_prefix_table('thread_locale');
  20.  
  21.     $sql="INSERT $tabthreadlocale (thread_id, locale, name, title, abstract, cloud) VALUES ($thread_id, $sqllang, $sqlname, $sqltitle, $sqlabstract, $sqlcloud) ON DUPLICATE KEY UPDATE thread_id=LAST_INSERT_ID(thread_id), locale=VALUES(locale), name=VALUES(name), title=VALUES(title), abstract=VALUES(abstract), cloud=VALUES(cloud)";
  22.  
  23.     $r = db_insert($sql);
  24.  
  25.     return $r;
  26. }
  1. <?php extract($errors); ?>
  2. <form class="compact" action="" method="post">
  3. <input name="clang" type="hidden" value="<?php echo $clang; ?>" />
  4. <p>
  5. <?php if (in_array('fr', $supported_languages)): ?>
  6. <input name="fr" type="image" src="<?php echo $base_path; ?>/images/theme/flags/fr.png" alt="fr" title="Français"/>
  7. <?php endif; ?>
  8. <?php if (in_array('en', $supported_languages)): ?>
  9. <input name="en" type="image" src="<?php echo $base_path; ?>/images/theme/flags/en.png" alt="en" title="English"/>
  10. <?php endif; ?>
  11. </p>
  12. <p>
  13. <input name="thread_title" type="text" size="40" maxlength="100" value="<?php echo htmlspecialchars($thread_title, ENT_COMPAT, 'UTF-8'); ?>" title="Titre" onkeypress="return submitonenter(event, 'thread_edit')"/>
  14. <label>URL :</label>
  15. <input name="thread_name" type="text" size="40" maxlength="100" value="<?php echo $thread_name; ?>" onkeypress="return submitonenter(event, 'thread_edit')"/>
  16. </p>
  17. <p><label>Extrait :</label></p>
  18. <p>
  19. <textarea name="thread_abstract" cols="80" rows="5"><?php echo htmlspecialchars($thread_abstract, ENT_COMPAT, 'UTF-8'); ?></textarea>
  20. </p>
  21. <p><label>Nuage :</label></p>
  22. <p>
  23. <textarea name="thread_cloud" cols="80" rows="5"><?php echo htmlspecialchars($thread_cloud, ENT_COMPAT, 'UTF-8'); ?></textarea>
  24. </p>
  25. <p>
  26. <label>Type :</label>
  27. <select name="thread_type" size="1">
  28. <option value="thread" <?php echo $thread_type == 'thread' ? 'selected="selected"' : ''; ?>>Fil</option>
  29. </select>
  30. </p>
  31. <input id="thread_edit" name="thread_edit" type="submit" value="Éditer" />
  32. </p>
  33. <?php if ($missing_thread_title or $missing_thread_name or $bad_thread_name or $missing_thread_type or $bad_thread_type): ?>
  34. <div class="alert">
  35. <?php if ($missing_thread_title): ?>
  36. <p>Vous n'avez pas saisi le titre du fil.</p>
  37. <?php endif; ?>
  38. <?php if ($missing_thread_name): ?>
  39. <p>Spécifiez un nom pour le lien sur le fil.</p>
  40. <?php elseif ($bad_thread_name): ?>
  41. <p>Le nom du lien sur le fil est invalide.</p>
  42. <?php endif; ?>
  43. <?php if ($missing_thread_type): ?>
  44. <p>Spécifiez le type du fil.</p>
  45. <?php elseif ($bad_thread_type): ?>
  46. <p>Le type de fil est invalide.</p>
  47. <?php endif; ?>
  48. </div>
  49. <?php endif; ?>
  50. </form>
  1. <?php extract($errors); ?>
  2. <form class="compact" action="" method="post">
  3. <input name="clang" type="hidden" value="<?php echo $clang; ?>" />
  4. <p>
  5. <?php if (in_array('fr', $supported_languages)): ?>
  6. <input name="fr" type="image" src="<?php echo $base_path; ?>/images/theme/flags/fr.png" alt="fr" title="Français"/>
  7. <?php endif; ?>
  8. <?php if (in_array('en', $supported_languages)): ?>
  9. <input name="en" type="image" src="<?php echo $base_path; ?>/images/theme/flags/en.png" alt="en" title="English"/>
  10. <?php endif; ?>
  11. </p>
  12. <p>
  13. <input name="thread_title" type="text" size="40" maxlength="100" value="<?php echo htmlspecialchars($thread_title, ENT_COMPAT, 'UTF-8'); ?>" title="Title" onkeypress="return submitonenter(event, 'thread_edit')"/>
  14. <label>URL:</label>
  15. <input name="thread_name" type="text" size="40" maxlength="100" value="<?php echo $thread_name; ?>" onkeypress="return submitonenter(event, 'thread_edit')"/>
  16. </p>
  17. <p><label>Abstract:</label></p>
  18. <p>
  19. <textarea name="thread_abstract" cols="80" rows="5"><?php echo htmlspecialchars($thread_abstract, ENT_COMPAT, 'UTF-8'); ?></textarea>
  20. </p>
  21. <p><label>Cloud:</label></p>
  22. <p>
  23. <textarea name="thread_cloud" cols="80" rows="5"><?php echo htmlspecialchars($thread_cloud, ENT_COMPAT, 'UTF-8'); ?></textarea>
  24. </p>
  25. <p>
  26. <label>Type:</label>
  27. <select name="thread_type" size="1">
  28. <option value="thread" <?php echo $thread_type == 'thread' ? 'selected="selected"' : ''; ?>>Thread</option>
  29. </select>
  30. </p>
  31. <input id="thread_edit" name="thread_edit" type="submit" value="Edit" />
  32. </p>
  33. <?php if ($missing_thread_title or $missing_thread_name or $bad_thread_name or $missing_thread_type or $bad_thread_type): ?>
  34. <div class="alert">
  35. <?php if ($missing_thread_title): ?>
  36. <p>You didn't input the title of the thread.</p>
  37. <?php endif; ?>
  38. <?php if ($missing_thread_name): ?>
  39. <p>Specify a name for the link to the thread.</p>
  40. <?php elseif ($bad_thread_name): ?>
  41. <p>The name of the link to the thread is invalid.</p>
  42. <?php endif; ?>
  43. <?php if ($missing_thread_type): ?>
  44. <p>Specify the type of the thread.</p>
  45. <?php elseif ($bad_thread_type): ?>
  46. <p>The type of the thread is invalid.</p>
  47. <?php endif; ?>
  48. </div>
  49. <?php endif; ?>
  50. </form>
  1. global $supported_threads;
  2.  
  3. $supported_threads=array('thread'); // 'thread'
  1. #banner #headline {float:right;margin-top:13px;margin-bottom:0;}
  2.  
  3. #threadnodenav, #bookpagenav {font-size:smaller;margin-bottom:1em;}

Commentaires

Votre commentaire :
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip aide 2000

Entrez un maximum de 2000 caractères.
Améliorez la présentation de votre texte avec les balises de formatage suivantes :
[p]paragraphe[/p], [b]gras[/b], [i]italique[/i], [u]souligné[/u], [s]barré[/s], [quote]citation[/quote], [pre]tel quel[/pre], [br]à la ligne,
[url]http://www.izend.org[/url], [url=http://www.izend.org]site[/url], [email]izend@izend.org[/email], [email=izend@izend.org]izend[/email],
[code]commande[/code], [code=langage]code source en c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].