Changeset 130

Show
Ignore:
Timestamp:
19/09/06 23:38:29 (7 years ago)
Author:
dez
Message:

Implements database writes for static editor, fixes #23 (dez)

Files:
3 modified

Legend:

Unmodified
Added
Removed
  • components/static.php

    r128 r130  
    4949        case "Save": 
    5050                // ...save the file 
    51                 file_put_contents($myfile, $_REQUEST['body'], LOCK_EX); 
     51                $savesuccess = @file_put_contents($myfile, $_REQUEST['body'], LOCK_EX); 
     52                if (!$savesuccess) $smarty->assign("fileerror", "Write failed"); 
     53                $id = $DB->GetOne("select id from static where path=?", array($path)); 
     54                $record = array(); 
     55                $record['summary'] = $_REQUEST['summary']; 
     56                $record['editor'] = $session->username; 
     57                $record['path'] = $path; 
     58                if ($id>0) { 
     59                        $DB->AutoExecute("static", $record, 'UPDATE', 'id = $id'); 
     60                } else { 
     61                        $DB->AutoExecute("static", $record, 'INSERT'); 
     62                } 
    5263                // probably need some error-handling here... 
    5364                break; 
     
    8394        case "edit": 
    8495                $smarty->assign("editcontent", htmlentities($body)); 
    85                 $body = $smarty->fetch('static_edit.tpl'); 
     96                $record['summary'] = $DB->GetOne("select summary from static where path=?", array($path)); 
     97                $smarty->assign("record", $record); 
    8698                $smarty->assign("action", "edit"); 
    8799                $modified = NULL; 
     100                $body = $smarty->fetch('static_edit.tpl'); 
    88101                break; 
    89102        case "delete-query": 
  • htdocs/index.php

    r126 r130  
    11<?php 
    22// Display execution time? 
    3 //$displaytime = TRUE; 
     3$displaytime = TRUE; 
    44 
    55// start the clock (this is just temporary cause I'm interested in how long all this takes) 
  • templates/index.tpl

    r127 r130  
    33                <div><div><div> 
    44                        Session: {$session->errormsg} 
     5                </div></div></div> 
     6        </div> 
     7{/if} 
     8{if $fileerror} 
     9        <div class="errorbar"> 
     10                <div><div><div> 
     11                        File error: {$fileerror} 
    512                </div></div></div> 
    613        </div>