You are here

function smileys_export_page in Smileys 5

Same name and namespace in other branches
  1. 6 smileys_import.module \smileys_export_page()

Menu callback; Present a page for .pak file for a Smiley pack.

1 string reference to 'smileys_export_page'
smileys_import_menu in ./smileys_import.module
Implementation of hook_menu().

File

./smileys_import.module, line 79

Code

function smileys_export_page() {
  if ($package = arg(4)) {
    $smileys = db_query("SELECT * FROM {smileys} WHERE package = '%s' ORDER BY id", $package);
    $path = drupal_get_path('module', 'smileys');
    if (!($packd = smileys_import_packs($package))) {
      drupal_set_message(t('Cannot find smiley package %pack.', array(
        '%pack' => $package,
      )));
      drupal_goto('admin/settings/smileys/export');
    }
    $smile_pak = "";
    $delimeter = '=+:';
    while ($smiley = db_fetch_object($smileys)) {
      $smile_pak .= str_replace(dirname($packd->filename) . '/', '', $smiley->image) . $delimeter;
      $smile_pak .= $smiley->description . $delimeter;
      $smile_pak .= $smiley->acronyms . "\n";
    }
    $output = "<div id=\"module-message\">\n";
    $output .= t('Please copy and paste the following text into a file at:<br /><strong>%package</strong><br /><em>with each smiley image in the same folder.</em>', array(
      '%package' => $path . '/packs/' . $package . '/' . $package . '.pak',
    )) . "\n";
    $output .= "</div>\n";
    $output .= "<div id=\"module-code\">\n";
    $output .= "<textarea cols=\"80\" rows=\"15\">\n";
    $output .= $smile_pak;
    $output .= "</textarea>\n";
    $output .= "</div>\n";
  }
  else {
    $packs = array();
    $header = array(
      t('Smiley Packs'),
      t('Operations'),
    );
    $smileyp = db_query("SELECT DISTINCT package FROM {smileys} ORDER BY package");
    while ($pack = db_fetch_object($smileyp)) {
      if ($pack->package != 'Uncategorized') {
        $packs[] = $pack->package;
        $rows[] = array(
          '<strong>' . $pack->package . '</strong>',
          l(t('Export'), 'admin/settings/smileys/export/' . $pack->package),
        );
      }
    }
    $output = theme('table', $header, $rows);
    if (empty($rows)) {
      drupal_set_message(t('No smiley packs to export.'));
      $output = '';
    }
  }
  return $output;
}