? rdf/vendor/arc
? rdf/vendor/arc.zip
Index: rdf/rdf.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/rdf/rdf.admin.inc,v
retrieving revision 1.38
diff -u -p -r1.38 rdf.admin.inc
--- rdf/rdf.admin.inc 28 Mar 2009 02:37:22 -0000 1.38
+++ rdf/rdf.admin.inc 23 May 2009 08:42:16 -0000
@@ -84,6 +84,44 @@ function rdf_admin_settings() {
'#options' => array(FALSE => t('Disabled'), TRUE => t('Enabled')),
'#description' => t('Whether to perform periodic purges of unused resource URIs on cron runs, decreasing the size of the rdf_resources table. It may be useful to enable this when dealing with transient RDF data sets that contain large numbers of URIs that are not likely to be seen again once the data sets expire or are removed.'),
);
+
+ // Requirements
+ $form['requirements'] = array(
+ '#type' => 'fieldset',
+ '#title' => t('Requirements'),
+ '#collapsible' => TRUE,
+ '#collapsed' => TRUE,
+ '#weight' => 80,
+ );
+
+ module_load_include('install', 'rdf', 'rdf');
+ // Need install.inc to declare constants and avoid warnings when calling hook_requirements...
+ include_once './includes/install.inc';
+ $status = rdf_requirements('runtime');
+ $form['requirements']['arc2_test'] = array(
+ '#type' => 'markup',
+ '#value' => '
'. $status['rdf']['description'] .'
', + ); + if($status['rdf']['value'] == t('Not installed')) { + $library_path = dirname(RDF_ARC2_PATH); + if (is_writable($library_path)) { + $form['requirements']['arc2_install_info'] = array( + '#type' => 'markup', '#prefix' => '', '#suffix' => '
', + '#value' => t("I can attempt to download and install this library for you automatically (*nix only). Results are not guaranteed. (PS, your file system is a little bit insecure if I can do this)"), + ); + $form['requirements']['arc2_install_button'] = array( + '#type' => 'submit', + '#value' => 'Install Arc2', + '#submit' => array('rdf_admin_install_arc'), + ); + } + else { + $form['requirements']['arc2_install_info'] = array( + '#type' => 'markup', '#prefix' => '', '#suffix' => '
', + '#value' => t('The library install folder %library_path is read-only, so I cannot install this automatically for you (*nix only). If it were writable to the webserver (generally a bad idea) I could try.', array('%library_path' => $library_path)), + ); + } + } return array_merge_recursive(system_settings_form($form), array('#theme' => 'rdf_admin_settings', 'buttons' => array('#weight' => 99))); } @@ -120,6 +158,37 @@ function theme_rdf_admin_settings($form) return drupal_render($form); } +/** + * Attempt to install and unzip the required library from remote source. + * This may have security implications - it won't work if you have correctly + * locked-down file permissions. It could if you are on a looser dev box. + * + * There may be various problems on different machines, but this may work. + */ +function rdf_admin_install_arc() { + $arc_library_package_url = 'http://arc.semsol.org/download/2009/03/05/arc.zip'; + $destination_filepath = dirname(RDF_ARC2_PATH) .'/'. basename($arc_library_package_url); + drupal_set_message(t('Requesting ARC2 package from !arc_package', array('!arc_package' => l($arc_library_package_url, $arc_library_package_url)))); + if ($package_data = file_get_contents($arc_library_package_url)) { + file_put_contents($destination_filepath, $package_data); + drupal_set_message(t('Fetched library to %destination_filepath', array('%destination_filepath' => $destination_filepath))); + // unpack it + // try system-level unzip (did not try eith ZipArchive) + drupal_set_message(t('Unpacking using commandline')); + exec("cd ". dirname($destination_filepath) .";unzip '". basename($destination_filepath) ."'"); + if (file_exists(RDF_ARC2_PATH. '/ARC2.php')) { + exec("chmod -R g+w ". RDF_ARC2_PATH ); + drupal_set_message(t('Success!')); + } + else { + drupal_set_message(t('Failed to unzip. You\'ll have to do it yourself.')); + } + } + else { + drupal_set_message(t('Failed to retrieve package from @arc_package', array('@arc_package' => l($arc_library_package_url, $arc_library_package_url))), 'error'); + } +} + ////////////////////////////////////////////////////////////////////////////// // RDF data management