Could someone please help me understand these two functions (load and save). As best as I can tell these are the two functions I want to deal with. What I am thinking of doing is making a mod/hack/variant... (call it what you want) for a little project of mine but I want to store all of the data that gallery stores, along with quite a bit of additional information in a MySQL database. It looks to me like this is where all of the ".dat" magic takes place (reading and writing the .dat files). I don't want to modify anymore than necessary and I would think it should be pretty clean. I could be way off here but it seems that Gallery is just taking all of the data in an object, serializing it and storing it in a file, reading and unserializing it as needed. But what is the object and its structure? maybe I am over-simplifying this but any help would be appreciated.
Regards,
Richard
Posts: 10
Ok, I spent some time looking at one of the dat files and looking at the classes and I think I understand most of the data structure. Could someone please look this over and tell me if this is correct and clear up the ? data types? Please? If it is correct then I think I can pretty easily turn this into a few related tables. Then the only thing I need to know is are all interactions with the dat files done through the Load() and Save() functions?
Any help would be greatly appreciated,
Richard Benfield
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
<---Begin Data Structure--->
Album (Object)
-$dir (string)
-$updateSerial (int)
-$version (string)
-$tsilb (string)
-$fields (array)
-fields["title"] (string)
-fields["description"] (string)
-fields["nextname"] (string)
-fields["bgcolor"] (string)
-fields["textcolor"] (string)
-fields["linkcolor"] (string)
-fields["font"] (string)
-fields["border"] (int?string)
-fields["bordercolor"] (string)
-fields["returnto"] (string)
-fields["thumb_size"] (int?string)
-fields["resize_size"] (int?string)
-fields["rows"] (int?string)
-fields["cols"] (int?string)
-fields["fit_to_window"] (string)
-fields["use_fullOnly"] (string)
-fields["print_photos"] (string)
-fields["use_exif"] (string)
-fields["parentAlbumName"] (Album Object?string)
-fields["clicks"] (int)
-fields["clicks_date"] (int)
-fields["display_clicks"] (string)
-fields["public_comments"] (string)
-fields["serial_number"] (int)
-fields["name"] (string)
-fields["last_mod_time"] (int)
-fields["background"] (string)
-fields["owner"] (string)
-fields["perms"] (array)
-fields["perms"][$permName] (array)
-canRead (array)
-$photos (array of AlbumItem objects)
-AlbumItem (Object)
-$caption (string)
-$hidden (string?(Null))
-$highlight (boolean?)
-$isAlbumName (?(Null))
-$clicks (int)
-$keywords (string?(Null))
-$uploadDate (int)
-$exifData (?(Null))
-$itemCaptureDate (array)
-$itemCaptureDate["hours"] (int)
-$itemCaptureDate["minutes"] (int)
-$itemCaptureDate["seconds"] (int)
-$itemCaptureDate["mon"] (int?string)
-$itemCaptureDate["mday"] (int?string)
-$itemCaptureDate["wday"] (int)
-$itemCaptureDate["year"] (int)
-$itemCaptureDate["yday"] (int)
-$itemCaptureDate["weekday"] (string)
-$itemCaptureDate["month"] (string)
-$itemCaptureDate[?] (int)
-$thumbnail (Image Object)
-$highlightImage (Image Object)
-$image (Image Object)
-Image (Object)
-$name (string)
-$type (string)
-$width (int?string)
-$height (int?string)
-$resizedName (string)
-$thumb_x (int?(Null))
-$thumb_y (int?(Null))
-$thumb_width (int?(Null))
-$thumb_height (int?(Null))
-$raw_width (int?string)
-$raw_height (int?string)
-$version (int)
-$comments (Comment Object)
-Comment (Object)
-$commentText (string)
-$datePosted (string)
-$IPNumber (string)
-$name (string)
-$UID (string)
<---End Data Structure--->
</TD></TR></TABLE><!-- BBCode End -->
Posts: 10
ok, I came up with a data structure for the tables based on what I could find. I am still very unsure about some of these data types and their max lengths. I am begining to re-write the load and save functions. For now I have decided to have seperate functions called sql_load and sql_save. The save function will run both the normal file based save and the sql_save. The load function will try to load from sql_load first and failing that it will load from the file. Hopefully all goes well and I will be able to stop using the files at all. But for now this is how I will do it. If anyone would like to help or could even just go over the sql structure and tell me what, if anything, needs to be changed, it would be greatly appreciated.
Thanks,
Richard Benfield
<!-- BBCode Start --><TABLE BORDER=0 ALIGN=CENTER WIDTH=85%><TR><TD><font class="pn-sub">Code:</font><HR></TD></TR><TR><TD><FONT class="pn-sub"><PRE>
DROP TABLE IF EXISTS `gallery_album`;
CREATE TABLE `gallery_album` (
`gaid` INT (11) UNSIGNED AUTO_INCREMENT,
`dir` VARCHAR (100),
`updateSerial` BIGINT UNSIGNED,
`version` INT (5) UNSIGNED,
`tsilb` VARCHAR (100),
`fields_title` VARCHAR (100),
`fields_description` TEXT,
`fields_nextname` VARCHAR (100),
`fields_bgcolor` VARCHAR (20),
`fields_textcolor` VARCHAR (20),
`fields_linkcolor` VARCHAR (20),
`fields_font` VARCHAR (50),
`fields_border` VARCHAR (5),
`fields_bordercolor` VARCHAR (20),
`fields_returnto` VARCHAR (20),
`fields_thumb_size` VARCHAR (10),
`fields_resize_size` VARCHAR (10),
`fields_rows` VARCHAR (5),
`fields_cols` VARCHAR (5),
`fields_fit_to_window` VARCHAR (10),
`fields_use_fullOnly` VARCHAR (10),
`fields_print_photos` VARCHAR (20),
`fields_use_exif` VARCHAR (10),
`fields_parentAlbumName` VARCHAR (100),
`fields_clicks` INT (10) UNSIGNED,
`fields_clicks_date` INT (15) UNSIGNED,
`fields_display_clicks` VARCHAR (10),
`fields_public_comments` VARCHAR (10),
`fields_serial_number` INT (10) UNSIGNED,
`fields_name` VARCHAR (100),
`fields_last_mod_time` INT (15) UNSIGNED,
`fields_background` VARCHAR (100),
`fields_owner` VARCHAR (100),
PRIMARY KEY(`gaid`),
UNIQUE(`gaid`)
) TYPE=MyISAM;
DROP TABLE IF EXISTS `gallery_image`;
CREATE TABLE `gallery_image` (
`giid` INT (20) UNSIGNED AUTO_INCREMENT,
`name` VARCHAR (100),
`type` VARCHAR (10),
`width` VARCHAR (10),
`height` VARCHAR (10),
`resizedName` VARCHAR (100),
`thumb_x` VARCHAR (10),
`thumb_y` VARCHAR (10),
`thumb_width` VARCHAR (10),
`thumb_height` VARCHAR (10),
`raw_width` VARCHAR (10),
`raw_height` VARCHAR (10),
`version` INT (5) UNSIGNED,
PRIMARY KEY(`giid`),
UNIQUE(`giid`)
) TYPE=MyISAM;
DROP TABLE IF EXISTS `gallery_comments`;
CREATE TABLE `gallery_comments` (
`gcid` INT (20) UNSIGNED AUTO_INCREMENT,
`gaiid` INT (15) UNSIGNED,
`commentText` TEXT,
`datePosted` VARCHAR (20),
`IPNumber` VARCHAR (20),
`name` VARCHAR (100),
`UID` VARCHAR (50),
PRIMARY KEY(`gcid`),
UNIQUE(`gcid`)
) TYPE=MyISAM;
DROP TABLE IF EXISTS `gallery_photos`;
CREATE TABLE `gallery_photos` (
`gpid` INT (15) UNSIGNED AUTO_INCREMENT,
`gpa_index` INT (10) UNSIGNED,
`gaiid` INT (11) UNSIGNED,
`gaid` INT (11) UNSIGNED,
PRIMARY KEY(`gpid`),
UNIQUE(`gpid`)
) TYPE=MyISAM;
DROP TABLE IF EXISTS `gallery_albumitem`;
CREATE TABLE `gallery_albumitem` (
`gaiid` INT (15) UNSIGNED AUTO_INCREMENT,
`caption` VARCHAR (100),
`hidden` VARCHAR (10),
`highlight` TINYINT(1),
`isAlbumName` VARCHAR (10),
`clicks` INT (10),
`keywords` VARCHAR (100),
`uploadDate` INT (15),
`ICD_seconds` INT (3),
`ICD_minutes` INT (3),
`ICD_hours` INT (3),
`ICD_mday` VARCHAR (3),
`ICD_wday` VARCHAR (3),
`ICD_mon` VARCHAR (3),
`ICD_year` VARCHAR (5),
`ICD_yday` VARCHAR (5),
`ICD_weekday` VARCHAR (10),
`ICD_month` VARCHAR (20),
`ICD_0` VARCHAR (15),
`exifData` VARCHAR (200),
`thumbnail` INT (11) UNSIGNED,
`highlightImage` INT (11) UNSIGNED,
`image` INT (11) UNSIGNED,
PRIMARY KEY(`gaiid`),
UNIQUE(`gaiid`)
) TYPE=MyISAM;
</TD></TR></TABLE><!-- BBCode End -->
Posts: 10
I am nearing completion of my load_sql() function. I found one thing that is wrong with the above structure. comments is not the comment object but rather an array of comment objects. Should have been obvious but I missed it... anyway, i've got it straight now. my biggest concerns right now are the fields that I only have a Null value for right now. I am not sure what data type or length to expect for these. As before, if anyone can help de-mistify some of these for me I would greatly appreciate it.
Thanks,
Richard
Posts: 10
I had also somehow completely missed the permission array. I have that incorporated now. I would really appreciate some help with coding the save function. It should be very easy as I have already done the load and mapped the object structure and the sql structure. If anyone would like to help or just take a look at the code for the new load function please email me at (richard at benfield dot ws).
Thanks,
Richard