<?php
define( 'WS_WEB', true );
require_once('common/WebInit.php');
require_once('WikiQuery.php');
/*
<Duesentrieb> ok... wenn du'S nochmal probieren willst, hier ist nochmal die URL: http://tools.wikimedia.de/~daniel/foo/MediaSearch.php?wikifam=commons.wikimedia.org
<elian> klar doch :-)
<Duesentrieb> ich denke, ich werde das in den nächsten Tagen offiziell machen.
<elian> hast du zeit für ne kleine idee?
<Duesentrieb> klar, desshalb zeig ich's dir ja
<Duesentrieb> oder meinst du generell?
<elian> okay, dann erst programmreview und dann idee :-)
<elian> *anguck*
<Duesentrieb> hehe, so was das nicht gemeint... aber mach mal :)
<elian> erster tipp: den text unter den bildanzeigen in gleicher schriftgröße
<elian> so wirkt das sehr unruhig und lenkt sehr von den bildvorschaun ab
<elian> genauso die searched in kategorienanzeige oben
<Duesentrieb> gleiche grösse wie was?
<elian> wär's nicht sinnvoller, die commons-links einfach wegzulassen dort?
<Duesentrieb> unten sind nur die gross, die bei der suche berücksichtigt wurden... aber fett reicht auch als hervorhebung, denke ich
<elian> ich benutze doch dein tool, weil das besser ist als deren kategoriebrowser
<Duesentrieb> naja, manchmal will man da schon hin...
<Duesentrieb> du meinst jetzt oben, wo "search" steht, ja?
<elian> ja
<elian> searching in 52 categories: Islamsearch, Hajjsearch, Sufismsearch, Muslimssearch, Islamic f
<elian> das da
<elian> unten sind die links in ordnung, bei den einzelnen bildern
<Duesentrieb> du willst oben nur die search links haben? hm... ok...
<Duesentrieb> und mit der schriftgrösse unten... die Labels sollten auf jeden fall kleiner (Tags, Categories...)
<Duesentrieb> aber die hervorgehobenen Kategorien und Seiten auch?
<elian> ich würd alles in einer schriftgröße machen
<Duesentrieb> alles unterm bild, oder *alles* alles?
<elian> warum sind manche kategorien/tags fett und gross, manche klein?
<Duesentrieb> die hervorgehobenen sind der grund dafür, dass das bild im suchergebnis ist.
<Duesentrieb> d.h. die in diesem Kontext relevanten
<elian> aaah
<Duesentrieb> könnte man natürlich auch mit farbe markieren oder so...
<elian> nee, es reicht, wenn man gleiche größe (klein) und fett im gegensatz zum rest macht
<Duesentrieb> hm, ok
<Duesentrieb> naja, das layout ist im moment eh etwas reudig... das eingabeformular müsste ich nochmal hübsch machen.
<Duesentrieb> wie findest du's den vom Funktionsumfang her? Insbesondere bei der Suche nach Lizenzen hab' ich an dich gedacht :)
<elian> einfach nur geil
<elian> es ist wirklich an alles gedacht
<Duesentrieb> hach, mitten auf den Eitel-Scheitel :)
<elian> csv export
<Duesentrieb> immer
<Duesentrieb> ich *hasse* HTML parsen :)
<elian> eine kleine verfeinerung
<elian> link aufs originalbild
<Duesentrieb> hm?
<Duesentrieb> ach so, du meinst direkt, statt auf die bildbeschreibung?
<elian> entweder zusätzlich oder statt
<Duesentrieb> bei bildern würde ich das bild selbst auf das original linken, die titel auf die beschreibungsseite
<elian> z.b. einen link "download"
<elian> so könnte mans machen
<elian> ja
<Duesentrieb> bei sound, etc, mach ich das eh schon, damit man's gleich abspielen kann.
<elian> perfekt
<Duesentrieb> ist zwar dann nicht konsistent mit den galerien im wiki, aber egal :)
<Duesentrieb> andererseits... wer das bild runterladen will, *soll* sich die beschreibungsseite angucken...
<elian> hm...
<Duesentrieb> aber wer nur mal die volle auflösung will, nicht unbedingt.
<elian> manchmal
<Duesentrieb> naja
<elian> z.b. könnte ich alle als PD getaggten sofort ziehen wollen
<Duesentrieb> mal gucken - danke jedenfalls für dein feedback
<Duesentrieb> naja, *das* machst du eh besser mit 'nem script :)
<elian> idee noch hören?
<Duesentrieb> hm, dafür könnte man die URLs ins CSV packen. Aber es gibt ja jetzt Special:Filepath (oder so), damit geht's auch so
<Duesentrieb> ja, klar :)
<mnh> Wie geb ich denn die Pixel an, als 100x200 oder 20000
<mnh> ?
*/
function getUploadInfo($field, $row) {
global $wq;
$html= '';
$html.= " <small>";
$html.= escapeHtml($row['img_media_type']);
if ($row['img_media_type'] == MEDIATYPE_BITMAP ) $html.= ' ('.escapeHtml($row["img_width"].'x'.$row["img_height"]).")";
$html.= ", ";
$html.= ceil($row["img_size"]/1024)."KB";
$html.= " (";
$u= "CheckUsage.php?i=".urlencode($row["img_name"])."&w=_100000";
$html.= "<i><a href='$u'>usage</a></i>";
$html.= ") ";
$html.= "<br/>";
$html.= $wq->makeDate($row["img_timestamp"]);
$html.= " by ";
$html.= $wq->makeLink($row["img_user_text"], NS_USER, false);
$html.= " (";
$p= "img_user_text=".urlencode($row["img_user_text"])
."&wikifam=".urlencode($wq->wikiSelector->selected)
."&wikilang=".urlencode($wq->wikiSelector->lang);
$u= "Gallery.php?$p";
$html.= "<i><a href='$u'>gallery</a></i>";
$html.= ") ";
$html.= "<br/>";
#if ($row['updated']) $html.= ' <b>(update)</b>';
#else $html.= ' (new)';
$html.= "</small>";
return $html;
}
function getThumbInfo($field, &$row) {
global $wq;
$html= $wq->wiki->getThumbnailHTML($row, NULL, NULL, true);
return $html;
}
function getUsageInfo($field, $row) {
global $wq;
$gals= preg_split('/\|/',$row['pages'],-1,PREG_SPLIT_NO_EMPTY);
$gals= array_unique($gals);
sort($gals);
$cats= preg_split('/\|/',$row['cats'],-1,PREG_SPLIT_NO_EMPTY);
$cats= array_unique($cats);
sort($cats);
$templates= preg_split('/\|/',$row['tags'],-1,PREG_SPLIT_NO_EMPTY);
$templates= array_unique($templates);
sort($templates);
$scats= isset($row['search_cats']) ? explode('|',$row['search_cats']) : array();
$sgals= isset($row['search_pages']) ? explode('|',$row['search_pages']) : array();
$html= '';
if ($gals) {
$html.= 'Articles: ';
$first= true;
foreach ($gals as $t) {
if ($first) $first= false;
else $html.= ', ';
$l= $wq->makeLink($t,NS_MAIN,true);
if ($sgals && in_array($t,$sgals)) $html.= "<b>$l</b>";
else $html.= "<small>$l</small>";
}
}
if ($cats) {
if ($gals) $html.= '<br/>';
$html.= 'Categories: ';
$first= true;
foreach ($cats as $t) {
if ($first) $first= false;
else $html.= ', ';
$l= $wq->makeLink($t,NS_CATEGORY,false);
if ($scats && in_array($t,$scats)) $html.= "<b>$l</b>";
else $html.= "<small>$l</small>";
}
}
if (!$gals && !$cats) {
$html.= '<span class="orphan">orphan!</span>';
$u= "CommonSense.php?i=".urlencode($row['img_name'])."&go-clean=yes";
$html.= "<br/><small><i><a href='$u'>categorize with CommonSense</a></i></small>";
}
if ($templates) {
$html.= '<br/>';
$html.= 'Tags: ';
$c= 0;
$first= true;
foreach ( $templates as $tmpl ) {
if ($first) $first= false;
else $html.= ', ';
if (preg_match('/^:/',$tmpl)) {
$ns= '';
$title= $tmpl;
$showns= false;
}
else {
$l= $wq->wiki->makeLinkEntry($tmpl);
if ($l['namespace']) {
$ns= $l['namespace'];
$title= $l['link'];
$showns= true;
}
else {
$ns= $wq->wiki->getNSText(NS_TEMPLATE);
$title= $tmpl;
$showns= false;
}
}
$lnk= $wq->makeLink($title,$ns,$showns);
if ($wq->wiki->hasTemplateClasses()) {
$cls= $wq->wiki->getTemplateClass($tmpl);
if (!$cls) $cls= 'unknown';
else if ($cls=='license' || $cls=='license-highlite' || $cls=='custom') $c+= 1;
if ($cls) $lnk= "<span class='$cls-tag'>$lnk</span>";
}
else $c+= 1;
$html.= $lnk;
}
#if ($html) $html= 'Templates: '.$html;
if (!$c) {
if ($html) $html.= ', ';
if (!$templates) $html.= '<span class="untagged">untagged!</span>';
else $html.= '<span class="untagged">no license tag!</span>';
}
}
#$u= "CheckUsage.php?i=".urlencode($row["img_name"])."&w=_1000000";
#$html.= "<br/><small><i><a href='$u'>usage in all projects</a></i></small>";
return $html;
}
function getImageInfo($field, $row) {
$html= '';
$html.= '<div style="text-align:center; margin-bottom:1ex; ">';
$html.= getThumbInfo($field, $row);
$html.= '</div>';
$html.= getUploadInfo($field, $row);
$html.= '<br/>';
$html.= getUsageInfo($field, $row);
return $html;
}
function makePageLinks($pages, $ns, $showns = false) {
global $wq;
$s= '';
foreach ($pages as $p) {
if ($s!=='') $s.= ', ';
if (is_array($p)) {
$s.= $wq->makeLink( $p['page_title'], $p['page_namespace'], $showns );
$t= $p['page_title'];
}
else {
$t= $p;
$s.= $wq->makeLink( $p, $ns, $showns );
}
if ($ns==NS_CATEGORY) {
$u= 'MediaSearch.php?category='.urlencode($t).'&'.$wq->getURLParameters('category', true);
$s.= "<sup><a href='$u'>search</a></sup>";
}
}
return $s;
}
$keywords= $wgRequest->getVal('keywords');
$category= $wgRequest->getVal('category');
$catdepth= $wgRequest->getVal('depth', 3);
$minpx= (int)$wgRequest->getVal('minpx');
$maxkb= (int)$wgRequest->getVal('maxkb');
$mimetype= $wgRequest->getVal('mimetype');
$mediatype= $wgRequest->getVal('mediatype');
$uploader= $wgRequest->getVal('uploader');
$noby= $wgRequest->getVal('noby');
$nosa= $wgRequest->getVal('nosa');
$nocopy= $wgRequest->getVal('nocopy');
$nobad= $wgRequest->getVal('nobad');
if (!$minpx) $minpx= '';
if (!$maxkb) $maxkb= '';
if (!$mediatype) $mediatype= 'auto';
$wq= new WikiQuery('MediaSearch', "dummy");
#$wq->setWikiDomain('commons.wikimedia.org');
#$wq->dumpSQL= true;
$wq->getWiki(); #init!
#$wq->chunks= array( 25, 50, 100, 250 );
$wq->defaultOrder= '-img_res';
$wq->columns= 4;
$wq->options['keywords']= true;
$wq->options['category']= true;
$wq->options['depth']= true;
$wq->options['minpx']= true;
$wq->options['maxkb']= true;
$wq->options['mimetype']= true;
$wq->options['mediatype']= true;
$wq->options['noby']= true;
$wq->options['nosa']= true;
$wq->options['nobad']= true;
$wq->options['nocopy']= true;
$wq->options['order']= true; #hack: force order to be preserved
$wq->forceOrder= true;
#$wq->dumpSQL= true;
#$sql= 'SELECT image.*, if( rev_id is null, 0, 1 ) as updated FROM image
# JOIN page ON page_namespace = '.NS_IMAGE.' AND page_title = img_name
# LEFT JOIN revision ON rev_timestamp = img_timestamp AND rev_page = page_id';
#$sql= 'SELECT image.*, if( oi_name is null, 0, 1 ) as updated FROM image
# LEFT JOIN oldimage ON oi_name = img_name
# GROUP BY img_name';
$indexTable= NULL;
$tagTable= NULL;
$keywords_disable= '';
$license_disable= '';
if ($wq->wikiSelector->domain) {
#if ($wsgLicenseTagTables) $tagTable= @$wsgLicenseTagTables[$wq->wikiSelector->domain];
#if (!$tagTable) $license_disable= ' disabled="disabled" ';
if ($wsgMediaIndexTables) $indexTable= @$wsgMediaIndexTables[$wq->wikiSelector->domain];
if (!$indexTable) $keywords_disable= ' disabled="disabled" ';
if ($indexTable && !strpos($indexTable ,'.')) $indexTable= "$wsgAuxWikiDB.$indexTable";
#if ($tagTable && !strpos($tagTable ,'.')) $tagTable= "$wsgAuxWikiDB.$tagTable";
}
$join= '';
$latejoin= '';
$where= array();
$having= array();
$sql= NULL;
$scope= array();
$imgres= "if ( img_media_type = \"".MEDIATYPE_BITMAP."\", img_width * img_height, if ( img_media_type = \"".MEDIATYPE_DRAWING."\", 1000000000, 0 ) ) as img_res";
if ($keywords && !$keywords_disable) {
$join.= " JOIN $indexTable ON img_name = idx_image";
$where[]= 'MATCH (idx_keyword) AGAINST ("'.addslashes($keywords).'" IN BOOLEAN MODE)';
$scope[]= 'keywords "'.escapeHtml($keywords).'"';
}
if ($category && $wq->wiki) {
$scope[]= 'category "'.escapeHtml($category).'"' . ( $catdepth ? " ($catdepth levels deep)" : $depth);
$parents= $wq->wiki->getCategories($category, NS_CATEGORY);
$wq->feedback[]= "<p><small>parent categories: ".makePageLinks($parents, NS_CATEGORY, false)."</small></p>";
$cats= $wq->wiki->getSubcategories($category, $catdepth);
$wq->feedback[]= "<p><small>searching in ".sizeof($cats)." categories: ".makePageLinks($cats, NS_CATEGORY, false)."</small></p>";
$pages= $wq->wiki->listCategories($cats, NS_MAIN);
$wq->feedback[]= "<p><small>searching on ".sizeof($pages)." pages: ".makePageLinks($pages, NS_MAIN, false)."</small></p>";
$cats= $wq->wiki->makeSQLSet($cats, true);
#FIXME: handle redirects!
$sql= "
select U.*, $imgres,
group_concat(distinct p separator '|') as search_pages,
group_concat(distinct c separator '|') as search_cats,
group_concat(distinct GP.page_title separator '|') as pages,
group_concat(distinct cl_to separator '|') as cats,
group_concat(distinct tl_title separator '|') as tags
from (
select image.*, page_title as p, NULL as c
from image
join imagelinks on il_to = img_name
join page on page_id = il_from and page_namespace = ".NS_MAIN."
join categorylinks ON cl_from = page_id
where cl_to in ".$cats."
union
select image.*, NULL as p, cl_to as c
from image
join page on page_title = img_name and page_namespace = ".NS_IMAGE."
join categorylinks ON cl_from = page_id
where cl_to in ".$cats."
) as U
";
}
if ($minpx) {
$where[]= '( img_media_type != "'.MEDIATYPE_BITMAP.'" || img_width >= '.(int)$minpx.' || img_height >= '.(int)$minpx.')';
$scope[]= 'no smaller than '.(int)$minpx.' pixels (for bitmaps)';
}
if ($maxkb) {
$where[]= 'img_size <= "'.($maxkb*1024).'"';
$scope[]= 'no larger than '.(int)$maxkb.'KB';
}
if ($uploader) {
#TODO: check that user exists (avoid typos)
$where[]= 'img_user_text = "'.addslashes($wq->wiki->asDBKey($uploader)).'"';
$scope[]= 'uploaded by '.escapeHtml($uploader);
}
if ($mimetype) {
$mimetype= strtolower(trim($mimetype));
$major= NULL;
$mm=& wfGetMimeMagic();
if (strpos($mimetype,'/')!==false) {
if (isset($mm->mMimeTypeAliases[$mimetype])) $mimetype= $mm->mMimeTypeAliases[$mimetype];
}
else {
$t= $mm->guessTypesForExtension($mimetype);
if ($t) $mimetype= $t;
}
if (strpos($mimetype,'/')!==false && (!$mediatype || $mediatype==='auto')) {
$type= $mm->findMediaType($mimetype);
if ($type && $type!==MEDIATYPE_UNKNOWN) {
$mediatype= $type;
}
}
if (strpos($mimetype,'/')!==false) {
if (isset($wsgMimeOverwrite[$mimetype])) $mimetype= $wsgMimeOverwrite[$mimetype];
$m= explode('/',$mimetype);
$major= trim($m[0]);
$minor= trim($m[1]);
}
else $minor= $mimetype;
if ($major) $where[]= 'img_major_mime = "'.addslashes($major).'"';
if ($minor) $where[]= 'img_minor_mime = "'.addslashes($minor).'"';
$scope[]= 'MIME type '.escapeHtml($mimetype).'';
}
if ($mediatype) {
if ($mediatype=='any') /* noop */;
else if ($mediatype=='auto') /* noop */;
else if ($mediatype=='other') $where[]= 'img_media_type NOT IN ( "'.MEDIATYPE_BITMAP.'", "'.MEDIATYPE_DRAWING.'", "'.MEDIATYPE_AUDIO.'", "'.MEDIATYPE_VIDEO.'" )';
else if ($mediatype=='image') $where[]= 'img_media_type IN ( "'.MEDIATYPE_BITMAP.'", "'.MEDIATYPE_DRAWING.'" )';
else if ($mediatype=='audio') $where[]= 'img_media_type = "'.MEDIATYPE_AUDIO.'"';
else if ($mediatype=='video') $where[]= 'img_media_type = "'.MEDIATYPE_VIDEO.'"';
else $where[]= 'img_media_type = "'.addslashes($mediatype).'"';
if ($mediatype != 'any' && $mediatype != 'auto') $scope[]= 'media type '.escapeHtml($mediatype).'';
}
if ($noby) {
$having[]= ' tags NOT RLIKE "(^|\\\\|)(GFDL([- ][\w\d\.\-]+)?|GPL|LGPL|FAL|CeCILL|BSDu?|Cc-.*|attribution|CopyrightedFreeUseProvided(That)?|Copyrighted_free_use_provided(_that)?)($|\\\\|)" ';
$scope[]= 'excluding files requiering attribution';
}
if ($nosa) {
$having[]= ' tags NOT RLIKE "(^|\\\\|)(GFDL([- ][\w\d\.\-]+)?|GPL|LGPL|FAL|CeCILL|BSDu?|Cc-(by-)?sa(-.*)?|CopyrightedFreeUseProvided(That)?|Copyrighted_free_use_provided(_that)?)($|\\\\|)" ';
$scope[]= 'excluding files under share-alike policy';
}
if ($nocopy) {
$having[]= ' tags NOT RLIKE "(^|\\\\|)(GFDL([- ][\w\d\.\-]+)?|GPL|LGPL|FAL|CeCILL)($|\\\\|)" ';
$scope[]= 'excluding files requiering license text';
}
if ($nobad) {
$having[]= 'tags RLIKE "(^|\\\\|)(GFDL([- ][\w\d\.\-]+)?|GPL|LGPL|FAL|CeCILL|BSDu?|Cc-.*|PD(-.*)?|Public_domain|Copyleft|CopyrightedFreeUse(Provided(That)?)?|Copyrighted_free_use(_provided(_that)?)?)($|\\\\|)"
AND tags NOT RLIKE "(^|\\\\|)(Delete|Deletion_request|Vfd|Ifd|Copyvio|Fair_use|Logo|Screenshot|Delete_because|Unknown(,_license_selector)?|No_source(_since)?|No_license(_since)?|Incomplete_license)($|\\\\|)"';
$scope[]= 'excluding questionable and untagged files';
}
if ($where) $where= ' WHERE '.implode ( ' AND ', $where);
else $where = '';
if ($having) $having= ' HAVING '.implode ( ' AND ', $having);
else $having = '';
if (!$sql) $sql= 'SELECT image.*, '.$imgres.',
group_concat(distinct GP.page_title separator "|") as pages,
group_concat(distinct cl_to separator "|") as cats,
group_concat(distinct tl_title separator "|") as tags FROM image';
$sql.= " JOIN page as IP ON IP.page_namespace = ".NS_IMAGE." AND IP.page_title = img_name ";
$sql.= $join;
$sql.= " LEFT JOIN imagelinks ON il_to = img_name LEFT JOIN page as GP ON GP.page_namespace = ".NS_MAIN." AND GP.page_id = il_from ";
$sql.= " LEFT JOIN categorylinks ON cl_from = IP.page_id ";
$sql.= " LEFT JOIN templatelinks ON tl_from = IP.page_id AND tl_namespace = ".NS_TEMPLATE;
$sql.= $latejoin;
$sql.= $where;
$sql.= " GROUP BY img_name ";
$sql.= $having;
$wq->query= $sql;
if ($scope) {
$wq->scope= implode(', ',$scope);
}
if (!$wgRequest->getVal('order')) $wq->order= '-img_timestamp';
#img_name as title, img_user, img_user_text, img_timestamp as value, img_description
/*
$wq->fields['img_user_text']= array(
'label' => 'User',
#'html' => true,
#'function' => 'getUserInfo',
'sort' => true,
#'filter' => true,
'filter-normalize' => 'title',
'hidden' => true,
);
$wq->fields['img_name']= array(
'label' => 'Name',
#'html' => true,
#'function' => 'getFileInfo',
'filter-normalize' => 'title',
'sort' => true,
'hidden' => true,
);
*/
$wq->fields['img_res']= array(
'label' => 'Resolution',
'sort' => true,
'hidden' => true,
'csv_hidden' => false,
);
$wq->fields['img_size']= array(
'label' => 'Size',
'sort' => true,
'hidden' => true,
'csv_hidden' => false,
);
$wq->fields['img_timestamp']= array(
'label' => 'Date',
#'html' => true,
#'pattern' => 'return $this->makeDate($row["img_timestamp"]);',
'sort' => true,
'hidden' => true,
'csv_hidden' => false,
#'timestamp' => true,
);
#..........
/*$wq->fields['thumb']= array(
'label' => 'Thumb',
'html' => true,
'function' => 'getThumbInfo',
'attributes' => 'style="text-align:center; width:12%;"',
);
*/
$wq->fields['info']= array(
'label' => 'Image',
'html' => true,
'function' => 'getImageInfo',
'attributes' => 'style="text-align:left; width:25%;"',
);
/*
$wq->fields['tags']= array(
'label' => 'Tags',
'html' => true,
'function' => 'getTagInfo',
);
*/
/*$wq->fields['usage']= array(
'label' => 'Usage',
'html' => true,
'function' => 'getUsageInfo',
);*/
#..............
$wq->csvFields= array(
'date' => 'csv_date',
'user' => 'img_user_text',
'title' => 'img_name',
'size' => 'img_size',
'width' => 'img_width',
'height' => 'img_height',
'type' => 'img_media_type',
'mime' => 'csv_mime',
'categories' => 'cats',
'pages' => 'pages',
'tags' => 'tags',
#'url' => 'csv_url',
#'description' => 'csv_info',
);
$wq->fields['csv_url']= array(
'label' => 'URL',
'pattern' => 'return $this->makeURL($row["img_name"],NS_IMAGE);',
'hidden' => true,
'csv_hidden' => false,
);
$wq->fields['csv_mime']= array(
'label' => 'MIME',
'pattern' => 'return $row["img_major_mime"]."/".$row["img_minor_mime"];',
'hidden' => true,
'csv_hidden' => false,
);
$wq->fields['csv_date']= array(
'label' => 'Date',
'pattern' => 'return $row["img_timestamp"];',
'hidden' => true,
'csv_hidden' => false,
);
$wq->styles[]= '.untagged { color:yellow; background-color:#DD0000; font-weight:bold; font-size:88%; white-space:nowrap; padding-left:1ex; padding-right:1ex; }';
$wq->styles[]= '.orphan { color:yellow; background-color:#DD0000; font-weight:bold; font-size:88%; white-space:nowrap; padding-left:1ex; padding-right:1ex; }';
$wq->styles[]= 'table.query-result { cell-spacing:1ex; }';
$wq->styles[]= 'table.query-result th { background-color:#D0D0D0; padding:1pt 2pt 2pt 2pt; }';
$wq->styles[]= 'table.query-result td { background-color:#F4F4F4; padding:0.5ex; }';
$wq->styles[]= 'table.query-result td img { background-color:#E0E0E0; padding:0.5ex; margin:0; border:1px solid #AAAAAA; }';
$wq->styles[]= 'table.searchbox th { vertical-align:top; text-align:right; }';
$wq->styles[]= '.license-tag { background-color:#DDFFDD; }';
$wq->styles[]= '.license-highlite-tag { background-color:#FFEEAA; }';
$wq->styles[]= '.custom-tag { background-color:#EEFFEE; }';
$wq->styles[]= '.delete-tag { background-color:#FFAAAA; }';
$wq->styles[]= '.problem-tag { background-color:#FFEEAA; }';
$wq->styles[]= '.unknown-tag { background-color:#FFDDFF; }';
$wq->styles[]= '.meta-tag { background-color:#DDDDFF; font-size: 80%; }';
$wq->styles[]= '.magic-tag { background-color:#DDDDDD; font-size: 80%; }';
$wq->styles[]= '.layout-tag { font-size: 80%; }';
$wq->styles[]= '.language-tag { font-size: 80%; }';
$wq->styles[]= 'small { font-size: 80%; }';
$wq->header[]= '<script type="text/javascript" src="CategorySelector.js"></script>';
$wq->header[]= '<link rel="stylesheet" type="text/css" href="CategorySelector.css"/>';
$noby_checked= $noby ? 'checked="checked"' : '';
$nosa_checked= $nosa ? 'checked="checked"' : '';
$nobad_checked= $nobad ? 'checked="checked"' : '';
$nocopy_checked= $nocopy ? 'checked="checked"' : '';
$mediatype_auto_sel= $mediatype === 'auto' ? 'selected="selected"' : '';
$mediatype_any_sel= $mediatype === 'any' ? 'selected="selected"' : '';
$mediatype_image_sel= $mediatype === 'image' ? 'selected="selected"' : '';
$mediatype_audio_sel= $mediatype === 'audio' ? 'selected="selected"' : '';
$mediatype_video_sel= $mediatype === 'video' ? 'selected="selected"' : '';
$mediatype_other_sel= $mediatype === 'other' ? 'selected="selected"' : '';
$treecat= trim($category);
if (!$treecat) $treecat= '*'; #FIXME: fetch root category for each project?!
$treeoptions= 'wiki='.$wq->wikiSelector->domain;
$treeoptions.= '&cat='.$treecat;
$wiki= $wq->wiki ? $wq->wiki->domain : NULL;
$rootcat= $wq->wiki ? $wq->wiki->root_category : NULL;
$wq->optionsHTML= <<<EOS
<table class='searchbox'>
<!--<tr>
<th>Keywords</th>
<td><input type='text' name='keywords' size='64' value='{$keywords}' {$keywords_disable}/></td>
</tr> -->
<tr>
<th>Category</th>
<td><input type='text' name='category' size='32' value='{$category}' id='categoryField'/>, depth
<input type='text' name='depth' size='3' value='{$catdepth}'/>
<small>(<a href='CategoryTree.php?{$treeoptions}'>browse category tree</a>)</small>
<script type='text/javascript'>
catsel= new CategorySelector('catsel', 'categoryField', '{$wiki}', '{$rootcat}');
catsel.attach('select...', 'Category Selector');
</script>
</td>
</tr>
<tr>
<th>Size</th>
<td>No larger than <input type='text' name='maxkb' size='6' value='{$maxkb}'/> KB,
no smaller than <input type='text' name='minpx' size='6' value='{$minpx}'/> pixels <small>(applies to bitmaps only)</small>
</td>
</tr>
<tr>
<th>Type</th>
<td>Type <select name='mediatype'>
<option value='auto' {$mediatype_auto_sel}>Auto</option>
<option value='any' {$mediatype_any_sel}>Any</option>
<option value='image' {$mediatype_image_sel}>Image</option>
<option value='audio' {$mediatype_audio_sel}>Audio</option>
<option value='video' {$mediatype_video_sel}>Video</option>
<option value='other' {$mediatype_other_sel}>Other</option>
</select>
Format <input type='text' name='mimetype' size='16' value='{$mimetype}'/>
</td>
</tr>
<tr>
<th>Upload</th>
<td>
User <input type='text' name='uploader' size='32' value='{$uploader}'/>
</td>
</tr>
<tr>
<th>License</th>
<td>
hide questionable <input type='checkbox' name='nobad' {$nobad_checked} {$license_disable}/>,
no license copy <input type='checkbox' name='nocopy' {$nocopy_checked} {$license_disable}/>,
no share-alike <input type='checkbox' name='nosa' {$nosa_checked} {$license_disable}/>,
no attribution <input type='checkbox' name='noby' {$noby_checked} {$license_disable}/>
<p>
<i>(<b>Note:</b> there is no guarantee that the images are tagged correctly. Before using a
media file you find here, always double-check the license info given on the description page.
When in doubt, please contact the uploader.)</i>
</p>
</td>
</tr>
</table>
EOS;
if (!$keywords && !$category && !$uploader) $wq->complete= false;
$wq->helpPageName= 'MediaSearch';
$wq->printPage();
$wq->close();
?>MediaSearch.php
application/x-php, 26743 bytes (load raw)

