t('YUI datatable settings'), 'page callback' => 'drupal_get_form', 'page arguments' => array('yui_datatable_settings_form'), 'access callback' => 'user_access', 'access arguments' => array('administer site configuration'), 'description' => t("View/Modify YUI datatable settings"), ); return $items; } /* * implementation of hook_perm(). */ function yui_datatable_perm() { $array = array('Access YUI datatable'); return $array; } /* *The settings page. */ function yui_datatable_settings_form() { $form = array(); return system_settings_form($form); } function yui_datatable_get_formatter($data) { } function theme_yui_datatable_table($header, $rows, $attributes = array(), $caption = NULL) { static $tableID; $tableID++; $thisTableID = 'table-' . $tableID; $thisMarkupID = 'markup-' . $tableID; render_datatable(); $attributes['id'] = $thisTableID; $sort = ''; foreach ($header as $row) { if (is_array($row)) { if ($row['data'] == NULL) { $row['data'] = ' '; } if (isset($row['sort'])) { $sort = ", { sortedBy : { key: '" . str_replace(' ', '', $row['data']) . "', dir : '" . $row['sort'] . "' } } "; } $rowJS .= "{ className : '" . $row['class'] . "', key : '" . str_replace(' ', '', $row['data']) . "', label : '" . $row['data'] . "', sortable : " . (isset($row['field']) ? 'true' : 'false') . " },"; } else { $rowJS .= "{ key : '$row', label : '$row' },"; } } foreach ($rows as $index => $row) { while (sizeof($rows[$index]) < sizeof($header)) { $rows[$index][] = array('data' => ' '); } } drupal_add_js(" YAHOO.util.Event.addListener(window, 'load', function() { YAHOO.example.EnhanceFromMarkup = new function() { var myColumnDefs = [ $rowJS ]; this.myDataSource = new YAHOO.util.DataSource(YAHOO.util.Dom.get('$thisTableID')); this.myDataSource.responseType = YAHOO.util.DataSource.TYPE_HTMLTABLE; this.myDataSource.responseSchema = { fields: [ $rowJS ] }; this.myDataTable = new YAHOO.widget.DataTable('$thisMarkupID', myColumnDefs, this.myDataSource$sort); $('form table:has(th div.select-all):not(.tableSelect-processed)').each(Drupal.yui_datatable_select); }; });", "inline", "footer"); return '
' . theme_table($header, $rows, $attributes, $caption) . '
'; } function yui_datatable_theme() { return array( 'table' => array( 'function' => 'theme_yui_datatable_table', 'arguments' => array('header' => array(), 'rows' => array(), 'attributes' => array(), 'caption' => NULL) ), ); } /* * Add the javascript/CSS needed to render the datatable */ function render_datatable() { if (!user_access('Access YUI datatable')) { return; } $yui_source = 'http://yui.yahooapis.com/2.5.2'; //variable_get('yui_source','http://yui.yahooapis.com/2.5.2'); yui_add_css('datatable', $yui_source, '/build/fonts/fonts-min.css'); yui_add_css('datatable', $yui_source, '/build/datatable/assets/skins/sam/datatable.css'); yui_add_js('datatable', $yui_source, '/build/yahoo-dom-event/yahoo-dom-event.js'); yui_add_js('datatable', $yui_source, '/build/element/element-beta-min.js'); yui_add_js('datatable', $yui_source, '/build/datasource/datasource-beta-min.js'); yui_add_js('datatable', $yui_source, '/build/datatable/datatable-beta-min.js'); drupal_add_js(drupal_get_path("module", "yui_datatable")."/yui_datatable_select.js"); }