You are here

function smileys_admin_list in Smileys 5

Same name and namespace in other branches
  1. 6 smileys.admin.inc \smileys_admin_list()
1 string reference to 'smileys_admin_list'
smileys_menu in ./smileys.module
Implementation of hook_menu().

File

./smileys.module, line 323

Code

function smileys_admin_list() {
  $path = drupal_get_path('module', 'smileys');
  drupal_add_js($path . '/smileys-admin.js');
  drupal_add_css($path . '/smileys-admin.css');
  $header = array(
    t('Promoted'),
    t('Smiley'),
    t('Acronyms'),
    t('Description'),
    t('Operations'),
  );
  $rows = array();
  $output = '';
  $smileyp = db_query("SELECT DISTINCT package FROM {smileys} ORDER BY package");
  while ($pack = db_fetch_object($smileyp)) {
    $package = $pack->package;
    $list = _smileys_list(1, " package = '{$package}' ");
    foreach ($list as $smiley) {
      $each_acronym = explode(' ', $smiley->acronyms);
      $promoted = $smiley->promote_to_box ? '<span class="smiley-selected" id="' . $smiley->id . '"> </span>' : '<span class="smiley-deselected" id="' . $smiley->id . '"> </span>';
      foreach ($each_acronym as $key => $eac) {
        $eac = str_replace("&lt;", "<", $eac);
        $eac = str_replace("&gt;", ">", $eac);
        $acronyms .= '<span style="color:' . ($key % 2 == 0 ? "#000000" : "#53616e") . ';">' . check_plain($eac) . '</span>&nbsp;';
      }
      $rows[] = array(
        $promoted,
        '<img src="' . check_url($GLOBALS['base_url'] . '/' . $smiley->image) . '" alt="' . check_plain($smiley->description) . '" />',
        $acronyms,
        check_plain($smiley->description),
        l(t('Edit'), 'admin/settings/smileys/edit/' . $smiley->id) . ' · ' . l(t('Delete'), 'admin/settings/smileys/delete/' . $smiley->id),
      );
      $acronyms = '';
    }
    $form['smileys'][$package] = array(
      '#type' => 'fieldset',
      '#title' => t($package),
      '#collapsed' => FALSE,
      '#collapsible' => TRUE,
    );
    $form['smileys'][$package]['smileys_box'] = array(
      '#type' => 'markup',
      '#value' => theme('table', $header, $rows, array(
        'id' => 'smileys-admin-list',
      )),
    );
    $output .= drupal_render($form);
    $form = array();
    $rows = array();
  }
  if ($output == '') {
    if (module_exists('smileys_import')) {
      $msg = t('No smileys found. You may !add, or !import.', array(
        '!add' => l(t('add custom smileys'), 'admin/settings/smileys/add'),
        '!import' => l(t('import smiley packages'), 'admin/settings/smileys/import'),
      ));
    }
    else {
      $msg = t('No smileys found. You may !add, or install smileys_import module & import smiley packages.', array(
        '!add' => l(t('add custom smileys'), 'admin/settings/smileys/add'),
      ));
    }
    drupal_set_message($msg);
  }
  return $output;
}