CustomFields - want to enhance

jerryh

Joined: 2013-02-04
Posts: 27
Posted: Tue, 2013-02-05 21:50

Module: CustomFields

I want to prefix this comment by I am new to Gallery2 and looking for additional information.

I am working on Gallery2 and want to enhance its features to add custom fields to items
upon uploading a new item. I basically want to ad a custom field value.
I am looking at CustomFieldHelper class as well as CustomFieldItemAdminController, CustomFieldItemEdit

Any additional information on this module would be helpful.

Thanks

SYSTEM INFO
Gallery URL = http://lantern.unavco.org/main.php
Gallery version = 2.3.2 core 1.3.0.2
API = Core 7.54, Module 3.9, Theme 2.6, Embed 1.5
PHP version = 5.2.5 apache2handler
Webserver = Apache/2.2.8 (Unix) DAV/2 mod_ssl/2.2.8 OpenSSL/0.9.8g PHP/5.2.5
Database = postgres7 8.2.5 3 9.0.4, lock.system=flock
Toolkits = ArchiveUpload, Exif, Getid3, LinkItemToolkit, Gd, Thumbnail
Acceleration = none, none
Operating system = SunOS lantern 5.10 Generic_120012-14 i86pc
Default theme = matrix
gettext = enabled
Locale = en_US
Browser = Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.57 Safari/537.17
Rows in GalleryAccessMap table = 40
Rows in GalleryAccessSubscriberMap table = 46
Rows in GalleryUser table = 3
Rows in GalleryItem table = 44
Rows in GalleryAlbumItem table = 15
Rows in GalleryCacheMap table = 0

PHP INFO
http://lantern.unavco.org/jerry.php

Remove this FAQ information from your post before submitting.

- Please add '[module / theme name]' along with specific subject in the title of your topic
- What information is required when asking for help in the forums?
http://codex.gallery2.org/index.php/Gallery2:faq#What_information_is_required_when_I_ask_for_help_in_the_forums.3F
- You can copy and paste a lot of the required information from "Site Admin" -> "Maintenance" -> "System Information" if your G2 is up and running.
- For development specific discussions, please use the forums in the Tech Zone


Gallery version (not just "2"):
Module / Theme name & version:
PHP version (e.g. 5.1.6):
PHPInfo Link (see FAQ):
Webserver (e.g. Apache 1.3.33):
Database (e.g. MySql 5.0.32):
Activated toolkits (e.g. NetPbm, GD):
Operating system (e.g. Linux):
Browser (e.g. Firefox 2.0):

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2013-02-05 22:48

You would need to create a CustomfieldOnUploadOption.inc to extend ItemAddOption
it would need to include methods handleRequestAfterAdd, loadTemplate and isAppropriate
@see /modules/core/ItemAdd.inc -> ItemAddOption

lastly you would need to registerFactoryImplementation for this in customfield/module.inc eg:

$ret = GalleryCoreApi::registerFactoryImplementation('ItemAddOption',
     'CustomfieldOnUploadOption', 'CustomfieldOnUploadOption',
     'modules/customfield/CustomfieldOnUploadOption.inc', 'customfield', null);
if ($ret) {
    return $ret;
}

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
jerryh

Joined: 2013-02-04
Posts: 27
Posted: Tue, 2013-02-05 23:21

Thank you. This is helpfule.. I will take a look.

I am looking at CustomField still at lower levels (Database) just to see whats going on.
First I only see one database table for custom field called gs_CustomFieldMap.
When I create a new field for an album, I don't see an entry in the table. However, once I give it a value , then its written into table.
Is there another table being leveraged when I create the field?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Tue, 2013-02-05 23:30

Interacting with the table directly would not be the gallery way of doing things.

Looking at CustomFieldItemEdit.inc should give you enough info to know how to react in handleRequestAfterAdd

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
jerryh

Joined: 2013-02-04
Posts: 27
Posted: Tue, 2013-02-05 23:59

Correct. I am trying to learn whats going on with the system. Thanks...

 
jerryh

Joined: 2013-02-04
Posts: 27
Posted: Wed, 2013-02-06 00:10

So Another similar question.... We will be doing batch uploads of photos/albums.
Would this be similar for Albums? If I create a new album through API

for creating new albums programmitcally, where do you suggest the best place to look? ItemAddAlbum.inc

 
jerryh

Joined: 2013-02-04
Posts: 27
Posted: Thu, 2013-02-07 21:45

loadTemplate is for UI - if we need one
isAppropriate -- Just return "true"?
/**
* Is this option appropriate at this time?
*
* @param GalleryItem $item
* @param GalleryDerivative $thumbnail
* @return array GalleryStatus a status code
* boolean true or false
*/
function isAppropriate($item, $thumbnail) {
return array(null, false);
}

 
jerryh

Joined: 2013-02-04
Posts: 27
Posted: Thu, 2013-02-07 22:06

I meant

function isAppropriate($item, $thumbnail) {
return array(null, true);
}

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2013-02-07 22:06
Quote:
isAppropriate -- Just return "true"?

Did you make onUpload an option in admin? if so is the option set to true?

    function isAppropriate() {
        list($ret, $onUpload) = GalleryCoreApi::getPluginParameter('module', 'customfield', 'onUpload');
        if ($ret) {
            return array($ret, false);
        }
        return array(null, $onUpload > 0);
    }

if not, just return array(null, true);

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Thu, 2013-02-07 22:16

isAppropriate receives no parameters

-s
________________________________
All New jQuery Minislideshow for G2/G3

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Fri, 2013-02-08 04:35