Commit 73cd1ee2 authored by Penny Leach's avatar Penny Leach
Browse files

template thumbnail stuff

parent 98d95b35
......@@ -563,6 +563,7 @@
<FIELD NAME="mtime" TYPE="datetime" NOTNULL="true" />
<FIELD NAME="cacheddata" TYPE="text" NOTNULL="false" />
<FIELD NAME="deleted" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
<FIELD NAME="thumbnail" TYPE="int" LENGTH="1" NOTNULL="true" DEFAULT="0" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="name" />
......
......@@ -95,15 +95,19 @@ function template_locate($templatename, $fetchdb=true) {
$template = array();
$thumbnails = array('jpg', 'jpeg', 'png', 'gif');
$thumbnails = array('jpg' => 'image/jpeg',
'jpeg' => 'image/jpeg',
'png' => 'image/png',
'gif' => 'image/gif');
if ($path = realpath(get_config('dataroot') . $fragment)) {
$template['fragment'] = $path;
if (is_readable(get_config('dataroot') . $css)) {
$template['css'] = get_config('dataroot') . $css;
}
foreach ($thumbnails as $t) {
foreach ($thumbnails as $t => $contenttype) {
if (is_readable(get_config('dataroot') . $templatedir . 'thumbnail.' . $t)) {
$template['thumbnailcontenttype'] = $contenttype;
$template['thumbnail'] = get_config('dataroot') . $templatedir . 'thumbnail.' . $t;
break;
}
......@@ -121,8 +125,9 @@ function template_locate($templatename, $fetchdb=true) {
if (is_readable(get_config('libroot') . $css)) {
$template['css'] = get_config('libroot') . $css;
}
foreach ($thumbnails as $t) {
foreach ($thumbnails as $t => $contenttype) {
if (is_readable(get_config('libroot') . $templatedir . 'thumbnail.' . $t)) {
$template['thumbnailcontenttype'] = $contenttype;
$template['thumbnail'] = get_config('libroot') . $templatedir . 'thumbnail.' . $t;
break;
}
......
......@@ -449,6 +449,9 @@ function upgrade_templates() {
$fordb->category = $template->category;
$fordb->mtime = db_format_timestamp(time());
$fordb->cacheddata = serialize($guff['parseddata']);
if (isset($guff['thumbnail'])) {
$fordb->thumbnail = 1;
}
if (isset($template->owner)) {
$fordb->owner = $template->owner;
}
......
<?php
/**
* This program is part of Mahara
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* @package mahara
* @subpackage core or plugintype/pluginname
* @author Your Name <you@example.org>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
define('INTERNAL', 1);
define('PUBLIC', 1);
require('init.php');
$type = param_alpha('type');
switch ($type) {
case 'template':
require_once('template.php');
$name = param_alpha('name');
$template = template_locate($name);
if (isset($template['thumbnail'])) {
header("Content-type: " . $thumbnail['thumbnailcontenttype']);
readfile($template['thumbnail']);
exit;
}
throw new InvalidArgumentException("Couldn't find a template thumbnail for $name");
break;
}
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment