OK sorry, here’s each file I have edited... might not be pretty but I have tried my best to understand the new way of working.
I am using MODx Revolution 2.0.4-pl2 and your Gallery snippet 1.0.1-rc2.
I have highlighted my editions with a line of ***.
FILE - assets/components/gallery/js/mgr/widgets/album
GAL.panel.Album = function(config) {
config = config || {};
Ext.apply(config,{
id: 'gal-panel-album'
,url: GAL.config.connector_url
,baseParams: {}
,border: false
,baseCls: 'modx-formpanel'
,items: [{
html: '<h2>'+_('gallery.album')+'</h2>'
,border: false
,id: 'gal-album-header'
,cls: 'modx-page-header'
},{
xtype: 'modx-tabs'
,bodyStyle: 'padding: 10px'
,defaults: { border: false ,autoHeight: true }
,border: true
,activeItem: 0
,hideMode: 'offsets'
,items: [{
title: _('general_information')
,layout: 'form'
,items: [{
xtype: 'statictextfield'
,fieldLabel: _('id')
,name: 'id'
,submitValue: true
},{
xtype: 'textfield'
,fieldLabel: _('name')
,name: 'name'
,width: 250
,allowBlank: false
},
*************************
{
xtype: 'textfield'
,fieldLabel: ('Movie Director')
,name: 'director'
,width: 250
,allowBlank: false
}
,{
xtype: 'checkboxgroup',
fieldLabel:'genre',
columns:2,//showing two columns of checkboxes
items:[
{boxLabel: 'action', name: 'genre[action]', inputValue: true},
{boxLabel: 'horror', name: 'genre[horror]', inputValue: true},
{boxLabel: 'comedy', name: 'genre[comedy]', inputValue: true}
]
},
*************************
{
xtype: 'textfield'
,fieldLabel: ('Minimum Requirements')
,name: 'req'
,width: 250
,allowBlank: false
}
,{
xtype: 'datefield',
name: 'releasedate',
fieldLabel: 'Release date',
allowBlank: false,
width: 250,
}
,{
xtype: 'textarea'
,fieldLabel: _('description')
,name: 'description'
,width: 400
},{
xtype: 'checkbox'
,fieldLabel: _('gallery.active')
,description: _('gallery.active_desc')
,name: 'active'
,inputValue: true
},{
xtype: 'checkbox'
,fieldLabel: _('gallery.prominent')
,description: _('gallery.prominent_desc')
,name: 'prominent'
,inputValue: true
}
,{
html: '<hr />',border: false
}
,{
xtype: 'gal-panel-album-items'
,cls: 'modx-pb-view-ct'
,album: config.album
}]
}/*,{
title: 'Context Access'
,layout: 'form'
,items: [{
html: '<p>Manage the Contexts that have access to this album.</p><br />'
,border: false
}]
}*/]
}]
,listeners: {
'setup': {fn:this.setup,scope:this}
,'beforeSubmit': {fn:this.beforeSubmit,scope:this}
,'success': {fn:this.success,scope:this}
}
});
GAL.panel.Album.superclass.constructor.call(this,config);
};
Ext.extend(GAL.panel.Album,MODx.FormPanel,{
setup: function() {
if (!this.config.album) return;
MODx.Ajax.request({
url: this.config.url
,params: {
action: 'mgr/album/get'
,id: this.config.album
}
,listeners: {
'success': {fn:function(r) {
this.getForm().setValues(r.object);
Ext.getCmp('gal-album-header').getEl().update('<h2>'+_('gallery.album')+': '+r.object.name+'</h2>');
},scope:this}
}
});
}
,beforeSubmit: function(o) {
Ext.apply(o.form.baseParams,{
});
}
,success: function(o) {
Ext.getCmp('dis-btn-save').setDisabled(false);
}
});
Ext.reg('gal-panel-album',GAL.panel.Album);
GAL.panel.AlbumItems = function(config) {
config = config || {};
this.view = MODx.load({
id: 'gal-album-items-view'
,xtype: 'gal-view-album-items'
,onSelect: {fn:function() { }, scope: this}
,containerScroll: true
,ident: this.ident
,cls: 'gal-view-album-items'
,album: config.album
,inPanel: true
,style: 'overflow: auto;'
});
this.view.pagingBar = new Ext.PagingToolbar({
pageSize: 24
,store: this.view.store
,displayInfo: true
,autoLoad: true
});
var dv = this.view;
dv.on('render', function() {
dv.dragZone = new MODx.DataView.dragZone(dv);
dv.dropZone = new MODx.DataView.dropZone(dv);
});
Ext.applyIf(config,{
id: 'gal-panel-album-items'
,cls: 'browser-win'
,layout: 'column'
,minWidth: 500
,minHeight: 350
,width: '90%'
,autoHeight: true
,modal: false
,closeAction: 'hide'
,border: false
,autoScroll: true
,items: [{
id: 'gal-album-items-ct'
,cls: 'browser-view'
,region: 'center'
,width: '80%'
,height: 450
,autoScroll: true
,border: false
,items: [{
xtype: 'toolbar'
,items: [{
xtype: 'button'
,text: _('gallery.item_upload')
,handler: this.uploadItem
,scope: this
},'-',{
xtype: 'button'
,text: _('gallery.batch_upload')
,handler: this.batchUpload
,scope: this
}]
},this.view]
,bbar: [this.view.pagingBar]
},{
html: ''
,id: 'gal-album-items-detail'
,region: 'east'
,split: true
,autoScroll: true
,width: '20%'
,minWidth: 150
,maxWidth: 250
,height: 450
,border: false
}]
});
GAL.panel.AlbumItems.superclass.constructor.call(this,config);
};
Ext.extend(GAL.panel.AlbumItems,MODx.Panel,{
windows: {}
,handleSort: function(o) {
var s = this.view.store;
console.log(o);
return;
var origRec = s.getAt(o.sourceId);
var lastRec = s.getAt(o.targetId);
MODx.Ajax.request({
url: this.config.url
,params: {
action: 'item/sort'
,album: this.config.album
,source: o.sourceIndex
,target: o.targetIndex
}
});
}
,uploadItem: function(btn,e) {
var r = {
album: this.config.album
,active: true
};
if (!this.windows.uploadItem) {
this.windows.uploadItem = MODx.load({
xtype: 'gal-window-item-upload'
,listeners: {
'success': {fn:function() { this.view.run(); },scope:this}
}
});
}
this.windows.uploadItem.fp.getForm().reset();
this.windows.uploadItem.setValues(r);
this.windows.uploadItem.show(e.target);
}
,batchUpload: function(btn,e) {
var r = {
album: this.config.album
,active: true
};
if (!this.windows.batchUpload) {
this.windows.batchUpload = MODx.load({
xtype: 'gal-window-batch-upload'
,listeners: {
'success': {fn:function() { this.view.run(); },scope:this}
}
});
} else {
this.windows.batchUpload.fp.getForm().reset();
}
this.windows.batchUpload.setValues(r);
this.windows.batchUpload.show(e.target);
}
});
Ext.reg('gal-panel-album-items',GAL.panel.AlbumItems);
GAL.window.UploadItem = function(config) {
config = config || {};
this.ident = config.ident || 'gupit'+Ext.id();
Ext.applyIf(config,{
title: _('gallery.item_upload')
,id: this.ident
,height: 150
,width: 475
,url: GAL.config.connector_url
,action: 'mgr/item/upload'
,fileUpload: true
,fields: [{
xtype: 'hidden'
,name: 'album'
},{
xtype: 'textfield'
,inputType: 'file'
,fieldLabel: _('gallery.file')
,name: 'file'
,id: 'gal-'+this.ident+'-file'
},{
xtype: 'textfield'
,fieldLabel: _('name')
,name: 'name'
,id: 'gal-'+this.ident+'-name'
,width: 300
}
,{
xtype: 'textarea'
,fieldLabel: _('description')
,name: 'description'
,id: 'gal-'+this.ident+'-description'
,width: 300
},{
xtype: 'checkbox'
,fieldLabel: _('gallery.active')
,name: 'active'
,description: ''
,id: 'gal-'+this.ident+'-active'
,checked: true
,inputValue: 1
},{
xtype: 'textfield'
,fieldLabel: _('gallery.tags')
,description: _('gallery.comma_separated_list')
,name: 'tags'
,id: 'gal-'+this.ident+'-tags'
}]
});
GAL.window.UploadItem.superclass.constructor.call(this,config);
};
Ext.extend(GAL.window.UploadItem,MODx.Window);
Ext.reg('gal-window-item-upload',GAL.window.UploadItem);
GAL.window.BatchUpload = function(config) {
config = config || {};
this.ident = config.ident || 'gupbu'+Ext.id();
Ext.applyIf(config,{
title: _('gallery.batch_upload')
,id: this.ident
,height: 150
,width: 475
,url: GAL.config.connector_url
,action: 'mgr/item/batchupload'
,fileUpload: true
,fields: [{
xtype: 'hidden'
,name: 'album'
},{
html: _('gallery.batch_upload_intro')
,border: false
},MODx.PanelSpacer,{
xtype: 'textfield'
,fieldLabel: _('gallery.directory')
,name: 'directory'
,id: 'gal-'+this.ident+'-directory'
,width: 300
,value: MODx.config['gallery.default_batch_upload_path'] || '{assets_path}images/'
},{
xtype: 'checkbox'
,fieldLabel: _('gallery.active')
,name: 'active'
,description: ''
,id: 'gal-'+this.ident+'-active'
,checked: true
,inputValue: 1
},{
xtype: 'textfield'
,fieldLabel: _('gallery.tags')
,description: _('gallery.batch_upload_tags')
,name: 'tags'
,id: 'gal-'+this.ident+'-tags'
,width: 300
}]
});
GAL.window.BatchUpload.superclass.constructor.call(this,config);
};
Ext.extend(GAL.window.BatchUpload,MODx.Window);
Ext.reg('gal-window-batch-upload',GAL.window.BatchUpload);
FILE - core/components/gallery/model/gallery/mysql/galalbum.map.inc.php
<?php
/**
* @package gallery
*/
$xpdo_meta_map['galAlbum']= array (
'package' => 'gallery',
'table' => 'gallery_albums',
'fields' =>
array (
'parent' => 0,
'name' => '',
'description' => '',
'createdon' => NULL,
'createdby' => 0,
'rank' => 0,
'active' => 0,
'prominent' => 0,
'watermark' => '',
*************************
'director' => '',
'genre' => '',
*************************
),
'fieldMeta' =>
array (
'parent' =>
array (
'dbtype' => 'int',
'precision' => '10',
'phptype' => 'integer',
'attributes' => 'unsigned',
'null' => false,
'default' => 0,
'index' => 'index',
),
'name' =>
array (
'dbtype' => 'varchar',
'precision' => '255',
'phptype' => 'string',
'null' => false,
'default' => '',
'index' => 'index',
),
*************************
'director' =>
array (
'dbtype' => 'varchar',
'precision' => '255',
'phptype' => 'string',
'null' => false,
'default' => '',
'index' => 'index',
),
'genre' =>
array (
'dbtype' => 'varchar',
'precision' => '100',
'phptype' => 'array',
'null' => false,
'default' => '',
'index' => 'index',
),
*************************
'description' =>
array (
'dbtype' => 'text',
'phptype' => 'string',
'null' => false,
'default' => '',
),
'createdon' =>
array (
'dbtype' => 'datetime',
'phptype' => 'datetime',
'null' => true,
),
'createdby' =>
array (
'dbtype' => 'int',
'precision' => '10',
'phptype' => 'integer',
'attributes' => 'unsigned',
'null' => false,
'default' => 0,
'index' => 'index',
),
'rank' =>
array (
'dbtype' => 'int',
'precision' => '10',
'phptype' => 'integer',
'attributes' => 'unsigned',
'null' => false,
'default' => 0,
),
'active' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
'phptype' => 'integer',
'attributes' => 'unsigned',
'null' => false,
'default' => 0,
),
'prominent' =>
array (
'dbtype' => 'tinyint',
'precision' => '1',
'phptype' => 'integer',
'attributes' => 'unsigned',
'null' => false,
'default' => 0,
),
'watermark' =>
array (
'dbtype' => 'varchar',
'precision' => '255',
'phptype' => 'string',
'null' => false,
'default' => '',
),
),
'aggregates' =>
array (
'Parent' =>
array (
'class' => 'galAlbum',
'local' => 'parent',
'foreign' => 'id',
'cardinality' => 'one',
'owner' => 'foreign',
),
'CreatedBy' =>
array (
'class' => 'modUser',
'local' => 'createdby',
'foreign' => 'id',
'cardinality' => 'one',
'owner' => 'foreign',
),
),
'composites' =>
array (
'AlbumItems' =>
array (
'class' => 'galAlbumItem',
'local' => 'id',
'foreign' => 'album',
'cardinality' => 'many',
'owner' => 'local',
),
'Contexts' =>
array (
'class' => 'galAlbumContext',
'local' => 'id',
'foreign' => 'album',
'cardinality' => 'many',
'owner' => 'local',
),
'Children' =>
array (
'class' => 'galAlbum',
'local' => 'id',
'foreign' => 'parent',
'cardinality' => 'many',
'owner' => 'local',
),
),
);
I created the new fields in the database, everything is being sent correctly. If I create a new gallery and I am in the gallery edit area I see the new options. If I fill them out this works as expected. The checkboxgroup is being sent as an array, the database shows this info if 2 checkboxes are clicked like this...
a:2:{s:2:"horror";s:4:"true";s:3:"action";s:4:"true";}"
The feed in the connector.php displayed in Firebug shows
"genre":"a:2:{s:2:\"horror\";s:4:\"true\";s:3:\"action\";s:4:\"true\";}",
After the new selections are sent and saved the feed back to the gallery does have the checkbox array but what I do not know how to do is say checkbox X and Y are present in the database so make them checked on the gallery edit page. The reason I am using checkboxgroups is to keep all related information together so it’s easily searched, also this is a very basic example of what I am trying to do and I want to keep all related data together in the database.
So basically I have everything working, I just don’t know how to say to the gallery edit page that this checkbox of checkboxgroup genre has been clicked according to the database so display it as checked.
I hope this is enough information to help.