function editFormHtml($record) { global $escapedTableName, $CURRENT_USER; // set field attributes $fieldValue = $record ? @$record[$this->name] : ''; // load categories $categoriesByNum = array(); $query = "SELECT * FROM `{$escapedTableName}` ORDER BY globalOrder"; $result = mysql_query($query) or die("MySQL Error: " . mysql_error() . "\n"); while ($row = mysql_fetch_assoc($result)) { $isOwner = @$row['createdByUserNum'] == $CURRENT_USER['num']; if (@$row['createdByUserNum'] && (!$isOwner && !$GLOBALS['hasEditorAccess'])) { continue; } $categoriesByNum[$row['num']] = $row; } if (is_resource($result)) { mysql_free_result($result); } // print " <tr>\n"; print " <td>{$this->label}</td>\n"; print " <td>\n"; print " <select name='{$this->name}'>\n"; print " <option value='0'>None (top level category)</option>\n"; foreach ($categoriesByNum as $num => $category) { $value = $category['num']; $selectedAttr = selectedIf($value, $fieldValue, true); $encodedLabel = htmlencode($category['breadcrumb']); $isUnavailable = preg_match("/:" . @$record['num'] . ":/", $category['lineage']); $extraAttr = $isUnavailable ? "style='color: #AAA' disabled='disabled' " : ''; print "<option value=\"{$value}\" {$extraAttr} {$selectedAttr}>{$encodedLabel}</option>\n"; } print " </select>\n"; // print " </td>\n"; print " </tr>\n"; }
function editFormHtml($record) { // set field attributes $listOptions = getListOptionsFromSchema($this, $record); $valignTop = $this->listType != 'pulldown' ? 'style="vertical-align: top;"' : ''; $prefixText = @$this->fieldPrefix; $description = getEvalOutput(@$this->description); // get field value if ($record) { $fieldValue = @$record[$this->name]; } else { if (array_key_exists($this->name, $_REQUEST)) { $fieldValue = join("\t", (array) @$_REQUEST[$this->name]); } else { $fieldValue = ''; } } $fieldValues = preg_split("/\t/", $fieldValue, -1, PREG_SPLIT_NO_EMPTY); // for multi value fields $encodedValue = htmlencode($fieldValue); // get list of values in database that aren't in list options (happens when list values are removed or field // ... was a textfield than switched to a pulldown that doesn't offer all the previously entered values as options $fieldValuesNotInList = array(); $listOptionValues = array(); foreach ($listOptions as $optionArray) { list($value, $label) = $optionArray; $listOptionValues[] = $value; } $fieldValuesNotInList = array_diff($fieldValues, $listOptionValues); $noLongerInListText = count($fieldValuesNotInList) > 1 ? t('Previous selections (no longer in list)') : t('Previous selection (no longer in list)'); // print " <tr>\n"; print " <td {$valignTop}>{$this->label}</td>\n"; print " <td>\n"; // pulldown if ($this->listType == 'pulldown') { print "{$prefixText}\n"; print " <select name='{$this->name}'>\n"; print " <option value=''><select></option>\n"; foreach ($listOptions as $optionArray) { list($value, $label) = $optionArray; $encodedValue = htmlencode($value); $selectedAttr = selectedIf($value, $fieldValue, true); $encodedLabel = htmlencode($label); print "<option value=\"{$encodedValue}\" {$selectedAttr}>{$encodedLabel}</option>\n"; } // show database values not in current list options if ($fieldValuesNotInList) { print " <optgroup label='{$noLongerInListText}'>\n"; foreach ($fieldValuesNotInList as $value) { print " <option value=\"" . htmlencode($value) . "\" selected='selected'>" . htmlencode($value) . "</option>\n"; } print " </optgroup>\n"; } print " </select>\n"; print "{$description}\n"; } else { if ($this->listType == 'pulldownMulti') { if ($prefixText) { print "{$prefixText}<br/>\n"; } print " <select name='{$this->name}[]' multiple='multiple' size='5'>\n"; foreach ($listOptions as $optionArray) { list($value, $label) = $optionArray; $encodedValue = htmlencode($value); $selectedAttr = in_array($value, $fieldValues) ? 'selected="selected"' : ''; $encodedLabel = htmlencode($label); print "<option value=\"{$encodedValue}\" {$selectedAttr}>{$encodedLabel}</option>\n"; } // show database values not in current list options if ($fieldValuesNotInList) { print " <optgroup label='{$noLongerInListText}'>\n"; foreach ($fieldValuesNotInList as $value) { print " <option value=\"" . htmlencode($value) . "\" selected='selected'>" . htmlencode($value) . "</option>\n"; } print " </optgroup>\n"; } print " </select>\n"; if ($description) { print "<br/>{$description}\n"; } } else { if ($this->listType == 'radios') { if ($prefixText) { print "{$prefixText}<br/>\n"; } foreach ($listOptions as $optionArray) { list($value, $label) = $optionArray; $encodedValue = htmlencode($value); $encodedLabel = htmlencode($label); $checkedAttr = $value == $fieldValue ? 'checked="checked"' : ''; $idAttr = "{$this->name}.{$encodedValue}"; print "<input type='radio' name='{$this->name}' value='{$encodedValue}' id='{$idAttr}' {$checkedAttr}/>\n"; print "<label for='{$idAttr}'>{$encodedLabel}</label><br />\n\n"; } // show database values not in current list options if ($fieldValuesNotInList) { print "{$noLongerInListText}<br />\n"; foreach ($fieldValuesNotInList as $value) { $encodedValue = htmlencode($value); $encodedLabel = htmlencode($value); $idAttr = "{$this->name}.{$encodedValue}"; print "<input type='radio' name='{$this->name}' value='{$encodedValue}' id='{$idAttr}' checked='checked'/>\n"; print "<label for='{$idAttr}'>{$encodedLabel}</label><br />\n\n"; } } if ($description) { print "{$description}\n"; } } else { if ($this->listType == 'checkboxes') { if ($prefixText) { print "{$prefixText}<br/>\n"; } foreach ($listOptions as $optionArray) { list($value, $label) = $optionArray; $encodedValue = htmlencode($value); $encodedLabel = htmlencode($label); $checkedAttr = in_array($value, $fieldValues) ? 'checked="checked"' : ''; $idAttr = "{$this->name}.{$encodedValue}"; print "<input type='checkbox' name='{$this->name}[]' value='{$encodedValue}' id='{$idAttr}' {$checkedAttr}/>\n"; print "<label for='{$idAttr}'>{$encodedLabel}</label><br />\n"; } // show database values not in current list options if ($fieldValuesNotInList) { print "{$noLongerInListText}<br />\n"; foreach ($fieldValuesNotInList as $value) { $encodedValue = htmlencode($value); $encodedLabel = htmlencode($value); $idAttr = "{$this->name}.{$encodedValue}"; print "<input type='checkbox' name='{$this->name}[]' value='{$encodedValue}' id='{$idAttr}' checked='checked' />\n"; print "<label for='{$idAttr}'>{$encodedLabel}</label><br />\n\n"; } } if ($description) { print "{$description}\n"; } } else { die("Unknown listType '{$this->listType}'!"); } } } } // list fields w/ advanced filters - add onchange event handler to local filter field if (@$this->filterField) { ?> <script type="text/javascript"><!-- $("[name='<?php echo $this->filterField; ?> ']").change(function () { var targetListField = '<?php echo $this->name; ?> '; var newFilterValue = this.value; updateListFieldOptions(targetListField, newFilterValue); }); // --></script> <?php } // print " </td>\n"; print " </tr>\n"; }
<option value='0' <?php selectedIf($field['adminOnly'], '0'); ?> > <?php echo t('Everyone'); ?> </option> <option value='1' <?php selectedIf($field['adminOnly'], '1'); ?> > <?php echo t('Editor Only'); ?> </option> <option value='2' <?php selectedIf($field['adminOnly'], '2'); ?> > <?php echo t('Admin Only'); ?> </option> </select> <label for="adminOnly"><?php echo t('Access Level - Choose if field has edit access restrictions.'); ?> </label><br/> </div> <div style="display: none" class="fieldOption isPasswordField"> <div class="label clear"> </div> <div>
function getTableRow($record, $value, $formType) { global $TABLE_PREFIX; // load access list $accessList = array(); if (@$_REQUEST['num']) { $query = "SELECT * FROM `{$TABLE_PREFIX}_accesslist` WHERE userNum = '" . mysql_escape($_REQUEST['num']) . "'"; $result = mysql_query($query) or die("MySQL Error: " . htmlencode(mysql_error()) . "\n"); while ($record = mysql_fetch_assoc($result)) { $accessList[$record['tableName']] = $record; } } // get section list $sectionList = array(); foreach (getSchemaTables() as $tableName) { $schema = loadSchema($tableName); $allowedMenuTypes = array('single', 'multi', 'category', 'menugroup', 'link', 'custom'); if (!in_array(@$schema['menuType'], $allowedMenuTypes)) { continue; } $thisMenu = array(); $thisMenu['menuName'] = htmlencode($schema['menuName']); if (@$schema['menuType'] != 'menugroup') { $thisMenu['menuName'] = ' ' . $thisMenu['menuName']; } if (@$schema['_indent']) { $thisMenu['menuName'] = ' ' . $thisMenu['menuName']; } $thisMenu['menuOrder'] = $schema['menuOrder']; $thisMenu['tableName'] = $tableName; $thisMenu['menuType'] = $schema['menuType']; array_push($sectionList, $thisMenu); } uasort($sectionList, '_sortMenusByOrder'); // sort menus by order value // display field $allAccessLevel = @$accessList['all']['accessLevel']; $sectionsDivStyle = $allAccessLevel != 1 ? "display: none;" : ''; // ob_start(); ?> <tr> <td valign="top" style="padding-top: 2px"><?php echo $this->label; ?> </td> <td> <table border="0" cellspacing="1" cellpadding="0"> <thead> <tr> <th width="305"><?php et('Section Name'); ?> </th> <th width="115" style="text-align: center"><?php et('Access'); ?> </th> <th width="100" style="text-align: center"><?php et('Max Records'); ?> </th> </tr> </thead> <tr> <td class="listRow listRowOdd"><?php et('All Sections'); ?> </td> <td class="listRow listRowOdd" style="text-align: center"> <select name="accessList[all][accessLevel]" style="width: 140px" onchange="(this.value=='1') ? $('.sectionAccessList').slideDown() : $('.sectionAccessList').slideUp();"> <option value="0" <?php selectedIf($allAccessLevel, '0'); ?> ><?php et('None'); ?> </option> <option value="3" <?php selectedIf($allAccessLevel, '3'); ?> ><?php et('Viewer'); ?> </option> <option value="6" <?php selectedIf($allAccessLevel, '6'); ?> ><?php et('Author'); ?> </option> <option value="7" <?php selectedIf($allAccessLevel, '7'); ?> ><?php eht('Author & Viewer'); ?> </option> <option value="9" <?php selectedIf($allAccessLevel, '9'); ?> ><?php et('Editor'); ?> </option> <option value="1" <?php selectedIf($allAccessLevel, '1'); ?> ><?php et('By Section'); ?> </option> </select> </td> <td class="listRow listRowOdd" style="text-align: center"><?php et('No Limit'); ?> </td> </tr> </table> <script type="text/javascript"> function toggleDisabledForAccessListMaxRecords(tablename) { var accessLevel = $("#accesslevel_"+tablename).val(); var disableMaxRecords = (accessLevel == 9 || accessLevel == 3); if (disableMaxRecords) { $("#maxRecords_"+tablename).attr("disabled", true).css("background-color","#DDD"); } else { $("#maxRecords_"+tablename).removeAttr("disabled").css("background-color","#FFF"); } } </script> <div class="sectionAccessList" style="<?php echo $sectionsDivStyle; ?> "> <div style="width: 0px; height: 0px;"></div><?php /* fixes IE7 issue which caused table to get no layout space, causing overlap and missing table content. the issue seems to be caused by a div with only a table inside. adding anything else inside the div seems to fix it, including  , but that adds extra whitespace, hence the div with no area */ ?> <table border="0" cellspacing="1" cellpadding="0"> <?php // list sections foreach ($sectionList as $section) { $bgColorClass = @$bgColorClass == "listRowEven" ? 'listRowOdd' : 'listRowEven'; # rotate bgclass $fieldnamePrefix = "accessList[{$section['tableName']}]"; $accessLevel = @$accessList[$section['tableName']]['accessLevel']; $maxRecords = @$accessList[$section['tableName']]['maxRecords']; $disableMaxRecords = $accessLevel == 9 || $accessLevel == 3; $maxRecordsAttr = $disableMaxRecords ? 'style="text-align: center; background-color: #DDD;" disabled="disabled"' : 'style="text-align: center;"'; ?> <tr> <td class="listRow <?php echo $bgColorClass; ?> " width="305"> <?php echo $section['menuName']; ?> </td> <td class="listRow <?php echo $bgColorClass; ?> " width="115" style="text-align: center"> <?php if ($section['menuType'] == 'single' || $section['tableName'] == 'accounts' || $section['menuType'] == 'menugroup' || $section['menuType'] == 'link') { ?> <input type="hidden" name="<?php echo $fieldnamePrefix; ?> [accessLevel]" value="0" /> <input type="checkbox" name="<?php echo $fieldnamePrefix; ?> [accessLevel]" value="9" <?php checkedIf($accessLevel, '9'); ?> /> <?php } elseif ($section['menuType'] == 'multi') { ?> <select name="<?php echo $fieldnamePrefix; ?> [accessLevel]" id="accesslevel_<?php echo $section['tableName']; ?> " style="width: 140px" onchange="toggleDisabledForAccessListMaxRecords('<?php echo $section['tableName']; ?> ')"> <option value="0" <?php selectedIf($accessLevel, '0'); ?> ><?php et('None'); ?> </option> <option value="3" <?php selectedIf($accessLevel, '3'); ?> ><?php et('Viewer'); ?> </option> <option value="6" <?php selectedIf($accessLevel, '6'); ?> ><?php et('Author'); ?> </option> <option value="7" <?php selectedIf($accessLevel, '7'); ?> ><?php eht('Author & Viewer'); ?> </option> <option value="9" <?php selectedIf($accessLevel, '9'); ?> ><?php et('Editor'); ?> </option> </select> <?php } elseif ($section['menuType'] == 'category') { ?> <select name="<?php echo $fieldnamePrefix; ?> [accessLevel]" id="accesslevel_<?php echo $section['tableName']; ?> " style="width: 140px" onchange="toggleDisabledForAccessListMaxRecords('<?php echo $section['tableName']; ?> ')"> <option value="0" <?php selectedIf($accessLevel, '0'); ?> ><?php et('None'); ?> </option> <option value="9" <?php selectedIf($accessLevel, '9'); ?> ><?php et('Editor'); ?> </option> </select> <?php } ?> </td> <td class="<?php echo $bgColorClass; ?> " width="100" style="text-align: center"> <?php if ($section['menuType'] == 'single') { printf(t("Single Page")); } elseif ($section['tableName'] == 'accounts') { ?> <?php } elseif ($section['menuType'] == 'multi') { ?> <input class="text-input medium-input" type="text" name="<?php echo $fieldnamePrefix; ?> [maxRecords]" id="maxRecords_<?php echo $section['tableName']; ?> " value="<?php echo $maxRecords; ?> " size="6" maxlength="6" <?php echo $maxRecordsAttr; ?> /> <?php } ?> </td> </tr> <?php } ?> </table></div> <br/><div style="font-size: 11px"> <b><?php et('Access Levels:'); ?> </b><br/> <div style="padding-left: 20px;"> <?php et('None - Don\'t allow user to access this section'); ?> <br/> <?php et('Viewer - User can view any record in this section (must also be enabled in section editor)'); ?> <br/> <?php et('Author - User can only access records they have created'); ?> <br/> <?php eht("Author & Viewer - User can view any record and modify records they've created"); ?> <br/> <?php et('Editor - User can access any records in this section'); ?> <br/> </div> <?php et('Max Records: Max records user is allowed to create (for regular users only - leave blank for unlimited)'); ?> </div> </td> </tr> <?php $html = ob_get_clean(); return $html; }
<option value="80" <?php selectedIf($SETTINGS['advanced']['imageResizeQuality'], '80'); ?> ><?php et('Normal - Good balance of quality and file size'); ?> </option> <option value="90" <?php selectedIf($SETTINGS['advanced']['imageResizeQuality'], '90'); ?> ><?php et('High - Larger file size, high quality'); ?> </option> <option value="100" <?php selectedIf($SETTINGS['advanced']['imageResizeQuality'], '100'); ?> ><?php et('Maximum - Very large file size, best quality'); ?> </option> </select> </td> </tr> <tr> <td width="200"><?php et('WYSIWYG Options'); ?> </td> <td height="22" valign="top">
function _showParentCategory($fieldSchema, $record, $schema) { global $escapedTableName, $CURRENT_USER; // set field attributes $fieldValue = $record ? @$record[$fieldSchema['name']] : ''; // load categories $categoriesByNum = array(); $query = "SELECT * FROM `{$escapedTableName}` ORDER BY globalOrder"; $result = mysql_query($query) or die("MySQL Error: " . mysql_error() . "\n"); while ($row = mysql_fetch_assoc($result)) { $isOwner = @$row['createdByUserNum'] == $CURRENT_USER['num']; if (@$row['createdByUserNum'] && (!$isOwner && !$GLOBALS['hasEditorAccess'])) { continue; } $categoriesByNum[$row['num']] = $row; } if (is_resource($result)) { mysql_free_result($result); } // print " <tr>\n"; print " <td>{$fieldSchema['label']}</td>\n"; print " <td>\n"; print " <select name='{$fieldSchema['name']}'>\n"; print " <option value='0'>" . t('None (top level category)') . "</option>\n"; $maxDepth = (int) @$schema['_maxDepth']; // if the user specifies 1, that should mean no subcategories foreach ($categoriesByNum as $num => $category) { $value = $category['num']; $selectedAttr = selectedIf($value, $fieldValue, true); $encodedLabel = htmlencode($category['breadcrumb']); $exceedsMaxDepth = $maxDepth && $category['depth'] >= $maxDepth - 1; $isUnavailable = $exceedsMaxDepth || preg_match("/:" . @$record['num'] . ":/", $category['lineage']); $extraAttr = $isUnavailable ? "style='color: #AAA' disabled='disabled' " : ''; print "<option value=\"{$value}\" {$extraAttr} {$selectedAttr}>{$encodedLabel}</option>\n"; } print " </select>\n"; // print " </td>\n"; print " </tr>\n"; }
function editFormHtml($record) { global $SETTINGS; $mysqlDateFormat = 'Y-m-d H:i:s'; $prefixText = @$this->fieldPrefix; $description = getEvalOutput(@$this->description); // get default date if (@$this->defaultDate == 'none') { $defaultDateTime = ''; } elseif (@$this->defaultDate == 'custom') { $defaultDateTime = @date($mysqlDateFormat, strtotime($this->defaultDateString)); } else { $defaultDateTime = date($mysqlDateFormat); } // get date value(s) $dateValue = @$record[$this->name] ? $record[$this->name] : $defaultDateTime; list($date, $time, $year, $month, $day, $hour24, $min, $sec, $amOrPm, $hour12) = array(null, null, null, null, null, null, null, null, null, null); if ($dateValue && $dateValue != '0000-00-00 00:00:00') { // mysql will default undefined dates to null or 0000-00-00 00:00:00 list($date, $time) = explode(' ', $dateValue); // expecting: YYYY-MM-DD HH:MM:SS list($year, $month, $day) = explode('-', $date); // expecting: YYYY-MM-DD list($hour24, $min, $sec) = explode(':', $time); // expecting: HH:MM:SS $amOrPm = $hour24 >= 12 ? 'PM' : 'AM'; $hour12 = $hour24 % 12 == 0 ? 12 : $hour24 % 12; } // get month options $monthOptions = "<option value=''><!-- --></option>\n"; $shortMonthNames = preg_split("/\\s*,\\s*/", t('Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec')); foreach (range(1, 12) as $num) { $selectedAttr = selectedIf($num, $month, true); $shortMonthName = @$shortMonthNames[$num - 1]; $monthOptions .= "<option value=\"{$num}\" {$selectedAttr}>{$shortMonthName}</option>\n"; } // get day options $dayOptions = "<option value=''><!-- --></option>\n"; foreach (range(1, 31) as $num) { $selectedAttr = selectedIf($num, $day, true); $dayOptions .= "<option value=\"{$num}\" {$selectedAttr}>{$num}</option>\n"; } // get year options $yearOptions = "<option value=''><!-- --></option>\n"; if (!$this->yearRangeStart) { $this->yearRangeStart = date('Y') - 5; } // v2.16 - default to 5 years previous if undefined if (!$this->yearRangeEnd) { $this->yearRangeEnd = date('Y') + 5; } // v2.16 - default to 5 years ahead if undefined foreach (range((int) $this->yearRangeStart, (int) $this->yearRangeEnd) as $num) { // (int) for range bug in PHP < 4.23 - see docs $selectedAttr = selectedIf($num, $year, true); $yearOptions .= "<option value=\"{$num}\" {$selectedAttr}>{$num}</option>\n"; } // get hour options $hour24Options = "<option value=''><!-- --></option>\n"; $hour12Options = "<option value=''><!-- --></option>\n"; foreach (range(0, 23) as $num) { $zeroPaddedNum = sprintf("%02d", $num); $selectedAttr = selectedIf($num, $hour24, true); $hour24Options .= "<option value=\"{$num}\" {$selectedAttr}>{$zeroPaddedNum}</option>\n"; } foreach (range(1, 12) as $num) { $selectedAttr = selectedIf($num, $hour12, true); $hour12Options .= "<option value=\"{$num}\" {$selectedAttr}>{$num}</option>\n"; } // get minute options $minOptions = "<option value=''><!-- --></option>\n"; foreach (range(0, 59) as $num) { $zeroPaddedNum = sprintf("%02d", $num); $selectedAttr = selectedIf($num, $min, true); $minOptions .= "<option value=\"{$num}\" {$selectedAttr}>{$zeroPaddedNum}</option>\n"; } // get second options $secOptions = "<option value=''><!-- --></option>\n"; foreach (range(0, 59) as $num) { $zeroPaddedNum = sprintf("%02d", $num); $selectedAttr = selectedIf($num, $sec, true); $secOptions .= "<option value=\"{$num}\" {$selectedAttr}>{$zeroPaddedNum}</option>\n"; } // get AmPm optins $amSelectedAttr = selectedIf($amOrPm, 'AM', true); $pmSelectedAttr = selectedIf($amOrPm, 'PM', true); // display date field print " <tr>\n"; print " <td>{$this->label}</td>\n"; print " <td>{$prefixText}\n"; $monthsField = " <select name='{$this->name}:mon'>{$monthOptions}</select>\n"; $daysField = " <select name='{$this->name}:day'>{$dayOptions}</select>\n"; if ($SETTINGS['dateFormat'] == 'dmy') { print $daysField . $monthsField; } else { print $monthsField . $daysField; } print " <select name='{$this->name}:year'>{$yearOptions}</select>\n"; if ($this->showTime) { print " \n"; if ($this->use24HourFormat) { // show 24 hour time print " <select name='{$this->name}:hour24'>{$hour24Options}</select>\n"; print " <select name='{$this->name}:min'>{$minOptions}</select>\n"; if ($this->showSeconds) { print " <select name='{$this->name}:sec'>{$secOptions}</select>\n"; } } else { // show 12 hour time print " <select name='{$this->name}:hour12'>{$hour12Options}</select>\n"; print " <select name='{$this->name}:min'>{$minOptions}</select>\n"; if ($this->showSeconds) { print " <select name='{$this->name}:sec'>{$secOptions}</select>\n"; } print " <select name='{$this->name}:isPM'>\n"; print " <option value=''><!-- --></option>\n"; print " <option value='0' {$amSelectedAttr}>AM</option>\n"; print " <option value='1' {$pmSelectedAttr}>PM</option>\n"; print " </select>\n"; } } print " {$description}</td>\n"; print " </tr>\n"; }