|
1 | 1 | <?php |
2 | 2 | /** |
3 | 3 | * mm_ddSelectDocuments |
4 | | - * @version 1.2.2 (2014-02-14) |
| 4 | + * @version 1.3 (2016-06-06) |
5 | 5 | * |
6 | 6 | * @desc A widget for ManagerManager that makes selection of documents ids easier. |
7 | 7 | * |
|
11 | 11 | * @param $tvs {comma separated string} - TVs names that the widget is applied to. @required |
12 | 12 | * @param $roles {comma separated string} - Roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). Default: ''. |
13 | 13 | * @param $templates {comma separated string} - Templates IDs for which the widget is applying (empty value means the widget is applying to all templates). Default: ''. |
14 | | - * @param $parentIds {comma separated string} - Parent documents IDs. @required |
| 14 | + * @param $parentIds {comma separated string} - Parent documents IDs. Default: '0'. |
15 | 15 | * @param $depth {integer} - Depth of search. Default: 1. |
16 | 16 | * @param $filter {separated string} - Filter clauses, separated by '&' between pairs and by '=' between keys and values. For example, 'template=15&published=1' means to choose the published documents with template id=15. Default: ''. |
17 | 17 | * @param $max {integer} - The largest number of elements that can be selected by user (“0” means selection without a limit). Default: 0. |
18 | 18 | * @param $labelMask {string} - Template to be used while rendering elements of the document selection list. It is set as a string containing placeholders for document fields and TVs. Also, there is the additional placeholder “[+title+]” that is substituted with either “menutitle” (if defined) or “pagetitle”. Default: '[+title+] ([+id+])'. |
| 19 | + * @param $allowDoubling {boolean} - Allows to select duplicates values. Default: false. |
19 | 20 | * |
20 | 21 | * @event OnDocFormPrerender |
21 | 22 | * @event OnDocFormRender |
22 | 23 | * |
23 | | - * @link http://code.divandesign.biz/modx/mm_ddselectdocuments/1.2.2 |
| 24 | + * @link http://code.divandesign.biz/modx/mm_ddselectdocuments/1.3 |
24 | 25 | * |
25 | | - * @copyright 2014, DivanDesign |
26 | | - * http://www.DivanDesign.biz |
| 26 | + * @copyright 2013–2016 DivanDesign {@link http://www.DivanDesign.biz } |
27 | 27 | */ |
28 | 28 |
|
29 | | -function mm_ddSelectDocuments($tvs = '', $roles = '', $templates = '', $parentIds, $depth = 1, $filter = '', $max = 0, $labelMask = '[+title+] ([+id+])'){ |
30 | | - if (empty($parentIds) || !useThisRule($roles, $templates)){return;} |
| 29 | +function mm_ddSelectDocuments($tvs = '', $roles = '', $templates = '', $parentIds = '0', $depth = 1, $filter = '', $max = 0, $labelMask = '[+title+] ([+id+])', $allowDoubling = false){ |
| 30 | + if (!useThisRule($roles, $templates)){return;} |
31 | 31 |
|
32 | 32 | global $modx; |
33 | 33 | $e = &$modx->Event; |
@@ -130,16 +130,16 @@ function mm_ddSelectDocuments($tvs = '', $roles = '', $templates = '', $parentId |
130 | 130 | ); |
131 | 131 | } |
132 | 132 |
|
133 | | - $output .= "//---------- mm_ddSelectDocuments :: Begin -----\n"; |
| 133 | + $output .= '//---------- mm_ddSelectDocuments :: Begin -----'.PHP_EOL; |
134 | 134 |
|
135 | 135 | foreach ($tvs as $tv){ |
136 | 136 | $output .= |
137 | 137 | ' |
138 | | -$j("#tv'.$tv['id'].'").ddMultipleInput({source: '.$jsonDocs.', max: '.$max.'}); |
| 138 | +$j("#tv'.$tv['id'].'").ddMultipleInput({source: '.$jsonDocs.', max: '.(int) $max.', allowDoubling: '.(int) $allowDoubling.'}); |
139 | 139 | '; |
140 | 140 | } |
141 | 141 |
|
142 | | - $output .= "//---------- mm_ddSelectDocuments :: End -----\n"; |
| 142 | + $output .= '//---------- mm_ddSelectDocuments :: End -----'.PHP_EOL; |
143 | 143 |
|
144 | 144 | $e->output($output); |
145 | 145 | } |
|
0 commit comments