. */ /** * Helper class for icon displaying in different layouts */ abstract class IconHelper { /** * Get the image tag for the given icon * * @param string $type of the wanted icon * @param string $title for the alt/title parameter * @param array $attributes additional attributes to add within the image tag */ public static function getIcon($type, $title, $attributes=NULL) { if( in_array($type, self::getAllIcons()) ) { return "\"".$title."\""; }else { return $title; } } /** * Checks if the current layout has all required icons * * @return NULL in case of no error, or an array of all missing icon types */ public static function checkLayout() { $missing = array(); foreach( self::getAllIcons() as $iconType ) { if( !isset($GLOBALS['LAYOUT_ICONS'][$iconType]) || !file_exists(self::getIconUrl($iconType)) ) { $missing[] = $iconType; } } if( count($missing)==0 ) { return null; }else { return $missing; } } private static function getIconUrl($type) { return ROOTPATH."layout/".$_SESSION['sess_layout']."/".$GLOBALS['LAYOUT_ICONS'][$type]; } private static function getAttributes($attributes) { if( $attributes==NULL ) { return ""; }else { $ret = ""; foreach( $attributes as $attribute=>$value ) { $ret .= $attribute . "=\"".$value."\" "; } return $ret; } } /** * Get an array of all available icons */ private static function getAllIcons() { return array('add', 'cancel', 'check', 'close', 'cross', 'delete', 'edit', 'info', 'mail', 'minus', 'save'); } } ?>