Plugin Directory

Changeset 407210


Ignore:
Timestamp:
07/09/2011 01:44:13 AM (15 years ago)
Author:
cavemonkey50
Message:

Improves the account select dropdown by organizing the accounts. Props bluntly.

Location:
google-analyticator/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • google-analyticator/trunk/google-analyticator.php

    r407202 r407210  
    732732    <td>
    733733        <?php
     734        // sort the $ga_accounts array by ga:accountName and then title
     735        $sorted_ga_accounts = array();
     736        foreach ($ga_accounts as $ga_account) {
     737            $sorted_ga_accounts[$ga_account['ga:accountName']][] = $ga_account;
     738        }
     739        foreach( $sorted_ga_accounts as $id => $sorted_ga_account) {
     740            usort($sorted_ga_accounts[$id], 'ga_sort_account_list');
     741        }
     742       
    734743        # Create a select box   
    735744        echo '<select name="' . key_ga_uid . '" id="' . key_ga_uid . '">';
     
    737746   
    738747        # The list of accounts
    739         foreach ( $ga_accounts AS $account ) {
    740             $select = ( get_option(key_ga_uid) == $account['ga:webPropertyId'] ) ? ' selected="selected"' : '';
    741             echo '<option value="' . $account['ga:webPropertyId'] . '"' . $select . '>' . $account['title'] . '</option>';
     748        foreach ( $sorted_ga_accounts AS $account_name => $account_list ) {
     749            echo "<optgroup label='".htmlentities($account_name)."'>\n";
     750            foreach( $account_list as $account) {
     751                $select = ( get_option(key_ga_uid) == $account['ga:webPropertyId'] ) ? ' selected="selected"' : '';
     752                echo '<option value="' . $account['ga:webPropertyId'] . '"' . $select . '>' . $account['title'] . '</option>';
     753            }
     754            echo "</optgroup>\n";
    742755        }
    743756   
     
    751764    }
    752765    die();
     766}
     767
     768function ga_sort_account_list($a, $b) {
     769    return strcmp($a['title'],$b['title']);
    753770}
    754771
  • google-analyticator/trunk/readme.txt

    r407202 r407210  
    5252
    5353= 6.2 =
    54 * Adds a new option for site speed tracking (enabled by default)
    55 * Replaces deprecated tracking code _setVar with _setCustomVar
     54* Adds a new option for site speed tracking (enabled by default).
     55* Replaces deprecated tracking code _setVar with _setCustomVar.
     56* Improves the account select dropdown by organizing the accounts. Props bluntly.
    5657
    5758= 6.1.3 =
Note: See TracChangeset for help on using the changeset viewer.