summaryrefslogtreecommitdiffstats
path: root/pages/content/Pages:Handle.xml
blob: 9abc7d90eb5b8ad98b341146bc5a23739de4e1df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<?xml version="1.0" encoding="UTF-8" ?>
<page>
  <info>
    <name>Pages:Handle</name>
    <template>phpexec</template>
    <access>0:0</access>
    <type>c</type>
  </info>
  <data>
    <code>
      <![CDATA[
<?PHP
  Uses('pages', 'links', 'templates');
  
  
  if($_POST['type'] != 'c' && $_POST['type'] != 'b')
    exit();
  
  if(isset($_POST['view'])) {
    if($_POST['name']) {
      header('Location: ' . $GLOBALS['links']->GetNeonLink(Unquote($_POST['name']), null, false));
      exit();
    }
  }
  elseif(isset($_POST['new'])) {
    $title = '{{New page}}';  
  ?>
  <h2>{{New page}}</h2>
  
  <form method="post" action="<?PHP echo $GLOBALS['links']->GetNeonLink('Pages:New'); ?>">
    <input type="hidden" name="type" value="<?PHP echo $_POST['type']; ?>" />
    {{Name}}: <input type="text" id="pagename" name="name" size="70" /><br />
    {{Template}}: <select type="text" class="spaced-top" name="template" size="1" />
    <?PHP
      foreach(array_keys($GLOBALS['templates']) as $key)
        echo '<option>' . $key . '</option>';
    ?>
    </select><br />
    <input type="submit" class="spaced-top" value="{{New}}" />
    <input type="submit" class="spaced-top" name="back" value="{{Back}}" />
  </form>
  <?PHP
  }
  elseif(isset($_POST['edit'])) {
    if($_POST['name']) {
      $data = $GLOBALS['pages']->GetEditor(Unquote($_POST['name']), $_POST['type'], $GLOBALS['links']->GetNeonLink('Pages', null, false));
      
      $title = $data['title'];
      
      echo $data['content'];
    }
  }
  elseif(isset($_POST['privs'])) {
    if($_POST['name']) {
      $name = htmlspecialchars(Unquote($_POST['name']));
      
      $title = '{{Change access to \'' . $name . '\'}}';
        
      echo '<h2>{{Change access to \'' . $name . '\'}}</h2>';
      
      $access = $GLOBALS['pages']->GetAccess(Unquote($_POST['name']), $_POST['type']);
      $groups = $GLOBALS['user']->ListGroups();
      
      array_unshift($groups, array(0, '{{Guest}}'));
      
      echo '<form action="' . $GLOBALS['links']->GetNeonLink('Pages:Privs') . '" method="post">';
      
      echo '<input type="hidden" name="name" value="' . $name . '" />';
      echo '<input type="hidden" name="type" value="' . $_POST['type'] . '" />';
      
      echo '<table>';
      
      foreach($groups as $group) {
        echo '<tr><td>' . htmlspecialchars($group[1]) . '</td><td>';
        
        echo '<select size="1" name="group_' . $group[0] . '">';
        
        echo '<option value="0"';
        if((hexdec($access[0][$group[0]/4]) & (1 << ($group[0]%4))) == 0) echo ' selected="selected"';
        echo '>{{No access}}</option>';
        
        echo '<option value="1"';
        if(((hexdec($access[0][$group[0]/4]) & (1 << ($group[0]%4))) != 0)
          && ((hexdec($access[1][$group[0]/4]) & (1 << ($group[0]%4))) == 0))
          echo ' selected="selected"';
        echo '>{{Read only}}</option>';
        
        echo '<option value="2"';
        if((hexdec($access[1][$group[0]/4]) & (1 << ($group[0]%4))) != 0) echo ' selected="selected"';
        echo '>{{Read and write}}</option>';
        
        echo '</select></td></tr>';
      }
      
      echo '</table>';
      
      echo '<input type="submit" class="spaced-top" value="{{Change}}" /> ';
      echo '<input type="submit" class="spaced-top" name="back" value="{{Back}}" />';
      
      echo '</form>';
    }
  }
  elseif(isset($_POST['copy'])) {
    if($_POST['name']) {
      $name = htmlspecialchars(Unquote($_POST['name']));
      
      $title = '{{Copy \'' . $name . '\'}}';
        
      echo '<h2>{{Copy \'' . $name . '\'}}</h2>';
      
      echo '<form method="post" action="' . $GLOBALS['links']->GetNeonLink('Pages:Copy') . '">';
      echo '<input type="hidden" name="name" value="' . $name . '" />';
      echo '<input type="hidden" name="type" value="' . $_POST['type'] . '" />';
      echo '{{New name}}: <input type="text" name="newname" value="' . $name . '" size="70" /><br />';
      echo '<input type="submit" class="spaced-top" value="{{Copy}}" /> ';
      echo '<input type="submit" class="spaced-top" name="back" value="{{Back}}" />';
      echo '</form>';
    }
  }
  elseif(isset($_POST['rename'])) {
    if($_POST['name']) {
      $name = htmlspecialchars(Unquote($_POST['name']));
      
      $title = '{{Rename \'' . $name . '\'}}';
      
      echo '<h2>{{Rename \'' . $name . '\'}}</h2>';
      
      echo '<form method="post" action="' . $GLOBALS['links']->GetNeonLink('Pages:Rename') . '">';
      echo '<input type="hidden" name="name" value="' . $name . '" />';
      echo '<input type="hidden" name="type" value="' . $_POST['type'] . '" />';
      echo '{{New name}}: <input type="text" name="newname" value="' . $name . '" size="70" /><br />';
      echo '<input type="submit" class="spaced-top" value="{{Rename}}" /> ';
      echo '<input type="submit" class="spaced-top" name="back" value="{{Back}}" />';
      echo '</form>';
    }
  }
  elseif(isset($_POST['delete'])) {
    if($_POST['name']) {
      $name = htmlspecialchars(Unquote($_POST['name']));
      
      $title = '{{Delete \'' . $name . '\'}}';
      
      echo '<h2>{{Delete \'' . $name . '\'}}</h2>';
      
      echo '<form method="post" action="' . $GLOBALS['links']->GetNeonLink('Pages:Delete') . '">';
      echo '<input type="hidden" name="name" value="' . $name . '" />';
      echo '<input type="hidden" name="type" value="' . $_POST['type'] . '" />';
      echo '{{Do you really want to delete the page \'' . $name . '\'?}}<br />';
      echo '<input type="submit" class="spaced-top" value="{{Delete}}" /> ';
      echo '<input type="submit" class="spaced-top" name="back" value="{{Back}}" />';
      echo '</form>';
    }
  }
?>
      ]]>
    </code>
  </data>
</page>