$fields = UserDataField::getAll(); foreach ($fields as $f) { switch ($f->type) { case UserDataField::RADIO: $opts = UserDataFieldOption::getAll($f->id); $arr = array(); foreach ($opts as $o) { $arr[$o['id']] = $o['value']; } $form->addRadio($f->name, $f->label, $arr, UserSetting::get($session->id, $f->name)); break; case UserDataField::AVATAR: $opts = UserDataFieldOption::getAll($f->id); $arr = array(); foreach ($opts as $o) { $img = new XhtmlComponentImage(); $img->src = getThumbUrl($o['value']); $arr[$o['id']] = $img->render(); } $form->addRadio($f->name, $f->label, $arr, UserSetting::get($session->id, $f->name)); break; case UserDataField::IMAGE: $pic_id = UserSetting::get($session->id, 'picture'); if ($pic_id) { $img = new XhtmlComponentImage(); $img->src = getThumbUrl($pic_id); $form->add($img, 'Existing picture'); $form->addCheckbox('remove_' . $f->id, 'Remove photo'); } $form->addFile($f->name, $f->label); break;
function showThumb($id, $title = '', $w = 50, $h = 50) { $i = new XhtmlComponentImage(); $i->src = getThumbUrl($id, $w, $h); $i->alt = strip_tags($title); $i->title = strip_tags($title); return $i->render(); }
switch ($f->mimetype) { case 'audio/wav': // works in FF6, Chrome, Safari, Opera // works in FF6, Chrome, Safari, Opera case 'audio/x-wav': case 'audio/mp3': // works in IE9, Chrome, Safari, NOT IN FF6 // works in IE9, Chrome, Safari, NOT IN FF6 case 'audio/ogg': // works in FF6, Chrome, Safari, Opera // works in FF6, Chrome, Safari, Opera case 'audio/x-m4a': // works in Chrome, NOT IN FF6, ??? in IE9 $a = new XhtmlComponentAudio(); $a->src = 'c/file/' . $f->id; echo $a->render(); break; case 'image/jpeg': case 'image/png': case 'image/gif': $i = new XhtmlComponentImage(); $i->title = $f->name; $i->src = 'c/file/' . $f->id; $i->width = 250; echo $i->render(); break; default: echo 'SKIPPING: ' . $f->mimetype . '<br/>'; // d($f); } echo '<br/>';