Ejemplo n.º 1
0
/**
 * Streams the document file to the browser
 *
 * @param string $objectId The CMIS object ID
 */
function _cmisro_download($objectId = null)
{
    if ($objectId) {
        $o = _cmisro_getObject($objectId);
        drupal_add_http_header('Cache-Control', 'no-cache, must-revalidate');
        drupal_add_http_header('Content-Type', $o['type']);
        drupal_add_http_header('Content-Length', $o['filesize']);
        drupal_add_http_header('Content-Disposition', "attachment; filename=\"{$o['filename']}\"");
        echo _cmisro_service()->getContentStream($objectId);
        exit;
    }
}
        $class = _cmisro_class_for_type($o['type']);
        // Only render links on folders
        //
        // This browser is written to navigate the directory structure.
        // It makes no sense to render a link on a document.
        //
        // However, if this browser is being used as a popup, the user
        // should be able to choose either a folder or a document.
        // We should render buttons on every item.
        $params = '';
        $button = '';
        if (!empty($_GET['popup']) && !empty($_GET['id'])) {
            $params = '&popup=1&id=' . $_GET['id'];
            $button = "\n\t\t\t\t\t<button type=\"button\" onclick=\"CMISRO_BROWSER.handleSelection('{$_GET['id']}', '{$o['id']}');\">\n\t\t\t\t\t\tChoose\n\t\t\t\t\t</button>\n\t\t\t\t\t";
        }
        if ($o['type'] == 'cmis:folder') {
            $title = "<a href=\"{$url}?ref={$o['id']}{$params}\">{$title}</a>";
        }
        echo "\n                <tr><td class=\"cmis_object {$class}\">{$title}</td>\n                    <td>{$button}</td>\n                </tr>\n                ";
    }
}
?>
	</table>
    <?php 
if (!empty($variables['listing']->hasMoreItems)) {
    pager_default_initialize($variables['listing']->numItems, _cmisro_service()->maxItems);
    echo theme('pager');
}
?>
</div>