Commit 66100ba3 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge changes from topic 'WR 331987 PDF export'

* changes:
  Bug 1826284: Allow more info to be displayed
  Bug 1826284: Allow PDF bulkexport to serve file correctly
  Bug 1826284: Allow either ghostscript or pdfunite to join pdfs
  Bug 1826284: My views block renders export different for pdf
  Bug 1826284: Plan block renders different for PDF export
  Bug 1826284: External media block renders different for PDF export
  Bug 1826284: Folder block renders different for PDF export
  Bug 1826284: Files to download block renders different for PDF export
  Bug 1826284: Gallery block renders export different for slideshow
  Bug 1826284: Pdf block renders export different for pdf
  Bug 1826284: Allow the exporttype to filter down to the block rendering
  Bug 1826284: Adding the pdf option to exports
  Bug 1826284: Generate a pdf file via chrome headless
parents 98c089e3 0307a929
......@@ -38,5 +38,6 @@ node_modules/
htdocs/.externalToolBuilders/
htdocs/auth/saml/extlib/simplesamlphp
htdocs/auth/saml/sp/resources
htdocs/lib/chrome-php
package-lock.json
*\:Zone.Identifier\:\$DATA
......@@ -73,6 +73,24 @@ else
@echo "Done!"
endif
pdfexportfile := $(shell ls -d htdocs/lib/chrome-php/headless-chromium-php-master 2>/dev/null)
cleanpdfexport:
@echo "Cleaning out PDF export files..."
rm -rf htdocs/lib/chrome-php
pdfexport: initcomposer
ifdef pdfexportfile
@echo "PDF export files already exists - doing nothing"
else
@echo "Pulling Headless-chromium-php from download ..."
@curl -sSL https://github.com/chrome-php/headless-chromium-php/archive/master.zip -o pdf_tmp.zip && unzip pdf_tmp.zip -d htdocs/lib/chrome-php && rm pdf_tmp.zip
@php external/composer.phar --working-dir=htdocs/lib/chrome-php/headless-chromium-php-master install
@find htdocs/lib/chrome-php/headless-chromium-php-master -type f -name composer.json -delete
@find htdocs/lib/chrome-php/headless-chromium-php-master -type f -name composer.lock -delete
@find htdocs/lib/chrome-php -type d -name Tests -exec rm -r {} +
@echo "Done!"
endif
vendorphpunit := $(shell external/vendor/bin/phpunit --version 2>/dev/null)
......
......@@ -49,6 +49,7 @@ foreach (array_keys($plugins) as $plugin) {
'disableable' => call_static_method($classname, 'can_be_disabled'),
'deprecated' => call_static_method($classname, 'is_deprecated'),
'name' => call_static_method($classname, 'get_plugin_display_name'),
'dependencies' => call_static_method($classname, 'has_plugin_dependencies'),
'enableable' => call_static_method($classname, 'is_usable')
);
if (
......@@ -106,12 +107,21 @@ foreach (array_keys($plugins) as $plugin) {
validate_plugin($plugin, $dir);
$classname = generate_class_name($plugin, $dir);
$classname::sanity_check();
$name = call_static_method($classname, 'get_plugin_display_name');
$plugins[$plugin]['notinstalled'][$dir]['name'] = $name;
$plugins[$plugin]['notinstalled'][$dir]['name'] = call_static_method($classname, 'get_plugin_display_name');
$plugins[$plugin]['notinstalled'][$dir]['dependencies'] = call_static_method($classname, 'has_plugin_dependencies');
}
catch (InstallationException $e) {
$plugins[$plugin]['notinstalled'][$dir]['notinstallable'] = $e->GetMessage();
}
// If there are 'required' dependencies then we mark the plugin notinstallable
if (isset($plugins[$plugin]['notinstalled'][$dir]['dependencies']['requires'])) {
if (isset($plugins[$plugin]['notinstalled'][$dir]['notinstallable'])) {
$plugins[$plugin]['notinstalled'][$dir]['notinstallable'] .= $plugins[$plugin]['notinstalled'][$dir]['dependencies']['requires'];
}
else {
$plugins[$plugin]['notinstalled'][$dir]['notinstallable'] = $plugins[$plugin]['notinstalled'][$dir]['dependencies']['requires'];
}
}
}
if ($plugin == 'artefact' && table_exists(new XMLDBTable('blocktype_installed'))) { // go check it for blocks as well
$btlocation = get_config('docroot') . $plugin . '/' . $dir . '/blocktype';
......
......@@ -123,7 +123,7 @@ $optionform = pieform(array(
'allowarchives' => array(
'type' => 'switchbox',
'title' => get_string('allowsarchives', 'group'),
'description' => get_string('allowsarchivesdescription', 'group'),
'description' => get_string('allowsarchivesdescription1', 'group'),
'defaultvalue' => $group_data->allowarchives,
'disabled' => !$group_data->submittableto,
),
......
......@@ -330,7 +330,7 @@ $siteoptionform = array(
'exporttoqueue' => array(
'type' => 'switchbox',
'title' => get_string('exporttoqueue', 'admin'),
'description' => get_string('exporttoqueuedescription2', 'admin'),
'description' => get_string('exporttoqueuedescription3', 'admin'),
'defaultvalue' => get_config('exporttoqueue'),
'disabled' => in_array('exporttoqueue', $OVERRIDDEN),
),
......
......@@ -15,6 +15,18 @@ require(dirname(dirname(dirname(__FILE__))) . '/init.php');
define('TITLE', get_string('bulkexporttitle1', 'admin'));
$exportplugins = plugins_installed('export');
if (!$exportplugins) {
die_info(get_string('noexportpluginsenabled', 'export'));
}
foreach ($exportplugins as $plugin) {
safe_require('export', $plugin->name);
$exportoptions[$plugin->name] = call_static_method(generate_class_name('export', $plugin->name), 'get_title');
}
$pdfrun = 'multi';
/**
* Convert a 2D array to a CSV file. This follows the basic rules from http://en.wikipedia.org/wiki/Comma-separated_values
*
......@@ -99,19 +111,30 @@ function create_zipfile($listing, $files) {
}
function bulkexport_submit(Pieform $form, $values) {
global $SESSION;
global $SESSION, $pdfrun;
$usernames = array();
// Read in the usernames explicitly specified
foreach (explode("\n", $values['usernames']) as $username) {
$username = trim($username);
if (!empty($username)) {
$usernames[] = $username;
if (!empty($values['usernames'])) {
foreach (explode("\n", $values['usernames']) as $username) {
$username = trim($username);
if (!empty($username) && record_exists('usr', 'username', $username)) {
$usernames[] = $username;
}
else {
log_debug(get_string('ignoringbulkexportuser', 'admin', $username));
}
}
if (empty($usernames)) {
// All explicit usernames were rejected
require_once(get_config('docroot') . '/lib/htmloutput.php');
print_export_iframe_die(get_string('bulkexportempty', 'admin'), null);
}
}
if (empty($usernames) && !empty($values['authinstance'])) {
if (empty($values['usernames']) && !empty($values['authinstance'])) {
// Export all users from the selected institution
$usernames = get_column_sql("SELECT username FROM {usr} WHERE authinstance = ? AND deleted = 0 AND id != 0", array($values['authinstance']));
}
......@@ -142,9 +165,25 @@ function bulkexport_submit(Pieform $form, $values) {
if ($exporttype == 'html') {
$exporter = new PluginExportHtml($user, PluginExport::EXPORT_ALL_VIEWS_COLLECTIONS, PluginExport::EXPORT_ALL_ARTEFACTS);
}
else if ($exporttype == 'pdf') {
if ($exportcount === 0 && $num_users === 1) {
$pdfrun = 'all';
}
else if ($exportcount === 0) {
$pdfrun = 'first';
}
else if ($num_users == ($exportcount + 1)) {
$pdfrun = 'last';
}
else {
$pdfrun = 'multi';
}
$exporter = new PluginExportPdf($user, PluginExport::EXPORT_ALL_VIEWS_COLLECTIONS, PluginExport::EXPORT_ALL_ARTEFACTS);
}
else {
$exporter = new PluginExportLeap($user, PluginExport::EXPORT_ALL_VIEWS_COLLECTIONS, PluginExport::EXPORT_ALL_ARTEFACTS);
}
try {
$exporter->export(true);
$zipfile = $exporter->export_compress();
......@@ -160,7 +199,8 @@ function bulkexport_submit(Pieform $form, $values) {
}
if (!$zipfile = create_zipfile($listing, $files)) {
export_iframe_die(get_string('bulkexportempty', 'admin'));
require_once(get_config('docroot') . '/lib/htmloutput.php');
print_export_iframe_die(get_string('bulkexportempty', 'admin'), null);
}
log_info("Exported $exportcount users to $zipfile");
......@@ -177,7 +217,12 @@ function bulkexport_submit(Pieform $form, $values) {
// Download the export file once it has been generated
require_once('file.php');
serve_file($zipfile, basename($zipfile), 'application/x-zip', array('lifetime' => 0, 'forcedownload' => true));
$mimetype = 'application/zip; charset=binary';
$options = array('lifetime' => 0, 'forcedownload' => true);
if ($exporttype == 'pdf') {
$options['overridecontenttype'] = 'none';
}
serve_file($zipfile, basename($zipfile), $mimetype, $options);
// TODO: delete the zipfile (and temporary files) once it's been downloaded
}
......@@ -211,8 +256,7 @@ $form = array(
'exporttype' => array(
'type' => 'select',
'title' => get_string('chooseanexportformat', 'export'),
'options' => array('leap' => 'Leap2A',
'html' => 'HTML'),
'options' => $exportoptions,
'defaultvalue' => 'leap'
),
'authinstance' => $authinstanceelement,
......
......@@ -25,7 +25,33 @@ class PluginBlocktypeFiledownload extends MaharaCoreBlocktype {
return array('fileimagevideo' => 3000);
}
public static function render_instance_export(BlockInstance $instance, $editing=false, $versioning=false, $exporting=null) {
if ($exporting != 'pdf') {
return self::render_instance($instance, $editing, $versioning);
}
// The exporting for pdf
$files = self::render_instance_data($instance, $editing, $versioning);
$smarty = smarty_core();
$smarty->assign('viewid', $instance->get('view'));
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('files', $files);
$smarty->assign('editing', $editing);
return $smarty->fetch('blocktype:filedownload:filedownload_pdfexport.tpl');
}
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$files = self::render_instance_data($instance, $editing, $versioning);
$smarty = smarty_core();
$smarty->assign('viewid', $instance->get('view'));
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('files', $files);
$smarty->assign('editing', $editing);
return $smarty->fetch('blocktype:filedownload:filedownload.tpl');
}
private static function render_instance_data(BlockInstance $instance, $editing=false, $versioning=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
require_once(get_config('docroot') . 'artefact/comment/lib.php');
......@@ -73,13 +99,7 @@ class PluginBlocktypeFiledownload extends MaharaCoreBlocktype {
$files[] = $file;
}
}
$smarty = smarty_core();
$smarty->assign('viewid', $instance->get('view'));
$smarty->assign('blockid', $instance->get('id'));
$smarty->assign('files', $files);
$smarty->assign('editing', $editing);
return $smarty->fetch('blocktype:filedownload:filedownload.tpl');
return $files;
}
public static function has_instance_config() {
......
......@@ -38,6 +38,28 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
return array('fileimagevideo' => 4000);
}
public static function render_instance_export(BlockInstance $instance, $editing=false, $versioning=false, $exporting=null) {
if ($exporting != 'pdf') {
return self::render_instance($instance, $editing, $versioning);
}
// The exporting for pdf
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
$configdata['viewid'] = $instance->get('view');
$configdata['simpledisplay'] = true;
$configdata['pdfexport'] = true; // pass down flag that we are in pdf export
list($result, $commentcount, $comments) = self::render_instance_data($instance, $editing, $versioning, $configdata);
$smarty = smarty_core();
if (isset($configdata['artefactid'])) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty = smarty_core();
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:folder:folder.tpl');
}
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
require_once(get_config('docroot') . 'artefact/lib.php');
$configdata = $instance->get('configdata');
......@@ -45,10 +67,23 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
$configdata['simpledisplay'] = true;
$configdata['blockid'] = $instance->get('id');
$configdata['editing'] = $editing;
list($result, $commentcount, $comments) = self::render_instance_data($instance, $editing, $versioning, $configdata);
$smarty = smarty_core();
if (isset($configdata['artefactid'])) {
$smarty->assign('commentcount', $commentcount);
$smarty->assign('comments', $comments);
}
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:folder:folder.tpl');
}
private static function render_instance_data(BlockInstance $instance, $editing=false, $versioning=false, $configdata=array()) {
// This can be either an image or profileicon. They both implement
// render_self
$result = '';
$commentcount = 0;
$comments = null;
$artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null;
if ($artefactid) {
$artefact = $instance->get_artefact_instance($artefactid);
......@@ -60,9 +95,7 @@ class PluginBlocktypeFolder extends MaharaCoreBlocktype {
$view = new View($configdata['viewid']);
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $view, $instance->get('id'), true, $editing, $versioning);
}
$smarty = smarty_core();
$smarty->assign('html', $result);
return $smarty->fetch('blocktype:folder:folder.tpl');
return array($result, $commentcount, $comments);
}
public static function has_config() {
......
......@@ -92,6 +92,66 @@ class PluginBlocktypeGallery extends MaharaCoreBlocktype {
);
}
public static function render_instance_export(BlockInstance $instance, $editing=false, $versioning=false, $exporting=null) {
if ($exporting != 'pdf') {
return self::render_instance($instance, $editing, $versioning);
}
// The exporting for pdf
$configdata = $instance->get('configdata'); // this will make sure to unserialize it for us
$viewid = $instance->get('view');
$style = isset($configdata['style']) ? intval($configdata['style']) : 2;
if ($style !== 1) {
// If not the slideshow then render in normal way
return self::render_instance($instance, $editing, $versioning);
}
else {
safe_require('artefact', 'file');
// Slideshow piles all the images on top of each other in PDF so we need to avoid this
if (isset($configdata['select']) && $configdata['select'] == 1 && is_array($configdata['artefactids'])) {
$artefactids = $configdata['artefactids'];
}
else if ($versioning && !empty($configdata['existing_artefacts'])) {
$artefactids = (array) $configdata['existing_artefacts'];
}
else if (!empty($configdata['artefactid'])) {
// Get descendents of this folder.
$artefactids = artefact_get_descendants(array(intval($configdata['artefactid'])));
}
$artefactids = $instance->order_artefacts_by_title($artefactids);
$html = '';
if ($artefactids) {
$firstdone = false;
foreach ($artefactids as $artefactid) {
$artefact = $instance->get_artefact_instance($artefactid);
if ($artefact->get('artefacttype') == 'folder') {
continue;
}
if (!file_exists($artefact->get_path())) {
continue;
}
$urlbase = get_config('wwwroot');
$url = $urlbase . 'artefact/file/download.php?file=' . $artefactid . '&view=' . $viewid;
$description = $artefact->get('description');
if (!$firstdone) {
$html .= '<div class="image"><img src="' . $url . '" alt="' . $artefact->get('title') . '"></div>';
if ($description) {
$html .= '<div class="card-body">' . $description . '</div>';
}
$html .= '<div class="text-midtone">' . get_string('notrendertopdf', 'artefact.file');
$html .= '<br>' . get_string('notrendertopdffiles', 'artefact.file', count($artefactids));
$firstdone = true;
}
$html .= '<br><a href="' . $url . '">' . $artefact->get('title') . '</a>';
}
$html .= '</div>';
}
return $html;
}
}
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
$configdata = $instance->get('configdata'); // this will make sure to unserialize it for us
$configdata['viewid'] = $instance->get('view');
......
......@@ -33,6 +33,38 @@ class PluginBlocktypePdf extends MaharaCoreBlocktype {
return array('fileimagevideo' => 8000);
}
public static function render_instance_export(BlockInstance $instance, $editing=false, $versioning=false, $exporting=null) {
if ($exporting != 'pdf') {
return self::render_instance($instance, $editing, $versioning);
}
// The exporting for PDF
require_once(get_config('docroot') . 'lib/view.php');
$configdata = $instance->get('configdata'); // this will make sure to unserialize it for us
$configdata['viewid'] = $instance->get('view');
$view = new View($configdata['viewid']);
$artefactid = isset($configdata['artefactid']) ? $configdata['artefactid'] : null;
$html = '';
if ($artefactid) {
$artefact = $instance->get_artefact_instance($configdata['artefactid']);
if (!file_exists($artefact->get_path())) {
return '';
}
$urlbase = get_config('wwwroot');
$url = $urlbase . 'artefact/file/download.php?file=' . $artefactid . '&view=' . $view->get('id');
$description = $artefact->get('description');
if ($description) {
$html .= '<div class="card-body">' . $description . '</div>';
}
$html .= '<div class="text-midtone">' . get_string('notrendertopdf', 'artefact.file');
$html .= '<br>' . get_string('notrendertopdffiles', 'artefact.file', 1);
// We need to add an <a> link so that the HTML export() sub-task makes a copy of the artefct for the export 'files/' directory
// We then override the link in the PDF pdf_view_export_data() function.
$html .= '<a href="' . $url . '">' . $artefact->get('title') . '</a>';
$html .= '</div>';
}
return $html;
}
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $USER;
require_once(get_config('docroot') . 'lib/view.php');
......
......@@ -385,3 +385,10 @@ $string['viruszipfile'] = 'Clam AV has found a file that is infected with a viru
$string['filetypenotallowed'] = 'Files with extension "%s" are not allowed.';
$string['filetypenotmatchingmimetype'] = 'The file extension does not match the file mimetype "%s".';
$string['validfiletypes'] = 'You can upload the following file types:';
$string['notrendertopdf'] = 'This block can not be rendered normally in the PDF export.';
$string['notrendertopdfview'] = 'The portfolio %s has been added as:';
$string['notrendertopdffiles'] = array(
'The file has been added to: ',
'The files have been added to: ',
);
$string['notrendertopdflink'] = 'The file can be accessed at: ';
......@@ -2213,8 +2213,8 @@ class ArtefactTypeFolder extends ArtefactTypeFileBase {
if (isset($options['blockid'])) {
$smarty->assign('blockid', $options['blockid']);
}
$template = 'artefact:file:folder_render_self.tpl';
if (isset($options['modal'])) {
$template = !empty($options['pdfexport']) ? 'artefact:file:folder_render_self_pdfexport.tpl' : 'artefact:file:folder_render_self.tpl';
if (isset($options['modal']) && !isset($options['pdfexport'])) {
$smarty->assign('modal', $options['modal']);
$template = 'artefact:file:folder_render_in_modal.tpl';
}
......
......@@ -60,8 +60,13 @@ class PluginBlocktypePlans extends MaharaCoreBlocktype {
safe_require('artefact','plans');
$configdata = $instance->get('configdata');
$limit = (!empty($configdata['count'])) ? $configdata['count'] : 10;
$smarty = smarty_core();
$limit = (!empty($configdata['count'])) ? $configdata['count'] : 10;
if ($exporter && get_class($exporter) == 'PluginExportPdf') {
$limit = 0;
$smarty->assign('pdfexport', true);
}
$plans = array();
$alltasks = array();
......@@ -106,6 +111,9 @@ class PluginBlocktypePlans extends MaharaCoreBlocktype {
$configdata['view'] = $instance->get('view');
$configdata['block'] = $blockid;
$configdata['versioning'] = $versioning;
if ($exporter && get_class($exporter) == 'PluginExportPdf') {
$configdata['pdfexport'] = true;
}
ArtefactTypeTask::render_tasks($tasks, $template, $configdata, $pagination, $editing, $versioning);
if (($exporter || $versioning) && $tasks['count'] > $tasks['limit']) {
$artefacturl = get_config('wwwroot') . 'view/view.php?id=' . $instance->get('view') .'&modal=1&artefact=' . $planid;
......
......@@ -122,6 +122,49 @@ class PluginBlocktypeExternalvideo extends MaharaCoreBlocktype {
return array('externalvideo' => array('media'));
}
public static function render_instance_export(BlockInstance $instance, $editing=false, $versioning=false, $exporting=null) {
if ($exporting != 'pdf') {
return self::render_instance($instance, $editing, $versioning);
}
$configdata = $instance->get('configdata');
// The exporting for pdf
$sources = self::load_media_sources();
$vidurl = preg_match('/"(https?:.*?)"/', $configdata['videoid'], $matches);
if (empty($matches[1])) {
// Can't work out what the url is
return self::render_instance($instance, $editing, $versioning);
}
$video = array();
$vidurl = $matches[1];
foreach ($sources as $name => $source) {
if ($video = $source->validate_url($vidurl)) {
break;
}
}
$html = '';
if (isset($video['vimeo'])) {
// Fetch the metadata for the video
$res = mahara_http_request(array(CURLOPT_URL => 'http://vimeo.com/api/v2/video/' . $video['vimeo'] . '.json'));
if ($res->info['http_code'] == '200') {
$json = json_decode($res->data);
if (isset($json[0]->thumbnail_large)) {
$html .= '<div class="image"><img src="' . $json[0]->thumbnail_large . '"></div>';
}
}
}
else if (isset($video['youtube'])) {
// We can fetch the thumbnail of the video and display that
$html .= '<div class="image"><img src="https://img.youtube.com/vi/' . $video['youtube'] . '/0.jpg"></div>';
}
$html .= '<div class="text-midtone">' . get_string('notrendertopdf', 'artefact.file');
$html .= '<br>' . get_string('notrendertopdflink', 'artefact.file');
// We need to add an <a> link so that the HTML export() sub-task makes a copy of the artefct for the export 'files/' directory
// We then override the link in the PDF pdf_view_export_data() function.
$html .= '<a class="" href="' . $vidurl . '">' . $instance->get('title') . '</a>';
$html .= '</div>';
return $html;
}
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false) {
global $THEME;
......
......@@ -18,8 +18,8 @@ class Media_vimeo implements MediaBase {
self::$iframe_sources = array(
array(
'match' => '#^http://player\.vimeo\.com/video/([0-9]+).*#',
'url' => $this->httpstr . '://player.vimeo.com/video/$1'
'match' => '#^https?://(player)\.vimeo\.com/video/([0-9]+).*#', // we do a dummy capture on 'player' so both this and the other one match ID at position $2
'url' => $this->httpstr . '://player.vimeo.com/video/$2'
),
array(
'match' => '#^https?://(www\.|secure\.)?vimeo\.com/([0-9]+)#',
......@@ -57,8 +57,8 @@ class Media_vimeo implements MediaBase {
public function validate_url($input) {
foreach (self::$iframe_sources as $source) {
if (preg_match($source['match'], $input)) {
return true;
if (preg_match($source['match'], $input, $matches)) {
return array('vimeo' => $matches[2]); // the type/id of the video
}
}
return false;
......
......@@ -64,8 +64,8 @@ class Media_youtube implements MediaBase {
public function validate_url($input) {
foreach (self::$iframe_sources as $source) {
if (preg_match($source['match'], $input)) {
return true;
if (preg_match($source['match'], $input, $matches)) {
return array('youtube' => $matches[2]); // the type/id of the video
}
}
return false;
......
......@@ -37,6 +37,30 @@ class PluginBlocktypeMyviews extends MaharaCoreBlocktype {
return array('profile', 'dashboard');
}
public static function render_instance_export(BlockInstance $instance, $editing=false, $versioning=false, $exporting=null) {
if ($exporting != 'pdf') {
return self::render_instance($instance, $editing, $versioning);
}
$userid = $instance->get_view()->get('owner');
if (!$userid) {
return '';
}
// Get viewable views
$views = View::view_search(null, null, (object) array('owner' => $userid), null,
0, 0, true, null, array('portfolio'), null, null, null, null, null, true);
$views = (array)$views;
foreach ($views['data'] as $k => $view) {
$views['data'][$k]['fileurl'] = './' . $view['id'] . '_' . $view['urlid'] . '.pdf';
}
$smarty = smarty_core();
$smarty->assign('options', array());
$smarty->assign('items', $views['data']);
$views['tablerows'] = $smarty->fetch('blocktype:myviews:myviews_pdfexport.tpl');
return $views['tablerows'];
}
/**
* This function renders a list of items views as html
*
......
......@@ -71,7 +71,6 @@ class PluginExportHtml extends PluginExport {
public function __construct(User $user, $views, $artefacts, $progresscallback=null) {
global $THEME;
parent::__construct($user, $views, $artefacts, $progresscallback);
$this->rootdir = 'HTML';
$this->exporttype = 'html';
......@@ -416,7 +415,7 @@ class PluginExportHtml extends PluginExport {
/**
* Dumps all views into the HTML export
*/
private function dump_view_export_data() {
protected function dump_view_export_data() {
safe_require('artefact', 'comment');
$progressstart = 55;
$progressend = 75;
......@@ -440,9 +439,6 @@ class PluginExportHtml extends PluginExport {
array('text' => $view->get('title'), 'path' => 'index.html'),
));
$directory = $this->exportdir . '/' . $this->rootdir . '/views/' . $view->get('id') . '_' . self::text_to_filename($view->get('title'));
if (is_dir($directory)) {
throw new SystemException(get_string('duplicatepagetitle', 'export.html'));
}
if (!check_dir_exists($directory)) {
throw new SystemException("Could not create directory for view $viewid");
}
......@@ -497,6 +493,7 @@ class PluginExportHtml extends PluginExport {
$smarty->assign('blocks', $blocks);
$smarty->assign('view', false);
}
$content = $smarty->fetch('export:html:view.tpl');
if (!file_put_contents("$directory/index.html", $content)) {
throw new SystemException("Could not write view page for view $viewid");
......@@ -517,7 +514,7 @@ class PluginExportHtml extends PluginExport {
* 'description' => ...
* )
*/
private function get_view_collection_summary() {
protected function get_view_collection_summary() {
$list = array();
foreach ($this->collections as $id => $collection) {
......@@ -689,15 +686,17 @@ class PluginExportHtml extends PluginExport {
*/
private function get_resume_field_modals(&$idarray, BlockInstance $bi) {
$configdata = $bi->get('configdata');
$field = $bi->get_artefact_instance($configdata['artefactid']);
$attachmentids = array();
if ($attachment = $field->get_attachments()) {
foreach ($attachment as $a) {
array_push($attachmentids, $a->{'id'});
if (isset($configdata['artefactid'])) {
$field = $bi->get_artefact_instance($configdata['artefactid']);
$attachmentids = array();
if ($attachment = $field->get_attachments()) {
foreach ($attachment as $a) {
array_push($attachmentids, $a->{'id'});
}
}
if (!empty($attachmentids)) {
$idarray = array_merge($idarray, $attachmentids);
}
}
if (!empty($attachmentids)) {
$idarray = array_merge($idarray, $attachmentids);
}
}
......@@ -840,7 +839,7 @@ private function get_folder_modals(&$idarray, BlockInstance $bi) {
/**
* Copies the static files (stylesheets etc.) into the export
*/
private function copy_static_files() {
protected function copy_static_files() {
global $THEME, $SESSION;
require_once('file.php');
$staticdir = $this->get('exportdir') . '/' . $this->get('rootdir') . '/static/';
......
......@@ -73,6 +73,7 @@ class PluginExportLeap extends PluginExport {
parent::__construct($user, $views, $artefacts, $progresshandler);
$this->smarty = smarty_core();
$this->exporttype = 'leap';
if (!check_dir_exists($this->exportdir . '/' . $this->filedir)) {