Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
a3cff3b
field type number
MrSwed Dec 3, 2014
24da0da
The default value in columnsData. If JSON (for select), the flag may …
MrSwed Dec 3, 2015
4562f2d
common control block with clear button
MrSwed Mar 3, 2015
d2d9f01
[+] batch filling
MrSwed Mar 4, 2015
41c788c
Refactor 1. Switch.. case.
MrSwed Mar 8, 2015
859bba8
Refactor 2. optimize vars (smaller file size)
MrSwed Mar 11, 2015
c95f285
allow use universal sizes of images
MrSwed Mar 28, 2015
0699716
allow use universal parameter size of inputs (80%,5em,auto,etc)
MrSwed Mar 27, 2015
c0c081e
more adaptive css
MrSwed Mar 27, 2015
3f78e36
Copy row button
MrSwed Mar 27, 2015
9236f89
Clone button. fix interaction with other elements
MrSwed Mar 29, 2015
3563b70
more compact headers
MrSwed Mar 29, 2015
e8c65c0
Reset button
MrSwed Mar 29, 2015
e99b956
new parameter - options: sortable (true/false) - now can switch off s…
MrSwed Mar 30, 2015
fdb43cf
cancel css width (conflict in child editor)
MrSwed Mar 31, 2015
393052a
fix comments
MrSwed Mar 31, 2015
fce21bd
revert "more adaptive css" (689d5011f14f0028f9c0eb003dd9964af1cd2578)…
MrSwed Apr 1, 2015
7702349
Refactor
MrSwed Apr 10, 2015
a5be4a7
Refactor and fix
MrSwed Apr 10, 2015
e03f0e3
Tip for title
MrSwed Apr 10, 2015
4aa987d
Данные колонки по умолчанию - предыдущий, если нет для данной колонки
MrSwed May 12, 2015
0153f85
Примеры для coloumnsData
MrSwed May 12, 2015
952a4d0
ширина для селекта
MrSwed May 15, 2015
2b004a8
fix numbering, refactoring
MrSwed May 24, 2015
7472201
some refactor
MrSwed May 24, 2015
6625be2
fix clone row
MrSwed May 24, 2015
e9e7bf2
Changes:
MrSwed Jun 1, 2015
9f5388a
[+] allow options directly in JSON
MrSwed Feb 25, 2016
5a8dc22
[+] Option: Show button "Raw". Show/Hide the original field. Availabl…
MrSwed Feb 25, 2016
a33d0dc
options documentation
MrSwed Feb 28, 2016
eaf9a20
[+] multiselect
MrSwed Mar 9, 2016
db04cc8
correct richedit window size for full toolbar
MrSwed May 12, 2016
1156b3f
fix using tables in richtext
MrSwed May 26, 2016
3636e7b
possible to hide common control panel
MrSwed Jun 27, 2016
bf67098
Confirm clear all
MrSwed Jun 28, 2016
a926016
refactor deprecated
MrSwed Aug 12, 2016
ee6ac69
[+] add languages
MrSwed Jan 31, 2017
568a1c6
[localization] more localized
MrSwed Jan 31, 2017
88e4a65
correct Readme.md
MrSwed Feb 1, 2017
036a5eb
Update README.md
MrSwed Feb 1, 2017
cd7b2ee
[*] source usage fix
MrSwed Sep 5, 2017
5743d8c
[fix] PHP7 FIX
MrSwed Sep 5, 2017
0fe5fea
[*] source usage fix
MrSwed Sep 5, 2017
902b952
[fix] v.4.6.1-sd
MrSwed Sep 5, 2017
59e4285
v.4.6.1-sd
MrSwed Sep 5, 2017
2a00c33
[fix] localization
MrSwed Jan 19, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# mm_ddMultipleFields

**This is NOT Original mm_ddMultipleFields**

To explore original mm_ddMultipleFields from DivanDesign go to original repo that forked
[DivanDesign/MODXEvo.plugin.ManagerManager.mm_ddMultipleFields](https://github.com/DivanDesign/MODXEvo.plugin.ManagerManager.mm_ddMultipleFields)


Widget for plugin ManagerManager that allows you to add any number of fields values (TV) in one document (values is written as one with using separator symbols). For example: a few images.
___
Visit the following [link](http://code.divandesign.biz/modx/mm_ddmultiplefields) to read the documentation, instructions & changelog.

See more info inside [ddmultiplefields.php](https://github.com/MrSwed/MODXEvo.plugin.ManagerManager.mm_ddMultipleFields/blob/master/ddmultiplefields/ddmultiplefields.php#L1-L32)
and in [Modx.im blog](http://modx.im/blog/addons/4265.html)
35 changes: 29 additions & 6 deletions ddmultiplefields/ddmultiplefields.css
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
font: 12px/1.2em Verdana,Helvetica,sans-serif !important;
}

.ddMultipleField input {height: 1.2em;}
.ddMultipleField input {height: 2em;}

.ddMultipleField input:focus {border-color: #E1A020 !important;}

Expand All @@ -39,11 +39,15 @@
vertical-align: top;
}

.ddMultipleField tr th, .ddMultipleField tr td.ddFieldCol:last-child {
.ddMultipleField tr td.ddFieldCol:last-child {
white-space: nowrap;
}

.ddMultipleField tr th {text-align: left;}
.ddMultipleField tr th {
line-height: 1;
text-align: left;
vertical-align: bottom;
}

.ddMultipleField tr td.ddFieldCol, .ddMultipleField tr td.ddSortHandle {
border: 2px solid #FFFFFF;
Expand All @@ -70,15 +74,22 @@
.ddMultipleField tr td.ddSortHandle div {
/* border-radius: 0 12px 12px 0; */
background: #007CC3;
width: 10px;
height: 23px;
min-width: 1em;
min-height: 2em;
-webkit-transition: opacity 0.3s ease-out;
-moz-transition: opacity 0.3s ease-out;
-ms-transition: opacity 0.3s ease-out;
-o-transition: opacity 0.3s ease-out;
transition: opacity 0.3s ease-out;
opacity: .3;
cursor: n-resize;
color: white;
display: inline-block;
padding: 0.2em 0.3em 0.2em 0.25em;
box-sizing: border-box;
}
.ddMultipleField.nosort tr td.ddSortHandle div {
cursor: default;
}

.ddMultipleField tr.ddFieldBlock:hover td.ddFieldCol, .ddMultipleField tr.ddFieldBlock:hover td.ddSortHandle {background: #B2E3FF;}
Expand All @@ -98,4 +109,16 @@
background: #f0f0f0;
width: 100%;
height: 100%;
}
}
.tip {
cursor: default;
}
.tip:after {
color: #999;
content: "?";
display: inline-block;
font-size: 80%;
padding: 0.05em 0.15em;
text-align: center;
vertical-align: super;
}
45 changes: 30 additions & 15 deletions ddmultiplefields/ddmultiplefields.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* mm_ddMultipleFields
* @version 4.6 (2014-10-24)
* @version 4.6.1-SD (2017-05-15)
*
* @desc Widget for plugin ManagerManager that allows you to add any number of fields values (TV) in one document (values is written as one with using separator symbols). For example: a few images.
*
Expand All @@ -10,7 +10,7 @@
* @param $tvs {comma separated string} - Names of TV for which the widget is applying. @required
* @param $roles {comma separated string} - The roles that the widget is applied to (when this parameter is empty then widget is applied to the all roles). Default: ''.
* @param $templates {comma separated string} - Templates IDs for which the widget is applying (empty value means the widget is applying to all templates). Default: ''.
* @param $columns {comma separated string} - Column types: field — field type column; text — text type column; textarea — multiple lines column; richtext — column with rich text editor; date — date column; id — hidden column containing unique id; select — list with options (parameter “columnsData”). Default: 'field'.
* @param $columns {comma separated string} - Column types: field — field type column; text — text type column; textarea — multiple lines column; richtext — column with rich text editor; date — date column; id — hidden column containing unique id; select, multiselect — list with options (parameter “columnsData”). Default: 'field'.
* @param $columnsTitle {comma separated string} - Columns titles. Default: ''.
* @param $colWidth {comma separated string} - Columns width (one value can be set). Default: 180;
* @param $splY {string} - Strings separator. Default: '||'.
Expand All @@ -19,7 +19,8 @@
* @param $imgH {integer} - Maximum value of image preview height. Default: 100.
* @param $minRow {integer} - Minimum number of strings. Default: 0.
* @param $maxRow {integer} - Maximum number of strings. Default: 0 (без лимита).
* @param $columnsData {separated string} - List of valid values in json format (with “||”). Default: ''.
* @param $columnsData {separated string} - List of valid values in json format (with “||”). Default: ''. Example: `[['','No selected'],['0','No'],['1','Yes',1]]`
* @param $options {array or JSON} - Extend options: sortable - allow sorting (default), showIndex - display line numbers (default), btnToggleRaw - show button "Raw" (not defailt)
*
* @event OnDocFormPrerender
* @event OnDocFormRender
Expand All @@ -30,26 +31,38 @@
* http://www.DivanDesign.biz
*/

function mm_ddMultipleFields($tvs = '', $roles = '', $templates = '', $columns = 'field', $columnsTitle = '', $colWidth = '180', $splY = '||', $splX = '::', $imgW = 300, $imgH = 100, $minRow = 0, $maxRow = 0, $columnsData = ''){
function isJson($string) {
json_decode($string);
return (json_last_error() == JSON_ERROR_NONE);
}

function mm_ddMultipleFields($tvs = '', $roles = '', $templates = '', $columns = 'field', $columnsTitle = '', $colWidth = '180', $splY = '||', $splX = '::', $imgW = 300, $imgH = 100, $minRow = 0, $maxRow = 0, $columnsData = '',$options = array()){
if (!useThisRule($roles, $templates)){return;}

if (is_array($options)) {
$options = json_encode($options);
}
global $modx;
$e = &$modx->Event;

$output = '';

$site = $modx->config['site_url'];
$widgetDir = $site.'assets/plugins/managermanager/widgets/ddmultiplefields/';
$widgetPath = 'assets/plugins/managermanager/widgets/ddmultiplefields/';
$widgetDir = $site.$widgetPath;

if ($e->name == 'OnDocFormPrerender'){
global $_lang;

$output .= includeJsCss($site.'assets/plugins/managermanager/js/jquery-ui-1.10.3.min.js', 'html', 'jquery-ui', '1.10.3');
ddTools::extendLanguage($widgetPath);
$usedLangKeys = array("insert","edit","clean","confirm_delete_record","batch_filling","clone_row","raw_btn_tip","reset");
$usedLangKeys = array_combine($usedLangKeys, $usedLangKeys);
$usedLang = array_intersect_key($_lang,$usedLangKeys);

$output .= includeJsCss($site.'assets/plugins/managermanager/js/jquery-ui.min.js', 'html', 'jquery-ui', '1.12.1');
$output .= includeJsCss($widgetDir.'ddmultiplefields.css', 'html');
$output .= includeJsCss($widgetDir.'jquery.ddMM.mm_ddMultipleFields.js', 'html', 'jquery.ddMM.mm_ddMultipleFields', '1.1.1');

$output .= includeJsCss('$j.ddMM.lang.edit = "'.$_lang['edit'].'";', 'html', 'mm_ddMultipleFields_plain', '1', true, 'js');
$output .= includeJsCss('$j.ddMM.lang = '.json_encode($usedLang).';', 'html', 'mm_ddMultipleFields_plain', '1', true, 'js');

$e->output($output);
}else if ($e->name == 'OnDocFormRender'){
global $mm_current_page;
Expand All @@ -59,16 +72,17 @@ function mm_ddMultipleFields($tvs = '', $roles = '', $templates = '', $columns =
$columnsData = array();

foreach ($columnsDataTemp as $value){
//Евалим знение и записываем результат или исходное значени
$eval = @eval($value);
$columnsData[] = $eval ? addslashes(json_encode($eval)) : addslashes($value);
//Проверяем значение и записываем результат или исходное значени
$columnsData[] = addslashes(!isJson($value) ? json_encode($value) : $value);
}
//Сливаем в строку, что бы передать на клиент
$columnsData = implode('||', $columnsData);
}

//Стиль превью изображения
$stylePrewiew = "max-width:{$imgW}px; max-height:{$imgH}px; margin: 4px 0; cursor: pointer;";
$imgW = $imgW.(is_numeric($imgW)?"px":"");
$imgH = $imgH.(is_numeric($imgH)?"px":"");
$stylePrewiew = "max-width:{$imgW}; max-height:{$imgH}; margin: 4px 0; cursor: pointer;";

$tvsMas = tplUseTvs($mm_current_page['template'], $tvs, 'image,file,text,email,textarea', 'id,type');
if ($tvsMas == false){return;}
Expand Down Expand Up @@ -100,7 +114,8 @@ function mm_ddMultipleFields($tvs = '', $roles = '', $templates = '', $columns =
colWidth: "'.$colWidth.'",
imageStyle: "'.$stylePrewiew.'",
minRow: "'.$minRow.'",
maxRow: "'.$maxRow.'"
maxRow: "'.$maxRow.'",
options: '.$options.'
});
';
}
Expand Down
Loading