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; }
function midgard_admin_asgard_trash_type_show($object, $indent = 0, $prefix = '', $enable_undelete = true) { static $persons = array(); static $shown = array(); static $url_prefix = ''; if (!$url_prefix) { $url_prefix = midcom_core_context::get()->get_key(MIDCOM_CONTEXT_ANCHORPREFIX); } if (isset($shown[$object->guid])) { return; } if (!isset($persons[$object->metadata->revisor])) { $persons[$object->metadata->revisor] = midcom::get('auth')->get_user($object->metadata->revisor); } $reflector = midcom_helper_reflector_tree::get($object); $icon = $reflector->get_object_icon($object); echo "{$prefix}<tr>\n"; $disabled = ''; if (!$enable_undelete) { $disabled = ' disabled="disabled"'; } $object_label = $reflector->get_object_label($object); if (empty($object_label)) { $object_label = $object->guid; } echo "{$prefix} <td class=\"checkbox\"><input type=\"checkbox\" name=\"undelete[]\"{$disabled} value=\"{$object->guid}\" id=\"guid_{$object->guid}\" /></td>\n"; echo "{$prefix} <td class=\"label\" style=\"padding-left: {$indent}px\"><label for=\"guid_{$object->guid}\">{$icon}" . $object_label . "</label></td>\n"; echo "{$prefix} <td class=\"nowrap\">" . strftime('%x %X', strtotime($object->metadata->revised)) . "</td>\n"; if (isset($persons[$object->metadata->revisor]->guid)) { echo "{$prefix} <td><a href=\"{$url_prefix}__mfa/asgard/object/view/{$persons[$object->metadata->revisor]->guid}/\">{$persons[$object->metadata->revisor]->name}</a></td>\n"; } else { echo "{$prefix} <td> </td>\n"; } echo "{$prefix} <td>" . midcom_helper_misc::filesize_to_string($object->metadata->size) . "</td>\n"; echo "{$prefix}</tr>\n"; $child_types = midcom_helper_reflector_tree::get_child_objects($object, true); if (is_array($child_types) && count($child_types) > 0) { $child_indent = $indent + 20; echo "{$prefix}<tbody class=\"children\">\n"; foreach ($child_types as $type => $children) { if (count($children) < 10 || isset($_GET['show_children'][$object->guid][$type])) { foreach ($children as $child) { midgard_admin_asgard_trash_type_show($child, $child_indent, "{$prefix} ", false); } } else { echo "{$prefix} <tr>\n"; echo "{$prefix} <td class=\"label\" style=\"padding-left: {$child_indent}px\" colspan=\"5\"><a href=\"?show_children[{$object->guid}][{$type}]=1\">" . sprintf(midcom::get('i18n')->get_string('show %s %s children', 'midgard.admin.asgard'), count($children), midgard_admin_asgard_plugin::get_type_label($type)) . "</a></td>\n"; echo "{$prefix} </tr>\n"; } } echo "{$prefix}</tbody>\n"; } $shown[$object->guid] = true; }
/** * Synchronizes the attachments info array with the attachment referenced by the * identifier. * * @param mixed $identifier The identifier of the attachment to update */ protected function _update_attachment_info($identifier) { // Shortcuts $att = $this->attachments[$identifier]; $stats = $att->stat(); $info = array(); $info['filename'] = $att->name; $info['description'] = $att->title; $info['mimetype'] = $att->mimetype; $info['url'] = midcom_db_attachment::get_url($att); $info['id'] = $att->id; $info['guid'] = $att->guid; $info['filesize'] = $stats[7]; $info['formattedsize'] = midcom_helper_misc::filesize_to_string($stats[7]); $info['lastmod'] = $stats[9]; $info['isoformattedlastmod'] = strftime('%Y-%m-%d %T', $stats[9]); $this->_update_attachment_info_additional($info, $att); $info['object'] = $this->attachments[$identifier]; $info['identifier'] = $identifier; $this->attachments_info[$identifier] = $info; }
$class = 'document ' . $document->get_class(); $link_html = "<![CDATA["; $link_html .= "<a href='" . $prefix . $path . "document/" . $document->guid . "/' class='" . $class . "'>"; $link_html .= "<img class='document_icon' src='" . $icon . "' />"; $link_html .= "<span>" . $document->title . "</span></a>"; $link_html .= "]]>"; echo "<cell>" . $link_html . "</cell>"; echo "<cell> " . $download_url . "</cell>"; //set contact-widget if (empty($document->author)) { $author = org_openpsa_widgets_contact::get($document->metadata->creator); } else { $author = org_openpsa_widgets_contact::get($document->author); } // creator_index, creator-vcard & revised date echo "<cell>" . $author->contact_details['lastname'] . ", " . $author->contact_details['firstname'] . "</cell>"; echo "<cell><![CDATA[<span class='jqgrid_person'>" . $author->show_inline() . "</span>]]></cell>"; echo "<cell> " . $document->metadata->revised . "</cell>"; echo "<cell><![CDATA[<span class='jqgrid_date'>" . date("d.m.Y H:m", $document->metadata->revised) . "</span>]]></cell>"; //filesize-index & modified file_size echo "<cell>" . $file_size . "</cell>"; echo "<cell><![CDATA[<span class='jqgrid_size'>" . midcom_helper_misc::filesize_to_string($file_size) . "</span>]]></cell>"; //level & parent of document echo "<cell>" . $level . "</cell>"; echo "<cell>" . $parent . "</cell>"; // leaf = true , expanded = false echo "<cell>true</cell>"; echo "<cell>false</cell>"; echo "</row>"; } echo "</rows>";
<?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 . '" '; } ?>
private function _undelete() { //TODO: This variable is unused static $undeleted_size = 0; if (!$this->_request_data['midcom_dba_classname']) { // No DBA class for the type, use plain Midgard undelete API foreach ($_POST['undelete'] as $guid) { $qb = new midgard_query_builder($this->type); $qb->add_constraint('guid', '=', $guid); $qb->include_deleted(); $results = $qb->execute(); foreach ($results as $object) { $object->undelete(); } } } else { // Delegate undeletion to DBA midcom_baseclasses_core_dbobject::undelete($_POST['undelete'], $this->type); } if ($undeleted_size > 0) { midcom::get('uimessages')->add($this->_l10n->get('midgard.admin.asgard'), sprintf($this->_l10n->get('in total %s undeleted'), midcom_helper_misc::filesize_to_string($undeleted_size)), 'info'); } }
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; }
$delete_title = sprintf(midcom::get('i18n')->get_string('delete %s %s', 'midgard.admin.asgard'), midcom::get('i18n')->get_string('attachment', 'midgard.admin.asgard'), $file->name); echo "<tr>\n"; echo " <td{$class}>\n"; echo " <a href=\"{$prefix}__mfa/asgard/object/attachments/{$data['object']->guid}/{$file->name}/\">\n"; echo " <img src=\"{$mime_icon}\" width=\"16\" height=\"16\"/>\n"; echo " {$file->name}\n"; echo " </a>\n "; echo " </td>\n"; $last_edit = $file->metadata->revised == 0 ? $file->metadata->created : $file->metadata->revised; echo " <td>" . strftime('%x %X', $last_edit) . "</td>\n"; if ($persons[$file->metadata->revisor]->guid) { echo "<td><a href=\"{$prefix}__mfa/asgard/object/open/{$persons[$file->metadata->revisor]->guid}/\">{$persons[$file->metadata->revisor]->name}</a></td>\n"; } else { echo "<td> </td>\n"; } echo " <td>" . midcom_helper_misc::filesize_to_string($file->metadata->size) . "</td>\n"; echo " <td>\n"; $class = ""; if (strpos($file->mimetype, "application") !== 0) { $class = 'class="thickbox"'; } echo " <a {$class} title=\"{$file->name}\" target=\"_self\" href=\"{$prefix}midcom-serveattachmentguid-{$file->guid}/{$file->name}\">\n"; echo " <img alt=\"{$file->name}\" src=\"" . MIDCOM_STATIC_URL . "/stock-icons/16x16/view.png\"/>\n"; echo " </a> \n"; echo " <a title=\"{$delete_title}\" href=\"{$prefix}__mfa/asgard/object/attachments/delete/{$data['object']->guid}/{$file->name}/\">\n"; echo " <img alt=\"{$delete_title}\" src=\"" . MIDCOM_STATIC_URL . "/stock-icons/16x16/trash.png\"/>\n"; echo " </a>\n"; $manage_title = midcom::get('i18n')->get_string('manage object', 'midgard.admin.asgard'); echo " <a title=\"{$manage_title}\" href=\"{$prefix}__mfa/asgard/object/open/{$file->guid}/\">\n"; echo " <img alt=\"{$manage_title}\" src=\"" . MIDCOM_STATIC_URL . "/stock-icons/16x16/properties.png\"/>\n"; echo " </a>\n";
<form class="urlform" method="post" action="&(data['delete_url']:h);"> <?php $file_url = midcom::get()->get_host_prefix() . "midcom-serveattachmentguid-{$data['file']->guid}/{$data['file']->name}"; $mime_icon = midcom_helper_misc::get_mime_icon($data['file']->mimetype); ?> <fieldset> <legend><?php echo midcom::get('i18n')->get_string('file information', 'midgard.admin.asgard'); ?> </legend> <div class="icon"> <a href="&(file_url);"> <img src="&(mime_icon);" /> <?php echo midcom_helper_misc::filesize_to_string($data['file']->metadata->size) . " {$data['file']->mimetype}"; ?> </a> </div> <label><span><?php echo midcom::get('i18n')->get_string('url', 'midgard.admin.asgard'); ?> </span> <input class="text" type="text" value="&(file_url);" readonly="readonly" /> </label> <br /> <input type="submit" class="delete" name="f_delete" value="<?php echo midcom::get('i18n')->get_string('delete', 'midcom'); ?> " />