public function get_row(midcom_core_dbaobject $document) { $prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); $entry = array(); $entry['id'] = $document->id; $entry['index_title'] = $document->title; $entry['index_filesize'] = 0; $entry['filesize'] = ''; $entry['mimetype'] = ''; $icon = MIDCOM_STATIC_URL . '/stock-icons/mime/gnome-text-blank.png'; $alt = ''; $att = $document->load_attachment(); if ($att) { $icon = midcom_helper_misc::get_mime_icon($att->mimetype); $alt = $att->name; $stats = $att->stat(); $entry['index_filesize'] = $stats[7]; $entry['filesize'] = midcom_helper_misc::filesize_to_string($stats[7]); $entry['mimetype'] = org_openpsa_documents_document_dba::get_file_type($att->mimetype); } $title = '<a class="tab_escape" href="' . $prefix . 'document/' . $document->guid . '/"><img src="' . $icon . '"'; $title .= 'alt="' . $alt . '" style="border: 0px; height: 16px; vertical-align: middle" /> ' . $document->title . '</a>'; $entry['title'] = $title; $entry['created'] = strftime('%Y-%m-%d %X', $document->metadata->created); $entry['index_author'] = ''; $entry['author'] = ''; if ($document->author) { $author = org_openpsa_contacts_person_dba::get_cached($document->author); $entry['index_author'] = $author->rname; $author_card = org_openpsa_widgets_contact::get($author->guid); $entry['author'] = $author_card->show_inline(); } return $entry; }
<?php $view = $data['document_dm']; $att = $data['document_attachment']; $document_type = midcom_helper_misc::filesize_to_string($att['filesize']) . ' ' . org_openpsa_documents_document_dba::get_file_type($att['mimetype']); $nap = new midcom_helper_nav(); $node = $nap->get_node($nap->get_current_node()); $score = round($data['document_search']->score * 100); $url = $data['document_search']->topic_url . 'document/' . $data['document']->guid . '/'; // MIME type $icon = MIDCOM_STATIC_URL . '/stock-icons/mime/gnome-text-blank.png'; if ($att) { $icon = midcom_helper_misc::get_mime_icon($att['mimetype']); } ?> <dt><a href="&(url);"><?php echo $view['title']; ?> </a></dt> <dd> <?php if ($icon) { ?> <div class="icon"><a style="text-decoration: none;" href="&(node[MIDCOM_NAV_FULLURL]);document/<?php echo $data['document']->guid; ?> /"><img src="&(icon);" <?php if ($view['document']) { echo 'title="' . $document_type . '" '; } ?>
public static function render_fileinfo($object, $field) { $output = ''; $identifiers = explode(',', $object->get_parameter('midcom.helper.datamanager2.type.blobs', 'guids_' . $field)); if (empty($identifiers)) { return $output; } $host_prefix = midcom::get()->get_host_prefix(); foreach ($identifiers as $identifier) { $parts = explode(':', $identifier); if (sizeof($parts) != 2) { continue; } $guid = $parts[1]; try { $attachment = new midcom_db_attachment($guid); $url = $host_prefix . '/midcom-serveattachmentguid-' . $attachment->guid . '/' . $attachment->name; $stat = $attachment->stat(); $filesize = midcom_helper_misc::filesize_to_string($stat[7]); $mimetype = org_openpsa_documents_document_dba::get_file_type($attachment->mimetype); $mimetype_icon = midcom_helper_misc::get_mime_icon($attachment->mimetype); $output .= '<span class="org_openpsa_helpers_fileinfo">'; $output .= '<a href="' . $url . '" class="icon"><img src="' . $mimetype_icon . '" alt="' . $mimetype . '" /></a>'; $output .= '<a href="' . $url . '" class="filename">' . $attachment->name . '</a>'; $output .= '<span class="mimetype">' . $mimetype . '</span>'; $output .= '<span class="filesize">' . $filesize . '</span>'; $output .= "</span>\n"; } catch (midcom_error $e) { $e->log(); continue; } $output .= ''; } return $output; }