CVS edit link for himue

For long time i've searched for a simple picture-gallery working out of the box.
All suggestions i've read in the meantime are to complicated, complex or not usable for me. I've found, that many other users have the same problem.

Therefore I wrote my own picture-gallery. It implements a new node-type to show all pictures in an specified directory. Descriptions will be automatically generated from the filenames, so there is no need to administer a seperate databse table, etc.
My gallery works with automated generetated thumbnails so it seems to be fast.
It can use Lightbox2 to simply generate lightshows and naturally it makes use of user configurable css-files to style the gallery. Some styles will be delivered with the module, so users don't eb worried about this.

several other features you can use (but not must use) are described in the README.txt

Comments

himue’s picture

Title: himue [himue] » himuesgallery [himue]
Assigned: Unassigned » himue
Issue tags: -Module review
StatusFileSize
new15.07 KB

All Documentation of the module himuesgallery is in the README.txt

A live example can be found under http://st-michael.de/node/27

avpaderno’s picture

Status: Postponed (maintainer needs more info) » Needs review
Issue tags: +Module review

Hello, and thanks for applying for a CVS account. I am adding the review tags, and some volunteers will review your code, reporting what needs to be changed.

I would suggest to expand the description of the proposed project, and report the differences between it and the existing projects. The
other modules are too complicated, and I created a simpler module reason is not sufficient to add a project that duplicates the work done in other projects (see http://drupal.org/node/539608).

himue’s picture

Hello and thanks for reply.

you tell me to explain the differeences betwenn my gallery and the gallery in other Projects.
I thought I've described something in the second parapraph of my original description, but i will do it detailed here.

Other gallery projects have I've found have an enourmous complexity to copy files on the webspace, to put the description of the pictures in a database and to sort the pictures in the order you want to show it to the visitor.
All what you have to do with himuesgallery is to put the pictures in a directory on webspace, create a new node from type himuesgallery, maybe select some presettings and your visitor will get a wellformated picture-gallery with descriptions, that are automatically generated descriptions under the pictures.

I'll try to compare some differences (O: = other gallerys; H: = himuesgallery)

O: You have to use a filemanger to put files on webspace. With many filemangers this is sometimes difficult and use a lot of time.
H: You can use filemanagers to, but you also can copy your files with your favorite ftp-programm.

O: Some programs upload files to a temporary directory an then copy it anywhere on the webserver. If you want to find it in the webservers filestructure, you have to do a long search.
H: The pictures will allways reside in the directory where you upload it. No matter to search for.

O: After you upload the files to webserver you have to describe the pictures manually and put the descriptions in an database.
H: description will automatically generated from the filenames of the pictures.

O: If you want to change the description, you have to search and change the corresponding database entry.
H: Change a description is simply done by renaming the file.

O: You have to do a "mouse orgy" to sort pictures in the way you want. I know, drag and drop is simple but cost a lot of time.
H: You order the pictures by giving the filename a leading number. E.g.: you name a file "001-This is the first picture.jpg" and "005-This ist the second picture.gif". Picters will then be sorted by the leading number, but the number will not be shown shown in description. In this exapmle the description will be "This is the first picture" for the first and "This ist the second picture" for the second.

O: To add or delete pictures you have to put the fiels on webserver and add a description to the database. Then you have to reorder the pictures if the new one should be betwenn 2 existing pictures.
H: To add a picture you simply copy it to the picture directory on webspace (eg. by using a filemanager or simply by using your ftp-programm). I'v you name your files with leading numbers like described before, it is very simple to insert a new picture betwenn 2 existing. Let's say you have pictures namen "005-File1.jpg", "010-File2.jpg" and "015-File3.jpg". to insert a picture named NewOne.jpg between File1 and File2 simply name it 007-NewOne.jpg" and copy t to the webspace.

O: To delete a picture you have to got to the website, delete the corresponding entry in drupal and maybe you have to delete the picture manually.
H: To delete a picture you simply delete the file from webspace.

O: I've found no gallery where you can highlight parts of the description.
H: In himuesgallery there are tags wich you can use in filename to do some highlighting.
Some examples:
- You have a file namend "001-This is RED text.jpg" you put to tags in filename like "001-This is .red.RED.-red. text.jpg" and the word RED will be shown in red color to the visitor.
- You name a file "this description have .qm.quotation mark.qm. in it.jpg and it will be shown as "this description have "quotation mark" in it".
- You name a file "001-Whats this.qe..jpg". The visitor will see se description "Whats this?"
There are lot of more tags you can use. All will be described in READEME.txt

O: Other gallerys can use tools like Lightbox2 to show pictures.
H: Himuesgallery also can use use Lightbox2 but contrary to other gallerys you need only a few mouse-clicks to change from showing single pictures to showing a slide show.

O: I know, many of the gallerys I've tried can format the output using css-files, but either I'm to stupid to find the css-files or I can only use one css-file for all my gallerys on a site.
H: Himuesgallery also use css-files to format the output. There are yome predefined css-files in the css-subfolder of the module-dir. You can put your own files there and then selsect the one you want to use in a dropdownbox on node-creation.
You also can tell the gallery-node to search for a css-file named himeusgallery.css in the picture-dir. So you can have your own css for any gallery.

O: Often i found no way to put some kind of longer text (intoducten, etc.) in top of the gallery.
H: In hiemuesgallery you simply fill the textfield (body) of the node. You can use HTML or WYSYWIG-editors to create it.

Hope this helps and meet your requirements of description.

himue’s picture

Title: himuesgallery [himue] » Corrected version
Assigned: himue » Unassigned
Issue tags: +Module review
StatusFileSize
new9.4 KB

Hello.

I've reviewed my code an have found some missing t()-functions etc.

Attachement is the final code.

Greetings,
himue

dave reid’s picture

Title: Corrected version » himue [himue]
avpaderno’s picture

Status: Needs review » Needs work
  1. Schema descriptions should not be passed to t(); see what Drupal core modules do.
  2. require_once("himuesgallery.php");
    

    If the code is always included, then it is better to merge the files. There is not pro to separate two files, if then one is always included. The purpose to write code in separated files is to reduce the memory usage, but that doesn't happen in this case, where there is also a delay caused by loading a file.

  3.   //Wir geben ein Array zurück, weil ein Modul mehrere Node-Typen definieren kann.
      //Wir definieren nur einen Node-Typ 'himuesgallery'
    

    Code comments should be written in English.

  4.   $form['meine'] = array(
        '#title' => t('Gallerie Settings'),
        '#type' => 'fieldset',
        '#collapsible' => TRUE,
        '#weight' => -10
      );
    

    Strings used in the user interface should be in sentence case, not title case.

  5.   $form['meine']['thumbnail_sort_order'] = array(
        '#type' => 'radios',
        '#required' => TRUE,
        '#title' => t('Sortorder for thumbnails (0=asc, 1=desc)'),
        '#options' => array(
          t('asc'),
          t('desc')
        ),
        '#default_value' => isset($node->thumbnail_sort_order) ? $node->thumbnail_sort_order : 0,
        '#weight' => -1,
      );
    

    meine should be main. Then the form item should be simply write as

      $form['thumbnail_sort_order'] = array(
        '#type' => 'radios',
        '#required' => TRUE,
        '#title' => t('Sortorder for thumbnails (0=asc, 1=desc)'),
        '#options' => array(
          t('asc'),
          t('desc')
        ),
        '#default_value' => isset($node->thumbnail_sort_order) ? $node->thumbnail_sort_order : 0,
        '#weight' => -1,
      );
    

    It's useless to group form fields when there is just a group (the meine group).

  6. function _himuesgallery_convert_description($description) {
      $description=str_replace(".br.", "<br>", $description);                  //break
      $description=str_replace(".-i.", "</i>", $description);                  //italic off
      $description=str_replace(".i.", "<i>", $description);                    //italic on
      $description=str_replace(".-b.", "</b>", $description);                  //bold off
      $description=str_replace(".b.", "<b>", $description);                    //bold on
      $description=str_replace(".ap.", "'", $description);                     //apostroph
      $description=str_replace(".es.", "'", $description);                     //apostroph
      $description=str_replace(".af.", '"', $description);                     //question mark
      $description=str_replace(".qm.", '"', $description);                     //question mark
      $description=str_replace(".bs.", "\"", $description);                    //backslash
      $description=str_replace(".-red.", "</font>", $description);             //red text off
      $description=str_replace(".red.", "<font color=red>", $description);     //red text on
      $description=str_replace(".-blue.", "</font>", $description);            //blue text off
      $description=str_replace(".blue.", "<font color=blue>", $description);   //blue text on
      $description=str_replace(".-green.", "</font>", $description);           //green text off
      $description=str_replace(".green.", "<font color=green>", $description); //green text on
      $description=str_replace("_", " ", $description);                        //replace underline with space
      $description=str_replace(".qe.", '?', $description);                     //question mark
      $description=str_replace(".fz.", '?', $description);                     //question mark
      $description=str_replace(".-right.", "</div>", $description);            //right-align text off
      $description=str_replace(".right.", "<div align=right>", $description);  //right-align text on
      $description=str_replace(".-left.", "</div>", $description);             //left-align text off
      $description=str_replace(".left.", "<div align=left>", $description);    //left-align text on
      $description=str_replace(".center.", "", $description);     
    

    All that code can be replaced with a single call to str_replace().

  7.   $Seitenverhaeltnis=10/15;
      $UmgekehrtesSeitenverhaeltnis=15/10;
    

    Also variables should use English words.

  8.     while ($file = @readdir ($handle))
        {
          //Test, if this is one of the supported filetypes. Otherwise ignore the file.
          $extension=substr($file,-4);
          if ((strtoupper($extension) == ".JPG") or (strtoupper($extension) == ".PNG") or (strtoupper($extension) == ".GIF")) {
            $files[$i]['File']=$file;
            
            //If first three charachters are an integer and fourth character is an "-" then dont show these charachters
            //So you can sort the files in any aorder you want if you number it
            if (((intval(substr($file,0,3)))<>0) AND ($file[3]=="-")) {
              $files[$i]['description'] = substr($file,4,-4);
            }
            //if no leading integer, the first 4 charachters are member of the filename.
            else {
              $files[$i]['description'] = substr($file,0,-4);
            }
    

    There is a Drupal function to scan a directory content. The code should use the Drupal Unicode functions, when available.

  9.     if ($node->thumbnail_sort_order<>0) {
          @rsort($files);
        }
        else {
          @sort($files);
        }
    

    There is no reason to suppress error warnings, in that case; the function doesn't emit any warning message.

  10. See http://drupal/coding-standards to understand how a module should be written; in particular, see how could should be formatted, and how constants should be written.
  11. <?php
    // $Id$
    /**
     * @file
     * Callbacks of thes administration site for himues gallery 
     */
     
    /**
     * Form creation
     *
     * @incggroup forms
     * @see system_settings_form().
     */
    function himuesgallery_admin_settigs() {
      $files_dir=file_directory_path();
      
      $form['himuesgallery_admin_settigs'] = array(
        '#type' => 'textfield',
        '#title' => t('The base directory of the gallerys for this site relativ to "%files_dir"', array('%files_dir' => $files_dir)), 
        '#default_value' => variable_get('himuesgallery_admin_settigs', ('himuesgallery')),
      );
      
      return system_settings_form($form);
    }
    

    There is no reason to create a file for that code; it can stay on the module file.

himue’s picture

Status: Needs work » Needs review
StatusFileSize
new8.93 KB

I think, i've considerd all your suggestions.

Only one comment on point 5:
I've changed "meine" to "main".
I think the group is'nt useless, because i found no other way to prevent, that "Menu settings" will between the body-field "Info-text in top of the gallery" and the rest of my settings.

Greetings,
himue

avpaderno’s picture

I think the group is'nt useless, because i found no other way to prevent, that "Menu settings" will between the body-field "Info-text in top of the gallery" and the rest of my settings.

To accomplish that is enough to set the weight of the fields, or add all the settings in a fieldset.

himue’s picture

To accomplish that is enough to set the weight of the fields,

With the weight-settings i'm not able to get the fields in the order i want. Don't know why, but there are allways problems with the body field or the menu-fieldset...

or add all the settings in a fieldset

Maybe i'm wrong, but when you look in #6 point 4.)
Isn't this the definition of an fieldset? (I'vre renamed "meine" in "main" allredy).

Thanks,
Himue

avpaderno’s picture

Status: Needs review » Needs work
package = Himues Developement

The package name is not supposed to be used to report who developed the module; as this is just a single module, and not a set of modules, the package ID used should be one already used by other projects (User interface, in example), or it should not reported.

variable_get('himuesgallery_admin_settigs', ('himuesgallery'))

The parentheses surrounding the string are not necessary.

  t('You have to select a css file'));

css should be written in upper case letters.

  //read the subdirs under the gallery-standard-path wich is set in administration
  $himuesgallery_path = file_directory_path() . "/" . variable_get('himuesgallery_admin_settigs', '');
  $array_of_dirs = glob($himuesgallery_path . '/*', GLOB_ONLYDIR);

There is a Drupal function to get the content of a directory.

/**
 * delete the thumbnails
 */
function _himuesgallery_delete_thumbnails($path) {
  if (is_dir($path)) {
    $handle = opendir($path);
    
    while ($file = readdir ($handle)) {
      $prefix=substr($file, 0,6);
      $prefix=strtoupper($prefix);
      if ($prefix=="THUMB.") unlink($path."/".$file);
    }
    closedir($handle);
    drupal_set_message(t("himuesgallery: Thumbnails renewed."));
  }
}

There is a Drupal function to scan the content of a directory. The code should also use the Drupal Unicode functions.

See http://drupal/coding-standards, which reports how PHP constants should be written, and how the code should be formatted.

himue’s picture

StatusFileSize
new8.86 KB

Thanks for reply.

I hope, i've considered all of your hints.
"Code review" from the coding module shows no errors/hints.

Himue

himue’s picture

Status: Needs work » Needs review
avpaderno’s picture

Status: Needs review » Fixed
if ($dir->name == "") $array_of_dirs[] = $dir->filename;

The curly brackets are not considered optional from Drupal coding standards. The code is correctly written as

if ($dir->name == "") {
  $array_of_dirs[] = $dir->filename;
}

Before, and after the operator = there should be a space ($variable = 'value'); that is true also for the other operators.

Thank you for your contribution! I am going to update your account.
These are some recommended readings to help with excellent maintainership:

You can find more contributors chatting on the IRC #drupal-contribute channel. So, come hang out and stay involved.
Thank you, also, for your patience with the review process.
Anyone is welcome to participate in the review process. Please consider reviewing other projects that are pending review. I encourage you to learn more about that process and join the group of reviewers.

I thank all the dedicated reviewers as well.

himue’s picture

O.k., i've fixed this.

Thanks for help,
himue

Status: Fixed » Closed (fixed)
Issue tags: -Module review

Automatically closed -- issue fixed for 2 weeks with no activity.

avpaderno’s picture

Component: Miscellaneous » new project application
Assigned: Unassigned » avpaderno
Issue summary: View changes