Commit a4688bda authored by Nigel McNie's avatar Nigel McNie
Browse files

Use render_self for all artefacts in the profileinfo and contactinfo blocktypes.

(cherry picked from commit 73b541f20fcc6d29316bbc52ad9563a81152e96c)
parent 25c544f4
......@@ -58,16 +58,13 @@ class PluginBlocktypeContactinfo extends PluginBlocktype {
// Get data about the profile fields in this blockinstance
if (!empty($configdata['artefactids'])) {
$artefactids = implode(', ', array_map('db_quote', $configdata['artefactids']));
$profiledata = get_records_select_array('artefact',
'id IN (' . $artefactids . ') AND owner = (SELECT owner FROM {view} WHERE id = ?)',
array($instance->get('view')),
'',
'artefacttype, title'
);
foreach ($profiledata as $profilefield) {
$data[$profilefield->artefacttype] = $profilefield->title;
$viewowner = get_field('view', 'owner', 'id', $instance->get('view'));
foreach ($configdata['artefactids'] as $id) {
$artefact = artefact_instance_from_id($id);
if ($artefact->get('owner') == $viewowner) {
$rendered = $artefact->render_self(array('link' => true));
$data[$artefact->get('artefacttype')] = $rendered['html'];
}
}
}
......
<ul>
{foreach from=$profileinfo key=key item=item}
<li><strong>{str tag=$key section=artefact.internal}:</strong>
{if $key == 'email'}
<a href="mailto:{$item|escape}">{$item|escape}</a>
{elseif $key == 'country'}
{str tag=country.$item}
{elseif in_array($key, array('officialwebsite', 'personalwebsite', 'blogaddress'))}
<a href="{$item|escape}">{$item|str_shorten_text:50}</a>
{else}
{$item|escape}
{/if}</li>
<li><strong>{str tag=$key section=artefact.internal}:</strong> {$item}</li>
{/foreach}
</ul>
......@@ -58,16 +58,13 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
// Get data about the profile fields in this blockinstance
if (!empty($configdata['artefactids'])) {
$artefactids = implode(', ', array_map('db_quote', $configdata['artefactids']));
$profiledata = get_records_select_array('artefact',
'id IN (' . $artefactids . ') AND owner = (SELECT owner FROM {view} WHERE id = ?)',
array($instance->get('view')),
'',
'artefacttype, title'
);
foreach ($profiledata as $profilefield) {
$data[$profilefield->artefacttype] = $profilefield->title;
$viewowner = get_field('view', 'owner', 'id', $instance->get('view'));
foreach ($configdata['artefactids'] as $id) {
$artefact = artefact_instance_from_id($id);
if ($artefact->get('owner') == $viewowner) {
$rendered = $artefact->render_self(array('link' => true));
$data[$artefact->get('artefacttype')] = $rendered['html'];
}
}
}
......
......@@ -6,16 +6,7 @@
{if in_array($key, array('introduction'))}
{* Skip some fields *}
{else}
<li><strong>{str tag=$key section=artefact.internal}:</strong>
{if $key == 'email'}
<a href="mailto:{$item|escape}">{$item|escape}</a>
{elseif $key == 'country'}
{str tag=country.$item}
{elseif in_array($key, array('officialwebsite', 'personalwebsite', 'blogaddress'))}
<a href="{$item|escape}">{$item|str_shorten_text:50}</a>
{else}
{$item|escape}
{/if}</li>
<li><strong>{str tag=$key section=artefact.internal}:</strong> {$item}</li>
{/if}
{/foreach}
</ul>
......
Supports Markdown
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