Commit 7a43ff77 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Group views by collection in html export view summary (bug #617125)


Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent cf6eab67
...@@ -177,6 +177,22 @@ class PluginExportHtml extends PluginExport { ...@@ -177,6 +177,22 @@ class PluginExportHtml extends PluginExport {
} }
} }
// Views in collections
if (!$this->exportingoneview && $this->collections) {
$viewlist = join(',', array_keys($this->views));
$collectionlist = join(',', array_keys($this->collections));
$records = get_records_select_array(
'collection_view',
"view IN ($viewlist) AND collection IN ($collectionlist)"
);
if ($records) {
foreach ($records as &$r) {
$this->collectionview[$r->collection][] = $r->view;
$this->viewcollection[$r->view] = $r->collection;
}
}
}
// Get the view data // Get the view data
$this->notify_progress_callback(55, get_string('exportingviews', 'export')); $this->notify_progress_callback(55, get_string('exportingviews', 'export'));
$this->dump_view_export_data(); $this->dump_view_export_data();
...@@ -345,25 +361,43 @@ class PluginExportHtml extends PluginExport { ...@@ -345,25 +361,43 @@ class PluginExportHtml extends PluginExport {
private function get_view_summary() { private function get_view_summary() {
$smarty = $this->get_smarty('../'); $smarty = $this->get_smarty('../');
$views = array(); $list = array();
foreach ($this->views as $view) { foreach ($this->collections as $id => $collection) {
$list['c' . $id] = array(
'title' => $collection->get('name'),
'views' => array(),
);
}
$nviews = 0;
foreach ($this->views as $id => $view) {
if ($view->get('type') != 'profile') { if ($view->get('type') != 'profile') {
$views[] = array( $item = array(
'title' => $view->get('title'), 'title' => $view->get('title'),
'folder' => self::text_to_path($view->get('title')), 'folder' => self::text_to_path($view->get('title')),
); );
if (isset($this->viewcollection[$id])) {
$list['c' . $this->viewcollection[$id]]['views'][] = $item;
}
else {
$list[$id] = $item;
}
$nviews++;
} }
} }
function sort_by_title($a, $b) { function sort_by_title($a, $b) {
return strnatcasecmp($a['title'], $b['title']); return strnatcasecmp($a['title'], $b['title']);
} }
usort($views, 'sort_by_title'); foreach (array_keys($this->collections) as $id) {
$smarty->assign('views', $views); usort($list['c' . $id]['views'], 'sort_by_title');
}
usort($list, 'sort_by_title');
$smarty->assign('list', $list);
if ($views) { if ($list) {
$stryouhaveviews = (count($views) == 1) $stryouhaveviews = ($nviews == 1)
? get_string('youhaveoneview', 'view') ? get_string('youhaveoneview', 'view')
: get_string('youhaveviews', 'view', count($views)); : get_string('youhaveviews', 'view', $nviews);
} }
else { else {
$stryouhaveviews = get_string('youhavenoviews', 'view'); $stryouhaveviews = get_string('youhavenoviews', 'view');
......
<p>{$stryouhaveviews}</p> <p>{$stryouhaveviews}</p>
<ul> <ul>
{foreach from=$views item=view} {foreach from=$list item=item}
<li><a href="views/{$view.folder}/index.html">{$view.title}</a></li> {if $item.folder}
<li><a href="views/{$item.folder}/index.html">{$item.title}</a></li>
{elseif $item.views}
<li>{$item.title}
<ul>
{foreach from=$item.views item=view}
<li><a href="views/{$view.folder}/index.html">{$view.title}</a></li>
{/foreach}
</ul>
</li>
{/if}
{/foreach} {/foreach}
</ul> </ul>
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