'Table external link templates.', 'fields' => [ 'id' => [ 'type' => 'varchar', 'length' => 32, 'not null' => TRUE, 'default' => '', 'description' => 'Name of the ext_link being referenced.', ], 'title' => [ 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'The link title', ], 'link' => [ 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'The link url template', ], 'glue' => [ 'type' => 'varchar', 'length' => 10, 'not null' => TRUE, 'description' => 'The string to concatenate name parts in the URL query string', ], 'category' => [ 'type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'description' => 'The link category', ], 'weight' => [ 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'Weight of filter within format.', ], 'status' => [ 'type' => 'int', 'not null' => TRUE, 'default' => 0, 'description' => 'External link enabled status. (1 = enabled, 0 = disabled)', ], ], 'primary key' => ['id'], 'indexes' => [ 'list' => ['weight', 'id'], ], ]; return $schema; } /** * implements hook_install() */ function ext_links_install() { $links_templates = migrate_old_ext_links(); foreach ($links_templates as $ext_link){ db_delete('variable') ->condition('name', "ext_links_" . $ext_link->id . '_%', 'LIKE') ->execute(); } variable_set('ext_links_appearance_grouped', variable_get('ext_links_options', 0) != 1 ? 1 : 0 ); variable_del('ext_links_options'); } /** * Implements hook_uninstall(). */ function hook_uninstall() { db_drop_table('ext_links'); } /** * Migrates old ext link templates from drupal vars to the ext_link table. */ function migrate_old_ext_links(){ $links_templates = ext_links_templates(); foreach ($links_templates as $ext_link){ $ext_link = _ext_links_merge_old_vars($ext_link); ext_links_save($ext_link); } return $links_templates; } /** * Merge the old settings stored in drupal vars into the ext_link template object * @param $ext_link object * * @return object * The ext link template */ function _ext_links_merge_old_vars($ext_link){ $ext_link_id = $ext_link->id; $ext_link->status = variable_get("ext_links_${ext_link_id}_check", $ext_link->status); $ext_link->link = variable_get("ext_links_${ext_link_id}_link", $ext_link->link); $ext_link->glue = variable_get("ext_links_${ext_link_id}_concat", $ext_link->glue); $ext_link->title = variable_get("ext_links_${ext_link_id}_text", $ext_link->title); return $ext_link; }