| @@ -1,15 +1,18 @@ | ||
| 1 | -<?php echo $data['warnings']; ?> | |
| 2 | -<form id="acym_form" enctype="multipart/form-data" action="<?php echo acym_completeLink(acym_getVar('cmd', 'ctrl')); ?>" method="post" name="acyForm"> | |
| 1 | +<?php | |
| 2 | +// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound -- View file, its variables are local to the include scope, not true globals. | |
| 3 | +defined('ABSPATH') || die('Restricted Access'); | |
| 4 | +?> | |
| 5 | +<?php echo wp_kses($data['warnings'], ['div' => ['class' => true], 'i' => ['class' => true, 'data-id' => true]]); ?> | |
| 6 | +<form id="acym_form" enctype="multipart/form-data" action="<?php echo esc_url(acym_completeLink(acym_getVar('cmd', 'ctrl'))); ?>" method="post" name="acyForm"> | |
| 3 | 7 | <div id="acym__file__select"> |
| 4 | 8 | <div class="acym__file__select grid-x"> |
| 5 | 9 | <div class="acym__file__select__area cell grid-x"> |
| 6 | 10 | <?php |
| 7 | - $fileTreeType = $data['fileTreeType']; | |
| 8 | - echo $fileTreeType->display($data['folders'], $data['uploadFolder'], 'currentFolder'); | |
| 11 | + $data['fileTreeType']->display($data['folders'], $data['uploadFolder'], 'currentFolder'); | |
| 9 | 12 | |
| 10 | 13 | if (empty($data['files'])) { |
| 11 | - echo acym_translation('ACYM_NO_FILE_HERE'); | |
| 14 | + echo esc_html(acym_translation('ACYM_NO_FILE_HERE')); | |
| 12 | 15 | } else { |
| 13 | 16 | $preparedFiles = []; |
| 14 | 17 | foreach ($data['files'] as $k => $file) { |
| 15 | 18 | $ext = strtolower(substr($file, strrpos($file, '.') + 1)); |
| @@ -23,24 +26,19 @@ | ||
| 23 | 26 | } else { |
| 24 | 27 | $srcImg = ACYM_LIVE.str_replace(DS, '/', ACYM_MEDIA_FOLDER).'images/icons/file.png'; |
| 25 | 28 | } |
| 26 | 29 | |
| 27 | - if (strlen($file) > 20) { | |
| 28 | - $title = '<span class="cell acym__file__select__title" title="'.acym_escape($file).'">'.substr(rtrim($file, $ext), 0, 12).'...'.$ext.'</span>'; | |
| 29 | - } else { | |
| 30 | - $title = '<span class="cell acym__file__select__title">'.$file.'</span>'; | |
| 31 | - } | |
| 32 | - | |
| 33 | 30 | $selected = $data['selectedFile'] === $file ? 'acym_clickme' : ''; |
| 34 | 31 | |
| 35 | 32 | $preparedFiles[] = [ |
| 36 | - 'title' => $title, | |
| 37 | 33 | 'image' => $srcImg, |
| 38 | 34 | 'file' => $file, |
| 35 | + 'ext' => $ext, | |
| 39 | 36 | 'selected' => $selected, |
| 40 | 37 | ]; |
| 41 | 38 | } |
| 42 | 39 | |
| 40 | + // Switch between grid and list views button | |
| 43 | 41 | ?> |
| 44 | 42 | <div id="acym__file__select__area__switch" class="cell medium-1 grid-x align-right"> |
| 45 | 43 | <button type="button" id="acym__file__select__area__switch__grid" class="is-hidden"><i class="acymicon-th"></i></button> |
| 46 | 44 | <button type="button" id="acym__file__select__area__switch__list"><i class="acymicon-menu"></i></button> |
| @@ -45,17 +43,27 @@ | ||
| 45 | 43 | <button type="button" id="acym__file__select__area__switch__grid" class="is-hidden"><i class="acymicon-th"></i></button> |
| 46 | 44 | <button type="button" id="acym__file__select__area__switch__list"><i class="acymicon-menu"></i></button> |
| 47 | 45 | </div> |
| 48 | 46 | <?php |
| 49 | - | |
| 47 | + // Display the grid view | |
| 50 | 48 | echo '<div id="acym__file__select__area__grid" class="margin-top-1 cell grid-x large-up-4 medium-up-3 small-up-2 grid-margin-x align-center">'; |
| 51 | 49 | foreach ($preparedFiles as $oneFile) { |
| 52 | 50 | ?> |
| 53 | 51 | <div class="cell acym__file__select__onepic text-center"> |
| 54 | - <a href="#" class="acym__file__select__add grid-x <?php echo $oneFile['selected']; ?>" mapdata="<?php echo acym_escape($oneFile['file']); ?>"> | |
| 55 | - <?php echo $oneFile['title']; ?> | |
| 52 | + <a href="#" | |
| 53 | + class="acym__file__select__add grid-x <?php echo esc_attr($oneFile['selected']); ?>" | |
| 54 | + mapdata="<?php echo esc_attr($oneFile['file']); ?>"> | |
| 55 | + <?php | |
| 56 | + if (strlen($oneFile['file']) > 20) { | |
| 57 | + echo '<span class="cell acym__file__select__title" title="'.esc_attr($oneFile['file']).'">'; | |
| 58 | + echo esc_html(substr(rtrim($oneFile['file'], $oneFile['ext']), 0, 12).'...'.$oneFile['ext']); | |
| 59 | + echo '</span>'; | |
| 60 | + } else { | |
| 61 | + echo '<span class="cell acym__file__select__title">'.esc_html($oneFile['file']).'</span>'; | |
| 62 | + } | |
| 63 | + ?> | |
| 56 | 64 | <div class="cell"> |
| 57 | - <img src="<?php echo acym_escape($oneFile['image']); ?>" alt="" /> | |
| 65 | + <img src="<?php echo esc_attr($oneFile['image']); ?>" alt="" /> | |
| 58 | 66 | </div> |
| 59 | 67 | </a> |
| 60 | 68 | </div> |
| 61 | 69 | <?php |
| @@ -61,13 +69,14 @@ | ||
| 61 | 69 | <?php |
| 62 | 70 | } |
| 63 | 71 | echo '</div>'; |
| 64 | 72 | |
| 73 | + // Display the list view | |
| 65 | 74 | echo '<div id="acym__file__select__area__list" class="margin-top-1 is-hidden cell grid-x">'; |
| 66 | 75 | foreach ($preparedFiles as $oneFile) { |
| 67 | 76 | ?> |
| 68 | - <a href="#" class="acym__file__select__add cell grid-x" mapdata="<?php echo acym_escape($oneFile['file']); ?>"> | |
| 69 | - <?php echo $oneFile['file']; ?> | |
| 77 | + <a href="#" class="acym__file__select__add cell grid-x" mapdata="<?php echo esc_attr($oneFile['file']); ?>"> | |
| 78 | + <?php echo esc_html($oneFile['file']); ?> | |
| 70 | 79 | </a> |
| 71 | 80 | <?php |
| 72 | 81 | } |
| 73 | 82 | echo '</div>'; |
| @@ -72,19 +81,19 @@ | ||
| 72 | 81 | } |
| 73 | 82 | echo '</div>'; |
| 74 | 83 | } |
| 75 | 84 | ?> |
| 76 | - <input type="hidden" id="acym__file__select__mapid" value="<?php echo acym_escape($data['map']); ?>"> | |
| 85 | + <input type="hidden" id="acym__file__select__mapid" value="<?php echo esc_attr($data['map']); ?>"> | |
| 77 | 86 | </div> |
| 78 | 87 | <div class="acym__file__select__area cell grid-x text-center"> |
| 79 | - <?php echo acym_inputFile('uploadedFile', '', '', 'cell medium-shrink'); ?> | |
| 80 | - <input type="hidden" name="currentFolder" value="<?php echo acym_escape($data['uploadFolder']); ?>" /> | |
| 81 | - <input type="hidden" name="id" value="<?php echo acym_escape($data['map']); ?>" /> | |
| 88 | + <?php acym_inputFile('uploadedFile', '', 'cell medium-shrink'); ?> | |
| 89 | + <input type="hidden" name="currentFolder" value="<?php echo esc_attr($data['uploadFolder']); ?>" /> | |
| 90 | + <input type="hidden" name="id" value="<?php echo esc_attr($data['map']); ?>" /> | |
| 82 | 91 | <div class="cell medium-auto hide-for-small-only"></div> |
| 83 | 92 | <button type="button" |
| 84 | - class="cell medium-shrink button button-secondary acy_button_submit" | |
| 85 | - type="submit" | |
| 86 | - data-task="select"> <?php echo acym_translation('ACYM_IMPORT'); ?> </button> | |
| 93 | + class="cell medium-shrink button button-secondary acy_button_submit" | |
| 94 | + type="submit" | |
| 95 | + data-task="select"> <?php echo esc_html(acym_translation('ACYM_IMPORT')); ?> </button> | |
| 87 | 96 | </div> |
| 88 | 97 | </div> |
| 89 | 98 | </div> |
| 90 | 99 | <?php acym_formOptions(); ?> |