Author Topic: [Feature Request] List available keywords in advanced search  (Read 11282 times)

0 Members and 2 Guests are viewing this topic.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[Feature Request] List available keywords in advanced search
« on: September 15, 2002, 03:58:19 PM »
Provide a drop down list of all the available keywords in the advanced search page.  Not knowing what keywords exist makes it hard to guess what keyword search can be performed.

Offline hottemax

  • Newbie
  • *
  • Posts: 10
    • View Profile
hiermit ermittle ich die keywords
« Reply #1 on: September 30, 2002, 09:12:02 AM »
Code: [Select]
<?PHP

/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: my_keywords.php                                      *
 *        Copyright: (C) 2002 Mathias Kaufberger                          *
 *            Email: m.kaufberger@gmx.de                                  *
 *              Web: -                                                    *
 *    Scriptversion: 1.0                                                  *
 *                                                                        *
 *    Never released without support from: Jan Sorgalla                   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) für weitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

/*   Allgemeine Daten fuer die Datenbankanbindung  und direkter Connect zur Datenbank.
Nach  Einbindung dieses Segments kann direkt mit  MySQL-Befehlen auf die Datenbank zugegriffen  werden.*/

/* Datenbankserver - In der Regel die IP */  
$db_server = "localhost";
/* Datenbankname */
  $db_name = "4images";
/* Datenbankuser */
  $db_user = "admin";
/* Datenbankpasswort */
  $db_passwort = "admin";
         

/*  mysql_connect (PHP 3, PHP 4 )
mysql_connect -- Open a connection to a MySQL Server  
mysql_db_query() selects a database and executes a query on it.
If the optional link identifier isn't specified, the function will try to find an open link to
the MySQL server and if no such link is found it'll try to
create one as if mysql_connect() was called with no arguments.
*/  
$db = @MYSQL_CONNECT($db_server,$db_user,$db_passwort);  

/* mysql_db_query PHP 3, PHP 4 )
mysql_db_query -- Send a MySQL query */
$result = mysql_db_query("4images","SELECT `image_keywords` FROM `4images_images` WHERE 1 order by `image_keywords` DESC");



/* mysql_fetch_row (PHP 3, PHP 4 )
mysql_fetch_row -- Get a result row as an enumerated array */
list($Name) = mysql_fetch_row($result);

// create a new array
$array = array();

while (list($Name) = mysql_fetch_row($result)){

/* Diese Funktion liefert TRUE, wenn eine Variable nicht definiert, leer oder gleich 0 ist, ansonsten FALSE.
empty (unknown) empty -- Determine whether a variable is set */
if(!empty($Name)){
/* explode (PHP 3, PHP 4 ) explode -- Split a string by string */
$explode_array = explode(" ",$Name);

for($x=0;$x<count($explode_array);$x++){
// shift into the new array
$temp = $explode_array[$x];
// strtolower (PHP 3, PHP 4 )
// strtolower -- Make a string lowercase convert into
$array[] = strtolower($temp);
//$array[] = $explode_array[$x];

}
}
}



/* array_unique (PHP 4 >= 4.0.1)
array_unique -- Removes duplicate values from an array*/
$array1 = array_unique($array);

/* sort (PHP 3, PHP 4 )sort -- Sort an array */
sort($array1,SORT_REGULAR);

/* for test reasons */
//echo "<b>Sorted Keywords:</b><br>";
echo implode(" - ",$array1);



?>

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
Finally had a chance to test
« Reply #2 on: October 05, 2002, 09:48:13 PM »
I was very carful to copy try the posted code.  Sadly, I get two errors:

Code: [Select]

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/www/Chris/images/keywords.php on line 55

Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result resource in /home/www/Chris/images/keywords.php on line 60

So it doesn't these lines:
Code: [Select]
list($Name) = mysql_fetch_row($result);
while (list($Name) = mysql_fetch_row($result)){

Maybe the code was obfuscated by not using the
Code: [Select]
BBCode? Did I miss something?

[b]UPDATE:

It was a simple bug.  I just didn't see it too quickly.  Must be the lack of sleep.  Here is the corrected script:[/b]
[code]<?php
/**************************************************************************
*
* 4images - A Web Based Image Gallery Management System
* ----------------------------------------------------------------
*
* File: my_keywords.php
* Copyright: (C) 2002 Mathias Kaufberger
* Email: m.kaufberger@gmx.de
* Web: -
* Scriptversion: 1.0
*
* Never released without support from: Jan Sorgalla
*
**************************************************************************
*
* Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-
* bedingungen (Lizenz.txt) für weitere Informationen.
* ---------------------------------------------------------------
* This script is NOT freeware! Please read the Copyright Notice
* (Licence.txt) for further information.
*
*************************************************************************/

/* Allgemeine Daten fuer die Datenbankanbindung und direkter Connect zur Datenbank.
Nach Einbindung dieses Segments kann direkt mit MySQL-Befehlen auf die Datenbank zugegriffen werden.*/

/* Datenbankserver - In der Regel die IP */
$db_server "localhost";
/* Datenbankname */
$db_name "database_name";
/* Datenbankuser */
$db_user "database_user";
/* Datenbankpasswort */
$db_password "database_password";


/* mysql_connect (PHP 3, PHP 4 )
mysql_connect -- Open a connection to a MySQL Server
mysql_db_query() selects a database and executes a query on it.
If the optional link identifier isn't specified, the function will try to find an open link to
the MySQL server and if no such link is found it'll try to
create one as if mysql_connect() was called with no arguments.
*/
$db = @MYSQL_CONNECT($db_server,$db_user,$db_password);

/* mysql_db_query PHP 3, PHP 4 )
mysql_db_query -- Send a MySQL query */
$result mysql_db_query$db_name,"SELECT `image_keywords` FROM `4images_images` WHERE 1 order by `image_keywords` DESC");

/* mysql_fetch_row (PHP 3, PHP 4 )
mysql_fetch_row -- Get a result row as an enumerated array */
list($Name) = mysql_fetch_row($result);

// create a new array
$array = array();

/* Diese Funktion liefert TRUE, wenn eine Variable nicht definiert, leer oder gleich 0 ist ansonsten FALSE. empty (unknown) empty -- Determine whether a variable is set */
while (list($Name) = mysql_fetch_row($result)){

  if(!empty(
$Name)){ // explode (PHP 3, PHP 4 ) explode -- Split a string by string
    
$explode_array explode(" ",$Name);

    for(
$x=0;$x<count($explode_array);$x++){
      
// shift into the new array
      
$temp $explode_array[$x];
      
// strtolower (PHP 3, PHP 4 )
      // strtolower -- Make a string lowercase convert into
      
$array[] = strtolower($temp);
      
//$array[] = $explode_array[$x];
    
}
  }
}

/* array_unique (PHP 4 >= 4.0.1)
array_unique -- Removes duplicate values from an array*/
$array1 array_unique($array);

/* sort (PHP 3, PHP 4 )sort -- Sort an array */
sort($array1,SORT_REGULAR);

/* for test reasons */
//echo "<b>Sorted Keywords:</b><br>";
echo implode(",",$array1);
?>

Offline jengwen

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
    • http://www.jenrichardsphotography.com
[Feature Request] List available keywords in advanced searc
« Reply #3 on: January 25, 2003, 06:33:19 PM »
Could you tell us (or give example code) of where to call this mod from?  Also, could you move it to the new mod forum, since it is kind of hidden here?

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[Feature Request] List available keywords in advanced searc
« Reply #4 on: January 25, 2003, 09:44:55 PM »
Basically you would use that php script to output the keywords and a bit of html to generate a drop down list, or other control, in the advanced search form.  This mod is number 3 on my 4images mod TODO list.  When I get to it, I'll try to come back here and post what I did.

I can't move this thread as I do not have any phpbb administrative priviledges, nor do I want any  :wink:

Offline SLL

  • Hero Member
  • *****
  • Posts: 585
    • View Profile
[Feature Request] List available keywords in advanced searc
« Reply #5 on: January 25, 2003, 11:01:04 PM »
Quote from: Chris
This mod is number 3 on my 4images mod TODO list.  When I get to it, I'll try to come back here and post what I did

Maybe you would consider to post your "todo" here, so others, who are missing the same features in 4images, wouldn't do the same job, and just wait for your mods?

Concerning this script: I'm not the brightest guy in the world, and I don't see any sense to list hundreds of search words in the dropdown.. where am I wrong?

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[Feature Request] List available keywords in advanced searc
« Reply #6 on: January 26, 2003, 02:22:10 AM »
Quote from: SLL
... I don't see any sense to list hundreds of search words in the dropdown.. where am I wrong?
These aren't search words, they're keywords.  Keywords are words you choose to explicitly assign to an image.

From a dictionary:
Quote
key·word also key word -
A word used as a reference point for finding other information.
It's very common in digital asset management programs to not only categorize files, but to also let you assign keywords.  Keywords are descriptive words and phrases that you can assign to your cataloged files in order to categorize and classify them. If you had an image of a tropical beach at sunset, for example, you might assign it keywords such as Sand, Beach, Ocean, Sunset, Tropical, Vacation, Recreation, Outdoor, and so on. Any of these terms would make it easier to group the image along with other related images, and also make it easier to search for the file.  

This isn't the same as category since you might choose to place the image in a "beach" category.  Suppose you also had an image of a city building taken at sunset when the color had changed and you placed it in a "buildings" category.  The keyword "sunset" could be used to group these images as having something in common.

Search words can be anything from the image description, caption, and even keywords.  So in 4images the difference is that keywords are chosen and assigned whereas search words are not.

Regarding my TODO list, it's actually a list of mods already posted here in the forums that I have yet to implement.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[Feature Request] List available keywords in advanced searc
« Reply #7 on: January 27, 2003, 03:46:33 AM »
Quote from: SLL
Concerning this script: I'm not the brightest guy in the world, and I don't see any sense to list hundreds of search words in the dropdown.. where am I wrong?
I think I now realize why this might be confusing.  The default template search_form.html, with the english language pack, uses search_keywords and lang_search_keywords in the form field that actually accepts "Search Words".  The text entered there is used to search description, keywords, image name, etc.

I hope this helps.

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
[Feature Request] List available keywords in advanced searc
« Reply #8 on: January 30, 2003, 05:17:57 AM »
A mod complete with a picture and full instructions for this is now available here:

http://4homepages.de/forum/viewtopic.php?p=15808