1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-04 12:17:42 +02:00

Snippets Plugin: view embed code feature added.

This commit is contained in:
Awilum
2012-11-17 19:25:24 +02:00
parent 1bad311aa5
commit 02f9f7f01a
3 changed files with 54 additions and 8 deletions

View File

@@ -0,0 +1,18 @@
if (typeof $.monstra == 'undefined') $.monstra = {};
$.monstra.snippets = {
init: function() { },
showEmbedCodes: function(name) {
$('#shortcode').html('{snippet get="'+name+'"}');
$('#phpcode').html('<?php echo Snippet::get("'+name+'"); ?>');
$('#embedCodes').modal();
}
};
$(document).ready(function(){
$.monstra.snippets.init();
});

View File

@@ -1,7 +1,11 @@
<?php
// Add plugin navigation link
Navigation::add(__('Snippets', 'snippets'), 'extends', 'snippets', 3);
// Add Plugin Javascript
Javascript::add('plugins/box/snippets/js/snippets.js', 'backend');
class SnippetsAdmin extends Backend {

View File

@@ -21,14 +21,38 @@
<tr>
<td><?php echo basename($snippet, '.snippet.php'); ?></td>
<td>
<div class="btn-toolbar">
<div class="btn-group">
<?php echo Html::anchor(__('Edit', 'snippets'), 'index.php?id=snippets&action=edit_snippet&filename='.basename($snippet, '.snippet.php'), array('class' => 'btn btn-actions')); ?>
<a class="btn dropdown-toggle btn-actions" data-toggle="dropdown" href="#" style="font-family:arial;"><span class="caret"></span></a>
<ul class="dropdown-menu">
<li><?php echo Html::anchor(__('View Embed Code', 'snippets'), 'javascript:;', array('title' => __('View Embed Code', 'snippets'), 'onclick' => '$.monstra.snippets.showEmbedCodes("'.basename($snippet, '.snippet.php').'");')); ?></li>
</ul>
<?php echo Html::anchor(__('Delete', 'snippets'),
'index.php?id=snippets&action=delete_snippet&filename='.basename($snippet, '.snippet.php').'&token='.Security::token(),
array('class' => 'btn btn-actions', 'onclick' => "return confirmDelete('".__('Delete snippet: :snippet', 'snippets', array(':snippet' => basename($snippet, '.snippet.php')))."')"));
?>
</div>
</div>
</td>
</tr>
<?php } ?>
</tbody>
</table>
<!-- /Snippets_list -->
<div id="embedCodes" class="modal hide fade">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h3><?php echo __('Embed Code', 'snippets'); ?></h3>
</div>
<div class="modal-body">
<p>
<b><?php echo __('Shortcode', 'snippets'); ?></b><br>
<code id="shortcode"></code>
<br> <br>
<b><?php echo __('PHP Code', 'snippets'); ?></b><br>
<code id="phpcode"></code>
</p>
</div>
</div>