|
View Documentation
|
||
Gallery Merge Documentation: |
||
|
See readme.php (or readme.txt) for documentation on main Gallery Merge Plugin. This file describes support for Gallery Merge to process data tables from other plugins during a merge. |
||
|
Gallery Merge Plugin Support for Other Plugin's Data: |
||
|
Of course there are many plugins available for use with CPG, and many of them need consideration during Gallery Merge. Those that add features without altering the structure of CPG tables (adding columns, etc) or without adding their own CPG tables can often be addressed just by insuring the same plugin in installed in the Target gallery. However, those that alter the structure of CPG tables, or add their own tables, have other considerations.
Those altering structure MUST be installed in the target gallery, or our generated SQL to merge galleries will not match the structure of the
Target table. (Even if SQL were generated to account for this difference - you would lose the data in the altered fields..) During Merge simulation and execution, the plugins installed in the Source galery will be matched to the Target, and our knowledge base. Exceptions will be noted. Critical exceptions (plugins missing that are known to ALTER CPG tables) will flag a warning and prevent execution. |
||
|
Plugin Knowledge Base: |
||
|
Obviously I don't know about all plugins, nor could I possibly research them all... but you can help! An interface is provided to allow easy addition of knowledge about other plugins,
and where needed to add support for plugin added data tables - retaining any mappings to data in the core Coppermine tables affected by the merge.
data/plugin_data.php defines all 'known' plugins, and their impact on Gallery Merge. Plugins can be added to the array defined there to:
The information needed about a plugin is very simple:
EXAMPLE:
'folder_name' => array( // (folder name this plugin adds)
'alters_cpg_tables' => {TRUE|FALSE|unknown}, // (changes CPG base tables STRUCTURES - adding columns, etc)
'adds_tables' => {TRUE|FALSE|unknown}, // (adds any new tables)
'table_pattern' => '{pattern}', // (patten to match for this plugins tables (that follows cpg table prefix)
'standard_folders' => {TRUE|FALSE|unknown}, // (FALSE if folder is outside of plugins directory - should only be older 'mods')
'plugin_name' => '{name}', // (name of plugin - may vary by language - only used in messages)
'merge_script' => '{merge_plugin_{pluginfoldername}|needed|unknown|n/a}', // (script to include if merge is supported for this table - .php suffix added of course)
// ****** remaining fields only required if 'merge_script' is provided ******
'pid_sql' => 'SELECT SQL to return list of PIDs') // If merge script translation will require picture (pid) information, provide SQL to generate a result
// set of PIDs that we care about... Only required PIDs are mapped to conserve memory
// in SQL use {cpg_table_prefix} to represent prefix...
|
||
|
Plugin Merge Scripts: |
||
|
For those plugins adding their own tables, the mapping and processing already part of Gallery Merge can be used to support these tables, and where needed - custom code can be provided -
but many will be able to be handled with just a little research and some parameter settings.
A skeleton is provided to clone for each supported plugin - start with 'plugins/gallery_merge/merge_plugin_skeleton.php' which contains an example of each type of process. When to use this script:
Parameters:
If none of the opions above will work for your plugin's tables - then you can provide your own functions to handle the data (process_type of 'custom') or combine the 'process_table' options with your own functions to 'tweak' the data. Ability to call a function either (or both) before or after the normal processing (custom can use either or both - nothing happens in between...)
EXAMPLE:
'table_suffix' => array( // table name that follows the cpg table prefix
'process_type' => '{process_table|compare_values|transient|static|custom}', // see detail above
// ****** following fields only required if 'process_type' = 'compare_values' ******
'compare_name_column' => 'name', // name of column containing the variable names
'compare_value_column' => 'value', // name of the column containing the variable setting
// ****** following fields only required if 'process_type' = 'process_table' or 'custom' ******
'table_key' => 'aid', // key field name
'orderby' => ''; // order by key field is default to assist restart - override here if needed
'compare_fields' => 'title'; // field(s) - comma separated - to match source to target (identify duplicates/inserts)
'compare_type' => ''; // type of compare: UNIQUE, IGNORE, MERGE
'skip_keys' => array('aid'); // set keys/columns to bypass for insert (typically auto-increment fields)
'zero_keys' => array('thumb'); // set keys/columns to 0 value on insert (typically data not yet available... to be updated later)
'map_values' => array('/title', 'thumb'); // set mapping values to set fields to build array for later processing
'skip_keys_difference' => array('aid', 'thumb'); // set keys to bypass for comparing like rows in source and target (like passwords...)
'translations' => array('visibility' => 'usergroups.visibility.group_id', // <- translate 'visibility' field using usergroups mapping, visibility as key, and set to target group_id
'owner' => 'users.owner.user_id', // <- translate 'owner' fied using users mapping, owner as key, and set to target user_id
'pos' => 'categories.category.incr_subalbum_pos', // <- translate 'pos' field using categories mapping, category as key, and ADD the subalbum_pos to current pos value
'conid.1' => 'categories.conid.cid.type=0', // <- translate 'conid' field using categories mapping, conid as key, and set to target cid - ONLY IF type = 0
'conid.2' => 'albums.conid.aid.type=1', // (the suffix following translate field (.1, .2, etc) are ignored - they can be any character or string to make array key unique)
'conid.3' => 'pictures.conid.pid.type=2'), ); // set translations to be done... fieldname => table.keyvalue.field to use
// ****** following fields (at least one) only required if 'process_type' = 'custom' - Optional for 'process_type = 'process_table' ******
'pre_merge_function' => '' // function to call before execution of merge script... (process types of 'process_table' and 'custom' only)
'post_merge_function' => '' // function to call following execution of merge script... (process types of 'process_table' and 'custom' only)
|
||
|
|
||
|
Congratulations again if you made it through all of this! And good luck merging galleries!! Your comments are welcome. I hope you find this useful. Greg (gmc on the CPG forum) | ||