diff --git a/site_verify.admin.inc b/site_verify.admin.inc old mode 100644 new mode 100755 diff --git a/site_verify.api.php b/site_verify.api.php old mode 100644 new mode 100755 diff --git a/site_verify.info b/site_verify.info old mode 100644 new mode 100755 index 8f22950..ab7bc19 --- a/site_verify.info +++ b/site_verify.info @@ -1,6 +1,7 @@ name = Site Verification description = "Verifies ownership of a site for use with search engines." core = 7.x +dependencies[] = ctools files[] = site_verify.module files[] = site_verify.admin.inc files[] = site_verify.install diff --git a/site_verify.install b/site_verify.install old mode 100644 new mode 100755 index a1177d5..0d259c3 --- a/site_verify.install +++ b/site_verify.install @@ -10,13 +10,27 @@ */ function site_verify_schema() { $schema['site_verify'] = array( - 'description' => '', + 'description' => 'Site Verification', + 'export' => array( + 'key' => 'engine', + 'key name' => 'Engine', + 'primary key' => 'svid', + 'identifier' => 'preset', // Exports will be defined as $preset + 'default hook' => 'site_verify', // Function hook name. + 'api' => array( + 'owner' => 'site_verify', + 'api' => 'site_verify', // Base name for api include files. + 'minimum_version' => 1, + 'current_version' => 1, + ), + ), 'fields' => array( 'svid' => array( 'type' => 'serial', 'unsigned' => TRUE, 'not null' => TRUE, 'description' => 'Primary Key: Unique site verification ID.', + 'no export' => TRUE, ), 'engine' => array( 'type' => 'varchar', diff --git a/site_verify.module b/site_verify.module index 3ae0ead..7403eb8 100755 --- a/site_verify.module +++ b/site_verify.module @@ -211,3 +211,81 @@ function site_verify_output($svid) { return t('This is a verification page for the @title search engine.', array('!title' => $verification['engine']['name'])); } } + + +/** + * Implementation of hook_ctools_plugin_api(). + * + * Tell CTools that we support the default_mymodule_presets API. + */ +function site_verify_ctools_plugin_api($owner, $api) { + if ($owner == 'site_verify' && $api == 'site_verify') { + return array('version' => 1); + } +} + +/** + * Implementation of hook_ctools_plugin_directory(). + */ +function site_verify_ctools_plugin_directory($module, $type) { + // Load the export_ui plugin. + if ($type =='export_ui') { + return 'plugins/export_ui'; + } +} + +/** + * This code is shamelessly stolen from Features. + * + * Modifications were made to have it export data from the database rather than + * from the ctools crud system. This allows for features to properly show items + * as overridden when there is no corresponding data in the database. + * + * @param $module + * @param $data + * @param $export + * @return array + */ +function site_verify_features_export_render($module, $data, $export){ + // Reset the export display static to prevent clashes. + drupal_static_reset('panels_export_display'); + $component='site_verify'; + ctools_include('export'); + $schema = ctools_export_get_schema($component); + + if (function_exists($schema['export']['to hook code callback'])) { + $export = $schema['export']['to hook code callback']($data, $module); + $code = explode("{\n", $export); + array_shift($code); + $code = explode('}', implode($code, "{\n")); + array_pop($code); + $code = implode('}', $code); + } + else { + $code = ' $export = array();'."\n\n"; + foreach ($data as $object_name) { + if ($object = db_query("select * from {site_verify} where engine=:engine", array(":engine"=>$object_name))->fetchObject()) { + $identifier = $schema['export']['identifier']; + $code .= _ctools_features_export_crud_export($component, $object, ' '); + $code .= " \$export[" . ctools_var_export($object_name) . "] = \${$identifier};\n\n"; + } + } + $code .= ' return $export;'; + } + + return array($schema['export']['default hook'] => $code); +} + +function site_verify_features_revert($module, $component){ + if ($objects = features_get_default($component, $module)) { + foreach ($objects as $name => $object) { + // Some things (like views) do not use the machine name as key + // and need to be loaded explicitly in order to be deleted. + _ctools_features_export_crud_delete($component, $object); + unset($object->svid); + $object->export_type = EXPORT_IN_CODE; + ctools_export_crud_save('site_verify', $object); + } + } +} + diff --git a/site_verify.test b/site_verify.test old mode 100644 new mode 100755