Commit 2980d23e authored by Stacey Walker's avatar Stacey Walker Committed by Gerrit Code Review
Browse files

new const for exporting collections and views separately (bug #825311)



Change-Id: I1feebe2f977d76e0c090a725232ad936eafdd851
Signed-off-by: default avatarStacey Walker <stacey@catalyst-eu.net>
parent 2d7b5468
......@@ -32,7 +32,8 @@ class HtmlExportInternal extends HtmlExportArtefactPlugin {
private $profileviewexported = false;
public function dump_export_data() {
if ($this->exporter->get('viewexportmode') == PluginExport::EXPORT_LIST_OF_VIEWS
if (($this->exporter->get('viewexportmode') == PluginExport::EXPORT_LIST_OF_VIEWS
|| $this->exporter->get('viewexportmode') == PluginExport::EXPORT_COLLECTIONS)
&& $this->exporter->get('artefactexportmode') == PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS) {
// Dont' care about profile information in this case
return;
......
......@@ -33,7 +33,8 @@ defined('INTERNAL') || die();
class HtmlExportResume extends HtmlExportArtefactPlugin {
public function dump_export_data() {
if ($this->exporter->get('viewexportmode') == PluginExport::EXPORT_LIST_OF_VIEWS
if (($this->exporter->get('viewexportmode') == PluginExport::EXPORT_LIST_OF_VIEWS
|| $this->exporter->get('viewexportmode') == PluginExport::EXPORT_COLLECTIONS)
&& $this->exporter->get('artefactexportmode') == PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS) {
// Dont' care about resume in this case
return;
......
......@@ -95,6 +95,9 @@ case 'all':
case 'views':
$exporter = new $class($user, $exportdata['views'], PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS, 'export_iframe_progress_handler');
break;
case 'collections':
$exporter = new $class($user, $exportdata['views'], PluginExport::EXPORT_COLLECTIONS, 'export_iframe_progress_handler');
break;
default:
export_iframe_die(get_string('unabletoexportportfoliousingoptions', 'export'));
}
......
......@@ -172,7 +172,8 @@ class PluginExportHtml extends PluginExport {
$artefactexporter = new $classname($this);
$artefactexporter->dump_export_data();
// If just exporting a list of views, we don't care about the summaries for each artefact plugin
if (!($this->viewexportmode == PluginExport::EXPORT_LIST_OF_VIEWS && $this->artefactexportmode == PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS)) {
if (!(($this->viewexportmode == PluginExport::EXPORT_LIST_OF_VIEWS || $this->viewexportmode == PluginExport::EXPORT_COLLECTIONS)
&& $this->artefactexportmode == PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS)) {
$summaries[$plugin] = array($artefactexporter->get_summary_weight(), $artefactexporter->get_summary());
}
}
......@@ -386,7 +387,7 @@ class PluginExportHtml extends PluginExport {
}
// Collection menu data
if (isset($this->viewcollection[$viewid])) {
if (isset($this->viewcollection[$viewid]) && $this->viewexportmode == PluginExport::EXPORT_COLLECTIONS) {
$smarty->assign_by_ref('collectionname', $this->collections[$this->viewcollection[$viewid]]->get('name'));
$smarty->assign_by_ref('collectionmenu', $this->collection_menu($this->viewcollection[$viewid]));
$smarty->assign('viewid', $viewid);
......@@ -423,6 +424,7 @@ class PluginExportHtml extends PluginExport {
);
}
$ncollections = count($this->collections);
$nviews = 0;
foreach ($this->views as $id => $view) {
if ($view->get('type') != 'profile') {
......@@ -449,9 +451,22 @@ class PluginExportHtml extends PluginExport {
$smarty->assign('list', $list);
if ($list) {
$stryouhaveviews = ($nviews == 1)
? get_string('youhaveoneview', 'view')
: get_string('youhaveviews', 'view', $nviews);
if ($this->viewexportmode != PluginExport::EXPORT_COLLECTIONS) {
$stryouhaveviews = ($nviews == 1)
? get_string('youhaveoneview', 'view')
: get_string('youhaveviews', 'view', $nviews);
}
else {
$stryouhavecollections = ($ncollections == 1)
? get_string('youhaveonecollection', 'collection')
: get_string('youhavecollections', 'collection', $ncollections);
$smarty->assign('stryouhavecollections', $stryouhavecollections);
return array(
'title' => get_string('Collections', 'collection'),
'description' => $smarty->fetch('export:html:collectionsummary.tpl'),
);
}
}
else {
$stryouhaveviews = get_string('youhavenoviews', 'view');
......
<p>{$stryouhavecollections}</p>
<ul>
{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>
<p>{$stryouhaveviews}</p>
<ul>
{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>
{if $item.views}
{foreach from=$item.views item=view}
<li><a href="views/{$view.folder}/index.html">{$view.title}</a></li>
{/foreach}
</ul>
</li>
{/if}
{/foreach}
</ul>
......@@ -175,7 +175,6 @@ function export_submit(Pieform $form, $values) {
$views = array_merge($views, get_column('collection_view', 'view', 'collection', $collection));
}
}
$values['what'] = 'views';
}
$exportdata = array(
......
......@@ -128,7 +128,9 @@ class PluginExportLeap extends PluginExport {
$this->export_header();
$this->setup_links();
$this->notify_progress_callback(10, get_string('exportingviews', 'export'));
$this->export_collections();
if ($this->viewexportmode == PluginExport::EXPORT_COLLECTIONS) {
$this->export_collections();
}
$this->export_views();
$this->notify_progress_callback(50, get_string('exportingartefacts', 'export'));
$this->export_artefacts();
......
......@@ -70,6 +70,11 @@ abstract class PluginExport extends Plugin {
*/
const EXPORT_LIST_OF_ARTEFACTS = -5;
/*
* Export only certain collections and their artefacts
*/
const EXPORT_COLLECTIONS = -6;
/**
* Maximum filename length in UTF-8 encoding characters
* Most file systems (FAT, FAT32, NTFS, ext2, ext3, ext4) support the filename length of 255 bytes
......@@ -158,6 +163,7 @@ abstract class PluginExport extends Plugin {
* @param mixed $artefacts can be:
* - PluginExport::EXPORT_ALL_ARTEFACTS
* - PluginExport::EXPORT_ARTEFACTS_FOR_VIEWS
* - PluginExport::EXPORT_COLLECTIONS
* - array, containing:
* - int - artefact ids
* - stdclass objects - db rows
......@@ -186,6 +192,10 @@ abstract class PluginExport extends Plugin {
$tmpviews = get_column_sql('SELECT id FROM {view} WHERE owner = ? ORDER BY id', array($userid));
$this->viewexportmode = $views;
}
else if (is_array($views) && $artefacts == self::EXPORT_COLLECTIONS) {
$tmpviews = $views;
$this->viewexportmode = self::EXPORT_COLLECTIONS;
}
else if (is_array($views)) {
$tmpviews = $views;
$this->viewexportmode = self::EXPORT_LIST_OF_VIEWS;
......@@ -240,6 +250,9 @@ abstract class PluginExport extends Plugin {
if ($artefacts == self::EXPORT_ARTEFACTS_FOR_VIEWS) {
$this->artefactexportmode = $artefacts;
}
else if ($artefacts == self::EXPORT_COLLECTIONS) {
$this->artefactexportmode = self::EXPORT_ARTEFACTS_FOR_VIEWS;
}
else {
$tmpartefacts = array_unique(array_merge($tmpartefacts, $artefacts));
$this->artefactexportmode = self::EXPORT_LIST_OF_ARTEFACTS;
......
......@@ -112,3 +112,5 @@ $string['copiedpagesblocksandartefactsfromtemplate'] = 'Copied %d pages, %d bloc
$string['copiedblogpoststonewjournal'] = 'Copied journal posts have been put into a new separate journal.';
$string['by'] = 'by';
$string['copycollection'] = 'Copy collection';
$string['youhaveonecollection'] = 'You have 1 collection.';
$string['youhavecollections'] = 'You have %s collections.';
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