Révision 3cb08e71
Ajouté par Assos Assos il y a plus de 10 ans
htmltest/sites/all/modules/fivestar/css/fivestar.css | ||
---|---|---|
12 | 12 |
.fivestar-combo-stars .fivestar-static-form-item { |
13 | 13 |
float: left; /* RTL */ |
14 | 14 |
margin-right: 40px; /* RTL */ |
15 |
margin-left: 40px; /* RTL */ |
|
15 | 16 |
} |
17 |
.fivestar-combo-stars .fivestar-static-item { |
|
18 |
float: left; /* RTL */ |
|
19 |
margin-right: 40px; /* RTL */ |
|
20 |
} |
|
21 |
|
|
16 | 22 |
.fivestar-combo-stars .fivestar-form-item { |
17 | 23 |
float: left; /* RTL */ |
18 | 24 |
} |
htmltest/sites/all/modules/fivestar/fivestar.info | ||
---|---|---|
7 | 7 |
files[] = test/fivestar.base.test |
8 | 8 |
files[] = test/fivestar.field.test |
9 | 9 |
|
10 |
; Information added by drupal.org packaging script on 2012-03-28
|
|
11 |
version = "7.x-2.0-alpha2"
|
|
10 |
; Information added by Drupal.org packaging script on 2014-02-01
|
|
11 |
version = "7.x-2.0-alpha3"
|
|
12 | 12 |
core = "7.x" |
13 | 13 |
project = "fivestar" |
14 |
datestamp = "1332954347"
|
|
14 |
datestamp = "1391276007"
|
|
15 | 15 |
|
htmltest/sites/all/modules/fivestar/fivestar.module | ||
---|---|---|
46 | 46 |
return $items; |
47 | 47 |
} |
48 | 48 |
|
49 |
/** |
|
50 |
* Implements hook_microdata_suggestions(). |
|
51 |
*/ |
|
52 |
function fivestar_microdata_suggestions() { |
|
53 |
$mappings = array(); |
|
54 |
|
|
55 |
// Add the review mapping for Schema.org |
|
56 |
$mappings['fields']['fivestar']['schema.org'] = array( |
|
57 |
'#itemprop' => array('aggregateRating'), |
|
58 |
'#is_item' => TRUE, |
|
59 |
'#itemtype' => array('http://schema.org/AggregateRating'), |
|
60 |
'average_rating' => array( |
|
61 |
'#itemprop' => array('ratingValue'), |
|
62 |
), |
|
63 |
); |
|
64 |
|
|
65 |
return $mappings; |
|
66 |
} |
|
67 |
|
|
49 | 68 |
/** |
50 | 69 |
* Implementation of hook_permission(). |
51 | 70 |
* |
... | ... | |
492 | 511 |
'#required' => $element['#required'], |
493 | 512 |
'#theme' => 'fivestar_select', |
494 | 513 |
'#default_value' => _fivestar_get_element_default_value($element), |
514 |
'#weight' => -2, |
|
495 | 515 |
); |
496 | 516 |
|
497 | 517 |
if (isset($element['#parents'])) { |
498 | 518 |
$element['vote']['#parents'] = $element['#parents']; |
499 | 519 |
} |
500 |
if (isset($element['#weight'])) { |
|
501 |
$element['vote']['#weight'] = $element['#weight']; |
|
502 |
} |
|
503 | 520 |
|
504 | 521 |
switch ($settings['text']) { |
505 | 522 |
case 'user': |
... | ... | |
507 | 524 |
'user_rating' => $values['user'], |
508 | 525 |
'votes' => $settings['style'] == 'dual' ? NULL : $values['count'], |
509 | 526 |
'stars' => $settings['stars'], |
527 |
'microdata' => $settings['microdata'], |
|
510 | 528 |
)); |
511 | 529 |
$class[] = 'fivestar-user-text'; |
512 | 530 |
break; |
... | ... | |
515 | 533 |
'average_rating' => $values['average'], |
516 | 534 |
'votes' => $values['count'], |
517 | 535 |
'stars' => $settings['stars'], |
536 |
'microdata' => $settings['microdata'], |
|
518 | 537 |
)); |
519 | 538 |
$class[] = 'fivestar-average-text'; |
520 | 539 |
break; |
... | ... | |
524 | 543 |
'average_rating' => $values['user'] ? NULL : $values['average'], |
525 | 544 |
'votes' => $settings['style'] == 'dual' ? NULL : $values['count'], |
526 | 545 |
'stars' => $settings['stars'], |
546 |
'microdata' => $settings['microdata'], |
|
527 | 547 |
)); |
528 | 548 |
$class[] = 'fivestar-smart-text'; |
529 | 549 |
$class[] = $values['user'] ? 'fivestar-user-text' : 'fivestar-average-text'; |
... | ... | |
534 | 554 |
'average_rating' => $settings['style'] == 'dual' ? NULL : $values['average'], |
535 | 555 |
'votes' => $settings['style'] == 'dual' ? NULL : $values['count'], |
536 | 556 |
'stars' => $settings['stars'], |
557 |
'microdata' => $settings['microdata'], |
|
537 | 558 |
)); |
538 | 559 |
$class[] = ' fivestar-combo-text'; |
539 | 560 |
break; |
htmltest/sites/all/modules/fivestar/includes/fivestar.field.inc | ||
---|---|---|
477 | 477 |
'field_name' => $instance['field_name'], |
478 | 478 |
'langcode' => $langcode, |
479 | 479 |
); |
480 |
// If microdata module is enabled, attach the microdata attributes. |
|
481 |
$settings['microdata'] = module_exists('microdata') ? $entity->microdata[$field['field_name']] : array(); |
|
482 |
|
|
480 | 483 |
$element[0] = drupal_get_form('fivestar_custom_widget', $values, $settings); |
481 | 484 |
// Our work here is done. |
482 | 485 |
return $element; |
... | ... | |
702 | 705 |
/** |
703 | 706 |
* Implements hook_microdata_value_type_alter(). |
704 | 707 |
*/ |
705 |
function fivestar_microdata_value_type_alter(&$types) { |
|
706 |
$types['fivestar'] = 'item'; |
|
708 |
function fivestar_microdata_value_types_alter(&$types) {
|
|
709 |
$types['fivestar'] = 'item_option';
|
|
707 | 710 |
} |
708 | 711 |
|
709 | 712 |
/** |
... | ... | |
752 | 755 |
$info[$entity_type]['bundles'][$instance['bundle']]['properties'][$field['field_name']] = array(); |
753 | 756 |
fivestar_property_info_callback($info, $entity_type, $field, $instance, 'fivestar'); |
754 | 757 |
$entity_info = $info[$entity_type]['bundles'][$instance['bundle']]['properties']; |
755 |
|
|
756 |
foreach ($entity_info[$field['field_name']]['property info'] as $property_name => $property) { |
|
757 |
$microdata[$property_name]['#attributes'] = array(); |
|
758 |
} |
|
758 |
} |
|
759 |
foreach ($entity_info[$field['field_name']]['property info'] as $property_name => $property) { |
|
760 |
$microdata[$property_name]['#attributes'] = array(); |
|
759 | 761 |
} |
760 | 762 |
} |
761 | 763 |
|
762 | 764 |
return $microdata; |
763 | 765 |
} |
764 |
|
|
765 |
|
|
766 |
/** |
|
767 |
* Implements hook_microdata_field_defaults. |
|
768 |
* |
|
769 |
* Sets default mappings for different vocabularies; for example, schema.org. |
|
770 |
* This enables fields to provide mappings for different use cases. |
|
771 |
*/ |
|
772 |
function fivestar_microdata_field_defaults() { |
|
773 |
$field_settings = array(); |
|
774 |
|
|
775 |
// Add the vocabulary terms that are used to describe the data. Multiple |
|
776 |
// schemes can be defined, allowing the user to choose which mapping to use. |
|
777 |
// The array key is used to choose which mapping to use in the field instance |
|
778 |
// settings form. |
|
779 |
$field_settings['default_mappings']['schema.org'] = array( |
|
780 |
'#itemprop' => array('aggregateRating'), |
|
781 |
'#itemtype' => 'http://schema.org/AggregateRating', |
|
782 |
'average_rating' => array( |
|
783 |
'#itemprop' => array('ratingValue'), |
|
784 |
), |
|
785 |
); |
|
786 |
|
|
787 |
return $field_settings; |
|
788 |
|
|
789 |
} |
htmltest/sites/all/modules/fivestar/includes/fivestar.theme.inc | ||
---|---|---|
35 | 35 |
'css' => isset($variables['css']) && $variables['css'] != 'default' ? $variables['css'] : FALSE, |
36 | 36 |
), |
37 | 37 |
); |
38 |
|
|
38 |
|
|
39 | 39 |
// Attach necessary JS settings |
40 | 40 |
$settings = array( |
41 | 41 |
'titleUser' => t('Your rating') .': ', |
... | ... | |
90 | 90 |
|
91 | 91 |
/** |
92 | 92 |
* Theme function for 'default' fivestar field formatter. |
93 |
* |
|
94 |
* This themes static stars. That is, pairs of stars where neither set |
|
95 |
* of stars is "exposed". Exposed stars are clickable and displayed in a |
|
96 |
* form. Theming of exposed stars is handled by the form array (and calls |
|
97 |
* the same theme functions called at the end of this function). |
|
93 | 98 |
*/ |
94 | 99 |
function theme_fivestar_formatter_default($variables) { |
95 | 100 |
$element = $variables['element']; |
... | ... | |
108 | 113 |
'widget' => $element['#widget'], |
109 | 114 |
); |
110 | 115 |
$star_display = theme('fivestar_static', $variables); |
111 |
return theme('fivestar_static_element', array('description' => $element['#description'], 'star_display' => $star_display)); |
|
116 |
return theme('fivestar_static_element', array('description' => $element['#description'], 'star_display' => $star_display, 'is_form' => FALSE));
|
|
112 | 117 |
} |
113 | 118 |
|
114 | 119 |
/** |
... | ... | |
124 | 129 |
$stars = (empty($element['#instance_settings']['stars'])) ? 5 : $element['#instance_settings']['stars']; |
125 | 130 |
$average = $element['#item']['average']; |
126 | 131 |
// Rating is X out of Y stars. |
127 |
$rating = round(($average/100) * $stars, 1);
|
|
132 |
$rating = round(($average/100) * $stars, 1); |
|
128 | 133 |
$output = $rating . '/' . $stars; |
129 | 134 |
|
130 | 135 |
return $output; |
... | ... | |
182 | 187 |
if($widget['name'] != 'default') { |
183 | 188 |
drupal_add_css($widget['css']); |
184 | 189 |
} |
185 |
|
|
190 |
|
|
186 | 191 |
$output = '<div class="fivestar-' . $widget['name'] . '">'; |
187 | 192 |
$output .= '<div class="fivestar-widget-static fivestar-widget-static-'. $tag .' fivestar-widget-static-'. $stars . ' clearfix">'; |
188 | 193 |
if (empty($stars)) { |
... | ... | |
281 | 286 |
*/ |
282 | 287 |
function theme_fivestar_static_element($variables) { |
283 | 288 |
$output = ''; |
284 |
$output .= '<div class="fivestar-static-form-item">'; |
|
289 |
if (isset($variables['is_form']) && !$variables['is_form']) { |
|
290 |
$output .= '<div class="fivestar-static-item">'; |
|
291 |
} |
|
292 |
else { |
|
293 |
$output .= '<div class="fivestar-static-form-item">'; |
|
294 |
} |
|
285 | 295 |
$element = array( |
286 | 296 |
'#type' => 'item', |
287 | 297 |
'#title' => $variables['title'], |
Formats disponibles : Unified diff
Weekly update of contrib modules