type == 'cmis:folder') {
$folder_parent->title = '..';
$children = array_merge(array($folder_parent), $children);
}
}
foreach ($children as $child) {
$author = $child->author;
$updated = date_format($child->properties['lastModificationDate'], 'n/j/Y g:i A');
$actions = array(
l(t('properties'), 'cmis/properties', array('attributes' => array('class' => 'action properties'), 'query' => array('id' => $child->id))),
l(t('delete'), 'cmis/delete', array('query' => array('id' => $child->id, 'return_url' => $_GET['q'])))
);
// @todo should be baseType in place of type
switch ($child->type) {
case 'cmis:folder':
$icon = $folder_img;
if (isset($context['id'])) {
$link = l($child->title, 'cmis/browser', array('query' => array('id' => $child->id)));
}
else {
$link = l($child->title, implode('/', array_merge(array('cmis/browser'), $context['bcarray'], array($child->title))));
}
$mimetype = 'Space';
$size = '';
break;
default:
$icon = $document_img;
$link = l($child->title, 'cmis/browser', array('query' => array('id' => $child->id)));
$mimetype = $child->contentMimeType;
$size = number_format($child->size / 1000, 2, '.', ',') .' K';
}
$rows[] = array($icon .' '. $link, $mimetype, $size, $author, $updated, theme('item_list', $actions, NULL, 'ul', array('class'=>'actions')));
}
drupal_add_js('
$(document).ready(function() {
$("A.action.properties").each(function() {
$(this).click(function() {
$(this).parents("LI:first").toggleClass("expanded").toggleClass("collapsed");
if ($(this).parents("TR:first").next().filter("TR.details").toggle().length == 0) {
$("
'. t('Loading'). '... | ")
.load(this.href+"&no_layout")
.insertAfter($(this).parents("TR:first"))
.wrapAll("
")
.before(" | ");
}
return false;
}).parents("LI:first").toggleClass("collapsed");
});
});', 'inline');
return theme('table', $header, $rows, array('class' => 'cmis_browser_browse_children'));
}
/**
* Theme for cmis_browser breadcrumb
*
* @param $bcarray
*/
function theme_cmis_browser_browse_breadcrumb($bcarray) {
$next_img = theme('image', drupal_get_path('module', 'cmis_browser') .'/images/next.gif');
$contents .= '';
$contents .= l('Root', 'cmis/browser'. $currentpath);
$currentpath = '';
foreach ($bcarray as $space) {
$contents .= $next_img .' ';
$currentpath .= '/'. $space;
$pagelink = l($space, 'cmis/browser'. $currentpath);
$contents .= $pagelink;
}
$contents .= '
';
return $contents;
}
/**
* Generate CMIS document list view.
* It displays document icon, name, download link, description, size, last modification date,
* modifier and thumbnail if any.
*
* @param $target_path
*/
function theme_cmis_browser_doc_view($target_path) {
module_load_include('api.inc', 'cmis');
$folder_img = theme('image', drupal_get_path('module', 'cmis_browser') .'/images/space.gif');
$document_img = theme('image', drupal_get_path('module', 'cmis_browser') .'/images/file.png');
try {
$repository = cmisapi_getRepositoryInfo();
$cmis_object = cmisapi_getProperties($repository->repositoryId, drupal_urlencode($target_path));
}
catch (CMISException $e) {
cmis_error_handler('cmis_browser', $e);
return t('Errors occured while trying to access CMIS repository. Please check Drupal error logs. (@error)', array('@error' => $e->getMessage()));
}
$updated = date_format($cmis_object->updated, 'n/j/Y g:i A');
if ($cmis_object->type == 'folder') {
$icon = $folder_img;
$link = l($cmis_object->title, 'cmis/browser'. $target_path);
}
else {
$icon = $document_img;
$link = l($cmis_object->title, 'cmis/browser', array('query' => array('id' => $cmis_object->id)));
}
$contents = ''. $icon . $link .'
';
$contents .= ''. $cmis_object->summary .'
';
$contents .= $cmis_object->type == 'folder'?'':' Size:'. number_format($cmis_object->size/1000, 2, '.', ',') .' K
';
$contents .= ' Modified:'. $updated .'
';
$contents .= ' Modifier:'. $cmis_object->author .'
';
return $contents;
}
/**
* Theme for cmis_browser_content_properties action.
*
* @param $cmis_object
*/
function theme_cmis_browser_content_properties($cmis_object) {
$output = theme('box', $cmis_object->title, $cmis_object->summary);
$header = array(t('Property'), t('Value'));
$rows = array();
$rows[] = array(''. t('Author') .'', $cmis_object->author);
$rows[] = array(''. t('Type') .'', $cmis_object->author);
foreach ($cmis_object->properties as $property => $value) {
if ($value instanceof DateTime) {
$rows[] = array(''. $property.'', date_format($value, 'n/j/Y g:i A'));
}
else {
$rows[] = array(''. $property.'', $value);
}
}
return $output . theme('table', NULL, $rows);
}