function bueditor_save_import in BUEditor 6.2
Same name and namespace in other branches
- 7 admin/bueditor.admin.inc \bueditor_save_import()
Save imported editor data. Save icons and library files into specified editor path.
2 calls to bueditor_save_import()
- bueditor_editor_import_submit in admin/
bueditor.admin.inc - Editor import form submission.
- bueditor_import_by_name in admin/
bueditor.admin.inc - Import an editor from 'bueditor/import' directory.
File
- admin/
bueditor.admin.inc, line 592
Code
function bueditor_save_import($editor) {
//this will fill in the blanks.
$default = bueditor_editor_defaults('Noname');
//buttons
$buttons = bueditor_grab_imported_buttons($editor);
//handle custom paths for icons and library files.
if (isset($editor->custom_path) && file_check_directory($editor->custom_path, 1)) {
$cpath = array(
'tokened' => bueditor_path_tr($editor->custom_path, 'reverse'),
'icons' => $editor->custom_path . '/icons',
'library' => $editor->custom_path,
);
//custom icons
if (isset($editor->icons) && !empty($editor->icons) && file_check_directory($cpath['icons'], 1)) {
foreach ($editor->icons as $name => $base64) {
$filepath = $cpath['icons'] . '/' . $name;
if (!file_exists($filepath)) {
file_put_contents($filepath, base64_decode($base64));
if (!@getimagesize($filepath)) {
unlink($filepath);
}
}
}
$editor->iconpath = $cpath['tokened'] . '/icons';
}
}
//library files
if (isset($editor->library)) {
if (empty($editor->library)) {
$editor->librarypath = '';
}
else {
$files = array();
foreach ($editor->library as $tokenpath => $content) {
$filepath = bueditor_path_tr($tokenpath);
if (file_exists($filepath)) {
$files[] = $tokenpath;
}
elseif (isset($cpath) && $content) {
$filename = basename($filepath);
file_put_contents($cpath['library'] . '/' . $filename, $content);
$files[] = $cpath['tokened'] . '/' . $filename;
}
}
$editor->librarypath = implode("\n", $files);
}
}
//set defaults for unset properties
foreach ($default as $key => $value) {
if (!isset($editor->{$key})) {
$editor->{$key} = $value;
}
}
//get rid of some unwanted or possibly big variables
unset($editor->custom_path, $editor->buttons, $editor->library, $editor->icons);
if (empty($editor->overwrite)) {
unset($editor->eid);
}
elseif (!empty($editor->eid)) {
db_query("DELETE FROM {bueditor_buttons} WHERE eid = %d", $editor->eid);
}
//save and return the editor
return bueditor_write_editor($editor, $buttons);
}