default.php
272 lines
| 1 | <?php |
| 2 | /** |
| 3 | * @package VikAppointments |
| 4 | * @subpackage core |
| 5 | * @author E4J s.r.l. |
| 6 | * @copyright Copyright (C) 2021 E4J s.r.l. All Rights Reserved. |
| 7 | * @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL |
| 8 | * @link https://vikwp.com |
| 9 | */ |
| 10 | |
| 11 | // No direct access |
| 12 | defined('ABSPATH') or die('No script kiddies please!'); |
| 13 | |
| 14 | JHtml::fetch('vaphtml.assets.fontawesome'); |
| 15 | |
| 16 | $rows = $this->rows; |
| 17 | |
| 18 | $filters = $this->filters; |
| 19 | |
| 20 | $vik = VAPApplication::getInstance(); |
| 21 | |
| 22 | $is_searching = $this->hasFilters(); |
| 23 | |
| 24 | /** |
| 25 | * Trigger event to display custom HTML. |
| 26 | * In case it is needed to include any additional fields, |
| 27 | * it is possible to create a plugin and attach it to an event |
| 28 | * called "onDisplayViewApipluginsList". The event method receives the |
| 29 | * view instance as argument. |
| 30 | * |
| 31 | * @since 1.7 |
| 32 | */ |
| 33 | $forms = $this->onDisplayListView($is_searching); |
| 34 | |
| 35 | ?> |
| 36 | |
| 37 | <form action="index.php?option=com_vikappointments" method="post" name="adminForm" id="adminForm"> |
| 38 | |
| 39 | <div class="btn-toolbar vapgroup-keyfilter-block" id="filter-bar"> |
| 40 | |
| 41 | <div class="btn-group pull-left input-append"> |
| 42 | <input type="text" name="keysearch" id="vapkeysearch" class="vapkeysearch" size="32" |
| 43 | value="<?php echo $this->escape($filters['keysearch']); ?>" placeholder="<?php echo $this->escape(JText::translate('JSEARCH_FILTER_SUBMIT')); ?>" /> |
| 44 | |
| 45 | <button type="submit" class="btn"> |
| 46 | <i class="fas fa-search"></i> |
| 47 | </button> |
| 48 | </div> |
| 49 | |
| 50 | <!-- Define role to detect the supported hook --> |
| 51 | <!-- {"rule":"customizer","event":"onDisplayViewApipluginsList","type":"search","key":"search"} --> |
| 52 | |
| 53 | <?php |
| 54 | // plugins can use the "search" key to introduce custom |
| 55 | // filters within the search bar |
| 56 | if (isset($forms['search'])) |
| 57 | { |
| 58 | echo $forms['search']; |
| 59 | } |
| 60 | |
| 61 | // in case a plugin needs to use the filter bar, display the button |
| 62 | if (isset($forms['filters'])) |
| 63 | { |
| 64 | ?> |
| 65 | <div class="btn-group pull-left"> |
| 66 | <button type="button" class="btn <?php echo ($is_searching ? 'btn-primary' : ''); ?>" onclick="vapToggleSearchToolsButton(this);"> |
| 67 | <?php echo JText::translate('JSEARCH_TOOLS'); ?> <i class="fas fa-caret-<?php echo ($is_searching ? 'up' : 'down'); ?>" id="vap-tools-caret"></i> |
| 68 | </button> |
| 69 | </div> |
| 70 | <?php |
| 71 | } |
| 72 | ?> |
| 73 | |
| 74 | <div class="btn-group pull-left"> |
| 75 | <button type="button" class="btn" onclick="clearFilters();"> |
| 76 | <?php echo JText::translate('JSEARCH_FILTER_CLEAR'); ?> |
| 77 | </button> |
| 78 | </div> |
| 79 | |
| 80 | </div> |
| 81 | |
| 82 | <div class="btn-toolbar" id="vap-search-tools" style="height: 32px;<?php echo ($is_searching ? '' : 'display: none;'); ?>"> |
| 83 | |
| 84 | <!-- Define role to detect the supported hook --> |
| 85 | <!-- {"rule":"customizer","event":"onDisplayViewApipluginsList","type":"search","key":"filters"} --> |
| 86 | |
| 87 | <?php |
| 88 | // plugins can use the "filters" key to introduce custom |
| 89 | // filters within the search bar |
| 90 | if (isset($forms['filters'])) |
| 91 | { |
| 92 | echo $forms['filters']; |
| 93 | } |
| 94 | ?> |
| 95 | |
| 96 | </div> |
| 97 | |
| 98 | <?php |
| 99 | if (count($rows) == 0) |
| 100 | { |
| 101 | echo $vik->alert(JText::translate('JGLOBAL_NO_MATCHING_RESULTS')); |
| 102 | } |
| 103 | else |
| 104 | { |
| 105 | /** |
| 106 | * Trigger event to display custom columns. |
| 107 | * |
| 108 | * @since 1.7 |
| 109 | */ |
| 110 | $columns = $this->onDisplayTableColumns(); |
| 111 | ?> |
| 112 | |
| 113 | <!-- Define role to detect the supported hook --> |
| 114 | <!-- {"rule":"customizer","event":"onDisplayApipluginsTableTH","type":"th"} --> |
| 115 | |
| 116 | <!-- Define role to detect the supported hook --> |
| 117 | <!-- {"rule":"customizer","event":"onDisplayApipluginsTableTD","type":"td"} --> |
| 118 | |
| 119 | <table cellpadding="4" cellspacing="0" border="0" width="100%" class="<?php echo $vik->getAdminTableClass(); ?>"> |
| 120 | |
| 121 | <?php echo $vik->openTableHead(); ?> |
| 122 | <tr> |
| 123 | |
| 124 | <th width="1%"> |
| 125 | <?php echo $vik->getAdminToggle(count($rows)); ?> |
| 126 | </th> |
| 127 | |
| 128 | <!-- NAME --> |
| 129 | |
| 130 | <th class="<?php echo $vik->getAdminThClass('left'); ?>" width="10%" style="text-align: left;"> |
| 131 | <?php echo JText::translate('VAPMANAGEGROUP2'); ?> |
| 132 | </th> |
| 133 | |
| 134 | <!-- FILE --> |
| 135 | |
| 136 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="10%" style="text-align: left;"> |
| 137 | <?php echo JText::translate('VAPMANAGECUSTMAIL5'); ?> |
| 138 | </th> |
| 139 | |
| 140 | <!-- DESCRIPTION --> |
| 141 | |
| 142 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="35%" style="text-align: left;"> |
| 143 | <?php echo JText::translate('VAPMANAGEGROUP3'); ?> |
| 144 | </th> |
| 145 | |
| 146 | <!-- CUSTOM --> |
| 147 | |
| 148 | <?php |
| 149 | foreach ($columns as $k => $col) |
| 150 | { |
| 151 | ?> |
| 152 | <th data-id="<?php echo $this->escape($k); ?>" class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>"> |
| 153 | <?php echo $col->th; ?> |
| 154 | </th> |
| 155 | <?php |
| 156 | } |
| 157 | ?> |
| 158 | |
| 159 | <!-- DETAILS --> |
| 160 | |
| 161 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="2%" style="text-align: center;"> </th> |
| 162 | |
| 163 | </tr> |
| 164 | <?php echo $vik->closeTableHead(); ?> |
| 165 | |
| 166 | <?php |
| 167 | $kk = 0; |
| 168 | for ($i = 0; $i < count($rows); $i++) |
| 169 | { |
| 170 | $row = $rows[$i]; |
| 171 | |
| 172 | // get plugin description |
| 173 | $short_desc = $desc = $row->getDescription(); |
| 174 | |
| 175 | if ($short_desc) |
| 176 | { |
| 177 | // split description line by line |
| 178 | $chunks = preg_split("/(\R|<br\s*\/\s*>)/", $short_desc); |
| 179 | // remove empty lines |
| 180 | $chunks = array_filter($chunks); |
| 181 | // use only the first paragraph |
| 182 | $short_desc = strip_tags(array_shift($chunks)); |
| 183 | } |
| 184 | ?> |
| 185 | <tr class="row<?php echo $kk; ?>"> |
| 186 | |
| 187 | <td> |
| 188 | <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $this->escape($row->getName()); ?>" onClick="<?php echo $vik->checkboxOnClick(); ?>"> |
| 189 | </td> |
| 190 | |
| 191 | <!-- NAME --> |
| 192 | |
| 193 | <td> |
| 194 | <div class="td-primary"><?php echo $row->getTitle(); ?></div> |
| 195 | </td> |
| 196 | |
| 197 | <!-- FILE --> |
| 198 | |
| 199 | <td class="hidden-phone"> |
| 200 | <?php echo $row->getName() . '.php'; ?> |
| 201 | </td> |
| 202 | |
| 203 | <!-- DESCRIPTION --> |
| 204 | |
| 205 | <td class="hidden-phone"> |
| 206 | <?php echo $short_desc; ?> |
| 207 | </td> |
| 208 | |
| 209 | <!-- CUSTOM --> |
| 210 | |
| 211 | <?php |
| 212 | foreach ($columns as $k => $col) |
| 213 | { |
| 214 | ?> |
| 215 | <td data-id="<?php echo $this->escape($k); ?>" class="hidden-phone"> |
| 216 | <?php echo isset($col->td[$i]) ? $col->td[$i] : ''; ?> |
| 217 | </td> |
| 218 | <?php |
| 219 | } |
| 220 | ?> |
| 221 | |
| 222 | <!-- DETAILS --> |
| 223 | |
| 224 | <td style="text-align: center;"> |
| 225 | <?php |
| 226 | if ($desc) |
| 227 | { |
| 228 | ?> |
| 229 | <a href="index.php?option=com_vikappointments&task=apiplugin.edit&cid[]=<?php echo $row->getName(); ?>" > |
| 230 | <i class="fas fa-sticky-note big"></i> |
| 231 | </a> |
| 232 | <?php |
| 233 | } |
| 234 | else |
| 235 | { |
| 236 | ?> |
| 237 | <a href="javascript:void(0)" class="disabled" disabled="disabled"> |
| 238 | <i class="fas fa-sticky-note big"></i> |
| 239 | </a> |
| 240 | <?php |
| 241 | } |
| 242 | ?> |
| 243 | </td> |
| 244 | |
| 245 | </tr> |
| 246 | <?php |
| 247 | $kk = 1 - $kk; |
| 248 | } |
| 249 | ?> |
| 250 | </table> |
| 251 | <?php |
| 252 | } |
| 253 | ?> |
| 254 | |
| 255 | <input type="hidden" name="boxchecked" value="0" /> |
| 256 | <input type="hidden" name="task" value="" /> |
| 257 | <input type="hidden" name="view" value="apiplugins" /> |
| 258 | |
| 259 | <?php echo JHtml::fetch('form.token'); ?> |
| 260 | <?php echo $this->navbut; ?> |
| 261 | </form> |
| 262 | |
| 263 | <script> |
| 264 | |
| 265 | function clearFilters() { |
| 266 | jQuery('#vapkeysearch').val(''); |
| 267 | |
| 268 | document.adminForm.submit(); |
| 269 | } |
| 270 | |
| 271 | </script> |
| 272 |