Changeset 818


Ignore:
Timestamp:
Sep 10, 2024 12:05:14 AM (9 days ago)
Author:
anonymous
Message:

Update printSortSelectMenu()

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/examples/_config.inc.php

    r803 r818  
    116116
    117117    // Prettify json when testing.
    118     'json_options' => ENVIRONMENT === PRODUCTION ? 0 : JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES,
     118    'json_options' => ENVIRONMENT === PRODUCTION ? 0 : JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE,
    119119]);
    120120
  • trunk/lib/App.inc.php

    r815 r818  
    234234
    235235        // Prettify json when testing.
    236         'json_options' => JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES,
     236        'json_options' => JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE,
    237237    );
    238238
  • trunk/lib/SortOrder.inc.php

    r812 r818  
    234234    *
    235235    * @access   public
    236     * @param    array   $cols   Array of column keys (printed in <option value="
">) and names (human-readable)
     236    * @param    array   $cols   Array of column keys and optional sort orders (printed in <option value="
">) and names (human-readable). E.g.:
     237    *                           [
     238    *                               'lecture_tbl.added_datetime--ASC' => _("Added date (oldest first)"),
     239    *                               'lecture_tbl.added_datetime--DESC' => _("Added date (newest first)"),
     240    *                           ]
    237241    * @return
    238242    * @author   Quinn Comendant <quinn@strangecode.com>
    239243    * @since    18 May 2019 15:27:21
    240244    */
    241     public function printSortSelectMenu($cols)
    242     {
    243         $app =& App::getInstance();
    244 
    245         ?><select name="sort" id="sort"><?php
     245    public function printSortSelectMenu($cols, $select_attributes='name="sort" id="sort"')
     246    {
     247        $app =& App::getInstance();
     248
     249        ?><select <?php echo $select_attributes; ?>><?php
    246250        foreach ($cols as $col => $col_name) {
    247             if (!isset($this->_columns[$col])) {
     251            list($sort, $order) = array_pad(explode('--', $col), 2, null);
     252            if (!isset($this->_columns[$sort])) {
    248253                $app->logMsg(sprintf('Sort select option %s is not setup via setColumn', $col), LOG_NOTICE, __FILE__, __LINE__);
    249254            }
    250255            printf('<option value="%s"%s>%s</option>',
    251256                $col,
    252                 ($this->sort_by == $col ? ' selected="selected"' : ''),
     257                ($this->sort_by == $sort && (!isset($order) || $this->order == $order) ? ' selected="selected"' : ''),
    253258                strip_tags($col_name)
    254259            );
Note: See TracChangeset for help on using the changeset viewer.