default.php
340 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('bootstrap.tooltip'); |
| 15 | JHtml::fetch('formbehavior.chosen'); |
| 16 | |
| 17 | $app = JFactory::getApplication(); |
| 18 | $vik = VAPApplication::getInstance(); |
| 19 | |
| 20 | $dt_format = $app->get('date_format') . ' ' . $app->get('time_format'); |
| 21 | |
| 22 | $is_searching = $this->hasFilters(); |
| 23 | |
| 24 | ?> |
| 25 | |
| 26 | <form action="admin.php?page=vikappointments&view=shortcodes" method="post" name="adminForm" id="adminForm"> |
| 27 | |
| 28 | |
| 29 | <div class="btn-toolbar" style="height: 32px;"> |
| 30 | |
| 31 | <div class="btn-group pull-left input-append"> |
| 32 | <input type="search" name="filter_search" id="post-search-input" size="32" |
| 33 | value="<?php echo $this->escape($this->filters['search']); ?>" placeholder="<?php echo $this->escape(JText::translate('JSEARCH_FILTER_SUBMIT')); ?>" /> |
| 34 | |
| 35 | <button type="submit" class="btn"> |
| 36 | <i class="fas fa-search"></i> |
| 37 | </button> |
| 38 | </div> |
| 39 | |
| 40 | <div class="btn-group pull-left"> |
| 41 | <button type="button" class="btn <?php echo ($is_searching ? 'btn-primary' : ''); ?>" onclick="vapToggleSearchToolsButton(this);"> |
| 42 | <?php echo JText::translate('JSEARCH_TOOLS'); ?> <i class="fas fa-caret-<?php echo ($is_searching ? 'up' : 'down'); ?>" id="vap-tools-caret"></i> |
| 43 | </button> |
| 44 | </div> |
| 45 | |
| 46 | <div class="btn-group pull-left"> |
| 47 | <button type="button" class="btn" onclick="clearFilters();"> |
| 48 | <?php echo JText::translate('JSEARCH_FILTER_CLEAR'); ?> |
| 49 | </button> |
| 50 | </div> |
| 51 | |
| 52 | </div> |
| 53 | |
| 54 | <div class="btn-toolbar" id="vap-search-tools" style="height: 32px;<?php echo ($is_searching ? '' : 'display: none;'); ?>"> |
| 55 | |
| 56 | <!-- TYPE filter --> |
| 57 | <?php |
| 58 | $options = array( |
| 59 | JHtml::fetch('select.option', '', JText::translate('JOPTION_SELECT_TYPE')), |
| 60 | ); |
| 61 | |
| 62 | foreach ($this->views as $type => $title) |
| 63 | { |
| 64 | $options[] = JHtml::fetch('select.option', $type, JText::translate($title)); |
| 65 | } |
| 66 | ?> |
| 67 | <div class="btn-group pull-left"> |
| 68 | <select name="filter_type" id="vik-type-filter" class="<?php echo ($this->filters['type'] != -1 ? 'active' : ''); ?>" onchange="document.adminForm.submit();"> |
| 69 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $this->filters['type']); ?> |
| 70 | </select> |
| 71 | </div> |
| 72 | |
| 73 | <!-- LANGUAGE filter --> |
| 74 | <?php |
| 75 | $options = array( |
| 76 | JHtml::fetch('select.option', '*', JText::translate('JOPTION_SELECT_LANGUAGE')), |
| 77 | ); |
| 78 | |
| 79 | foreach (JLanguage::getKnownLanguages() as $tag => $lang) |
| 80 | { |
| 81 | $options[] = JHtml::fetch('select.option', $tag, $lang['nativeName']); |
| 82 | } |
| 83 | ?> |
| 84 | <div class="btn-group pull-left"> |
| 85 | <select name="filter_lang" id="vik-lang-filter" class="<?php echo ($this->filters['lang'] != '*' ? 'active' : ''); ?>" onchange="document.adminForm.submit();"> |
| 86 | <?php echo JHtml::fetch('select.options', $options, 'value', 'text', $this->filters['lang']); ?> |
| 87 | </select> |
| 88 | </div> |
| 89 | |
| 90 | </div> |
| 91 | |
| 92 | <?php |
| 93 | if (count($this->shortcodes) == 0) |
| 94 | { |
| 95 | echo $vik->alert(JText::translate('JGLOBAL_NO_MATCHING_RESULTS')); |
| 96 | } |
| 97 | else |
| 98 | { |
| 99 | ?> |
| 100 | <table cellpadding="4" cellspacing="0" border="0" width="100%" class="<?php echo $vik->getAdminTableClass(); ?>" style="margin-top:10px;"> |
| 101 | |
| 102 | <?php echo $vik->openTableHead(); ?> |
| 103 | <tr> |
| 104 | <td width="2%" class="manage-column column-cb check-column"> |
| 105 | <?php echo $vik->getAdminToggle(count($this->shortcodes)); ?> |
| 106 | </td> |
| 107 | |
| 108 | <!-- ID --> |
| 109 | |
| 110 | <th class="<?php echo $vik->getAdminThClass('left nowrap hidden-phone'); ?>" width="1%" style="text-align: left;"> |
| 111 | <?php echo JText::translate('JID'); ?> |
| 112 | </th> |
| 113 | |
| 114 | <!-- NAME --> |
| 115 | |
| 116 | <th class="<?php echo $vik->getAdminThClass('left'); ?>" width="20%" style="text-align: left;"> |
| 117 | <?php echo JText::translate('JNAME'); ?> |
| 118 | </th> |
| 119 | |
| 120 | <!-- TYPE --> |
| 121 | |
| 122 | <th class="<?php echo $vik->getAdminThClass('left'); ?>" width="15%" style="text-align: left;"> |
| 123 | <?php echo JText::translate('JTYPE'); ?> |
| 124 | </th> |
| 125 | |
| 126 | <!-- SHORTCODE --> |
| 127 | |
| 128 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="10%" style="text-align: center;"> |
| 129 | <?php echo JText::translate('JSHORTCODE'); ?> |
| 130 | </th> |
| 131 | |
| 132 | <!-- POST --> |
| 133 | |
| 134 | <th class="<?php echo $vik->getAdminThClass(); ?>" width="10%" style="text-align: center;"> |
| 135 | <?php echo JText::translate('JPOST'); ?> |
| 136 | </th> |
| 137 | |
| 138 | <!-- LANGUAGE --> |
| 139 | |
| 140 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="10%" style="text-align: center;"> |
| 141 | <?php echo JText::translate('JLANGUAGE'); ?> |
| 142 | </th> |
| 143 | |
| 144 | <!-- AUTHOR --> |
| 145 | |
| 146 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="15%" style="text-align: center;"> |
| 147 | <?php echo JText::translate('JCREATEDBY'); ?> |
| 148 | </th> |
| 149 | |
| 150 | <!-- CREATION DATE --> |
| 151 | |
| 152 | <th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="15%" style="text-align: center;"> |
| 153 | <?php echo JText::translate('JCREATEDON'); ?> |
| 154 | </th> |
| 155 | |
| 156 | </tr> |
| 157 | <?php echo $vik->closeTableHead(); ?> |
| 158 | |
| 159 | <?php |
| 160 | foreach ($this->shortcodes as $i => $row) |
| 161 | { |
| 162 | ?> |
| 163 | <tr class="row"> |
| 164 | |
| 165 | <td> |
| 166 | <input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onClick="<?php echo $vik->checkboxOnClick(); ?>"> |
| 167 | </td> |
| 168 | |
| 169 | <!-- ID --> |
| 170 | |
| 171 | <td class="hidden-phone"> |
| 172 | <?php echo $row->id; ?> |
| 173 | </td> |
| 174 | |
| 175 | <!-- NAME --> |
| 176 | |
| 177 | <td> |
| 178 | <div class="td-primary"> |
| 179 | <?php |
| 180 | if ($row->parent_id) |
| 181 | { |
| 182 | echo str_repeat('— ', count($row->ancestors)); |
| 183 | } |
| 184 | ?> |
| 185 | |
| 186 | <a href="javascript: void(0);" onclick="jQuery('#cb<?php echo $i; ?>').prop('checked', true);Joomla.submitbutton('shortcodes.edit');"> |
| 187 | <?php echo $row->name; ?> |
| 188 | </a> |
| 189 | </div> |
| 190 | </td> |
| 191 | |
| 192 | <!-- TITLE --> |
| 193 | |
| 194 | <td> |
| 195 | <?php echo JText::translate($row->title); ?> |
| 196 | </td> |
| 197 | |
| 198 | <!-- SHORTCODE --> |
| 199 | |
| 200 | <td style="text-align: center;"> |
| 201 | <?php |
| 202 | echo $vik->createPopover(array( |
| 203 | 'title' => JText::translate('JSHORTCODE'), |
| 204 | 'content' => '<textarea style="width:250px;height:200px;resize:none;" onclick="this.select();">' . $row->shortcode . '</textarea>', |
| 205 | 'icon' => 'qrcode', |
| 206 | 'trigger' => 'click', |
| 207 | )); |
| 208 | ?> |
| 209 | </td> |
| 210 | |
| 211 | <!-- POST --> |
| 212 | |
| 213 | <td style="text-align: center;"> |
| 214 | <?php |
| 215 | // display link to reach the page in the front-end |
| 216 | if ($row->post_id) |
| 217 | { |
| 218 | ?> |
| 219 | <a href="<?php echo get_permalink($row->post_id); ?>" target="_blank" class="hasTooltip" title="<?php echo $this->escape(JText::translate('VAP_SHORTCODE_VIEW_FRONT')); ?>"> |
| 220 | <i class="fas fa-external-link-square-alt" style="font-size: 18px;"></i> |
| 221 | </a> |
| 222 | <?php |
| 223 | } |
| 224 | // display trashed link to edit the post |
| 225 | else if ($row->tmp_post_id) |
| 226 | { |
| 227 | $post = get_post($row->tmp_post_id); |
| 228 | ?> |
| 229 | <a href="edit.php?post_status=trash&post_type=<?php echo $post->post_type; ?>" target="_blank" class="hasTooltip" title="<?php echo $this->escape(JText::translate('VAP_SHORTCODE_VIEW_TRASHED')); ?>"> |
| 230 | <i class="fas fa-external-link-square-alt" style="color: #900; font-size: 18px;"></i> |
| 231 | </a> |
| 232 | <?php |
| 233 | } |
| 234 | // display button to create a new post |
| 235 | else |
| 236 | { |
| 237 | ?> |
| 238 | <a href="javascript:void(0);" class="shortcode-add-post hasTooltip" title="<?php echo $this->escape(JText::translate('VAP_SHORTCODE_CREATE_PAGE')); ?>"> |
| 239 | <i class="fas fa-plus-square" style="font-size: 18px;"></i> |
| 240 | </a> |
| 241 | <?php |
| 242 | } |
| 243 | ?> |
| 244 | </td> |
| 245 | |
| 246 | <!-- LANGUAGE --> |
| 247 | |
| 248 | <td style="text-align: center;" class="hidden-phone"> |
| 249 | <?php |
| 250 | if ($row->lang == '*') |
| 251 | { |
| 252 | echo JText::translate('JALL'); |
| 253 | } |
| 254 | else |
| 255 | { |
| 256 | // explode langtag |
| 257 | $parts = preg_split('/[\-_]/', $row->lang); |
| 258 | $flag = strtolower(end($parts)) . '.png'; |
| 259 | |
| 260 | // do not display a flag that doesn't exist |
| 261 | if (is_file(VAPBASE . DIRECTORY_SEPARATOR . 'assets' . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'flags' . DIRECTORY_SEPARATOR . $flag)) |
| 262 | { |
| 263 | ?> |
| 264 | <img src="<?php echo VAPASSETS_URI . 'css/flags/' . $flag; ?>" /> |
| 265 | <?php |
| 266 | } |
| 267 | } |
| 268 | ?> |
| 269 | </td> |
| 270 | |
| 271 | <!-- AUTHOR --> |
| 272 | |
| 273 | <td style="text-align: center;" class="hidden-phone"> |
| 274 | <?php echo JUser::getInstance($row->createdby)->username; ?> |
| 275 | </td> |
| 276 | |
| 277 | <!-- CREATION DATE --> |
| 278 | |
| 279 | <td style="text-align: center;" class="hidden-phone"> |
| 280 | <?php echo JHtml::fetch('date', $row->createdon, $dt_format); ?> |
| 281 | </td> |
| 282 | |
| 283 | </tr> |
| 284 | <?php |
| 285 | } |
| 286 | ?> |
| 287 | </table> |
| 288 | <?php |
| 289 | } |
| 290 | ?> |
| 291 | |
| 292 | <input type="hidden" name="option" value="com_vikappointments" /> |
| 293 | <input type="hidden" name="view" value="shortcodes" /> |
| 294 | <input type="hidden" name="task" value="" /> |
| 295 | <input type="hidden" name="return" value="<?php echo $this->escape($this->returnLink); ?>" /> |
| 296 | <?php echo $this->navbut; ?> |
| 297 | |
| 298 | </form> |
| 299 | |
| 300 | <?php |
| 301 | JText::script('VAP_SHORTCODE_CREATE_PAGE_CONFIRM'); |
| 302 | ?> |
| 303 | |
| 304 | <script> |
| 305 | |
| 306 | (function($) { |
| 307 | 'use strict'; |
| 308 | |
| 309 | window['clearFilters'] = () => { |
| 310 | $('#post-search-input').val(''); |
| 311 | $('#vik-type-filter').updateChosen(''); |
| 312 | $('#vik-lang-filter').updateChosen('*'); |
| 313 | |
| 314 | document.adminForm.submit(); |
| 315 | } |
| 316 | |
| 317 | $(function() { |
| 318 | $('.shortcode-add-post').on('click', function() { |
| 319 | // ask for a confirmation |
| 320 | if (!confirm(Joomla.JText._('VAP_SHORTCODE_CREATE_PAGE_CONFIRM'))) { |
| 321 | // action denied |
| 322 | return false; |
| 323 | } |
| 324 | |
| 325 | // uncheck all checkboxes |
| 326 | $('input[name="cid[]"],thead input[type="checkbox"]').prop('checked', false); |
| 327 | |
| 328 | // get parent <tr> |
| 329 | var tr = $(this).closest('tr'); |
| 330 | // find checkbox and toggle it |
| 331 | tr.find('input[name="cid[]"]').prop('checked', true); |
| 332 | |
| 333 | // submit form |
| 334 | Joomla.submitform('shortcode.addpage'); |
| 335 | }); |
| 336 | }); |
| 337 | })(jQuery); |
| 338 | |
| 339 | </script> |
| 340 |