Changeset 534 for trunk/lib/HTML.inc.php


Ignore:
Timestamp:
Jul 27, 2015 7:56:08 AM (9 years ago)
Author:
anonymous
Message:

Improved module maker validation output. Allow disabling cache at run time for ACL. Added ACL getList() method. Improved ACL CLI listing. Fixed app boomerang array initialization. Now retaining identical boomerang URLs if the key is different. Added a maximum boomerang time. Added a way to disable cache per request through a query string. Added validator isDecimal() method. Added disableSelectOptions() HTML method. Added getGravatarURL() method. Change how navigation page array is managed. Updated navigation currentPage() method to test an array of URLs.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/HTML.inc.php

    r502 r534  
    154154    }
    155155
     156    /*
     157    *
     158    *
     159    * @access   public
     160    * @param    array   $options    Array of options, with keys: value, selected, text
     161    * @param    array   $deselected Array of values to disable in options.
     162    * @return   array               Same options, but those with a value matching an element in $deselected will have a 'disabled' element of true.
     163    * @author   Quinn Comendant <quinn@strangecode.com>
     164    * @version  1.0
     165    * @since    24 Jul 2015 01:41:33
     166    */
     167    static public function disableSelectOptions($options, $deselected)
     168    {
     169        $app =& App::getInstance();
     170        $n = sizeof($options);
     171        for ($i=0; $i < $n; $i++) {
     172            $app->logMsg(sprintf('Disable check: %s == %s', $options[$i]['value'], getDump($deselected)), LOG_DEBUG, __FILE__, __LINE__);
     173            $options[$i]['disabled'] = in_array($options[$i]['value'], $deselected);
     174        }
     175        return $options;
     176    }
     177
    156178    /**
    157179     * Prints option fields for a select form. Works only with enum or set
     
    219241
    220242        foreach ($options as $o) {
    221             printf('<option value="%s"%s>%s</option>',
     243            printf('<option value="%s"%s%s>%s</option>',
    222244                oTxt($o['value']),
    223                 ($o['selected'] ? ' selected' : ''),
     245                (isset($o['selected']) && $o['selected'] ? ' selected' : ''),
     246                (isset($o['disabled']) && $o['disabled'] ? ' disabled' : ''),
    224247                oTxt($o['text'])
    225248            );
    226249        }
    227250    }
     251
     252    /**
     253     * Get a Gravatar URL for a specified email address.
     254     *
     255     * @param string $email The email address
     256     * @param string $size Size in pixels, defaults to 80px [ 1 - 2048 ]
     257     * @param string $d Default imageset to use [ 404 | mm | identicon | monsterid | wavatar ]
     258     * @param string $r Maximum rating (inclusive) [ g | pg | r | x ]
     259     * @return String containing a URL to a gravatar image.
     260     * @source http://gravatar.com/site/implement/images/php/
     261     */
     262    static public function getGravatarURL($email, $size=80, $defset='mm', $rating='g') {
     263        return sprintf('https://www.gravatar.com/avatar/%s?s=%s&d=%s&r=%s',
     264            md5(strtolower(trim($email))),
     265            $size,
     266            $defset,
     267            $rating
     268        );
     269    }
    228270}
Note: See TracChangeset for help on using the changeset viewer.