Index: node_embed.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/node_embed/node_embed.module,v
retrieving revision 1.5
diff -u -r1.5 node_embed.module
--- node_embed.module	8 Sep 2010 02:11:40 -0000	1.5
+++ node_embed.module	26 Nov 2010 20:28:38 -0000
@@ -44,7 +44,7 @@
  * Implementation of hook_preprocess_node()
  */
 function node_embed_preprocess_node(&$vars) {
-  if ($vars['node_embedded']) { 
+  if (isset($vars['node_embedded']) && $vars['node_embedded']) { 
     $vars['template_files'][] = "node-embed--default";
     $vars['template_files'][] = 'node-embed--' . $vars['type'];
   }
@@ -145,8 +145,7 @@
  * results in segment fault.
  */
 function node_embed_validate($form, &$form_state) {
-  $nid = $form['nid']['#value'];  
-  if ($nid) {
+  if (isset($form['nid']) && ($nid = $form['nid']['#value'])) {
     $needle = "[[nid:$nid]]";
     $found = strpos($form['#post']['body'], $needle);
     if ($found === FALSE) {
Index: plugins/node_embed.inc
===================================================================
RCS file: plugins/node_embed.inc
diff -N plugins/node_embed.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/node_embed.inc	26 Nov 2010 20:28:39 -0000
@@ -0,0 +1,54 @@
+<?php
+/**
+ * Define a Wysiwyg plugin.
+ *
+ * Supposed to be used for "Drupal plugins" (cross-editor plugins) only.
+ *
+ * @see hook_wysiwyg_plugin()
+ *
+ * Each plugin file in the specified plugin directory of a module needs to
+ * define meta information about the particular plugin provided.
+ * The plugin's hook implementation function name is built out of the following:
+ * - 'hook': The name of the module providing the plugin.
+ * - 'INCLUDE': The basename of the file containing the plugin definition.
+ * - 'plugin': Static.
+ *
+ * For example, if your module's name is 'mymodule' and
+ * mymodule_wysiwyg_include_directory() returned 'plugins' as plugin directory,
+ * and this directory contains an "awesome" plugin file named 'awesome.inc', i.e.
+ *   sites/all/modules/mymodule/plugins/awesome.inc
+ * then the corresponding plugin hook function name is:
+ *   mymodule_awesome_plugin()
+ *
+ * @see hook_wysiwyg_include_directory()
+ *
+ * @return
+ *   Meta information about the buttons provided by this plugin.
+ */
+function node_embed_node_embed_plugin() {
+  jquery_ui_add(array('ui.draggable', 'ui.droppable', 'ui.dialog'));
+  
+  $plugins['node_embed'] = array(
+    // The plugin's title; 
+    'title' => t('Node Embed'),
+    // The (vendor) homepage of this plugin; defaults to ''.
+    'vendor url' => 'http://drupal.org/project/node_embed',
+    // The button image filename; defaults to '[plugin-name].png'.
+    'icon path' => drupal_get_path('module', 'node_embed').'/plugins/images',
+    'icon file' => 'icon.gif',
+    // The button title to display on hover.
+    'icon title' => t('Embed a Node'),
+    // An alternative path to the integration JavaScript; defaults to
+    // '[path-to-module]/[plugins-directory]/[plugin-name]'.
+    'js path' => drupal_get_path('module', 'node_embed') . '/plugins/js',
+    // An alternative filename of the integration JavaScript; defaults to
+    // '[plugin-name].js'.
+    'js file' => 'node_embed.js',
+    // An array of settings for this button. Required, but API is still in flux.
+    'settings' => array(
+    ),
+  );
+  return $plugins;
+}
+
+?>
\ No newline at end of file
Index: plugins/js/node_embed.js
===================================================================
RCS file: plugins/js/node_embed.js
diff -N plugins/js/node_embed.js
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/js/node_embed.js	26 Nov 2010 20:28:39 -0000
@@ -0,0 +1,87 @@
+(function ($) {
+
+/**
+ * Wysiwyg plugin button implementation for NodeEmbed plugin.
+ */
+Drupal.wysiwyg.plugins.node_embed = {
+  /**
+   * Return whether the passed node belongs to this plugin.
+   *
+   * @param node
+   *   The currently focused DOM element in the editor content.
+   */
+  isNode: function(node) {
+    return ($(node).is('img.wysiwyg-node_embed'));
+  },
+
+  /**
+   * Execute the button.
+   *
+   * @param data
+   *   An object containing data about the current selection:
+   *   - format: 'html' when the passed data is HTML content, 'text' when the
+   *     passed data is plain-text content.
+   *   - node: When 'format' is 'html', the focused DOM element in the editor.
+   *   - content: The textual representation of the focused/selected editor
+   *     content.
+   * @param settings
+   *   The plugin settings, as provided in the plugin's PHP include file.
+   * @param instanceId
+   *   The ID of the current editor instance.
+   */
+  invoke: function(data, settings, instanceId) {
+    
+    
+    //Show the node selection Dialog
+    var iframeSrc = Drupal.settings.basePath + 'ckeditor-node-embed';
+    var dialogMarkup = '<div id="nodeEmbedDialog" title="Embed a Node" style="width:100%; height:100%">' + 
+      '<iframe frameborder="no" style="width:500px; height:325px; border:0" src="'+iframeSrc+'"></iframe>' + 
+      '<div class="nodeEmbedButtons"><button id="buttonEmbedFromDialog">Embed</button><button id="buttonCancelDialog">Cancel</button></div>'
+      '</div>'
+    var dialog = $(dialogMarkup).dialog(
+      {
+        autoOpen: false,
+        height: 400,
+        width: 500,
+        modal: true,
+	 dialogClass: 'node_embed_dialog'
+      }
+    );
+    
+    $(dialog).bind( "dialogclose", function(event, ui) {
+      $(this).remove();
+    });
+    
+    $('#buttonEmbedFromDialog').click(function(e) {
+      var node_id = window.currentActiveNid; //set or updated whenever a node is selected
+      if( node_id != null && node_id != "" ) {
+        dialog.editor_content = '[[nid:' + node_id + ']]';
+      }
+
+      if(window.currentActiveNid && window.currentActiveNid != ""){
+        var edit_content = "[[nid:"+window.currentActiveNid+"]]";
+        if (data.format == 'html') {
+          var content = '<div class="embed">'+edit_content+'</div>';
+        }
+        else {
+          var content = edit_content;
+        }
+        //write the content to the editor
+        if (typeof content != 'undefined') {
+          Drupal.wysiwyg.instances[instanceId].insert(content);
+        }
+      }
+
+      $(dialog).dialog('close');
+    });
+    
+    $('#buttonCancelDialog').click(function(e) {
+      $(dialog).dialog('close');
+    });
+    
+    $(dialog).dialog('open');
+    // Generate HTML markup.
+    
+  },
+};
+})(jQuery);
\ No newline at end of file
Index: plugins/node_embed/node_embed.css
===================================================================
RCS file: plugins/node_embed/node_embed.css
diff -N plugins/node_embed/node_embed.css
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ plugins/node_embed/node_embed.css	26 Nov 2010 20:28:39 -0000
@@ -0,0 +1,50 @@
+.node_embed_dialog {
+  background:#e9e9e9;
+  border:2px solid #333;
+  border-radius:5px;
+  -moz-border-radius:5px;
+  -webkit-border-radius:5px;
+  padding:5px;
+}
+
+.node_embed_dialog .ui-dialog-titlebar {
+  margin:0;
+  padding:5px;
+  background-color:#333;
+  color:#fff;
+  border-radius:5px;
+  -moz-border-radius:5px;
+  -webkit-border-radius:5px;
+  position:relative;
+}
+
+.node_embed_dialog .ui-dialog-titlebar-close {
+  position:absolute;
+  right:5px;
+  color:#fff;
+}
+
+#nodeEmbedDialog {
+  margin:10px 0 0 0;
+}
+
+.node_embed_dialog .nodeEmbedButtons {
+  margin:0;
+  padding: 0;
+}
+
+.node_embed_dialog .nodeEmbedButtons button {
+  background: #333;
+  color: #fff;
+  border-radius:5px;
+  -moz-border-radius:5px;
+  -webkit-border-radius:5px;
+  border:1px solid #444;
+  padding:3px 10px;
+  margin:5px 5px 0 0;
+  cursor: pointer;
+}
+
+.node_embed_dialog .nodeEmbedButtons button:hover {
+  border:1px solid #999;
+}
\ No newline at end of file
