1
22

Editing campaigns

Code

Create the file campaignedit.php in the folder actions with the following content:

  1. function campaignedit($lang, $arglist=false) {
  2.     global $supported_languages;
  3.  
  4.     $campaign=$page=false;
  5.  
  6.     if (is_array($arglist)) {
  7.         if (isset($arglist[0])) {
  8.             $campaign=$arglist[0];
  9.         }
  10.         if (isset($arglist[1])) {
  11.             $page=$arglist[1];
  12.         }
  13.     }
  14.  
  15.     $clang=false;
  16.     foreach ($supported_languages as $slang) {
  17.         if (isset($_POST[$slang])) {
  18.             $clang=$slang;
  19.             break;
  20.         }
  21.     }
  22.     if (!$clang) {
  23.         if (isset($_POST['clang'])) {
  24.             $clang = $_POST['clang'];
  25.         }
  26.         else if (isset($_GET['clang'])) {
  27.             $clang = $_GET['clang'];
  28.         }
  29.         else {
  30.             $clang=$lang;
  31.         }
  32.         if (!in_array($clang, $supported_languages)) {
  33.             return run('error/notfound', $lang);
  34.         }
  35.     }
  36.  
  37.     if (!$campaign) {
  38.         return run('error/notfound', $lang);
  39.     }
  40.  
  41.     if (!$page) {
  42.         require_once 'actions/campaigneditsummary.php';
  43.  
  44.         return campaigneditsummary($lang, $clang, $campaign);
  45.     }
  46.  
  47.     require_once 'actions/campaigneditpage.php';
  48.  
  49.     return campaigneditpage($lang, $clang, $campaign, $page);
  50. }

Create the file campaigneditsummary.php in the folder actions with the following content:

  1. require_once 'readarg.php';
  2. require_once 'strtofname.php';
  3. require_once 'userhasrole.php';
  4. require_once 'userprofile.php';
  5. require_once 'models/thread.inc';
  6.  
  7. function campaigneditsummary($lang, $clang, $thread) {
  8.     global $with_toolbar;
  9.  
  10.     $user_id=user_profile('id');
  11.  
  12.     if (!$user_id) {
  13.         return run('error/unauthorized', $lang);
  14.     }
  15.  
  16.     $thread_id = thread_id($thread);
  17.     if (!$thread_id) {
  18.         return run('error/notfound', $lang);
  19.     }
  20.  
  21.     $r = thread_get($lang, $thread_id);
  22.     if (!$r) {
  23.         return run('error/notfound', $lang);
  24.     }
  25.     extract($r); /* thread_user_id thread_type thread_title */
  26.  
  27.     if ($thread_type != 'campaign') {
  28.         return run('error/notfound', $lang);
  29.     }
  30.  
  31.     if ($thread_user_id != $user_id and !user_has_role('administrator')) {
  32.         return run('error/notfound', $lang);
  33.     }
  34.  
  35.     $confirmed=false;
  36.  
  37.     $action='init';
  38.     if (isset($_POST['thread_reorder'])) {
  39.         $action='reorder';
  40.     }
  41.     else if (isset($_POST['node_create'])) {
  42.         $action='create';
  43.     }
  44.     else if (isset($_POST['node_copy'])) {
  45.         $action='copy';
  46.     }
  47.     else if (isset($_POST['node_delete'])) {
  48.         $action='delete';
  49.     }
  50.     else if (isset($_POST['node_confirmdelete'])) {
  51.         $action='delete';
  52.         $confirmed=true;
  53.     }
  54.  
  55.     $new_node_name=$new_node_title=$new_node_number=false;
  56.     $old_node_number=false;
  57.  
  58.     $p=false;
  59.  
  60.     switch($action) {
  61.         case 'create':
  62.         case 'delete':
  63.         case 'copy':
  64.         case 'reorder':
  65.             if (isset($_POST['new_node_title'])) {
  66.                 $new_node_title=readarg($_POST['new_node_title']);
  67.                 $new_node_name = strtofname($new_node_title);
  68.             }
  69.             if (isset($_POST['new_node_number'])) {
  70.                 $new_node_number=readarg($_POST['new_node_number']);
  71.             }
  72.             if (isset($_POST['old_node_number'])) {
  73.                 $old_node_number=readarg($_POST['old_node_number']);
  74.             }
  75.             if (isset($_POST['p'])) {
  76.                 $p=$_POST['p']; // DON'T readarg!
  77.             }
  78.             break;
  79.         default:
  80.             break;
  81.     }
  82.  
  83.     $thread_contents = array();
  84.  
  85.     $r = thread_get_contents($clang, $thread_id);   /* node_id node_number node_ignored node_name node_title node_cloud thread_image */
  86.  
  87.     if (!$r or count($r) != count($p)) {
  88.         $p = false;
  89.     }
  90.  
  91.     if ($r) {
  92.         $pos=1;
  93.         $thread_url = url('campaignedit', $lang) . '/' . $thread_id;
  94.         foreach ($r as $c) {
  95.             $c['node_url'] = $thread_url  . '/' . $c['node_id'];
  96.             $c['pos'] = $p ? $p[$pos] : $pos;
  97.             $thread_contents[$pos] = $c;
  98.             $pos++;
  99.         }
  100.     }
  101.  
  102.     $missing_new_node_title=false;
  103.     $bad_new_node_title=false;
  104.     $bad_new_node_number=false;
  105.  
  106.     $missing_old_node_number=false;
  107.     $bad_old_node_number=false;
  108.  
  109.     switch($action) {
  110.         case 'copy':
  111.         case 'create':
  112.             if (!$new_node_title) {
  113.                 $missing_new_node_title = true;
  114.             }
  115.             else if (!$new_node_name) {
  116.                 $bad_new_node_title = true;
  117.             }
  118.             else if (!preg_match('#^\w+(-\w+)*$#', $new_node_name)) {
  119.                 $bad_new_node_title = true;
  120.             }
  121.             if (!$new_node_number) {
  122.                 $new_node_number = false;
  123.             }
  124.             else if (!is_numeric($new_node_number)) {
  125.                 $bad_new_node_number = true;
  126.             }
  127.             else if ($new_node_number < 1 or $new_node_number > count($thread_contents) + 1) {
  128.                 $bad_new_node_number = true;
  129.             }
  130.             break;
  131.  
  132.         default:
  133.             break;
  134.     }
  135.  
  136.     switch($action) {
  137.         case 'copy':
  138.         case 'delete':
  139.             if (!$old_node_number) {
  140.                 $missing_old_node_number = true;
  141.             }
  142.             else if (!is_numeric($old_node_number)) {
  143.                 $bad_old_node_number = true;
  144.             }
  145.             else if ($old_node_number < 1 or $old_node_number > count($thread_contents)) {
  146.                 $bad_old_node_number = true;
  147.             }
  148.             break;
  149.  
  150.         default:
  151.             break;
  152.     }
  153.  
  154.     $confirm_delete_node=false;
  155.  
  156.     switch($action) {
  157.         case 'create':
  158.         case 'copy':
  159.             if ($missing_new_node_title or $bad_new_node_title or $bad_new_node_number) {
  160.                 break;
  161.             }
  162.  
  163.             if ($action == 'copy') {
  164.                 if ($missing_old_node_number or $bad_old_node_number) {
  165.                     break;
  166.                 }
  167.  
  168.                 $node_id = $thread_contents[$old_node_number]['node_id'];
  169.  
  170.                 $np = thread_copy_node($clang, $thread_user_id, $thread_id, $node_id, $new_node_name, $new_node_title, $new_node_number);
  171.             }
  172.             else {
  173.                 $np = thread_create_node($clang, $thread_user_id, $thread_id, $new_node_name, $new_node_title, $new_node_number);
  174.             }
  175.  
  176.             if (!$np) {
  177.                 break;
  178.             }
  179.  
  180.             extract($np);   /* node_id node_number */
  181.             $node_ignored = false;
  182.             $node_title = $new_node_title;
  183.             $node_url = url('campaignedit', $lang) . '/' . $thread_id . '/' . $node_id;
  184.             $pos = $node_number;
  185.  
  186.             if ($thread_contents) {
  187.                 foreach ($thread_contents as &$c) {
  188.                     if ($c['node_number'] >= $pos) {
  189.                         $c['node_number']++;
  190.                     }
  191.                     if ($c['pos'] >= $pos) {
  192.                         $c['pos']++;
  193.                     }
  194.                 }
  195.                 array_splice($thread_contents, $pos-1, 0, array(compact('node_id', 'node_title', 'node_number', 'node_ignored', 'node_url', 'pos')));
  196.             }
  197.             else {
  198.                 $pos=1;
  199.                 $thread_contents=array($pos => compact('node_id', 'node_title', 'node_number', 'node_ignored', 'node_url', 'pos'));
  200.             }
  201.  
  202.             $new_node_name=$new_node_title=false;
  203.             $new_node_number=$node_number+1;
  204.  
  205.             $old_node_number = false;
  206.  
  207.             break;
  208.  
  209.         case 'delete':
  210.             if ($missing_old_node_number or $bad_old_node_number) {
  211.                 break;
  212.             }
  213.  
  214.             if (!$confirmed) {
  215.                 $confirm_delete_node=true;
  216.                 break;
  217.             }
  218.  
  219.             $node_id = $thread_contents[$old_node_number]['node_id'];
  220.  
  221.             $r = thread_delete_node($thread_id, $node_id);
  222.  
  223.             if (!$r) {
  224.                 break;
  225.             }
  226.  
  227.             unset($thread_contents[$old_node_number]);
  228.             $thread_contents = array_values($thread_contents);
  229.  
  230.             foreach ($thread_contents as &$c) {
  231.                 if ($c['node_number'] >= $old_node_number) {
  232.                     $c['node_number']--;
  233.                 }
  234.                 if ($c['pos'] >= $old_node_number) {
  235.                     $c['pos']--;
  236.                 }
  237.             }
  238.  
  239.             $old_node_number = false;
  240.  
  241.             break;
  242.  
  243.         case 'reorder':
  244.             if (!$p) {
  245.                 break;
  246.             }
  247.  
  248.             $neworder=range(1, count($p));
  249.             array_multisort($p, SORT_NUMERIC, $neworder);
  250.  
  251.             $number=1;
  252.             $nc=array();
  253.             foreach ($neworder as $i) {
  254.                 $c = &$thread_contents[$i];
  255.                 if ($c['node_number'] != $number) {
  256.                     thread_set_node_number($thread_id, $c['node_id'], $number);
  257.                     $c['node_number'] = $number;
  258.                 }
  259.                 $c['pos']=$number;
  260.  
  261.                 $nc[$number++] = $c;
  262.             }
  263.             $thread_contents = $nc;
  264.  
  265.             break;
  266.  
  267.         default:
  268.             break;
  269.     }
  270.  
  271.     head('title', $thread_title ? $thread_title : $thread_id);
  272.     head('description', false);
  273.     head('keywords', false);
  274.     head('robots', 'noindex, nofollow');
  275.  
  276.     $viewsms=url('campaign', $clang) . '/'. $thread_id . '?' . 'slang=' . $lang;
  277.  
  278.     $admin=true;
  279.     $banner = build('banner', $lang, $with_toolbar ? false : compact('viewsms', 'admin'));
  280.     $toolbar = $with_toolbar ? build('toolbar', $lang, compact('viewsms', 'admin')) : false;
  281.  
  282.     $inlanguages=view('inlanguages', false, compact('clang'));
  283.  
  284.     $errors = compact('missing_new_node_title', 'bad_new_node_title', 'bad_new_node_number', 'missing_old_node_number', 'bad_old_node_number');
  285.  
  286.     $content = view('campaigneditsummary', $lang, compact('clang', 'inlanguages', 'thread_title', 'thread_id', 'thread_contents', 'new_node_name', 'new_node_title', 'new_node_number', 'old_node_number', 'confirm_delete_node', 'errors'));
  287.  
  288.     $output = layout('editing', compact('toolbar', 'banner', 'content'));
  289.  
  290.     return $output;
  291. }

Create the view campaigneditsummary in English and in French in the files views/en/campaigneditsummary.phtml and views/fr/campaigneditsummary.phtml:

  1. <?php extract($errors); ?>
  2. <h3<?php if ($thread_title): ?> title="<?php echo $thread_id; ?>"<?php endif; ?>><?php echo htmlspecialchars($thread_title ? $thread_title : $thread_id , ENT_COMPAT, 'UTF-8'); ?></h3>
  3. <form method="post" class="compact">
  4. <input name="clang" type="hidden" value="<?php echo $clang; ?>" />
  5. <p>
  6. <?php echo $inlanguages; ?>
  7. </p>
  8. <p>
  9. <input class="submit submit_add" id="node_create" name="node_create" type="submit" value="Add" />
  10. campaign
  11. <input id="new_node_title" name="new_node_title" type="text" size="50" maxlength="100" value="<?php echo htmlspecialchars($new_node_title, ENT_COMPAT, 'UTF-8'); ?>" title="Title" onkeypress="return focusonenter(event, 'new_node_number')"/>
  12. <span class="nowrap">
  13. #
  14. <input id="new_node_number" name="new_node_number" type="text" size="2" maxlength="3" value="<?php echo htmlspecialchars($new_node_number, ENT_COMPAT, 'UTF-8'); ?>" title="Number" onkeypress="return submitonenter(event, 'node_create')"/>
  15. </span>
  16. </p>
  17. <?php if ($thread_contents): ?>
  18. <div id="threadcontent">
  19. <fieldset class="block">
  20. <legend>Titles</legend>
  21. <table id="nodelist">
  22. <tbody>
  23. <?php
  24. $i=1;
  25. $maxlen=strlen(count($thread_contents))+1;
  26. foreach ($thread_contents as $c) {
  27.     extract($c);    /* pos, node_id node_title, node_url, node_number, node_ignored */
  28.     $node_url .= '?' . 'clang=' . $clang;
  29. ?>
  30. <tr>
  31. <td><input name="p[<?php echo $i; ?>]" type="text" size="2" maxlength="<?php echo $maxlen; ?>" value="<?php echo $pos; ?>" /></td>
  32. <td><a href="<?php echo $node_url; ?>" title="<?php echo $node_id; ?>"><?php echo $node_title ? htmlspecialchars($node_title, ENT_COMPAT, 'UTF-8') : $node_id; ?></a></td>
  33. </tr>
  34. <?php
  35.     $i++;
  36. }
  37. ?>
  38. </tbody>
  39. </table>
  40. </fieldset>
  41. <p>
  42. <input class="submit submit_sort" id="thread_reorder" name="thread_reorder" type="submit" value="Sort" />
  43. list or
  44. <input class="submit submit_copy" id="node_copy" name="node_copy" type="submit" value="Copy" />
  45. or
  46. <input class="submit submit_delete" id="node_delete" name="node_delete" type="submit" value="Delete" />
  47. campaign
  48. <span class="nowrap">
  49. #
  50. <input id="old_node_number" name="old_node_number" type="text" size="2" maxlength="3" value="<?php echo htmlspecialchars($old_node_number, ENT_COMPAT, 'UTF-8'); ?>" title="Number" onkeypress="return submitonenter(event, 'node_delete')"/>
  51. </span>
  52. <?php if ($confirm_delete_node): ?>
  53. <input class="submit submit_confirm" id="node_confirmdelete" name="node_confirmdelete" type="submit" value="Confirm" />
  54. <?php endif; ?>
  55. </p>
  56. </div>
  57. <?php endif; ?>
  58. </form>
  59. <?php
  60. $focus=false;
  61. if ($missing_new_node_title or $bad_new_node_title) {
  62.     $focus='#new_node_title';
  63. }
  64. else if ($bad_new_node_number) {
  65.     $focus='#new_node_number';
  66. }
  67. else if ($missing_old_node_number or $bad_old_node_number) {
  68.     $focus='#old_node_number';
  69. }
  70. else if ($confirm_delete_node) {
  71.     $focus='#old_node_number';
  72. }
  73. ?>
  74. <?php if ($focus): ?>
  75. <?php head('javascript', 'jquery.scrollTo', 'screen'); ?>
  76. <script>
  77. $(function() {$('<?php echo $focus; ?>').focus(); $.scrollTo('<?php echo $focus; ?>', {offset: -200}); });
  78. </script>
  79. <?php endif; ?>
  1. <?php extract($errors); ?>
  2. <h3<?php if ($thread_title): ?> title="<?php echo $thread_id; ?>"<?php endif; ?>><?php echo htmlspecialchars($thread_title ? $thread_title : $thread_id , ENT_COMPAT, 'UTF-8'); ?></h3>
  3. <form method="post" class="compact">
  4. <input name="clang" type="hidden" value="<?php echo $clang; ?>" />
  5. <p>
  6. <?php echo $inlanguages; ?>
  7. </p>
  8. <p>
  9. <input class="submit submit_add" id="node_create" name="node_create" type="submit" value="Ajouter" />
  10. la campagne
  11. <input id="new_node_title" name="new_node_title" type="text" size="50" maxlength="100" value="<?php echo htmlspecialchars($new_node_title, ENT_COMPAT, 'UTF-8'); ?>" title="Titre" onkeypress="return focusonenter(event, 'new_node_number')"/>
  12. <span class="nowrap">
  13. #
  14. <input id="new_node_number" name="new_node_number" type="text" size="2" maxlength="3" value="<?php echo htmlspecialchars($new_node_number, ENT_COMPAT, 'UTF-8'); ?>" title="Numéro" onkeypress="return submitonenter(event, 'node_create')"/>
  15. </span>
  16. </p>
  17. <?php if ($thread_contents): ?>
  18. <div id="threadcontent">
  19. <fieldset class="block">
  20. <legend>Titres</legend>
  21. <table id="nodelist">
  22. <tbody>
  23. <?php
  24. $i=1;
  25. $maxlen=strlen(count($thread_contents))+1;
  26. foreach ($thread_contents as $c) {
  27.     extract($c);    /* pos, node_id node_title, node_url, node_number, node_ignored */
  28.     $node_url .= '?' . 'clang=' . $clang;
  29. ?>
  30. <tr>
  31. <td><input name="p[<?php echo $i; ?>]" type="text" size="2" maxlength="<?php echo $maxlen; ?>" value="<?php echo $pos; ?>" /></td>
  32. <td><a href="<?php echo $node_url; ?>" title="<?php echo $node_id; ?>"><?php echo $node_title ? htmlspecialchars($node_title, ENT_COMPAT, 'UTF-8') : $node_id; ?></a></td>
  33. </tr>
  34. <?php
  35.     $i++;
  36. }
  37. ?>
  38. </tbody>
  39. </table>
  40. </fieldset>
  41. <p>
  42. <input class="submit submit_sort" id="thread_reorder" name="thread_reorder" type="submit" value="Trier" />
  43. la liste ou
  44. <input class="submit submit_copy" id="node_copy" name="node_copy" type="submit" value="Copier" />
  45. ou
  46. <input class="submit submit_delete" id="node_delete" name="node_delete" type="submit" value="Supprimer" />
  47. la campagne
  48. <span class="nowrap">
  49. #
  50. <input id="old_node_number" name="old_node_number" type="text" size="2" maxlength="3" value="<?php echo htmlspecialchars($old_node_number, ENT_COMPAT, 'UTF-8'); ?>" title="Numéro" onkeypress="return submitonenter(event, 'node_delete')"/>
  51. </span>
  52. <?php if ($confirm_delete_node): ?>
  53. <input class="submit submit_confirm" id="node_confirmdelete" name="node_confirmdelete" type="submit" value="Confirmer" />
  54. <?php endif; ?>
  55. </p>
  56. </div>
  57. <?php endif; ?>
  58. </form>
  59. <?php
  60. $focus=false;
  61. if ($missing_new_node_title or $bad_new_node_title) {
  62.     $focus='#new_node_title';
  63. }
  64. else if ($bad_new_node_number) {
  65.     $focus='#new_node_number';
  66. }
  67. else if ($missing_old_node_number or $bad_old_node_number) {
  68.     $focus='#old_node_number';
  69. }
  70. else if ($confirm_delete_node) {
  71.     $focus='#old_node_number';
  72. }
  73. ?>
  74. <?php if ($focus): ?>
  75. <?php head('javascript', 'jquery.scrollTo', 'screen'); ?>
  76. <script>
  77. $(function() {$('<?php echo $focus; ?>').focus(); $.scrollTo('<?php echo $focus; ?>', {offset: -200}); });
  78. </script>
  79. <?php endif; ?>

Create the file campaigneditpage.php in the folder actions with the following content:

  1. require_once 'userhasrole.php';
  2. require_once 'userprofile.php';
  3. require_once 'models/thread.inc';
  4.  
  5. function campaigneditpage($lang, $clang, $thread, $node) {
  6.     global $with_toolbar, $supported_contents, $limited_contents;
  7.  
  8.     $user_id=user_profile('id');
  9.  
  10.     if (!$user_id) {
  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.     $node_id = thread_node_id($thread_id, $node, $clang);
  20.     if (!$node_id) {
  21.         return run('error/notfound', $lang);
  22.     }
  23.  
  24.     $r = thread_get($clang, $thread_id);
  25.     if (!$r) {
  26.         return run('error/notfound', $lang);
  27.     }
  28.     extract($r); /* thread_user_id thread_type thread_name thread_title thread_abstract thread_cloud */
  29.  
  30.     if ($thread_type != 'campaign') {
  31.         return run('error/notfound', $lang);
  32.     }
  33.  
  34.     if ($thread_user_id != $user_id and !user_has_role('administrator')) {
  35.         return run('error/notfound', $lang);
  36.     }
  37.  
  38.     $content_types=$limited_contents['campaign'];
  39.     $node_editor = build('nodeeditor', $lang, $clang, $node_id, $content_types);
  40.  
  41.     $node_name=$node_title=false;
  42.     $r = thread_get_node($clang, $thread_id, $node_id);
  43.     if ($r) {
  44.         extract($r); /* node_name node_title */
  45.     }
  46.  
  47.     head('title', $node_title ? $node_title : $node_id);
  48.     head('description', false);
  49.     head('keywords', false);
  50.     head('robots', 'noindex, nofollow');
  51.  
  52.     $banner=$toolbar=false;
  53.  
  54.     $headline_text=translate('campaignsummary:title', $lang);
  55.     $headline_url=url('campaignedit', $lang) . '/' . $thread_id . '?' . 'clang=' . $clang;
  56.     $headline = compact('headline_text', 'headline_url');
  57.     $viewsms=url('campaign', $clang) . '/'. $thread_id . '/' . $node_id;
  58.  
  59.     $banner = build('banner', $lang, $with_toolbar ? compact('headline') : compact('headline', 'viewsms'));
  60.     $toolbar = $with_toolbar ? build('toolbar', $lang, compact('viewsms')) : false;
  61.  
  62.     $prev_node_label=$prev_node_url=false;
  63.     $r=thread_node_prev($clang, $thread_id, $node_id);
  64.     if ($r) {
  65.         extract($r);
  66.         $prev_node_label = $prev_node_title ? $prev_node_title : $prev_node_id;
  67.         $prev_node_url=url('campaignedit', $lang) . '/' . $thread_id . '/'. $prev_node_id . '?' . 'clang=' . $clang;
  68.     }
  69.  
  70.     $next_node_label=$next_node_url=false;
  71.     $r=thread_node_next($clang, $thread_id, $node_id);
  72.     if ($r) {
  73.         extract($r);
  74.         $next_node_label = $next_node_title ? $next_node_title : $next_node_id;
  75.         $next_node_url=url('campaignedit', $lang) . '/' . $thread_id . '/'. $next_node_id . '?' . 'clang=' . $clang;
  76.     }
  77.  
  78.     $title = view('headline', false, $headline);
  79.     $sidebar = view('sidebar', false, compact('title'));
  80.  
  81.     $content = view('campaigneditpage', $lang, compact('node_editor', 'node_id', 'node_title', 'prev_node_url', 'prev_node_label', 'next_node_url', 'next_node_label'));
  82.  
  83.     $output = layout('editing', compact('toolbar', 'banner', 'content', 'sidebar'));
  84.  
  85.     return $output;
  86. }

Create the view campaigneditpage in English and in French in the files views/en/campaigneditpage.phtml and views/fr/campaigneditpage.phtml:

  1. <h3<?php if ($node_title): ?> title="<?php echo $node_id; ?>"<?php endif; ?>><?php echo htmlspecialchars($node_title ? $node_title : $node_id , ENT_COMPAT, 'UTF-8'); ?></h3>
  2. <?php if ($next_node_url or $prev_node_url): ?>
  3. <p class="navigation menu">
  4. <?php if ($prev_node_url): ?>
  5. <a class="previous" href="<?php echo $prev_node_url; ?>"><span>&lt;</span></a>
  6. <a href="<?php echo $prev_node_url; ?>"><?php echo htmlspecialchars($prev_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  7. <?php endif; ?>
  8. <?php if ($next_node_url and $prev_node_url): ?>
  9. &nbsp;|&nbsp;
  10. <?php endif; ?>
  11. <?php if ($next_node_url): ?>
  12. <a href="<?php echo $next_node_url; ?>"><?php echo htmlspecialchars($next_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  13. <a class="next" href="<?php echo $next_node_url; ?>"><span>&gt;</span></a>
  14. <?php endif; ?>
  15. </p>
  16. <?php endif; ?>
  17. <?php echo $node_editor; ?>
  1. <h3<?php if ($node_title): ?> title="<?php echo $node_id; ?>"<?php endif; ?>><?php echo htmlspecialchars($node_title ? $node_title : $node_id , ENT_COMPAT, 'UTF-8'); ?></h3>
  2. <?php if ($next_node_url or $prev_node_url): ?>
  3. <p class="navigation menu">
  4. <?php if ($prev_node_url): ?>
  5. <a class="previous" href="<?php echo $prev_node_url; ?>"><span>&lt;</span></a>
  6. <a href="<?php echo $prev_node_url; ?>"><?php echo htmlspecialchars($prev_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  7. <?php endif; ?>
  8. <?php if ($next_node_url and $prev_node_url): ?>
  9. &nbsp;|&nbsp;
  10. <?php endif; ?>
  11. <?php if ($next_node_url): ?>
  12. <a href="<?php echo $next_node_url; ?>"><?php echo htmlspecialchars($next_node_label, ENT_COMPAT, 'UTF-8'); ?></a>
  13. <a class="next" href="<?php echo $next_node_url; ?>"><span>&gt;</span></a>
  14. <?php endif; ?>
  15. </p>
  16. <?php endif; ?>
  17. <?php echo $node_editor; ?>

Create the URL for the action campaignedit in English and in French in the file aliases.inc:

  1.         'edit/campaign' => 'campaignedit',
  1.         'edition/campagne' => 'campaignedit',

Edit the file actions/campaignsummary.php:

  1.     global $system_languages, $with_toolbar;
  1.     $slang=false;
  2.     if (isset($_GET['slang'])) {
  3.         $slang = $_GET['slang'];
  4.     }
  5.     else {
  6.         $slang=$lang;
  7.     }
  8.     if (!in_array($slang, $system_languages)) {
  9.         return run('error/notfound', $lang);
  10.     }
  1.     $editsms=url('campaignedit', $slang) . '/'. $campaign_id . '?' . 'clang=' . $lang;
  2.  
  3.     $banner = build('banner', $lang, $with_toolbar ? compact('headline', 'search') : compact('headline', 'search', 'editsms'));
  4.     $toolbar = $with_toolbar ? build('toolbar', $lang, compact('editsms')) : false;

Edit the file actions/campaignpage.php:

  1.     global $system_languages, $with_toolbar;
  1.     $slang=false;
  2.     if (isset($_GET['slang'])) {
  3.         $slang = $_GET['slang'];
  4.     }
  5.     else {
  6.         $slang=$lang;
  7.     }
  8.     if (!in_array($slang, $system_languages)) {
  9.         return run('error/notfound', $lang);
  10.     }
  1.     $editsms=url('campaignedit', $slang) . '/' . $thread_id . '/' . $node_id . '?' . 'clang=' . $lang;
  2.  
  3.     $banner = build('banner', $lang, $with_toolbar ? compact('headline', 'search') : compact('headline', 'search', 'editsms'));
  4.     $toolbar = $with_toolbar ? build('toolbar', $lang, compact('editsms')) : false;

Edit the file blocks/banner.php:

  1.     $is_client = user_has_role('client');
  1.                 case 'editsms':
  2.                     if ($param) {
  3.                         if ($is_client or $is_admin) {
  4.                             $edit_page=$param;
  5.                         }
  6.                     }
  7.                     break;
  8.                 case 'viewsms':
  9.                     if ($param) {
  10.                         if ($is_client or $is_admin) {
  11.                             $view_page=$param;
  12.                         }
  13.                     }
  14.                     break;

Edit the file blocks/toolbar.php:

  1.     $is_client = user_has_role('client');
  1.                 case 'editsms':
  2.                     if ($param) {
  3.                         if ($is_client or $is_admin) {
  4.                             $edit_page=$param;
  5.                         }
  6.                     }
  7.                     break;
  8.                 case 'viewsms':
  9.                     if ($param) {
  10.                         if ($is_client or $is_admin) {
  11.                             $view_page=$param;
  12.                         }
  13.                     }
  14.                     break;
Test

Connect as a client.

Click on the large phone to display the list of campaigns.

Bar Foo

  1. The web engine

Click on the keyboard to switch to editing mode.

Bar Foo

campaign #

Titles
The web engine

list or or campaign #

Add a campaign called QRmii.

Titles
The web engine
QRmii

Click on the web to switch to viewing mode.

Bar Foo

  1. The web engine
  2. QRmii

Click on the keyboard to switch to editing mode.

Press on the flag to display the list of campaigns in French.

Titles
Le moteur web

The campaign QRmii doesn't exist in French.

Click on the web to switch to viewing mode.

  1. The web engine

Click on the keyboard then on the flag to edit the campaigns in English.

Click on the title The web engine to access its content.

The web engine

Check the content of the message.

Click on the link QRmii under the title to move to the next campaign.

Enter the keywords QR code QRmii in the cloud.

Press Edit.

Add a content of type SMS.

Type in A QRmii is a QR code which contains a short URL. Flashing a QRmii with a smartphone displays the page of the original URL. in the text field.

Press Modify.

Click on the web to display the content of the campaign.

QRmii

QR code QRmii

Message

A QRmii is a QR code which contains a short URL. Flashing a QRmii with a smartphone displays the page of the original URL.

Check the keywords displayed by the cloud of the search engine.

Click on the link The web engine under the title to display the content of the previous campaign.

Click on the title Campagnes at top right to display the list of campaigns.

To create the version in French of the campaign QRmii, display the list of campaigns in English in the editor and click on the title QRmii.

Press on the flag to switch to the version in French.

Notice that the title is empty. As long as a campaign has no title, it can't be accessed. Enter QRmii in the text field for the title and complete the cloud with the keywords QR code QRmii.

Press Edit to create the version in French.

Enter Un QRmii est un code QR qui contient une URL raccourcie. Flasher un QRmii avec un smartphone affiche la page de l'URL d'origine. in the text field for the SMS.

Press Modify.

To test the interface in French, enter the URL /fr/accueil or more simply /fr.

Git
  1. /izendsms.com
    1. actions
      1. campaignedit.php
      2. campaigneditpage.php
      3. campaigneditsummary.php
      4. campaignpage.php
      5. campaignsummary.php
    2. blocks
      1. banner.php
      2. toolbar.php
    3. includes
      1. aliases.inc
    4. views
      1. en
        1. campaigneditpage.phtml
        2. campaigneditsummary.phtml
      2. fr
        1. campaigneditpage.phtml
        2. campaigneditsummary.phtml

Commit this version:

$ git status
$ git add actions/campaignedit.php actions/campaigneditpage.php actions/campaigneditsummary.php actions/campaignpage.php actions/campaignsummary.php blocks/banner.php blocks/toolbar.php includes/aliases.inc views/en/campaigneditpage.phtml views/en/campaigneditsummary.phtml views/fr/campaigneditpage.phtml views/fr/campaigneditsummary.phtml
$ git commit -m'Adds editing campaigns'

IMPORTANT: Edit the DB connector in the file includes/db.inc.

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].