summaryrefslogtreecommitdiff
path: root/media.php
diff options
context:
space:
mode:
Diffstat (limited to 'media.php')
-rw-r--r--media.php116
1 files changed, 20 insertions, 96 deletions
diff --git a/media.php b/media.php
index 7d67f971e..10e0b36b9 100644
--- a/media.php
+++ b/media.php
@@ -7,6 +7,7 @@
require_once(DOKU_INC.'inc/html.php');
require_once(DOKU_INC.'inc/search.php');
require_once(DOKU_INC.'inc/format.php');
+ require_once(DOKU_INC.'inc/template.php');
require_once(DOKU_INC.'inc/auth.php');
header('Content-Type: text/html; charset='.$lang['encoding']);
@@ -14,48 +15,34 @@
$NS = $_REQUEST['ns'];
$NS = cleanID($NS);
+ //check upload permissions
if(auth_quickaclcheck("$NS:*") >= AUTH_UPLOAD){
- $uploadok = true;
+ $UPLOADOK = true;
//create the given namespace (just for beautification)
$mdir = $conf['mediadir'].'/'.utf8_encodeFN(str_replace(':','/',$NS));
io_makeFileDir("$mdir/xxx");
}else{
- $uploadok = false;
+ $UPLOADOK = false;
}
- if($_FILES['upload']['tmp_name'] && $uploadok){
+ if($_FILES['upload']['tmp_name'] && $UPLOADOK){
media_upload($NS);
}
- //start output
- html_head();
-?>
-<body>
- <?html_msgarea()?>
- <h1><?=$lang['mediaselect']?></h1>
-
- <div class="mediaselect">
- <div class="mediaselect-left">
- <?=media_html_namespaces()?>
- </div>
- <div class="mediaselect-right">
- <?
- print media_html_media($NS);
- if($uploadok){
- print media_html_uploadform($NS);
- }
- ?>
- </div>
- </div>
+ //start output and load template
+ header('Content-Type: text/html; charset=utf-8');
+ include(DOKU_INC.'tpl/'.$conf['template'].'/media.php');
-</body>
-</html>
-<?
//restore old umask
umask($conf['oldumask']);
/**********************************************/
+/**
+ * Handles Mediafile uploads
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
function media_upload($NS){
global $conf;
global $lang;
@@ -86,76 +73,13 @@ function media_upload($NS){
return false;
}
-function media_html_uploadform($ns){
- global $lang;
-?>
- <div class="uploadform">
- <form action="<?=$_SERVER['PHP_SELF']?>" name="upload" method="post" enctype="multipart/form-data">
- <?=$lang['txt_upload']?>:<br />
- <input type="file" name="upload" class="edit" onchange="suggestWikiname();" />
- <input type="hidden" name="ns" value="<?=htmlspecialchars($ns)?>" /><br />
- <?=$lang['txt_filename']?>:<br />
- <input type="text" name="id" class="edit" />
- <input type="submit" class="button" value="<?=$lang['btn_upload']?>" accesskey="s" />
- </form>
- </div>
-<?
-}
-
-function media_html_media($ns){
- global $conf;
- global $lang;
- $dir = utf8_encodeFN(str_replace(':','/',$ns));
-
- print '<b>'.$lang['mediafiles'].'</b>';
- print ' <code>'.$ns.':</code>';
-
- $data = array();
- search($data,$conf['mediadir'],'search_media',array(),$dir);
-
- if(!count($data)){
- print '<div style="text-align:center; margin:2em;">';
- print $lang['nothingfound'];
- print '</div>';
- return;
- }
-
- print '<ul>';
- foreach($data as $item){
- print '<li>';
- print '<a href="javascript:mediaSelect(\''.$item['id'].'\')">';
- print utf8_decodeFN($item['file']);
- print '</a>';
- if($item['isimg']){
- print ' ('.$item['info'][0].'&#215;'.$item['info'][1];
- print ' '.filesize_h($item['size']).')<br />';
-
- # build thumbnail
- $link=array();
- $link['name']=$item['id'];
- if($item['info'][0]>120) $link['name'] .= '?120';
- $link = format_link_media($link);
- print $link['name'];
-
- }else{
- print ' ('.filesize_h($item['size']).')';
- }
- print '</li>';
- }
- print '</ul>';
-}
-
-function media_html_namespaces(){
- global $conf;
- global $lang;
-
- $data = array();
- #add default namespace
- print '<b><a href="'.DOKU_BASE.'media.php?ns=">'.$lang['namespaces'].'</a></b>';
- search($data,$conf['mediadir'],'search_namespaces',array());
- print html_buildlist($data,'idx',media_html_list_namespaces);
-}
-
+/**
+ * Userfunction for html_buildlist
+ *
+ * Prints available media namespaces
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
function media_html_list_namespaces($item){
$ret = '';
$ret .= '<a href="'.DOKU_BASE.'media.php?ns='.idfilter($item['id']).'" class="idx_dir">';