? nodeformpopup.info
Index: nodeformpopup.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodeformpopup/nodeformpopup.module,v
retrieving revision 1.25
diff -u -r1.25 nodeformpopup.module
--- nodeformpopup.module	4 Dec 2006 19:45:18 -0000	1.25
+++ nodeformpopup.module	8 Jan 2007 23:03:52 -0000
@@ -42,10 +42,10 @@
 
 function _nodeformpopup_bookmarklet_access() {
   $types = node_get_types();
-  foreach($types as $type => $name) {
-    if (variable_get('nodeformpopup_'.$type, 0)) {
+  foreach($types as $type) {
+    if (variable_get('nodeformpopup_'.$type->type, 0)) {
       $node = new stdClass();
-      $node->type = $type;
+      $node->type = $type->type;
       if (node_access('create', $node)) {
         return TRUE;
       }
@@ -61,14 +61,14 @@
   switch ($op) {
     case 'add':
       $type = check_plain($type);
-      $types = node_get_types();
-      if ($types[$type] && variable_get('nodeformpopup_'.$type, 0)) {
+      $types = node_get_types('types');
+      if (isset($types[$type]) && variable_get('nodeformpopup_'.$type, 0)) {
         global $user;
         if (node_access('create', $type)) {
           drupal_add_js(drupal_get_path('module', 'nodeformpopup'). '/nodeformpopup.js');
-          drupal_set_title(t('Submit %name', array('%name' => node_get_name($node))));
+          drupal_set_title(t('Submit %name', array('%name' => node_get_types('name', $node))));
           $node = array('type' => $type, 'uid' => $user->uid, 'name' => $user->name);
-          print theme('nodeformpopup_page', node_form($node));
+          print theme('nodeformpopup_page', drupal_get_form($type .'_node_form', $node));
         }
         elseif ($user->roles[DRUPAL_ANONYMOUS_RID]) {
           drupal_set_title(t('Access denied'));
@@ -115,11 +115,11 @@
 function nodeformpopup_bookmarklets() {
   drupal_set_title('Bookmarklets');
   $bookmarklets = array();
-  foreach (node_get_types() as $type => $name) {
+  foreach (node_get_types('types') as $type) {
     $node = new stdClass();
-    $node->type = $type;
-    if (variable_get('nodeformpopup_'.$type, 0) && node_access('create', $node)) {
-      $bookmarklets[] = nodeformpopup_bookmarklet($type);
+    $node->type = $type->type;
+    if (variable_get('nodeformpopup_'.$type->type, 0) && node_access('create', $node)) {
+      $bookmarklets[] = nodeformpopup_bookmarklet($type->type);
     }
   }
   return theme('item_list', $bookmarklets);
@@ -130,28 +130,28 @@
  * Allows to enable or disable popups for each content type.
  */
 function nodeformpopup_form_alter($form_id, &$form) {
-
   // alter content type settings
-  if (isset($form['type']) && $form['type']['#value'].'_node_settings' == $form_id) {
-
+  if ($form_id == 'node_type_form' && isset($form['#node_type']->type)) {
+    $type = $form['old_type']['#value'];
+    
     $form['submission']['nodeformpopup'] = array(
       '#type' => 'fieldset',
       '#title' => t('Popup forms and bookmarklets'),
       '#collapsible' => TRUE,
     );
 
-    $form['submission']['nodeformpopup']['nodeformpopup_'. $form['type']['#value']] = array(
+    $form['submission']['nodeformpopup']['nodeformpopup'] = array(
       '#type' => 'radios',
       '#title' => t('Submit nodes via popup or bookmarklet'),
-      '#default_value' => variable_get('nodeformpopup_'.$form['type']['#value'], 0),
-      '#options' => array(t('Disabled'), t('Enabled')),
+      '#default_value' => variable_get('nodeformpopup_'.$type, 0),
+      '#options' => array(0 => t('Disabled'), 1 => t('Enabled')),
     );
 
-    if (node_get_base($form['type']['#value']) == 'content' && module_exist('content')) {
-      $form['submission']['nodeformpopup']['nodeformpopup_'. $form['type']['#value'] .'_nodereference'] = array(
+    if (node_get_types('module',$type) == 'content' && module_exist('content')) {
+      $form['submission']['nodeformpopup']['nodeformpopup_'. $type .'_nodereference'] = array(
         '#type' => 'radios',
         '#title' => t('Shortcuts for nodereference fields'),
-        '#default_value' => variable_get('nodeformpopup_'.$form['type']['#value'] .'_nodereference', 0),
+        '#default_value' => variable_get('nodeformpopup_'.$type .'_nodereference', 0),
         '#options' => array(t('Disabled'), t('Enabled')),
         '#description' => t('Provides a set of links to quickly submit new nodes within nodereference autocomplete fields.')
       );
@@ -214,7 +214,7 @@
 function nodeformpopup_bookmarklet($type) {
   $node = new stdClass();
   $node->type = $type;
-  $label = t('Submit %name to %site', array('%name' => node_get_name($node), '%site' => variable_get('site_name', 'drupal')));
+  $label = t('Submit %name to %site', array('%name' => node_get_types('name', $node), '%site' => variable_get('site_name', 'drupal')));
   $url = url('nodeformpopup/add/'. check_plain($type), '', NULL, TRUE);
   return theme('nodeformpopup_bookmarklet', $label, $url);
 }
@@ -224,14 +224,14 @@
  * WARNING: no XSS filters applied here
  */
 function theme_nodeformpopup_page($content = NULL, $op = NULL) {
-  $output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
-  $output .= '<html lang="'. $GLOBALS['locale'] .'" xml:lang="'. $GLOBALS['locale'] .'" xmlns="http://www.w3.org/1999/xhtml">';
+  $output = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n";
+  $output .= '<html xmlns="http://www.w3.org/1999/xhtml">';
   $output .= '<head>';
-  $output .= '<title>'. variable_get('site_name', 'drupal') .' | '. drupal_get_title() .'</title>';
+  $output .= ' <title>'. (drupal_get_title() ? strip_tags(drupal_get_title()) : variable_get('site_name', 'Drupal')) .'</title>';
   $output .= drupal_get_html_head();
-  $output .= theme_get_styles();
-  $output .= theme_stylesheet_import(base_path() . drupal_get_path('module', 'nodeformpopup') .'/nodeformpopup.css');
-  $output .= '</head>';
+  $output .= drupal_get_css();
+  $output .= drupal_get_js();
+  $output .= ' </head>';
   $output .= '<body'. ($op ? ' class="'.$op.'"' : '') .'>';
   $output .= '<div id="'. ($GLOBALS['theme_key'] == 'pushbutton' ? 'site-info' : 'header') .'"><h1 class="site-name"><a href="#popupcontent">'. drupal_get_title() .'</a></h1></div>';
   $output .= '<div id="popupcontent">';
