Exemplo n.º 1
0
	<?php 
/**
 * Star rating input view - an HTML tag back with a hidden input
 *
 * @uses $vars['class'] CSS class
 * @uses $vars['name'] Input name to retrieve the value in the action
 * @uses $vars['value'] Current value
 * @uses $vars['disabled'] Whether or not this is a readonly input
 * @uses $vars['min'] Minimum input value
 * @uses $vars['max'] Maximum input value
 * @uses $vars['step'] At what step the input values are iterated
 */
$settings = elgg_stars_get_rating_settings();
$id = md5(microtime());
$options = array('data-rateit-backingfld' => "#{$id}", 'data-rateit-readonly' => false, 'data-rateit-resetable' => 0);
if (isset($vars['class'])) {
    $options['class'] = "{$vars['class']} rateit";
    unset($vars['class']);
} else {
    $options['class'] = 'rateit';
}
if (isset($vars['name'])) {
    $name = $options['data-annotation-name'] = $vars['name'];
    unset($vars['name']);
} else {
    $name = $options['data-annotation-name'] = 'starrating';
}
if (isset($vars['value'])) {
    $value = $options['data-rateit-value'] = $vars['value'];
    unset($vars['value']);
}
Exemplo n.º 2
0
/**
 * Check if annotation value is in acceptable range
 *
 * @param float $val
 * @return boolean
 */
function elgg_stars_is_valid_rating($val)
{
    $settings = elgg_stars_get_rating_settings();
    return $val > $settings['min'] && $val <= $settings['max'];
}