function bueditor_button_add in BUEditor 5
Insert/update a button.
1 call to bueditor_button_add()
- bueditor_form_editor_submit in ./
bueditor.module - Editor form submitted.
File
- ./
bueditor.module, line 287
Code
function bueditor_button_add($button) {
$sets = array();
$vals = array();
$bid = $button['bid'];
$button['content'] = str_replace("\r\n", "\n", $button['content']);
$button['icon'] = $button['icon'] ? $button['icon'] : ($button['caption'] ? $button['caption'] : substr($button['title'], 0, 2));
unset($button['caption'], $button['bid']);
foreach ($button as $key => $val) {
$sets[] = $key . "='%s'";
$vals[] = $val;
}
if (is_numeric($bid)) {
//button with an ID. update
$vals[] = $bid;
db_query("UPDATE {bueditor_buttons} SET " . implode(', ', $sets) . " WHERE bid = %d", $vals);
}
else {
if ($button['title']) {
//button with no real ID. insert
db_query("INSERT INTO {bueditor_buttons} (" . implode(', ', array_keys($button)) . ") VALUES(" . str_repeat("'%s', ", count($vals) - 1) . "'%s')", $vals);
}
}
}