From 820fa24b2cc7cd677f9e392f5834e69bc3e46dc5 Mon Sep 17 00:00:00 2001 From: andi Date: Fri, 11 Mar 2005 15:56:11 +0100 Subject: more template additions - media selection works again darcs-hash:20050311145611-9977f-6a2987fbe10ba90cf279a3874d8d7510e63294b5.gz --- inc/html.php | 3 +- inc/template.php | 83 +++++++++++++++++++++++++++++++++++ media.php | 116 +++++++++---------------------------------------- tpl/default/design.css | 5 +++ tpl/default/media.php | 62 ++++++++++++++++++++++++++ 5 files changed, 172 insertions(+), 97 deletions(-) create mode 100644 tpl/default/media.php diff --git a/inc/html.php b/inc/html.php index 85e3189ea..df3f446b5 100644 --- a/inc/html.php +++ b/inc/html.php @@ -293,6 +293,7 @@ function html_btn($name,$id,$akey,$params,$method='get'){ /** * Check for the given permission or prints an error * + * @deprecated * @author Andreas Gohr */ function html_acl($perm){ @@ -596,7 +597,7 @@ function html_search(){ print ''; } }else{ - print '
'.$lang['nothingfound'].'
'; + print '
'.$lang['nothingfound'].'
'; } //hide progressbar diff --git a/inc/template.php b/inc/template.php index 233ded96b..d52d5c7a0 100644 --- a/inc/template.php +++ b/inc/template.php @@ -96,6 +96,9 @@ function tpl_content(){ case 'register': html_register(); break; + case 'denied': + print parsedLocale('denied'); + break; default: msg("Failed to handle command: ".hsc($ACT),-1); } @@ -307,4 +310,84 @@ function tpl_pageinfo(){ } } +/** + * Print a list of namespaces containing media files + * + * @author Andreas Gohr + */ +function tpl_medianamespaces(){ + global $conf; + + $data = array(); + search($data,$conf['mediadir'],'search_namespaces',array()); + print html_buildlist($data,'idx',media_html_list_namespaces); +} + +/** + * Print a list of mediafiles in the current namespace + * + * @author Andreas Gohr + */ +function tpl_mediafilelist(){ + global $conf; + global $lang; + global $NS; + $dir = utf8_encodeFN(str_replace(':','/',$NS)); + + $data = array(); + search($data,$conf['mediadir'],'search_media',array(),$dir); + + if(!count($data)){ + ptln('
'.$lang['nothingfound'].'
'); + return; + } + + ptln('
    ',2); + foreach($data as $item){ + ptln('
  • ',4); + ptln(''. + utf8_decodeFN($item['file']). + '',6); + if($item['isimg']){ + ptln('('.$item['info'][0].'×'.$item['info'][1]. + ' '.filesize_h($item['size']).')
    ',6); + + # build thumbnail + $link=array(); + $link['name']=$item['id']; + if($item['info'][0]>120) $link['name'] .= '?120'; + $link = format_link_media($link); + ptln($link['name'],6); + + }else{ + ptln ('('.filesize_h($item['size']).')',6); + } + ptln('
  • ',4); + } + ptln('
',2); +} + +/** + * Print the media upload form if permissions are correct + * + * @author Andreas Gohr + */ +function tpl_mediauploadform(){ + global $NS; + global $UPLOADOK; + global $lang; + + if(!$UPLOADOK) return; + + ptln('
',2); + ptln($lang['txt_upload'].':
',4); + ptln('',4); + ptln('
',4); + ptln($lang['txt_filename'].'
',4); + ptln('',4); + ptln('',4); + ptln('
',2); +} + ?> 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(); -?> - - -

- -
-
- -
-
- -
-
+ //start output and load template + header('Content-Type: text/html; charset=utf-8'); + include(DOKU_INC.'tpl/'.$conf['template'].'/media.php'); - - - + */ 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; -?> -
-
- :
- -
- :
- - -
-
-'.$lang['mediafiles'].''; - print ' '.$ns.':'; - - $data = array(); - search($data,$conf['mediadir'],'search_media',array(),$dir); - - if(!count($data)){ - print '
'; - print $lang['nothingfound']; - print '
'; - return; - } - - print '
    '; - foreach($data as $item){ - print '
  • '; - print ''; - print utf8_decodeFN($item['file']); - print ''; - if($item['isimg']){ - print ' ('.$item['info'][0].'×'.$item['info'][1]; - print ' '.filesize_h($item['size']).')
    '; - - # 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 '
  • '; - } - print '
'; -} - -function media_html_namespaces(){ - global $conf; - global $lang; - - $data = array(); - #add default namespace - print ''.$lang['namespaces'].''; - 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 + */ function media_html_list_namespaces($item){ $ret = ''; $ret .= ''; diff --git a/tpl/default/design.css b/tpl/default/design.css index 2a428a1e5..2bf7903ea 100644 --- a/tpl/default/design.css +++ b/tpl/default/design.css @@ -42,6 +42,11 @@ hr { height: 0px; } +div.nothing { + text-align:center; + margin: 2em; +} + /* ---------------- forms ------------------------ */ form { diff --git a/tpl/default/media.php b/tpl/default/media.php new file mode 100644 index 000000000..6509bdb5a --- /dev/null +++ b/tpl/default/media.php @@ -0,0 +1,62 @@ + + + */ +?> + + + <?=hsc($lang['mediaselect'])?> [<?=hsc($conf['title'])?>] + + + + + + + + + + + + +
+ + +

+ +
+ +
+ + + +
+ +
+ Available files in : + + + +
+ +
+
+ +
+ +
+ -- cgit v1.2.3