Changeset 88

Show
Ignore:
Timestamp:
27/08/06 23:46:21 (7 years ago)
Author:
dez
Message:

Updates to library component
contents component now works

Files:
2 added
3 modified

Legend:

Unmodified
Added
Removed
  • components/contents.php

    r87 r88  
    11<?php 
     2 
     3function listdir($path, $recurse) { 
     4        $dirlist = scandir($path); 
     5        $output = array(); 
     6        foreach($dirlist as $file) { 
     7                if ($file!="." && $file!="..") { 
     8                        if (!is_dir($path."/".$file)) { 
     9                                $foo = ereg_replace("\.txt", "", $file); 
     10                                if ($foo!=@$lastdir) $output[$foo]=$foo; 
     11                                 
     12                        } else { 
     13                                if ($recurse) $output[$file]=listdir($path."/".$file); 
     14                                else $output[$file]=$file; 
     15                                $lastdir=$file; 
     16                        } 
     17                } 
     18        } 
     19        return $output; 
     20} 
    221 
    322if ($path==$component['path']) { 
    423 
    5         $output = "<h2>Table of Contents</h2>\n"; 
    624 
     25        $dirlist = listdir("static".$component['path'], TRUE); 
     26 
     27        $smarty->assign('rootnode', $component['path']); 
     28        $smarty->assign('dirlist', $dirlist); 
     29        $output = $smarty->fetch('contents.tpl'); 
    730        $smarty->assign('title', $pathlist[1]); 
    831        $smarty->assign('body', $output); 
    932} else { 
    1033        include("static.php"); 
    11         $smarty->assign("secondary", "<div class=\"cbb\"><h3>In this section</h3>\nList...</div>"); 
     34        $dirlist = listdir("static".$path, FALSE); 
     35        $smarty->assign('rootnode', $path); 
     36print_r($dirlist); 
     37        $smarty->assign('data', $dirlist); 
     38        $smarty->assign('level', 0); 
     39        $output = $smarty->fetch('contents-loop.tpl'); 
     40 
     41 
     42        $smarty->assign("secondary", "<div class=\"cbb\"><h3>In this section</h3>".$output."</div>"); 
    1243} 
    1344?> 
  • components/library.php

    r81 r88  
    33$mode = "list"; 
    44 
    5 $smarty->assign("randoms", $DB->GetAll("SELECT * FROM books ORDER BY random() LIMIT 1")); 
     5$smarty->assign("randoms", $DB->GetAll("SELECT * FROM books WHERE image_url IS NOT NULL ORDER BY random() LIMIT 5")); 
    66 
    77if ($mode == "display") { 
    88 
    99 
     10} 
    1011 
    11 } 
    1212$output = $smarty->fetch("library.tpl"); 
    1313$smarty->assign("title","Library"); 
  • templates/library.tpl

    r81 r88  
    88 
    99<h3>Random Books</h3> 
    10 {foreach name=randoms from=$random item=randomitem} 
    11 <img src="{$randomitem.img}" alt="{$randomitem.title}" /> 
     10{foreach name=randoms from=$randoms item=randomitem} 
     11<img src="{$randomitem.image_url}" alt="{$randomitem.title}" /> 
    1212{/foreach}  
     13<p>Images provided by <a href="http://www.amazon.co.uk">Amazon</a></p>