Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions attachments_component/site/controllers/attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function display($cachable = false, $urlparams = false)
*/
public function displayString($parent_id, $parent_type, $parent_entity,
$title=null, $show_file_links=true, $allow_edit=true,
$echo=true, $from=null)
$echo=true, $from=null, $attachmentid=null)
{
$document = JFactory::getDocument();

Expand All @@ -95,7 +95,7 @@ public function displayString($parent_id, $parent_type, $parent_entity,
$model->setSortOrder($sort_order);

// If none of the attachments should be visible, exit now
if ( ! $model->someVisible() ) {
if ( ! $model->someVisible($attachmentid) ) {
return false;
}

Expand Down
7 changes: 4 additions & 3 deletions attachments_component/site/models/attachments.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function setSortOrder($new_sort_order)
*
* @return the list of attachments for this parent
*/
public function &getAttachmentsList()
public function &getAttachmentsList($attachmentid=null)
{
// Just return it if it has already been created
if ( $this->_list != null ) {
Expand Down Expand Up @@ -426,6 +426,7 @@ public function &getAttachmentsList()
}

$query->where('a.parent_type=' . $db->quote($parent_type) . ' AND a.parent_entity=' . $db->quote($parent_entity));
if ($attachmentid != null) $query->where('a.id = ' . $attachmentid);
if ( !$user->authorise('core.admin') ) {
$query->where('a.access IN ('.$user_levels.')');
}
Expand Down Expand Up @@ -500,7 +501,7 @@ public function numAttachments()
*
* @return true if there are attachments and some should be visible
*/
public function someVisible()
public function someVisible($attachmentid=null)
{
// See if the attachments list has been loaded
if ( $this->_list == null ) {
Expand All @@ -511,7 +512,7 @@ public function someVisible()
}

// Since the attachments have not been loaded, load them now
$this->getAttachmentsList();
$this->getAttachmentsList($attachmentid);
}

return $this->_some_visible;
Expand Down
12 changes: 8 additions & 4 deletions attachments_plugin_framework/attachments_plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -872,16 +872,19 @@ public function insertAttachmentsList(&$content, $parent_id, $parent_entity)
$attachments_tag = '';
$attachments_tag_args = '';
$match = false;
if (JString::strpos($content->$text_field_name, '{attachments'))
$offset = -1;
while ($offset != FALSE) {
if ($offset == -1) $offset = 0;
if ($offset = JString::strpos($content->$text_field_name, '{attachments', $offset))
{
if (preg_match('@(<span class="hide_attachments_token">)?{attachments([ ]*:*[^}]+)?}(</span>)?@', $content->$text_field_name, $match))
{
$attachments_tag = true;
}

if (isset($match[1]) && $match[1])
if (isset($match[2]) && $match[2])
{
$attachments_tag_args_raw = $match[1];
$attachments_tag_args_raw = $match[2];
$attachments_tag_args = ltrim($attachments_tag_args_raw, ' :');
}

Expand All @@ -908,7 +911,7 @@ public function insertAttachmentsList(&$content, $parent_id, $parent_entity)
// Get the html for the attachments list
require_once JPATH_SITE . '/components/com_attachments/controllers/attachments.php';
$controller = new AttachmentsControllerAttachments;
$attachments_list = $controller->displayString($parent_id, $this->parent_type, $parent_entity, null, true, true, false, $from);
$attachments_list = $controller->displayString($parent_id, $this->parent_type, $parent_entity, null, true, true, false, $from, $attachments_tag_args);

// If the attachments list is empty, insert an empty div for it
if ($attachments_list == '')
Expand Down Expand Up @@ -1007,6 +1010,7 @@ public function insertAttachmentsList(&$content, $parent_id, $parent_entity)
}
break;
}
} // while

return $content;
}
Expand Down