array( 'name' => t('CMIS Alfresco'), 'module' => 'cmis_alfresco', 'description' => t('Alfresco CMIS client'), ), ); } /** * Invokes a CMIS Alfresco service * * @param $serviceurl * @param $headers * @param $method * @param $data * @param $retry */ function cmis_alfresco_invoke_service($service_url, $headers = array(), $method = 'GET', $data = NULL, $retry = 3) { return module_invoke(_cmis_alfresco_get_service_invoker(), 'cmis_alfresco_service', $service_url, $headers, $method, $data, $retry); } /** * Returns the current module name that handles * Alfresco CMIS service calls. * * @return string module name */ function _cmis_alfresco_get_service_invoker() { $invoker = variable_get('cmis_alfresco_service_invoker', 'cmis_alfresco_ticket'); if (!module_exists($invoker)) { throw new CMISException('Unknown CMIS Alfresco service invoker'); } return $invoker; } /** * Implementation of hook_menu() * */ function cmis_alfresco_menu() { $items['cmis/opensearch'] = array( 'type' => MENU_NORMAL_ITEM, 'title' => 'CMIS Keyword Search', 'description' => 'Keyword search with OpenSearch', 'page callback' => 'cmis_alfresco_opensearch_view', 'access arguments' => array('access cmis'), 'file' => 'cmis_alfresco.pages.inc', ); return $items; } /** * Implementation of hook_perm() * */ function cmis_alfresco_perm() { $perms = array( 'administer alfresco', 'access alfresco', ); return $perms; } /** * Implementation of hook_form() * * @param $form_state */ function cmis_alfresco_opensearch_form(&$form_state) { $opensearch = array( '#type' => 'fieldset', '#title' => t('OpenSearch'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $opensearch['cmis_alfresco_opensearch_keyword'] = array( '#type' => 'textfield', '#title' => t('Keyword'), '#description' => t('Search the repository using opensearch support'), '#default_value' => arg(2), ); $opensearch['cmis_alfresco_opensearch_submit'] = array( '#type' => 'submit', '#value' => t('Search'), ); $form['opensearch'] = $opensearch; return $form; } /** * Implementation of hook_form_submit() * */ function cmis_alfresco_opensearch_form_submit($form, &$form_state) { if ($form_state['values']['cmis_alfresco_opensearch_keyword']) { $form_state['redirect'] = 'cmis/opensearch/'. urlencode(trim($form_state['values']['cmis_alfresco_opensearch_keyword'])); } else { $form_state['redirect'] = 'cmis/opensearch'; form_set_error('cmis_alfresco_opensearch_form', 'Please enter a keyword'); } } /** * Implementation of hook_theme() * */ function cmis_alfresco_theme() { return array( 'cmis_alfresco_opensearch_results' => array('arguments' => array('entries')) ); } function theme_cmis_alfresco_opensearch_results($entries) { if (empty($entries)) { return ''; } module_load_include('utils.inc', 'cmis_alfresco'); foreach ($entries as $entry) { $summary = $entry->summary; $score = $entry->children('relevance', TRUE)->score; $updated = date_create($entry->updated); $updatedStr = date_format($updated, 'n/j/Y g:i A'); $alfIcon = $entry->icon; $documentLink = l($entry->title, 'cmis/browser', array('query' => array('id' => $entry->id))); $rows[] = array(''. $documentLink, $entry->author->name, $updatedStr, $score); } $header = array(t('Name'), t('Author'), t('Updated'), t('Score')); $contents .= theme('table', $header, $rows); return $contents; }