Icon class


General News

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

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

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

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


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

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

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

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

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


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

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

}

?>

Continue Reading

Locator Plugin Updated, Weather Plugin Released


Products

A Weather plugin has been released for glFusion 1.2.0 and higher.  This plugin uses Google's weather API to retrieve weather conditions based on postal code or city & state.  The block at the left is an example of this plugin in action.

The Locator plugin has been updated to version 1.0.2.  This release includes a fix for cases where floating-point numbers use a comma as the decimal separator, which MySQL cannot handle.  Also new is integration with the new Weather plugin, allowing weather conditions to be displayed on the location pages.

Continue Reading

Form Plugin Beta Released for glFusion


Products

An initial beta version of the Forms plugin has been released at www.glfusion.org.  This plugin is based conceptually on the robust nexForm plugin for Geeklog by Nextide.  This is a simplified version, noticeably missing many of the layout functions of the Nextide version, and is intended to be a simple and straightforward method of creating custom forms and storing use responses.

This is the first public beta release, use at your own risk.  This plugin has performed well in limited testing on a public site, but your mileage may vary.

Update:  Version 0.1.1 is available for download.  This version adds static and calculate fields.

Continue Reading

Banner Plugin for glFusion 0.1.1 Available


General News

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.

Custom Profile Plugin 1.0.1 Released


Products

The Custom Profile plugin has been updated to version 1.0.1. This plugin allows the site administrator to create custom user data fields, such as address, phone number, membership ID, all without editing templates or code. This release contains minor fixes for issues reported in 1.0.0.

Continue Reading

PayPal plugin version 0.4.1 for glFusion released


Products

It seems that some users of the PayPal plugin version 0.4.0 are having trouble adding new products to the database. This issue cannot be duplicated in development or testing environments, so there's no firm fix yet. However, version 0.4.1 of the plugin includes a global "debug" option which will cause a variety of messages to be logged to the site's error.log file where they can be viewed with the log viewer. Hopefully this will help troubleshoot the issue. Version 0.4.1 is available now for download at www.glfusion.org.

Updated PayPal Plugin Released for glFusion


Products

The PayPal plugin for glFusion has been updated to version 0.4.0.  This version brings several changes, most notably the ability to automatically create encrypted PayPal buttons and the ability for other plugins to provide products or services for sale.

This release is available in the download area at the glFusion web site.  Be sure to back up your database before installing or updating this plugin- there have been a lot of changes to the schema.

Documentation can be found in the wiki.

glFusion Plugin Update


Products

An issue has been discovered with unescaped strings being sent to the search function in several plugins.  Aside from simply being a bad practice, this caused SQL errors when suspect string were submitted in the search form.

The affected plugins are:

  • Classified Ads
  • Daily Quotes
  • Geo Locator

Updated versions have been uploaded to glFusion.org

Custom Profile Plugin 1.0.0 Released


Products

Version 1.0.0 of the Custom Profile plugin for glFusion has been released and is available for download here.  This version makes use of the new template variables available in glFusion 1.1.7 to allow the site administrator to create custom user profiles without any template or code changes!.

 

The fields may be text, checkbox, radio buttons or dates; may optionally appear on the registration form; and may be editable by the user (or only by administrators).

Banner Plugin for glFusion Released


Products

Banner Ads for glFusion 0.0.2 has been released at www.glfusion.org.  This allows the administrator to display rotating banner ads in header, footer or side blocks.  Banners may be uploaded images, remotely hosted images, or HTML/Javascript, such as Google Adsense.

Documentation for this plugin can be found here.