diff options
author | Andreas Gohr <gohr@cosmocode.de> | 2009-09-21 11:55:32 +0200 |
---|---|---|
committer | Andreas Gohr <gohr@cosmocode.de> | 2009-09-21 11:55:32 +0200 |
commit | 56fe6664b115c2f694611299b7ee94a836f2aa52 (patch) | |
tree | 2fbea8a9c6bb386d287260d27bd2b45b64e9ba83 | |
parent | c9f568299c0bb7d6aa8d9ce127c53db6bb38e8aa (diff) | |
download | rpg-56fe6664b115c2f694611299b7ee94a836f2aa52.tar.gz rpg-56fe6664b115c2f694611299b7ee94a836f2aa52.tar.bz2 |
media file name search completed
Ignore-this: c04f76bbe3d6817e876e721e4fcf7252
Note: development is part of ICKE 2.0 project
http://www.icke-projekt.de
darcs-hash:20090921095532-6e07b-bcf49154135c393a42352190dd929ddea3de3a29.gz
-rw-r--r-- | inc/lang/en/lang.php | 4 | ||||
-rw-r--r-- | inc/media.php | 86 |
2 files changed, 34 insertions, 56 deletions
diff --git a/inc/lang/en/lang.php b/inc/lang/en/lang.php index 121b0fec2..b43aa0e54 100644 --- a/inc/lang/en/lang.php +++ b/inc/lang/en/lang.php @@ -94,8 +94,8 @@ $lang['resendpwdsuccess'] = 'Your new password has been sent by email.'; $lang['license'] = 'Except where otherwise noted, content on this wiki is licensed under the following license:'; $lang['licenseok'] = 'Note: By editing this page you agree to license your content under the following license:'; -$lang['txt_searchmediakey'] = 'Search for file'; -$lang['txt_searchrelative'] = 'Only search in namespace :%s'; +$lang['searchmedia'] = 'Search file name:'; +$lang['searchmedia_in'] = 'Search in %s'; $lang['txt_upload'] = 'Select file to upload'; $lang['txt_filename'] = 'Upload as (optional)'; $lang['txt_overwrt'] = 'Overwrite existing file'; diff --git a/inc/media.php b/inc/media.php index ec6548179..f1b6ea62e 100644 --- a/inc/media.php +++ b/inc/media.php @@ -440,25 +440,20 @@ function media_filelist($ns,$auth=null,$jump=''){ if($auth < AUTH_READ){ // FIXME: print permission warning here instead? echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.NL; - return; - } - - media_uploadform($ns, $auth); - - $dir = utf8_encodeFN(str_replace(':','/',$ns)); - $data = array(); - search($data,$conf['mediadir'],'search_media', - array('showmsg'=>true,'depth'=>1),$dir); + }else{ + media_uploadform($ns, $auth); - if(!count($data)){ - echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.NL; - return; - } + $dir = utf8_encodeFN(str_replace(':','/',$ns)); + $data = array(); + search($data,$conf['mediadir'],'search_media', + array('showmsg'=>true,'depth'=>1),$dir); - foreach($data as $item){ - media_printfile($item,$auth,$jump); + if(!count($data)){ + echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.NL; + }else foreach($data as $item){ + media_printfile($item,$auth,$jump); + } } - media_searchform($ns); } @@ -474,44 +469,33 @@ function media_searchlist($query,$ns,$auth=null){ global $lang; $ns = cleanID($ns); - // check auth our self if not given (needed for ajax calls) - if(is_null($auth)) $auth = auth_quickaclcheck("$ns:*"); - - echo '<h1 id="media__ns">Search</h1>'.NL; - - if($auth < AUTH_READ){ - // FIXME: print permission warning here instead? - echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.NL; - return; - } - - media_searchform($ns,$query); - if ($query) { - - if (isset($_REQUEST['key_relative'])) { - $dir = utf8_encodeFN(str_replace(':','/',$ns)); - } else { - $dir = ''; - } - - $data = array(); - $evt = new Doku_Event('MEDIA_SEARCH', $dir); + $evdata = array( + 'ns' => $ns, + 'data' => array(), + 'query' => $query + ); + $evt = new Doku_Event('MEDIA_SEARCH', $evdata); if ($evt->advise_before()) { - $pattern = '#'.preg_quote($query,'#').'#'; - search($data,$conf['mediadir'],'search_media', array('showmsg'=>false,'pattern'=>$pattern),$dir); + $dir = utf8_encodeFN(str_replace(':','/',$evdata['ns'])); + $pattern = '/'.preg_quote($evdata['query'],'/').'/i'; + search($evdata['data'], + $conf['mediadir'], + 'search_media', + array('showmsg'=>false,'pattern'=>$pattern), + $dir); } $evt->advise_after(); unset($evt); + } - if(!count($data)){ - echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.NL; - return; - } + echo '<h1 id="media__ns">'.sprintf($lang['searchmedia_in'],hsc($ns).':*').'</h1>'.NL; + media_searchform($ns,$query); - foreach($data as $item){ - media_printfile($item,$auth,'',$display_namespace=true); - } + if(!count($evdata['data'])){ + echo '<div class="nothing">'.$lang['nothingfound'].'</div>'.NL; + }else foreach($evdata['data'] as $item){ + media_printfile($item,$item['perm'],'',true); } } @@ -736,15 +720,9 @@ function media_searchform($ns,$query=''){ $form->addHidden('ns', $ns); $form->addHidden('do', 'searchlist'); $form->addElement(form_makeOpenTag('p')); - $form->addElement(form_makeTextField('q', $query, $lang['txt_searchmediakey'].':', 'searchmedia__key')); + $form->addElement(form_makeTextField('q', $query,$lang['searchmedia'],'','',array('title'=>sprintf($lang['searchmedia_in'],hsc($ns).':*')))); $form->addElement(form_makeButton('submit', '', $lang['btn_search'])); $form->addElement(form_makeCloseTag('p')); - if ($ns) { - $form->addElement(form_makeOpenTag('p')); - $form->addElement(form_makeCheckboxField('key_relative', true, sprintf($lang['txt_searchrelative'], $ns), 'dw__relative', 'check', isset($_REQUEST['key_relative'])?array('checked' => 'checked'):array())); - $form->addElement(form_makeCloseTag('p')); - } - html_form('searchmedia', $form); } |