Changeset 125

Show
Ignore:
Timestamp:
13/09/06 00:18:37 (7 years ago)
Author:
dez
Message:

Adds a bunch of templates that no-one thought to svn add previously
Adds page creation and deletion to static component

Files:
9 added
9 modified

Legend:

Unmodified
Added
Removed
  • components/bananas.php

    r94 r125  
    11<?php 
    2 echo($path); 
    32$banana_index = array_search("Bananas", $pathlist); 
    43if ((sizeof($pathlist) > $banana_index + 1) && (trim($pathlist[$banana_index + 1]) != "")) { 
  • components/contents.php

    r94 r125  
    4242                $smarty->assign('data', $dirlist); 
    4343                $smarty->assign('level', 0); 
    44                 $output = $smarty->fetch('contents-loop.tpl'); 
    45                 $smarty->assign("secondary", "<div class=\"cbb\"><h3>In this section</h3>".$output."</div>"); 
    46                 $smarty->assign('title', end($pathlist)); 
     44                if (!isset($_REQUEST['action'])) { 
     45                        $output = $smarty->fetch('contents-loop.tpl'); 
     46                        $smarty->assign("secondary", "<div class=\"cbb\"><h3>In this section</h3>".$output."</div>"); 
     47                } 
    4748        } 
    4849} 
  • components/news.php

    r93 r125  
    11<?php 
    22 
     3if (isset($_REQUEST['action'])) { 
     4        $action = $_REQUEST['action']; 
     5} else { 
     6        $action = "view"; 
     7} 
     8 
    39$smarty->assign("news",$DB->GetArray("SELECT * FROM news ORDER BY date DESC LIMIT 5")); 
    4 $output = $smarty->fetch($base."templates/news.tpl"); 
    5 $smarty->assign("title", "News"); 
     10 
     11if ($action == "edit") { 
     12        $output = $smarty->fetch("news_edit.tpl"); 
     13        $smarty->assign("title", "Edit News"); 
     14} else { 
     15        $output = $smarty->fetch("news.tpl"); 
     16        $smarty->assign("title", "News"); 
     17} 
     18 
    619$smarty->assign("body", $output); 
     20 
    721?> 
  • components/static.php

    r122 r125  
    11<?php 
    22// Static page producer module 
     3 
     4// A user must be in the html group in order to edit pages in this component 
     5$permission = "html"; 
    36 
    47// Get the right filename... 
     
    69if (!file_exists($myfile)) { 
    710        $myfile = $base."static$path.txt"; 
    8         // ...or serve a 404 error 
     11        // If the file doesn't exist... 
    912        if (!file_exists($myfile)) { 
    10                 header("HTTP/1.1 404 Not Found"); 
    11                 $smarty->assign("body", file_get_contents($base."static/404.txt")); 
    12                 $smarty->assign("pathlist", array("", "Error")); 
    13                 $smarty->assign("title", "File not found"); 
    14                 return; 
     13                if (isset($session->groups[$permission]) && @$_REQUEST['action']=="create") { 
     14                        // ...and we have permission and have been asked to, create it 
     15                        $body = "foo"; 
     16                } else { 
     17                        // ...serve a 404 error 
     18                        header("HTTP/1.1 404 Not Found"); 
     19                        $body = file_get_contents($base."static/404.txt"); 
     20                        $smarty->assign("pathlist", array("", "Error")); 
     21                        $title = "File not found"; 
     22                        $smarty->assign("title", $title); 
     23                        $smarty->assign("body", $body); 
     24                        // Give those with permission the chance to create the page 
     25                        if (isset($session->groups[$permission])) $smarty->assign("creatable", TRUE); 
     26                        return; 
     27                } 
    1528        } 
    1629} 
    1730 
    18 // A user must be in the html group in order to edit pages in this component 
    19 $permission = "html"; 
    20  
    21  
    22 // If we've been asked to save changes and have permission to do so... 
    23 if (@$_REQUEST['action']=="Save" && $session->groups[$permission]) { 
    24         file_put_contents($myfile, $_REQUEST['body'], LOCK_EX); 
     31// If we've got edit permission... 
     32if (isset($session->groups[$permission])) { 
     33        switch (@$_REQUEST['action']) { 
     34        case "Save": 
     35                // ...save the file 
     36                file_put_contents($myfile, $_REQUEST['body'], LOCK_EX); 
     37                // probably need some error-handling here... 
     38                break; 
     39        case "Delete": 
     40                $deleted = unlink($myfile); 
     41                break; 
     42        } 
    2543} 
    2644 
    27 if (isset($pathlist[2])) 
    28         $title = $pathlist[2]; 
    29 elseif (isset($pathlist[1])) 
    30         $title = $pathlist[1]; 
    31 else 
    32         $title = "Static Page Producer"; 
     45$title = end($pathlist); 
    3346 
    34 $body = file_get_contents($myfile); 
    35 $modified = filectime($myfile); 
     47if (file_exists($myfile)) { 
     48        $body = file_get_contents($myfile); 
     49        $modified = date("r", filectime($myfile)); 
     50} 
    3651 
    3752$smarty->assign("title", $title); 
    38 $smarty->assign("modified", date("r", $modified)); 
    39  
    4053 
    4154// Editing static pages - does the user have permission? 
    4255if (isset($session->groups[$permission])) { 
    4356// display Edit link on page 
    44         $smarty->assign("editable", true); 
     57        $smarty->assign("editable", TRUE); 
    4558// load the editing template 
    46         if (@$_REQUEST['action']=="edit") { 
     59        switch (@$_REQUEST['action']) { 
     60        case "create": 
     61                if (!file_exists($myfile)) file_put_contents($myfile, "Page under construction\n", LOCK_EX); 
     62        case "edit": 
    4763                $smarty->assign("editcontent", htmlentities($body)); 
    4864                $body = $smarty->fetch('static_edit.tpl'); 
    49                 $smarty->assign("action", $_REQUEST['action']); 
     65                $smarty->assign("action", "edit"); 
     66                $modified = NULL; 
     67                break; 
     68        case "delete-query": 
     69                $body = $smarty->fetch('static_delete.tpl').$body; 
     70                break; 
     71        case "Delete": 
     72                if ($deleted) $body = "File deleted"; 
     73                break; 
    5074        } 
    5175} 
    5276 
    5377$smarty->assign("body", $body); 
    54  
     78$smarty->assign("modified", @$modified); 
    5579?> 
  • htdocs/css/sucs.css

    r122 r125  
    367367 
    368368/* -------------------------------------------------- 
     369    Dialog box 
     370   -------------------------------------------------- */ 
     371 
     372.dialog { 
     373        text-align: center; 
     374        margin: auto; 
     375        width: 20em; 
     376} 
     377 
     378/* -------------------------------------------------- 
    369379    Tables 
    370380   -------------------------------------------------- */ 
     
    389399        text-align: right; 
    390400} 
     401 
     402#edit ul { 
     403        margin: 0; 
     404} 
     405 
     406#edit li { 
     407        display: inline; 
     408        float: right; 
     409        padding-left: 1em; 
     410} 
  • htdocs/index.php

    r109 r125  
    11<?php 
     2// Display execution time? 
     3//$displaytime = TRUE; 
    24 
    35// start the clock (this is just temporary cause I'm interested in how long all this takes) 
    4 $time = microtime(); 
    5 $time = explode(' ', $time); 
    6 $time = $time[1] + $time[0]; 
    7 $begintime = $time; 
     6if (@$displaytime) { 
     7        $time = microtime(); 
     8        $time = explode(' ', $time); 
     9        $time = $time[1] + $time[0]; 
     10        $begintime = $time; 
     11} 
    812 
    913/* -------------------------------------------------------- 
     
    4549$compdebug = TRUE; 
    4650 
    47 // Display execution time? 
    48 $displaytime = false; 
    4951 
    5052/* -------------------------------------------------------- 
     
    136138 
    137139// Last chance to stop the clock and still end up with valid HTML 
    138 $time = microtime(); 
    139 $time = explode(" ", $time); 
    140 $time = $time[1] + $time[0]; 
    141 $endtime = $time; 
    142 $totaltime = ($endtime - $begintime); 
    143 if ($displaytime) $smarty->assign("totaltime", $totaltime); 
     140if (@$displaytime) { 
     141        $time = microtime(); 
     142        $time = explode(" ", $time); 
     143        $time = $time[1] + $time[0]; 
     144        $endtime = $time; 
     145        $totaltime = ($endtime - $begintime); 
     146        $smarty->assign("totaltime", $totaltime); 
     147} 
    144148 
    145149$smarty->display("foot".$language['file'].".tpl"); 
  • static/About.txt

    r116 r125  
    1818<li>Mail list hosting</li> 
    1919<li><a href="/Help/Advisory">Programming Advisory service</a></li> 
    20 <li><a href="/Services/Library">Reference Library</a> of popular books (including Computer Science recommended course texts)</li> 
    21 <li>24hr access to our own <a href="/Services/Room">Computer Room</a><br /> 
     20<li><a href="/Knowledge/Library">Reference Library</a> of popular books (including Computer Science recommended course texts)</li> 
     21<li>24hr access to our own <a href="/About/Room">Computer Room</a><br /> 
    2222Features include: 
    2323<ul> 
  • templates/index.tpl

    r122 r125  
    1313{$body} 
    1414 
     15{if $creatable} 
     16<p>You can <a href="?action=create">create</a> this page though.</p> 
     17{/if} 
     18 
    1519{if $modified} 
    1620<div id="edit"> 
    1721{if $editable} 
    18 <a href="?action=edit">Edit</a><br /> 
     22<ul> 
     23<li><a href="?action=delete-query">Delete</a></li> 
     24<li><a href="?action=edit">Edit</a></li> 
     25</ul> 
     26<div class="clear"></div> 
    1927{/if} 
    2028Page last modified {$modified} 
  • templates/library.tpl

    r105 r125  
    66<h3>Random Books</h3> 
    77        {foreach name=randoms from=$randoms item=randomitem} 
    8         <a href="/Services/Library/{$randomitem.id}"><img src="{$randomitem.image_url}" alt="{$randomitem.title}" height="120" /></a> 
     8        <a href="/Knowledge/Library/{$randomitem.id}"><img src="{$randomitem.image_url}" alt="{$randomitem.title}" height="120" /></a> 
    99        {/foreach} 
    1010 
     
    2727        <ul> 
    2828        {foreach name=results from=$results item=result} 
    29 <li><a href="/Services/Library/{$result.id}">{$result.title}</a>{if $result.onloan} <em>(on loan)</em>{/if} </li> 
     29<li><a href="/Knowledge/Library/{$result.id}">{$result.title}</a>{if $result.onloan} <em>(on loan)</em>{/if} </li> 
    3030        {/foreach} 
    3131        </ul>