Release diogenes-0.9.22
[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
6855525e
JL
21
22/** This class describes a Barrel File.
23 */
24class Diogenes_Barrel_File
25{
26 /** The Page this File belongs to */
27 var $page;
28
29 /** File properties */
30 var $props = array();
31
32 /** Constructs a new File.
33 *
34 * @param $page
35 * @param $file
36 */
37 function Diogenes_Barrel_File(&$page, $file)
38 {
39 if (!is_object($page))
40 {
41 trigger_error("\$page is not an object!", E_USER_ERROR);
42 }
43
44 $this->page =& $page;
45 $this->props = array(
46 'file' => $file
47 );
48
49 /*
50 if (is_array($props))
51 {
52 foreach (array_keys($props) as $key)
53 {
54 $this->props[$key] = $props[$key];
55 }
56 }*/
57 }
58
59
60 /** Delete a file (not implemented)
61 *
62 * @param $barrel
63 * @param $dir
64 */
65 function delete(&$barrel, $dir)
66 {
67 global $globals;
68
69 }
70
71
72 /** Return the list of action applicable to the file
73 *
74 * @param $canedit
75 */
76 function make_actions($canedit)
77 {
78 global $globals;
79
80 $dir = $this->page->props['PID'];
81 $file = $this->props['file'];
82
83 $rev = "files?action=revs&amp;dir=$dir&amp;target=$file";
84 $edit = "edit?dir=$dir&amp;file=$file";
85 $del = "javascript:file_delete('$dir','$file');";
86 $rename = "javascript:file_rename('$dir','$file');";
87 $view = "../". $this->page->getLocation($file);
88
89 $actions = array();
90 if ($view) array_push($actions, array(__("view"), $view, "view"));
91 if ($edit && $canedit) array_push($actions, array(__("edit"), $edit, "edit"));
92 if ($rev) array_push($actions, array(__("revisions"),$rev, "revisions"));
93 if ($rename && $canedit) array_push($actions, array(__("rename"), $rename, "rename"));
94 if ($del && $canedit) array_push($actions, array(__("delete"), $del, "delete"));
95
96 return $globals->icons->get_action_icons($actions);
97 }
98
99
100 /** Build the 'File' toolbar
101 *
102 * @param $canedit
103 */
104 function make_toolbar($canedit)
105 {
106 $dir = $this->page->props['PID'];
107 $file = $this->props['file'];
108 global $afile;
109
110 $filebar = array ();
111 if ($canedit)
112 {
113 array_push($filebar, array( __("raw editor"), ($afile == "edit") ? "" : "edit?dir=$dir&amp;file=$file"));
114 array_push($filebar, array( __("HTML editor"), ($afile == "compose") ? "" : "compose?dir=$dir&amp;file=$file"));
115 }
116 array_push($filebar, array( __("file revisions"), "files?action=revs&amp;dir=$dir&amp;target=$file"));
117
118 return $filebar;
119 }
120
121}
122
123?>