Changeset 1118 for trunk


Ignore:
Timestamp:
03/22/10 03:43:03 (2 years ago)
Author:
wefgef
Message:

Proper security UI

  • Added a select instead of the input field for the security level of a wiki page.

REVIEW URL http://reviewboard.infoarena.ro/r/142/

Location:
trunk/www
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/www/controllers/textblock_edit.php

    r1069 r1118  
    3434    $values['text'] = request('text', $page['text']); 
    3535    $values['title'] = request('title', $page['title']); 
    36     $values['security'] = request('security', $page['security']); 
     36 
     37    $security_values = array_map('trim', explode(':', $page['security'])); 
     38    $values['security'] = request('security', $security_values[0]); 
     39    if (count($security_values) > 1) { 
     40        $values['security_special'] = request('security_special', $security_values[1]); 
     41    } else { 
     42        $values['security_special'] = request('security_special', ''); 
     43    } 
     44 
    3745    $values['forum_topic'] = request('forum_topic', $page['forum_topic']); 
    3846    $values['tags'] = request('tags', tag_build_list("textblock", $page_name, "tag")); 
     
    4553        $new_page['text'] = $values['text']; 
    4654        $new_page['title'] = $values['title']; 
    47         $new_page['security'] = $values['security']; 
     55 
     56        if ($values['security_special'] != '') { 
     57            $new_page['security'] = sprintf('%s: %s', $values['security'], 
     58                                            $values['security_special']); 
     59        } else { 
     60            $new_page['security'] = $values['security']; 
     61        } 
     62 
    4863        $new_page['forum_topic'] = $values['forum_topic']; 
    4964        $new_page['creation_timestamp'] = $values['creation_timestamp']; 
  • trunk/www/static/css/screen.css

    r1099 r1118  
    15461546    margin: 0 .5em .5em 2em; 
    15471547} 
     1548 
     1549/* Proper Security UI */ 
     1550.security_show { 
     1551    display: inline; 
     1552    margin-left: 0.5em; 
     1553} 
     1554 
     1555.security_hide { 
     1556    display: none; 
     1557} 
  • trunk/www/views/textblock_edit.php

    r1111 r1118  
    1616<?= html_escape($task_id) ?></a></h1> 
    1717<?php } ?> 
     18 
     19<script type="text/javascript"> 
     20    function toggleSpecial() { 
     21        var select = document.getElementById("security_select"); 
     22        var option = select.options[select.selectedIndex].value; 
     23        var special = document.getElementById("special"); 
     24 
     25        if (option == "round" || option == "task") { 
     26            special.className = "security_show"; 
     27        } else { 
     28            special.className = "security_hide"; 
     29        } 
     30    } 
     31</script> 
    1832 
    1933<form accept-charset="utf-8" action="<?= html_escape(url_textblock_edit($page_name)) ?>" method="post" id="form_wikiedit" <?= tag_form_event() ?>> 
     
    6074    <li id="field_security"> 
    6175        <label for="form_security">Nivel de securitate al paginii 
    62         <a href="<?= html_escape(url_textblock('documentatie/securitate')) ?>">(?)</a></label>  
    63         <input type="text" name="security" value="<?= fval('security') ?>" id="form_security" /> 
     76        <a href="<?= html_escape(url_textblock('documentatie/securitate')) ?>">(?)</a></label> 
     77 
     78        <select id="security_select" name="security" onchange="toggleSpecial()"> 
     79        <?php 
     80            $options = array( 
     81                array('value' => 'public', 'html' => 'Public'), 
     82                array('value' => 'protected', 'html' => 'Protected'), 
     83                array('value' => 'private', 'html' => 'Private'), 
     84                array('value' => 'round', 'html' => 'Round'), 
     85                array('value' => 'task', 'html' => 'Task') 
     86            ); 
     87 
     88            foreach ($options as $option) { 
     89                if ($option['value'] == fval('security')) { 
     90                    echo sprintf('<option value="%s" selected="selected">%s 
     91                                 </option>', $option['value'], $option['html']); 
     92                } else { 
     93                    echo sprintf('<option value="%s">%s</option>', 
     94                                 $option['value'], $option['html']); 
     95                } 
     96            } 
     97        ?> 
     98        </select> 
     99 
     100        <?php 
     101            if (in_array(fval('security'), array('round', 'task'))) { 
     102                $css_class = "security_show"; 
     103            } else { 
     104                $css_class = "security_hide"; 
     105            } 
     106 
     107            echo sprintf('<input name="security_special" id="special" 
     108                          type="text" value="%s" class="%s">', 
     109                          fval('security_special'), $css_class); 
     110        ?> 
     111 
    64112        <?= ferr_span('security') ?> 
    65113    </li> 
Note: See TracChangeset for help on using the changeset viewer.