Commit 3c44a80e authored by Penny Leach's avatar Penny Leach

Merge branch 'dwoo'

Conflicts:
	htdocs/lib/web.php

Inaki's patch had changed the smarty function to add httpswwwroot.  I
moved this to lib/dwoo/mahara/Dwoo_Mahara.php
parents a757a430 63382bab
......@@ -57,7 +57,8 @@ $loadingicon = $THEME->get_url('images/loading.gif');
$successicon = $THEME->get_url('images/success.gif');
$failureicon = $THEME->get_url('images/failure.gif');
// Remove all files in the smarty cache
// Remove all files in the smarty and dwoo caches
// TODO post 1.2 remove the smarty part
require_once('file.php');
$basedir = get_config('dataroot') . 'smarty/compile/';
$dh = new DirectoryIterator($basedir);
......@@ -68,6 +69,16 @@ foreach ($dh as $themedir) {
clearstatcache();
check_dir_exists($themedirname);
}
$basedir = get_config('dataroot') . 'dwoo/compile/';
$dh = new DirectoryIterator($basedir);
foreach ($dh as $themedir) {
if ($themedir->isDot()) continue;
$themedirname = $basedir . $themedir->getFilename();
rmdirr($themedirname);
clearstatcache();
check_dir_exists($themedirname);
}
$loadingstring = json_encode(get_string('upgradeloading', 'admin'));
$installsuccessstring = json_encode(get_string('installsuccess', 'admin'));
......
......@@ -3,7 +3,7 @@
<div class="rbuttons">
<a class="btn btn-add" href="{$WWWROOT}artefact/blog/new/">{str section="artefact.blog" tag="addblog"}</a>
</div>
{if empty($blogs->data)}
{if !$blogs->data}
<div>{str tag=youhavenoblogs section=artefact.blog}</div>
{else}
<table id="bloglist" class="tablerenderer fullwidth">
......
......@@ -19,7 +19,7 @@
<th>{str tag=Date section=artefact.file}</th>
</tr>
{if $folder != '/'}
<tr class="r{cycle values=0,1}">
<tr class="r{cycle values='0,1'}">
<td><img src="{$rootpath}static/file/theme/default/static/images/folder.gif" alt="{str tag=Folder section=artefact.file}"></td>
<td><a href="../index.html">{str tag=parentfolder section=artefact.file}</a></td>
<td>{str tag=parentfolder section=artefact.file}</td>
......@@ -28,7 +28,7 @@
</tr>
{/if}
{foreach from=$folders item=folder}
<tr class="r{cycle values=0,1}">
<tr class="r{cycle values='0,1'}">
<td><img src="{$rootpath}static/file/theme/default/static/images/folder.gif" alt="{str tag=Folder section=artefact.file}"></td>
<td><a href="{$folder.path|rawurlencode|escape}/index.html">{$folder.title|escape}</a></td>
<td>{$folder.description|escape}</td>
......@@ -37,7 +37,7 @@
</tr>
{/foreach}
{foreach from=$files item=file}
<tr class="r{cycle values=0,1}">
<tr class="r{cycle values='0,1'}">
<td><img src="{$rootpath}static/file/theme/default/static/images/file.gif" alt="{str tag=File section=artefact.file}"></td>
<td><a href="{$file.path|rawurlencode|escape}">{$file.title|escape}</a></td>
<td>{$file.description|escape}</td>
......
{if empty($filelist)}
{if $filelist}
<p>{str tag=nofilesfound section=artefact.file}</p>
{else}
<table id="filelist" class="tablerenderer filelist">
......@@ -15,7 +15,7 @@
<tbody>
{foreach from=$filelist item=file}
{if !$publishing || !$file->permissions || $file->can_republish}{assign var=publishable value=1}{else}{assign var=publishable value=0}{/if}
<tr id="file:{$file->id}" class="r{cycle values=0,1} directory-item{if $file->isparent} parentfolder{/if}{if $file->artefacttype == 'folder'} folder{/if}{if !empty($highlight) && $highlight == $file->id} highlight-file{/if}{if $edit == $file->id} hidden{/if}{if !$publishable && $file->artefacttype != 'folder'} disabled{/if}" {if !$publishable && $file->artefacttype != 'folder'} title="{str tag=notpublishable section=artefact.file}"{/if}>
<tr id="file:{$file->id}" class="r{cycle values='0,1'} directory-item{if $file->isparent} parentfolder{/if}{if $file->artefacttype == 'folder'} folder{/if}{if $highlight && $highlight == $file->id} highlight-file{/if}{if $edit == $file->id} hidden{/if}{if !$publishable && $file->artefacttype != 'folder'} disabled{/if}" {if !$publishable && $file->artefacttype != 'folder'} title="{str tag=notpublishable section=artefact.file}"{/if}>
<td>
{if $editable}
<div{if !$file->isparent} class="icon-drag" id="drag:{$file->id}"{/if}>
......
<p id="{$prefix}_empty_selectlist"{if !empty($selectedlist)} class="hidden"{/if}>{str tag=nofilesfound section=artefact.file}</p>
<table id="{$prefix}_selectlist" class="attachments fullwidth{if empty($selectedlist)} hidden{/if}">
<p id="{$prefix}_empty_selectlist"{if !$selectedlist} class="hidden"{/if}>{str tag=nofilesfound section=artefact.file}</p>
<table id="{$prefix}_selectlist" class="attachments fullwidth{if !$selectedlist} hidden{/if}">
<thead>
<tr>
<th></th>
......@@ -11,7 +11,7 @@
<tbody>
{foreach from=$selectedlist item=file}
{assign var=displaytitle value=$file->title|str_shorten_text:34|escape}
<tr class="r{cycle values=0,1}{if !empty($highlight) && $highlight == $file->id} highlight-file{/if}">
<tr class="r{cycle values='0,1'}{if $highlight && $highlight == $file->id} highlight-file{/if}">
<td>
<img src="{if $file->artefacttype == 'image'}{$WWWROOT}artefact/file/download.php?file={$file->id}&size=20x20{else}{theme_url filename=images/`$file->artefacttype`.gif}{/if}">
</td>
......
{if $profileiconpath}<div class="fr"><img src="{$profileiconpath|escape}" alt=""></div>{/if}
<p>{$profileinfo.introduction|clean_html}</p>
{if $profileinfo && (count($profileinfo) != 1 || empty($profileinfo.introduction))}<ul>
{if $profileinfo && (count($profileinfo) != 1 || !$profileinfo.introduction)}<ul>
{foreach from=$profileinfo key=key item=item}
{if !in_array($key, array('introduction'))} <li><strong>{str tag=$key section=artefact.internal}:</strong> {$item}</li>
{/if}
......
......@@ -18,7 +18,7 @@
</thead>
<tbody>
{foreach from=$rows item=row}
<tr class="r{cycle values=0,1}">
<tr class="r{cycle values='0,1'}">
<td>{$row->date|escape}</td>
<td><div class="jstitle">{$row->title|escape}</div><div class="jsdescription">{$row->description|escape}</div></td>
</tr>
......
......@@ -18,7 +18,7 @@
</thead>
<tbody>
{foreach from=$rows item=row}
<tr class="r{cycle values=0,1}">
<tr class="r{cycle values='0,1'}">
<td>{$row->date|escape}</td>
<td><div class="jstitle">{$row->title|escape}</div><div class="jsdescription">{$row->description|escape}</div></td>
</tr>
......
......@@ -19,7 +19,7 @@
</thead>
<tbody>
{foreach from=$rows item=row}
<tr class="r{cycle values=0,1}">
<tr class="r{cycle values='0,1'}">
<td>{$row->startdate|escape}</td>
<td>{$row->enddate|escape}</td>
<td><div class="jstitle">{$row->qualification|escape}</div><div class="jsdescription">{$row->qualdescription|escape}</div></td>
......
......@@ -19,7 +19,7 @@
</thead>
<tbody>
{foreach from=$rows item=row}
<tr class="r{cycle values=0,1}">
<tr class="r{cycle values='0,1'}">
<td>{$row->startdate|escape}</td>
<td>{$row->enddate|escape}</td>
<td><div class="jstitle">{$row->jobtitle|escape}: {$row->employer|escape}</div>
......
......@@ -19,7 +19,7 @@
</thead>
<tbody>
{foreach from=$rows item=row}
<tr class="r{cycle values=0,1}">
<tr class="r{cycle values='0,1'}">
<td>{$row->startdate|escape}</td>
<td>{$row->enddate|escape}</td>
<td><div class="jstitle">{$row->title|escape}</div><div class="jsdescription">{$row->description|escape}</div></td>
......
......@@ -4,7 +4,7 @@
{foreach from=$friends item=row}
<tr>
{foreach from=$row item=friend}
<td class="r{cycle values=0,1} friendcell">
<td class="r{cycle values='0,1'} friendcell">
<a href="{$WWWROOT}user/view.php?id={$friend}">
<img src="{$WWWROOT}thumb.php?type=profileicon&amp;maxwidth=60&amp;maxheight=60&amp;id={$friend}" alt="">
</a>
......
......@@ -2,7 +2,7 @@
<table id="usergroupstable" class="fullwidth">
{foreach from=$USERGROUPS item=item}
<tr>
<td class="r{cycle values=0,1}">
<td class="r{cycle values='0,1'}">
<h4><a href="{$WWWROOT}group/view.php?id={$item->id}">{$item->name|escape}</a> - {$item->roledisplay|escape}</h4>
{if $item->description}
{$item->description}
......
......@@ -2,7 +2,7 @@
<table id="userviewstable">
{foreach from=$VIEWS item=item name=view}
<tr>
<td class="r{cycle values=0,1}">
<td class="r{cycle values='0,1'}">
<h4><a href="{$WWWROOT}view/view.php?id={$item->id}">{$item->title|escape}</a></h4>
{if $item->description}
<div>{$item->description}</div>
......
......@@ -22,7 +22,7 @@
<th></th>
</tr>
{foreach from=$forums item=forum}
<tr class="r{cycle values=0,1}">
<tr class="r{cycle values='0,1'}">
<td>
{if $admin}
<div class="fr btn-spacer s">
......
......@@ -2,7 +2,7 @@
{if $sticky}
<tr class="stickytopic">
{else}
<tr class="r{cycle values=0,1}">
<tr class="r{cycle values='0,1'}">
{/if}
<td>
{if $topic->closed}<img src="{$closedicon|escape}" alt="{str tag="Closed" section="interaction.forum"}">{/if}
......
Dwoo in Mahara
======================
Website: http://www.dwoo.org/
Version: svn://dwoo.org/dwoo/trunk -r280
This library is used for all the templating.
Changes:
* None
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?php
/**
* Dwoo adapter for Agavi
*
* Install instructions :
* - download dwoo from dwoo.org and unzip it somewhere in your agavi app
* - add a renderer to your output_types.xml as such :
* <renderer name="dwoo" class="DwooRenderer">
* <parameter name="assigns">
* <parameter name="routing">ro</parameter>
* <parameter name="request">rq</parameter>
* <parameter name="controller">ct</parameter>
* <parameter name="user">us</parameter>
* <parameter name="translation_manager">tm</parameter>
* <parameter name="request_data">rd</parameter>
* </parameter>
* <parameter name="extract_vars">true</parameter>
* <parameter name="plugin_dir">%core.lib_dir%/dwoo_plugins</parameter>
* </renderer>
*
* - add dwoo's directory to your include path or include dwooAutoload.php yourself
* either through agavi's autoload.xml (with name="Dwoo") or through your index.php
*
* Notes:
* - you can copy the /Dwoo/Adapters/Agavi/dwoo_plugins directory to your agavi app's
* lib directory, or change the plugin_dir parameter in the output_types.xml file.
* these plugins are agavi-specific helpers that shortens the syntax to call common
* agavi helpers (i18n, routing, ..)
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the
* use of this software.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
* @copyright Copyright (c) 2008, Jordi Boggiano
* @license http://dwoo.org/LICENSE Modified BSD License
* @link http://dwoo.org/
* @version 1.1.0
* @date 2009-07-18
* @package Dwoo
*/
class DwooRenderer extends AgaviRenderer implements AgaviIReusableRenderer
{
/**
* @constant string The directory inside the cache dir where templates will
* be stored in compiled form.
*/
const COMPILE_DIR = 'templates';
/**
* @constant string The subdirectory inside the compile dir where templates
* will be stored in compiled form.
*/
const COMPILE_SUBDIR = 'dwoo';
/**
* @constant string The directory inside the cache dir where cached content
* will be stored.
*/
const CACHE_DIR = 'dwoo';
/**
* @var Dwoo Dwoo template engine.
*/
protected $dwoo = null;
/**
* @var string A string with the default template file extension,
* including the dot.
*/
protected $defaultExtension = '.html';
/**
* stores the (optional) plugin directory to add to the Dwoo_Loader
*/
protected $plugin_dir = null;
/**
* Pre-serialization callback.
*
* Excludes the Dwoo instance to prevent excessive serialization load.
*/
public function __sleep()
{
$keys = parent::__sleep();
unset($keys[array_search('dwoo', $keys)]);
return $keys;
}
/**
* Initialize this Renderer.
*
* @param AgaviContext The current application context.
* @param array An associative array of initialization parameters.
*/
public function initialize(AgaviContext $context, array $parameters = array())
{
parent::initialize($context, $parameters);
$this->plugin_dir = $this->getParameter('plugin_dir', $this->plugin_dir);
}
/**
* provides a custom compiler to the dwoo renderer with optional settings
* you can set in the agavi output_types.xml config file
*
* @return Dwoo_Compiler
*/
public function compilerFactory()
{
if (class_exists('Dwoo_Compiler', false) === false) {
include DWOO_DIRECTORY . 'Dwoo/Compiler.php';
}
$compiler = Dwoo_Compiler::compilerFactory();
$compiler->setAutoEscape((bool) $this->getParameter('auto_escape', false));
return $compiler;
}
/**
* Grab a cleaned up dwoo instance.
*
* @return Dwoo A Dwoo instance.
*/
protected function getEngine()
{
if($this->dwoo) {
return $this->dwoo;
}
if(!class_exists('Dwoo')) {
if (file_exists(dirname(__FILE__).'/../../../dwooAutoload.php')) {
// file was dropped with the entire dwoo package
require dirname(__FILE__).'/../../../dwooAutoload.php';
} else {
// assume the dwoo package is in the include path
require 'dwooAutoload.php';
}
}
$parentMode = fileperms(AgaviConfig::get('core.cache_dir'));
$compileDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::COMPILE_DIR . DIRECTORY_SEPARATOR . self::COMPILE_SUBDIR;
AgaviToolkit::mkdir($compileDir, $parentMode, true);
$cacheDir = AgaviConfig::get('core.cache_dir') . DIRECTORY_SEPARATOR . self::CACHE_DIR;
AgaviToolkit::mkdir($cacheDir, $parentMode, true);
$this->dwoo = new Dwoo($compileDir, $cacheDir);
if (!empty($this->plugin_dir)) {
$this->dwoo->getLoader()->addDirectory($this->plugin_dir);
}
$this->dwoo->setDefaultCompilerFactory('file', array($this, 'compilerFactory'));
return $this->dwoo;
}
/**
* Render the presentation and return the result.
*
* @param AgaviTemplateLayer The template layer to render.
* @param array The template variables.
* @param array The slots.
* @param array Associative array of additional assigns.
*
* @return string A rendered result.
*/
public function render(AgaviTemplateLayer $layer, array &$attributes = array(), array &$slots = array(), array &$moreAssigns = array())
{
$engine = $this->getEngine();
$data = array();
if($this->extractVars) {
$data = $attributes;
} else {
$data[$this->varName] = &$attributes;
}
$data[$this->slotsVarName] =& $slots;
foreach($this->assigns as $key => $getter) {
$data[$key] = $this->context->$getter();
}
foreach($moreAssigns as $key => &$value) {
if(isset($this->moreAssignNames[$key])) {
$key = $this->moreAssignNames[$key];
}
$data[$key] =& $value;
}
return $engine->get($layer->getResourceStreamIdentifier(), $data);
}
}
\ No newline at end of file
// ------------------------
// Install notes :
// ------------------------
- drop dwoo's directory in app/lib/renderer (create if needed)
- add a renderer to app/config/output_types.xml as such :
<renderer name="dwoo" class="DwooRenderer">
<parameter name="assigns">
<parameter name="routing">ro</parameter>
<parameter name="request">rq</parameter>
<parameter name="controller">ct</parameter>
<parameter name="user">us</parameter>
<parameter name="translation_manager">tm</parameter>
<parameter name="request_data">rd</parameter>
</parameter>
<parameter name="extract_vars">true</parameter>
<parameter name="plugin_dir">%core.lib_dir%/dwoo_plugins</parameter>
</renderer>
- add the renderer to app/config/autoload.xml as such :
<autoload name="DwooRenderer">%core.lib_dir%/renderer/dwoo/Dwoo/Adapter/Agavi/DwooRenderer.php</autoload>
- you can copy the /Dwoo/Adapters/Agavi/dwoo_plugins directory to your agavi app's
lib directory, or change the plugin_dir parameter in the output_types.xml file.
these plugins are agavi-specific helpers that shortens the syntax to call common
agavi helpers (i18n, routing, ..)
<?php
/**
* <strong>Agavi specific plugin</strong>
*
* uses AgaviTranslationManager to localize a string
*
* <pre>
* * string : the string to localize
* </pre>
*
* Examples:
* <code>
* {t "Hello"}
* {t $header}
* </code>
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
* @copyright Copyright (c) 2008, Jordi Boggiano
* @license http://dwoo.org/LICENSE Modified BSD License
* @link http://dwoo.org/
* @version 1.0.0
* @date 2008-10-23
* @package Dwoo
*/
function Dwoo_Plugin_t_compile(Dwoo_Compiler $compiler, $string)
{
return '$this->data[\'tm\']->_('.$string.')';
}
\ No newline at end of file
<?php
/**
* <strong>Agavi specific plugin</strong>
*
* uses AgaviRouting to create an url
*
* <pre>
* * route : the route name, optional (by default the current url is returned)
* * params : an array with variables to build the route, optional
* * options : an array of options to pass to the routing object, optional
* * rest : for convenience, you can just pass named parameters that will be used as
* the params array, but you must not provide the params array in this case
* </pre>
*
* Examples:
* <code>
* {a url("route.name" array(param="Value", param2=$otherVal))}Here is a link{/a}
* <form action="{url}"> {* without any parameter it just returns the current url *}
* </code>
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
* @copyright Copyright (c) 2008, Jordi Boggiano
* @license http://dwoo.org/LICENSE Modified BSD License
* @link http://dwoo.org/
* @version 1.0.0
* @date 2008-10-23
* @package Dwoo
*/
function Dwoo_Plugin_url_compile(Dwoo_Compiler $compiler, $route = null, $params = null, $options = null, array $rest = array())
{
if ($params == 'null') {
if (count($rest)) {
$params = array();
foreach ($rest as $k=>$v) {
if (is_numeric($k)) {
$params[] = $k.'=>'.$v;
} else {
$params[] = '"'.$k.'"=>'.$v;
}
}
$params = 'array('.implode(', ', $params).')';
} else {
$params = 'array()';
}
}
if ($options == 'null') {
$options = 'array()';
}
return '$this->data[\'ro\']->gen('.$route.', '.$params.', '.$options.')';
}
\ No newline at end of file
// CakePHP Dwoo bridge - v0.2
// ------------------------
// Installation :
// ------------------------
// 1. Download and install the dwoo library, preferably on the
// 'vendors' directory of CakePHP. However you can place it
// anywhere you want; if you do, make sure to change the App::import
// line in dwoo.php to include the dwoo library properly.
//
// 2. Place this file in the app/views directory, or on cake/libs/view.
//
// 3. Create the app/tmp/dwoo/cache and app/tmp/dwoo/compile directories
// and make sure they are writable.
// ------------------------
// Usage example :
// ------------------------
// In your controller class you need to change the view property to
// use Dwoo at some point in the execution using :
$this->view = 'Dwoo';
// Or you can also override the view property in your AppController class as such :
class AppController extends Controller {
public $view = 'Dwoo';
}
// If you want another template extension (default is .tpl) you must
// edit the dwoo.php file at line 44 and change it to :
$this->ext = ".html";
//{include $templatedir."index.tpl"}
\ No newline at end of file
<?php
App::import('vendor', 'dwoo', array("file" => 'dwoo/dwooAutoload.php'));
/**
* Dwoo adapter for CakePHP
*
* Based on SmartyView by Mark John S. Buenconsejo <mjwork@simpleteq.com>
*
* This software is provided 'as-is', without any express or implied warranty.
* In no event will the authors be held liable for any damages arising from the use of this software.
*
* This file is released under the LGPL
* "GNU Lesser General Public License"