clarify use of mysql_fetch_array : use mysql_fetch_assoc or mysql_fetch_row
[diogenes.git] / include / Barrel / File.php
CommitLineData
6855525e
JL
1<?php
2/*
3 * Copyright (C) 2003-2004 Polytechnique.org
4 * http://opensource.polytechnique.org/
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21require_once 'diogenes.icons.inc.php';
22
23/** This class describes a Barrel File.
24 */
25class Diogenes_Barrel_File
26{
27 /** The Page this File belongs to */
28 var $page;
29
30 /** File properties */
31 var $props = array();
32
33 /** Constructs a new File.
34 *
35 * @param $page
36 * @param $file
37 */
38 function Diogenes_Barrel_File(&$page, $file)
39 {
40 if (!is_object($page))
41 {
42 trigger_error("\$page is not an object!", E_USER_ERROR);
43 }
44
45 $this->page =& $page;
46 $this->props = array(
47 'file' => $file
48 );
49
50 /*
51 if (is_array($props))
52 {
53 foreach (array_keys($props) as $key)
54 {
55 $this->props[$key] = $props[$key];
56 }
57 }*/
58 }
59
60
61 /** Delete a file (not implemented)
62 *
63 * @param $barrel
64 * @param $dir
65 */
66 function delete(&$barrel, $dir)
67 {
68 global $globals;
69
70 }
71
72
73 /** Return the list of action applicable to the file
74 *
75 * @param $canedit
76 */
77 function make_actions($canedit)
78 {
79 global $globals;
80
81 $dir = $this->page->props['PID'];
82 $file = $this->props['file'];
83
84 $rev = "files?action=revs&amp;dir=$dir&amp;target=$file";
85 $edit = "edit?dir=$dir&amp;file=$file";
86 $del = "javascript:file_delete('$dir','$file');";
87 $rename = "javascript:file_rename('$dir','$file');";
88 $view = "../". $this->page->getLocation($file);
89
90 $actions = array();
91 if ($view) array_push($actions, array(__("view"), $view, "view"));
92 if ($edit && $canedit) array_push($actions, array(__("edit"), $edit, "edit"));
93 if ($rev) array_push($actions, array(__("revisions"),$rev, "revisions"));
94 if ($rename && $canedit) array_push($actions, array(__("rename"), $rename, "rename"));
95 if ($del && $canedit) array_push($actions, array(__("delete"), $del, "delete"));
96
97 return $globals->icons->get_action_icons($actions);
98 }
99
100
101 /** Build the 'File' toolbar
102 *
103 * @param $canedit
104 */
105 function make_toolbar($canedit)
106 {
107 $dir = $this->page->props['PID'];
108 $file = $this->props['file'];
109 global $afile;
110
111 $filebar = array ();
112 if ($canedit)
113 {
114 array_push($filebar, array( __("raw editor"), ($afile == "edit") ? "" : "edit?dir=$dir&amp;file=$file"));
115 array_push($filebar, array( __("HTML editor"), ($afile == "compose") ? "" : "compose?dir=$dir&amp;file=$file"));
116 }
117 array_push($filebar, array( __("file revisions"), "files?action=revs&amp;dir=$dir&amp;target=$file"));
118
119 return $filebar;
120 }
121
122}
123
124?>