/[drupal]/contributions/modules/jquery_media/jquery_media.module
ViewVC logotype

Diff of /contributions/modules/jquery_media/jquery_media.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.5.2.5, Sat Sep 6 21:27:44 2008 UTC revision 1.5.2.6, Wed Dec 17 14:43:50 2008 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: jquery_media.module,v 1.5.2.4 2008/08/28 01:47:17 aaron Exp $  // $Id: jquery_media.module,v 1.5.2.5 2008/09/06 21:27:44 aaron Exp $
3    
4  /**  /**
5   * @file   * @file
# Line 78  function jquery_media_nodeapi(&$node, $o Line 78  function jquery_media_nodeapi(&$node, $o
78        if ($types[$node->type]) {        if ($types[$node->type]) {
79          jquery_media_add();          jquery_media_add();
80        }        }
81        if (is_array($node->jquery_media)) {  //       if (is_array($node->jquery_media)) {
82          jquery_media_add($node->jquery_media);  //         jquery_media_add($node->jquery_media);
83        }  //       }
84        break;        break;
85      case 'delete':      case 'delete':
86        db_query("DELETE FROM {jquery_media_node} WHERE nid=%d", $node->nid);  //       db_query("DELETE FROM {jquery_media_node} WHERE nid=%d", $node->nid);
87        break;        break;
88      case 'update':      case 'update':
89        db_query("DELETE FROM {jquery_media_node} WHERE nid=%d", $node->nid);  //       db_query("DELETE FROM {jquery_media_node} WHERE nid=%d", $node->nid);
90        // Don't break yet; we may need to insert our new options.        // Don't break yet; we may need to insert our new options.
91      case 'insert':      case 'insert':
92        if ($node->jquery_media_insert) {  //       if ($node->jquery_media_insert) {
93          $node->jquery_media = array();  //         $node->jquery_media = array();
94          // @TODO: Build the node specific options from form.  //         // @TODO: Build the node specific options from form.
95          db_query("INSERT INTO {jquery_media_node} (nid, options) VALUES (%d, '%s')", $node->nid, serialize($node->jquery_media));  //         db_query("INSERT INTO {jquery_media_node} (nid, options) VALUES (%d, '%s')", $node->nid, serialize($node->jquery_media));
96        }  //       }
97        unset($node->jquery_media_insert);  //       unset($node->jquery_media_insert);
98        break;        break;
99      case 'load':      case 'load':
100        $jquery_media = db_result(db_query("SELECT options FROM {jquery_media_node} WHERE nid = %d", $node->nid));  //       $jquery_media = db_result(db_query("SELECT options FROM {jquery_media_node} WHERE nid = %d", $node->nid));
101        if (isset($jquery_media)) {  //       if (isset($jquery_media)) {
102          $node->jquery_media = unserialize($jquery_media);  //         $node->jquery_media = unserialize($jquery_media);
103        }  //       }
104        break;        break;
105    }    }
106  }  }
# Line 111  function jquery_media_nodeapi(&$node, $o Line 111  function jquery_media_nodeapi(&$node, $o
111   *  allowing to enable the plugin from a particular node.   *  allowing to enable the plugin from a particular node.
112   */   */
113  function jquery_media_form_alter(&$form, $form_state, $form_id) {  function jquery_media_form_alter(&$form, $form_state, $form_id) {
114    if (substr($form_id, -10) == '_node_form') {  //   if (substr($form_id, -10) == '_node_form') {
115      if (user_access('add jquery media to content')) {  //     if (user_access('add jquery media to content')) {
116        $node = $form['#node'];  //       $node = $form['#node'];
117        $form['jquery_media_fieldset'] = array(  //       $form['jquery_media_fieldset'] = array(
118          '#type' => 'fieldset',  //         '#type' => 'fieldset',
119          '#title' => t('jQuery Media'),  //         '#title' => t('jQuery Media'),
120          '#collapsible' => TRUE,  //         '#collapsible' => TRUE,
121          '#collapsed' => TRUE,  //         '#collapsed' => TRUE,
122        );  //       );
123        $form['jquery_media_fieldset']['jquery_media_insert'] = array(  //       $form['jquery_media_fieldset']['jquery_media_insert'] = array(
124          '#type' => 'checkbox',  //         '#type' => 'checkbox',
125          '#title' => t('Invoke jQuery Media'),  //         '#title' => t('Invoke jQuery Media'),
126          '#default_value' => is_array($node->jquery_media),  //         '#default_value' => is_array($node->jquery_media),
127        );  //       );
128        $form['jquery_media_fieldset']['jquery_media'] = array(  //       $form['jquery_media_fieldset']['jquery_media'] = array(
129          '#type' => 'value',  //         '#type' => 'value',
130          '#value' => $node->jquery_media,  //         '#value' => $node->jquery_media,
131        );  //       );
132        // @TODO: Add specific options here, such as w/h.  //       // @TODO: Add specific options here, such as w/h.
133      }  //     }
134      else {  //     else {
135        $form['jquery_media_insert'] = array(  //       $form['jquery_media_insert'] = array(
136          '#type' => 'value',  //         '#type' => 'value',
137          '#value' => is_array($node->jquery_media),  //         '#value' => is_array($node->jquery_media),
138        );  //       );
139        $form['jquery_media'] = array(  //       $form['jquery_media'] = array(
140          '#type' => 'value',  //         '#type' => 'value',
141          '#value' => $node->jquery_media,  //         '#value' => $node->jquery_media,
142        );  //       );
143      }  //     }
144    }  //   }
145  }  }
146    
147  /**  /**
148     *  Implements hook_init().
149   *  Invoke the plugin on any page listed from the configuration page.   *  Invoke the plugin on any page listed from the configuration page.
150   *  Code swiped from block_list   *  Code swiped from block_list
151   */   */
152  function jquery_media_footer() {  function jquery_media_init() {
153    $path = drupal_get_path_alias($_GET['q']);    $path = drupal_get_path_alias($_GET['q']);
154    $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote(variable_get('jquery_media_pages', ''), '/')) .')$/';    $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. preg_quote(variable_get('site_frontpage', 'node'), '/') .'\2'), preg_quote(variable_get('jquery_media_pages', ''), '/')) .')$/';
155    // Compare with the internal and path alias (if any).    // Compare with the internal and path alias (if any).

Legend:
Removed from v.1.5.2.5  
changed lines
  Added in v.1.5.2.6

  ViewVC Help
Powered by ViewVC 1.1.2