function iframe_save_state($args) { $elem = $args['elem']; $obj = $args['obj']; if (array_shift(elem_classes($elem)) != 'iframe') { return false; } // make sure the type is set $obj['type'] = 'iframe'; $obj['module'] = 'iframe'; // hook invoke_hook('alter_save', array('obj' => &$obj, 'elem' => $elem)); load_modules('glue'); $ret = save_object($obj); if ($ret['#error']) { log_msg('error', 'iframe_save_state: save_object returned ' . quot($ret['#data'])); return false; } else { return true; } }
############# if update then REDIRECT PAGE: to get correct GET URL again if ($site->fdat['op2'] != 'saveclose') { header("Location: " . $site->self . "?tab=" . $site->fdat['tab'] . "&id=" . $site->fdat['id'] . "&keel=" . $site->fdat['keel'] . '&callback=' . $site->fdat['callback']); } } # / SAVE PERMISSIONS TAB ############## ############## # SAVE OBJECT TAB if ($site->fdat['tab'] == 'object') { $is_new = $site->fdat['op'] == 'new' ? true : false; if (function_exists('onBeforeObjectSave')) { $site->globals['onBeforeObjectSave'] = onBeforeObjectSave($objekt); } include_once "edit_object.php"; $save_result = save_object(); $site->fdat['op'] = 'edit'; $op = $site->fdat['op']; if (isset($objekt->all['in_wysiwyg_filename'])) { $save_in_wysiwyg_filename = $objekt->all['in_wysiwyg_filename']; /* very ugly workaround for bug #2269 */ } ########reload object $objekt = new Objekt(array(objekt_id => $objekt->objekt_id, on_sisu => 1, no_cache => 1)); if (function_exists('onObjectSave') && $save_result) { $site->globals['onObjectSave'] = onObjectSave($objekt); } $site->fdat['id'] = $objekt->objekt_id; $tyyp['tyyp_id'] = $objekt->all['tyyp_id']; } # / SAVE OBJECT TAB
if (isset($_REQUEST['id']) && strlen($_REQUEST['id']) < 25) { $id = strip_tags($_REQUEST['id']); } # START OUTPUT LS_page_start('empty'); # Left nav pane echoing echo '<div class="navi" style="left: 5px;">' . _button('NEU Klass. / Msggr.', '', 'admin_liga_types.php?op=new') . _button('Admin home', '', 'admin_main_menu.php') . '</div>'; echo '<h3>Klassen / Messagegroups</h3>'; # header and start table switch ($myop) { case "list": echo object_list(); break; case "new": echo object_form(); break; case "edit": echo object_form($id); break; case "save": save_object($id); echo object_list(); break; case "delete": delete_object($id); echo object_list(); break; } echo '</td></tr></table>'; # end table LS_page_end();
function video_upload($args) { $ext = filext($args['file']); if ($args['mime'] == 'video/ogg' || $ext == 'ogv' || $ext == 'ogg') { // notice: we also handle ogg here although this also could be a // different mime type // make sure mime type is set $mime = 'video/ogg'; } elseif ($args['mime'] == 'video/h264' || $ext == 'h264') { // haven't seen these out there $mime = 'video/h264'; } elseif ($args['mime'] == 'video/mp4' || $ext == 'mp4') { // think this need not be h264, but well $mime = 'video/mp4'; } elseif ($args['mime'] == 'video/webm' || $ext == 'webm') { // again, webm could also be audio/webm $mime = 'video/webm'; } else { return false; } load_modules('glue'); $obj = create_object($args); if ($obj['#error']) { return false; } else { $obj = $obj['#data']; } $obj['type'] = 'video'; $obj['module'] = 'video'; $obj['video-file'] = $args['file']; $obj['video-file-mime'] = $mime; save_object($obj); $ret = render_object(array('name' => $obj['name'], 'edit' => true)); if ($ret['#error']) { return false; } else { return $ret['#data']; } }
/** * implements upload */ function image_upload($args) { // check if supported file if (!in_array($args['mime'], array('image/jpeg', 'image/png', 'image/gif')) || $args['mime'] == '' && !in_array(filext($args['file']), array('jpg', 'jpeg', 'png', 'gif'))) { return false; } load_modules('glue'); // create new object $obj = create_object($args); if ($obj['#error']) { return false; } else { $obj = $obj['#data']; } $obj['type'] = 'image'; // this is for a potential future speedup $obj['module'] = 'image'; $obj['image-file'] = $args['file']; $obj['image-file-mime'] = $args['mime']; // save original-{width,height} if we can calculate it if (_gd_available()) { $a = expl('.', $args['page']); $size = _gd_get_imagesize(CONTENT_DIR . '/' . $a[0] . '/shared/' . $obj['image-file']); $obj['image-file-width'] = $size[0]; $obj['object-width'] = $size[0] . 'px'; $obj['image-file-height'] = $size[1]; $obj['object-height'] = $size[1] . 'px'; } save_object($obj); // render object and return html $ret = render_object(array('name' => $obj['name'], 'edit' => true)); log_msg('debug', 'image_upload: ' . print_r($ret, 1)); if ($ret['#error']) { return false; } else { return $ret['#data']; } }
/** * update an object * * this function merges the attributes in $args with the object already on * disk. the object need not exist before, though. * this function takes the object lock. * @param array $args arguments * key 'name' is the object name (i.e. page.rev.obj) * key 'content' is the object's content * all other key/value pairs are treated as attributes * @return array response */ function update_object($args) { if (empty($args['name'])) { return response('Required argument "name" missing or empty', 400); } // LOCK $L = _obj_lock($args['name'], LOCK_TIME); // the object need not exist, so we're not checking against // $L being NULL here if ($L === false) { return response('Could not acquire lock to ' . quot($args['name']) . ' in ' . LOCK_TIME . 'ms', 500); } $old = load_object($args); if ($old['#error']) { $old = array(); } else { $old = $old['#data']; } $new = array_merge($old, $args); $ret = save_object($new); // UNLOCK _obj_unlock($L); return $ret; }
function download_upload_fallback($args) { // we handle everything load_modules('glue'); $obj = create_object($args); if ($obj['#error']) { return false; } else { $obj = $obj['#data']; } $obj['type'] = 'download'; $obj['module'] = 'download'; $obj['download-file'] = $args['file']; $obj['download-file-mime'] = $args['mime']; save_object($obj); $ret = render_object(array('name' => $obj['name'], 'edit' => true)); if ($ret['#error']) { return false; } else { return $ret['#data']; } }