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
21 require_once 'diogenes.icons.inc.php';
23 /** This class describes a Barrel File.
25 class Diogenes_Barrel_File
27 /** The Page this File belongs to */
30 /** File properties */
33 /** Constructs a new File.
38 function Diogenes_Barrel_File(&$page, $file)
40 if (!is_object($page))
42 trigger_error("\$page is not an object!", E_USER_ERROR
);
53 foreach (array_keys($props) as $key)
55 $this->props[$key] = $props[$key];
61 /** Delete a file (not implemented)
66 function delete(&$barrel, $dir)
73 /** Return the list of action applicable to the file
77 function make_actions($canedit)
81 $dir = $this->page
->props
['PID'];
82 $file = $this->props
['file'];
84 $rev = "files?action=revs&dir=$dir&target=$file";
85 $edit = "edit?dir=$dir&file=$file";
86 $del = "javascript:file_delete('$dir','$file');";
87 $rename = "javascript:file_rename('$dir','$file');";
88 $view = "../". $this->page
->getLocation($file);
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"));
97 return $globals->icons
->get_action_icons($actions);
101 /** Build the 'File' toolbar
105 function make_toolbar($canedit)
107 $dir = $this->page
->props
['PID'];
108 $file = $this->props
['file'];
114 array_push($filebar, array( __("raw editor"), ($afile == "edit") ?
"" : "edit?dir=$dir&file=$file"));
115 array_push($filebar, array( __("HTML editor"), ($afile == "compose") ?
"" : "compose?dir=$dir&file=$file"));
117 array_push($filebar, array( __("file revisions"), "files?action=revs&dir=$dir&target=$file"));