File: places.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 (154 lines) | stat: -rw-r--r-- 4,713 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
153
154
<?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() && !$user->get("browse_places")) {
        header("Location: " . add_sid("zoph.php"));
    }
    $parent_place_id = getvar("parent_place_id");
    if (!$parent_place_id) {
        $place = get_root_place();
    }
    else {
        $place = new place($parent_place_id);
    }
    $place->lookup();
    $ancestors = $place->get_ancestors();
    $children = $place->get_children(null, "title");

    $total_photo_count = $place->get_total_photo_count($user);
    $photo_count = $place->get_photo_count($user);

    $title = $place->get("parent_place_id") ? $place->get("title") : translate("Places");

    require_once("header.inc.php");
?>
    <h1>
<?php
    if ($user->is_admin()) {
?>
        <span class="actionlink"><a href="place.php?_action=new&amp;parent_place_id=<?php echo $place->get("place_id") ?>"><?php echo translate("new") ?></a></span>
<?php
    }
?>
        <?php echo translate("places") . "\n" ?>
    </h1>
    <div class="main">
<?php
    if ($user->is_admin()) {
?>
        <span class="actionlink">
            <a href="place.php?_action=edit&amp;place_id=<?php echo $place->get("place_id") ?>"><?php echo translate("edit") ?></a> | 
            <a href="place.php?_action=delete&amp;place_id=<?php echo $place->get("place_id") ?>"><?php echo translate("delete") ?></a>
        </span>
        
        <h2>
<?php
    if ($ancestors) {
        while ($parent = array_pop($ancestors)) {
?>
            <?php echo $parent->get_link() ?> &gt;
<?php
        }
    }
?>
        </h2>
      <form id="quicknav">
<?php
        echo create_pulldown("parent_place_id", 0, get_places_select_array($user), "onChange='form.submit()'");
?>
      </form>
<?php
    }
    if ($user->get("detailed_places")) {
        echo $place->to_html();
        if ($place->get("notes")) {
            echo $place->get("notes");
        }
    }
    else {
        echo "<h2>" . $title . "</h2>\n";
    }
    if ($place->get("place_description")) {
       echo $place->get("place_description");
    }
?>
    <br><br>
<?php
    $fragment = translate("in this place");
    if($total_photo_count > 0) {
        if ($total_photo_count > $photo_count && $children) {
?>
        <span class="actionlink">
            <a href="photos.php?location_id=<?php echo $place->get_branch_ids($user) ?>"><?php echo translate("view photos") ?></a>
        </span>
<?php   
            $fragment .= " " . translate("or its children");
            if ($total_photo_count > 1) {
                echo sprintf(translate("There are %s photos"), $total_photo_count);
                echo " $fragment.<br>\n";
            }
            else {
                echo sprintf(translate("There is %s photo"), $total_photo_count);
                echo " $fragment.<br>\n";
            }
        }
        $fragment = translate("in this place");
        if (!$place->get("parent_place_id")) { // root place
            $fragment = translate("available");
        }
        if ($photo_count > 0) {
?>
            <span class="actionlink">
                <a href="photos.php?location_id=<?php echo $place->get("place_id") ?>"><?php echo translate("view photos")?></a>
            </span>
<?php

            if ($photo_count > 1) {
                echo sprintf(translate("There are %s photos"), $photo_count);
                echo " $fragment.<br>\n";
            }
            else {
                echo sprintf(translate("There is %s photo"), $photo_count);
                echo " $fragment.<br>\n";
            }
        }
    }
    else {
?>
        <?php echo translate("There are no photos") ?> <?php echo $fragment . ".<br>\n"; 
    }
    if ($children) {
?>
        <ul>
<?php
        foreach($children as $a) {
?>
            <li><a href="places.php?parent_place_id=<?php echo $a->get("place_id") ?>"><?php echo $a->get("title") ?></a></li>
<?php
        }
?>
        </ul>
<?php
    }
?>
    </div>
<?php
    require_once("footer.inc.php");
?>