03b8e86bb947f97830aec92fda8a3ccb5e144e7c
3 * Copyright (C) 2003-2004 Polytechnique.org
4 * http://opensource.polytechnique.org/
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.
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.
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
22 /** This class describes a Barrel File.
24 class Diogenes_Barrel_File
26 /** The Page this File belongs to */
29 /** File properties */
32 /** Constructs a new File.
37 function Diogenes_Barrel_File(&$page, $file)
39 if (!is_object($page))
41 trigger_error("\$page is not an object!", E_USER_ERROR
);
52 foreach (array_keys($props) as $key)
54 $this->props[$key] = $props[$key];
60 /** Delete a file (not implemented)
65 function delete(&$barrel, $dir)
72 /** Return the list of action applicable to the file
76 function make_actions($canedit)
80 $dir = $this->page
->props
['PID'];
81 $file = $this->props
['file'];
83 $rev = "files?action=revs&dir=$dir&target=$file";
84 $edit = "edit?dir=$dir&file=$file";
85 $del = "javascript:file_delete('$dir','$file');";
86 $rename = "javascript:file_rename('$dir','$file');";
87 $view = "../". $this->page
->getLocation($file);
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"));
96 return $globals->icons
->get_action_icons($actions);
100 /** Build the 'File' toolbar
104 function make_toolbar($canedit)
106 $dir = $this->page
->props
['PID'];
107 $file = $this->props
['file'];
113 array_push($filebar, array( __("raw editor"), ($afile == "edit") ?
"" : "edit?dir=$dir&file=$file"));
114 array_push($filebar, array( __("HTML editor"), ($afile == "compose") ?
"" : "compose?dir=$dir&file=$file"));
116 array_push($filebar, array( __("file revisions"), "files?action=revs&dir=$dir&target=$file"));