Projet

Général

Profil

Révision d50a36e0

Ajouté par Assos Assos il y a presque 4 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/file_entity/file_entity.file.inc
282 282
  );
283 283

  
284 284
  foreach ($files as $file) {
285
    $file->title = file_entity_replace_title($file, $replace_options, NULL, $language->language);
286
    $file->alt = file_entity_replace_alt($file, $replace_options, NULL, $language->language);
285
    if (empty($file->title)) {
286
      $file->title = file_entity_replace_title($file, $replace_options, NULL, $language->language);
287
    }
288
    if (empty($file->alt)) {
289
      $file->alt = file_entity_replace_alt($file, $replace_options, NULL, $language->language);
290
    }
287 291
  }
288 292
}
289 293

  
drupal7/sites/all/modules/file_entity/file_entity.info
32 32
; We have to add a fake version so Git checkouts do not fail Media dependencies
33 33
version = 7.x-2.x-dev
34 34

  
35
; Information added by Drupal.org packaging script on 2020-06-05
36
version = "7.x-2.29"
35
; Information added by Drupal.org packaging script on 2020-06-15
36
version = "7.x-2.30"
37 37
core = "7.x"
38 38
project = "file_entity"
39
datestamp = "1591321853"
39
datestamp = "1592259102"
drupal7/sites/all/modules/file_entity/file_entity.pages.inc
177 177
        '#items' => (count($limits) <= 15) ? $limits : array(implode(', ', $limits)),
178 178
      );
179 179

  
180
      if (!empty($valid_extensions)) {
180
      if (!empty($valid_extensions) && count($limits) == count($valid_extensions)) {
181 181
        $form['upload']['#description'] = t('Files must be less than these sizes: !list',
182 182
          array(
183 183
            '!list' => render($list),
drupal7/sites/all/modules/file_entity/tests/file_entity_test.info
5 5
dependencies[] = file_entity
6 6
hidden = TRUE
7 7

  
8
; Information added by Drupal.org packaging script on 2020-06-05
9
version = "7.x-2.29"
8
; Information added by Drupal.org packaging script on 2020-06-15
9
version = "7.x-2.30"
10 10
core = "7.x"
11 11
project = "file_entity"
12
datestamp = "1591321853"
12
datestamp = "1592259102"
drupal7/sites/all/modules/fivestar/README.txt
1
CONTENTS OF THIS FILE
2
---------------------
3

  
4
 * Introduction
5
 * Requirements
6
 * Installation
7
 * Configuration
8
 * Maintainers
9

  
10

  
11
INTRODUCTION
12
------------
1 13

  
2 14
The Fivestar voting module adds a clean, attractive voting widget to nodes and
3 15
comments in Drupal. It features:
4 16

  
5
 * jQuery rollover effects and AJAX no-reload voting
17
 * jQuery (1.0 - 1.8) rollover effects and AJAX no-reload voting
6 18
 * Customizable star sets
7
 * Graceful degradation to an HTML rating form when JavaScript is turned off
8
 * Per-nodetype configurability
9
 * Support for anonymous voters
10
 * Spam protection to keep users from filling your DB with bogus votes
11
 * Easy-to-use integration with Views module for lists sorted by rating, or filtered by min/max ratings
12
 * A Fivestar CCK field for use in custom node types
19
 * Graceful degradation to a HTML rating form when JavaScript is disabled
20
 * Configurability per node type
21
 * Anonymous voting support
22
 * Voting spam protection
23
 * Easy-to-use integration with Views for lists sorted by rating, or filtered
24
   by min/max ratings
25
 * A Fivestar field for use in custom node types
13 26
 * An easy-to-use Form API element type for use in other modules
14 27

  
15
Fivestar was designed by Nate Haug and Jeff Eaton.
28
 * For a full description of the module, visit the project page:
29
   https://www.drupal.org/project/fivestar
16 30

  
17
This Module Made by Robots: http://www.lullabot.com
31
 * To submit bug reports and feature suggestions, or track changes:
32
   https://www.drupal.org/project/issues/fivestar
18 33

  
34
 * For more information on module usage, visit the documentation guide:
35
   https://www.drupal.org/docs/7/modules/fivestar
19 36

  
20
Dependencies
37

  
38
REQUIREMENTS
21 39
------------
22
 * votingapi
23 40

  
24
Fivestar also provides additional features for both the CCK and Views modules.
41
This module requires the following modules:
25 42

  
26
Install
27
-------
28
Installing the Fivestar voting module is simple:
43
 * Voting API (https://www.drupal.org/project/votingapi)
29 44

  
30
1) Copy the fivestar folder to the modules folder in your installation.
31 45

  
32
2) Enable the module using Administer -> Modules (/admin/build/modules)
46
INSTALLATION
47
------------
33 48

  
34
Note: Aggressive caching will complain that fivestar doesn't work, but it
35
actually causes no problems. To improve performance, the module implements
36
hook_init() -- and the caching advisor screen uses that as the only metric to
37
determine whether a module will work with the caching system. Activate it
38
without fear, friends -- Fivestar will continue to hum happily along.
49
 * Install as you would normally install a contributed Drupal module. Visit
50
   https://www.drupal.org/node/1897420 for further information.
39 51

  
40
Upgrading from Drupal 5
41
-----------------------
42
The Drupal 6 version of VotingAPI has been significantly improved for both
43
efficiency and flexibility. Because Fivestar depends on VotingAPI for much of
44
its functionality, these changes have affected Fivestar.
45 52

  
46
The Fivestar Anonymous vote interval set in admin/settings/fivestar is no
47
longer available. We use the same setting as defined in VotingAPI now, set at
48
admin/settings/votingapi. It has the same effect as the previous Fivestar
49
setting.
53
CONFIGURATION
54
-------------
50 55

  
51
Configuration for Simple Rating
52
-------------------------------
56
Fivestar has two configuration modes:
53 57

  
54
Fivestar has two completely separate modes of operation. The first is letting an
55
end-user rate a piece of content. The settings for this are on the content type
56
settings page. These settings let you expose a rating widget when viewing the
57
node, not editing it. Clicking on the widget registers a vote for that node, and
58
never anything else.
58
 * End-user rating a piece of content: These settings are located on the content
59
   type settings page. These settings let you expose a rating widget when
60
   viewing the node, not editing it. Clicking on the widget registers a vote for
61
   that node, and never anything else.
59 62

  
60 63
The configuration for Fivestar is spread between the content type settings page,
61 64
Fivestar site settings page, and access permissions. To configure:
62 65

  
63
1) Configure the site-wide setting for Fivestar, Administer -> Settings ->
64
   Fivestar.
66
1) Configure the site-wide setting for Fivestar, Administer -> Configuration ->
67
   Fivestar (or go directly to /admin/config/content/fivestar)
65 68

  
66 69
2) Activate voting on each content type. For example, if you want Fivestar to
67
   appear on story nodes, use Administer -> Content Management ->
68
   Content Types -> Story, and check the "Enable Fivestar rating" box under
70
   appear on "Article" nodes, use Administer -> Structure -> Content Types ->
71
   Article, and check the "Enable Fivestar rating" box under
69 72
   the "Fivestar ratings" heading. Repeat for each content type desired.
70 73

  
71 74
3) Enable anonymous voting.
72 75
   If you want to allow anonymous voting, you'll need to set permissions for
73
   that. Use Administer -> User Management -> Access Control, and check the
74
   "rate content" and "view ratings" checkboxes for the roles you'd like.
75
   You'll find these permission items under the "fivestar module" heading.
76
   that. Use Administer -> People -> Permissions, and check the
77
   "Use Fivestar to rate content" checkboxe for the role(s) you'd like.
78
   You'll find this permission under the "Fivestar" module heading.
79

  
76 80

  
77 81
Configuration for Reviews of Content
78 82
------------------------------------
......
83 87
Visitors will not be rating the comments themselves. Fivestar does not allow for
84 88
the rating of comments.
85 89

  
86
1) If it's not already enabled, turn on comment module at Administer ->
87
   Site Building -> Modules.
90
1) If it's not already enabled, turn on the comment module at
91
   Administer -> Modules.
88 92

  
89 93
2) Visit the content type you want to enable reviews, such as Administer ->
90
   Content Management -> Content Types -> Story, and select an option under
94
   Structure -> Content Types -> Article, and select an option under
91 95
   the "Comment widget" section.
92 96

  
97

  
93 98
Configuration as a CCK field / Advanced Rating
94 99
----------------------------------------------
95 100

  
......
109 114

  
110 115
To configure a CCK field for rating a node while creating a new 'review' node:
111 116

  
112
1) Create a new node type called 'review' at Administer -> Content Management ->
117
1) Create a new node type called 'review' at Administer -> Structure ->
113 118
Content Types. Configure the type. Do NOT set any fivestar settings on the
114 119
content type form! We don't want users to actually be able to rate the reviews
115 120
themselves!
......
121 126
3) Configure the rating widget to your liking. Most field have help text which
122 127
explain their purpose. The Node ID field is the most important field on the page
123 128
which determines exactly what node will receive the value of the rating. In a
124
realy simple case, you could just enter the value 10 to always rate on the same
129
really simple case, you could just enter the value 10 to always rate on the same
125 130
node with nid = 10.
126 131

  
127 132
A common scenario is using fivestar with nodecomments to make reviews. If using
......
131 136
Save your field. Now when making new nodes of type 'review', the user will
132 137
select a star that will register a vote on the value of the Node ID field.
133 138

  
139

  
134 140
Views Integration
135 141
-----------------
136 142
Fivestar depends on the views integration provided by VotinAPI, but adds some
......
143 149
Fivestar also provides handling for the display of Fivestar CCK fields, they are
144 150
in the Field list under "Fivestar Rating: [Field name]".
145 151

  
152

  
146 153
Creating a Fivestar Set
147 154
-----------------------
148 155

  
149
1. Open your favorite image editor and create an image that is 3 times as high as it is wide.
150
   The default size for Fivestar (and the easiest to work with) is 16x48 pixels.
156
1. Open your favorite image editor and create an image that is 3 times as high
157
   as it is wide. The default size for Fivestar (and the easiest to work with)
158
   is 16x48 pixels.
151 159

  
152 160
2. Setup guides at 16 pixels and 32 pixels. This splits your canvas into thirds.
153 161

  
154
3. Create a star icon in the top third. When satisfied, copy it into the middle and bottom
155
   thirds of the image. Change the middle and bottom copies to your liking. Fivestar will
156
   use the top, middle, and bottom images for each state of the star.
157
   
162
3. Create a star icon in the top third. When satisfied, copy it into the middle
163
   and bottom thirds of the image. Change the middle and bottom copies to your
164
   liking. Fivestar will use the top, middle, and bottom images for each state
165
   of the star.
166

  
158 167
   Top      -> Off
159 168
   Middle   -> On
160 169
   Bottom   -> Hover
161 170

  
162
4. Save your image as "star.png" in a new directory. The name of your directory will be the label
163
   for your set of stars, spaces are not allowed.
171
4. Save your image as "star.png" in a new directory. The name of your directory
172
   will be the label for your set of stars, spaces are not allowed.
164 173

  
165
5. Do the same thing for a cancel image, only there are only 2 states for a cancel image, so your
166
   image will be 16 pixels by 32pixels. Setup a guide at 16 pixels so your canvas is split in half.
174
5. Do the same thing for a cancel image, only there are only 2 states for a
175
   cancel image, so your image will be 16 pixels by 32pixels. Setup a guide at
176
   16 pixels so your canvas is split in half.
167 177

  
168
6. Create a cancel icon in the top half. Then duplicate it into the bottom half. The cancel states
169
   are simply Off and Hover.
178
6. Create a cancel icon in the top half. Then duplicate it into the bottom half.
179
   The cancel states are simply Off and Hover.
170 180

  
171 181
   Top      -> Off
172 182
   Bottom   -> Hover
173 183

  
174 184
7. Save your cancel image as "cancel.png" in the directory create in step 4.
175 185

  
176
8. Create the CSS stylesheet. The easiest way to make this stylesheet is to copy an existing CSS
177
   file from another set of stars. The "Basic" set provides an excellent example for a 16x16 star,
178
   because it only changes the background image as necessary. If you're making a larger or smaller
179
   size for your stars than 16x16 pixels, the "Minimal" and "Outline" sets make for a good example.
186
8. Create the CSS stylesheet. The easiest way to make this stylesheet is to copy
187
   an existing CSS file from another set of stars. The "Basic" set provides an
188
   excellent example for a 16x16 star, because it only changes the background
189
   image as necessary. If you're making a larger or smaller size for your stars
190
   than 16x16 pixels, the "Minimal" and "Outline" sets make for a good example.
191

  
180 192

  
181 193
Contributing
182 194
------------
183 195
Have a sweet set of stars you'd like to contribute to the Fivestar module?
184
Post them to the Fivestar issue queue: http://drupal.org/project/issues/fivestar
196
Post them to the issue queue: https://drupal.org/project/issues/fivestar
197

  
185 198

  
186 199
Support
187 200
-------
188 201
If you experience a problem with fivestar or have a problem, file a
189 202
request or issue on the fivestar queue at
190
http://drupal.org/project/issues/fivestar. DO NOT POST IN THE FORUMS. Posting in
191
the issue queues is a direct line of communication with the module authors.
203
https://drupal.org/project/issues/fivestar. DO NOT POST IN THE FORUMS. Posting
204
in the issue queues is a direct line of communication with the module authors.
205

  
206

  
207
MAINTAINERS
208
-----------
209

  
210
Fivestar was designed by Nate Haug and Jeff Eaton.
211

  
212
This Module Made by Robots: http://www.lullabot.com
drupal7/sites/all/modules/fivestar/css/fivestar-admin.css
29 29
  float: left; /* RTL */
30 30
  width: 12em;
31 31
}
32
.color-form .form-text, .color-form .form-select {
32
.color-form .form-text,
33
.color-form .form-select {
33 34
  float: left; /* RTL */
34 35
}
35 36
.color-form .form-text {
drupal7/sites/all/modules/fivestar/css/fivestar-rtl.css
47 47
div.fivestar-widget div.on a {
48 48
  background-position: right -16px;
49 49
}
50
div.fivestar-widget div.hover a, div.rating div a:hover {
50
div.fivestar-widget div.hover a,
51
div.rating div a:hover {
51 52
  background-position: right -32px;
52 53
}
drupal7/sites/all/modules/fivestar/css/fivestar.css
66 66
  display: block;
67 67
}
68 68

  
69
div.fivestar-widget .cancel, div.fivestar-widget .star {
69
div.fivestar-widget .cancel,
70
div.fivestar-widget .star {
70 71
  float: left; /* RTL */
71 72
  width: 17px;
72 73
  height: 15px;
73 74
  overflow: hidden;
74 75
  text-indent: -999em;
75 76
}
76
div.fivestar-widget .cancel, div.fivestar-widget .cancel a {
77
div.fivestar-widget .cancel,
78
div.fivestar-widget .cancel a {
77 79
  background: url(../widgets/default/delete.gif) no-repeat 0 -16px; /* RTL */
78 80
  text-decoration: none;
79 81
}
80 82

  
81
div.fivestar-widget .star, div.fivestar-widget .star a {
83
div.fivestar-widget .star,
84
div.fivestar-widget .star a {
82 85
  background: url(../widgets/default/star.gif) no-repeat 0 0; /* RTL */
83 86
  text-decoration: none;
84 87
}
85 88

  
86
div.fivestar-widget .cancel a, div.fivestar-widget .star a {
89
div.fivestar-widget .cancel a,
90
div.fivestar-widget .star a {
87 91
  display: block;
88 92
  width: 100%;
89 93
  height: 100%;
......
94 98
div.fivestar-widget div.on a {
95 99
  background-position: 0 -16px; /* RTL */
96 100
}
97
div.fivestar-widget div.hover a, div.rating div a:hover {
101
div.fivestar-widget div.hover a,
102
div.rating div a:hover {
98 103
  background-position: 0 -32px; /* RTL */
99 104
}
100 105
form.fivestar-widget div.description {
drupal7/sites/all/modules/fivestar/fivestar.api.php
5 5
 * Provides API documentation for the fivestar module.
6 6
 */
7 7

  
8

  
9 8
/**
10
 * Implementation of hook_fivestar_widgets().
9
 * Implements hook_fivestar_widgets().
11 10
 *
12 11
 * This hook allows other modules to create additional custom widgets for
13 12
 * the fivestar module.
......
30 29
}
31 30

  
32 31
/**
33
 * Implementation of hook_fivestar_access().
32
 * Implements hook_fivestar_access().
34 33
 *
35 34
 * This hook is called before every vote is cast through Fivestar. It allows
36
 * modules to allow or deny voting on any type of entity, such as nodes, users, or
37
 * comments.
35
 * modules to allow or deny voting on any type of entity, such as nodes, users,
36
 * or comments.
38 37
 *
39 38
 * @param $entity_type
40 39
 *   Type entity.
......
45 44
 * @param $uid
46 45
 *   The user ID trying to cast the vote.
47 46
 *
48
 * @return boolean or NULL
47
 * @return bool|null
49 48
 *   Returns TRUE if voting is supported on this object.
50 49
 *   Returns NULL if voting is not supported on this object by this module.
51 50
 *   If needing to absolutely deny all voting on this object, regardless
......
63 62
}
64 63

  
65 64
/**
66
 * Implementation of hook_fivestar_target_info().
65
 * Implements hook_fivestar_target_info().
67 66
 *
68 67
 * @param $field
69 68
 *   The field structure for the operation.
......
71 70
 *   The instance structures for the $field.
72 71
 *
73 72
 * @return array
74
 *   An array of key => value pairs. Each key must be unique the identifier for this
75
 *   target selection. The Value is an array of key => value pairs for a title and a
76
 *   callback function. The title value is used for displaying in the #options array
77
 *   of the target selection option. The callback function is used when trying to decided
78
 *   which target the current vote should be cast against.
73
 *   An array of key => value pairs. Each key must be unique the identifier for
74
 *   this target selection. The Value is an array of key => value pairs for a
75
 *   title and a callback function. The title value is used for displaying in
76
 *   the #options array of the target selection option. The callback function
77
 *   is used when trying to decided which target the current vote should be
78
 *   cast against.
79 79
 *
80 80
 * @see fivestar_get_targets()
81 81
 * @see fivestar_fivestar_target_info()
......
90 90
    // node's author instead of the actual node.
91 91
    'example_node_author' => array(
92 92
      'title' => t('Node Author'),
93
      'callback' => '_example_target_node_author'
93
      'callback' => '_example_target_node_author',
94 94
    ),
95 95
  );
96 96

  
......
112 112
 *   The language associated with $items.
113 113
 *
114 114
 * @return array
115
 *   An array of key => value pairs. The return array must contain an entity_id key
116
 *   and a entity_type key. The value os the entity_id and entity_type is what the
117
 *   fivestar vote is going to be cast against when a user has selected this option
118
 *   as the target selection.
115
 *   An array of key => value pairs. The return array must contain an entity_id
116
 *   key and a entity_type key. The value os the entity_id and entity_type is
117
 *   what the fivestar vote is going to be cast against when a user has selected
118
 *   this option as the target selection.
119 119
 *
120 120
 * @see _fivestar_target_comment_parent_node()
121 121
 * @see _fivestar_target_node_reference()
drupal7/sites/all/modules/fivestar/fivestar.info
5 5
dependencies[] = votingapi
6 6
configure = admin/config/content/fivestar
7 7
files[] = fivestar.migrate.inc
8
files[] = includes/fivestar_views_handler_filter_in_operator.inc
8 9
files[] = test/fivestar.base.test
9 10
files[] = test/fivestar.field.test
10 11

  
11
; Information added by Drupal.org packaging script on 2016-04-23
12
version = "7.x-2.2"
12
; Information added by Drupal.org packaging script on 2020-06-13
13
version = "7.x-2.3"
13 14
core = "7.x"
14 15
project = "fivestar"
15
datestamp = "1461406444"
16

  
16
datestamp = "1592024933"
drupal7/sites/all/modules/fivestar/fivestar.install
2 2

  
3 3
/**
4 4
 * @file
5
 * Installation file for fivestar module.
5
 * Install, update, and uninstall functions the Fivestar module.
6 6
 */
7 7

  
8
/**
9
 * Implements hook_uninstall().
10
 */
8 11
function fivestar_uninstall() {
9 12
  db_query("DELETE FROM {variable} WHERE name LIKE 'fivestar_%'");
10 13
}
11 14

  
12 15
/**
13
 * hook_field_schema().
16
 * Hook_field_schema().
14 17
 */
15 18
function fivestar_field_schema() {
16 19
  return array(
......
19 22
        'type' => 'int',
20 23
        'unsigned' => TRUE,
21 24
        'not null' => FALSE,
22
        'sortable' => TRUE
25
        'sortable' => TRUE,
23 26
      ),
24 27
      'target' => array(
25 28
        'type' => 'int',
26 29
        'unsigned' => TRUE,
27
        'not null' => FALSE
30
        'not null' => FALSE,
28 31
      ),
29 32
    ),
30 33
  );
31 34
}
32 35

  
33 36
/**
34
 * Fixes the axis value stored for fivestar fields
37
 * Fixes the axis value stored for fivestar fields.
35 38
 */
36 39
function fivestar_update_7201() {
37 40
  drupal_load('module', 'fivestar');
......
46 49
}
47 50

  
48 51
/**
49
 * Moves the field settings to field instance settings
52
 * Moves the field settings to field instance settings.
50 53
 */
51 54
function fivestar_update_7202() {
52 55
  $fields = field_read_fields(array('module' => 'fivestar'));
......
60 63
  }
61 64
}
62 65

  
63

  
64 66
/**
65
 * Convert all existing fivestar/node_type settings into fields with exposed fivestar formatters
67
 * Converts all existing fivestar/node_type settings into fields with exposed fivestar formatters.
66 68
 */
67 69
function fivestar_update_7203() {
68
  // Gather the node types
70
  // Gather the node types.
69 71
  $query = db_select('node_type', 'n');
70 72
  $query->addField('n', 'type');
71 73
  $result = $query->execute();
......
108 110
      );
109 111

  
110 112
      if (variable_get('fivestar_' . $var_suffix, FALSE)) {
111
        // Check to see if a field for this tag exists and create one if needed
113
        // Check to see if a field for this tag exists and create one if needed.
112 114
        $field_name = 'field_' . $tag;
113 115
        $field = field_read_field($field_name . $suffix, array('include_deleted' => TRUE));
114 116

  
......
129 131
          $field = field_create_field($field_values);
130 132
        }
131 133

  
132
        // Create an instance of the field in this bundle
134
        // Create an instance of the field in this bundle.
133 135
        $instance = field_read_instance('node', $field['field_name'], $type, array('include_deleted' => TRUE));
134 136
        if (empty($instance)) {
135 137
          $instance_info = array(
......
168 170
    }
169 171
  }
170 172

  
171
  // Rebuild the menu to remove the node type tag form paths
173
  // Rebuild the menu to remove the node type tag form paths.
172 174
  menu_rebuild();
173 175
  _field_info_collate_fields(TRUE);
174 176
}
175 177

  
176 178
/**
177
 * Preserve settings from fivestar_formatter_exposed_stars and convert to
178
 * fivestar_formatter_default.
179
 * Preserve settings from fivestar_formatter_exposed_stars and convert to fivestar_formatter_default.
179 180
 */
180 181
function fivestar_update_7204() {
181 182
  $fields = field_read_fields(array('type' => 'fivestar'));
......
203 204
          }
204 205
        }
205 206
      }
206
      // Update the instance
207
      // Update the instance.
207 208
      field_update_instance($instance);
208 209
    }
209 210
  }
210 211
}
211 212

  
212 213
/**
213
 * Rename fivestar 'select' widget to 'fivestar_select'
214
 * Rename fivestar 'select' widget to 'fivestar_select'.
215
 *
214 216
 * @see http://drupal.org/node/1285456
215 217
 */
216 218
function fivestar_update_7205() {
......
222 224
      // If the widget type is select, lets change it.
223 225
      if ($instance['widget']['type'] == 'select') {
224 226
        $instance['widget']['type'] = 'fivestar_select';
225
        // Update the instance
227
        // Update the instance.
226 228
        field_update_instance($instance);
227 229
      }
228 230
    }
......
230 232
}
231 233

  
232 234
/**
233
 * Preserve setting after new feature preventing re-votes
235
 * Preserve setting after new feature preventing re-votes.
236
 *
234 237
 * @see http://drupal.org/node/356605
235 238
 */
236 239
function fivestar_update_7206() {
......
241 244
    foreach ($instances as $instance) {
242 245
      // The default should be to allow re-voting.
243 246
      $instance['settings']['allow_revote'] = TRUE;
244
        // Update the instance
245
        field_update_instance($instance);
247
      // Update the instance.
248
      field_update_instance($instance);
246 249
    }
247 250
  }
248 251
}
249 252

  
250 253
/**
251
 * Preserve setting after new feature preventing own votes
254
 * Preserve setting after new feature preventing own votes.
255
 *
252 256
 * @see http://drupal.org/node/189527
253 257
 */
254 258
function fivestar_update_7207() {
......
259 263
    foreach ($instances as $instance) {
260 264
      // The default should be to allow own votes.
261 265
      $instance['settings']['allow_ownvote'] = TRUE;
262
        // Update the instance
263
        field_update_instance($instance);
266
      // Update the instance.
267
      field_update_instance($instance);
264 268
    }
265 269
  }
266 270
}
267 271

  
268 272
/**
269 273
 * Change field formatters to ensure unique.
274
 *
270 275
 * @see http://drupal.org/node/1063754
271 276
 */
272 277
function fivestar_update_7208() {
drupal7/sites/all/modules/fivestar/fivestar.migrate.inc
1 1
<?php
2

  
2 3
/**
3 4
 * @file
4 5
 * Base integration with the Migrate API class.
......
20 21
 */
21 22
class MigrateFivestarFieldHandler extends MigrateFieldHandler {
22 23

  
24
  /**
25
   *
26
   */
23 27
  public function __construct() {
24 28
    $this->registerTypes(array('fivestar'));
25 29
  }
26 30

  
31
  /**
32
   *
33
   */
27 34
  public function fields($type, $parent_field, $migration = NULL) {
28 35
    $fields = array(
29 36
      'target' => t('Ratings: The target of the rating.'),
......
31 38
    return $fields;
32 39
  }
33 40

  
41
  /**
42
   *
43
   */
34 44
  public function prepare($entity, array $field_info, array $instance, array $values) {
35 45
    $arguments = array();
36 46
    if (isset($values['arguments'])) {
......
46 56

  
47 57
    return isset($return) ? $return : NULL;
48 58
  }
59

  
49 60
}
drupal7/sites/all/modules/fivestar/fivestar.module
8 8
include_once dirname(__FILE__) . '/includes/fivestar.field.inc';
9 9

  
10 10
/**
11
 * Implementation of hook_help().
11
 * Implements hook_help().
12 12
 */
13 13
function fivestar_help($path, $arg) {
14
  $output = '';
15 14
  switch ($path) {
15

  
16 16
    case 'admin/config/content/fivestar':
17 17
      $output = t('This page is used to configure site-wide features of the Fivestar module.');
18
    break;
18
      return $output;
19

  
20
    case 'admin/help#fivestar':
21
      $output = '';
22
      $output .= '<h3>' . t('About') . '</h3>';
23
      $output .= '<p>' . t('The <a href="@fivestar">Fivestar</a> voting module is a very simple rating module that provides the possibility to rate items with stars or similar items. This gives you the possibilities to rate various items or even to create online forms for evaluations and assessments with different questions to be answered.
24
For more information, see the online documentation for the <a href="@doco">Fivestar module</a>.',
25
      array(
26
        '@fivestar' => 'http://drupal.org/project/fivestar',
27
        '@doco' => 'https://drupal.org/handbook/modules/fivestar',
28
      )) . '</p>';
29
      $output .= '<h3>' . t('Uses') . '</h3>';
30
      $output .= '<dl>';
31
      $output .= '<dt>' . t('General') . '</dt>';
32
      $output .= '<dd>' . t('The Fivestar module can be used to easily rate various types of content on your website. These ratings can be used on the content itself or even from the comments of that piece of content.') . '</dd>';
33
      $output .= '<dt>' . t('Basic Concepts and Features') . '</dt>';
34
      $output .= '<dd>' . t('Fivestar is an excellent voting widget first made available for use on Drupal 5 websites. The D5 module included the ability to create a voting widget for nodes. With Drupal 6 came the ability to add comments. And with Drupal 7, the web developer was given the ability to create the voting widget with any entity.') . '</dd>';
35
      $output .= '<dt>' . t('Advanced Use Cases') . '</dt>';
36
      $output .= '<dd>' . t('There are many excellent resources online describing the many Fivestar features, such as the excellent article <a href="@features">"In-Depth features of Drupal Fivestar" </a>.',
37
        array(
38
          '@features' => 'https://www.greengeeks.com/kb/3233/drupal-fivestar/',
39
        )) . '</dd>';
40
      $output .= '</dl>';
41
      return $output;
19 42
  }
20
  return $output;
21 43
}
22 44

  
23 45
/**
24
 * Implementation of hook_menu().
46
 * Implements hook_menu().
25 47
 */
26 48
function fivestar_menu() {
27 49
  $items = array();
......
45 67
function fivestar_microdata_suggestions() {
46 68
  $mappings = array();
47 69

  
48
  // Add the review mapping for Schema.org
70
  // Add the review mapping for Schema.org.
49 71
  $mappings['fields']['fivestar']['schema.org'] = array(
50 72
    '#itemprop' => array('aggregateRating'),
51 73
    '#is_item' => TRUE,
......
62 84
}
63 85

  
64 86
/**
65
 * Implementation of hook_permission().
87
 * Implements hook_permission().
66 88
 *
67 89
 * Exposes permissions for rating content.
68 90
 */
......
75 97
}
76 98

  
77 99
/**
78
 * Implementation of hook_theme().
100
 * Implements hook_theme().
79 101
 */
80 102
function fivestar_theme() {
81 103
  return array(
......
136 158
  );
137 159
}
138 160

  
161
/**
162
 * Implements hook_views_api().
163
 */
164
function fivestar_views_api() {
165
  return array(
166
    'api' => 3,
167
    'path' => drupal_get_path('module', 'fivestar') . '/includes',
168
  );
169
}
170

  
171
/**
172
 *
173
 */
139 174
function _fivestar_variables() {
140 175
  return array('fivestar', 'fivestar_unvote', 'fivestar_style', 'fivestar_stars', 'fivestar_comment', 'fivestar_position', 'fivestar_position_teaser', 'fivestar_labels_enable', 'fivestar_labels', 'fivestar_text', 'fivestar_title', 'fivestar_feedback');
141 176
}
......
144 179
 * Internal function to handle vote casting, flood control, XSS, IP based
145 180
 * voting, etc...
146 181
 */
147

  
148 182
function _fivestar_cast_vote($entity_type, $id, $value, $tag = NULL, $uid = NULL, $skip_validation = FALSE, $vote_source = NULL) {
149 183
  global $user;
150 184
  $tag = empty($tag) ? 'vote' : $tag;
......
162 196
    // Get the user's current vote.
163 197
    $criteria = array('entity_type' => $entity_type, 'entity_id' => $id, 'tag' => $tag, 'uid' => $uid);
164 198
    // Get the unique identifier for the user (IP Address if anonymous).
165

  
166 199
    if ($vote_source != NULL) {
167 200
      $user_criteria = array('vote_source' => $vote_source);
168 201
      $limit = 1;
......
181 214
      votingapi_set_votes($votes);
182 215
    }
183 216

  
184
    // Moving the calculationg after saving/deleting the vote but before getting the votes.
217
    // Moving the calculation after saving/deleting the vote but before
218
    // getting the votes.
185 219
    votingapi_recalculate_results($entity_type, $id);
186 220
    return fivestar_get_votes($entity_type, $id, $tag, $uid);
187 221
  }
......
202 236
 *   The VotingAPI tag for which to retrieve votes.
203 237
 * @param $uid
204 238
 *   Optional. A user ID for which to retrieve votes.
239
 *
205 240
 * @return
206 241
 *   An array of the following keys:
207 242
 *   - average: An array of VotingAPI results, including the average 'value'.
......
225 260
  $votes = array();
226 261

  
227 262
  // Initialize defaults.
228
  foreach($ids as $id) {
263
  foreach ($ids as $id) {
229 264
    $votes[$entity_type][$id] = array(
230 265
      'average' => array(),
231 266
      'count' => array(),
......
235 270

  
236 271
  $results = votingapi_select_results($criteria);
237 272
  $user_votes = array();
238
  if(!empty($results)) {
239
    foreach(votingapi_select_votes($criteria += array('uid' => $uid)) as $uv) {
273
  if (!empty($results)) {
274
    foreach (votingapi_select_votes($criteria += array('uid' => $uid)) as $uv) {
240 275
      $user_votes[$uv['entity_type']][$uv['entity_id']] = $uv;
241 276
    }
242 277
  }
......
248 283
    if ($result['function'] == 'count') {
249 284
      $votes[$result['entity_type']][$result['entity_id']]['count'] = $result;
250 285
    }
251
	  if ($uid) {
252
	    if (!empty($user_votes[$result['entity_type']][$result['entity_id']])) {
286
    if ($uid) {
287
      if (!empty($user_votes[$result['entity_type']][$result['entity_id']])) {
253 288
        $votes[$result['entity_type']][$result['entity_id']]['user'] = $user_votes[$result['entity_type']][$result['entity_id']];
254 289
        $votes[$result['entity_type']][$result['entity_id']]['user']['function'] = 'user';
255
	    }
256
	  }
257
	  else {
258
	    // If the user is anonymous, we never bother loading their existing votes.
259
	    // Not only would it be hit-or-miss, it would break page caching. Safer to always
260
	    // show the 'fresh' version to anon users.
290
      }
291
    }
292
    else {
293
      // If the user is anonymous, we never bother loading their existing votes.
294
      // Not only would it be hit-or-miss, it would break page caching. Safer to
295
      // always show the 'fresh' version to anon users.
261 296
      $votes[$result['entity_type']][$result['entity_id']]['user'] = array('value' => 0);
262
	  }
297
    }
263 298
  }
264 299

  
265 300
  return $votes;
266 301
}
267 302

  
303
/**
304
 *
305
 */
268 306
function fivestar_get_votes($entity_type, $id, $tag = 'vote', $uid = NULL) {
269 307
  $multiple = fivestar_get_votes_multiple($entity_type, array($id), $tag, $uid);
270 308
  return $multiple[$entity_type][$id];
......
282 320
 * @param $uid
283 321
 *   The user trying to cast the vote.
284 322
 *
285
 * @return boolean
323
 * @return bool
286 324
 */
287 325
function fivestar_validate_target($entity_type, $id, $tag, $uid = NULL) {
288 326
  if (!isset($uid)) {
......
301 339
}
302 340

  
303 341
/**
304
 * Implementation of hook_fivestar_access().
342
 * Implements hook_fivestar_access().
305 343
 *
306 344
 * This hook is called before every vote is cast through Fivestar. It allows
307 345
 * modules to allow voting on any type of entity, such as nodes, users, or
......
316 354
 * @param $uid
317 355
 *   The user ID trying to cast the vote.
318 356
 *
319
 * @return boolean or NULL
357
 * @return bool|NULL
320 358
 *   Returns TRUE if voting is supported on this object.
321 359
 *   Returns NULL if voting is not supported on this object by this module.
322 360
 *   If needing to absolutely deny all voting on this object, regardless
......
341 379
}
342 380

  
343 381
/**
344
 * Implementation of hook_form_comment_form_alter().
382
 * Implements hook_form_comment_form_alter().
345 383
 *
346 384
 * This hook removes the parent node, together with the fivestar field, from
347 385
 * the comment preview page. If this is left in, when the user presses the
......
352 390
function fivestar_form_comment_form_alter(&$form, &$form_state, $form_id) {
353 391
  $fivestar_field_keys = array();
354 392
  if (isset($form['comment_output_below'])) {
355
    foreach($form['comment_output_below'] as $key => $value) {
393
    foreach ($form['comment_output_below'] as $key => $value) {
356 394
      if (is_array($value) && !empty($value['#field_type']) && $value['#field_type'] == 'fivestar') {
357 395
        $fivestar_field_keys[] = $key;
358 396
      }
......
366 404
}
367 405

  
368 406
/**
369
 * Implementation of hook_fivestar_widgets().
407
 * Implements hook_fivestar_widgets().
370 408
 *
371 409
 * This hook allows other modules to create additional custom widgets for
372 410
 * the fivestar module.
......
432 470
function fivestar_custom_widget($form, &$form_state, $values, $settings) {
433 471
  $form = array(
434 472
    '#attributes' => array(
435
      'class' => array('fivestar-widget')
473
      'class' => array('fivestar-widget'),
436 474
    ),
437 475
  );
438 476
  $form['#submit'][] = 'fivestar_form_submit';
......
500 538
}
501 539

  
502 540
/**
503
 * AJAX submit handler for fivestar_custom_widget
541
 * AJAX submit handler for fivestar_custom_widget.
504 542
 */
505 543
function fivestar_ajax_submit($form, $form_state) {
506 544
  if (!empty($form_state['settings']['content_id'])) {
507 545
    $entity = entity_load($form_state['settings']['entity_type'], array($form_state['settings']['entity_id']));
508 546
    $entity = reset($entity);
509 547
    _fivestar_update_field_value($form_state['settings']['content_type'], $entity, $form_state['settings']['field_name'], $form_state['settings']['langcode'], $form_state['values']['vote']);
510
    $votes = _fivestar_cast_vote($form_state['settings']['content_type'], $form_state['settings']['content_id'], $form_state['values']['vote'], $form_state['settings']['tag']);
548
    $votes = _fivestar_cast_vote($form_state['settings']['entity_type'], $form_state['settings']['content_id'], $form_state['values']['vote'], $form_state['settings']['tag']);
511 549
  }
512 550

  
513 551
  $values = array();
......
517 555

  
518 556
  // We need to process the 'fivestar' element with the new values.
519 557
  $form['vote']['#values'] = $values;
520
  // Also need to pass on form_state and the complete form, just like form_builder() does.
558
  // Also need to pass on form_state and the complete form,
559
  // just like form_builder() does.
521 560
  $new_element = fivestar_expand($form['vote'], $form_state, $form_state['complete form']);
522 561
  // Update the description. Since it doesn't account of our cast vote above.
523
  // TODO: Look into all this, I honestly don't like it and it's a bit weird.
562
  // @todo Look into all this, I honestly don't like it and it's a bit weird.
524 563
  $form['vote']['vote']['#description'] = isset($new_element['vote']['#description']) ? $new_element['vote']['#description'] : '';
525

  
564
  if (!$form['vote']['#allow_revote'] && !$form['vote']['#allow_clear']) {
565
    $form['vote'] = $new_element;
566
  }
526 567
  return array(
527 568
    '#type' => 'ajax',
528 569
    '#commands' => array(
......
535 576
}
536 577

  
537 578
/**
538
 * Implementation of hook_elements().
579
 * Implements hook_elements().
539 580
 *
540
 * Defines 'fivestar' form element type
581
 * Defines 'fivestar' form element type.
541 582
 */
542 583
function fivestar_element_info() {
543 584
  $type['fivestar'] = array(
......
570 611
 * Process callback for fivestar_element -- see fivestar_element()
571 612
 */
572 613
function fivestar_expand($element, $form_state, $complete_form) {
573
  if (!_fivestar_allow_vote($element)){
614
  if (!_fivestar_allow_vote($element)) {
574 615
    $element['#input'] = FALSE;
575 616
  }
576 617

  
577
  // Add CSS and JS
618
  // Add CSS and JS.
578 619
  $path = drupal_get_path('module', 'fivestar');
579 620
  $element['#attached']['js'][] = $path . '/js/fivestar.js';
580 621
  $element['#attached']['css'][] = $path . '/css/fivestar.css';
......
582 623
  $values = $element['#values'];
583 624
  $class[] = 'clearfix';
584 625

  
585
  $title = 'it';
626
  $title = t('it');
586 627
  if (isset($element['#settings']['entity_id']) && isset($element['#settings']['entity_type'])) {
587 628
    $entity_id = $element['#settings']['entity_id'];
588 629
    $entity = entity_load($element['#settings']['entity_type'], array($entity_id));
589 630
    $entity = $entity[$entity_id];
590
    $title = $entity->title;
591
  } elseif (isset($complete_form['#node'])) {
631
    if (isset($entity->title)) {
632
      $title = $entity->title;
633
    }
634
  }
635
  elseif (isset($complete_form['#node'])) {
592 636
    $title = $complete_form['#node']->title;
593 637
  }
594 638
  $options = array('-' => t('Select rating'));
595 639
  for ($i = 1; $i <= $element['#stars']; $i++) {
596
    $this_value = ceil($i * 100/$element['#stars']);
640
    $this_value = ceil($i * 100 / $element['#stars']);
597 641
    $options[$this_value] = t('Give @title @star/@count', array('@title' => $title, '@star' => $i, '@count' => $element['#stars']));
598 642
  }
599 643
  // Display clear button only if enabled.
......
625 669
      ));
626 670
      $class[] = 'fivestar-user-text';
627 671
      break;
672

  
628 673
    case 'average':
629 674
      $element['vote']['#description'] = $settings['style'] == 'dual' ? NULL : theme('fivestar_summary', array(
630 675
        'average_rating' => $values['average'],
......
634 679
      ));
635 680
      $class[] = 'fivestar-average-text';
636 681
      break;
682

  
637 683
    case 'smart':
638 684
      $element['vote']['#description'] = ($settings['style'] == 'dual' && !$values['user']) ? NULL : theme('fivestar_summary', array(
639 685
        'user_rating' => $values['user'],
......
645 691
      $class[] = 'fivestar-smart-text';
646 692
      $class[] = $values['user'] ? 'fivestar-user-text' : 'fivestar-average-text';
647 693
      break;
694

  
648 695
    case 'dual':
649 696
      $element['vote']['#description'] = theme('fivestar_summary', array(
650 697
        'user_rating' => $values['user'],
......
655 702
      ));
656 703
      $class[] = ' fivestar-combo-text';
657 704
      break;
705

  
658 706
    case 'none':
659 707
      $element['vote']['#description'] = NULL;
660 708
      break;
......
664 712
    case 'average':
665 713
      $class[] = 'fivestar-average-stars';
666 714
      break;
715

  
667 716
    case 'user':
668 717
      $class[] = 'fivestar-user-stars';
669 718
      break;
719

  
670 720
    case 'smart':
671 721
      $class[] = 'fivestar-smart-stars ' . ($values['user'] ? 'fivestar-user-stars' : 'fivestar-average-stars');
672 722
      break;
723

  
673 724
    case 'dual':
674 725
      $class[] = 'fivestar-combo-stars';
675 726
      $static_average = theme('fivestar_static', array(
......
744 795
 *
745 796
 * @param $element
746 797
 *   The fivestar element
798
 *
747 799
 * @return
748 800
 *   The default value for the element.
749 801
 */
......
756 808
      case 'average':
757 809
        $default_value = $element['#values']['average'];
758 810
        break;
811

  
759 812
      case 'user':
760 813
        $default_value = $element['#values']['user'];
761 814
        break;
815

  
762 816
      case 'smart':
763 817
        $default_value = (!empty($element['#values']['user']) ? $element['#values']['user'] : $element['#values']['average']);
764 818
        break;
819

  
765 820
      case 'dual':
766 821
        $default_value = $element['#values']['user'];
767 822
        break;
823

  
768 824
      default:
769 825
        $default_value = $element['#values']['average'];
770 826
    }
771 827
  }
772 828

  
773 829
  for ($i = 0; $i <= $element['#stars']; $i++) {
774
    $this_value = ceil($i * 100/$element['#stars']);
775
    $next_value = ceil(($i+1) * 100/$element['#stars']);
830
    $this_value = ceil($i * 100 / $element['#stars']);
831
    $next_value = ceil(($i + 1) * 100 / $element['#stars']);
776 832

  
777 833
    // Round up the default value to the next exact star value if needed.
778 834
    if ($this_value < $default_value && $next_value > $default_value) {
......
793 849
}
794 850

  
795 851
/**
796
 * Implementation of hook_votingapi_metadata_alter().
852
 * Implements hook_votingapi_metadata_alter().
797 853
 */
798 854
function fivestar_votingapi_metadata_alter(&$data) {
799 855
  foreach (fivestar_get_tags() as $tag) {
......
806 862
  }
807 863
}
808 864

  
865
/**
866
 *
867
 */
809 868
function fivestar_get_tags() {
810 869
  $tags_txt = variable_get('fivestar_tags', 'vote');
811 870
  $tags_exploded = explode(',', $tags_txt);
......
828 887
  return $tags;
829 888
}
830 889

  
890
/**
891
 *
892
 */
831 893
function fivestar_get_targets($field, $instance, $key = FALSE, $entity = FALSE, $langcode = LANGUAGE_NONE) {
832 894
  $options = array();
833 895
  $targets = module_invoke_all('fivestar_target_info', $field, $instance);
......
864 926
        foreach ($field_instances as $field_instance) {
865 927
          $options[$field_instance['field_name']] = array(
866 928
            'title' => t('Node reference: @field', array('@field' => $field_instance['field_name'])),
867
            'callback' => '_fivestar_target_node_reference'
929
            'callback' => '_fivestar_target_node_reference',
868 930
          );
869 931
        }
870 932
      }
......
880 942
        foreach ($field_instances as $field_instance) {
881 943
          $options[$field_instance['field_name']] = array(
882 944
            'title' => t('Entity reference: @field', array('@field' => $field_instance['field_name'])),
883
            'callback' => '_fivestar_target_entityreference'
945
            'callback' => '_fivestar_target_entityreference',
884 946
          );
885 947
        }
886 948
      }
......
896 958
        foreach ($field_instances as $field_instance) {
897 959
          $options[$field_instance['field_name']] = array(
898 960
            'title' => t('User reference: @field', array('@field' => $field_instance['field_name'])),
899
            'callback' => '_fivestar_target_user_reference'
961
            'callback' => '_fivestar_target_user_reference',
900 962
          );
901 963
        }
902 964
      }
......
907 969
  if ($instance['entity_type'] == 'comment') {
908 970
    $options['parent_node'] = array(
909 971
      'title' => t('Parent Node'),
910
      'callback' => '_fivestar_target_comment_parent_node'
972
      'callback' => '_fivestar_target_comment_parent_node',
911 973
    );
912 974
  }
913 975

  
......
967 1029
  return $target;
968 1030
}
969 1031

  
1032
/**
1033
 *
1034
 */
970 1035
function _fivestar_target_comment_parent_node($entity, $field, $instance, $langcode) {
971 1036
  return array(
972 1037
    'entity_id' => $entity->nid,
......
977 1042
/**
978 1043
 * Helper function to determine if a user can vote on content.
979 1044
 *
980
 * @return Boolean
1045
 * @return bool
981 1046
 */
982 1047
function _fivestar_allow_vote($element) {
983 1048
  global $user;
......
991 1056
    $criteria = array(
992 1057
      'entity_id' => isset($element['#settings']['content_id']) ? $element['#settings']['content_id'] : NULL,
993 1058
      'entity_type' => isset($element['#settings']['content_type']) ? $element['#settings']['content_type'] : NULL,
1059
      'tag' => isset($element['#settings']['tag']) ? $element['#settings']['tag'] : NULL,
994 1060
      'uid' => $user->uid,
995 1061
    );
996 1062

  
997
  $can_revote = !votingapi_select_votes($criteria);
1063
    $can_revote = !votingapi_select_votes($criteria);
998 1064
  }
999 1065
  if (!$can_revote) {
1000 1066
    return FALSE;
......
1014 1080
  $uid2 = $user->uid;
1015 1081
  return $entity->uid != $user->uid;
1016 1082
}
1083

  
1084
/**
1085
 * Implements hook_ctools_content_subtype_alter()
1086
 */
1087
function fivestar_ctools_content_subtype_alter(&$subtype, &$plugin) {
1088
  if ($plugin['name'] == 'entity_field' && isset($subtype['subtype_id'])) {
1089
    list($entity_type, $field_name) = explode(':', $subtype['subtype_id'], 2);
1090
    $field = field_info_field($field_name);
1091
    if ($field['type'] == 'fivestar') {
1092
      $subtype['render callback'] = 'fivestar_fivestar_field_content_type_render';
1093
    }
1094
  }
1095
}
1096

  
1097
/**
1098
 * Render the custom content type.
1099
 */
1100
function fivestar_fivestar_field_content_type_render($subtype, $conf, $panel_args, $context) {
1101
  if (empty($context) || empty($context->data)) {
1102
    return;
1103
  }
1104

  
1105
  // Get a shortcut to the entity.
1106
  $entity = $context->data;
1107
  list($entity_type, $field_name) = explode(':', $subtype, 2);
1108

  
1109
  // Load the entity type's information for this field.
1110
  $ids = entity_extract_ids($entity_type, $entity);
1111
  $field = field_info_instance($entity_type, $field_name, $ids[2]);
1112

  
1113
  // Do not render if the entity type does not have this field.
1114
  if (empty($field)) {
1115
    return;
1116
  }
1117
  $language = field_language($entity_type, $entity, $field_name);
1118

  
1119
  if (empty($conf['label']) || $conf['label'] == 'title') {
1120
    $label = 'hidden';
1121
    $conf['label'] = 'title';
1122
  }
1123
  else {
1124
    $label = $conf['label'];
1125
  }
1126

  
1127
  $field_settings = array(
1128
    'label' => $label,
1129
    'type' => $conf['formatter'],
1130
    // Pass all entity field panes settings to field display settings.
1131
    'pane_settings' => $conf,
1132
  );
1133

  
1134
  // Get the field output, and the title.
1135
  if (!empty($conf['formatter_settings'])) {
1136
    $field_settings['settings'] = $conf['formatter_settings'];
1137
  }
1138

  
1139
  $all_values = field_get_items($entity_type, $entity, $field_name, $language);
1140

  
1141
  if (!$all_values) {
1142
    $all_values = array();
1143
  }
1144

  
1145
  // Reverse values.
1146
  if (isset($conf['delta_reversed']) && $conf['delta_reversed']) {
1147
    $all_values = array_reverse($all_values, TRUE);
1148
  }
1149

  
1150
  if (isset($conf['delta_limit'])) {
1151
    $offset = intval($conf['delta_offset']);
1152
    $limit = !empty($conf['delta_limit']) ? $conf['delta_limit'] : NULL;
1153
    $all_values = array_slice($all_values, $offset, $limit, TRUE);
1154
  }
1155

  
1156
  $clone = clone $entity;
1157
  $clone->{$field_name}[$language] = $all_values;
1158
  $field_output = field_view_field($entity_type, $clone, $field_name, $field_settings, $language);
1159

  
1160
  if (!empty($field_output) && !empty($conf['override_title'])) {
1161
    $field_output['#title'] = filter_xss_admin($conf['override_title_text']);
1162
  }
1163

  
1164
  // Build the content type block.
1165
  $block = new stdClass();
1166
  $block->module = 'entity_field';
1167
  if ($conf['label'] == 'title' && isset($field_output['#title'])) {
1168
    $block->title = $field_output['#title'];
1169
  }
1170

  
1171
  $block->content = $field_output;
1172
  $block->delta   = $ids[0];
1173

  
1174
  return $block;
1175
}
drupal7/sites/all/modules/fivestar/includes/fivestar.admin.inc
16 16
    '#title' => t('Voting tags'),
17 17
    '#description' => t('Choose the voting tags that will be available for node rating. A tag is simply a category of vote. If you only need to rate one thing per node, leave this as the default "vote".'),
18 18
    '#weight' => 3,
19
   );
19
  );
20 20

  
21 21
  $form['tags']['tags'] = array(
22 22
    '#type' => 'textfield',
......
24 24
    '#default_value' => variable_get('fivestar_tags', 'vote'),
25 25
    '#required' => TRUE,
26 26
    '#description' => t('Separate multiple tags with commas.'),
27
   );
27
  );
28 28

  
29
  $form['#submit'][] ='fivestar_settings_submit';
29
  $form['#submit'][] = 'fivestar_settings_submit';
30 30

  
31 31
  $form['submit'] = array(
32 32
    '#type' => 'submit',
......
37 37
  return $form;
38 38
}
39 39

  
40
/**
41
 * Submit handler for fivestar_settings() form.
42
 */
40 43
function fivestar_settings_submit($form, &$form_state) {
41 44
  drupal_set_message(t('Your settings have been saved.'));
42
  // TODO We could delete all variables for removed tags
45
  // @todo We could delete all variables for removed tags.
43 46
  variable_set('fivestar_tags', $form_state['values']['tags']);
44 47
}
drupal7/sites/all/modules/fivestar/includes/fivestar.field.inc
2 2

  
3 3
/**
4 4
 * @file
5
 * Provides CCK integration for fivestar module
5
 * Provides CCK integration for fivestar module.
6 6
 */
7 7

  
8 8
/**
9
 * Implementation of hook_field_info().
9
 * Implements hook_field_info().
10 10
 */
11 11
function fivestar_field_info() {
12 12
  return array(
......
28 28
  );
29 29
}
30 30

  
31
/**
32
 *
33
 */
31 34
function fivestar_form_field_ui_field_edit_form_alter(&$form, $form_state) {
32 35
  $field = $form['#field'];
33 36
  $instance = $form['#instance'];
......
43 46
}
44 47

  
45 48
/**
46
 * Implementation of hook_field_settings_form().
49
 * Implements hook_field_settings_form().
47 50
 */
48 51
function fivestar_field_settings_form($field, $instance) {
49 52
  $form['axis'] = array(
......
59 62
  return $form;
60 63
}
61 64

  
65
/**
66
 *
67
 */
62 68
function fivestar_field_instance_settings_form($field, $instance) {
63 69
  $form = array();
64 70

  
......
105 111
}
106 112

  
107 113
/**
108
 * Implementation of hook_field_insert().
114
 * Implements hook_field_insert().
109 115
 */
110 116
function fivestar_field_insert($entity_type, $entity, $field, $instance, $langcode, &$items) {
111 117
  _fivestar_field_helper($entity_type, $entity, $field, $instance, $langcode, $items);
112 118
}
113 119

  
114 120
/**
115
 * Implementation of hook_field_update().
121
 * Implements hook_field_update().
116 122
 */
117 123
function fivestar_field_update($entity_type, $entity, $field, $instance, $langcode, &$items) {
118 124
  _fivestar_field_helper($entity_type, $entity, $field, $instance, $langcode, $items);
119 125
}
120 126

  
121 127
/**
122
 * Implementation of hook_field_delete().
128
 * Implements hook_field_delete().
123 129
 */
124 130
function fivestar_field_delete($entity_type, $entity, $field, $instance, $langcode, &$items) {
125 131
  _fivestar_field_helper($entity_type, $entity, $field, $instance, $langcode, $items, 'delete');
126 132
}
127 133

  
134
/**
135
 * Implements hook_field_views_data().
136
 */
137
function fivestar_field_views_data($field) {
138
  $data = field_views_field_default_views_data($field);
139
  foreach ($data as $table_name => $table_data) {
140
    // Add our handler to the rating views field.
141
    $data[$table_name][$field['field_name'] . '_rating']['filter']['handler'] = 'fivestar_views_handler_filter_in_operator';
142
  }
143
  return $data;
144
}
145

  
146
/**
147
 *
148
 */
128 149
function _fivestar_field_helper($entity_type, $entity, $field, $instance, $langcode, &$items, $op = '') {
129 150
  foreach ($items as $delta => $item) {
130 151
    if ((isset($entity->status) && !$entity->status) || $op == 'delete') {
......
144 165
      _fivestar_cast_vote($target['entity_type'], $target['entity_id'], $rating, $field['settings']['axis'], $entity->uid, TRUE, $target['vote_source']);
145 166
      votingapi_recalculate_results($target['entity_type'], $target['entity_id']);
146 167
    }
147
    // The original callback is only called for a single updated field, but the Field API
148
    // then updates all fields of the entity. For an update, the Field API first deletes
149
    // the equivalent row in the database and then adds a new row based on the
150
    // information in $items here. If there are multiple Fivestar fields on an entity, the
151
    // one being updated is handled ok ('rating' having already been set to the new value),
152
    // but other Fivestar fields are set to NULL as 'rating' isn't set - not what an update
153
    // would be expected to do. So set 'rating' for all of the Fivestar fields from the
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff