File: color_scheme.php

package info (click to toggle)
zoph 0.6-2.1
  • links: PTS
  • area: main
  • in suites: etch-m68k
  • size: 1,716 kB
  • ctags: 2,283
  • sloc: php: 8,554; perl: 1,601; sh: 760; sql: 382; python: 338; makefile: 71
file content (152 lines) | stat: -rw-r--r-- 5,131 bytes parent folder | download | duplicates (2)
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
<?php
/*
 * This file is part of Zoph.
 *
 * Zoph is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 * 
 * Zoph is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * You should have received a copy of the GNU General Public License
 * along with Zoph; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
    require_once("include.inc.php");

    if (!$user->is_admin()) {
        $_action = "display";
    }

    $color_scheme_id = getvar("color_scheme_id");

    $color_scheme = new color_scheme($color_scheme_id);

    if ($_action == "copy") {
        $title = translate("Copy Color Scheme");
        $color_scheme->lookup();
        $name = "copy of " . $color_scheme->get("name");
        $color_scheme_id = 0;
        $_action = "new";
        $copy=1;
    }
    $obj = &$color_scheme;
    $redirect = "color_schemes.php";
    require_once("actions.inc.php");

    if ($_action == "update") {
        $user->prefs->load();
    }

    if ($action != "insert") {
        $color_scheme->lookup();
        $title = $color_scheme->get("name");
    } 
    else {
        $title = translate("New Color Scheme");
    }

    require_once("header.inc.php");
?>
<?php
    if ($action == "display") {
?>
          <h1>
<?php
        if ($user->is_admin()) {
?>
          <span class="actionlink">
            <a href="color_scheme.php?_action=edit&amp;color_scheme_id=<?php echo $color_scheme->get("color_scheme_id") ?>"><?php echo translate("edit") ?></a> |
            <a href="color_scheme.php?_action=delete&amp;color_scheme_id=<?php echo $color_scheme->get("color_scheme_id") ?>"><?php echo translate("delete") ?></a> |
            <a href="color_scheme.php?_action=new"><?php echo translate("new") ?></a>
          </span>
<?php
        }
?>
            <?php echo translate("color scheme") ?>
          </h1>
      <div class="main">
        <h2><?php echo $color_scheme->get("name") ?></h2>

<?php
        $colors = $color_scheme->get_display_array();
?>
            <table class="colors">
<?php
        while (list($name, $value) = each($colors)) {
            if ($name == "Name") { continue; }
?>
                <tr>
                  <th class="fieldtitle"><?php echo $name ?></th>
                  <td><?php echo $value ?></td>
                  <td style="width: 60px; background: #<?php echo $value ?>;">&nbsp;</td>
                </tr>
<?php
        } ?>
              </table>
<?php    }
    else if ($action == "confirm") {
?>
          <h1><?php echo translate("delete color scheme") ?></h1>
      <div class="main">
          <span class="actionlink">
            <a href="color_scheme.php?_action=confirm&amp;color_scheme_id=<?php echo $color_scheme->get("color_scheme_id") ?>"><?php echo translate("delete") ?></a> |
            <a href="color_scheme.php?_action=display&amp;color_scheme_id=<?php echo $color_scheme->get("color_scheme_id") ?>"><?php echo translate("cancel") ?></a>
          </span>
          <?php echo sprintf(translate("Confirm deletion of '%s'"), $color_scheme->get("name")) ?>:
          <br>
<?php
    }
    else {
        $colors = $color_scheme->get_edit_array();
?>
          <h1>
            <span class="actionlink">
              <a href="color_schemes.php"><?php echo translate("return") ?></a>
            </span>
            <?php echo translate("color scheme") ?>
          </h1>
      <div class="main">
        <form action="color_scheme.php">
        <table class="colors">
        <tr>
          <td class="fieldtitle">Name</td>
          <td>
              <input type="hidden" name="_action" value="<?php echo $action ?>">
              <input type="hidden" name="color_scheme_id" value="<?php echo $color_scheme->get("color_scheme_id") ?>">

<?php
              if ($copy) {
                  echo create_text_input("name", "copy of " . $color_scheme->get("name"), 16, 64);
              } else {
                  echo create_text_input("name", $color_scheme->get("name"), 16, 64);
              }
?>
           </td>
        </tr>

<?php
        while (list($name, $value) = each($colors)) {
            if ($name == "Name") { continue; }
            $bg = preg_replace('/.*value="([^"]+)".*\n/', '$1', $value);
?>
        <tr>
          <td class="fieldtitle"><?php echo $name ?></td>
                <td><?php echo $value ?></td>
                <td style='width: 60px; <?php echo $action != "insert" ? " background: #$bg" : "" ?>' >&nbsp;</td>
        </tr>
<?php
        }
?>
</table>
<input type="submit" value="<?php echo translate($action, 0) ?>">
<?php
    }
?>
<?php echo ( $action == "" || $action == "display" || $action == "delete" || $action == "confirm" ) ? "" : "</form>"; ?>
</div>

<?php require_once("footer.inc.php"); ?>