Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - WhiteRabbit

Pages: [1]
1
Hello people:

I'm making a mod to automatically make URLs to search.php to make possible searching fields by direct click on the field's value on the details page.
I added some code to make search.php to take variables from the GET array, and I did put this function to separate the indexed words from the non-indexed ones in the field value:

Code: [Select]
function create_searchable_words($base) {
  $words = split(' ', $base);
  foreach ($words as $key => $word) {
  if (strlen($word) > MIN_SEARCH_KEYWORD_LENGTH and strlen($word) < MAX_SEARCH_KEYWORD_LENGTH) {
if ($key == 0) {$final_url = $word;}
else {$final_url = $final_url." ".$word;}
}
   }
   return $final_url;
}

It's working Ok, but I have some problems with the "searchstopterms.txt" words. As you know, the words on that list aren't indexed, even if they enter in the range of MIN_SEARCH_KEYWORD_LENGTH and MAX_SEARCH_KEYWORD_LENGTH .
I think that somewhere in the code there is already a function that makes what I want: separate the searchable words from a string(as the one that I did make), plus removing the words that are at "searchstopterms.txt" from the string.
Anyone knows where it is?.

Thanks in advance.

WR.

2
Hello people.

I'm making a mod to my current template, to allow it to change the height and width values of an image, depending on the visitor's resolution.

Here is the "core" of the modification, the size calculation script. I made it on a separate page with static values for the image name, and it is working OK. But when I adapted it to 4images, it has no effect. I leave here the entire modification, to anyone that wants to debug it...

On header.html add :
Code: [Select]
<script language="JavaScript" type="text/javascript">
function image_size(){
    var AspectRatio, FinalWidth, FinalHeight, DoResize;
    DoResize=0;
    if (screen.width < 1024) {FinalWidth = 640; DoResize=1}
    if (screen.width < 800) {FinalWidth = 480; DoResize=1}
    if ((document.{image_id}.width > document.{image_id}.height) && (DoResize==1))
    { AspectRatio = (document.{image_id}.width / document.{image_id}.height);
FinalHeight = FinalWidth/AspectRatio;
document.{image_id}.width = FinalWidth;
document.{image_id}.height = FinalHeight;}
    if ((document.{image_id}.width < document.{image_id}.height) && (DoResize==1))
    {    AspectRatio = document.{image_id}.height / document.{image_id}.width;
FinalHeight = FinalWidth;
FinalWidth = FinalHeight/AspectRatio;
document.{image_id}.width = FinalWidth;
document.{image_id}.height = FinalHeight;}
    }
</script>

On <template's directory>/template/media/jpg.html change:
Code: [Select]
<!-- Template file for JPG Files -->
<img src="{media_src}" border="1" alt="{image_name}"{width_height} /><br />

with this:
Code: [Select]
<!-- Template file for JPG Files -->
<img src="{media_src}" border="1" alt="{image_name}" name="{image_id}" {width_height} /><br />

On <template's directory>/details.html add:
Code: [Select]
<script language="JavaScript">
image_size();
</script>
just before the tag {footer}

The last part can be added in jpg.html , it don't make difference.
I don't have any debug windows of IE or Mozilla saying that the code is wrong, as I say, it works OK with the object's name static...

Any ideas?.

Best regards.
WR.

3
Tutorials / [TUT] Making a "boolean" (tinyint 1) field searchable
« on: August 04, 2005, 02:31:50 AM »
NOTE: I was wanting to post this on the mods section, but I don't know why I don't have permission to post there. If some admin wants to move the post, I will be grateful

Hello people:

There is a problem if you want to add a boolean field and make it searchable using this guide:
http://www.4homepages.de/forum/index.php?topic=1313.0

That works very well with varchar fields. But for boolean fields, it's actually a waste of time and space, because to index it you have to set MIN_SEARCH_KEYWORD_LENGTH to 1, what causes to almost ALL words to be indexed. That can be a problem if you have various searchable fields, as I have. And in case that you want to find a positive value you have to enter a 1 in the search terms...

This mod allows you to make a boolean field searcheable WITHOUT indexing it. It works almost in the same way wich search_new_images works.
I will show the example with the field "image_nocturnal", but thats your choice.

First, add a "boolean" (tinyint 1) field to the images table, with this tutorial:
If you are goin to use an "internal" field (as this example, there is no need to show "Nocturnal: Yes" in the details page) you can avoid the steps involving details.html .

http://www.4homepages.de/forum/index.php?topic=747.msg3277#msg3277

In file search.php :
Look for:
Code: [Select]
if (isset($HTTP_POST_VARS['search_new_images']) || isset($HTTP_GET_VARS['search_new_images'])) {
  $search_new_images = 1;
  $show_result = 1;
}
else {
  $search_new_images = 0;
}

Insert below :
Code: [Select]
// NOCTURNAS
if (isset($HTTP_POST_VARS['search_nocturnal_images']) || isset($HTTP_GET_VARS['search_nocturnal_images'])) {
  $search_nocturnal_images = 1;
  $show_result = 1;
}
else {
  $search_nocturnal_images = 0;
}
//FIN NOCTURNAS

find:
Code: [Select]
if ($search_new_images && $show_result == 1) {
  $search_id['search_new_images'] = 1;
}

insert below:
Code: [Select]
//NOCTURNAS
if ($search_nocturnal_images && $show_result == 1) {
  $search_id['search_nocturnal_images'] = 1;
}
//FIN NOCTURNAS

find:
Code: [Select]
  if (!empty($search_id['search_new_images']) && $search_id['search_new_images'] == 1) {
    $new_cutoff = time() - 60 * 60 * 24 * $config['new_cutoff'];
    $sql_where_query .= "AND i.image_date >= $new_cutoff ";
  }

add below:
Code: [Select]
// NOCTURNAS
  if (!empty($search_id['search_nocturnal_images']) && $search_id['search_nocturnal_images'] == 1) {
    $sql_where_query .= "AND i.image_nocturnal = 1 ";
  }
// FIN NOCTURNAS

find:
Code: [Select]
  $site_template->register_vars(array(
    "search_keywords" => htmlspecialchars(stripslashes($org_search_keywords)),
    "search_user" => htmlspecialchars(stripslashes($org_search_user)),
    "lang_search_by_keyword" => $lang['search_by_keyword'],
    "lang_search_by_username" => $lang['search_by_username'],
    "lang_new_images_only" => $lang['new_images_only'],
    "lang_search_terms" => $lang['search_terms'],
    "lang_or" => $lang['or'],
    "lang_and" => $lang['and'],
    "lang_category" => $lang['category'],
    "lang_search_fields" => $lang['search_fields'],
    "lang_all_fields" => $lang['all_fields'],
    "lang_name_only" => $lang['name_only'],
    "lang_description_only" => $lang['description_only'],
    "lang_keywords_only" => $lang['keywords_only'],
    "category_dropdown" => get_category_dropdown($cat_id),

add below
(note the comma on the previous line)
Code: [Select]
    "category_dropdown" => get_category_dropdown($cat_id),
// NOCTURNAS
    "lang_nocturnal_images_only" => $lang['nocturnal_images_only']
// FIN NOCTURNAS

Now in page_header.php :

Find:
Code: [Select]
  "url_new_images" => $site_sess->url(ROOT_PATH."search.php?search_new_images=1"),
Add below :
Code: [Select]
// NOCTURNAS
  "url_nocturnal_images" => $site_sess->url(ROOT_PATH."search.php?search_nocturnal_images=1"),
// FIN NOCTURNAS

Now go to main.php of your language directory, and define (before ?> or in any place that you want):

Code: [Select]
$lang['nocturnal_images_only'] = "Sólo imágenes nocturnas";
("Sólo imágenes nocturnas" = "Only nocturnal images" in english).

Now you can add in your template pages the following code:

In search_form.html, the checkbox to limit the search to the images that have a positive value on the field "image_nocturnal":
Code: [Select]
<input type="checkbox" name="search_nocturnal_images" value="1" /> {lang_nocturnal_images_only}
And the link to show directly all the images with a positive value (on any page of your template):
Code: [Select]
<a href="{url_nocturnal_images}">
In case that someone ask:

If you want to look for non-positive (zero) values in the field too, you can put a second instance of the mod (just below the new code added), and change the variable, function and tag names, and replace:
Code: [Select]
$sql_where_query .= "AND i.image_nocturnal = 1 ";
with:
Code: [Select]
$sql_where_query .= "AND i.image_nocturnal = 0 ";
Well, that's it...
Best regards.
WR.

4
Hola gente.

Bueno soy nuevo por acá, más que nada porque estoy armando un sitio de fotografías y 4images me pareció la mejor opción.
La verdad me estoy volviendo loco con los mods...
Antes de preguntar, les dejo mi primera contribución:

Traduje el annotation mod al español, simplemente deben agregar lo que aquí les paso a \lang\spanish\admin.php

Code: [Select]
//-----------------------------------------------------
//--- Annotation Settings -----------------------------
//-----------------------------------------------------

$lang['nav_ann_settings'] = "Configuración de Annotation";
$lang['nav_ann_current_conv_tool'] = "actualmente está configurado como herramienta de conversión de imágenes";
$setting['annotation_use'] = "Utilizar nota automática de imágenes al subir imágenes.";
$setting['annotation_mode'] = "Modo de Nota<br /><span class=\"smalltext\">Seleccione si usar una nota de texto o de imagen</span>";
$annotation_mode_optionlist = array(
  "text"  => "texto",
  "image" => "imagen"
);
$setting['annotation_embed_image'] = "Imagen a incustar<br /><span class=\"smalltext\">Especifique la ruta completa y nombre de archivo de la imagen PNG</span>";
$setting['annotation_embed_image_opacity'] = "Opacidad de la imagen a insertar<br /><span class=\"smalltext\">Valor entre 0 y 100.</span>";
$setting['annotation_embed_image_bg'] = "Color de fondo de la imagen a insertar que se toma como transparencia<br /><span class=\"smalltext\">Defina un valor hexadecimal, por ejemplo: #000000. <a target=\"_blank\" href=\"color.html\">Ejemplos de colores</a></span>";
$setting['annotation_font'] = "Fuente (tipografía) de la nota &nbsp;&nbsp;<span class=\"smalltext\"><br>Especifique la ruta completa y nombre de archivo de fuente.<br>Para ImageMagick & librería GD: <b>TTF para Windows</b> solamente, para NetPBM: fuentes de formato <b>X-Windows BDF</b> solamente!</span>";
$setting['annotation_font_size'] = "Tamaño de la fuente";
$setting['annotation_use_shadow'] = "Usar sombras";
$setting['annotation_shadow_offset'] = "Desplazamiento de la sombra (el mismo a la derecha y abajo)";
$setting['annotation_image_quality'] = "Calidad de la imagen resultante: (en porcentaje)";
$setting['annotation_text'] = "Texto a incrustar <br /><span class=\"smalltext\">Las siguientes variables son válidas: <b>%N</b> - Nombre del sitio, <b>%H</b> - URL completa, <b>%U</b> - URL corta, <b>%S</b> - Nombre de usuario, <b>%D</b> - fecha, <b>%T</b> - hora, <b>%B</b> - baja una línea</span>";
$setting['annotation_fill_color'] = "Color de relleno del texto<br /><span class=\"smalltext\">Defina un valor hexadecimal, por ejemplo #FFFFFF. <a target=\"_blank\" href=\"color.html\">Ejemplos de colores en HEX</a></span>";
$setting['annotation_shadow_color'] = "Color de la sombra del texto <br /><span class=\"smalltext\">Defina un valor hexadecimal, por ejemplo,  #000000. <a target=\"_blank\" href=\"color.html\">Ejemplos de colores en HEX</a></span>";
$setting['annotation_fill_alpha'] = "Nivel de transparencia del color de relleno (alpha blending)<br /><span class=\"smalltext\">El valor de mezcla alpha debe estar entre 0.0 y 0.9&nbsp;&nbsp;&nbsp;&nbsp;0.0 = sin transparencia (sólido)</span>";
$annotation_fill_alpha_optionlist = array(
  "0.0"  => "0.0",
  "0.1"  => "0.1",
  "0.2"  => "0.2",
  "0.3"  => "0.3",
  "0.4"  => "0.4",
  "0.5"  => "0.5",
  "0.6"  => "0.6",
  "0.7"  => "0.7",
  "0.8"  => "0.8",
  "0.9"  => "0.9",
);
$setting['annotation_shadow_alpha'] = "Nivel de transparencia del relleno de la sombra (alpha blending)<br /><span class=\"smalltext\">El valos de mezcla alpha debe estar entre 0.0 y 0.9&nbsp;&nbsp;&nbsp;&nbsp;0.0 = sin transparencia (sólido)</span>";
$annotation_shadow_alpha_optionlist = array(
  "0.0"  => "0.0",
  "0.1"  => "0.1",
  "0.2"  => "0.2",
  "0.3"  => "0.3",
  "0.4"  => "0.4",
  "0.5"  => "0.5",
  "0.6"  => "0.6",
  "0.7"  => "0.7",
  "0.8"  => "0.8",
  "0.9"  => "0.9",
);
$setting['annotation_v_alignment'] = "Alineación vertical";
$setting['annotation_h_alignment'] = "Alineación horizontal";
$annotation_v_positioning_optionlist = array(
  "top"  => "por encima",
  "middle" => "al medio",
  "bottom" => "debajo"
);
$annotation_h_positioning_optionlist = array(
  "left"  => "borde izquierdo",
  "center"  => "centro",
  "right" => "borde derecho"
);
$setting['annotation_top_offset'] = "Margen superior";
$setting['annotation_bottom_offset'] = "Margen inferior";
$setting['annotation_left_offset'] = "Margen izquierdo";
$setting['annotation_right_offset'] = "Margen derecho";
?>

Y ahora sí, las preguntas:
Estoy probando todos los mods en mi PC antes de subir todo al hosting. Estoy armando, en un directorio aparte, un 4images con todos los mods instalados, de manera que una vez que suba los archivos al hosting "real", simplemente tenga que ejecutar la instalación del 4images, y luego la de cada mod. (en mi caso estoy probando con el auto-resize y el annotation, y tengo planeado agregar el exif).
Lo que sucede es que, en el caso del annotate, funciona perfecto el plug in (batch annotate), sin embargo no logro hacer que funcionen los tags (he probado %S y %N , que son los que usaré principalmente), en lugar de imprimir el dato simplemente implime las cadenas, como si la variable no estuviese definida. Tampoco pude lograr que incruste las notas al subir nuevas imágenes. Estoy muy seguro de que segui los pasos de instalación al pie de la letra.
Y el auto rezise tampoco funciona. Las opciones aparecen correctamente en el panel, pero no hay caso.

Alguno tiene alguna ayuda? es preferible hacer una instalación tradicional del 4 images y luego agregar los mods manualmente en el host?.

Saludos.
WR.

Pages: [1]