function smiley_admin_list in Smiley 6
1 string reference to 'smiley_admin_list'
- smiley_menu in ./
smiley.module - Implementation of hook_menu().
File
- ./
smiley.admin.inc, line 105
Code
function smiley_admin_list() {
_smiley_check_filter();
$path = drupal_get_path('module', 'smiley');
drupal_add_js($path . '/scripts/admin/smiley-admin.js', 'module', 'header', FALSE, TRUE, FALSE);
drupal_add_css($path . '/scripts/admin/smiley-admin.css', 'module', 'all', FALSE);
$header = array(
t('Smiley'),
t('Visibility'),
t('Acronyms'),
t('Description'),
t('Category'),
t('Weight'),
);
$rows = array();
$packages = array();
$categories = array(
'Miscellaneous' => 'Miscellaneous',
);
$smileyp = db_query("SELECT DISTINCT package FROM {smiley} ORDER BY package");
while ($pack = db_fetch_object($smileyp)) {
$categories[$pack->package] = $pack->package;
}
ksort($categories);
$categories = array_unique($categories);
$output = '<form id="smiley-admin-form">';
$smileyp = db_query("SELECT DISTINCT package FROM {smiley} ORDER BY package");
while ($pack = db_fetch_object($smileyp)) {
$packages[] = check_plain($pack->package);
$select = '';
foreach ($categories as $category) {
$cat = check_plain($category);
$select .= '<option value="' . $cat . '"' . ($category == $pack->package ? 'selected="selected"' : '') . '>' . $cat . '</option>' . "\n";
}
$rows[] = array(
'data' => array(
array(
'data' => '<span>' . check_plain($pack->package) . '</span>',
'class' => 'category',
'colspan' => 7,
),
),
'class' => 'category',
);
$rows[] = array(
'data' => array(
array(
'data' => '<em>' . t('No smiley in this category') . '</em>',
'colspan' => 7,
),
),
'class' => "category-message category-populated category-" . str_replace(array(
'_',
' ',
), '-', drupal_strtolower(check_plain($pack->package))) . "-message",
);
$list = _smiley_list(1, " WHERE package = '" . check_plain($pack->package) . "' ORDER BY weight");
foreach ($list as $smiley) {
$each_acronym = explode(' ', $smiley->acronyms);
if ($smiley->promote_to_box == -1) {
$promoted = '<span class="smiley-deselected" id="' . $smiley->id . '"> </span>';
}
elseif ($smiley->promote_to_box == 0) {
$promoted = '<span class="smiley-middle" id="' . $smiley->id . '"> </span>';
}
elseif ($smiley->promote_to_box == 1) {
$promoted = '<span class="smiley-selected" id="' . $smiley->id . '"> </span>';
}
$acronyms = '';
foreach ($each_acronym as $key => $eac) {
$eac = str_replace("<", "<", $eac);
$eac = str_replace(">", ">", $eac);
$acronyms .= '<span style="color:' . ($key % 2 == 0 ? "#000000" : "#53616e") . ';">' . check_plain($eac) . '</span> ';
}
$rows[] = array(
'data' => array(
array(
'data' => '<div class="nub">' . l(t('Edit'), 'admin/settings/smiley/edit/' . $smiley->id, array(
'attributes' => array(
'class' => 'edit',
'title' => t('Edit this smiley'),
),
)) . l(t('Delete'), 'admin/settings/smiley/delete/' . $smiley->id, array(
'attributes' => array(
'class' => 'delete',
'title' => t('Delete this smiley'),
),
)) . '</div>' . theme('image', check_url($smiley->image), check_plain($smiley->description), check_plain($smiley->description)),
'class' => 'nub-td',
),
$promoted,
$acronyms,
check_plain($smiley->description),
'<center><select id="edit-category" class="form-select smiley-category-select smiley-category-' . str_replace(array(
'_',
' ',
), '-', drupal_strtolower(check_plain($pack->package))) . '" name="category">' . $select . '</select></center>',
'<center><input style="text-align: center;" size="1" id="' . $smiley->id . '" class="smiley-weight" value="' . $smiley->weight . '"></input></center>',
),
'class' => 'draggable',
);
$acronyms = '';
}
}
$form['smiley'] = array(
'#type' => 'markup',
'#value' => theme('table', $header, $rows, array(
'id' => 'smiley_admin_list',
)),
);
$output .= drupal_render($form);
foreach ($packages as $package) {
drupal_add_tabledrag('smiley_admin_list', 'match', 'sibling', 'smiley-category-select', 'smiley-category-' . str_replace(array(
'_',
' ',
), '-', drupal_strtolower($package)), NULL, FALSE);
drupal_add_tabledrag('smiley_admin_list', 'order', 'sibling', 'smiley-weight');
}
if (count($rows) == 0) {
if (module_exists('smiley_import')) {
$msg = t('No smiley found. You may !add, or !import.', array(
'!add' => l(t('add a custom smiley'), 'admin/settings/smiley/add'),
'!import' => l(t('import smiley packages'), 'admin/settings/smiley/import'),
));
}
else {
$msg = t('No smiley found. You may !add, or install smiley_import module & import smiley packages.', array(
'!add' => l(t('add custom smiley'), 'admin/settings/smiley/add'),
));
}
drupal_set_message($msg);
$output = '';
}
else {
$output .= '<br /> <i>' . t('Visibility Legend') . '</i><br /><span class="smiley-selected"></span>' . t('Visible on select box + popup') . '<br /><span class="smiley-middle"></span>' . t('Visible on only on popup i.e. "More Smileys"') . '<br /><span class="smiley-deselected"></span>' . t('Invisible (but not disabled)');
}
return $output . '</form>';
}