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 <?php
// Add plugin navigation link
Navigation::add(__('Snippets', 'snippets'), 'extends', 'snippets', 3); Navigation::add(__('Snippets', 'snippets'), 'extends', 'snippets', 3);
// Add Plugin Javascript
Javascript::add('plugins/box/snippets/js/snippets.js', 'backend');
class SnippetsAdmin extends Backend { class SnippetsAdmin extends Backend {

View File

@@ -1,7 +1,7 @@
<h2><?php echo __('Snippets', 'snippets'); ?></h2> <h2><?php echo __('Snippets', 'snippets'); ?></h2>
<br /> <br />
<?php if(Notification::get('success')) Alert::success(Notification::get('success')); ?> <?php if (Notification::get('success')) Alert::success(Notification::get('success')); ?>
<?php <?php
echo ( echo (
@@ -20,15 +20,39 @@
<?php if (count($snippets_list) != 0) foreach ($snippets_list as $snippet) { ?> <?php if (count($snippets_list) != 0) foreach ($snippets_list as $snippet) { ?>
<tr> <tr>
<td><?php echo basename($snippet, '.snippet.php'); ?></td> <td><?php echo basename($snippet, '.snippet.php'); ?></td>
<td> <td>
<?php echo Html::anchor(__('Edit', 'snippets'), 'index.php?id=snippets&action=edit_snippet&filename='.basename($snippet, '.snippet.php'), array('class' => 'btn btn-actions')); ?> <div class="btn-toolbar">
<?php echo Html::anchor(__('Delete', 'snippets'), <div class="btn-group">
'index.php?id=snippets&action=delete_snippet&filename='.basename($snippet, '.snippet.php').'&token='.Security::token(), <?php echo Html::anchor(__('Edit', 'snippets'), 'index.php?id=snippets&action=edit_snippet&filename='.basename($snippet, '.snippet.php'), array('class' => 'btn btn-actions')); ?>
array('class' => 'btn btn-actions', 'onclick' => "return confirmDelete('".__('Delete snippet: :snippet', 'snippets', array(':snippet' => basename($snippet, '.snippet.php')))."')")); <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> </td>
</tr> </tr>
<?php } ?> <?php } ?>
</tbody> </tbody>
</table> </table>
<!-- /Snippets_list --> <!-- /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>