function editFormHtml($record) { // set field attributes $description = getEvalOutput(@$this->description); $fieldHeight = @$this->fieldHeight ? $this->fieldHeight : 100; $fieldPrefix = @$this->fieldPrefix; if ($fieldPrefix != '') { $fieldPrefix .= "<br/>\n"; } // get field value if ($record) { $fieldValue = @$record[$this->name]; } else { if (array_key_exists($this->name, $_REQUEST)) { $fieldValue = @$_REQUEST[$this->name]; } else { $fieldValue = getEvalOutput(@$this->defaultContent); } } $encodedValue = htmlencode($fieldValue); // display field print <<<__HTML__ <tr> <td style="vertical-align: top">{$this->label}</td> <td> {$fieldPrefix} <textarea name="{$this->name}" id="field_{$this->name}" rows="5" cols="40" style="width: 100%; height: {$fieldHeight}px; visibility: hidden;">{$encodedValue}</textarea> {$description} </td> </tr> __HTML__; }
function getTableRow($record, $value, $formType) { $html = ''; if ($this->separatorType == 'blank line') { $html .= " <tr>\n"; $html .= " <td> </td>\n"; $html .= " <td> </td>\n"; $html .= " </tr>\n"; } else { if ($this->separatorType == 'header bar') { $html .= " <tr>\n"; $html .= " <td colspan='2' >\n"; $html .= " <div class='content-box content-box-divider'>\n"; $html .= " <div class='content-box-header'><h3>{$this->separatorHeader}</h3></div>\n"; $html .= " </div>\n"; $html .= " </td>\n"; $html .= " </tr>\n"; } else { if ($this->separatorType == 'html') { $html .= getEvalOutput($this->separatorHTML); } else { die("Unknown separator type '{$this->separatorType}'!"); } } } // return $html; }
function editFormHtml($record) { // set field attributes $fieldHeight = @$this->fieldHeight ? $this->fieldHeight : 100; $fieldPrefix = @$this->fieldPrefix; if ($fieldPrefix != '') { $fieldPrefix .= "<br/>\n"; } // get field value if ($record) { $fieldValue = @$record[$this->name]; } else { if (array_key_exists($this->name, $_REQUEST)) { $fieldValue = @$_REQUEST[$this->name]; } else { $fieldValue = getEvalOutput(@$this->defaultContent); } } // if ($this->autoFormat) { $fieldValue = preg_replace("/<br\\/>\n/", "\n", $fieldValue); } // remove autoformat break tags $encodedValue = htmlencode($fieldValue); // display field print <<<__HTML__ <tr> <td style="vertical-align: top">{$this->label}</td> <td> {$fieldPrefix} <textarea name="{$this->name}" style="width: 100%; height: {$fieldHeight}px" rows="5" cols="50">{$encodedValue}</textarea> </td> </tr> __HTML__; }
function editFormHtml($record) { global $isMyAccountMenu; // set field attributes $formRowAttrs = array('inputType' => @$this->isPasswordField ? 'password' : 'text', 'maxLengthAttr' => @$this->maxLength ? "maxlength='{$this->maxLength}'" : '', 'styleWidth' => @$this->fieldWidth ? "{$this->fieldWidth}px" : "250px", 'description' => getEvalOutput(@$this->description), 'prefixText' => @$this->fieldPrefix, 'readOnly' => ''); // get field value if ($record) { $fieldValue = @$record[$this->name]; } else { if (array_key_exists($this->name, $_REQUEST)) { $fieldValue = @$_REQUEST[$this->name]; } else { $fieldValue = getEvalOutput(@$this->defaultValue); } } $encodedValue = htmlencode($fieldValue); // special case for My Account's password field if ($isMyAccountMenu && $this->name == 'password') { $this->_editFormRow($formRowAttrs + array('label' => t('Current Password'), 'fieldname' => 'password:old', 'encodedValue' => '')); $this->_editFormRow($formRowAttrs + array('label' => t('New Password'), 'fieldname' => $this->name, 'encodedValue' => '')); $this->_editFormRow($formRowAttrs + array('label' => t('New Password (again)'), 'fieldname' => 'password:again', 'encodedValue' => '')); } else { $this->_editFormRow($formRowAttrs + array('label' => $this->label, 'fieldname' => $this->name, 'encodedValue' => $encodedValue)); } }
function getTableRow($record, $value, $formType) { // $formType is edit or view if (!$record) { die(basename(__FILE__) . ':' . __FUNCTION__ . ": record not defined!"); } $label = @$this->label; $fieldPrefix = @$this->fieldPrefix; $description = getEvalOutput(@$this->description); // display field $html = <<<__HTML__ <tr> <td style="vertical-align: top">{$label}</td> <td> <span>{$fieldPrefix}</span> {$value} <span>{$description}</span> </td> </tr> __HTML__; return $html; }
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"; }
<div id="footer"> <small> <?php if ($SETTINGS['footerHTML']) { echo getEvalOutput($SETTINGS['footerHTML']) . '<br/>'; } $executeSecondsString = sprintf(t("%s seconds"), showExecuteSeconds(true)); echo applyFilters('execute_seconds', $executeSecondsString); ?> <?php doAction('admin_footer'); ?> <!-- --> </small> </div> </div> <!-- End #main-content --> </div> <!-- End #body-wrapper --> <div class="clear"></div> </body> </html>
function getTableRow($record, $value, $formType) { global $isMyAccountMenu; $parentTable = $GLOBALS['menu']; // set field attributes $relatedTable = $this->relatedTable; $relatedWhere = getEvalOutput(@$this->relatedWhere); $seeMoreLink = @$this->relatedMoreLink ? "?menu={$relatedTable}&search=1&_ignoreSavedSearch=1&" . getEvalOutput($this->relatedMoreLink) : ''; // load list functions require_once "lib/menus/default/list_functions.php"; require_once "lib/viewer_functions.php"; // save and update globals list($originalMenu, $originalTableName, $originalSchema) = array($GLOBALS['menu'], $GLOBALS['tableName'], $GLOBALS['schema']); $GLOBALS['menu'] = $relatedTable; $GLOBALS['tableName'] = $relatedTable; $GLOBALS['schema'] = loadSchema($relatedTable); $GLOBALS['schema'] = array_merge($GLOBALS['schema'], getSchemaFields($GLOBALS['schema'])); // v2.16+, add pseudo-fields name and _tableName to all fieldSchemas. Doing this once here instead of every time in loadSchema() is less expensive // load list data list($listFields, $records, $metaData) = list_functions_init(array('isRelatedRecords' => true, 'tableName' => $relatedTable, 'where' => $relatedWhere, 'perPage' => @$this->relatedLimit)); ### show header $html = ''; $recordCount = count($records); $oneOrZero = $recordCount > 0 ? 1 : 0; $seeMoreHTML = $seeMoreLink ? "<br/><a href='{$seeMoreLink}'>" . htmlencode(t("see related records >>")) . "</a>" : ''; $showingText = sprintf(t('Showing %1$s - %2$s of %3$s related records'), $oneOrZero, $recordCount, $metaData['totalRecords']); ob_start(); ?> <tr><td colspan="2"> <div class="clear"></div> <div class="content-box"> <div class="content-box-header"> <div style="float:right; text-align: right; line-height: 110%"> <?php echo $showingText; ?> <?php echo $seeMoreHTML; ?> </div> <h3><?php echo $this->label; ?> <!-- --></h3> <div class="clear"></div> </div> <!-- End .content-box-header --> <div class="content-box-content"> <?php $html .= ob_get_clean(); ### show body // show list ob_start(); showListTable($listFields, $records, array('isRelatedRecords' => true, 'showView' => @$this->relatedView, 'showModify' => @$this->relatedModify, 'showErase' => @$this->relatedErase, 'showCreate' => @$this->relatedCreate)); $html .= ob_get_clean(); ### get footer $buttonsRight = ''; if (@$this->relatedCreate) { // show "create" button for related records $buttonsRight = relatedRecordsButton(t('Create'), "?menu={$relatedTable}&action=edit&{$parentTable}Num=###"); } $tableName = $relatedTable; $isRelatedTable = true; $buttonsRight = applyFilters('list_buttonsRight', $buttonsRight, $tableName, $isRelatedTable); $html .= <<<__FOOTER__ <div style='float:right; padding-top: 3px'> {$buttonsRight} </div> <div class='clear'></div> </div><!-- End .content-box-content --> </div><!-- End .content-box --> </td></tr> __FOOTER__; // reset globals list($GLOBALS['menu'], $GLOBALS['tableName'], $GLOBALS['schema']) = array($originalMenu, $originalTableName, $originalSchema); // return $html; }
function _addUndefinedDefaultsToNewRecord($colsToValues, $mySqlColsAndTypes) { global $schema; if (!$schema) { die("No \$schema defined!"); } $currentDate = date("Y-m-d H:i:s"); // set default to required Format: YYYY-MM-DD HH:MM:SS $dateFieldDefault = $currentDate; foreach ($mySqlColsAndTypes as $colName => $colType) { // set special field values if ($colName == 'createdDate') { $colsToValues[$colName] = $currentDate; } else { if ($colName == 'createdByUserNum') { $colsToValues[$colName] = $GLOBALS['CURRENT_USER']['num']; } else { if ($colName == 'dragSortOrder') { $colsToValues[$colName] = @$_REQUEST['dragSortOrder'] ? $_REQUEST['dragSortOrder'] : time(); } else { if ($colName == 'siblingOrder') { $colsToValues[$colName] = time(); } } } } // sort to bottom // skip fields with a value already if (array_key_exists($colName, $colsToValues)) { continue; } // skip if already defined //Pick a default date to use for date fields if (@$schema[$colName]['type'] == 'date') { if (@$schema[$colName]['defaultDate'] == 'custom' && @$schema[$colName]['defaultDateString']) { $dateFieldDefault = date("Y-m-d H:i:s", strtotime($schema[$colName]['defaultDateString'])); } elseif ($schema[$colName]['defaultDate'] == 'none') { $dateFieldDefault = "0000-00-00 00:00:00"; } else { $dateFieldDefault = $currentDate; } } // set adminOnly fields to default value (they'd have a value assigned already if user was admin) $isAdminOnly = @$schema[$colName]['adminOnly']; $fieldType = @$schema[$colName]['type']; if ($isAdminOnly && $fieldType == 'textfield') { $colsToValues[$colName] = getEvalOutput(@$schema[$colName]['defaultValue']); } else { if ($isAdminOnly && $fieldType == 'list') { $colsToValues[$colName] = getEvalOutput(@$schema[$colName]['defaultValue']); } else { if ($isAdminOnly && $fieldType == 'textbox') { $colsToValues[$colName] = getEvalOutput(@$schema[$colName]['defaultContent']); } else { if ($isAdminOnly && $fieldType == 'wysiwyg') { $colsToValues[$colName] = getEvalOutput(@$schema[$colName]['defaultContent']); } else { if ($isAdminOnly && $fieldType == 'checkbox') { $colsToValues[$colName] = (int) @$schema[$colName]['checkedByDefault']; } else { if (@$schema[$colName]['type'] == 'date') { $colsToValues[$colName] = $dateFieldDefault; } else { if (preg_match("/^\\w*datetime/i", $colType)) { $colsToValues[$colName] = $currentDate; } else { if (preg_match("/^\\w*int/i", $colType)) { $colsToValues[$colName] = '0'; } else { $colsToValues[$colName] = ''; } } } } } } } } // default all other field to blank } return $colsToValues; }
function _showCheckbox($fieldSchema, $record) { // set field attributes $checkedAttr = ''; if (array_key_exists($fieldSchema['name'], $_REQUEST)) { $checkedAttr = @$_REQUEST[$fieldSchema['name']] ? 'checked="checked"' : ''; } else { if ($record && @$record[$fieldSchema['name']]) { $checkedAttr = 'checked="checked"'; } else { if (!@$record['num'] && $fieldSchema['checkedByDefault']) { $checkedAttr = 'checked="checked"'; } } } $prefixText = @$fieldSchema['fieldPrefix']; $description = getEvalOutput(@$fieldSchema['description']); // v2.52 // display field print <<<__HTML__ <tr> <td valign="top">{$fieldSchema['label']}</td> <td> {$prefixText} <input type="hidden" name="{$fieldSchema['name']}" value="0" /> <input type="checkbox" name="{$fieldSchema['name']}" value="1" id="{$fieldSchema['name']}" {$checkedAttr}/> <label for="{$fieldSchema['name']}">{$description}<!-- --></label> </td> </tr> __HTML__; }
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"; }
function getListOptionsFromSchema($fieldSchema, $record = null, $useCache = false, $listValues = null) { global $TABLE_PREFIX; $listOptions = array(); $optionsType = @$fieldSchema['optionsType']; // get list values to lookup $listValuesAsCSV = ''; if ($listValues) { foreach ($listValues as $value) { $listValuesAsCSV .= "'" . mysql_escape($value) . "',"; } $listValuesAsCSV = chop($listValuesAsCSV, ','); // remove trailing comma } ### parse text options if ($optionsType == 'text') { // parse $optionText = explode("\n", @$fieldSchema['optionsText']); foreach ($optionText as $optionString) { if (preg_match("/(^|[^\\|])(\\|\\|)*(\\|)(?!\\|)/", $optionString, $match, PREG_OFFSET_CAPTURE)) { $delimiterOffset = $match[3][1]; $value = substr($optionString, 0, $delimiterOffset); $label = substr($optionString, $delimiterOffset + 1); } else { $value = $optionString; $label = $optionString; } $value = str_replace("||", "|", $value); $label = str_replace("||", "|", $label); // remove trailing whitespace $value = rtrim($value); $label = rtrim($label); $listOptions[] = array($value, $label); } } else { $cacheTable = ''; // create query if ($optionsType == 'table') { $valueField = @$fieldSchema['optionsValueField']; $labelField = @$fieldSchema['optionsLabelField']; $selectTable = $TABLE_PREFIX . $fieldSchema['optionsTablename']; $tableSchema = loadSchema($fieldSchema['optionsTablename']); $where = $listValuesAsCSV ? "WHERE `{$valueField}` IN ({$listValuesAsCSV})" : ''; $orderBy = @$tableSchema['listPageOrder'] ? "ORDER BY {$tableSchema['listPageOrder']}" : ''; $query = "SELECT `{$valueField}`, `{$labelField}` FROM `{$selectTable}` {$where} {$orderBy} LIMIT 0, 999"; $cacheTable = $fieldSchema['optionsTablename']; } else { if ($optionsType == 'query') { $filterFieldValue = @$record[@$fieldSchema['filterField']]; $GLOBALS['ESCAPED_FILTER_VALUE'] = mysql_escape($filterFieldValue); $query = getEvalOutput($fieldSchema['optionsQuery']); if (preg_match("/\\bFROM\\s+(\\S+)/", $query, $matches)) { $cacheTable = $matches[1]; $cacheTable = preg_replace("/\\W/", '', $cacheTable); // remove ` quotes, etc } } else { die("Unknown optionsType '{$optionsType}'!"); } } // load cache module if ($useCache && $cacheTable) { $libDir = dirname(__FILE__); if (file_exists("{$libDir}/viewer_turboCache.php")) { require_once "{$libDir}/viewer_turboCache.php"; } // load cached result if (!function_exists('turboCache_load')) { die("Error: 'useCaching' enabled but no caching plugin found!<br/>Either disable 'useCaching' or install caching plugin."); } $listOptions = turboCache_load($cacheTable, $query); if ($listOptions) { return $listOptions; } } // execute query $result = @mysql_query($query); if (!$result) { $error = "There was an error creating the list field '" . @$fieldSchema['name'] . "'.\n\n"; $error .= "MySQL Error: " . mysql_error() . "\n\n"; header("Content-type: text/plain"); die($error); } while ($row = mysql_fetch_row($result)) { $value = $row[0]; $label = array_key_exists(1, $row) ? $row[1] : $value; // use value if no label specified $listOptions[] = array($value, $label); } if (is_resource($result)) { mysql_free_result($result); } // save to cache if ($useCache && $cacheTable) { turboCache_save($cacheTable, $query, $listOptions); } } // return $listOptions; }
if ($CURRENT_USER) { $headerLinks .= "<a href='?menu=_myaccount'>" . t('My Account') . "</a>"; } if ($CURRENT_USER) { $headerLinks .= " | <a href='?action=logoff'>" . sprintf(t("Logoff (%s)"), htmlencode($CURRENT_USER['username'])) . "</a>"; } // Help | License | View Website >> if ($headerLinks) { $headerLinks .= "<br/>\n"; } if ($SETTINGS['helpUrl']) { $headerLinks .= "<a href='" . getEvalOutput($SETTINGS['helpUrl']) . "' target='_blank'>" . t('Help') . "</a> | "; } $headerLinks .= "<a href='?menu=license'>" . t('License') . "</a> | "; if ($SETTINGS['websiteUrl']) { $headerLinks .= "<a href='" . getEvalOutput($SETTINGS['websiteUrl']) . "' target='_blank' class='mLink'>" . t('View Website >>') . "</a><br/>"; } // echo applyFilters('header_links', $headerLinks); ?> </div> <?php if ($CURRENT_USER) { ?> <ul id="main-nav"> <?php echo $menuLinks; ?> </ul>