| 1 |
<?php
|
| 2 |
// $Id: ldapdata.theme.inc,v 1.2 2009/02/19 16:56:16 miglius Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* Themes for ldapdata module.
|
| 7 |
*/
|
| 8 |
|
| 9 |
//////////////////////////////////////////////////////////////////////////////
|
| 10 |
// Theme callbacks
|
| 11 |
|
| 12 |
/**
|
| 13 |
* Theme function for the admin edit form.
|
| 14 |
*/
|
| 15 |
function theme_ldapdata_admin_edit($form) {
|
| 16 |
$output = '';
|
| 17 |
$rows = array();
|
| 18 |
foreach (element_children($form) as $element) {
|
| 19 |
if ($element == 'attributes') {
|
| 20 |
if (isset($form['attributes']['table'])) {
|
| 21 |
foreach (element_children($form['attributes']['table']) as $key) {
|
| 22 |
$row = array();
|
| 23 |
$row[] = drupal_render($form['attributes']['table'][$key]);
|
| 24 |
$row[] = drupal_render($form['attributes']['ldapdata_roattrs'][$key]);
|
| 25 |
$row[] = drupal_render($form['attributes']['ldapdata_rwattrs'][$key]);
|
| 26 |
$rows[] = $row;
|
| 27 |
}
|
| 28 |
}
|
| 29 |
else {
|
| 30 |
$rows[] = array(array('data' => t('No attributes configured.'), 'colspan' => 3));
|
| 31 |
}
|
| 32 |
$form['attributes']['#children'] = drupal_render($form['attributes']['ldapdata_attrs']);
|
| 33 |
$form['attributes']['#children'] .= theme('table', $form['attributes']['header']['#value'], $rows);
|
| 34 |
$form['attributes']['#children'] .= drupal_render($form['attributes']['ldapdata_filter_php']);
|
| 35 |
$output .= drupal_render($form['attributes']);
|
| 36 |
}
|
| 37 |
else {
|
| 38 |
$output .= drupal_render($form[$element]);
|
| 39 |
}
|
| 40 |
}
|
| 41 |
|
| 42 |
$output .= drupal_render($form);
|
| 43 |
|
| 44 |
return $output;
|
| 45 |
}
|
| 46 |
|
| 47 |
/**
|
| 48 |
* Theme functon for the LDAP attribute.
|
| 49 |
*/
|
| 50 |
function theme_ldapdata_ldap_attribute($value, $type) {
|
| 51 |
switch ($type) {
|
| 52 |
case 'url':
|
| 53 |
$ret = strpos($value, '://') ? $value : "http://$value";
|
| 54 |
$ret = "<a href=\"$ret\">$ret</a>";
|
| 55 |
break;
|
| 56 |
case 'txt':
|
| 57 |
default:
|
| 58 |
$ret = $value;
|
| 59 |
break;
|
| 60 |
}
|
| 61 |
|
| 62 |
return $ret;
|
| 63 |
}
|
| 64 |
|