예제 #1
0
function ajaxGetUsersAsPulldown()
{
    global $TABLE_PREFIX, $hasEditorAccess, $tableName;
    if (!$hasEditorAccess) {
        return '';
    }
    // must have section admin access
    // get users with access to this section
    $query = "SELECT u.num, u.username\n              FROM {$TABLE_PREFIX}accounts u\n              JOIN {$TABLE_PREFIX}_accesslist a ON u.num = a.userNum\n             WHERE a.accessLevel > 1 AND a.tableName IN ('all','{$tableName}')\n             ORDER BY username";
    $users = mysql_select_query($query);
    // get option values
    $userNums = array_pluck($users, 'num');
    $userNames = array_pluck($users, 'username');
    $optionsHTML = getSelectOptions(null, $userNums, $userNames);
    // show pulldown
    $selectHTML = "<select name='createdByUserNum'>\n";
    $selectHTML .= "<option value=''>" . htmlencode(t("<select user>")) . "</option>\n";
    $selectHTML .= $optionsHTML;
    $selectHTML .= "</select>\n";
    //
    print $selectHTML;
    exit;
}
function getSearchFieldLabelsAndHTML()
{
    global $schema, $tableName;
    $searchFieldLabelsAndHtml = array();
    // display search fields
    $searchRows = _parseSearchFieldsFormat($schema['listPageSearchFields']);
    foreach ($searchRows as $searchRow) {
        list($label, $fieldnames, $displayAs, $searchFieldSuffix) = $searchRow;
        $isMulti = false;
        if (count($fieldnames) === 1 && preg_match('/^\\w+\\[\\]$/', $fieldnames[0])) {
            $fieldnames[0] = trim(@$fieldnames[0], '[]');
            $isMulti = true;
        }
        $fieldsAsCSV = join(',', $fieldnames);
        $name = "{$fieldsAsCSV}_{$searchFieldSuffix}";
        $lastValue = @$_REQUEST[$name];
        // get fieldschema for single field searches:
        $fieldSchema = @$schema[$fieldnames[0]];
        if ($fieldSchema) {
            $fieldSchema['name'] = $fieldnames[0];
        }
        // special case: add createdBy.fieldname search functionality
        if (preg_match("/^createdBy\\.(.*?)\$/i", $fieldsAsCSV, $matches)) {
            $name = 'createdByUserNum_match';
            $labelField = $matches[1];
            $lastValue = @$_REQUEST[$name];
            $displayAs = 'dropdown';
            $fieldSchema = array('name' => '_not_used_', 'optionsType' => 'table', 'optionsTablename' => 'accounts', 'optionsValueField' => 'num', 'optionsLabelField' => $matches[1]);
            // list all users who have records in this section
            $fieldSchema = array('name' => '_not_used_', 'optionsType' => 'query', 'optionsQuery' => "SELECT a.num, a.`{$labelField}`\n                                  FROM {$GLOBALS['TABLE_PREFIX']}accounts a\n                                  JOIN `{$GLOBALS['TABLE_PREFIX']}{$tableName}` f ON a.num = f.createdByUserNum\n                              ORDER BY a.`{$labelField}`");
            /*
              // list all users who have access to create records in this section
              $fieldSchema = array(
                'name'              => '_not_used_',
                'optionsType'       => 'query',
                'optionsQuery'      => "SELECT a.num, a.`$labelField`
                                          FROM {$GLOBALS['TABLE_PREFIX']}accounts a
                                          JOIN `{$GLOBALS['TABLE_PREFIX']}_accesslist` al ON a.num = al.userNum
                                         WHERE al.accessLevel > 1 AND al.tableName IN ('all','$tableName')
                                      ORDER BY a.`$labelField`",
              );
            */
        }
        // generate html
        $html = '';
        if ($displayAs == 'textfield') {
            $html .= "<input class='text-input' type='text' name='{$name}' value='" . htmlencode($lastValue) . "' size='30' />";
        } else {
            if ($displayAs == 'checkbox') {
                $checkedValue = getFirstDefinedValue(@$fieldSchema['checkedValue'], t('Checked'));
                $uncheckedValue = getFirstDefinedValue(@$fieldSchema['uncheckedValue'], t('Unchecked'));
                $optionValues = array('1', '0');
                $optionLabels = array($checkedValue, $uncheckedValue);
                $optionsHTML = getSelectOptions($lastValue, $optionValues, $optionLabels, false);
                $html .= "<select name='{$name}'>";
                $html .= "<option value=''>" . htmlencode(t("<any>")) . "</option>\n";
                $html .= $optionsHTML;
                $html .= "</select>";
            } else {
                if ($displayAs == 'dropdown') {
                    $optionsHTML = getSelectOptionsFromSchema($lastValue, $fieldSchema, false);
                    if ($isMulti) {
                        $html .= "<select name='{$name}[]' multiple>";
                    } else {
                        $html .= "<select name='{$name}'>";
                    }
                    $html .= "<option value=''>" . htmlencode(t("<any>")) . "</option>\n";
                    $html .= $optionsHTML;
                    $html .= "</select>";
                } else {
                    if ($displayAs == 'custom') {
                        $functionName = $searchFieldSuffix;
                        if (!function_exists($functionName)) {
                            die("Search function '" . htmlencode($functionName) . "' doesn't exist!<br/>Check: Admin &gt; Section Editors &gt; Search &gt; Search Fields");
                        }
                        $html .= call_user_func($functionName);
                        if (!$html) {
                            continue;
                        }
                        // return nothing from function to not display search field
                    } else {
                        die("Unknown search field type '" . htmlencode($displayAs) . "'!");
                    }
                }
            }
        }
        // add instructions for date search fields
        if (@$fieldSchema['type'] == 'date' && count($fieldnames) == 1) {
            $html .= ' &nbsp; ';
            $html .= t('Format:');
            $html .= ' YYYY-MM-DD ';
            if (@$fieldSchema['showTime']) {
                $html .= ' HH:MM:SS ';
            }
            // custom datepicker code - this is only called is jqueryUI datepicker is loaded
            $jsDateFormat = @$fieldSchema['showTime'] ? "yy-mm-dd 00:00:00" : "yy-mm-dd";
            $buttonImageUrl = CMS_ASSETS_URL . "/3rdParty/jqueryUI/calendar.gif";
            $html .= <<<__HTML__
        <script type='text/javascript'><!--
          \$(function() {
            if (\$.datepicker != undefined) {
              \$('[name={$name}]').datepicker({  // this is from: lib/menus/default/list_functions.php
                showOn: 'button',
                //buttonImage: '<?php echo CMS_ASSETS_URL ?>/3rdParty/jqueryUI/calendar.gif',
                buttonImage: '{$buttonImageUrl}',
                buttonImageOnly: true,
                dateFormat: '{$jsDateFormat}'
              });
            }
          });
        //--></script>
__HTML__;
        }
        //
        $searchFieldLabelsAndHtml[] = array($label, $html);
    }
    //
    return $searchFieldLabelsAndHtml;
}
<div id="content" class="wide">
    <ul class="nav nav-tabs" id="stat-nav">
      <li class="active"><a href="/stat/recommend">推荐人</a></li>
      <li><a href="/stat/candidate">候选人</a></li>
      <li><a href="/stat/partner">银杏伙伴</a></li>
      <li><a href="/stat/data">项目数据</a></li>
    </ul>
    <h5>推荐人相关信息,包含了推荐人数量,推荐的候选人数量,推荐数量的TOP排名</h5>
     <form class="filter" action="/stat/recommend" method="get" style="margin: 20px 0">
        <select class="chosen-select span2" multiple name="gender[]" data-placeholder=" - 推荐人性别 -"><?php 
echo getSelectOptions("gender");
?>
</select>
        <select class="chosen-select span2" multiple name="name[]" data-placeholder=" - 推荐人姓名 -"><?php 
echo getSelectOptions("user_info.name");
?>
</select>
        <input type="submit" class="btn btn-stat" value="筛选">
        <a type="button" href="/stat/recommend" class="btn btn-stat" >重置</a>
    </form>
    <table class="table table-striped table-hover home-tb">
      <tr>
        <td class="l">推荐人总数:</td>
        <td class="r"><?php 
echo $recommend_count;
?>
</td>
        <td class="l">候选人总数:</td>
        <td class="r"><?php 
echo $candidate_count;
예제 #4
0
if ($CURRENT_USER['isAdmin']) {
    $advancedCommands['Admin: Code Generator'] = '?menu=_codeGenerator&tableName=' . $GLOBALS['tableName'];
}
$advancedCommands = applyFilters('list_advancedCommands', $advancedCommands);
if ($advancedCommands) {
    $labels = array_map('t', array_keys($advancedCommands));
    // translate labels
    ?>
          <select name="_advancedAction">
            <option value=''><?php 
    et('Advanced Commands...');
    ?>
</option>
            <option value=''>&nbsp;</option>
            <?php 
    echo getSelectOptions(null, array_values($advancedCommands), $labels);
    ?>
          </select>
          <input name="_advancedActionSubmit" value=" go "  class="button" type="submit" />
          <br />
          <?php 
}
?>

    </div>
    <div style="float:right">
      <?php 
echo $buttonsRight;
?>
    </div>
    <div class="clear"></div>
예제 #5
0
          <?php 
echo getSelectOptions($selectedOption, array_keys($columnTypesNumeric), array_values($columnTypesNumeric));
?>
        
        </optgroup>

        <optgroup label="Text/String Types">
          <?php 
echo getSelectOptions($selectedOption, array_keys($columnTypesString), array_values($columnTypesString));
?>
        
        </optgroup>
        
        <optgroup label="Custom Types">
          <?php 
echo getSelectOptions($selectedOption, array_keys($columnTypesCustom), array_values($columnTypesCustom));
?>
        
        </optgroup>
        
      </select>
      <div class="customColumnRow" <?php 
echo $textfieldValue ? '' : 'style="display: none;"';
?>
>
        <input class="text-input" name="customColumnType" size="60" value="<?php 
echo htmlencode($textfieldValue);
?>
" />
        <a href="http://dev.mysql.com/doc/refman/5.0/en/data-type-overview.html" target="_blank">MySQL Data Types &gt;&gt;</a>
      </div>
예제 #6
0
function getSelectOptionsFromSchema($selectedValue, $fieldSchema, $showEmptyOptionFirst = false)
{
    // error checking
    if (!$fieldSchema) {
        die(__FUNCTION__ . ": No fieldSchema specified!");
    }
    if (!@$fieldSchema['name']) {
        die(__FUNCTION__ . ": fieldSchema must have fieldname defined in 'name'!");
    }
    // get field options
    $optionValues = array();
    $optionLabels = array();
    $listOptions = getListOptionsFromSchema($fieldSchema);
    foreach ($listOptions as $valueAndLabel) {
        list($optionValue, $optionLabel) = $valueAndLabel;
        $optionValues[] = $optionValue;
        $optionLabels[] = $optionLabel;
    }
    $optionsHTML = getSelectOptions($selectedValue, $optionValues, $optionLabels, $showEmptyOptionFirst);
    //
    return $optionsHTML;
}
<div id="content" class="wide">
    <ul class="nav nav-tabs" id="stat-nav">
      <li><a href="/stat/recommend">推荐人</a></li>
      <li><a href="/stat/candidate">候选人</a></li>
      <li class="active"><a href="/stat/partner">银杏伙伴</a></li>
      <li><a href="/stat/data">项目数据</a></li>
    </ul>
    <h5>银杏伙伴相关信息,包含了银杏伙伴数量,地区排名,性别比例</h5>
    <form class="filter" action="/stat/partner" method="get" style="margin: 20px 0">
        <select class="chosen-select span2" multiple name="address_province[]" data-placeholder=" - 银杏伙伴省份 -"><?php 
echo getSelectOptions("user_recommends.address_province", "partner");
?>
</select>
        <select class="chosen-select span2" multiple name="gender[]" data-placeholder=" - 银杏伙伴性别 -"><?php 
echo getSelectOptions("user_info.gender");
?>
</select>
        <input type="submit" class="btn btn-stat" value="筛选">
        <a type="button" href="/stat/partner" class="btn btn-stat" >重置</a>
    </form>

    <table class="table table-striped table-hover home-tb">
      <tr>
        <td class="l">银杏伙伴数量:</td>
        <td class="r"><?php 
echo $partner_count;
?>
</td>
      </tr>
    </table>
예제 #8
0
            <form class="clearfix" action="reservation.php" method="post">
                <div id="departDIV">
                    <label for="depart">Départ:</label><br>
                    <select name="depart" id="depart">
                        <option value="" disabled selected>Selectionner</option>
                        <?php 
getSelectOptions("station");
?>
                    </select>
                </div>
                <div id="destinationDIV">
                    <label for="destination">Déstination:</label><br>
                    <select name="destination" id="destination">
                        <option value="" disabled selected>Selectionner</option>
                        <?php 
getSelectOptions("station");
?>
                    </select>
                </div>
                <div id="passagerDIV">
                    <label for="passager">Nb. de Passagers:</label><br>
                    <select name="passager" id="passager" >
                        <option value="" disabled selected>Selectionner</option>
                        <?php 
for ($i = 1; $i < 41; $i++) {
    echo '<option valuer="' . $i . '">' . $i . ' personnes</option>';
}
?>
                    </select>
                </div>
                <div id="retourDIV">
예제 #9
0
    
    <tr>
      <td width="200"><?php 
et("Login Timeouts");
?>
</td>
      <td>
        <?php 
et("Automatically expire login sessions after");
?>
        <input type="text" name="login_expiry_limit" value="<?php 
echo htmlencode(@$SETTINGS['advanced']['login_expiry_limit']);
?>
" size="4" maxlength="4" class="text-input" style="width: 3em; text-align: center">
        <?php 
$htmlOptions = getSelectOptions(@$SETTINGS['advanced']['login_expiry_unit'], array('minutes', 'hours', 'days', 'months'), array(t('minutes'), t('hours'), t('days'), t('months')));
?>
        <select name="login_expiry_unit"><?php 
echo $htmlOptions;
?>
</select><br/>
      </td>
    </tr>    

    <tr><td colspan="2">&nbsp;</td></tr>

    <tr>
      <td width="200"><?php 
et('Hide PHP Errors');
?>
</td>
예제 #10
0
?>

      </td>
     </tr>

    </table>

   <table border="0" cellspacing="0" cellpadding="1" class="options" id="advancedTabOptions" style="display: none; width: 100%;">
     <tr>
      <td class="labelColumn"><?php 
et('Per Page');
?>
</td>
      <td>
        <?php 
$optionsHTML = getSelectOptions(coalesce(@$schema['_perPageDefault'], 25), array(5, 10, 25, 50, 100, 250, 1000));
?>
        <select name="_perPageDefault"><?php 
echo $optionsHTML;
?>
</select>&nbsp;<?php 
echo t('Default number of records to show per page');
?>
     </tr>
     <tr>
      <td class="labelColumn"><?php 
et('Max Records');
?>
</td>
      <td><input class="text-input" type="text" name="_maxRecords" value="<?php 
echo htmlencode(@$schema['_maxRecords']);
function cg2_option_selectSection($allowedMenuTypes = array())
{
    // 2.62 - added allowedMenuTypes
    // get options HTML
    $valuesToLabels = array();
    $skippedMenuTypes = array('', 'menugroup', 'link');
    foreach (getSortedSchemas() as $tableName => $schema) {
        if ($skippedMenuTypes && in_array(@$schema['menuType'], $skippedMenuTypes)) {
            continue;
        }
        if ($allowedMenuTypes && !in_array(@$schema['menuType'], $allowedMenuTypes)) {
            continue;
        }
        if (@$schema['menuHidden']) {
            continue;
        }
        $menuType = @$schema['menuType'];
        $valuesToLabels[$tableName] = @$schema['menuName'] . " ({$menuType})";
    }
    $optionsHTML = getSelectOptions(@$_REQUEST['tableName'], array_keys($valuesToLabels), array_values($valuesToLabels), true);
    if (!$optionsHTML) {
        $optionsHTML = "<option value=''>" . t("No matching sections were found") . "</option>\n";
    }
    ?>
  <div class="fieldOption">
    <div class="label" style="padding-top: 6px"><?php 
    et('Select Section');
    ?>
</div>
    <div style="float:left">
      <select name="tableName"><?php 
    echo $optionsHTML;
    ?>
</select>
    </div>
    <div class="clear"></div>
  </div>
<?php 
}
function __getCategoryNames_asSelectOptions($fieldname)
{
    $tableName = @$_REQUEST['tableName'];
    // options
    $showRootOption = $fieldname == 'rootCategoryNum';
    $showEmptyOptionFirst = $fieldname == 'defaultCategoryNum';
    // eg: <select>
    // if no table...
    if (!$tableName) {
        $htmlOptions = "<option value=''>" . htmlencode(t('<select section above>')) . "</option>";
    } else {
        // load categories
        $query = "SELECT num, name, breadcrumb, depth\n                     FROM `{$GLOBALS['TABLE_PREFIX']}{$tableName}` ORDER BY `globalOrder`";
        $categories = mysql_select_query($query);
        // load option values
        $selectedValues = @$_REQUEST[$fieldname];
        $optionValues = array_pluck($categories, 'num');
        $optionLabels = array();
        foreach ($categories as $category) {
            //$optionLabels[] = htmlencode($category['breadcrumb']);
            $optionLabels[] = str_repeat("&nbsp; &nbsp;", $category['depth']) . htmlencode($category['name']);
        }
        // get html
        $htmlOptions = '';
        if ($showRootOption) {
            $htmlOptions .= "<option value=''>" . t('Root (show all categories)') . "</option>\n";
        }
        $htmlOptions .= getSelectOptions($selectedValues, $optionValues, $optionLabels, $showEmptyOptionFirst, false);
        if (!$optionValues) {
            $htmlOptions .= "<option value=''>" . htmlencode(t('<no records found>')) . "</option>\n";
        }
    }
    //
    return $htmlOptions;
}
예제 #13
0
function getStationByName($name)
{
    $repo = EManager::getEntityManager()->getRepository('Station');
    $station = $repo->findBy(array('name' => $name));
    if (isset($station) && count($station) == 1) {
        echo "<option id=" . $station[0]->getId() . ">" . $station[0]->getName() . "</option>";
    } else {
        getSelectOptions("station");
    }
}
function getBackupFiles_asOptions($defaultValue = '')
{
    //
    $backupFiles = getBackupFiles_asArray();
    // sort recently modified files first
    array_multisort(@array_map(create_function('$x', 'return filemtime(DATA_DIR."/backups/".$x);'), $backupFiles), SORT_DESC, $backupFiles);
    //
    if (!$backupFiles) {
        $labelsToValues = array(t('There are no backups available') => '');
    } else {
        $labelsToValues = array(t('Select version to restore') => '');
        $labelsToValues = $labelsToValues + array_combine($backupFiles, $backupFiles);
    }
    //
    $values = array_values($labelsToValues);
    $labels = array_keys($labelsToValues);
    $htmlOptions = getSelectOptions($defaultValue, $values, $labels, false);
    //
    return $htmlOptions;
}