Commit 39714775 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Merge branch 'master' of git@gitorious.org:mahara/mahara

parents b3e97a9b 9472fb76
......@@ -65,6 +65,7 @@ class PluginBlocktypeBlog extends PluginBlocktype {
require_once(get_config('docroot') . 'artefact/lib.php');
$blog = $instance->get_artefact_instance($configdata['artefactid']);
$configdata['hidetitle'] = true;
$configdata['countcomments'] = true;
$configdata['viewid'] = $instance->get('view');
if ($instance->get_view()->is_submitted()) {
// Don't display posts added after the submitted date.
......
......@@ -64,6 +64,7 @@ class PluginBlocktypeBlogpost extends PluginBlocktype {
require_once(get_config('docroot') . 'artefact/lib.php');
$blogpost = $instance->get_artefact_instance($configdata['artefactid']);
$configdata['hidetitle'] = true;
$configdata['countcomments'] = true;
$configdata['viewid'] = $instance->get('view');
$result = $blogpost->render_self($configdata);
$result = $result['html'];
......
......@@ -50,26 +50,35 @@ var ImageDialog = {
// Get image list from calling window
document.getElementById('image_list_container').innerHTML = this.imageSelectorHTML(f.src.value);
// Check if the image attached
if (e.nodeName == 'IMG' && f.image_list.selectedIndex == 0) {
f.img_src.value = f.src.value;
}
// Refresh
this.getImageData(f.image_list.options[f.image_list.selectedIndex].value);
},
imageSelectorHTML : function(src) {
var imageid = tinyMCEPopup.getWin().imageIdFromSrc(src);
var imagefiles = tinyMCEPopup.getWin().imageList;
var disabled = '';
if (imagefiles.length == 0) {
return '';
disabled = 'disabled';
}
else {
var sel = '<select class="select" name="image_list" id="image_list" onchange="this.form.src.value=this.options[this.selectedIndex].value;ImageDialog.resetImageData();ImageDialog.getImageData(this.form.src.value);">';
sel += '<option value="">--</option>';
for (var i = 0; i < imagefiles.length; i++) {
sel += '<option value="' + imagefiles[i].id + '"';
if (imageid == imagefiles[i].id) {
sel += ' selected';
}
sel += '>' + imagefiles[i].name + '</option>';
var sel = '<select class="select" name="image_list" id="image_list" ' + disabled + ' onchange="this.form.src.value=this.options[this.selectedIndex].value;ImageDialog.resetImageData();ImageDialog.getImageData(this.form.src.value);">';
sel += '<option value="">--</option>';
for (var i = 0; i < imagefiles.length; i++) {
sel += '<option value="' + imagefiles[i].id + '" title="' + imagefiles[i].description + '"';
if (imageid == imagefiles[i].id) {
sel += ' selected';
}
return sel;
sel += '>' + imagefiles[i].name + '</option>';
}
return sel;
},
update : function() {
......@@ -241,7 +250,7 @@ var ImageDialog = {
resetImageData : function() {
var f = document.forms[0];
f.width.value = f.height.value = "";
f.width.value = f.height.value = f.alt.value = "";
},
updateImageData : function() {
......@@ -256,18 +265,32 @@ var ImageDialog = {
getImageData : function(imageid) {
var f = document.forms[0];
var imgsrc = '';
this.preloadImg = new Image();
this.preloadImg.onload = this.updateImageData;
this.preloadImg.onerror = this.resetImageData;
var imgsrc = tinyMCEPopup.getWin().imageSrcFromId(imageid);
f.src.value = imgsrc;
if (f.image_list.options[f.image_list.selectedIndex].childNodes[0].nodeValue &&
typeof(f.image_list.options[f.image_list.selectedIndex].childNodes[0].nodeValue) == 'string') {
f.alt.value = f.image_list.options[f.image_list.selectedIndex].childNodes[0].nodeValue;
if (imageid) {
// Image list
imgsrc = tinyMCEPopup.getWin().imageSrcFromId(imageid);
f.src.value = imgsrc;
// Use discription of attached image if possible, but preserve if it was changed.
if (f.image_list.options[f.image_list.selectedIndex].title && !f.alt.value.length) {
f.alt.value = f.image_list.options[f.image_list.selectedIndex].title;
}
else if (f.image_list.selectedIndex && !f.alt.value.length) {
f.alt.value = f.image_list.options[f.image_list.selectedIndex].childNodes[0].nodeValue;
}
// Disable img_src inputbox
f.img_src.disabled = true;
}
else {
// Image URL
f.img_src.disabled = false;
f.image_list.disabled = (f.img_src.value.length || f.image_list.options.length == 1) ? true : false;
imgsrc = f.src.value;
}
f.imgid.value = imageid;
this.preloadImg.src = imgsrc;
}
......
......@@ -78,7 +78,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
// Get entries that this blog/selection feels are a part of it
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'has_part') && isset($link['href'])) {
if ($importer->curie_equals($link['rel'], $importer->get_leap2a_namespace(), 'has_part') && isset($link['href'])) {
$otherrequiredentries[] = (string)$link['href'];
}
}
......@@ -181,23 +181,14 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
if (!isset($blogpostentry->link)) {
continue;
}
$blogpost = null;
foreach ($blogpostentry->link as $blogpostlink) {
$blogpost = null;
if ($importer->curie_equals($blogpostlink['rel'], '', 'enclosure') && isset($blogpostlink['href'])) {
if (!$blogpost) {
$artefactids = $importer->get_artefactids_imported_by_entryid((string)$blogpostentry->id);
$blogpost = new ArtefactTypeBlogPost($artefactids[0]);
}
$importer->trace("Attaching file $blogpostlink[href] to blog post $blogpostentry->id", PluginImportLeap::LOG_LEVEL_VERBOSE);
$artefactids = $importer->get_artefactids_imported_by_entryid((string)$blogpostlink['href']);
if (isset($artefactids[0])) {
$blogpost->attach($artefactids[0]);
} else { // it may be just an attached file, with no Leap2A element in its own right ....
if ($id = self::attach_linked_file($blogpostentry, $blogpostlink, $importer)) {
$blogpost->attach($id);
$newartefactmapping[(string)$blogpostlink['href']][] = $id;
}
}
if (!$blogpost) {
$artefactids = $importer->get_artefactids_imported_by_entryid((string)$blogpostentry->id);
$blogpost = new ArtefactTypeBlogPost($artefactids[0]);
}
if ($id = $importer->create_attachment($entry, $blogpostlink, $blogpost)) {
$newartefactmapping[$link['href']][] = $id;
}
if ($blogpost) {
$blogpost->commit();
......@@ -215,15 +206,8 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
}
$blogpost = new ArtefactTypeBlogPost($blogpostids[0]);
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href'])) {
if (isset($artefactids[0])) {
$blogpost->attach($artefactids[0]);
} else {
if ($id = self::attach_linked_file($entry, $link, $importer)) {
$blogpost->attach($id);
$newartefactmapping[(string)$link['href']][] = $id;
}
}
if ($id = $importer->create_attachment($entry, $link, $blogpost)) {
$newartefactmapping[$link['href']][] = $id;
}
}
$blogpost->commit();
......@@ -320,7 +304,7 @@ class LeapImportBlog extends LeapImportArtefactPlugin {
$blogpost->set('title', (string)$entry->title);
// If the entry has out of line content, we import that separately as a
// file and set the content to refer to it
if (isset($entry->content['src']) && isset($entry->content['type'])) {
if (LeapImportFile::is_file($entry, $importer)) {
$file = LeapImportFile::create_file($entry, $importer);
$createdartefacts[] = $file->get('id');
......
......@@ -126,6 +126,9 @@ $string['texttop'] = 'Text top';
$string['textbottom'] = 'Text bottom';
$string['left'] = 'Left';
$string['right'] = 'Right';
$string['src'] = 'Image URL';
$string['image_list'] = 'Attached image';
$string['alt'] = 'Description';
$string['copyfull'] = 'Others will get their own copy of your %s';
$string['copyreference'] = 'Others may display your %s in their View';
......
......@@ -512,11 +512,14 @@ class ArtefactTypeBlogPost extends ArtefactType {
public function render_self($options) {
$smarty = smarty_core();
$artefacturl = get_config('wwwroot') . 'view/artefact.php?artefact=' . $this->get('id');
if (isset($options['viewid'])) {
$artefacturl .= '&view=' . $options['viewid'];
}
$smarty->assign('artefacturl', $artefacturl);
if (empty($options['hidetitle'])) {
if (isset($options['viewid'])) {
$smarty->assign('artefacttitle', '<a href="' . get_config('wwwroot') . 'view/artefact.php?artefact='
. $this->get('id') . '&amp;view=' . $options['viewid']
. '">' . hsc($this->get('title')) . '</a>');
$smarty->assign('artefacttitle', '<a href="' . $artefacturl . '">' . hsc($this->get('title')) . '</a>');
}
else {
$smarty->assign('artefacttitle', hsc($this->get('title')));
......@@ -528,6 +531,13 @@ class ArtefactTypeBlogPost extends ArtefactType {
if (isset($options['viewid'])) {
safe_require('artefact', 'file');
$postcontent = ArtefactTypeFolder::append_view_url($postcontent, $options['viewid']);
if (isset($options['countcomments']) && $this->allowcomments) {
safe_require('artefact', 'comment');
$empty = array();
$ids = array($this->id);
$commentcount = ArtefactTypeComment::count_comments($empty, $ids);
$smarty->assign('commentcount', $commentcount ? $commentcount[$this->id]->comments : 0);
}
}
$smarty->assign('artefactdescription', $postcontent);
$smarty->assign('artefact', $this);
......@@ -607,8 +617,8 @@ class ArtefactTypeBlogPost extends ArtefactType {
$data = get_records_sql_assoc('
SELECT
a.id, a.title, a.description, a.author, a.authorname, ' .
db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ",
a.locked, bp.published" . $from . '
db_format_tsfield('a.ctime', 'ctime') . ', ' . db_format_tsfield('a.mtime', 'mtime') . ',
a.locked, bp.published, a.allowcomments ' . $from . '
ORDER BY bp.published ASC, a.ctime DESC',
array($id),
$offset, $limit
......@@ -636,6 +646,13 @@ class ArtefactTypeBlogPost extends ArtefactType {
}
}
// Get comment counts
if (!empty($viewoptions['countcomments'])) {
safe_require('artefact', 'comment');
$viewids = array();
$commentcounts = ArtefactTypeComment::count_comments($viewids, array_keys($data));
}
// Format dates properly
foreach ($data as &$post) {
if (is_null($viewoptions)) {
......@@ -648,6 +665,9 @@ class ArtefactTypeBlogPost extends ArtefactType {
else {
$by = $post->author ? display_default_name($post->author) : $post->authorname;
$post->postedby = get_string('postedbyon', 'artefact.blog', $by, format_date($post->ctime));
if (isset($commentcounts)) {
$post->commentcount = isset($commentcounts[$post->id]) ? $commentcounts[$post->id]->comments : 0;
}
}
$post->ctime = format_date($post->ctime, 'strftimedaydatetime');
$post->mtime = format_date($post->mtime);
......
......@@ -188,78 +188,6 @@ $javascript = <<<EOF
// to select an image from the list of image files attached to the
// post.
// The contents of this function is stolen straight out of the tinyMCE
// code in tinymce/themes/advanced/editor_template_src.js
function getSelectedImgAttributes (editorid) {
var src = "", alt = "", border = "", hspace = "", vspace = "", width = "", height = "", align = "";
var title = "", onmouseover = "", onmouseout = "", action = "insert";
var img = tinyMCE.imgElement;
var inst = tinyMCE.getInstanceById(editorid);
if (tinyMCE.selectedElement != null && tinyMCE.selectedElement.nodeName.toLowerCase() == "img") {
img = tinyMCE.selectedElement;
tinyMCE.imgElement = img;
}
if (img) {
// Is it a internal MCE visual aid image, then skip this one.
if (tinyMCE.getAttrib(img, 'name').indexOf('mce_') == 0)
return true;
src = tinyMCE.getAttrib(img, 'src');
alt = tinyMCE.getAttrib(img, 'alt');
// Try polling out the title
if (alt == "")
alt = tinyMCE.getAttrib(img, 'title');
// Fix width/height attributes if the styles is specified
if (tinyMCE.isGecko) {
var w = img.style.width;
if (w != null && w != "")
img.setAttribute("width", w);
var h = img.style.height;
if (h != null && h != "")
img.setAttribute("height", h);
}
border = tinyMCE.getAttrib(img, 'border');
hspace = tinyMCE.getAttrib(img, 'hspace');
vspace = tinyMCE.getAttrib(img, 'vspace');
width = tinyMCE.getAttrib(img, 'width');
height = tinyMCE.getAttrib(img, 'height');
align = tinyMCE.getAttrib(img, 'align');
onmouseover = tinyMCE.getAttrib(img, 'onmouseover');
onmouseout = tinyMCE.getAttrib(img, 'onmouseout');
title = tinyMCE.getAttrib(img, 'title');
// Is realy specified?
if (tinyMCE.isMSIE) {
width = img.attributes['width'].specified ? width : "";
height = img.attributes['height'].specified ? height : "";
}
src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
// Use mce_src if defined
mceRealSrc = tinyMCE.getAttrib(img, 'mce_src');
if (mceRealSrc != "") {
src = mceRealSrc;
if (tinyMCE.getParam('convert_urls'))
src = eval(tinyMCE.settings['urlconverter_callback'] + "(src, img, true);");
}
action = "update";
}
return {'src' : src, 'alt' : alt, 'border' : border, 'hspace' : hspace, 'vspace' : vspace,
'width' : width, 'height' : height, 'align' : align, 'title' : title,
'onmouseover' : onmouseover, 'onmouseout' : onmouseout, 'action' : action};
}
// Get all the files in the attached files list that have been
// recognised as images. This function is called by the the popup
// window, but needs access to the attachment list on this page
......@@ -268,7 +196,7 @@ function attachedImageList() {
var attachments = editpost_filebrowser.selecteddata;
for (var a in attachments) {
if (attachments[a].artefacttype == 'image') {
images.push({'id': attachments[a].id, 'name': attachments[a].title});
images.push({'id': attachments[a].id, 'name': attachments[a].title, 'description': attachments[a].description});
}
}
return images;
......@@ -294,14 +222,10 @@ function blogpostImageWindow(ui, v) {
var t = tinyMCE.activeEditor;
imageList = attachedImageList();
if (imageList.length == 0) {
alert({$noimagesmessage});
return true;
}
var template = new Array();
template['file'] = '{$wwwroot}artefact/blog/image_popup.php?src=\{\$src\}';
template['file'] = '{$wwwroot}artefact/blog/image_popup.php';
template['width'] = 355;
template['height'] = 275 + (tinyMCE.isMSIE ? 25 : 0);
......
......@@ -39,6 +39,7 @@ if ($blockid = param_integer('block', null)) {
$bi = new BlockInstance($blockid);
$configdata = $bi->get('configdata');
$limit = isset($configdata['count']) ? $configdata['count'] : 5;
$configdata['countcomments'] = true;
$posts = ArtefactTypeBlogpost::get_posts($configdata['artefactid'], $limit, $offset, $configdata);
$template = 'artefact:blog:viewposts.tpl';
$pagination = array(
......
......@@ -5,6 +5,7 @@
<script language="javascript" type="text/javascript" src="{$WWWROOT}js/tinymce/utils/mctabs.js"></script>
<script language="javascript" type="text/javascript" src="{$WWWROOT}js/tinymce/utils/form_utils.js"></script>
<script language="javascript" type="text/javascript" src="{$WWWROOT}artefact/blog/image_popup.js"></script>
<link rel="stylesheet" href="{$WWWROOT}artefact/blog/theme/raw/static/style/style.css"></link>
<base target="_self" />
</head>
<body id="image" style="display: none">
......@@ -20,15 +21,22 @@
<!--input id="src" name="src" type="text" value="" style="width: 200px" onchange="getImageData();" /-->
<input id="src" name="src" type="hidden" value="" />
<input id="imgid" name="imgid" type="hidden" value="" />
<input id="alt" name="alt" type="hidden" value="" />
<div id="srcbrowsercontainer"></div>
<table border="0" cellpadding="4" cellspacing="0">
<tr>
<td class="nowrap"><label for="img_src">{str section=artefact.blog tag=src}</label></td>
<td><input id="img_src" name="img_src" type="text" value="" style="width: 200px" onchange="this.form.src.value=this.value;ImageDialog.getImageData();" onmouseup="this.onchange();" onkeyup="this.onchange();"/></td>
</tr>
<!-- Image list -->
<tr>
<td nowrap="nowrap"><label for="align">{str tag=image}</label></td>
<td nowrap="nowrap"><label for="image_list">{str section=artefact.blog tag=image_list}</label></td>
<td id="image_list_container"></td>
</tr>
<!-- /Image list -->
<tr>
<td class="nowrap"><label for="alt">{str section=artefact.blog tag=alt}</label></td>
<td><input id="alt" name="alt" type="text" value="" style="width: 200px" /></td>
</tr>
<tr>
<td nowrap="nowrap"><label for="align">{str section=artefact.blog tag=alignment}</label></td>
<td><select id="align" name="align">
......
......@@ -19,5 +19,8 @@
</tbody>
</table>
{/if}
<div class="postdetails">{$postedbyon}</div>
<div class="postdetails">{$postedbyon}
{if isset($commentcount) && $artefact->get('allowcomments')} | <a href="{$artefacturl}">{str tag=Comments section=artefact.comment} ({$commentcount})</a>{/if}</div>
</div>
</div>
......@@ -91,4 +91,9 @@
}
.attachments .unselect {
font-size: .9167em;
}
/* Insert Image Dialog */
#img_src[disabled=""] {
background-color: #F0F0EE;
}
\ No newline at end of file
......@@ -22,7 +22,8 @@
</tbody>
</table>
{/if}
<div class="postdetails">{$post->postedby}</div>
<div class="postdetails">{$post->postedby}
{if $options.viewid && $post->allowcomments} | <a href="{$WWWROOT}view/artefact.php?artefact={$post->id}&view={$options.viewid}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a>{/if}</div>
</td>
</tr>
{/foreach}
......@@ -90,7 +90,7 @@ class LeapImportComment extends LeapImportArtefactPlugin {
// Check that the entry 'reflects_on' something
$otherentries = array();
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'reflects_on') && isset($link['href'])) {
if ($importer->curie_equals($link['rel'], $importer->get_leap2a_namespace(), 'reflects_on') && isset($link['href'])) {
$otherentries[] = (string)$link['href'];
}
}
......@@ -172,7 +172,7 @@ class LeapImportComment extends LeapImportArtefactPlugin {
*/
public static function get_referent_entryid(SimpleXMLElement $entry, PluginImportLeap $importer) {
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'reflects_on') && isset($link['href'])) {
if ($importer->curie_equals($link['rel'], $importer->get_leap2a_namespace(), 'reflects_on') && isset($link['href'])) {
return (string)$link['href'];
}
}
......@@ -194,7 +194,7 @@ class LeapImportComment extends LeapImportArtefactPlugin {
*/
public static function setup_relationships(SimpleXMLElement $entry, PluginImportLeap $importer) {
$comment = null;
$newartefacts = array(); // save any newly created extra ones (eg enclosures)
$referentid = self::get_referent_entryid($entry, $importer);
// Link artefact comments; view comments are done later
......@@ -206,21 +206,18 @@ class LeapImportComment extends LeapImportArtefactPlugin {
// Attachments
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href'])) {
if (!$comment) {
$comment = self::get_comment_instance($entry, $importer);
}
$importer->trace("Attaching file $link[href] to comment $entry->id", PluginImportLeap::LOG_LEVEL_VERBOSE);
$artefactids = $importer->get_artefactids_imported_by_entryid((string)$link['href']);
if (isset($artefactids[0])) {
$comment->attach($artefactids[0]);
}
if (!$comment) {
$comment = self::get_comment_instance($entry, $importer);
}
if ($id = $importer->create_attachment($entry, $link, $comment)) {
$newartefacts[] = $id;
}
}
if ($comment) {
$comment->commit();
}
return $newartefacts;
}
/**
......
{foreach $files file}
<div title="{$file.title}">
<div class="fl"><a href="{$WWWROOT}{$file.downloadurl}" target="_blank"><img src="{$file.iconsrc}" alt=""></a></div>
<div class="fl"><a href="{$file.downloadurl}" target="_blank"><img src="{$file.iconsrc}" alt=""></a></div>
<div style="margin-left: 40px;">
<h4><a href="{$file.downloadurl}" target="_blank">{$file.title|str_shorten_text:20}</a></h4>
{if $file.description}<p>{$file.description}</p>{/if}
......
......@@ -53,11 +53,11 @@ class LeapExportElementFile extends LeapExportElement {
public function assign_smarty_vars() {
parent::assign_smarty_vars();
$this->smarty->assign('summary', $this->artefact->get('description'));
$this->smarty->assign('contentsrc', $this->exporter->get('filedir') . $this->filename);
}
public function add_attachments() {
$this->filename = $this->exporter->add_attachment($this->artefact->get_path(), $this->artefact->get('title'));
$this->add_enclosure_link($this->filename, $this->get_content_type());
}
public function get_content_type() {
......
......@@ -102,13 +102,30 @@ class LeapImportFile extends LeapImportArtefactPlugin {
* if it's of rdf:type rdf:resource. This may be more strict than necessary
* - possibly just having the content ouf of line should be enough.
*
* In the 2010-07 version of Leap2A, an entry is *also* a file, if it's in an enclosure link.
* However, since we have to support BC, those might actually be entries too, so we have to check
* to see if what's in there is actually something that exists as a key in the array of entry ids.
*
* @param SimpleXMLElement $entry The entry to check
* @param PluginImportLeap $importer The importer
* @return boolean Whether the entry is a file
*/
private static function is_file(SimpleXMLElement $entry, PluginImportLeap $importer) {
return PluginImportLeap::is_rdf_type($entry, $importer, 'resource')
&& isset($entry->content['src']);
public static function is_file(SimpleXMLElement $entry, PluginImportLeap $importer) {
if (PluginImportLeap::is_rdf_type($entry, $importer, 'resource')
&& isset($entry->content['src'])) {
return true;
}
else {
// go through all the links and look for enclsures
$filesfound = 0;
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href']) && !$importer->entry_exists((string)$link['href'])) {
$filesfound++;
}
}
return ($filesfound == 1);
}
return false;
}
/**
......@@ -141,7 +158,7 @@ class LeapImportFile extends LeapImportArtefactPlugin {
*/
private static function has_parent_folder(SimpleXMLElement $entry, PluginImportLeap $importer) {
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'is_part_of') && isset($link['href'])) {
if ($importer->curie_equals($link['rel'], $importer->get_leap2a_namespace(), 'is_part_of') && isset($link['href'])) {
$potentialfolder = $importer->get_entry_by_id((string)$link['href']);
if ($potentialfolder && self::is_folder($potentialfolder, $importer)) {
return true;
......@@ -169,7 +186,7 @@ class LeapImportFile extends LeapImportArtefactPlugin {
// Get entries that this folder feels are a part of it
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], PluginImportLeap::NS_LEAP, 'has_part') && isset($link['href'])) {
if ($importer->curie_equals($link['rel'], $importer->get_leap2a_namespace(), 'has_part') && isset($link['href'])) {
$child = $importer->get_entry_by_id((string)$link['href']);
if ($child) {
if (self::is_file($child, $importer) || self::is_folder($child, $importer)) {
......@@ -216,7 +233,24 @@ class LeapImportFile extends LeapImportArtefactPlugin {
// This means that it could have UTF8 characters in it, and the PHP
// documentation doesn't sound hopeful that urldecode will work with
// UTF8 characters
$pathname = urldecode((string)$entry->content['src']);
$pathname = false;
$description = '';
if (isset($entry->content['src'])) {
$pathname = urldecode((string)$entry->content['src']);
$filetype = (string)$entry->content['type'];
} else {
foreach ($entry->link as $link) {
if ($importer->curie_equals($link['rel'], '', 'enclosure') && isset($link['href']) && !$importer->entry_exists((string)$link['href'])) {
$pathname = urldecode((string)$link['href']);
$filetype = (string)$link['type'];
$description = strip_tags(PluginImportLeap::get_entry_content($entry, $importer)); // TODO do we have a better way of stripping tags? and why isn't this html anyway?
}
}
}
if (!$pathname) {
$importer->trace("WARNING: couldn't find a file for $entry->id ");
return;