Commit 4c567b3c authored by Lisa Seeto's avatar Lisa Seeto Committed by Robert Lyon

Bug 1762845: HTML export still contains the 'details' / 'add comment' links for blocks on the pages

- add in render_instance_export func for comment block
- remove non-export things in render_instance_export
- add check for export status when setting canedit var

behatnotneeded

Change-Id: I3f9ae3d82c0a69277e2e6e79404f73ad9d35e3ba
Signed-off-by: default avatarLisa Seeto <lisaseeto@catalyst.net.nz>
parent 02c99bab
......@@ -96,6 +96,20 @@ class PluginBlocktypeComment extends MaharaCoreBlocktype {
return $html;
}
public static function render_instance_export(BlockInstance $instance, $editing=false, $versioning=false, $exporting=null) {
global $USER;
$view = new View($instance->get('view'));
safe_require('artefact', 'comment');
$commentoptions = ArtefactTypeComment::get_comment_options();
$commentoptions->view = $instance->get_view();
$feedback = ArtefactTypeComment::get_comments($commentoptions);
$smarty = smarty_core();
$smarty->assign('feedback', $feedback);
$html = $smarty->fetch('blocktype:comment:comment.tpl');
return $html;
}
public static function has_instance_config() {
return false;
}
......
......@@ -787,7 +787,7 @@ class ArtefactTypeComment extends ArtefactType {
$is_export_preview = param_integer('export',0);
// Comment authors can edit recent comments if they're private or if no one has replied yet.
if (!$item->deletedby && $item->isauthor && !$is_export_preview && !$data->versioning
if (!$data->export && !$item->deletedby && $item->isauthor && !$is_export_preview && !$data->versioning
&& ($item->private || $item->id == $lastcomment->id) && $item->ts > $editableafter) {
$item->canedit = 1;
}
......
......@@ -50,6 +50,7 @@ interface IPluginBlocktype {
public static function get_categories();
public static function render_instance(BlockInstance $instance, $editing=false, $versioning=false);
public static function render_instance_export(BlockInstance $instance, $editing=false, $versioning=false, $exporting=null);
}
/**
......@@ -93,6 +94,10 @@ abstract class PluginBlocktype extends Plugin implements IPluginBlocktype {
return true;
}
public static function render_instance_export(BlockInstance $instance, $editing=false, $versioning=false, $exporting=null) {
return static::render_instance($instance, $editing, $versioning);
}
/**
* To define a pluginwide configuration
*/
......@@ -1322,6 +1327,14 @@ class BlockInstance {
$content = '';
$smarty->assign('loadbyajax', true);
}
else if ($exporting !== false) {
try {
$content = call_static_method($classname, 'render_instance_export', $this, false, $versioning, $exporting);
}
catch (NotFoundException $e) {
$content = '';
}
}
else {
$smarty->assign('loadbyajax', false);
try {
......
......@@ -71,7 +71,9 @@ 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';
// Create basic required directories
foreach (array('views', 'static', 'static/profileicons') as $directory) {
......@@ -478,12 +480,12 @@ class PluginExportHtml extends PluginExport {
}
if (!$view->uses_new_layout()) {
$smarty->assign('view', $outputfilter->filter($view->build_rows(false, true)));
$smarty->assign('view', $outputfilter->filter($view->build_rows(false, $this->exporttype)));
$smarty->assign('newlayout', false);
$smarty->assign('blocks', false);
}
else {
$blocks = $view->get_blocks(false, true);
$blocks = $view->get_blocks(false, $this->exporttype);
if ($blocks) {
foreach ($blocks as $bk => $bv) {
if (isset($blocks[$bk]['content'])) {
......
......@@ -72,6 +72,7 @@ class PluginExportLeap extends PluginExport {
public function __construct(User $user, $views, $artefacts, $progresshandler=null) {
parent::__construct($user, $views, $artefacts, $progresshandler);
$this->smarty = smarty_core();
$this->exporttype = 'leap';
if (!check_dir_exists($this->exportdir . '/' . $this->filedir)) {
throw new SystemException("Couldn't create the temporary export directory $this->exportdir");
}
......@@ -301,7 +302,7 @@ class PluginExportLeap extends PluginExport {
$this->smarty->assign('contenttype', 'xhtml');
if (!$view->uses_new_layout()) {
if ($viewcontent = self::parse_xhtmlish_content($view->build_rows(false, true), $view->get('id'))) {
if ($viewcontent = self::parse_xhtmlish_content($view->build_rows(false, $this->exporttype), $view->get('id'))) {
$this->smarty->assign('content', clean_html($viewcontent, true));
}
$this->smarty->assign('viewdata', $config['rows']);
......@@ -314,7 +315,7 @@ class PluginExportLeap extends PluginExport {
$this->smarty->assign('layout', $widths);
}
else {
if ($viewblocks = self::parse_xhtmlish_content($view->get_blocks(false, true), $view->get('id'))) {
if ($viewblocks = self::parse_xhtmlish_content($view->get_blocks(false, $this->exporttype), $view->get('id'))) {
$this->smarty->assign('content', clean_html($viewblocks, true));
$this->smarty->assign('blocks', $config['grid']);
}
......
......@@ -152,6 +152,12 @@ abstract class PluginExport extends Plugin implements IPluginExport {
*/
public $views = array();
/**
* The exporter type - to allow it to be used as a string variable
*/
public $exporttype;
/**
* Whether the user requested to export comments as well
*/
......
......@@ -2263,28 +2263,6 @@ class View {
}
else {
$result = $blockinstance->render_viewing($exporting, $versioning);
if ($exporting) {
// Blocks with toolbars will export with their info withing the block itself instead
$classname = generate_class_name('blocktype', $blockinstance->get('blocktype'));
$instanceinfo = call_static_method(
$classname,
'get_instance_toolbars',
$blockinstance
);
foreach($instanceinfo as $info) {
if (is_array($info)) {
if (isset($info['buttons'])) {
$result .= $info['buttons'];
}
if (isset($info['toolbarhtml'])) {
$result .= $info['toolbarhtml'];
}
}
else if (is_string($info)) {
$result .= $info;
}
}
}
$blockcontent .= $result;
}
}
......
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