///////////////////////////// dojo01.js if (Drupal.jsEnabled) { $(document).ready(function() { $("#hideme").fadeOut(2000,function(){ alert("Animation Done."); }) }) } ///////////////////////////// dojo02.js if (Drupal.jsEnabled) { $(document).ready(function() { $("#clickme").click(function() { $("#search-theme-form").slideToggle(250); return false; }) }) } ///////////////////////////// dojo03.js if (Drupal.jsEnabled) { $(document).ready(function() { $("#clickme").click(function() { $("#search-theme-form").slideToggle(250); titlediv = $("#clickme").parent(); uri = titlediv.attr("title"); $.get(uri + '/dojo', '', function(data) { $("#fillme").empty(); $("#fillme").append(data); }); return false; }) }) } ///////////////////////////// dojo04.js if (Drupal.jsEnabled) { $(document).ready(function() { $("#clickme").click(function() { key = $("#edit-search-theme-form-keys").val(); titlediv = $("#clickme").parent(); uri = titlediv.attr("title"); if (key != '') { $.get(uri + '/' + key, '', function(data) { $("#fillme").empty(); $("#fillme").append(data); }); } return false; }); $("#search-theme-form").submit(function() { key = $("#edit-search-theme-form-keys").val(); titlediv = $("#clickme").parent(); uri = titlediv.attr("title"); if (key != '') { $.get(uri + '/' + key, '', function(data) { $("#fillme").empty(); $("#fillme").append(data); }); } return false; }) }) } ///////////////////////////// ///////////////////////////// end dojo0x.js ///////////////////////////// ///////////////////////////// ///////////////////////////// start dojo.module ///////////////////////////// 'admin/settings/dojo', 'title' => t('Dojo Settings'), 'description' => t('Staring a granular taxonomy requirement system'), 'callback' => 'drupal_get_form', 'callback arguments' => array('dojo_settings'), 'access' => user_access('administer site configuration'), 'type' => MENU_NORMAL_ITEM, // optional ); $items[] = array( 'path' => 'dojojs', 'title' => 'jQuery Dojo!', 'type' => MENU_CALLBACK, 'callback' => 'dojo_jquery_page', 'access' => user_access('access content'), ); $items[] = array( 'path' => 'dojojs/ajax', 'title' => 'jQuery AJAX callback', 'type' => MENU_CALLBACK, 'callback' => 'dojo_jquery_ajax', 'access' => user_access('access content'), ); return $items; } function dojo_settings() { $types = node_get_types(); // print_r($types); $vocabs = taxonomy_get_vocabularies(); // print_r($vocabs); $header = array(t('Vocabulary')); foreach($vocabs as $vid => $vocab) { // make a row $row = array(); $row[] = $vocab->name; foreach($types as $type => $data) { $row[] = '[x]'; $header[] = $type; } $rows[] = $row; } $form = array(); $form['table'] = array( '#type' => 'markup', '#value' => theme('table', $header, $rows), ); return $form; } function dojo_perm() { return array('post dojo without revision'); } /** * Implementation of hook_nodeapi * * For dojo lesson and great justice! */ function dojo_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { switch ($op) { case 'submit': If($node->type == 'dojo') { drupal_set_message('DOJO NODE SUBMITTED!'); } break; case 'search result': if ($node->uid == 1) { // use the uid of your puppy-hater here $output = 'THIS USER HATES PUPPIES!'; return $output; } break; case 'validate': // what we want is for this to check the perms if the revision bit is not set. if ($node->revision != 1 && user_access('post dojo without revision') == FALSE) { form_set_error('revision', t('Hey man, you have to make a revision')); } break; case 'update index': If($node->type == 'dojo') { return 'dojotastic'; } break; case 'view': If($node->type == 'dojo') { $node->content['body']['#value'] .= '

This was added in nodeapi for dojo nodes onle!

'; } break; } } /** * Imlementation of hook_form_alter * * This will add a validation callback and turn an input format into * radio buttons. */ function dojo_form_alter($form_id, &$form) { if ($form_id == 'dojo_node_form') { // print_r($form); $form['#theme'] = 'dojo'; $form['#validate']['dojo_validate'] = array(); // $form['field_belt_color']['key']['#type'] = 'radios'; $tree = taxonomy_get_tree(1); // print_r($tree); $belts = array(); foreach($tree as $term) { // $belts[$term->tid] = $term->name; } // $form['field_belt_color']['key']['#options'] = $belts; unset($form['options']['revision']); $form['revision'] = array( '#type' => 'checkbox', '#title' => 'Create new revision', '#default_value' => 1, '#prefix' => '
', '#suffix' => '
', '#weight' => -100, ); } if ($form_id == 'search_form') { // restrict search terms w/custom validation callback $form['#validate']['dojo_search_validate'] = array(); } if ($form_id == 'battle_node_form') { unset($form['taxonomy'][2]['#options'][0]); $form['taxonomy'][2]['#required'] = TRUE; } } function theme_dojo($form) { // print_r($form); $output .= drupal_render($form); return $output; } function dojo_validate($form_id, $form_values, $form) { if($form_values['title'] == 'Foo') { form_set_error('title', t('Foo is not allowed!')); } } function dojo_search_validate($form_id, $form_values, $form) { // if the user doesn't have access, stop them from searching for the dojo if(user_access('post dojo without revision') == FALSE && strstr($form_values['keys'], 'dojo')) { form_set_error('keys', t('Yoy cannot search for the Dojo!')); } } /** * I'm writing this funtion because I need to understand db_rewrite_sql */ function dojo_query() { $sql = 'SELECT * from {node} WHERE nid = %d'; $sql = db_rewrite_sql($sql); print_r($sql); $result = db_query($sql, 2); $node = db_fetch_object($result); print_r($node); } /** * JS LESSSON FUNCTIONS 01 * function dojo_jquery_page() { $data = drupal_get_path('module', 'dojo'). '/dojo01.js'; drupal_add_js($data, 'module'); $output = '

Some Big Text!

'; return $output; } **********************************************/ /** * JS LESSSON FUNCTIONS 02 * function dojo_jquery_page() { $data = drupal_get_path('module', 'dojo'). '/dojo02.js'; drupal_add_js($data, 'module'); $output = '

Big Text!

'; $output = '
'. l('Toggle Search', '', array('id' => 'clickme')) .'
'; return $output; } **********************************************/ /** * JS LESSSON FUNCTIONS 03 * function dojo_jquery_page() { $data = drupal_get_path('module', 'dojo'). '/dojo03.js'; drupal_add_js($data, 'module'); $output = '

Big Text!

'; $output .= '
'. l('Fire AJAX', '', array('id' => 'clickme')) .'
'; $output .= '
'; return $output; } function dojo_jquery_ajax($key) { $titles = array(); $result = db_query("SELECT title, nid FROM {node}", $key); while ($node = db_fetch_object($result)) { $titles[] = l($node->title, 'node/'.$node->nid); } $output = theme('item_list', $titles); exit($output); } **********************************************/ /** * JS LESSSON FUNCTIONS * function dojo_jquery_page() { $data = drupal_get_path('module', 'dojo'). '/dojo04.js'; drupal_add_js($data, 'module'); $output = '

Big Text!

'; $output .= '
'. l('Fire AJAX', '', array('id' => 'clickme')) .'
'; $output .= '
'; return $output; } function dojo_jquery_ajax($key) { global $user; $key = check_plain($key); $output .= "

SEARCH BY $user->name

"; $output .= search_data($key); exit($output); } **********************************************/ ///////////////////////////// ///////////////////////////// end dojo.module /////////////////////////////