This is for the search form. Create a new file and copy this into it:
<?php
define('IN_COPPERMINE', true);
require('include/init.inc.php');
pageheader("Suche");
function div_start($tag)
{
echo "<div id=\"$tag\" style=\"display:none;\">";
starttable("100%", $tag, 2);
}
function div_end()
{
endtable();
echo "</div>";
}
starttable("100%", "Auswahl",2);
echo "
<tr>
<td class=\"tableb\" width=\"200\">
Ich suche nach:
</td>
<td class=\"tableb\">
<input type=\"radio\" name=\"albfile\" onclick=\"document.getElementById('Bildersuche').style.display = 'none'; document.getElementById('Albensuche').style.display = 'block'; document.getElementById('album').focus();\" /> Alben
<input type=\"radio\" name=\"albfile\" onclick=\"document.getElementById('Bildersuche').style.display = 'block'; document.getElementById('Albensuche').style.display = 'none';\" /> Dateien (Bilder, Videos)
</td>
</tr>
";
endtable();
div_start("Albensuche");
echo "
<script type=\"text/javascript\">
var alertTimerId = 0;
function doSearch ( )
{
clearTimeout ( alertTimerId );
document.getElementById('album').style.color = '#FF0000';
alertTimerId = setTimeout ( 'DoShowResult()', 500 );
}
function DoShowResult ( )
{
document.getElementById('album').style.color = '#000000';
clearTimeout ( alertTimerId );
showResult(document.getElementById('album').value);
}
</script>
<tr>
<td class=\"tableb\">
<form method=\"get\" action=\"thumbnails.php\">
<input type=\"text\" id=\"album\" name=\"alb_title\" class=\"textinput\" size=\"50\" onkeyup=\"doSearch()\" />
<input type=\"hidden\" name=\"album\" value=\"search_alb\" />
<input type=\"submit\" name=\"Submit\" value=\"Suchen\" class=\"button\" />
<div align=\"left\" id=\"livesearch\" style=\"position:absolute;background-color: #ffffff;\" />
</form>
</td>
</tr>
";
div_end();
div_start("Bildersuche");
echo "</table><form method=\"get\" action=\"thumbnails.php\"><input type=\"hidden\" name=\"album\" value=\"search_pic\" />";
starttable("100%", "Kriterien",2);
//$disabled = isfriend() ? "" : "disabled=\"disabled\"";
echo "
<!--
<tr>
<td class=\"tableb\" width=\"200\">
Alles <br />
</td>
<td class=\"tableb\">
<input type=\"radio\" name=\"all\" value=\"on\" onclick=\"
document.getElementById('cat_on').click();
document.getElementById('alb_on').click();
document.getElementById('file_on').click();
document.getElementById('com_on').click();
document.getElementById('pers_on').click();
\" /> Anzeigen
<input type=\"radio\" name=\"all\" value=\"off\" onclick=\"
document.getElementById('cat_off').click();
document.getElementById('alb_off').click();
document.getElementById('file_off').click();
document.getElementById('com_off').click();
document.getElementById('pers_off').click();
\" /> Nicht anzeigen
</td>
</tr>
-->
<tr>
<td class=\"tableb\" width=\"200\">
<b>Kategorie</b> -> Monat / Jahr <br />
</td>
<td class=\"tableb\">
<input type=\"radio\" name=\"cat\" id=\"cat_on\" value=\"on\" onclick=\"document.getElementById('Kategorie').style.display = 'block'; document.getElementById('cat_month').focus();\" /> Anzeigen
<input type=\"radio\" name=\"cat\" id=\"cat_off\" value=\"off\" onclick=\"document.getElementById('Kategorie').style.display = 'none';\" checked=\"checked\" /> Nicht anzeigen
</td>
</tr>
<tr>
<td class=\"tableb\" width=\"200\">
<b>Album</b> -> Titel / Beschreibung
</td>
<td class=\"tableb\">
<input type=\"radio\" name=\"alb\" id=\"alb_on\" value=\"on\" onclick=\"document.getElementById('Album').style.display = 'block'; document.getElementById('alb_title').focus();\" /> Anzeigen
<input type=\"radio\" name=\"alb\" id=\"alb_off\" value=\"off\" onclick=\"document.getElementById('Album').style.display = 'none';\" checked=\"checked\" /> Nicht anzeigen
</td>
</tr>
<tr>
<td class=\"tableb\" width=\"200\">
<b>Datei</b> -> Name / Endung
</td>
<td class=\"tableb\">
<input type=\"radio\" name=\"file\" id=\"file_on\" value=\"on\" onclick=\"document.getElementById('Datei').style.display = 'block'; document.getElementById('file_name').focus();\" /> Anzeigen
<input type=\"radio\" name=\"file\" id=\"file_off\" value=\"off\" onclick=\"document.getElementById('Datei').style.display = 'none';\" checked=\"checked\" /> Nicht anzeigen
</td>
</tr>
<tr>
<td class=\"tableb\" width=\"200\">
<b>Kommentar</b> -> Autor / Text
</td>
<td class=\"tableb\">
<input type=\"radio\" name=\"com\" id=\"com_on\" value=\"on\" onclick=\"document.getElementById('Kommentar').style.display = 'block'; document.getElementById('com_aut').focus();\" /> Anzeigen
<input type=\"radio\" name=\"com\" id=\"com_off\" value=\"off\" onclick=\"document.getElementById('Kommentar').style.display = 'none';\" checked=\"checked\" /> Nicht anzeigen
</td>
</tr>
<tr>
<td class=\"tableb\" width=\"200\">
<b>Person</b> -> Name
</td>
<td class=\"tableb\">
<input type=\"radio\" name=\"pers\" id=\"pers_on\" value=\"on\" $disabled onclick=\"document.getElementById('Person').style.display = 'block'; document.getElementById('pers_name').focus();\" /> Anzeigen
<input type=\"radio\" name=\"pers\" id=\"pers_off\" value=\"off\" onclick=\"document.getElementById('Person').style.display = 'none';\" checked=\"checked\" /> Nicht anzeigen
</td>
</tr>
";
endtable();
div_start("Kategorie");
$first_year = mysql_result(cpg_db_query("SELECT MIN(name) FROM {$CONFIG['TABLE_CATEGORIES']}"),0);
$years = "";
for ($i=$first_year; $i<=date("Y"); $i++)
$years .= "<option>$i</option>";
echo "
<tr>
<td class=\"tableb\" width=\"200\">
Monat:
</td>
<td class=\"tableb\">
<select id=\"cat_month\" name=\"cat_month\" class=\"button\" size=\"1\" style=\"width:300px;\">
<option selected=\"selected\"></option>
<option>Januar</option>
<option>Februar</option>
<option>März</option>
<option>April</option>
<option>Mai</option>
<option>Juni</option>
<option>Juli</option>
<option>August</option>
<option>September</option>
<option>Oktober</option>
<option>November</option>
<option>Dezember</option>
</select><br />
</td>
</tr>
<tr>
<td class=\"tableb\" width=\"200\">
Jahr:
</td>
<td class=\"tableb\">
<select name=\"cat_year\" class=\"button\" size=\"1\" style=\"width:300px;\">
<option selected=\"selected\"></option> $years
</selected>
</td>
</tr>
";
div_end();
div_start("Album");
echo "
<tr>
<td class=\"tableb\" width=\"200\">
Titel:
</td>
<td class=\"tableb\">
<input type=\"input\" id=\"alb_title\" name=\"alb_title\" class=\"textinput\" style=\"width:300px;\" />
</td>
</tr>
<tr>
<td class=\"tableb\" width=\"200\">
Beschreibung:
</td>
<td class=\"tableb\">
<input type=\"input\" name=\"alb_desc\" class=\"textinput\" style=\"width:300px;\" />
</td>
</tr>
";
div_end();
div_start("Datei");
echo "
<tr>
<td class=\"tableb\" width=\"200\">
Name:
</td>
<td class=\"tableb\">
<input type=\"input\" id=\"file_name\" name=\"file_name\" class=\"textinput\" style=\"width:300px;\" />
</td>
</tr>
<tr>
<td class=\"tableb\" width=\"200\">
Endung:
</td>
<td class=\"tableb\">
<input type=\"input\" name=\"file_ext\" class=\"textinput\" style=\"width:300px;\" /> (z.B. \"flv\" für alle Videos)
</td>
</tr>
";
div_end();
div_start("Kommentar");
echo "
<tr>
<td class=\"tableb\" width=\"200\">
Autor:
</td>
<td class=\"tableb\">
<input type=\"input\" id=\"com_aut\" name=\"com_aut\" class=\"textinput\" style=\"width:300px;\" />
</td>
</tr>
<tr>
<td class=\"tableb\" width=\"200\">
Text:
</td>
<td class=\"tableb\">
<input type=\"input\" name=\"com_text\" class=\"textinput\" style=\"width:300px;\" />
</td>
</tr>
";
div_end();
//if (isfriend())
//{
div_start("Person");
echo "
<tr>
<td class=\"tableb\" width=\"200\">
Name:
</td>
<td class=\"tableb\">
<input type=\"input\" id=\"pers_name\" name=\"pers_name\" id=\"pers_name\" class=\"textinput\" style=\"width:300px;\" />
</td>
</tr>
";
$result = cpg_db_query("SELECT note FROM {$CONFIG['TABLE_PREFIX']}notes GROUP BY note ORDER BY note ASC");
if (mysql_num_rows($result))
{
echo "<tr><td class=\"tableb\" colspan=\"2\">";
while ($row = mysql_fetch_array($result, MYSQL_NUM))
echo "<span class=\"button\" style=\"cursor: pointer;\" onclick=\"document.getElementById('pers_name').value += ' '+'{$row[0]}'+' ';document.getElementById('search').focus();return false;\"> {$row[0]} </span> ";
echo "</td></tr>" ;
echo "<tr><td class=\"tableb\" colspan=\"2\" align=\"center\">";
echo "Obenstehende Liste enthält alle bisher verlinkten Personen und können per Klick zur Suche hinzugefügt werden.";
echo "</td></tr>";
}
div_end();
//}
starttable("100%", "<input type=\"submit\" value=\"Suchen\" class=\"button\" />");
endtable();
echo "</form></div>";
pagefooter();
?>
FYI:
1. The field "Person" is for the annotations. I modified the plugin a little bit. In my gallery you mark persons that are on the picture, that's why it's called "Person".
2. The function
isfriend() checks, if someone has the rights to access the person search (= search for annotations). I have disabled the check in this example, because it's only relevant in my gallery.
3. I have an AJAX script for pre searching the albums. If you get an error or something at the album search, the needed files are missing.
Here is the code for the meta albums. It has to copied into include/functions.inc.php:
case 'search_pic': // Search pictures
if ($META_ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = "Suchergebnisse - $CURRENT_CAT_NAME";
} else {
$album_name = "Suchergebnisse";
}
$META_ALBUM_SET = str_replace("AND aid NOT IN","AND a.aid NOT IN",$META_ALBUM_SET);
$get_array = array("file", "file_name", "file_ext", "com", "com_aut", "com_text", "alb", "alb_title", "alb_desc", "pers", "pers_name", "cat", "cat_month", "cat_year");
foreach($get_array as $key)
{
$_GET[$key] = isset($_GET[$key]) ? trim(preg_replace("[\s+]"," ",$_GET[$key])) : $_COOKIE[$key];
setcookie($key, $_GET[$key]);
}
$columns = "";
$tables = "{$CONFIG['TABLE_PICTURES']} p INNER JOIN {$CONFIG['TABLE_ALBUMS']} a ON p.aid = a.aid";
$where = "";
$suffix = "";
$order = "p.pid";
if ($_GET['file'] == "on")
{
$where .= "AND (";
if ($_GET['file_name'] != "")
{
$file_name_parts = explode(" ", $_GET['file_name']);
foreach ($file_name_parts as $value)
$where .= "p.filename LIKE '%$value%' AND ";
}
if (trim($_GET['file_ext']) != "")
$where .= "p.filename LIKE '%.".trim($_GET['file_ext'])."' AND ";
$where .= "1) ";
}
if ($_GET['com'] == "on")
{
$tables .= " INNER JOIN {$CONFIG['TABLE_COMMENTS']} c ON c.pid = p.pid";
$where .= "AND (";
$order = "c.msg_id";
if ($_GET['com_text'] != "")
{
$com_text_parts = explode(" ", $_GET['com_text']);
foreach ($com_text_parts as $value)
$where .= "c.msg_body LIKE '%$value%' AND ";
}
if ($_GET['com_aut'] != "")
$where .= "c.msg_author LIKE '%{$_GET['com_aut']}%' AND ";
$where .= "1) ";
}
if ($_GET['alb'] == "on")
{
$where .= "AND (";
if ($_GET['alb_title'] != "")
{
$alb_title_parts = explode(" ", $_GET['alb_title']);
foreach ($alb_title_parts as $value)
$where .= "a.title LIKE '%$value%' AND ";
}
if ($_GET['alb_desc'] != "")
{
$alb_desc_parts = explode(" ", $_GET['alb_desc']);
foreach ($alb_desc_parts as $value)
$where .= "a.description LIKE '%$value%' AND ";
}
$where .= "1) ";
}
if ($_GET['pers'] == "on")
{
if ($_GET['pers_name'] != "")
{
$columns .= ", COUNT(DISTINCT note) AS anzahl";
$tables .= " INNER JOIN {$CONFIG['TABLE_PREFIX']}notes n ON p.pid = n.pid";
$where .= "AND (";
$pers_name_parts = explode(" ", $_GET['pers_name']);
$pcount = count($pers_name_parts);
for ($i=0;$i<$pcount-1;$i++)
$where .= "n.note = '{$pers_name_parts[$i]}' OR ";
$where .= "n.note = '{$pers_name_parts[$i]}' AND ";
$where .= "1) ";
$suffix = "GROUP BY p.pid HAVING anzahl = $pcount";
}
}
if ($_GET['cat'] == "on")
{
$tables .= " INNER JOIN {$CONFIG['TABLE_CATEGORIES']} cm ON cm.cid = a.category";
$where .= "AND (";
if ($_GET['cat_month'] != "")
$where .= "cm.name LIKE '{$_GET['cat_month']}' AND ";
if ($_GET['cat_year'] != "")
{
$tables .= " INNER JOIN {$CONFIG['TABLE_CATEGORIES']} cy ON cm.parent = cy.cid";
$where .= "cy.name LIKE '{$_GET['cat_year']}' AND ";
}
$where .= "1) ";
}
$query = "SELECT DISTINCT(p.pid) $columns FROM $tables WHERE approved = 'YES' $where $META_ALBUM_SET $suffix";
$result = cpg_db_query($query);
$count = mysql_num_rows($result);
mysql_free_result($result);
$select_columns = 'DISTINCT p.*, a.title';
$query = "SELECT $select_columns $columns FROM $tables WHERE approved = 'YES' $where $META_ALBUM_SET $suffix ORDER BY $order DESC $limit";
$result = cpg_db_query($query);
$rowset = array();
while($row = mysql_fetch_array($result)){
$rowset[-$row['pid']] = $row;
}
mysql_free_result($result);
if ($set_caption) build_caption($rowset);
$rowset = CPGPluginAPI::filter('thumb_caption_search_pic',$rowset);
return $rowset;
break;
case 'search_alb': // Search albums
if ($META_ALBUM_SET && $CURRENT_CAT_NAME) {
$album_name = "Suchergebnisse - $CURRENT_CAT_NAME";
} else {
$album_name = "Suchergebnisse";
}
if (isset($_GET['alb_title']))
$alb_title = trim(preg_replace("[\s+]"," ",$_GET['alb_title']));
else
$alb_title = $_COOKIE['alb_title'];
setcookie('alb_title', $alb_title);
$where = "";
$alb_title_parts = explode(" ", $alb_title);
foreach ($alb_title_parts as $key => $value)
$where .= "{$CONFIG['TABLE_ALBUMS']}.title LIKE '%$value%' AND ";
$META_ALBUM_SET = str_replace("aid", $CONFIG['TABLE_PICTURES'].".aid", $META_ALBUM_SET);
$query = "SELECT count({$CONFIG['TABLE_ALBUMS']}.aid) FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE $where {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND approved = 'YES' $META_ALBUM_SET GROUP BY {$CONFIG['TABLE_PICTURES']}.aid";
$result = cpg_db_query($query);
$count = mysql_num_rows($result);
mysql_free_result($result);
//$query = "SELECT *,{$CONFIG['TABLE_ALBUMS']}.title AS title,{$CONFIG['TABLE_ALBUMS']}.aid AS aid FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND approved = 'YES' $META_ALBUM_SET GROUP BY {$CONFIG['TABLE_PICTURES']}.aid ORDER BY {$CONFIG['TABLE_PICTURES']}.ctime DESC $limit";
//display album thumbnail // by muu
$query = "SELECT *,{$CONFIG['TABLE_ALBUMS']}.title AS title,{$CONFIG['TABLE_ALBUMS']}.aid AS aid FROM {$CONFIG['TABLE_PICTURES']},{$CONFIG['TABLE_ALBUMS']} WHERE $where {$CONFIG['TABLE_PICTURES']}.aid = {$CONFIG['TABLE_ALBUMS']}.aid AND approved = 'YES' AND {$CONFIG['TABLE_PICTURES']}.pid = {$CONFIG['TABLE_ALBUMS']}.thumb $META_ALBUM_SET ORDER BY {$CONFIG['TABLE_PICTURES']}.ctime DESC $limit"; // by muu
$result = cpg_db_query($query);
$rowset = cpg_db_fetch_rowset($result);
mysql_free_result($result);
if ($set_caption) build_caption($rowset,array('ctime'));
$rowset = CPGPluginAPI::filter('thumb_caption_lastalb',$rowset);
return $rowset;
break;
For HTML titles you have to add the 2 meta albums in your language file (
$lang_meta_album_names[])
I suppose that's all you have to know
