11

Editing a node content

Create site25 by copying site24.

  1. /cms
    1. ...
    2. site24
    3. site25

In this chapter, we are going to create the node content editor.

To test the result online, enter http://www.frasq.org/cms/site25 in the address bar of your navigator. Identify yourself with the name foobar and the password f00bar. Edit the page Legal information. The editor displays the different contents of the node in a series of input fields. Notice that content 2 is evaluated by PHP.

Leave the content type selector on Text and press Add. Cut and paste the text <p><b>frasq.org</b></p> from content 2 to the new content. Change the display order by entering 3 in the field next to the position of content 2 and 2 in the field next to the position of content 3. Press Modify at the end of the page. Delete content 2.

NOTE: In this demonstration version, the content of the site can not be modified.

Edit the file blocks/nodeeditor.php and modify the end of the function nodeeditor to add the content returned by the function nodecontenteditor to the view:

  1.     $content_editor = build('nodecontenteditor', $lang, $clang, $node_id);
  2.  
  3.     $errors = compact('missing_node_name', 'bad_node_name', 'missing_node_title');
  4.  
  5.     $output = view('editing/nodeeditor', $lang, compact('clang', 'node_name', 'node_title', 'node_abstract', 'node_cloud', 'content_editor', 'errors'));

Insert this content at the end of the files views/en/editing/nodeeditor.phtml for the version in English and views/fr/editing/nodeeditor.phml for the version in French:

  1. <h4>Contents</h4>
  2. <?php echo $content_editor; ?>
  1. <h4>Contenu</h4>
  2. <?php echo $content_editor; ?>

Add the file nodecontenteditor.php in the folder blocks with the following content:

  1. /cms/site25
    1. blocks
      1. nodecontenteditor.php
  1. require_once 'readarg.php';
  2. require_once 'models/node.inc';
  3.  
  4. function nodecontenteditor($lang, $clang, $node_id) {
  5.     $action='init';
  6.     if (isset($_POST['content_modify'])) {
  7.         $action='modify';
  8.     }
  9.     else if (isset($_POST['content_create'])) {
  10.         $action='create';
  11.     }
  12.     else if (isset($_POST['content_delete'])) {
  13.         $action='delete';
  14.     }
  15.  
  16.     $new_content_type=$new_content_number=false;
  17.     $old_content_number=false;
  18.  
  19.     $node_contents = false;
  20.     $id=false;
  21.     $p=false;
  22.  
  23.     switch($action) {
  24.         case 'init':
  25.         case 'reset':
  26.             $r = node_get_contents($clang, $node_id);
  27.  
  28.             if ($r) {
  29.                 $pos=1;
  30.                 $node_contents = array();
  31.                 foreach ($r as $c) {
  32.                     $c['content_pos'] = $c['content_number'];
  33.                     $node_contents[$pos] = $c;
  34.                     $pos++;
  35.                 }
  36.             }
  37.             break;
  38.         case 'modify':
  39.         case 'create':
  40.         case 'delete':
  41.             if (isset($_POST['content_new_type'])) {
  42.                 $new_content_type=readarg($_POST['content_new_type']);
  43.             }
  44.             if (isset($_POST['content_new_number'])) {
  45.                 $new_content_number=readarg($_POST['content_new_number']);
  46.             }
  47.             if (isset($_POST['content_old_number'])) {
  48.                 $old_content_number=readarg($_POST['content_old_number']);
  49.             }
  50.             if (isset($_POST['content_id'])) {
  51.                 $id=$_POST['content_id'];   // DON'T readarg!
  52.             }
  53.             if (isset($_POST['content_p'])) {
  54.                 $p=$_POST['content_p'];     // DON'T readarg!
  55.             }
  56.  
  57.             if ($id and $p and is_array($id) and is_array($p) and count($id) == count($p)) {
  58.                 $fieldgroups = array(
  59.                                 'text'      => array('content_text', 'content_eval'),
  60.                                 'infile'    => array('content_infile'),
  61.                 );
  62.  
  63.                 $node_contents=array();
  64.  
  65.                 foreach ($fieldgroups as $type => $fields) {
  66.                     foreach ($fields as $fieldname) {
  67.                         if (isset($_POST[$fieldname]) and is_array($_POST[$fieldname])) {
  68.                             foreach ($_POST[$fieldname] as $i => $value) {
  69.                                 $v=readarg($value, true, false);    // trim but DON'T strip!
  70.                                 switch ($fieldname) {
  71.                                     case 'content_text':
  72.                                         /* DON'T strip_tag! */
  73.                                         break;
  74.                                     case 'content_infile':
  75.                                         $v=strip_tags($v);
  76.                                         break;
  77.                                     case 'content_eval':
  78.                                         $v=$v=='on' ? true : false;
  79.                                         break;
  80.                                 }
  81.                                 if (!isset($node_contents[$i])) {
  82.                                     $node_contents[$i] = array('content_id' => $id[$i], 'content_pos' => $p[$i], 'content_type' => $type, $fieldname => $v);
  83.                                 }
  84.                                 else {
  85.                                     $node_contents[$i][$fieldname] = $v;
  86.                                 }
  87.                             }
  88.                         }
  89.                     }
  90.                 }
  91.  
  92.                 if ($node_contents) {
  93.                     ksort($node_contents);
  94.                 }
  95.             }
  96.             break;
  97.         default:
  98.             break;
  99.     }
  100.  
  101.     $missing_new_content_type=false;
  102.     $bad_new_content_type=false;
  103.     $bad_new_content_number=false;
  104.  
  105.     $missing_old_content_number=false;
  106.     $bad_old_content_number=false;
  107.  
  108.     $missing_content_number=false;
  109.     $bad_content_number=false;
  110.  
  111.     switch($action) {
  112.         case 'create':
  113.             if (empty($new_content_type)) {
  114.                 $missing_new_content_type = true;
  115.             }
  116.             else if (!in_array($new_content_type, array('text', 'infile'))) {
  117.                 $bad_new_content_type = true;
  118.             }
  119.             if (empty($new_content_number)) {
  120.                 $new_content_number = false;
  121.             }
  122.             else if (!is_numeric($new_content_number)) {
  123.                 $bad_new_content_number = true;
  124.             }
  125.             else if ($new_content_number < 1) {
  126.                 $bad_new_content_number = true;
  127.             }
  128.             else if ($new_content_number > count($node_contents)) {
  129.                 $new_content_number = false;
  130.             }
  131.             break;
  132.  
  133.         case 'delete':
  134.             if (empty($old_content_number)) {
  135.                 $missing_old_content_number = true;
  136.             }
  137.             else if (!is_numeric($old_content_number)) {
  138.                 $bad_old_content_number = true;
  139.             }
  140.             else if ($old_content_number < 1 or $old_content_number > count($node_contents)) {
  141.                 $bad_old_content_number = true;
  142.             }
  143.             break;
  144.  
  145.         case 'modify':
  146.             foreach ($node_contents as $c) {
  147.                 extract($c);
  148.  
  149.                 if (empty($content_pos)) {
  150.                     $missing_content_number = true;
  151.                 }
  152.                 else if (!is_numeric($content_pos)) {
  153.                     $bad_content_number = true;
  154.                 }
  155.                 else if ($content_pos < 1 or $content_pos > count($node_contents)) {
  156.                     $bad_content_number = true;
  157.                 }
  158.             }
  159.             break;
  160.  
  161.         default:
  162.             break;
  163.     }
  164.  
  165.     switch($action) {
  166.         case 'modify':
  167.             if ($missing_content_number or $bad_content_number) {
  168.                 break;
  169.             }
  170.  
  171.             if ($p) {
  172.                 array_multisort(range(1, count($p)), SORT_NUMERIC, $p);
  173.                 array_multisort($p, SORT_NUMERIC, $node_contents);
  174.             }
  175.  
  176.             $r = node_set_contents($clang, $node_id, $node_contents);
  177.  
  178.             if (!$r) {
  179.                 break;
  180.             }
  181.  
  182.             break;
  183.  
  184.         case 'create':
  185.             if ($missing_new_content_type or $bad_new_content_type or $bad_new_content_number) {
  186.                 break;
  187.             }
  188.  
  189.             $nc = node_create_content($clang, $node_id, $new_content_type, $new_content_number);
  190.             if (!$nc) {
  191.                 break;
  192.             }
  193.  
  194.             $content_id = $nc['content_id'];
  195.             $content_pos = $nc['content_number'];
  196.             $content_type = $new_content_type;
  197.             $content_text=false;
  198.             $content_eval=false;
  199.             $content_infile=false;
  200.  
  201.             $content_thread=$content_node=false;
  202.  
  203.             if ($node_contents) {
  204.                 foreach ($node_contents as &$c) {
  205.                     if ($c['content_pos'] >= $content_pos) {
  206.                         $c['content_pos']++;
  207.                     }
  208.                 }
  209.                 array_splice($node_contents, $content_pos-1, 0, array(compact('content_id', 'content_type', 'content_text', 'content_eval', 'content_infile', 'content_thread', 'content_node', 'content_pos')));
  210.             }
  211.             else {
  212.                 $content_pos=1;
  213.                 $node_contents=array($content_pos => compact('content_id', 'content_type', 'content_text', 'content_eval', 'content_infile', 'content_thread', 'content_node', 'content_pos'));
  214.             }
  215.  
  216.             if ($new_content_number) {
  217.                 $new_content_number++;
  218.             }
  219.  
  220.             break;
  221.  
  222.         case 'delete':
  223.             if ($missing_old_content_number or $bad_old_content_number) {
  224.                 break;
  225.             }
  226.  
  227.             $c = $node_contents[$old_content_number];
  228.             $content_id = $c['content_id'];
  229.             $content_type = $c['content_type'];
  230.  
  231.             $r = node_delete_content($node_id, $content_id, $content_type);
  232.  
  233.             if (!$r) {
  234.                 break;
  235.             }
  236.  
  237.             unset($node_contents[$old_content_number]);
  238.             $node_contents = array_values($node_contents);
  239.  
  240.             foreach ($node_contents as &$c) {
  241.                 if ($c['content_pos'] >= $old_content_number) {
  242.                     $c['content_pos']--;
  243.                 }
  244.             }
  245.  
  246.             $old_content_number = false;
  247.  
  248.             break;
  249.  
  250.         default:
  251.             break;
  252.     }
  253.  
  254.     $errors = compact('missing_new_content_type', 'bad_new_content_type', 'bad_new_content_number', 'missing_old_content_number', 'bad_old_content_number', 'missing_content_number', 'bad_content_number');
  255.  
  256.     $output = view('editing/nodecontenteditor', $lang, compact('clang', 'new_content_type', 'new_content_number', 'old_content_number', 'node_contents', 'errors'));
  257.  
  258.     return $output;
  259. }

Edit the file models/node.inc and add the functions node_set_contents, node_create_content and node_delete_content:

  1. function node_set_contents($lang, $node_id, $node_contents) {

node_set_contents takes 3 arguments: the language of the content, the node number and a array of contents.

  1.     $sqllang=db_sql_arg($lang, false);
  2.  
  3.     $tabnode=db_prefix_table('node');
  4.  
  5.     $sql="UPDATE $tabnode SET modified=NOW() WHERE node_id=$node_id LIMIT 1";
  6.  
  7.     $r = db_update($sql);
  8.  
  9.     if (!$r) {
  10.         return false;
  11.     }

Updates the modified field of node $node_id. Returns false if $node_id doesn't exist in the DB.

  1.     $number = 1;
  2.  
  3.     $tabnodecontent=db_prefix_table('node_content');
  4.     $tabcontenttext=db_prefix_table('content_text');
  5.     $tabcontentinfile=db_prefix_table('content_infile');
  6.  
  7.     foreach ($node_contents as $c) {
  8.         $content_text='';
  9.         $content_eval=false;
  10.         $content_infile=false;
  11.  
  12.         extract($c);    /* content_id content_number content_type (content_text content_eval | content_infile) */
  13.         $sqltype=db_sql_arg($content_type, false);
  14.  
  15.         $sql="UPDATE $tabnodecontent SET number=$number WHERE node_id=$node_id AND content_id=$content_id AND content_type=$sqltype";
  16.         $r = db_update($sql);
  17.  
  18.         if (!$r) {
  19.             return false;
  20.         }

Goes through $node_contents. Updates the list of contents of a node in the table node_content while numbering them.

  1.         switch($content_type) {
  2.             case 'text':
  3.                 $sqltext=db_sql_arg($content_text, true, true);
  4.                 $sqleval=$content_eval ? 1 : 0;
  5.                 $sql="INSERT $tabcontenttext (content_id, locale, text, eval) VALUES ($content_id, $sqllang, $sqltext, $sqleval) ON DUPLICATE KEY UPDATE text=VALUES(text), eval=VALUES(eval)";
  6.                 break;
  7.             case 'infile':
  8.                 $sqlpath=db_sql_arg($content_infile, true, true);
  9.                 $sql="INSERT $tabcontentinfile SET content_id=$content_id, locale=$sqllang, path=$sqlpath ON DUPLICATE KEY UPDATE path=VALUES(path)";
  10.                 break;
  11.         }
  12.  
  13.         $r = db_update($sql);
  14.  
  15.         if (!$r) {
  16.             return false;
  17.         }
  18.  
  19.         $number++;
  20.     }
  21.  
  22.     return true;
  23. }

Updates the table content_text or content_infile depending the content type.

  1. function node_create_content($lang, $node_id, $content_type, $content_number=0) {
  2.     $tabnodecontent=db_prefix_table('node_content');
  3.  
  4.     $sql="SELECT COUNT(*)+1 AS n FROM $tabnodecontent WHERE node_id=$node_id";
  5.  
  6.     $r = db_query($sql);
  7.  
  8.     if (!$r) {
  9.         return false;
  10.     }
  11.  
  12.     $n = $r[0]['n'];
  13.  
  14.     if ($content_number < 1 or $content_number > $n) {
  15.         $content_number = $n;
  16.     }
  17.  
  18.     $sqllang=db_sql_arg($lang, false);
  19.  
  20.     switch($content_type) {
  21.         case 'text':
  22.         case 'infile':
  23.             $tabcontenttype=db_prefix_table("content_$content_type");
  24.             break;
  25.         default:
  26.             return false;
  27.     }
  28.  
  29.     $sql="INSERT $tabcontenttype SET locale=$sqllang";
  30.  
  31.     $r = db_insert($sql);
  32.  
  33.     if (!$r) {
  34.         return false;
  35.     }
  36.  
  37.     $content_id = db_insert_id();
  38.  
  39.     if ($content_number != $n) {
  40.         $sql="UPDATE $tabnodecontent SET number=number+1 WHERE node_id=$node_id AND number >= $content_number ORDER BY number";
  41.  
  42.         db_update($sql);
  43.     }
  44.  
  45.     $sqltype=db_sql_arg($content_type, false);
  46.  
  47.     $sql="INSERT $tabnodecontent SET node_id=$node_id, content_id=$content_id, content_type=$sqltype, number=$content_number";
  48.  
  49.     $r = db_insert($sql);
  50.  
  51.     return $r ? compact('content_id', 'content_number') : false;
  52. }
  1. function node_delete_content($node_id, $content_id, $content_type) {
  2.     $sqltype=db_sql_arg($content_type, false);
  3.  
  4.     switch($content_type) {
  5.         case 'text':
  6.         case 'infile':
  7.             $tabnodecontent=db_prefix_table('node_content');
  8.             $tabcontenttype=db_prefix_table("content_$content_type");
  9.  
  10.             $sql="DELETE nc, ct FROM $tabnodecontent nc JOIN $tabcontenttype ct ON ct.content_id=nc.content_id WHERE nc.node_id=$node_id AND nc.content_id=$content_id AND nc.content_type=$sqltype";
  11.             break;
  12.         default:
  13.             return false;
  14.     }
  15.  
  16.     $r = db_delete($sql);
  17.  
  18.     if (!$r) {
  19.         return false;
  20.     }
  21.  
  22.     $sql="SET @n=0";
  23.     db_update($sql);
  24.     $sql="UPDATE $tabnodecontent SET number=(@n:=@n+1) WHERE node_id=$node_id ORDER BY number";
  25.     db_update($sql);
  26.  
  27.     return true;
  28. }

Add the view of the content editor in English in the folder views/en/editing with the following content:

  1. /cms/site25
    1. views
      1. en
        1. editing
          1. nodecontenteditor.phtml
  1. <?php extract($errors); ?>
  2. <form action="" method="post">
  3. <input name="clang" type="hidden" value="<?php echo $clang; ?>" />
  4. <p>
  5. <input name="content_create" type="submit" value="Add" />
  6. a type
  7. <?php
  8. $selected=$new_content_type ? $new_content_type : 'text';
  9. ?>
  10. <select name="content_new_type" size="1">
  11. <option value="text" <?php echo $selected == 'text' ? 'selected="selected"' : ''; ?>>Text</option>
  12. <option value="infile" <?php echo $selected == 'infile' ? 'selected="selected"' : ''; ?>>Insert</option>
  13. </select>
  14. #
  15. <input name="content_new_number" type="text" size="2" maxlength="2" value="<?php echo htmlspecialchars($new_content_number, ENT_COMPAT, 'UTF-8'); ?>" title="Number"/>
  16. <?php if ($node_contents): ?>
  17. or
  18. <input name="content_delete" type="submit" value="Delete" />
  19. #
  20. <input name="content_old_number" type="text" size="2" maxlength="2" value="<?php echo htmlspecialchars($old_content_number, ENT_COMPAT, 'UTF-8'); ?>" title="Number"/>
  21. <?php endif; ?>
  22. </p>
  23. <?php if ($missing_new_content_type or $bad_new_content_type or $bad_new_content_number or $missing_old_content_number or $bad_old_content_number or $missing_content_number or $bad_content_number): ?>
  24. <div class="alert">
  25. <?php if ($missing_new_content_type): ?>
  26. <p>The new content has no type.</p>
  27. <?php elseif ($bad_new_content_type): ?>
  28. <p>The type of the new content is not valid.</p>
  29. <?php endif; ?>
  30. <?php if ($bad_new_content_number): ?>
  31. <p>The new content number is not valid.</p>
  32. <?php endif; ?>
  33. <?php if ($missing_old_content_number): ?>
  34. <p>You didn't specify the number of the content to delete.</p>
  35. <?php elseif ($bad_old_content_number): ?>
  36. <p>The number of the content to delete is not valid.</p>
  37. <?php endif; ?>
  38. <?php if ($missing_content_number): ?>
  39. <p>A content number is missing.</p>
  40. <?php endif; ?>
  41. <?php if ($bad_content_number): ?>
  42. <p>A content number is not valid.</p>
  43. <?php endif; ?>
  44. </div>
  45. <?php endif; ?>
  46. <?php if ($node_contents): ?>
  47. <?php
  48. $i=1;
  49. foreach ($node_contents as $c) {
  50.     $content_text='';
  51.     $content_eval=false;
  52.     $content_infile=false;
  53.     extract($c);    /* content_id content_number content_type (content_text content_eval | content_infile) content_pos */
  54. ?>
  55. <p class="<?php echo ($i % 2) ? 'odd' : 'even'; ?>">
  56. <?php echo $i; ?>.
  57. <input name="content_id[<?php echo $i; ?>]" type="hidden" value="<?php echo $content_id; ?>"/>
  58. <input name="content_p[<?php echo $i; ?>]" type="text" size="2" maxlength="2" value="<?php echo htmlspecialchars($content_pos, ENT_COMPAT, 'UTF-8'); ?>"/>
  59. <?php switch ($content_type): ?>
  60. <?php case 'text': ?>
  61. <label>Text:</label>
  62. <?php break; ?>
  63. <?php case 'infile': ?>
  64. <label>Insert:</label>
  65. <?php break; ?>
  66. <?php endswitch; ?>
  67. </p>
  68. <?php switch ($content_type): ?>
  69. <?php case 'text': ?>
  70. <div class="tagbar">
  71. <span><input name="content_eval[<?php echo $i; ?>]" type="checkbox" <?php if ($content_eval) echo 'checked="checked"'; ?> /><img src="<?php echo $base_path; ?>/images/theme/edit/code.png" alt="PHP" title="seval" /></span>
  72. </div>
  73. <textarea id="content_text_<?php echo $i; ?>" name="content_text[<?php echo $i; ?>]" cols="100" rows="8"><?php echo htmlspecialchars($content_text, ENT_COMPAT, 'UTF-8'); ?></textarea>
  74. <?php break; ?>
  75. <?php case 'infile': ?>
  76. <p>
  77. <input name="content_infile[<?php echo $i; ?>]" type="text" size="40" maxlength="200" value="<?php echo htmlspecialchars($content_infile, ENT_COMPAT, 'UTF-8'); ?>" title="File" />
  78. </p>
  79. <?php break; ?>
  80. <?php endswitch; ?>
  81. <?php
  82.     $i++;
  83. }
  84. ?>
  85. <p>
  86. <input id="content_modify" name="content_modify" type="submit" value="Modify" />
  87. contents
  88. </p>
  89. <?php endif; ?>
  90. </form>

Add the view of the content editor in French in the folder views/fr/editing with the following content:

  1. /cms/site25
    1. views
      1. en
        1. editing
          1. nodecontenteditor.phtml
  1. <?php extract($errors); ?>
  2. <form action="" method="post">
  3. <input name="clang" type="hidden" value="<?php echo $clang; ?>" />
  4. <p>
  5. <input name="content_create" type="submit" value="Ajouter" />
  6. un type
  7. <?php
  8. $selected=$new_content_type ? $new_content_type : 'text';
  9. ?>
  10. <select name="content_new_type" size="1">
  11. <option value="text" <?php echo $selected == 'text' ? 'selected="selected"' : ''; ?>>Texte</option>
  12. <option value="infile" <?php echo $selected == 'infile' ? 'selected="selected"' : ''; ?>>Insert</option>
  13. </select>
  14. #
  15. <input name="content_new_number" type="text" size="2" maxlength="2" value="<?php echo htmlspecialchars($new_content_number, ENT_COMPAT, 'UTF-8'); ?>" title="Numéro"/>
  16. <?php if ($node_contents): ?>
  17. ou
  18. <input name="content_delete" type="submit" value="Supprimer" />
  19. le #
  20. <input name="content_old_number" type="text" size="2" maxlength="2" value="<?php echo htmlspecialchars($old_content_number, ENT_COMPAT, 'UTF-8'); ?>" title="Numéro"/>
  21. <?php endif; ?>
  22. </p>
  23. <?php if ($missing_new_content_type or $bad_new_content_type or $bad_new_content_number or $missing_old_content_number or $bad_old_content_number or $missing_content_number or $bad_content_number): ?>
  24. <div class="alert">
  25. <?php if ($missing_new_content_type): ?>
  26. <p>Le nouveau contenu n'a pas de type.</p>
  27. <?php elseif ($bad_new_content_type): ?>
  28. <p>Le type du nouveau contenu n'est pas valide.</p>
  29. <?php endif; ?>
  30. <?php if ($bad_new_content_number): ?>
  31. <p>Le numéro du nouveau contenu n'est pas valide.</p>
  32. <?php endif; ?>
  33. <?php if ($missing_old_content_number): ?>
  34. <p>Vous n'avez pas saisi le numéro du contenu à supprimer.</p>
  35. <?php elseif ($bad_old_content_number): ?>
  36. <p>Le numéro du contenu à supprimer est invalide.</p>
  37. <?php endif; ?>
  38. <?php if ($missing_content_number): ?>
  39. <p>Un numéro de contenu est manquant.</p>
  40. <?php endif; ?>
  41. <?php if ($bad_content_number): ?>
  42. <p>Un numéro de contenu est invalide.</p>
  43. <?php endif; ?>
  44. </div>
  45. <?php endif; ?>
  46. <?php if ($node_contents): ?>
  47. <?php
  48. $i=1;
  49. foreach ($node_contents as $c) {
  50.     $content_text='';
  51.     $content_eval=false;
  52.     $content_infile=false;
  53.     extract($c);    /* content_id content_number content_type (content_text content_eval | content_infile) content_pos */
  54. ?>
  55. <p class="<?php echo ($i % 2) ? 'odd' : 'even'; ?>">
  56. <?php echo $i; ?>.
  57. <input name="content_id[<?php echo $i; ?>]" type="hidden" value="<?php echo $content_id; ?>"/>
  58. <input name="content_p[<?php echo $i; ?>]" type="text" size="2" maxlength="2" value="<?php echo htmlspecialchars($content_pos, ENT_COMPAT, 'UTF-8'); ?>"/>
  59. <?php switch ($content_type): ?>
  60. <?php case 'text': ?>
  61. <label>Texte :</label>
  62. <?php break; ?>
  63. <?php case 'infile': ?>
  64. <label>Insert :</label>
  65. <?php break; ?>
  66. <?php endswitch; ?>
  67. </p>
  68. <?php switch ($content_type): ?>
  69. <?php case 'text': ?>
  70. <div class="tagbar">
  71. <span><input name="content_eval[<?php echo $i; ?>]" type="checkbox" <?php if ($content_eval) echo 'checked="checked"'; ?> /><img src="<?php echo $base_path; ?>/images/theme/edit/code.png" alt="PHP" title="seval" /></span>
  72. </div>
  73. <textarea id="content_text_<?php echo $i; ?>" name="content_text[<?php echo $i; ?>]" cols="100" rows="8"><?php echo htmlspecialchars($content_text, ENT_COMPAT, 'UTF-8'); ?></textarea>
  74. <?php break; ?>
  75. <?php case 'infile': ?>
  76. <p>
  77. <input name="content_infile[<?php echo $i; ?>]" type="text" size="40" maxlength="200" value="<?php echo htmlspecialchars($content_infile, ENT_COMPAT, 'UTF-8'); ?>" title="Fichier" />
  78. </p>
  79. <?php break; ?>
  80. <?php endswitch; ?>
  81. <?php
  82.     $i++;
  83. }
  84. ?>
  85. <p>
  86. <input id="content_modify" name="content_modify" type="submit" value="Modifier" />
  87. le contenu
  88. </p>
  89. <?php endif; ?>
  90. </form>

Add the icon of the field eval in a content of type Text in the folder images/theme/edit:

  1. /cms/site25
    1. images
      1. theme
        1. edit
          1. code.png

Style the content editor by adding the following lines in the file css/theme.css:

  1. .odd {background-color:#ffffe0;}
  2. .even {background-color:#eaefb3;}
  3.  
  4. .tagbar {margin-bottom:5px;}

Enter http://localhost/cms/site25/en in the address bar of your navigator. Identify yourself with the name foobar and the password f00bar. Edit the page Legal information. Add a content of type Text at position 2 then a content of type Insert at position 3. Enter the HTML text <h5>Minimal configuration</h5> in the input field for the text of content 2. Enter files/sysinfo.php in the input field for the file name of content 3. Press Modify at the end of the page. Click on the View button to check the result. Edit the version in French.

Comments

Your comment:
[p] [b] [i] [u] [s] [quote] [pre] [br] [code] [url] [email] strip help 2000

Enter a maximum of 2000 characters.
Improve the presentation of your text with the following formatting tags:
[p]paragraph[/p], [b]bold[/b], [i]italics[/i], [u]underline[/u], [s]strike[/s], [quote]citation[/quote], [pre]as is[/pre], [br]line break,
[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]command[/code], [code=language]source code in c, java, php, html, javascript, xml, css, sql, bash, dos, make, etc.[/code].