echo 'Add as a '; Person_Group::printMembershipStatusChooser('membership_status'); echo ' of '; $can_add_group = Person_Group::printChooser('groupid', 0, array_keys($groups)); ?> </div> <div class="modal-footer"> <input type="submit" class="btn" value="Go" accesskey="s" onclick="if (!$('[name=groupid]').val()) { alert('Choose a group first'); return false; }" /> <button class="btn" data-dismiss="modal" aria-hidden="true">Cancel</button> </div> </form> </div> <?php } // -------- CHECK PERMISSIONS AND ASSEMBLE DATA ------------- // $accordion = SizeDetector::getWidth() && SizeDetector::isNarrow(); $tabs = array('basic' => 'Basic Details'); if ($GLOBALS['user_system']->havePerm(PERM_VIEWNOTE)) { $notes = $person->getNotesHistory(); $tabs['notes'] = 'Notes (' . count($notes) . ')'; } if ($can_add_group || count($groups) > 1) { $tabs['groups'] = 'Groups (' . count($groups) . ')'; } if ($GLOBALS['user_system']->havePerm(PERM_VIEWATTENDANCE)) { $tabs['attendance'] = 'Attendance'; } if ($GLOBALS['user_system']->havePerm(PERM_VIEWROSTER)) { $tabs['rosters'] = 'Rosters'; } if (!$accordion && ($GLOBALS['user_system']->havePerm(PERM_VIEWNOTE) || !$GLOBALS['system']->featureEnabled('NOTES'))) {
function print_widget($name, $params, $value) { $classes = array_get($params, 'class', ''); if (!array_get($params, 'allow_empty', 1)) { $classes .= ' compulsory'; } $attrs = array(); foreach (array_get($params, 'attrs', array()) as $attr => $val) { $attrs[] = $attr . '="' . ents($val) . '"'; } $attrs = implode(' ', $attrs); switch ($params['type']) { case 'phone': $lengths = get_valid_phone_number_lengths($params['formats']); $width = max(get_phone_format_lengths($params['formats'])); ?> <input name="<?php echo $name; ?> " type="tel" size="<?php echo $width; ?> " value="<?php echo format_phone_number($value, $params['formats']); ?> " class="phone-number" validlengths="<?php echo implode(',', $lengths); ?> " <?php echo $attrs; ?> /> <?php break; case 'bibleref': require_once 'bible_ref.class.php'; $br = new bible_ref($value); $value = $br->toShortString(); $params['class'] = 'bible-ref'; // fall through // fall through case 'text': case 'email': $maxlength_exp = empty($params['maxlength']) ? '' : 'maxlength="' . $params['maxlength'] . '"'; if (array_get($params, 'height', 1) > 1) { $cols_exp = empty($params['width']) ? '' : 'cols="' . $params['width'] . '"'; ?> <textarea name="<?php echo $name; ?> " rows="<?php echo $params['height']; ?> " <?php echo $cols_exp; ?> class="<?php echo trim($classes); ?> " <?php echo $maxlength_exp; ?> ><?php echo ents($value); ?> </textarea> <?php } else { $width_exp = empty($params['width']) ? '' : 'size="' . $params['width'] . '"'; $regex_exp = empty($params['regex']) ? '' : 'regex="' . trim($params['regex'], '/ ') . '"'; $autocomplete_exp = isset($params['autocomplete']) ? 'autocomplete=' . ($params['autocomplete'] ? 'on' : 'off') . '"' : ''; ?> <input type="<?php echo $params['type']; ?> " name="<?php echo $name; ?> " value="<?php echo ents($value); ?> " class="<?php echo trim($classes); ?> " <?php echo implode(' ', array($maxlength_exp, $width_exp, $regex_exp, $autocomplete_exp)); ?> <?php echo $attrs; ?> /> <?php } break; case 'html': static $includedCK = false; if (!$includedCK) { ?> <script src="<?php echo BASE_URL . 'resources/ckeditor/ckeditor.js'; ?> "></script> <?php } ?> <textarea class="ckeditor" name="<?php echo $name; ?> " <?php echo $attrs; ?> ><?php echo $value; ?> </textarea> <?php break; case 'int': $classes .= ' int-box'; $width_exp = ''; if (!empty($params['width'])) { $width_exp = 'size="' . $params['width'] . '" '; } else { $width_exp = 'size="3" '; } ?> <input type="text" name="<?php echo $name; ?> " value="<?php echo $value; ?> " class="<?php echo trim($classes); ?> " <?php echo $width_exp; ?> <?php echo $attrs; ?> /> <?php break; case 'select': $our_val = is_array($value) ? $value : ($value === '' ? array() : array("{$value}")); foreach ($our_val as $k => $v) { $our_val[$k] = "{$v}"; } if (array_get($params, 'style', 'dropbox') == 'colour-buttons') { ?> <div class="radio-button-group <?php echo array_get($params, 'class', ''); ?> " <?php if (!SizeDetector::isNarrow()) { echo ' tabindex="1"'; } ?> > <input type="hidden" name="<?php echo $name; ?> " value="<?php echo reset($our_val); ?> " /> <?php foreach ($params['options'] as $k => $v) { $classes = 'btn value-' . $k; if (in_array("{$k}", $our_val, true)) { $classes .= ' active'; } ?> <div class="<?php echo $classes; ?> " title="<?php echo $v; ?> " data-val="<?php echo $k; ?> " > <?php echo strtoupper($v[0]); ?> </div> <?php } ?> </div> <?php } else { if (array_get($params, 'allow_multiple')) { $height = array_get($params, 'height', min(count($params['options']), 4)); if (substr($name, -2) != '[]') { $name .= '[]'; } $style = 'height: ' . $height * 1.8 . 'em'; $classes .= ' multi-select'; // the empty onclick below is to make labels work on iOS // see http://stackoverflow.com/questions/5421659/html-label-command-doesnt-work-in-iphone-browser ?> <div class="<?php echo $classes; ?> " style="<?php echo $style; ?> " tabindex="0" onclick="" <?php echo $attrs; ?> > <?php foreach ($params['options'] as $k => $v) { $checked_exp = in_array("{$k}", $our_val, true) ? ' checked="checked"' : ''; $disabled_exp = !empty($params['disabled_prefix']) && strpos($k, $params['disabled_prefix']) === 0 ? ' disabled="disabled" ' : ''; ?> <label class="checkbox" title="<?php echo ents($v); ?> "> <input type="checkbox" name="<?php echo $name; ?> " value="<?php echo $k; ?> " <?php echo $checked_exp . $disabled_exp; ?> > <?php echo ents($v); ?> </label> <?php } ?> </div> <?php } else { ?> <select name="<?php echo $name; ?> " class="<?php echo $classes; ?> " <?php echo $attrs; ?> > <?php if (array_get($params, 'allow_empty') && !array_get($params, 'allow_multiple')) { ?> <option value=""><?php echo array_get($params, 'empty_text', '(None)'); ?> </option> <?php } foreach (array_get($params, 'options', array()) as $k => $v) { $selected_exp = in_array("{$k}", $our_val, true) ? ' selected="selected"' : ''; $disabled_exp = !empty($params['disabled_prefix']) && strpos($k, $params['disabled_prefix']) === 0 ? ' disabled="disabled" ' : ''; ?> <option value="<?php echo $k; ?> "<?php echo $selected_exp . $disabled_exp; ?> ><?php echo ents($v); ?> </option> <?php } ?> </select> <?php } } break; case 'date': $day_year_classes = trim($classes . ' int-box'); if (FALSE === strpos($name, '[')) { $name_template = $name . '%s'; } else { $name_template = substr($name, 0, strpos($name, '[')) . '%s' . substr($name, strpos($name, '[')); } $months = array(); if (array_get($params, 'allow_empty', false)) { $months[''] = '(Month)'; } for ($i = 1; $i < 13; $i++) { $months[$i] = date(array_get($params, 'month_format', 'F'), strtotime("2007-{$i}-01")); } if (empty($value)) { $value = date('Y-m-d'); } // blank dates not allowed list($year_val, $month_val, $day_val) = explode('-', substr($value, 0, 10)); ?> <span class="nowrap" <?php echo $attrs; ?> > <input type="text" name="<?php printf($name_template, '_d'); ?> " class="day-box <?php echo $day_year_classes; ?> " size="2" maxlength="2" value="<?php echo $day_val; ?> " placeholder="DD" /><select name="<?php printf($name_template, '_m'); ?> " class="month-box <?php echo $classes; ?> "> <?php foreach ($months as $i => $month_name) { $selected = $i == $month_val ? ' selected="selected"' : ''; ?> <option value="<?php echo $i; ?> "<?php echo $selected; ?> ><?php echo $month_name; ?> </option> <?php } ?> </select><input type="text" name="<?php printf($name_template, '_y'); ?> " class="year-box <?php echo $day_year_classes; ?> " size="4" maxlength="4" value="<?php echo $year_val; ?> " placeholder="YYYY"/> </span> <?php break; case 'reference': if (!empty($params['references'])) { $where = array(); if (!empty($params['filter']) && is_array($params['filter'])) { $where = $params['filter']; } $where_logic = array_get($params, 'filter_logic', 'AND'); $options = $GLOBALS['system']->getDBObjectData($params['references'], $where, $where_logic, array_get($params, 'order_by')); $dummy = new $params['references'](); $our_val = is_array($value) ? $value : (empty($value) ? array() : array($value)); if (!empty($params['filter']) && is_callable($params['filter'])) { foreach ($options as $i => $o) { $dummy->populate($i, $o); if (!in_array($i, $our_val) && !$params['filter']($dummy)) { unset($options[$i]); } } } $params['options'] = array(); foreach ($options as $k => $details) { $dummy->populate($k, $details); $params['options'][$k] = $dummy->toString(); } $params['type'] = 'select'; print_widget($name, $params, $value); } break; case 'bitmask': $value = (int) $value; ?> <div class="bitmask-boxes"> <?php $percol = false; $cols = 3; require_once 'include/size_detector.class.php'; if (SizeDetector::getWidth()) { if (SizeDetector::isNarrow()) { $cols = 1; } else { if (SizeDetector::isMedium()) { $cols = 2; } } } if ($cols > 1) { $percol = ceil(count($params['options']) / $cols); ?> <div class="bitmask-column" <?php echo $attrs; ?> > <?php } $i = 0; foreach ($params['options'] as $k => $v) { $checked_exp = ($value & (int) $k) == $k ? 'checked="checked"' : ''; // the empty onclick below is to make labels work on iOS // see http://stackoverflow.com/questions/5421659/html-label-command-doesnt-work-in-iphone-browser ?> <label class="checkbox" onclick=""> <input type="checkbox" name="<?php echo ents($name); ?> []" value="<?php echo ents($k); ?> " <?php echo $checked_exp; ?> > <?php echo nbsp(ents($v)); ?> </label> <?php if ($percol && ++$i % $percol == 0) { ?> </div> <div> <?php } } if ($percol) { ?> </div> <?php } ?> </div> <?php break; } }
<?php @session_start(); include 'size_detector.class.php'; SizeDetector::processRequest(); ?> <html> <head> <style>html,body { height: 100% }</style> </head> <body> <h1>Size Detector Test</h1> <pre style="border: 2px solid"> The server thinks the width is <?php echo SizeDetector::getWidth(); ?> and height is <?php echo SizeDetector::getHeight(); ?> </pre> <form method="post" style="border: 2px solid"> <?php SizeDetector::printFormFields(); ?> This is a form <input type="submit" /> </form> </body> </html>