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 {
}
}
// 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
$this->notify_progress_callback(55, get_string('exportingviews', 'export'));
$this->dump_view_export_data();
......@@ -345,25 +361,43 @@ class PluginExportHtml extends PluginExport {
private function get_view_summary() {
$smarty = $this->get_smarty('../');
$views = array();
foreach ($this->views as $view) {
$list = array();
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') {
$views[] = array(
$item = array(
'title' => $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) {
return strnatcasecmp($a['title'], $b['title']);
}
usort($views, 'sort_by_title');
$smarty->assign('views', $views);
foreach (array_keys($this->collections) as $id) {
usort($list['c' . $id]['views'], 'sort_by_title');
}
usort($list, 'sort_by_title');
$smarty->assign('list', $list);
if ($views) {
$stryouhaveviews = (count($views) == 1)
if ($list) {
$stryouhaveviews = ($nviews == 1)
? get_string('youhaveoneview', 'view')
: get_string('youhaveviews', 'view', count($views));
: get_string('youhaveviews', 'view', $nviews);
}
else {
$stryouhaveviews = get_string('youhavenoviews', 'view');
......
<p>{$stryouhaveviews}</p>
<ul>
{foreach from=$views item=view}
<li><a href="views/{$view.folder}/index.html">{$view.title}</a></li>
{foreach from=$list item=item}
{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}
</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