You are here

function smileys_import_add in Smileys 5

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

Menu callback; Add a Smiley pack.

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

File

./smileys_import.module, line 159

Code

function smileys_import_add($packname) {
  $delimeter = '=+:';
  $pack = $packname ? $packname : arg(5);
  smileys_import_delete($pack, 1);
  if (!($packd = smileys_import_packs($pack))) {
    drupal_set_message(t('Cannot find smiley package %pack.', array(
      '%pack' => $pack,
    )));
    drupal_goto('admin/settings/smileys/import');
  }
  $fcontents = @file(dirname($packd->filename) . '/' . $pack . '.pak');
  for ($i = 0; $i < count($fcontents); $i++) {
    $smile_data = explode($delimeter, trim(addslashes($fcontents[$i])));
    for ($j = 2; $j < count($smile_data); $j++) {
      $smile_data[$j] = str_replace("<", "&lt;", $smile_data[$j]);
      $smile_data[$j] = str_replace(">", "&gt;", $smile_data[$j]);
      $k = $smile_data[$j];
      db_query("INSERT INTO {smileys} (acronyms, image, description, standalone, package) VALUES('%s', '%s', '%s', %d, '%s')", str_replace("\\'", "''", $smile_data[$j]), dirname($packd->filename) . '/' . str_replace("\\'", "''", $smile_data[0]), str_replace("\\'", "''", $smile_data[1]), 1, $pack);
    }
  }
  drupal_set_message(t('Smiley package %pack installed.', array(
    '%pack' => $pack,
  )));
  drupal_goto('admin/settings/smileys/import');
}