You are here

function theme_cmis_browser_browse_children in CMIS API 6.3

Same name and namespace in other branches
  1. 6.4 cmis_browser/cmis_browser.theme.inc \theme_cmis_browser_browse_children()
  2. 6.2 cmis_browser/cmis_browser.theme.inc \theme_cmis_browser_browse_children()
  3. 7.2 cmis_browser/cmis_browser.theme.inc \theme_cmis_browser_browse_children()
  4. 7 cmis_browser/cmis_browser.theme.inc \theme_cmis_browser_browse_children()

Custom theme for cmis_browser_browse action

Parameters

$children:

2 theme calls to theme_cmis_browser_browse_children()
theme_cmis_browser in cmis_browser/cmis_browser.theme.inc
theme_cmis_query_results in cmis_query/cmis_query.module
Theme function for CMIS query search results

File

cmis_browser/cmis_browser.theme.inc, line 34

Code

function theme_cmis_browser_browse_children($context = array()) {
  $header = array(
    t('name'),
    t('type'),
    t('size'),
    t('author'),
    t('last modified'),
    '',
  );
  $rows = array();
  $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');
  foreach ($context['children'] as $child) {
    $author = $child->properties['cmis:createdBy'];
    $updated = date_format(date_create($child->properties['cmis: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'],
        ),
      )),
    );
    switch ($child->properties['cmis:baseTypeId']) {
      case 'cmis:folder':
        $icon = $folder_img;
        $link = l($child->properties['cmis:name'], 'cmis/browser' . $child->properties['cmis:path']);
        $mimetype = 'Space';
        $size = '';
        break;
      default:
        $icon = $document_img;
        $link = l($child->properties['cmis:name'], 'cmis/browser', array(
          'query' => array(
            'id' => $child->id,
          ),
        ));
        $mimetype = $child->properties['cmis:contentStreamMimeType'];
        $size = number_format($child->properties['cmis:contentStreamLength'] / 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) {
            $("<td colspan=\\"6\\"><span class=\\"load_indicator\\">' . t('Loading') . '...</span></td>")
              .load(this.href+"&no_layout")
              .insertAfter($(this).parents("TR:first"))
              .wrapAll("<tr class=\\"details\\"></tr>")
              .before("<td></td>");
          }
          return false;
        }).parents("LI:first").toggleClass("collapsed");
      });
    });', 'inline');
  return theme('table', $header, $rows, array(
    'class' => 'cmis_browser_browse_children',
  ));
}