| 1 |
<?php |
| 2 |
/** |
| 3 |
* @package VikBooking |
| 4 |
* @subpackage com_vikbooking |
| 5 |
* @author Alessio Gaggii - E4J srl |
| 6 |
* @copyright Copyright (C) 2023 E4J srl. All rights reserved. |
| 7 |
* @license GNU General Public License version 2 or later; see LICENSE |
| 8 |
* @link https://vikwp.com |
| 9 |
*/ |
| 10 |
|
| 11 |
// No direct access |
| 12 |
defined('ABSPATH') or die('No script kiddies please!'); |
| 13 |
|
| 14 |
$app = JFactory::getApplication(); |
| 15 |
$vik = VikApplication::getInstance(); |
| 16 |
|
| 17 |
$dt_format = $app->get('date_format') . ' ' . $app->get('time_format'); |
| 18 |
|
| 19 |
/** |
| 20 |
* Attempt to register the visited menu page. |
| 21 |
* |
| 22 |
* @since 1.6.0 |
| 23 |
*/ |
| 24 |
$menu_action = [ |
| 25 |
'name' => __('Shortcodes', 'vikbooking'), |
| 26 |
'href' => 'admin.php?option=com_vikbooking&view=shortcodes', |
| 27 |
]; |
| 28 |
|
| 29 |
$action_obj = json_encode($menu_action); |
| 30 |
|
| 31 |
JFactory::getDocument()->addScriptDeclaration( |
| 32 |
<<<JS |
| 33 |
;(function($) { |
| 34 |
$(function() { |
| 35 |
try { |
| 36 |
VBOCore.registerAdminMenuAction($action_obj, 'global'); |
| 37 |
} catch(e) { |
| 38 |
console.error(e); |
| 39 |
} |
| 40 |
}); |
| 41 |
})(jQuery); |
| 42 |
JS |
| 43 |
); |
| 44 |
|
| 45 |
?> |
| 46 |
|
| 47 |
<form action="admin.php?option=com_vikbooking" method="post" name="adminForm" id="adminForm"> |
| 48 |
|
| 49 |
<?php |
| 50 |
/** |
| 51 |
* Added filters to search the shortcodes by name, type and language. |
| 52 |
* |
| 53 |
* @since 1.1.5 |
| 54 |
*/ |
| 55 |
?> |
| 56 |
<div class="tablenav top"> |
| 57 |
|
| 58 |
<div class="alignleft actions"> |
| 59 |
<input type="search" id="post-search-input" name="filter_search" value="<?php echo $this->filters['search']; ?>" /> |
| 60 |
<button type="submit" id="search-submit" class="button"><?php echo JText::translate('JSEARCH_FILTER_SUBMIT'); ?></button> |
| 61 |
</div> |
| 62 |
|
| 63 |
<div class="alignright actions" style="padding-right:0;"> |
| 64 |
<!-- TYPE filter --> |
| 65 |
<select name="filter_type" id="vik-type-filter" onchange="document.adminForm.submit();"> |
| 66 |
<option value=""><?php echo JText::translate('JOPTION_SELECT_TYPE'); ?></option> |
| 67 |
<?php |
| 68 |
foreach ($this->views as $type => $title) |
| 69 |
{ |
| 70 |
?> |
| 71 |
<option value="<?php echo $type; ?>" <?php echo ($type == $this->filters['type'] ? 'selected="selected"' : ''); ?>><?php echo JText::translate($title); ?></option> |
| 72 |
<?php |
| 73 |
} |
| 74 |
?> |
| 75 |
</select> |
| 76 |
|
| 77 |
<!-- LANGUAGE filter --> |
| 78 |
<select name="filter_lang" id="vik-lang-filter" onchange="document.adminForm.submit();" style="margin-right: 0;"> |
| 79 |
<option value="*"><?php echo JText::translate('JOPTION_SELECT_LANGUAGE'); ?></option> |
| 80 |
<?php |
| 81 |
foreach (JLanguage::getKnownLanguages() as $tag => $lang) |
| 82 |
{ |
| 83 |
?> |
| 84 |
<option value="<?php echo $tag; ?>" <?php echo ($tag == $this->filters['lang'] ? 'selected="selected"' : ''); ?>><?php echo $lang['nativeName']; ?></option> |
| 85 |
<?php |
| 86 |
} |
| 87 |
?> |
| 88 |
</select> |
| 89 |
</div> |
| 90 |
|
| 91 |
</div> |
| 92 |
|
| 93 |
<?php if (count($this->shortcodes) == 0) { ?> |
| 94 |
|
| 95 |
<p class="warn"><?php echo JText::translate('NO_ROWS_FOUND'); ?></p> |
| 96 |
|
| 97 |
<?php } else { ?> |
| 98 |
|
| 99 |
<table cellpadding="4" cellspacing="0" border="0" width="100%" class="<?php echo $vik->getAdminTableClass(); ?>" style="margin-top:10px;"> |
| 100 |
|
| 101 |
<?php echo $vik->openTableHead(); ?> |
| 102 |
<tr> |
| 103 |
<td width="1%" class="manage-column column-cb check-column"> |
| 104 |
<?php echo $vik->getAdminToggle(count($this->shortcodes)); ?> |
| 105 |
</td> |
| 106 |
<th class="<?php echo $vik->getAdminThClass('left hidden-phone hidden-tablet'); ?>" width="3%" style="text-align: left;"><?php echo JText::translate('JID'); ?></th> |
| 107 |
<th class="<?php echo $vik->getAdminThClass('left'); ?>" width="25%" style="text-align: left;"><?php echo JText::translate('JNAME'); ?></th> |
| 108 |
<th class="<?php echo $vik->getAdminThClass('left hidden-phone'); ?>" width="15%" style="text-align: left;"><?php echo JText::translate('JTYPE'); ?></th> |
| 109 |
<th class="<?php echo $vik->getAdminThClass(); ?>" width="10%" style="text-align: center;"><?php echo JText::translate('JSHORTCODE'); ?></th> |
| 110 |
<th class="<?php echo $vik->getAdminThClass(); ?>" width="25%" style="text-align: center;"><?php echo JText::translate('JPOST'); ?></th> |
| 111 |
<th class="<?php echo $vik->getAdminThClass('hidden-phone hidden-tablet'); ?>" width="10%" style="text-align: center;"><?php echo JText::translate('JCREATEDBY'); ?></th> |
| 112 |
<th class="<?php echo $vik->getAdminThClass('hidden-phone'); ?>" width="11%" style="text-align: center;"><?php echo JText::translate('JCREATEDON'); ?></th> |
| 113 |
</tr> |
| 114 |
<?php echo $vik->closeTableHead(); ?> |
| 115 |
|
| 116 |
<?php |
| 117 |
foreach ($this->shortcodes as $i => $row) |
| 118 |
{ |
| 119 |
?> |
| 120 |
<tr class="row"> |
| 121 |
<td><input type="checkbox" id="cb<?php echo $i;?>" name="cid[]" value="<?php echo $row->id; ?>" onClick="<?php echo $vik->checkboxOnClick(); ?>"></td> |
| 122 |
|
| 123 |
<td class="hidden-phone hidden-tablet"><?php echo $row->id; ?></td> |
| 124 |
|
| 125 |
<td> |
| 126 |
<?php |
| 127 |
if ($row->parent_id) |
| 128 |
{ |
| 129 |
echo str_repeat('— ', count($row->ancestors)); |
| 130 |
} |
| 131 |
?> |
| 132 |
|
| 133 |
<a href="javascript: void(0);" onclick="jQuery('#cb<?php echo $i; ?>').prop('checked', true);Joomla.submitbutton('shortcodes.edit');"> |
| 134 |
<?php echo $row->name; ?> |
| 135 |
</a> |
| 136 |
</td> |
| 137 |
|
| 138 |
<td class="hidden-phone"><?php echo JText::translate($row->title); ?></td> |
| 139 |
|
| 140 |
<td style="text-align: center;"> |
| 141 |
<span class="vbo-shortcode-icn-wrap"> |
| 142 |
<?php echo $vik->createPopover(array( |
| 143 |
'title' => JText::translate('JSHORTCODE'), |
| 144 |
'content' => '<textarea style="width:250px;height:200px;" onclick="this.select();">' . $row->shortcode . '</textarea>', |
| 145 |
'icon' => 'qrcode', |
| 146 |
'trigger' => 'click', |
| 147 |
)); ?> |
| 148 |
</span> |
| 149 |
</td> |
| 150 |
|
| 151 |
<td style="text-align: center;"> |
| 152 |
<?php if ($row->post_id) { ?> |
| 153 |
|
| 154 |
<a href="<?php echo get_permalink($row->post_id); ?>" target="_blank" data-postid="<?php echo $row->post_id; ?>" class="btn btn-primary vbo-link-btn-small"> |
| 155 |
<?php echo JText::translate('VBO_SC_VIEWFRONT'); ?> <i class="<?php echo VikBookingIcons::i('external-link-square'); ?>"></i> |
| 156 |
</a> |
| 157 |
|
| 158 |
<?php } else if ($row->tmp_post_id) { |
| 159 |
|
| 160 |
$post = get_post($row->tmp_post_id); |
| 161 |
|
| 162 |
?> |
| 163 |
|
| 164 |
<a href="edit.php?post_status=trash&post_type=<?php echo $post->post_type; ?>" target="_blank" class="btn vbo-link-btn-small"> |
| 165 |
<?php echo JText::translate('VBO_SC_VIEWTRASHPOSTS'); ?> <i class="<?php echo VikBookingIcons::i('external-link-square'); ?>" style="color: #900;"></i> |
| 166 |
</a> |
| 167 |
|
| 168 |
<?php } else { ?> |
| 169 |
|
| 170 |
<a href="index.php?option=com_vikbooking&task=shortcode.add_to_page&cid[]=<?php echo $row->id; ?>&return=<?php echo $this->returnLink; ?>" class="btn btn-danger vbo-link-btn-small" onclick="return confirm('<?php echo $this->escape(JText::translate('VBO_SC_ADDTOPAGE_HELP')); ?>');"> |
| 171 |
<?php echo JText::translate('VBO_SC_ADDTOPAGE'); ?> <i class="<?php echo VikBookingIcons::i('plus-square'); ?>"></i> |
| 172 |
</a> |
| 173 |
|
| 174 |
<?php } ?> |
| 175 |
</td> |
| 176 |
|
| 177 |
<td class="hidden-phone hidden-tablet" style="text-align: center;"><?php echo JUser::getInstance($row->createdby)->username; ?></td> |
| 178 |
|
| 179 |
<td class="hidden-phone" style="text-align: center;"><?php echo JHtml::fetch('date', $row->createdon, $dt_format); ?></td> |
| 180 |
</tr> |
| 181 |
<?php } ?> |
| 182 |
|
| 183 |
</table> |
| 184 |
|
| 185 |
<?php } ?> |
| 186 |
|
| 187 |
<input type="hidden" name="option" value="com_vikbooking" /> |
| 188 |
<input type="hidden" name="view" value="shortcodes" /> |
| 189 |
<input type="hidden" name="task" value="" /> |
| 190 |
<input type="hidden" name="return" value="<?php echo $this->returnLink; ?>" /> |
| 191 |
<?php echo $this->navbut; ?> |
| 192 |
|
| 193 |
</form> |
| 194 |
|