You are here

function patterns_export_finalize_export in Patterns 7.2

Same name and namespace in other branches
  1. 7 patterns_export/ \patterns_export_finalize_export()

Initializes the appropriate action to export a collection of patterns


string $action The type of export action:

array $sections The sections of the pattern:

array $info The info section of the pattern:

array $modules The modules section of the pattern:

string $format The pattern format:

string $filename (optional) The final name of file :

string $path (optional) The path of the temporary directory in which the zip file will be saved:

2 calls to patterns_export_finalize_export()
patterns_export_batch_finish in patterns_export/
Finishes a batch operation. @TODO Doc.
patterns_export_php in patterns_export/
Starts the exporting process in php execution mode


patterns_export/, line 15


function patterns_export_finalize_export($action = PATTERNS_EXPORT_TO_FILE, $sections = array(), $info = array(), $modules = array(), $format, $filename = NULL) {

  // If some sections did not return any data
  // we remove them. We don't remove the modules!
  foreach ($sections as $s => $value) {
    if (empty($value)) {
  if (empty($sections)) {
    drupal_set_message(t('Export did not return any data.'), 'error');
    return FALSE;
  if ($action == PATTERNS_EXPORT_TO_FILE) {
    return patterns_export_to_file($sections, $info, $modules, $format, $filename);
  else {
    if ($action == PATTERNS_EXPORT_TO_DB) {
      return patterns_export_to_db($sections, $info, $modules, $format, $filename);
    else {
      if ($action == PATTERNS_EXPORT_TO_ZIP) {
        $path = pathinfo($filename, PATHINFO_DIRNAME);
        if (!empty($path)) {

          // no full path, probably it is from the web interface
          if ($path == '.') {
            $path = NULL;
          else {
            $path .= '/';
            $filename = pathinfo($filename, PATHINFO_BASENAME);
        return patterns_export_to_zip($sections, $info, $modules, $format, $filename, $path);
      else {
        drupal_set_message(t('Unknown export option: %option', array(
          '%options' => $action,