Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Sedo_Extra_Helper_Demo
- {
- //@ME: CHECK THIS FUNCTION : $myproperty = XenForo_Template_Helper_Core::styleProperty('myproperty');
- /******
- #GetDisplayValue
- This function gets the visual value of a display property. The value is returned in the following array: $return['result']
- If it is a color, the following arrays are also available:
- - $return['rgba'], for the rgba color value
- - $return['rgb'], for the rgb color value
- - $return['hexa'], for the hexa color value
- For a color, $return['result'] will return the rgba value for all recent browsers
- and will automatically return the rgb value for the old version of Internet Explorer
- ***/
- public static function GetDisplayValue($property, $defaultvalue)
- {
- $value = array();
- if (XenForo_Application::isRegistered('styles'))
- {
- $style = XenForo_Application::get('styles');
- }
- else
- {
- //ie: for XenForo_Template_Admin
- $style = XenForo_Model::create('XenForo_Model_Style')->getAllStyles();
- XenForo_Application::set('styles', $style);
- }
- $visitor = XenForo_Visitor::getInstance();
- $styleid = $visitor['style_id'];
- if($styleid == 0)
- {
- $options = XenForo_Application::get('options');
- $styleid = $options->defaultStyleId;
- }
- //Get current style properties
- if (isset($style[$styleid]['properties']))
- {
- $properties = $style[$styleid]['properties'];
- $properties = unserialize($properties);
- $value['result'] = $properties[$property];
- if (!is_array($value['result']) AND preg_match('#rgba#i', $value['result']))
- {
- $isBadIE = self::isBadIE();
- $value['rgba'] = $value['result'];
- $value['rgb'] = XenForo_Helper_Color::unRgba($value['result']);
- $value['hexa'] = self::rgb2hex($value['rgb']);
- if ($isBadIE == true)
- {
- $value['result'] = $value['rgb'];
- }
- }
- elseif (!is_array($value['result']) AND preg_match('#rgb(?!a)#i', $value['result']))
- {
- $value['rgba'] = XenForo_Helper_Color::rgba($value['result'], 1);
- $value['rgb'] = $value['result'];
- $value['hexa'] = self::rgb2hex($value['rgb']);
- }
- elseif ( !is_array($value['result']) ) //don't forget the hexa value options !
- {
- $value['rgba'] = XenForo_Helper_Color::rgba($value['result'], 1);
- $value['rgb'] = XenForo_Helper_Color::unRgba($value['rgba']);
- $value['hexa'] = self::rgb2hex($value['rgb']);
- }
- else
- {
- $value['rgba'] = $defaultvalue;
- $value['rgb'] = $defaultvalue;
- $value['hexa'] = $defaultvalue;
- }
- }
- else
- {
- $value['result'] = $defaultvalue;
- $value['rgba'] = $defaultvalue;
- $value['rgb'] = $defaultvalue;
- $value['hexa'] = $defaultvalue;
- }
- return $value;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement