Révision 018e218c
Ajouté par Assos Assos il y a plus de 10 ans
htmltest/sites/all/modules/flag/README.txt | ||
---|---|---|
7 | 7 |
to give all the control to the administrator. Using this module, the |
8 | 8 |
site administrator can provide an arbitrary number of 'flags'. |
9 | 9 |
|
10 |
A flag is really just a boolean toggle that is set on a node, comment,
|
|
11 |
or user. Flags may be per-user, meaning that each user can flag an item |
|
10 |
A flag is really just a boolean toggle that is set on an entity such as a node,
|
|
11 |
comment, or user. Flags may be per-user, meaning that each user can flag an item
|
|
12 | 12 |
individually, or global, meaning that the item is either flagged or it |
13 | 13 |
is not flagged, and any user who changes that changes it for everyone. |
14 | 14 |
|
15 |
In this way, additional flags (similar to 'published' and 'sticky') can
|
|
16 |
be put on nodes, or other items, and dealt with by the system however
|
|
15 |
In this way, additional flags (similar to 'published' and 'sticky') can |
|
16 |
be put on nodes, or other items, and dealt with by the system however |
|
17 | 17 |
the administration likes. |
18 | 18 |
|
19 | 19 |
Each flag allows the administrator to choose the 'flag this' text, and |
... | ... | |
25 | 25 |
flag provides data to the Views module, and provides a default |
26 | 26 |
view to list 'My bookmarks'. These default views are somewhat crude, |
27 | 27 |
but are easily tailored to whatever the system administrator would like |
28 |
it to do.
|
|
28 |
it to do. |
|
29 | 29 |
|
30 |
Each flag also provides an 'argument' to the Views module that can be
|
|
31 |
used to allow a user to view other people's flagged content. This isn't
|
|
32 |
turned on by default anywhere, though, and the administrator will need
|
|
30 |
Each flag also provides an 'argument' to the Views module that can be |
|
31 |
used to allow a user to view other people's flagged content. This isn't |
|
32 |
turned on by default anywhere, though, and the administrator will need |
|
33 | 33 |
to construct a view in order to take advantage of it. |
34 | 34 |
|
35 |
The module will come installed with a simple flag called "bookmarks" and
|
|
36 |
a simple view for 'My bookmarks'. This is a default view provided by the
|
|
37 |
Flag module, but can be customized to fit the needs of your site. To
|
|
38 |
customize this view, go to admin/structure/views and find the
|
|
39 |
'flags_bookmarks' view. Click the 'Add' action to customize the view.
|
|
40 |
Once saved, the new version of the view will be used rather than the one
|
|
35 |
The Flag Bookmark module provides a simple flag called "bookmarks" and
|
|
36 |
a simple view for 'My bookmarks'. This is a default view provided by the |
|
37 |
Flag module, but can be customized to fit the needs of your site. To |
|
38 |
customize this view, go to admin/structure/views and find the |
|
39 |
'flags_bookmarks' view. Click the 'Add' action to customize the view. |
|
40 |
Once saved, the new version of the view will be used rather than the one |
|
41 | 41 |
provided by Flag. |
42 | 42 |
|
43 | 43 |
Besides editing the default view that comes with the module, Flag |
htmltest/sites/all/modules/flag/flag.api.php | ||
---|---|---|
350 | 350 |
/** |
351 | 351 |
* Alter the javascript structure that describes the flag operation. |
352 | 352 |
* |
353 |
* @param $info |
|
354 |
* The info array before it is returned from flag_build_javascript_info(). |
|
353 | 355 |
* @param $flag |
354 | 356 |
* The full flag object. |
355 |
* @param $entity_id |
|
356 |
* The ID of the node, comment, user or other object being flagged. |
|
357 | 357 |
* |
358 | 358 |
* @see flag_build_javascript_info() |
359 | 359 |
*/ |
360 |
function hook_flag_javascript_info_alter() { |
|
361 |
|
|
360 |
function hook_flag_javascript_info_alter(&$info, $flag) { |
|
361 |
if ($flag->name === 'test') { |
|
362 |
$info['newLink'] = $flag->theme($flag->is_flagged($info['contentId']) ? 'unflag' : 'flag', $info['contentId'], array( |
|
363 |
'after_flagging' => TRUE, |
|
364 |
'errors' => $flag->get_errors(), |
|
365 |
// Additional options to pass to theme's preprocess function/template. |
|
366 |
'icon' => TRUE, |
|
367 |
'hide_text' => TRUE, |
|
368 |
)); |
|
369 |
} |
|
362 | 370 |
} |
363 | 371 |
|
364 | 372 |
/** |
htmltest/sites/all/modules/flag/flag.info | ||
---|---|---|
26 | 26 |
files[] = includes/views/flag_plugin_argument_validate_flaggability.inc |
27 | 27 |
files[] = tests/flag.test |
28 | 28 |
|
29 |
; Information added by drupal.org packaging script on 2013-09-13
|
|
30 |
version = "7.x-3.2"
|
|
29 |
; Information added by Drupal.org packaging script on 2014-01-26
|
|
30 |
version = "7.x-3.3"
|
|
31 | 31 |
core = "7.x" |
32 | 32 |
project = "flag" |
33 |
datestamp = "1379063829"
|
|
33 |
datestamp = "1390732707"
|
|
34 | 34 |
|
htmltest/sites/all/modules/flag/flag.install | ||
---|---|---|
100 | 100 |
'default' => 0, |
101 | 101 |
), |
102 | 102 |
'sid' => array( |
103 |
'description' => "The user's session id as stored in the session table.",
|
|
103 |
'description' => "The user's numeric sid from the session_api table.",
|
|
104 | 104 |
'type' => 'int', |
105 | 105 |
'unsigned' => TRUE, |
106 | 106 |
'not null' => TRUE, |
htmltest/sites/all/modules/flag/flag.module | ||
---|---|---|
33 | 33 |
// The following tells EntityAPI how to save flaggings, thus allowing use |
34 | 34 |
// of Entity metadata wrappers (if present). |
35 | 35 |
'save callback' => 'flagging_save', |
36 |
'creation callback' => 'flagging_create', |
|
36 | 37 |
), |
37 | 38 |
); |
38 | 39 |
|
... | ... | |
72 | 73 |
return reset($result); |
73 | 74 |
} |
74 | 75 |
|
76 |
/** |
|
77 |
* Entity API creation callback. |
|
78 |
* |
|
79 |
* Creates an unsaved flagging object for use with $flag->flag(). |
|
80 |
* |
|
81 |
* @param $values |
|
82 |
* An array of values as described by the entity's property info. Only |
|
83 |
* 'flag_name' or 'fid' must be specified, since $flag->flag() does the rest. |
|
84 |
* |
|
85 |
* @return |
|
86 |
* An unsaved flagging object containing the property values. |
|
87 |
*/ |
|
88 |
function flagging_create($values = array()) { |
|
89 |
$flagging = (object) array(); |
|
90 |
|
|
91 |
if (!isset($values['flag_name'])) { |
|
92 |
if (isset($values['fid'])) { |
|
93 |
// Add flag_name, determined from fid. |
|
94 |
$flag = flag_get_flag(NULL, $values['fid']); |
|
95 |
$values['flag_name'] = $flag->name; |
|
96 |
} |
|
97 |
} |
|
98 |
|
|
99 |
// Apply the given values. |
|
100 |
foreach ($values as $key => $value) { |
|
101 |
$flagging->$key = $value; |
|
102 |
} |
|
103 |
|
|
104 |
return $flagging; |
|
105 |
} |
|
106 |
|
|
75 | 107 |
/** |
76 | 108 |
* Saves a flagging entity. |
77 | 109 |
* |
... | ... | |
616 | 648 |
continue; |
617 | 649 |
} |
618 | 650 |
|
619 |
foreach ($flag->types as $bundle_name) { |
|
651 |
$applicable_bundles = $flag->types; |
|
652 |
// If the list of bundles is empty, it indicates all bundles apply. |
|
653 |
if (empty($applicable_bundles)) { |
|
654 |
$entity_info = entity_get_info($flag->entity_type); |
|
655 |
$applicable_bundles = array_keys($entity_info['bundles']); |
|
656 |
} |
|
657 |
|
|
658 |
foreach ($applicable_bundles as $bundle_name) { |
|
620 | 659 |
if ($flag->show_on_form) { |
621 | 660 |
$extra[$flag->entity_type][$bundle_name]['form']['flag'] = array( |
622 | 661 |
'label' => t('Flags'), |
... | ... | |
698 | 737 |
$id = NULL; |
699 | 738 |
} |
700 | 739 |
|
740 |
// Keep track of whether the entity is new or not, as we're about to fiddle |
|
741 |
// with the entity id for the flag's entity cache. |
|
742 |
$is_existing_entity = !empty($id); |
|
743 |
|
|
701 | 744 |
// Get all possible flags for this entity type. |
702 | 745 |
$flags = flag_get_flags($entity_type); |
703 | 746 |
|
... | ... | |
710 | 753 |
} |
711 | 754 |
|
712 | 755 |
// Get the flag status. |
713 |
if (isset($id)) {
|
|
756 |
if ($is_existing_entity) {
|
|
714 | 757 |
$flag_status = $flag->is_flagged($id); |
715 | 758 |
} |
716 | 759 |
else { |
... | ... | |
719 | 762 |
$flag_status = FALSE; |
720 | 763 |
// Apply the per-bundle defaults for nodes. |
721 | 764 |
if ($entity_type == 'node') { |
722 |
$flag_status = variable_get('flag_' . $flag->name . '_default_' . $form['type']['#value'], 0); |
|
765 |
$node_type = $entity->type; |
|
766 |
$flag_status = variable_get('flag_' . $flag->name . '_default_' . $node_type, 0); |
|
723 | 767 |
} |
724 | 768 |
|
725 | 769 |
// For a new, unsaved entity, make a dummy entity ID so that the flag |
... | ... | |
1646 | 1690 |
// Non-Views public API |
1647 | 1691 |
|
1648 | 1692 |
/** |
1649 |
* Get the count of flags for a certain entity.
|
|
1693 |
* Get the count of flags for a particular entity type.
|
|
1650 | 1694 |
* |
1651 | 1695 |
* @param $flag |
1652 | 1696 |
* The flag. |
1653 | 1697 |
* @param $entity_type |
1654 |
* The entity type (usually 'node').
|
|
1698 |
* The entity type. For example, 'node'.
|
|
1655 | 1699 |
* |
1656 | 1700 |
* @return |
1657 | 1701 |
* The flag count with the flag name and entity type as the array key. |
... | ... | |
2104 | 2148 |
* The "machine readable" name of the flag; e.g. 'bookmarks'. |
2105 | 2149 |
* @param $entity_id |
2106 | 2150 |
* The entity ID to check for flagging, for example a node ID. |
2151 |
* @param $variables |
|
2152 |
* An array of further variables to pass to theme('flag'). For the full list |
|
2153 |
* of parameters, see flag.tpl.php. Of particular interest: |
|
2154 |
* - after_flagging: Set to TRUE if this flag link is being displayed as the |
|
2155 |
* result of a flagging action. |
|
2156 |
* - errors: An array of error messages. |
|
2107 | 2157 |
* |
2108 | 2158 |
* @return |
2109 | 2159 |
* The HTML for the themed flag link. |
2110 | 2160 |
*/ |
2111 |
function flag_create_link($flag_name, $entity_id) { |
|
2161 |
function flag_create_link($flag_name, $entity_id, $variables = array()) {
|
|
2112 | 2162 |
$flag = flag_get_flag($flag_name); |
2113 | 2163 |
if (!$flag) { |
2114 | 2164 |
// Flag does not exist. |
... | ... | |
2118 | 2168 |
// User has no permission to use this flag. |
2119 | 2169 |
return; |
2120 | 2170 |
} |
2121 |
return $flag->theme($flag->is_flagged($entity_id) ? 'unflag' : 'flag', $entity_id); |
|
2171 |
return $flag->theme($flag->is_flagged($entity_id) ? 'unflag' : 'flag', $entity_id, $variables);
|
|
2122 | 2172 |
} |
2123 | 2173 |
|
2124 | 2174 |
/** |
htmltest/sites/all/modules/flag/flag.rules.inc | ||
---|---|---|
456 | 456 |
} |
457 | 457 |
|
458 | 458 |
/** |
459 |
* Base action implementation: Fetch count of flags for a particular entity. |
|
459 |
* Base action implementation: Fetch count of flags for a particular entity type.
|
|
460 | 460 |
*/ |
461 | 461 |
function flag_rules_action_fetch_entity_flag_count($flag, $entity_type) { |
462 | 462 |
$count = flag_get_entity_flag_counts($flag, $entity_type); |
htmltest/sites/all/modules/flag/flag_actions.info | ||
---|---|---|
7 | 7 |
|
8 | 8 |
files[] = flag.install |
9 | 9 |
files[] = flag_actions.module |
10 |
; Information added by drupal.org packaging script on 2013-09-13
|
|
11 |
version = "7.x-3.2"
|
|
10 |
; Information added by Drupal.org packaging script on 2014-01-26
|
|
11 |
version = "7.x-3.3"
|
|
12 | 12 |
core = "7.x" |
13 | 13 |
project = "flag" |
14 |
datestamp = "1379063829"
|
|
14 |
datestamp = "1390732707"
|
|
15 | 15 |
|
htmltest/sites/all/modules/flag/flag_bookmark/flag_bookmark.info | ||
---|---|---|
4 | 4 |
dependencies[] = flag |
5 | 5 |
package = Flags |
6 | 6 |
|
7 |
; Information added by drupal.org packaging script on 2013-09-13
|
|
8 |
version = "7.x-3.2"
|
|
7 |
; Information added by Drupal.org packaging script on 2014-01-26
|
|
8 |
version = "7.x-3.3"
|
|
9 | 9 |
core = "7.x" |
10 | 10 |
project = "flag" |
11 |
datestamp = "1379063829"
|
|
11 |
datestamp = "1390732707"
|
|
12 | 12 |
|
htmltest/sites/all/modules/flag/includes/flag.admin.inc | ||
---|---|---|
529 | 529 |
'#title' => t('Flag confirmation message'), |
530 | 530 |
'#default_value' => isset($flag->flag_confirmation) ? $flag->flag_confirmation : '', |
531 | 531 |
'#description' => t('Message displayed if the user has clicked the "flag this" link and confirmation is required. Usually presented in the form of a question such as, "Are you sure you want to flag this content?"'), |
532 |
// This will get changed to a state by flag_link_type_options_states(). |
|
533 |
'#required' => TRUE, |
|
532 | 534 |
); |
533 | 535 |
|
534 | 536 |
$form['display']['link_options_confirm']['unflag_confirmation'] = array( |
... | ... | |
536 | 538 |
'#title' => t('Unflag confirmation message'), |
537 | 539 |
'#default_value' => isset($flag->unflag_confirmation) ? $flag->unflag_confirmation : '', |
538 | 540 |
'#description' => t('Message displayed if the user has clicked the "unflag this" link and confirmation is required. Usually presented in the form of a question such as, "Are you sure you want to unflag this content?"'), |
541 |
// This will get changed to a state by flag_link_type_options_states(). |
|
542 |
'#required' => TRUE, |
|
539 | 543 |
); |
540 | 544 |
|
541 | 545 |
$form['actions'] = array( |
... | ... | |
561 | 565 |
} |
562 | 566 |
|
563 | 567 |
/** |
564 |
* FormAPI after_build function set states on link type options fieldsets. |
|
568 |
* FormAPI after_build function to set states on link type options fieldsets.
|
|
565 | 569 |
* |
566 | 570 |
* We do this in an after build so we handle further link types fieldsets from |
567 | 571 |
* other modules that provide link types. |
... | ... | |
581 | 585 |
':input[name="link_type"]' => array('value' => $radio_value), |
582 | 586 |
), |
583 | 587 |
); |
588 |
|
|
589 |
// If an element in a link type options fieldset is required, then we |
|
590 |
// remove this, as this would break the form, by demanding the user |
|
591 |
// enter a value for a form element they possibly can't see! |
|
592 |
// Instead, we set the required property as a state. |
|
593 |
foreach (element_children($element[$key]) as $child_key) { |
|
594 |
if (!empty($element[$key][$child_key]['#required'])) { |
|
595 |
$element[$key][$child_key]['#required'] = FALSE; |
|
596 |
$element[$key][$child_key]['#states']['required'] = array( |
|
597 |
':input[name="link_type"]' => array('value' => $radio_value), |
|
598 |
); |
|
599 |
} |
|
600 |
} |
|
601 |
|
|
584 | 602 |
// Gather up the radio values for the format we need for a multiple |
585 | 603 |
// value state. |
586 | 604 |
$intro_element_values_array[] = array('value' => $radio_value); |
... | ... | |
635 | 653 |
$form_state['values']['title'] = trim($form_state['values']['title']); |
636 | 654 |
$form_values = $form_state['values']; |
637 | 655 |
|
638 |
if ($form_values['link_type'] == 'confirm') { |
|
639 |
if (empty($form_values['flag_confirmation'])) { |
|
640 |
form_set_error('flag_confirmation', t('A flag confirmation message is required when using the confirmation link type.')); |
|
641 |
} |
|
642 |
if (empty($form_values['unflag_confirmation'])) { |
|
643 |
form_set_error('unflag_confirmation', t('An unflag confirmation message is required when using the confirmation link type.')); |
|
644 |
} |
|
645 |
} |
|
646 |
|
|
647 |
|
|
648 | 656 |
$flag = $form['#flag']; |
649 | 657 |
$flag->form_input($form_values); |
650 | 658 |
$errors = $flag->validate(); |
htmltest/sites/all/modules/flag/includes/flag.pages.inc | ||
---|---|---|
160 | 160 |
'flagName' => $flag->name, |
161 | 161 |
'flagStatus' => $flag->is_flagged($entity_id) ? 'flagged' : 'unflagged', |
162 | 162 |
); |
163 |
drupal_alter('flag_javascript_info', $info); |
|
163 |
drupal_alter('flag_javascript_info', $info, $flag);
|
|
164 | 164 |
return $info; |
165 | 165 |
} |
htmltest/sites/all/modules/flag/includes/flag/flag_entity.inc | ||
---|---|---|
180 | 180 |
function get_labels_token_types() { |
181 | 181 |
// The token type name might be different to the entity type name. If so, |
182 | 182 |
// an own flag entity handler can be used for overriding this. |
183 |
return array_merge(array($this->entity_type), parent::get_labels_token_types()); |
|
183 |
$entity_info = entity_get_info($this->entity_type); |
|
184 |
if (isset($entity_info['token type'])) { |
|
185 |
return array_merge(array($entity_info['token type']), parent::get_labels_token_types()); |
|
186 |
} |
|
187 |
else { |
|
188 |
return array_merge(array($this->entity_type), parent::get_labels_token_types()); |
|
189 |
} |
|
184 | 190 |
} |
185 | 191 |
|
186 | 192 |
/** |
htmltest/sites/all/modules/flag/includes/flag/flag_flag.inc | ||
---|---|---|
788 | 788 |
} |
789 | 789 |
} |
790 | 790 |
elseif ($action == 'flag') { |
791 |
// Invoke hook_entity_presave(). |
|
792 |
module_invoke_all('entity_presave', $flagging, 'flagging'); |
|
793 |
|
|
791 | 794 |
if ($this->uses_anonymous_cookies()) { |
792 | 795 |
$this->_flag_anonymous($entity_id); |
793 | 796 |
} |
... | ... | |
850 | 853 |
private function _insert_flagging($flagging) { |
851 | 854 |
field_attach_presave('flagging', $flagging); |
852 | 855 |
field_attach_insert('flagging', $flagging); |
856 |
// Invoke hook_entity_insert(). |
|
857 |
module_invoke_all('entity_insert', $flagging, 'flagging'); |
|
853 | 858 |
} |
854 | 859 |
private function _update_flagging($flagging) { |
855 | 860 |
field_attach_presave('flagging', $flagging); |
856 | 861 |
field_attach_update('flagging', $flagging); |
857 | 862 |
// Update the cache. |
858 | 863 |
entity_get_controller('flagging')->resetCache(); |
864 |
// Invoke hook_entity_update(). |
|
865 |
module_invoke_all('entity_update', $flagging, 'flagging'); |
|
859 | 866 |
} |
860 | 867 |
private function _delete_flagging($flagging) { |
861 | 868 |
field_attach_delete('flagging', $flagging); |
862 | 869 |
// Remove from the cache. |
863 | 870 |
entity_get_controller('flagging')->resetCache(); |
871 |
// Invoke hook_entity_delete(). |
|
872 |
module_invoke_all('entity_delete', $flagging, 'flagging'); |
|
864 | 873 |
} |
865 | 874 |
|
866 | 875 |
/** |
htmltest/sites/all/modules/flag/tests/flagaccesstest/flagaccesstest.info | ||
---|---|---|
5 | 5 |
package = Flags |
6 | 6 |
hidden = TRUE |
7 | 7 |
|
8 |
; Information added by drupal.org packaging script on 2013-09-13
|
|
9 |
version = "7.x-3.2"
|
|
8 |
; Information added by Drupal.org packaging script on 2014-01-26
|
|
9 |
version = "7.x-3.3"
|
|
10 | 10 |
core = "7.x" |
11 | 11 |
project = "flag" |
12 |
datestamp = "1379063829"
|
|
12 |
datestamp = "1390732707"
|
|
13 | 13 |
|
Formats disponibles : Unified diff
Weekly update of contrib modules