Commit 2b9b0829 authored by Nigel McNie's avatar Nigel McNie
Browse files

Lay out the 'all profile information' page a little nicer.

parent 0ea01ae5
......@@ -60,19 +60,45 @@ class HtmlExportInternal extends HtmlExportArtefactPlugin {
// Generic profile information
$smarty->assign('breadcrumbs', array(array('text' => 'Profile information', 'path' => 'index.html')));
$sections = array();
// Organise profile information by sections, ordered how it's ordered
// on the 'edit profile' page
$sections = array(
'aboutme' => array(),
'contact' => array(),
'messaging' => array(),
'general' => array(),
);
$elementlist = call_static_method('ArtefactTypeProfile', 'get_all_fields');
$elementlistlookup = array_flip(array_keys($elementlist));
$profilefields = get_column_sql('SELECT id FROM {artefact} WHERE owner=? AND artefacttype IN ('
. join(",",array_map(create_function('$a','return db_quote($a);'),array_keys($elementlist)))
. join(",",array_map(create_function('$a','return db_quote($a);'), array_keys($elementlist)))
. ")", array($this->exporter->get('user')->get('id')));
foreach ($profilefields as $id) {
$artefact = artefact_instance_from_id($id);
$rendered = $artefact->render_self(array());
$sections[$this->get_category_for_artefacttype($artefact->get('artefacttype'))][$artefact->get('artefacttype')] = $rendered['html'];
$rendered = $artefact->render_self(array('link' => true));
$sections[$this->get_category_for_artefacttype($artefact->get('artefacttype'))][$artefact->get('artefacttype')] = array(
'html' => $rendered['html'],
'weight' => $elementlistlookup[$artefact->get('artefacttype')]
);
}
// Sort the data and then drop the weighting information
foreach ($sections as &$section) {
uasort($section, create_function('$a, $b', 'return $a["weight"] > $b["weight"];'));
foreach ($section as &$data) {
$data = $data['html'];
}
}
$smarty->assign('sections', $sections);
$iconid = $this->exporter->get('user')->get('profileicon');
if ($iconid) {
$icon = artefact_instance_from_id($iconid);
// TODO: protect title from /'s
$smarty->assign('icon', '<img src="../../static/profileicons/200px-' . $icon->get('title') . '" alt="Profile Icon">');
}
$content = $smarty->fetch('export:html/internal:index.tpl');
if (!file_put_contents($this->fileroot . 'index.html', $content)) {
throw new SystemException("Unable to write profile information page");
......@@ -102,11 +128,32 @@ class HtmlExportInternal extends HtmlExportArtefactPlugin {
switch ($artefacttype) {
case 'firstname':
case 'lastname':
return 'basic';
case 'preferredname':
case 'studentid':
case 'introduction':
return 'aboutme';
case 'email':
case 'faxnumber':
case 'businessnumber':
case 'homenumber':
case 'mobilenumber':
case 'city':
case 'town':
case 'address':
case 'country':
case 'blogaddress':
case 'personalwebsite':
case 'officialwebsite':
return 'contact';
case 'jabberusername':
case 'skypeusername':
case 'yahoochat':
case 'aimscreenname':
case 'msnnumber':
case 'icqnumber':
return 'messaging';
default:
return 'unclassified';
return 'general';
}
}
......
{include file="export:html:header.tpl"}
{if $icon}<div id="profile-icon">{$icon}</div>{/if}
{foreach from=$sections key=sectionname item=section}
<div>
<h3>{$sectionname|escape}</h3>
<dl>
{if count($section)}
<div class="profileinfo">
<h3>{str tag=$sectionname section=artefact.internal}</h3>
<table>
{foreach from=$section key=title item=value}
<dt>{$title|escape}</dt>
<dd>{$value}</dd>
<tr>
<th>{str tag=$title section=artefact.internal}:</th>
<td>{$value}</td>
</tr>
{/foreach}
</dl>
</table>
</div>
{/if}
{/foreach}
{include file="export:html:footer.tpl"}
/**
* CSS rules for internal artefact plugin HTML export
*
* Copyright (C) 2009 Catalyst IT
* This file is licensed under the same terms as Mahara itself
*/
.profileinfo th {
text-align: right;
vertical-align: top;
width: 12em;
padding: 0 .25em .5em 0;
}
.profileinfo td {
vertical-align: top;
padding: 0;
}
#profile-icon {
float: right;
}
h3 {
margin: 1em 0 0.25em 8em;
}
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