Commit 70ac0d54 authored by Francois Marier's avatar Francois Marier
Browse files
parents bca782a5 53ca3b54
<?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 blocktype-folder
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$string['title'] = 'A folder';
$string['description'] = 'A single folder from your Files area';
?>
<?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 blocktype-image
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
class PluginBlocktypeFolder extends PluginBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.file/folder');
}
public static function get_description() {
return get_string('description', 'blocktype.file/folder');
}
public static function get_categories() {
return array('file');
}
public static function render_instance(BlockInstance $instance) {
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
$configdata['viewid'] = $instance->get('view');
// This can be either an image or profileicon. They both implement
// render_self
$result = '';
if (isset($configdata['artefactid'])) {
$folder = artefact_instance_from_id($configdata['artefactid']);
$result = $folder->render_self($configdata);;
$result = $result['html'];
}
return $result;
}
public static function has_instance_config() {
return true;
}
public static function instance_config_form($instance) {
$configdata = $instance->get('configdata');
return array(
self::artefactchooser_element((isset($configdata['artefactid'])) ? $configdata['artefactid'] : null),
);
}
public static function artefactchooser_element($default=null) {
return array(
'name' => 'artefactid',
'type' => 'artefactchooser',
'title' => get_string('folder'),
'defaultvalue' => $default,
'rules' => array(
'required' => true,
),
'blocktype' => 'folder',
'limit' => 10,
'artefacttypes' => array('folder'),
'template' => 'artefact:file:artefactchooser-element.tpl',
);
}
/**
* Optional method. If specified, allows the blocktype class to munge the
* artefactchooser element data before it's templated
*
* Note: this method is the same as the one for the 'filedownload' blocktype
*/
public static function artefactchooser_get_element_data($artefact) {
global $USER;
// Grab data about all folders this user has, so we can make full paths to them
static $folderdata = null;
if ($folderdata === null) {
$folderdata = get_records_select_assoc('artefact', "artefacttype='folder' AND owner = ?", array($USER->get('id')), '', 'id, title, parent');
}
$artefact->icon = call_static_method(generate_artefact_class_name($artefact->artefacttype), 'get_icon', array('id' => $artefact->id));
$artefact->hovertitle = $artefact->description;
$artefact->description = self::get_full_folder_path($artefact->id, $folderdata);
return $artefact;
}
public static function artefactchooser_get_sort_order() {
return 'parent, title';
}
/**
* Works out a full path to a folder, given an ID. Implemented this way so
* only one query is made.
*/
private static function get_full_folder_path($id, $folderdata) {
$path = '';
foreach ($folderdata as $folder) {
if ($folder->id == $id) {
$path = $folder->title;
while ($folder->parent !== null) {
$folder = $folderdata[$folder->parent];
$path = $folder->title . '/' . $path;
}
}
}
return $path;
}
}
?>
<?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 blocktype-image
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2007082801;
$config->release = '0.9';
?>
......@@ -738,12 +738,34 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
return get_records_array('artefact', 'parent', $this->get('id'));
}
public function render_self($options) {
$smarty = smarty_core();
$smarty->assign('title', $this->get('title'));
$smarty->assign('description', $this->get('description'));
$smarty->assign('viewid', $options['viewid']);
if ($childrecords = $this->folder_contents()) {
$this->add_to_render_path($options);
usort($childrecords, array('ArtefactTypeFileBase', 'my_files_cmp'));
$children = array();
foreach ($childrecords as &$child) {
$c = artefact_instance_from_id($child->id);
$child->title = $c->get('title');
$child->date = format_date(strtotime($child->mtime), 'strfdaymonthyearshort');
$child->iconsrc = call_static_method(generate_artefact_class_name($child->artefacttype), 'get_icon', array('id' => $child->id, 'viewid' => $options['viewid']));
}
$smarty->assign('children', $childrecords);
}
return array('html' => $smarty->fetch('artefact:file:folder_render_self.tpl'),
'javascript' => null);
}
public function describe_size() {
return $this->count_children() . ' ' . get_string('files', 'artefact.file');
}
public static function get_icon($options=null) {
return theme_get_url('images/folder.gif');
}
public static function collapse_config() {
......
<div>
<h3>{$title|escape}</h3>
<div>{$description|escape}</div>
<div>
{if (isset($children))}
<table>
<thead>
<tr>
<th colspan="5">{str tag=contents section=artefact.file}:</th>
</tr>
<tr>
<th></th>
<th>{str tag=name}</th>
<th>{str tag=description}</th>
<th>{str tag=date}</th>
</tr>
</thead>
<tbody>
{foreach from=$children item=child}
<tr class="{cycle values=r1,r0}">
<td><img src="{$child->iconsrc}" border="0" alt="{$child->artefacttype|escape}"></td>
<td><a href="{$WWWROOT}view/view.php?id={$viewid|escape}&amp;artefact={$child->id|escape}">{$child->title}</a></td>
<td>{$child->description}</td>
<td>{$child->date}</td>
</tr>
{/foreach}
</tbody></table>
{else}
{str tag=emptyfolder section=artefact.file}
{/if}
</div>
</div>
<?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 blocktype-entireresume
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$string['title'] = 'Your Entire Resume';
$string['description'] = 'A quick way to show your whole resume';
?>
<?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 blocktype-entireresume
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
class PluginBlocktypeEntireresume extends PluginBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.resume/entireresume');
}
/**
* Entire resume blocks never have titles
*/
public static function get_instance_title(BlockInstance $bi) {
return '';
}
public static function get_description() {
return get_string('description', 'blocktype.resume/entireresume');
}
public static function get_categories() {
return array('resume');
}
public static function render_instance(BlockInstance $instance) {
require_once(get_config('docroot') . 'artefact/lib.php');
$smarty = smarty_core();
//$configdata = $instance->get('configdata');
//$configdata['viewid'] = $instance->get('view');
// Get data about the resume fields the user has
$return = '';
if ($artefacts = get_records_sql_array('
SELECT va.artefact, a.artefacttype
FROM {view_artefact} va
INNER JOIN {artefact} a ON (va.artefact = a.id)
WHERE va.view = ?
AND va.block = ?', array($instance->get('view'), $instance->get('id')))) {
foreach ($artefacts as $artefact) {
$resumefield = artefact_instance_from_id($artefact->artefact);
$rendered = $resumefield->render_self(array('viewid' => $instance->get('view')));
$result = $rendered['html'];
if (!empty($rendered['javascript'])) {
$result .= '<script type="text/javascript">' . $rendered['javascript'] . '</script>';
}
$smarty->assign($artefact->artefacttype, $result);
}
}
return $smarty->fetch('blocktype:entireresume:content.tpl');
}
public static function has_instance_config() {
return false;
}
// TODO: make decision on whether this should be abstract or not. PROBABLY SHOULD BE
public static function artefactchooser_element($default=null) {
}
/**
* Subscribe to the blockinstancecommit event to make sure all artefacts
* that should be in the blockinstance are
*/
public static function get_event_subscriptions() {
return array(
(object)array(
'event' => 'blockinstancecommit',
'callfunction' => 'ensure_resume_artefacts_in_blockinstance',
),
);
}
/**
* Hook for making sure that all resume artefacts are associated with a
* blockinstance at blockinstance commit time
*/
public static function ensure_resume_artefacts_in_blockinstance($event, $blockinstance) {
safe_require('artefact', 'resume');
$artefacttypes = implode(', ', array_map('db_quote', PluginArtefactResume::get_artefact_types()));
// Get all artefacts that are resume related and belong to the correct owner
$artefacts = get_records_sql_array('
SELECT id
FROM {artefact}
WHERE artefacttype IN(' . $artefacttypes . ')
AND owner = (
SELECT owner
FROM {view}
WHERE id = ?
)', array($blockinstance->get('view')));
if ($artefacts) {
// Make sure they're registered as being in this view
foreach ($artefacts as $artefact) {
$record = (object)array(
'view' => $blockinstance->get('view'),
'artefact' => $artefact->id,
'block' => $blockinstance->get('id'),
);
ensure_record_exists('view_artefact', $record, $record);
}
}
}
}
?>
{if $coverletter}<h2>Cover Letter</h2>
{$coverletter}{/if}
{if $interest}<h3>Interests</h3>
{$interest}{/if}
{if $contactinformation}<h3>Contact Information</h3>
{$contactinformation}{/if}
{if $personalinformation}<h3>Personal Information</h3>
{$personalinformation}{/if}
{if $employmenthistory || $educationhistory}<h2>History</h2>{/if}
{if $employmenthistory}<h3>Employment</h3>
{$employmenthistory}{/if}
{if $educationhistory}<h3>Education</h3>
{$educationhistory}{/if}
{if $certification}<h2>Certifications</h2>
{$certification}{/if}
{if $book}<h2>Books Published</h2>
{$book}{/if}
{if $membership}<h2>Professional Memberships</h2>
{$membership}{/if}
<?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 blocktype-entireresume
* @author Nigel McNie <nigel@catalyst.net.nz>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL
* @copyright (C) 2006,2007 Catalyst IT Ltd http://catalyst.net.nz
*
*/
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2007082802;
$config->release = '0.9';
?>
......@@ -117,6 +117,35 @@ class ArtefactTypeResume extends ArtefactType {
public function render_self($options) {
return array('html' => $this->description);
}
/**
* Overrides the default commit to make sure that any 'entireresume' blocks
* in views the user have know about this artefact - but only if necessary.
* Goals and skills are not in the entireresume block
*
* @param boolean $updateresumeblocks Whether to update any resume blockinstances
*/
public function commit($updateresumeblocks=true) {
if ($updateresumeblocks) {
foreach (get_records_sql_array('
SELECT id, view, configdata
FROM {block_instance}
WHERE blocktype = \'entireresume\'
AND "view" IN (
SELECT id
FROM {view}
WHERE "owner" = ?)', array($this->owner)) as $blockinstance) {
$whereobject = (object)array(
'view' => $blockinstance->view,
'artefact' => $this->get('id'),
'block' => $blockinstance->id,
);
ensure_record_exists('view_artefact', $whereobject, $whereobject);
}
}
parent::commit();
}
}
class ArtefactTypeCoverletter extends ArtefactTypeResume {
......
......@@ -486,7 +486,9 @@ class BlockInstance {
}
$this->rebuild_artefact_list();
// @TODO maybe handle_event here.
// Tell stuff about this
handle_event('blockinstancecommit', $this);
$this->dirty = false;
}
......
......@@ -99,12 +99,6 @@ function upgrade_template_migration() {
}
$numcolumns = count($viewcolumns);
// Temporary, testing the migration of certain templates only
if ($view->template != 'filelist' && $view->template != 'PPAE') {
//log_debug('skipping template, it is not blogreflection');
continue;
}
// Handle all label blocks, by converting them to WYSIWYG blocks
if ($lblocks = get_records_array('view_content', 'view', $view->id)) {
foreach ($lblocks as $block) {
......@@ -228,13 +222,11 @@ function upgrade_template_migration() {
}
}
if ($empty) {
log_debug("Column $c is empty");
$numcolumns--;
unset($viewcolumns[$c]);
}
}
}
log_debug("Final number of columns in view: $numcolumns");
// Make all the block instances have the correct column and order
foreach ($viewcolumns as $c => $col) {
......@@ -270,7 +262,6 @@ function upgrade_template_migration() {
* @param BlockInstance $bi blockinstance to insert
*/
function upgrade_template_insert_block(&$columns, $key, BlockInstance $bi) {
log_debug('upgrade_template_insert_block() for key ' . $key);
foreach ($columns as &$c) {
if (array_key_exists($key, $c)) {
if (!empty($c[$key])) {
......@@ -316,6 +307,8 @@ function upgrade_template_update_block(&$columns, $block) {
if ($block->artefacttype == 'file' || $block->artefacttype == 'image') {
upgrade_template_add_artefact_to_blockinstance($bi, $block->artefact);
}
// More than one artefact in this filedownload block, so remove the title
$bi->set('title', '');
}
// If the blockinstance is profileinfo, we can keep adding profile fields to it
else if ($bi->get('blocktype') == 'profileinfo') {
......@@ -326,7 +319,7 @@ function upgrade_template_update_block(&$columns, $block) {
else {
// The profileicon is stored in a dedicated field, not 'artefactids'