Random Image
Idle Lobster Traps
My Account

Icon class


Icon::Get() returns the "img src" tag or "<i></i>" tags for an icon, depending on configuration (see the fake $_CONF['use_image_icons'] variable). CSS icons can come from Uikit or Fontawesome since I've noticed that non-Uikit themes include Fontawesome fonts. Not sure if this is still true.

Personally I like switching all to the CSS icons which have the advantage of taking color attributes like "danger", "warning", "grey", etc.

<?php


class Icon
{
    private static $images = array(
            'add', 'edit', 'copy', 'delete',
            'list', 'mail', 'group', 'user',
            'greyuser','check', 'greycheck',
            'cross', 'disk', 'accept', 'addchild',
            'update', 'wrench', 'info', 'greyinfo',
            'blank'
        );
    private static $icons = array(
            'add'       => 'plus-circle',
            'edit'      => 'edit',
            'copy'      => 'copy',
            'delete'    => 'remove',
            'list'      => 'list',
            'mail'      => 'enveloope-o',
            'group'     => 'group',
            'user'      => 'user',
            'greyuser'  => 'user',
            'check'     => 'check',
            'greycheck' => 'check',
            'cross'     => 'plus',
            'disk'      => 'save',
            'accept'    => 'check',
            'addchild'  => 'user-plus',
            'update'    => 'save',
            'wrench'    => 'wrench',
            'info'      => 'info-circle',
            'greyinfo'  => 'info-circle',
            'blank'     => '',
    );
    private static $prefix = NULL;

    /**
    *   Get a glFusion image icon
    *
    *   @param  string  $name   Name of icon, following the iconset prefix
    *   @param  array   $attrs  Optional attributes to embed in the icon HTML
    *   @return string      Full <img .../> tag for the icon
    */
    public static function getImage($name, $attrs = array())
    {
        global $_CONF, $_IMAGE_TYPE, $LANG_ADMIN, $_SYSTEM;

        if (!in_array($name, self::$icons)) $name = 'blank';

        $icon_url = "{$_CONF['layout_url']}/images/admin/$name.$_IMAGE_TYPE";
        if (!isset($attrs['alt'])) {
            $alt = isset($attrs['title']) ? $attrs['title'] : $LANG_ADMIN[$name];
        } else {
            $alt = $attrs['alt'];
        }
        return COM_createImage($icon_url, $alt, $attrs);
    }


    /**
    *   Get a CSS icon from Uikit or Fontawesom
    *
    *   @param  string  $name   Name of icon, following the iconset prefix
    *   @param  array   $attrs  Optional attributes to embed in the icon HTML
    *   @return string      Full <i...></i> tag for the icon
    */
    public static function getCSS($name, $attrs = array())
    {
        global $LANG_ADMIN, $_SYSTEM;

        if (self::$prefix === NULL) {
            self::$prefix = ($_SYSTEM['framework'] == 'uikit') ? 'uk-icon uk-' : 'fa fa-';
        }

        $attr_str = '';
        if (!isset($attrs['alt'])) {
            $attrs['alt'] = isset($attrs['title']) ? $attrs['title'] : $LANG_ADMIN[$name];
        }

        if (isset(self::$icons[$name])) {
            $name = self::$icons[$name];
        }

        foreach ($attrs as $attr_name=>$attr_value) {
            $attr_str .= ' ' . $attr_name . '="' . $attr_value . '"';
        }
        $icon = '<i class="' . self::$prefix . $name . '"' . $attr_str . '></i>';
        return $icon;
    }


    /**
    *   Get the image or CSS icon depending on configuration.
    *
    *   @param  string  $name   Name of icon, following the iconset prefix
    *   @param  array   $attrs  Optional attributes to embed in the icon HTML
    *   @return string      Full <i...></i> tag for the icon
    */
    public static function Get($name, $attrs = array())
    {
        global $_CONF;

        if ($_CONF['use_image_icons']) {
            return self::getImage($name, $attrs);
        } else {
            return self::getCSS($name, $attrs);
        }
    }

}

?>

Small World Workshop


Accompanying Noella Ballenger on her Small World workshop yielded some different ways of looking at something as simple as a flower. 

 

Despite the high winds, a few usable photographs were obtained.

Banner Plugin for glFusion 0.1.1 Available


Version 0.1.1 of the Banner Plugin for glFusion is now available. This version fixes a few issues, including a fatal error that would occur under PHP 4. The checking for topic limits was also re-worked so that banners, categories, and campaigns may be restricted to specific topics.

  • Added topic limits to Banners and Campaigns
  • Fixed the plugin crashing under PHP 4
  • Campaign IDs with spaces caused problems in Campaign::getBanners()
  • Impressions and Max Impressions were not saved when the banner form was saved
  • Added click tracking to HTML ads
  • Added a "target" option for each ad
  • Banners weren't displayed in stories
  • Centerblock wasn't working, should work properly now.

New Site Online


This site has been moved from E107 to Geeklog.  Please be patient as we finish the conversion.
Random Image
Idle Lobster Traps
My Account