gingerbeardman

mollify file editor v2

Jul 6th, 2011
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.27 KB | None | 0 0
  1. <?php
  2.     class EditFileViewer extends FullDocumentViewer {
  3.         protected function getHtml($item, $full) {
  4.             $resourceUrl = $this->getResourceUrl();
  5.             $settings = $this->getSettings();
  6.  
  7.             // read file
  8.             $html  = '';
  9.             $stream = $item->read();
  10.             while (!feof($stream))
  11.                 $html .= fread($stream, 1024);
  12.             fclose($stream);
  13.            
  14.             //form submit url
  15.             $submit_url = $this->getServiceUrl("filesystem", array($item->publicId(), "content"), TRUE);
  16.            
  17.             return <<<HTML
  18. <html>
  19. <head>
  20.     <title>{$item->name()}</title>
  21.     <link rel="stylesheet" href="/mollify/client/themes/basic/style.css">
  22.     <style type="text/css">
  23.         textarea {
  24.             font: normal normal normal 0.9em/1.2em "Courier New", Courier, serif;
  25.             width: 100%;
  26.             height: 88%;
  27.             margin-bottom: 1em;
  28.             padding: 0.5em;
  29.             outline: none;
  30.             background-color: #EEE;
  31.             border: 1px solid #999;
  32.         }
  33.        
  34.         form {
  35.             margin: 0;
  36.         }
  37.  
  38.         .right {
  39.             float: right;
  40.             margin-right: 1em;
  41.         }
  42.     </style>
  43. </head>
  44. <body>
  45.     <form action="$submit_url" method="POST" accept-charset="utf-8">
  46.         <textarea name="data">$html</textarea>
  47.         <input class="mollify-dialog-button" type="submit" value="Save">
  48.         <input class="mollify-dialog-button right" type="reset" value="Revert">
  49.     </form>
  50. </body>
  51. </html>
  52. HTML;
  53.         }
  54.     }
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment