linkit_picker.module in Linkit Picker 7
Same filename and directory in other branches
Main file for linkit_pikcer module.
File
linkit_picker.moduleView source
<?php
/**
* @file
* Main file for linkit_pikcer module.
*/
/**
* Implements hook_form_alter().
*/
function linkit_picker_form_alter(&$form, &$form_state, $form_id) {
if ($form_id == "_linkit_form") {
$form['link']['link']['#field_suffix'] = '<input type="submit" id="linkit-imce" name="linkit-imce" value="Choose File ..." class="form-submit" />';
$form['link']['attributes']['#weight'] = 3;
$form['link']['browser_wrapper'] = array(
'#type' => 'fieldset',
'#title' => t('Select From List'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#weight' => 2,
'#attributes' => array(
'class' => array(
'linkit_picker',
),
),
);
$modulesInstalled = module_list();
$views = array();
if (array_key_exists('linkit_node', $modulesInstalled)) {
$views[] = 'linkit_picker_node';
$form['link']['browser_wrapper']['node'] = array(
'#type' => 'button',
'#value' => t('Node'),
'#weight' => 0,
'#attributes' => array(
'class' => array(
'linkit_picker_button',
),
),
);
}
if (array_key_exists('linkit_user', $modulesInstalled)) {
$views[] = 'linkit_picker_user';
$form['link']['browser_wrapper']['user'] = array(
'#type' => 'button',
'#value' => t('User'),
'#weight' => 1,
'#attributes' => array(
'class' => array(
'linkit_picker_button',
),
),
);
}
if (array_key_exists('linkit_taxonomy', $modulesInstalled)) {
$views[] = 'linkit_picker_term';
$form['link']['browser_wrapper']['term'] = array(
'#type' => 'button',
'#value' => t('Term'),
'#weight' => 2,
'#attributes' => array(
'class' => array(
'linkit_picker_button',
),
),
);
}
$form['link']['browser_wrapper']['container'] = array(
'#prefix' => '<div id="linkit-picker-container">',
'#suffix' => '</div>',
'#markup' => _linkit_picker_render_container($views),
'#weight' => 10,
);
}
}
/**
* Return all the views that should be used in the container.
*/
function _linkit_picker_render_container($views) {
$form_value = "";
foreach ($views as $view) {
$form_value .= _linkit_picker_get_views($view);
}
return $form_value;
}
/**
* Implements hook_views_api().
*/
function linkit_picker_views_api() {
return array(
'api' => 3,
'path' => drupal_get_path('module', 'linkit_picker') . '/includes',
);
}
/**
* Implements hook_theme_registry_alter().
*/
function linkit_picker_theme_registry_alter(&$theme_registry) {
// Add a new preprocess function
$theme_registry['linkit_dashboard']['preprocess functions'][] = 'linkit_picker_alter_template_preprocess_linkit_dashboard';
}
function linkit_picker_alter_template_preprocess_linkit_dashboard(&$variables) {
drupal_add_js(drupal_get_path('module', 'linkit_picker') . '/linkit_picker.js');
drupal_add_css(drupal_get_path('module', 'linkit_picker') . '/linkit_picker.css');
$variables['styles'] = drupal_get_css();
$variables['head'] = drupal_get_html_head();
$variables['scripts'] = drupal_get_js();
}
function _linkit_picker_get_views($viewname) {
$output = '';
$view = views_get_view($viewname);
if ($view && $view
->access('default')) {
$output .= '<div class="view-container">';
$output .= $view
->get_title();
$output .= $view
->preview('default');
$output .= '</div>';
}
return $output;
}
Functions
Name![]() |
Description |
---|---|
linkit_picker_alter_template_preprocess_linkit_dashboard | |
linkit_picker_form_alter | Implements hook_form_alter(). |
linkit_picker_theme_registry_alter | Implements hook_theme_registry_alter(). |
linkit_picker_views_api | Implements hook_views_api(). |
_linkit_picker_get_views | |
_linkit_picker_render_container | Return all the views that should be used in the container. |