You are here

linkit_file.module in Linkit 7

Same filename and directory in other branches
  1. 6 plugins/linkit_file/linkit_file.module

Extend Linkit with files.

File

plugins/linkit_file/linkit_file.module
View source
<?php

/**
 * @file
 * Extend Linkit with files.
 */

/**
 * Implements hook_linkit_load_plugins().
 */
function linkit_file_linkit_load_plugins($string) {
  $matches = array();

  // Get files.
  $result = db_select('file_managed', 'f')
    ->fields('f', array(
    'filename',
    'uri',
    'filemime',
  ))
    ->condition('f.filename', '%' . db_like($string) . '%', 'LIKE')
    ->condition('f.status', '1')
    ->condition('f.uri', 'public://%', 'LIKE')
    ->execute();
  $public_path = variable_get('file_public_path', conf_path() . '/files');
  foreach ($result as $file) {
    $matches['file'][] = array(
      'title' => $file->filename,
      'path' => $public_path . '/' . file_uri_target($file->uri),
      'information' => array(
        'type' => 'File',
        'mimetype' => $file->filemime,
      ),
    );
  }
  return $matches;
}

/**
 * Implements hook_linkit_get_search_styled_link().
 */
function linkit_file_linkit_get_search_styled_link($string) {
  return;
}

/**
 * Implements hook_linkit_info_plugins().
 * 
 * This is used by linkit_permissions
 */
function linkit_file_linkit_info_plugins() {
  $return['linkit_file'] = array(
    'type' => 'file',
  );
  return $return;
}

Functions

Namesort descending Description
linkit_file_linkit_get_search_styled_link Implements hook_linkit_get_search_styled_link().
linkit_file_linkit_info_plugins Implements hook_linkit_info_plugins().
linkit_file_linkit_load_plugins Implements hook_linkit_load_plugins().