PHP Classes

the delete function is not implemented

Recommend this page to a friend!

      PHP SQLite Code Vault  >  PHP SQLite Code Vault package blog  >  How to Organize Your ...  >  All threads  >  the delete function is not implemented  >  (Un) Subscribe thread alerts  
Subject:the delete function is not implemented
Summary:bugs and improvements
Messages:7
Author:adilbo
Date:2023-05-04 13:20:36
 

  1. the delete function is not implemented   Reply   Report abuse  
Picture of adilbo adilbo - 2023-05-04 13:20:36
the UI is ugly, maybe use:
dohliam.github.io/dropin-minimal-cs ...

and textarea { height: 400px; }

also

// If the form is submitted to delete a snippet
if (isset($_GET['delete'])) {
// Get the datain the database
$snippets->deleteSnippet($_GET['delete']);
}

and

<a href='admin.php?delete=" . $snippet_row['id'] . "' onclick=\"return confirm('Are you sure?');\">&#10060;</a>


But main problem is that $_POST['code'] will break the page if it include the wrong content ;-)

But all in all a nice little tool that needs improvment!


  2. Re: the delete function is not implemented   Reply   Report abuse  
Picture of JImmy Bo JImmy Bo - 2023-05-04 15:15:04 - In reply to message 1 from adilbo
thanks for the response. I've made some changes to comment out some filters that were causing some issues with the snippet storage, also fixed up the display and delete button on the example so certain tags in snippets weren't breaking things too much. I agree the UI is really basic and intend to give it a bit of a ui boost here when i get a minute.

  3. Re: the delete function is not implemented   Reply   Report abuse  
Picture of adilbo adilbo - 2023-05-08 07:43:09 - In reply to message 2 from JImmy Bo
What do you think about changing:

<input type="text" name="search" placeholder="Search Snippets">


to


<input type="text" name="search" placeholder="Search <?php echo $snippets->getSnippetCount(); ?> Snippets">



;-)

  4. Re: the delete function is not implemented   Reply   Report abuse  
Picture of JImmy Bo JImmy Bo - 2023-05-09 04:38:55 - In reply to message 3 from adilbo
I threw the snippet count in a floating div fixed to the bottom of the page in the example. Also made some pretty big interface changes to eliminate some of the bulk and make it friendlier to edit. Thanks for the suggestions.

  5. Re: Improvements   Reply   Report abuse  
Picture of adilbo adilbo - 2023-05-09 05:57:30 - In reply to message 4 from JImmy Bo
Nice!

I would like to highlight the syntax, I use this in the header:

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/default.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/highlight.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.7.0/styles/stackoverflow-dark.min.css">

this line to show the code in the snippet:

$html .= "<pre><code class='code-snippet language-". strtolower($snippet_row['language']) ."'>" . $snippet_row['code'] . "</code></pre><textarea style='position:absolute;left:-9000px' id='".$snippet_row['id']."'>" . $snippet_row['code'] . "</textarea>";

and I also add a button to copy the code into the clipboard:

$html .= "<div><button class='copyBtn' onclick='copy_code(\"" . $snippet_row['id'] . "\")'>Copy</button></div>";

and this javascript at the end of the page:

hljs.highlightAll();function copy_code(id){var target=document.getElementById(id);target.focus();target.select();document.execCommand("copy");}

  6. Re: the delete function is not implemented   Reply   Report abuse  
Picture of JImmy Bo JImmy Bo - 2023-05-09 17:45:51 - In reply to message 5 from adilbo
added theme dropdown selection box to update the theme for the syntax highlighting for the displayed code in the listings. Now have a copy json to clipboard and copy code to clipboard buttons. A cookie also store last used theme. Possibly work on activating a dark theme as I think this one is so bright it burns my retinas. May implement syntax highlighting on update/add as well, but might possibly bring in codemirror for that. Probably next update will handle tab in textareas in update/add sections.

  7. Re: the delete function is not implemented   Reply   Report abuse  
Picture of JImmy Bo JImmy Bo - 2023-05-11 18:11:03 - In reply to message 5 from adilbo
I decided to ditch codemirror as I was having too many issues integrating, so instead switched to ace code editor for the update code section. Let me know what you think. If you want to keep yours, you should be able to simply remove the use_ace_edit class on the textarea in the edit section. I decided against highlight.js for that section as it wasn't feature rich enough I thought for code editing.