Index: admin/media.php
===================================================================
--- admin/media.php	(revision 3094)
+++ admin/media.php	(revision 3099)
@@ -56,4 +56,7 @@
 }
 
+# Get query in any
+$q = isset($_REQUEST['q']) ? $_REQUEST['q'] : null;
+
 # Sort combo
 $sort_combo = array(
@@ -82,4 +85,7 @@
 	$page_url_params['plugin_id'] = $plugin_id;
 }
+if ($q) {
+	$page_url_params['q'] = $q;
+}
 
 $core->callBehavior('adminMediaURLParams',$page_url_params);
@@ -100,6 +106,15 @@
 		$core->media->setFileSort($file_sort);
 	}
-	$core->media->chdir($d);
-	$core->media->getDir();
+	$query = false;
+	if ($q) {
+		$query = $core->media->searchMedia($q);
+	}
+	if (!$query) {
+		$core->media->chdir($d);
+		$core->media->getDir();
+	} else {
+		$d = null;
+		$core->media->chdir($d);
+	}
 	$core_media_writable = $core->media->writable();
 	$dir =& $core->media->dir;
@@ -170,5 +185,5 @@
 				'name' => $upfile['name'],
 				'size' => $upfile['size'],
-				'html' => mediaItemLine($core->media->getFile($new_file_id), 1)
+				'html' => mediaItemLine($core->media->getFile($new_file_id),1,$query)
 			);
 		} catch (Exception $e) {
@@ -187,5 +202,5 @@
 			$f_private = (isset($_POST['upfilepriv']) ? $_POST['upfilepriv'] : false);
 
-			$core->media->uploadFile($upfile['tmp_name'], $upfile['name'], $f_title, $f_private);
+			$core->media->uploadFile($upfile['tmp_name'],$upfile['name'],$f_title,$f_private);
 
 			dcPage::addSuccessNotice(__('Files have been successfully uploaded.'));
@@ -273,4 +288,5 @@
 	' &nbsp; <input type="submit" name="rmyes" value="'.__('Yes').'" />'.
 	form::hidden('d',$d).
+	form::hidden('q',$q).
 	$core->adminurl->getHiddenFormFields('admin.media',$page_url_params).
 	$core->formNonce().
@@ -296,31 +312,46 @@
 	);
 } else {
-	$temp_params = $page_url_params;
-	$temp_params['d']='%s';
-	$bc_template = $core->adminurl->get('admin.media',$temp_params,'&amp;',true);
-	$breadcrumb_media = $core->media->breadCrumb($bc_template,'<span class="page-title">%s</span>');
-	if ($breadcrumb_media == '') {
+	if ($query || (!$query && $q)) {
+		$count = $query ? count($dir['files']) : 0;
+		$home_params = $page_url_params;
+		$home_params['d']='';
+		$home_params['q']='';
 		$breadcrumb = dcPage::breadcrumb(
 			array(
 				html::escapeHTML($core->blog->name) => '',
-				__('Media manager') => ''
+				__('Media manager') => $core->adminurl->get('admin.media',$home_params),
+				__('Search:').' '.$q.' ('.sprintf(__('%s file found','%s files found',$count),$count).')' => ''
 			),
 			array('home_link' => !$popup)
 		);
 	} else {
-		$home_params = $page_url_params;
-		$home_params['d']='';
-
-		$breadcrumb = dcPage::breadcrumb(
-			array(
-				html::escapeHTML($core->blog->name) => '',
-				__('Media manager') => $core->adminurl->get('admin.media',$home_params),
-				$breadcrumb_media => ''
-			),
-			array(
-				'home_link' => !$popup,
-				'hl' => false
-			)
-		);
+		$temp_params = $page_url_params;
+		$temp_params['d']='%s';
+		$bc_template = $core->adminurl->get('admin.media',$temp_params,'&amp;',true);
+		$breadcrumb_media = $core->media->breadCrumb($bc_template,'<span class="page-title">%s</span>');
+		if ($breadcrumb_media == '') {
+			$breadcrumb = dcPage::breadcrumb(
+				array(
+					html::escapeHTML($core->blog->name) => '',
+					__('Media manager') => ''
+				),
+				array('home_link' => !$popup)
+			);
+		} else {
+			$home_params = $page_url_params;
+			$home_params['d']='';
+
+			$breadcrumb = dcPage::breadcrumb(
+				array(
+					html::escapeHTML($core->blog->name) => '',
+					__('Media manager') => $core->adminurl->get('admin.media',$home_params),
+					$breadcrumb_media => ''
+				),
+				array(
+					'home_link' => !$popup,
+					'hl' => false
+				)
+			);
+		}
 	}
 }
@@ -402,5 +433,9 @@
 $fmt_form_media = '<form action="'.$core->adminurl->get("admin.media").'" method="post" id="form-medias">'.
 	'<div class="files-group">%s</div>'.
-	'<p class="hidden">'.$core->formNonce() . form::hidden(array('d'),$d).form::hidden(array('plugin_id'),$plugin_id).'</p>';
+	'<p class="hidden">'.$core->formNonce().
+	form::hidden(array('d'),$d).
+	form::hidden(array('q'),$q).
+	form::hidden(array('plugin_id'),$plugin_id).
+	'</p>';
 
 if (!$popup) {
@@ -426,4 +461,14 @@
 
 	echo
+	'<form action="'.$core->adminurl->get("admin.media").'" method="get" id="search-form">'.
+	'<p><label for="search" class="classic">'.__('Search:').'</label> '.
+	form::field('q',20,255,$q).' '.
+	'<input type="submit" value="'.__('OK').'" />'.' '.
+	'<span class="form-note">'.__('Will search into media filename (including path), title and description').'</span>'.
+	form::hidden(array('popup'),$popup).
+	form::hidden(array('plugin_id'),$plugin_id).
+	form::hidden(array('post_id'),$post_id).
+	'</p>'.
+	'</form>'.
 	'<form action="'.$core->adminurl->get("admin.media").'" method="get" id="filters-form">'.
 	'<p class="two-boxes"><label for="file_sort" class="classic">'.__('Sort files:').'</label> '.
@@ -435,4 +480,5 @@
 	form::hidden(array('plugin_id'),$plugin_id).
 	form::hidden(array('post_id'),$post_id).
+	form::hidden(array('q'),$q).
 	'</p>'.
 	'</form>'.
@@ -444,7 +490,7 @@
 	{
 		if ($items[$i]->d) {
-			$dgroup .= mediaItemLine($items[$i],$j);
+			$dgroup .= mediaItemLine($items[$i],$j,$query);
 		} else {
-			$fgroup .= mediaItemLine($items[$i],$j);
+			$fgroup .= mediaItemLine($items[$i],$j,$query);
 		}
 	}
@@ -466,5 +512,5 @@
 	!(count($items) == 0 || (count($items) == 1 && $items[0]->parent));
 
-if ($core_media_writable || $core_media_archivable) {
+if ((!$query) && ($core_media_writable || $core_media_archivable)) {
 	echo
 	'<div class="vertical-separator">'.
@@ -472,5 +518,5 @@
 }
 
-if ($core_media_writable || $core_media_archivable) {
+if ((!$query) && ($core_media_writable || $core_media_archivable)) {
 	echo
 	'<div class="two-boxes odd">';
@@ -508,5 +554,5 @@
 }
 
-if ($core_media_writable)
+if (!$query && $core_media_writable)
 {
 	echo
@@ -569,9 +615,10 @@
 form::hidden('rmyes',1).form::hidden('d',html::escapeHTML($d)).
 form::hidden(array('plugin_id'),$plugin_id).form::hidden('remove','').
+form::hidden(array('q'),$q).
 $core->formNonce().
 '</div>'.
 '</form>';
 
-if ($core_media_writable || $core_media_archivable) {
+if ((!$query) && ($core_media_writable || $core_media_archivable)) {
 	echo
 	'</div>';
@@ -586,9 +633,10 @@
 
 /* ----------------------------------------------------- */
-function mediaItemLine($f,$i)
+function mediaItemLine($f,$i,$query)
 {
 	global $core, $page_url, $popup, $post_id, $plugin_id,$page_url_params;
 
 	$fname = $f->basename;
+	$file = $query ? $f->relname : $f->basename;
 
 	$class = 'media-item media-col-'.($i%2);
@@ -625,5 +673,5 @@
 	$res =
 	'<div class="'.$class.'"><p><a class="media-icon media-link" href="'.rawurldecode($link).'">'.
-	'<img src="'.$f->media_icon.'" alt="" />'.$fname.'</a></p>';
+	'<img src="'.$f->media_icon.'" alt="" />'.($query ? $file : $fname).'</a></p>';
 
 	$lst = '';
@@ -657,9 +705,12 @@
 	if ($f->del) {
 		if (!$popup && !$f->d) {
-			$act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($f->basename)),rawurlencode($f->basename));
+			$act .= form::checkbox(array('medias[]', 'media_'.rawurlencode($file)),$file);
 		} else {
 			$act .= '<a class="media-remove" '.
-			'href="'.html::escapeURL($page_url).'&amp;plugin_id='.$plugin_id.'&amp;d='.
-			rawurlencode($GLOBALS['d']).'&amp;remove='.rawurlencode($f->basename).'">'.
+			'href="'.html::escapeURL($page_url).
+			'&amp;plugin_id='.$plugin_id.
+			'&amp;d='.rawurlencode($GLOBALS['d']).
+			'&amp;q='.rawurlencode($GLOBALS['q']).
+			'&amp;remove='.rawurlencode($file).'">'.
 			'<img src="images/trash.png" alt="'.__('Delete').'" title="'.__('delete').'" /></a>';
 		}
Index: inc/core/class.dc.media.php
===================================================================
--- inc/core/class.dc.media.php	(revision 2768)
+++ inc/core/class.dc.media.php	(revision 3099)
@@ -368,5 +368,4 @@
 				return strcasecmp($a->basename,$b->basename);
 		}
-
 	}
 
@@ -520,4 +519,55 @@
 
 	/**
+	Search into media db (only).
+
+	@param	query		<b>string</b>		Search query
+	@return boolean 	true or false if nothing found
+	*/
+	public function searchMedia($query)
+	{
+		if ($query == '') {
+			return false;
+		}
+
+		$strReq =
+		'SELECT media_file, media_id, media_path, media_title, media_meta, media_dt, '.
+		'media_creadt, media_upddt, media_private, user_id '.
+		'FROM '.$this->table.' '.
+		"WHERE media_path = '".$this->path."' ".
+		"AND (media_title LIKE '%".$this->con->escape($query)."%' ".
+		"	OR media_file LIKE '%".$this->con->escape($query)."%' ".
+		"	OR media_meta LIKE '<Description>%".$this->con->escape($query)."%</Description>')";
+
+		if (!$this->core->auth->check('media_admin',$this->core->blog->id))
+		{
+			$strReq .= 'AND (media_private <> 1 ';
+
+			if ($this->core->auth->userID()) {
+				$strReq .= "OR user_id = '".$this->con->escape($this->core->auth->userID())."'";
+			}
+			$strReq .= ') ';
+		}
+
+		$rs = $this->con->select($strReq);
+
+		$this->dir = array('dirs' => array(),'files' => array());
+		$f_res = array();
+		while ($rs->fetch())
+		{
+			$fr = $this->fileRecord($rs);
+			if ($fr) {
+				$f_res[] = $fr;
+			}
+		}
+		$this->dir['files'] = $f_res;
+
+		try {
+			usort($this->dir['files'],array($this,'sortFileHandler'));
+		} catch (Exception $e) {}
+
+		return (count($f_res) > 0 ? true : false);
+	}
+
+	/**
 	Returns media items attached to a blog post. Result is an array containing
 	fileItems objects.
Index: locales/fr/main.po
===================================================================
--- locales/fr/main.po	(revision 3094)
+++ locales/fr/main.po	(revision 3099)
@@ -1488,4 +1488,13 @@
 msgstr "Les réglages actuels pour les médias et les images sont définis dans les %s"
 
+#, php-format
+msgid "%s file found"
+msgid_plural "%s files found"
+msgstr[0] "%s fichier trouvé"
+msgstr[1] "%s fichiers trouvés"
+
+msgid "Will search into media filename (including path), title and description"
+msgstr "Recherche parmi les noms des fichiers (incluant leur chemin), les titres et descriptions"
+
 msgid "Blog parameters"
 msgstr "Paramètres du blog"
