2 require_once 'diogenes.common.inc.php';
3 require_once 'diogenes.admin.inc.php';
4 require_once 'Barrel.php';
5 require_once 'Barrel/Page.php';
7 $page = new DiogenesAdmin
;
8 $bbarrel =& $page->barrel
;
11 $rcs = $page->getRcs();
14 $page->assign('msg_submit',__("Submit"));
15 $page->assign('msg_reset',__("Reset"));
16 $page->assign('msg_properties',__("Page properties"));
17 $page->assign('msg_parent',__("parent page"));
18 $page->assign('msg_location',__("location"));
19 $page->assign('msg_title',__("title"));
20 $page->assign('msg_page_template',__("page template"));
21 $page->assign('msg_status',__("status"));
22 $page->assign('msg_access',__("access"));
23 $page->assign('msg_read_perms',__("read access"));
24 $page->assign('msg_write_perms',__("write access"));
25 $page->assign('msg_actions',__("actions"));
26 $page->assign('msg_add_page', array(__("Add a page"),"?action=edit") );
28 $page->assign('post', $page->script_self());
29 $page->assign('table', $bbarrel->table_page
);
31 $action = isset($_REQUEST["action"]) ?
$_REQUEST["action"] : "";
32 $target = isset($_REQUEST["target"]) ?
$_REQUEST["target"] : "";
34 if (isset($_REQUEST["dir"])) {
35 $dir = $_REQUEST["dir"];
36 if (!$action) $action="edit";
42 /* add or update a page */
46 // if needed, import a file
47 if ($globals->word_import
&& isset($_FILES['wordfile']) && is_uploaded_file($_FILES['wordfile']['tmp_name'])) {
48 $userfile = strtolower($_FILES['wordfile']['name']);
49 if (!substr($userfile,-4,4) == ".doc") {
50 $page->info(__("Document name does not end in .doc"));
52 $mydir = $bbarrel->spool
->spoolPath($dir);
53 $page->info(__("Checking in Word file") . " $userfile");
54 $rcs->commit($dir, $globals->wordfile
,
55 file_get_contents($_FILES['wordfile']['tmp_name']),
56 "Word file update $userfile" );
58 $page->info(__("Importing Word file") . " $userfile");
59 $rcs->importWordFile($dir, $globals->htmlfile
, $_FILES['wordfile']['tmp_name']);
61 } else if (isset($_FILES['htmlfile']) && is_uploaded_file($_FILES['htmlfile']['tmp_name'])) {
62 $userfile = strtolower($_FILES['htmlfile']['name']);
63 if ( (substr($userfile,-4,4) == ".htm") ||
(substr($userfile,-5,5) == ".html") ) {
64 $page->info(__("Importing HTML file") . " $userfile");
65 $rcs->commit( $dir, $globals->htmlfile
,
66 $rcs->importHtmlString(file_get_contents($_FILES['htmlfile']['tmp_name'])),
67 "html file import of $userfile" );
69 $page->info(__("Raw file import") . " $userfile");
70 $rcs->commit( $dir, $globals->htmlfile
,
71 file_get_contents($_FILES['htmlfile']['tmp_name']),
72 "raw file import of $userfile" );
82 if (isset($_REQUEST['pedit_location'])) {
84 $props['location'] = $_REQUEST['pedit_' . 'location'];
87 $props['location'] = '';
91 $kprops = array('parent', 'title', 'perms', 'wperms', 'status', 'template');
92 foreach ($kprops as $key) {
93 $props[$key] = $_REQUEST['pedit_' . $key];
96 $bpage = new Diogenes_Barrel_Page($bbarrel, $props);
97 $bpage->toDb($homepage, $page);
102 Diogenes_Barrel_Page
::delete($bbarrel, $target, $page);
106 // retrieve all the barrel's page
107 $bpages = $bbarrel->getPages();
112 $bpage = Diogenes_Barrel_Page
::fromDb($bbarrel, $dir);
114 $tparent = empty($_REQUEST['parent']) ?
$bbarrel->getPID('') : $_REQUEST['parent'];
115 //$page->info("parent $tparent");
116 $bpage = new Diogenes_Barrel_Page($bbarrel, array('parent' => $tparent));
120 //if (isset($bpage->props['PID'])) {
122 $page->toolbar(__("Page"), $bpage->make_toolbar());
123 $page->toolbar(__("File"), $bpage->make_doc_toolbar($rcs));
126 // retrieve suitable parents for the current page
127 if (!$bpage->props
['PID'] ||
strlen($bpage->props
['location']))
129 $parent_all = array();
130 foreach($bpages as $pkey => $pval)
132 if (!$dir or (($pval->props
['PID'] != $dir) and ($pval->props
['parent'] != $dir)))
134 $parent_all[$pkey] = $pval;
138 $parent_opts = array();
139 foreach (array_keys($parent_all) as $pkey)
141 $ppage = $parent_all[$pkey];
142 if (!$ppage->props
['parent'] or isset($parent_all[$ppage->props
['parent']]))
144 $pageloc = $bbarrel->getLocation($pkey);
145 $parent_opts[$pkey] = ( strlen($pageloc) ?
"<$pageloc> " : "") . $ppage->props
['title'];
148 $page->assign('parent_opts', $parent_opts);
155 $gtitle = $bbarrel->getLocation($dir);
156 if (!$gtitle) $gtitle = __("home");
158 $page->assign('greeting',__("Page manager") . ($gtitle ?
" - $gtitle" : "") );
160 $page->assign('html',__("Import HTML"));
161 $page->assign('htmlblab',__("You can replace the current page's contents by uploading an HTML file below."));
162 $page->assign('htmlstrip',__("If the file name ends with .htm or .html, anything outside the <body></body> pair will be stripped."));
163 $page->assign('send',__("Send"));
165 $page->assign('dir',$dir);
166 $page->assign('page_obj', $bpage->props
);
167 $page->assign('status_opts',array(0=>__("visible"), 1=>__("under construction"), 2=>__("disabled"), 3=>__("archived")));
168 $page->assign('templates',$page->getTemplates());
170 if ($globals->word_import
) {
172 $page->assign('word',__("Import a Word document"));
174 if (file_exists($bbarrel->spool
->spoolPath($dir,$globals->wordfile
)) )
176 $page->assign('wordblab', __("This page's master document is currently a Word document."));
177 $page->assign('wordsend', __("You can upload a new version of the Word document below."));
178 $page->assign('wordfile', __("You can get the current version of the file here"));
179 $page->assign('wordlnk', array($globals->wordfile
,$page->urlSite((strlen($bpage->props
['location']) ?
$bpage->props
['location'].'/' : '') . $globals->wordfile
)) );
181 $page->assign('wordblab', __("If you wish, you can set this page's content from a Word document."));
182 $page->assign('wordsend', __("To do so, simply upload the Word document below."));
186 $page->display('page-properties.tpl');