atrpo.module

<?php
// $Id: atrpo.module,v 1.1.2.2 2009/08/19 10:42:40 xano Exp $

/**
 * @file
 *   Hook implementations and general funcions.
 */

/**
 * Implementation of hook_atr_source_info().
 */
function atrpo_atr_source_info() {
  return array(
    'atrpo' => t('GNU gettext translations (*.po files)'),
  );
}

/**
 * Implementation of hook_form_FORM_ID_alter().
 */
function atrpo_form_atr_form_review_alter(&$form, &$form_state) {
  array_unshift($form['#submit'], 'atrpo_atr_form_review_submit');
  $form['atrpo']['settings']['atrpo_files'] = array(
    '#type' => 'atr_file',
    '#title' => t('Files'),
    '#default_value' => NULL,
  );
}

/**
 * Form submit handler for atr_form_review().
 */
function atrpo_atr_form_review_submit($form, &$form_state) {
  $values = $form_state['values'];
  if ($values['atrpo_toggle']) {
    module_load_include('inc', 'atrpo', 'includes/atrpo.extract');
    foreach ($values['atrpo_files'] as $path) {
      atrpo_extract($path);
      atr_rmdir($path);
    }
  }
}