<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[16393] trunk/wp-includes/js/tinymce: Next pass on internal linking.</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/16393">16393</a></dd>
<dt>Author</dt> <dd>nacin</dd>
<dt>Date</dt> <dd>2010-11-15 23:48:24 +0000 (Mon, 15 Nov 2010)</dd>
</dl>

<h3>Log Message</h3>
<pre>Next pass on internal linking. Functional, but needs styling. props koopersmith, see <a href="http://trac.wordpress.org/ticket/11420">#11420</a>.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpincludesjstinymcepluginswplinkeditor_plugindevjs">trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js</a></li>
<li><a href="#trunkwpincludesjstinymcepluginswplinkeditor_pluginjs">trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.js</a></li>
<li><a href="#trunkwpincludesjstinymcepluginswplinkjswplinkdevjs">trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js</a></li>
<li><a href="#trunkwpincludesjstinymcewpmcelinkincludesphp">trunk/wp-includes/js/tinymce/wp-mce-link-includes.php</a></li>
<li><a href="#trunkwpincludesjstinymcewpmcelinkphp">trunk/wp-includes/js/tinymce/wp-mce-link.php</a></li>
<li><a href="#trunkwpincludesjstinymcewptinymcejsgz">trunk/wp-includes/js/tinymce/wp-tinymce.js.gz</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpincludesjstinymcepluginswplinkeditor_plugindevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js (16392 => 16393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js        2010-11-15 20:13:05 UTC (rev 16392)
+++ trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.dev.js        2010-11-15 23:48:24 UTC (rev 16393)
</span><span class="lines">@@ -13,8 +13,8 @@
</span><span class="cx">                         ed.addCommand('WP_Link', function() {
</span><span class="cx">                                 ed.windowManager.open({
</span><span class="cx">                                         file : tinymce.baseURL + '/wp-mce-link.php',
</span><del>-                                        width : 320,
-                                        height : 340,
</del><ins>+                                        width : 480,
+                                        height : 400,
</ins><span class="cx">                                         inline : 1
</span><span class="cx">                                 }, {
</span><span class="cx">                                         plugin_url : url // Plugin absolute URL
</span></span></pre></div>
<a id="trunkwpincludesjstinymcepluginswplinkeditor_pluginjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.js (16392 => 16393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.js        2010-11-15 20:13:05 UTC (rev 16392)
+++ trunk/wp-includes/js/tinymce/plugins/wplink/editor_plugin.js        2010-11-15 23:48:24 UTC (rev 16393)
</span><span class="lines">@@ -1 +1 @@
</span><del>-(function(){tinymce.create(&quot;tinymce.plugins.wpLink&quot;,{init:function(a,b){a.addCommand(&quot;WP_Link&quot;,function(){a.windowManager.open({file:tinymce.baseURL+&quot;/wp-mce-link.php&quot;,width:320,height:340,inline:1},{plugin_url:b})});a.addButton(&quot;link&quot;,{title:a.getLang(&quot;advanced.link_desc&quot;),cmd:&quot;WP_Link&quot;});a.addShortcut(&quot;alt+shift+a&quot;,a.getLang(&quot;advanced.link_desc&quot;),&quot;WP_Link&quot;);a.onNodeChange.add(function(d,c,e){c.setActive(&quot;wplink&quot;,e.nodeName==&quot;A&quot;)})},getInfo:function(){return{longname:&quot;WordPress Link Dialog&quot;,author:&quot;WordPress&quot;,authorurl:&quot;http://wordpress.org&quot;,infourl:&quot;&quot;,version:&quot;1.0&quot;}}});tinymce.PluginManager.add(&quot;wplink&quot;,tinymce.plugins.wpLink)})();
</del><span class="cx">\ No newline at end of file
</span><ins>+(function(){tinymce.create(&quot;tinymce.plugins.wpLink&quot;,{init:function(a,b){a.addCommand(&quot;WP_Link&quot;,function(){a.windowManager.open({file:tinymce.baseURL+&quot;/wp-mce-link.php&quot;,width:480,height:400,inline:1},{plugin_url:b})});a.addButton(&quot;link&quot;,{title:a.getLang(&quot;advanced.link_desc&quot;),cmd:&quot;WP_Link&quot;});a.addShortcut(&quot;alt+shift+a&quot;,a.getLang(&quot;advanced.link_desc&quot;),&quot;WP_Link&quot;);a.onNodeChange.add(function(d,c,e){c.setActive(&quot;wplink&quot;,e.nodeName==&quot;A&quot;)})},getInfo:function(){return{longname:&quot;WordPress Link Dialog&quot;,author:&quot;WordPress&quot;,authorurl:&quot;http://wordpress.org&quot;,infourl:&quot;&quot;,version:&quot;1.0&quot;}}});tinymce.PluginManager.add(&quot;wplink&quot;,tinymce.plugins.wpLink)})();
</ins><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesjstinymcepluginswplinkjswplinkdevjs"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js (16392 => 16393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js        2010-11-15 20:13:05 UTC (rev 16392)
+++ trunk/wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js        2010-11-15 23:48:24 UTC (rev 16393)
</span><span class="lines">@@ -1,138 +1,51 @@
</span><del>-(function($){
-        $.widget('wp.wpTabs', {
-                options: {},
-                _create: function() {
-                        var self = this,
-                                ul = this.element,
-                                lis = ul.children();
-                        
-                        this.active = lis.filter('.wp-tab-active');
-                        // Calculate panel IDs
-                        lis.each(function() {
-                                var panel = self._getPanel( $(this) );
-                                if ( self.active[0] == this )
-                                        panel.show();
-                                else
-                                        panel.hide();
-                        });
-                        
-                        ul.delegate('li', 'click.wpTabs', function(e) {
-                                var li = $(this);
-                                
-                                // Prevent any child link from redirecting the page.
-                                e.preventDefault();
-                                // Deactivate previous tab.
-                                self._getPanel( self.active ).hide();
-                                self.active.removeClass('wp-tab-active');
-                                self._trigger(&quot;hide&quot;, e, self.widget() );
-                                
-                                // Activate current tab.
-                                self.active = li.addClass('wp-tab-active');
-                                self._getPanel( self.active ).show();
-                                self._trigger(&quot;show&quot;, e, self.widget() );
-                        });
-                },
-                widget: function() {
-                        return {
-                                ul: this.element,
-                                tab: this.active,
-                                panel: this._getPanel( this.active )
-                        };
-                },
-                _setPanel: function( $el ) {
-                        var panel = $( '#' + $el.children('.wp-tab-for-id').val() );
-                        $el.data( 'wp-tab-panel', panel );
-                        return panel;
-                },
-                _getPanel: function( $el ) {
-                        var panel = $el.data('wp-tab-panel');
-                        return ( !panel || !panel.length ) ? this._setPanel( $el ) : panel;
-                }
-        });
-        // Create tab bars by default.
-        $(function(){
-                $('.wp-tab-bar').wpTabs();
-        });
-})(jQuery);
-
</del><span class="cx"> (function($){        
</span><del>-        var inputs = {}, panels, active, ed,
</del><ins>+        var inputs = {}, results = {}, ed,
</ins><span class="cx">         wpLink = {
</span><span class="cx">                 init : function() {
</span><span class="cx">                         var e, etarget, eclass;
</span><span class="cx">                         // Init shared vars
</span><span class="cx">                         ed = tinyMCEPopup.editor;
</span><ins>+                        
+                        
+                        // URL
+                        inputs.url = $('#url-field');
</ins><span class="cx">                         // Secondary options
</span><span class="cx">                         inputs.title = $('#link-title-field');
</span><span class="cx">                         // Advanced Options
</span><span class="cx">                         inputs.openInNewTab = $('#link-target-checkbox');
</span><ins>+                        inputs.search = $('#search-field');
+                        // Result lists
+                        results.search = $('#search-results');
+                        results.recent = $('#most-recent-results');
</ins><span class="cx">                         
</span><del>-                        panels = $('.link-panel');
-                        active = $('.link-panel-active');
-                        $('#link-panel-tab-bar').wpTabs({
-                                show: function(e, widget) {
-                                        active = widget.panel;
-                                        active.addClass('link-panel-active');
-                                        wpLink.maybeLoadPanel();
-                                },
-                                hide: function(e, widget) {
-                                        active.removeClass('link-panel-active');
-                                }
-                        })
-                        
-                        panels.each( function(){
-                                var linkType = this.id.replace(/^link-panel-id-/,''),
-                                        parts = linkType.split('-');
-                                $(this).data( 'link-type', {
-                                        full : linkType,
-                                        type : parts[0],
-                                        name : parts[1] || ''
-                                });
-                        });
-                        
</del><span class="cx">                         // Bind event handlers
</span><span class="cx">                         $('#wp-update').click( wpLink.update );
</span><span class="cx">                         $('#wp-cancel').click( function() { tinyMCEPopup.close(); } );
</span><del>-                        $('.link-panel .wp-tab-bar').wpTabs('option', 'show', wpLink.maybeLoadPanel );
-                        $('.link-panel .wp-tab-panel').delegate('li', 'click', wpLink.selectInternalLink );
-                        $('.wp-tab-panel-pagelinks').delegate('a', 'click', wpLink.selectPageLink );
-                        $('.link-panel .link-search-field').keyup( wpLink.searchInternalLinks );
</del><ins>+                        $('.query-results').delegate('li', 'click', wpLink.selectInternalLink );
+                        $('.wp-results-pagelinks').delegate('a', 'click', wpLink.selectPageLink );
+                        inputs.search.keyup( wpLink.searchInternalLinks );
</ins><span class="cx"> 
</span><del>-                        active.find('input.url-field').focus();
-
</del><span class="cx">                         // If link exists, select proper values.
</span><del>-                        e = ed.dom.getParent(ed.selection.getNode(), 'A');
-                        if ( ! e )
-                                return;
-                        
-                        active.find('input.url-field').val( e.href );
-                        inputs.title.val( ed.dom.getAttrib(e, 'title') );
-                        // Advanced Options
-                        
-                        if ( &quot;_blank&quot; == ed.dom.getAttrib(e, 'target') )
-                                inputs.openInNewTab.attr('checked','checked');
</del><ins>+                        if ( e = ed.dom.getParent(ed.selection.getNode(), 'A') ) {
+                                // Set URL and description.
+                                inputs.url.val( e.href );
+                                inputs.title.val( ed.dom.getAttrib(e, 'title') );
+                                // Set open in new tab.
+                                if ( &quot;_blank&quot; == ed.dom.getAttrib(e, 'target') )
+                                        inputs.openInNewTab.attr('checked','checked');
+                        }
</ins><span class="cx">                 },
</span><span class="cx">                 
</span><span class="cx">                 update : function() {
</span><span class="cx">                         var el,
</span><span class="cx">                                 ed = tinyMCEPopup.editor,
</span><span class="cx">                                 attrs = {
</span><ins>+                                        href : inputs.url.val(),
</ins><span class="cx">                                         title : inputs.title.val(),
</span><span class="cx">                                         target : inputs.openInNewTab.attr('checked') ? '_blank' : ''
</span><del>-                                }, defaultContent, e, b;
</del><ins>+                                }, e, b,
+                                defaultContent = attrs.title ? attrs.title : attrs.href;
</ins><span class="cx">                         
</span><del>-                        if ( active.hasClass('link-panel-custom') ) {
-                                attrs.href = active.find('input.url-field').val();
-                                defaultContent = attrs.href;
-                        } else {
-                                el = active.find('li.selected:visible');
-                                if ( !el.length )
-                                        return;
-                                
-                                attrs.href = el.children('input').val();
-                                defaultContent = el.text();
-                        }
-                        
</del><span class="cx">                         tinyMCEPopup.restoreSelection();
</span><span class="cx">                         e = ed.dom.getParent(ed.selection.getNode(), 'A');
</span><span class="cx">                         
</span><span class="lines">@@ -190,47 +103,14 @@
</span><span class="cx">                         tinyMCEPopup.close();
</span><span class="cx">                 },
</span><span class="cx">                 
</span><del>-                maybeLoadPanel : function() {
-                        var panel = active.find('.wp-tab-panel:visible');
-                        if ( panel.length &amp;&amp; panel.find('.wp-tab-panel-loading').length )
-                                wpLink.linkPanelAJAX( panel );
-                },
-                
-                linkPanelAJAX : function( $panel, params, callback ) {
-                        if ( ! $panel.hasClass('wp-tab-panel') )
-                                $panel = $panel.parents('.wp-tab-panel');
-                        
-                        if ( ! $panel.length )
-                                return;
-                                
-                        var query = $panel.children('.wp-tab-panel-query').val();
-                        
-                        wpLink.linkAJAX( $panel, $.extend({
-                                preset : query,
-                                page : 'all' == query ? 1 : 0
-                        }, params), function(r, lt) {
-                                var pagelinks = $panel.children('.wp-tab-panel-pagelinks');
-                                
-                                // Set results
-                                $panel.children('ul').html( wpLink.generateListMarkup( r['results'], lt ) );
-                                
-                                // Handle page links
-                                if ( r['page_links'] )
-                                        pagelinks.html( r['page_links'] ).show();
-                                else
-                                        pagelinks.hide();
-                                // Run callback
-                                if ( callback )
-                                        callback(r, lt);
-                        })
-                },
-                
</del><span class="cx">                 selectInternalLink : function() {
</span><span class="cx">                         var t = $(this);
</span><span class="cx">                         if ( t.hasClass('unselectable') )
</span><span class="cx">                                 return;
</span><span class="cx">                         t.siblings('.selected').removeClass('selected');
</span><span class="cx">                         t.addClass('selected');
</span><ins>+                        inputs.url.val( t.children('.item-permalink').val() );
+                        inputs.title.val( t.children('.item-title').text() );
</ins><span class="cx">                 },
</span><span class="cx">                 
</span><span class="cx">                 selectPageLink : function(e) {
</span><span class="lines">@@ -239,37 +119,62 @@
</span><span class="cx">                         page = page ? page[1] : 1; // If there's no match, it's the first page.
</span><span class="cx">                         e.preventDefault(); // Prevent the link from redirecting.
</span><span class="cx">                         
</span><del>-                        wpLink.linkPanelAJAX( $(this), { page : page });
</del><ins>+                        wpLink.linkAJAX( $(this), { page : page });
</ins><span class="cx">                 },
</span><span class="cx">                 
</span><span class="cx">                 searchInternalLinks : function() {
</span><del>-                        var t = $(this),
</del><ins>+                        var t = $(this), waiting,
+                                title = t.val();
+                        
+                        if ( title ) {
+                                results.recent.hide();
+                                results.search.show();
</ins><span class="cx">                                 waiting = t.siblings('img.waiting').show();
</span><del>-                                
-                        wpLink.linkPanelAJAX( t, { title : t.val() }, function(){ waiting.hide(); });
</del><ins>+                                wpLink.linkAJAX( results.search, { title : title }, function(){ waiting.hide(); });
+                        } else {
+                                results.search.hide();
+                                results.recent.show();
+                        }
</ins><span class="cx">                 },
</span><span class="cx">                 
</span><del>-                linkAJAX : function( el, params, callback ) {
-                        var linkType = el.parents('.link-panel').data('link-type');
</del><ins>+                linkAJAX : function( $panel, params, callback ) {
+                        if ( ! $panel.hasClass('query-results') )
+                                $panel = $panel.parents('.query-results');
+                        
+                        if ( ! $panel.length )
+                                return;
+                        
</ins><span class="cx">                         $.post( ajaxurl, $.extend({
</span><del>-                                action : 'wp-link-ajax',
-                                type : linkType.type,
-                                name : linkType.name
</del><ins>+                                action : 'wp-link-ajax'
</ins><span class="cx">                         }, params ), function(r) {
</span><del>-                                return callback(r, linkType); 
</del><ins>+                                var pagelinks = $panel.children('.wp-results-pagelinks');
+                                
+                                // Set results
+                                $panel.children('ul').html( wpLink.generateListMarkup( r['results'] ) );
+                                
+                                // Handle page links
+                                if ( r['page_links'] )
+                                        pagelinks.html( r['page_links'] ).show();
+                                else
+                                        pagelinks.hide();
+                                
+                                // Run callback
+                                if ( callback )
+                                        callback( r['results'] );
</ins><span class="cx">                         }, &quot;json&quot; );
</span><span class="cx">                 },
</span><span class="cx">                 
</span><del>-                generateListMarkup : function( results, linkType ) {
</del><ins>+                generateListMarkup : function( results ) {
</ins><span class="cx">                         var s = '';
</span><span class="cx">                         
</span><span class="cx">                         if ( ! results )
</span><del>-                                return '&lt;li class=&quot;no-matches-found unselectable&quot;&gt;&lt;em&gt;' + wpLinkL10n.noMatchesFound + '&lt;/em&gt;&lt;/li&gt;';
</del><ins>+                                return '&lt;li class=&quot;no-matches-found unselectable&quot;&gt;&lt;span class=&quot;item-title&quot;&gt;&lt;em&gt;' + wpLinkL10n.noMatchesFound + '&lt;/em&gt;&lt;/span&gt;&lt;/li&gt;';
</ins><span class="cx">                         
</span><span class="cx">                         $.each( results, function() {
</span><del>-                                s+= '&lt;li id=&quot;link-to-' + linkType.full + '-' + this['ID'] + '&quot;&gt;';
-                                s+= '&lt;input type=&quot;hidden&quot; value=&quot;' + this['permalink'] + '&quot; /&gt;';
</del><ins>+                                s+= '&lt;li&gt;&lt;input type=&quot;hidden&quot; class=&quot;item-permalink&quot; value=&quot;' + this['permalink'] + '&quot; /&gt;';
+                                s+= '&lt;span class=&quot;item-title&quot;&gt;'
</ins><span class="cx">                                 s+= this['title'] ? this['title'] : '&lt;em&gt;'+ wpLinkL10n.untitled + '&lt;/em&gt;';
</span><ins>+                                s+= '&lt;/span&gt;&lt;span class=&quot;item-info&quot;&gt;' + this['info'] + '&lt;/span&gt;';
</ins><span class="cx">                                 s+= '&lt;/li&gt;';
</span><span class="cx">                         });
</span><span class="cx">                         return s;
</span></span></pre></div>
<a id="trunkwpincludesjstinymcewpmcelinkincludesphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/tinymce/wp-mce-link-includes.php (16392 => 16393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/tinymce/wp-mce-link-includes.php        2010-11-15 20:13:05 UTC (rev 16392)
+++ trunk/wp-includes/js/tinymce/wp-mce-link-includes.php        2010-11-15 23:48:24 UTC (rev 16393)
</span><span class="lines">@@ -1,151 +1,35 @@
</span><span class="cx"> &lt;?php
</span><ins>+// args expects optionally 'pagenum' and 's'
+function wp_link_query( $args = array() ) {
+        $pts = get_post_types( array( 'publicly_queryable' =&gt; true ), 'objects' );
+        $pt_names = array_keys( $pts );
</ins><span class="cx">         
</span><del>-class WP_Tab_Bar {
-        var $tabs = array();
-        
-        var $id = '';
-        var $classes = array();
-        
-        var $selected = '';
-        
-        function add( $id, $label, $url='' ) {
-                array_push( $this-&gt;tabs, array(
-                        'label' =&gt; $label,
-                        'for' =&gt; $id,
-                        'url' =&gt; $url
-                ));
-        }
-        
-        function select( $id ) {
-                $this-&gt;selected = $id;
-        }
-        
-        function render( $echo=true ) {
-                if ( empty( $this-&gt;selected ) )
-                        $this-&gt;selected = $this-&gt;tabs[0]['for'];
-
-                array_unshift( $this-&gt;classes, 'wp-tab-bar' );
-                
-                $out = &quot;&lt;ul id='$this-&gt;id' class='&quot; . esc_attr( implode( ' ', $this-&gt;classes ) ) . &quot;'&gt;&quot;;
-                foreach( $this-&gt;tabs as $tab ) {
-                        if ( !isset($tab['url']) )
-                                $tab['url'] = '';
-
-                        $out.= &quot;&lt;li class='&quot;;
-                        $out.= $this-&gt;selected == $tab['for'] ? 'wp-tab-active' : '';
-                        $out.= &quot;'&gt;&lt;input type='hidden' class='wp-tab-for-id' value='{$tab['for']}' /&gt;&quot;;
-                        $out.= &quot;&lt;a href='{$tab['url']}#{$tab['for']}'&gt;&quot;;
-                        $out.= &quot;{$tab['label']}&lt;/a&gt;&lt;/li&gt;&quot;;
-                }
-                $out.= &quot;&lt;/ul&gt;&quot;;
-
-                if ( $echo )
-                        echo $out;
-
-                return $out;
-        }
-}
-
-function wp_link_panel_custom() { ?&gt;
-        &lt;div id=&quot;link-panel-id-custom&quot; class=&quot;link-panel link-panel-custom link-panel-active&quot;&gt;
-                &lt;input type=&quot;hidden&quot; class=&quot;link-panel-type&quot; value=&quot;custom&quot; /&gt;
-                &lt;label&gt;
-                        &lt;span&gt;&lt;?php _e('URL:'); ?&gt;&lt;/span&gt;&lt;input class=&quot;url-field&quot; type=&quot;text&quot; /&gt;
-                &lt;/label&gt;
-        &lt;/div&gt;
-&lt;?php }
-
-function wp_link_panel_structure( $panel_type, $name, $queries ) {
-        $id = $panel_type . '-' . $name;
-        
-        ?&gt;
-        &lt;div id=&quot;link-panel-id-&lt;?php echo $id; ?&gt;&quot; class=&quot;link-panel link-panel-&lt;?php echo $panel_type; ?&gt;&quot;&gt;
-                &lt;!-- &lt;input type=&quot;hidden&quot; class=&quot;link-panel-type&quot; value=&quot;&lt;?php echo $panel_type; ?&gt;&quot; /&gt; --&gt;
-                &lt;!-- &lt;input type=&quot;hidden&quot; class=&quot;link-panel-id&quot; value=&quot;&quot; /&gt; --&gt;
-                &lt;?php
-                
-                $tb = new WP_Tab_Bar();
-                foreach( $queries as $i =&gt; $query ) {
-                        $queries[$i]['id'] = &quot;$id-{$query['preset']}&quot;;
-                        $tb-&gt;add( $queries[$i]['id'], $query['label'] );
-                }
-                $tb-&gt;render();
-
-                foreach( $queries as $query ): ?&gt;
-                        &lt;div id=&quot;&lt;?php echo $query['id']; ?&gt;&quot; class=&quot;wp-tab-panel&quot;&gt;
-                                &lt;input type=&quot;hidden&quot; class=&quot;wp-tab-panel-query&quot; value=&quot;&lt;?php echo $query['preset']; ?&gt;&quot; /&gt;
-                                
-                        &lt;?php if ( 'search' == $query['preset'] ): ?&gt;
-                                &lt;label for=&quot;&lt;?php echo $id; ?&gt;-search-field&quot; class=&quot;link-search-wrapper&quot;&gt;
-                                        &lt;span&gt;&lt;?php _e('Search:'); ?&gt;&lt;/span&gt;
-                                        &lt;input type=&quot;text&quot; id=&quot;&lt;?php echo $id; ?&gt;-search-field&quot; class=&quot;link-search-field&quot; /&gt;
-                                        &lt;img class=&quot;waiting&quot; src=&quot;&lt;?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?&gt;&quot; alt=&quot;&quot; /&gt;
-                                &lt;/label&gt;
-                                &lt;ul id=&quot;&lt;?php echo $id; ?&gt;-search-results&quot; class=&quot;link-search-results&quot;&gt;&lt;/ul&gt;
-                                
-                        &lt;?php else: ?&gt;
-                                &lt;div class=&quot;wp-tab-panel-pagelinks wp-tab-panel-pagelinks-top&quot;&gt;&lt;/div&gt;
-                                &lt;ul&gt;
-                                        &lt;li class=&quot;wp-tab-panel-loading unselectable&quot;&gt;&lt;em&gt;&lt;?php _e('Loading...'); ?&gt;&lt;/em&gt;&lt;/li&gt;
-                                &lt;/ul&gt;
-                                &lt;div class=&quot;wp-tab-panel-pagelinks wp-tab-panel-pagelinks-bottom&quot;&gt;&lt;/div&gt;
-                        &lt;?php endif; ?&gt;
-                        &lt;/div&gt;
-                &lt;?php endforeach; ?&gt;
-        &lt;/div&gt;
-&lt;?php }
-
-function wp_link_query_post_type( $pt_obj, $preset='all', $opts=array() ) {
-        $args_base = array(
-                'post_type' =&gt; $pt_obj-&gt;name,
</del><ins>+        $query = array(
+                'post_type' =&gt; $pt_names,
</ins><span class="cx">                 'suppress_filters' =&gt; true,
</span><span class="cx">                 'update_post_term_cache' =&gt; false,
</span><span class="cx">                 'update_post_meta_cache' =&gt; false,
</span><span class="cx">                 'post_status' =&gt; 'publish',
</span><ins>+                'order' =&gt; 'DESC',
+                'orderby' =&gt; 'post_date',
+                'posts_per_page' =&gt; 20,
</ins><span class="cx">         );
</span><del>-        
-        switch( $preset ) {
-        case 'all':
-                $args = array_merge( $args_base, array(
-                        'order' =&gt; 'ASC',
-                        'orderby' =&gt; 'title',
-                        'posts_per_page' =&gt; 20,
-                ));
-                break;
-        case 'recent':
-                $args = array_merge( $args_base, array(
-                        'order' =&gt; 'DESC',
-                        'orderby' =&gt; 'post_date',
-                        'posts_per_page' =&gt; 15,
-                ));
-                break;
-        case 'search':
-                $args = array_merge( $args_base, array(
-                        's' =&gt; isset($opts['search']) ? $opts['search'] : '',
-                        'posts_per_page' =&gt; 10
-                ));
-                break;
-        }
-        
-        // Handle pages if a page number is specified.
-        if ( isset( $opts['pagenum'] ) &amp;&amp; isset( $args['posts_per_page'] ) ) {
-                $pages = array(
-                        'current' =&gt; $opts['pagenum'],
-                        'per_page' =&gt; $args['posts_per_page']
-                );
-                
-                if ( ! isset( $args['offset'] ) )
-                        $args['offset'] = 0 &lt; $opts['pagenum'] ? $args['posts_per_page'] * ( $opts['pagenum'] - 1 ) : 0;
-                $pages['offset'] = $args['offset'];
-        }
-        
-        // Allow args to be extended.
-        if ( isset( $opts['args'] ) )
-                $args = array_merge( $args, $opts['args'] );
-        
</del><ins>+
+        $args['pagenum'] = isset( $args['pagenum'] ) ? absint( $args['pagenum'] ) : 1;
+
+        if ( isset( $args['s'] ) )
+                $query['s'] = $args['s'];
+
+        $pagination = array(
+                'current'  =&gt; $args['pagenum'],
+                'per_page' =&gt; $query['posts_per_page'],
+        );
+
+        $query['offset'] = $pagination['offset'] = $args['pagenum'] &gt; 1 ? $query['posts_per_page'] * ( $args['pagenum'] - 1 ) : 0;
+
</ins><span class="cx">         // Do main query.
</span><span class="cx">         $get_posts = new WP_Query;
</span><del>-        $posts = $get_posts-&gt;query( $args );
</del><ins>+        $posts = $get_posts-&gt;query( $query );
</ins><span class="cx">         // Check if any posts were found.
</span><span class="cx">         if ( ! $get_posts-&gt;post_count )
</span><span class="cx">                 return false;
</span><span class="lines">@@ -153,57 +37,49 @@
</span><span class="cx">         // Build results.
</span><span class="cx">         $results = array();
</span><span class="cx">         foreach ( $posts as $post ) {
</span><ins>+                if ( 'post' == $post-&gt;post_type )
+                        $info = mysql2date( __( 'Y/m/d' ), $post-&gt;post_date );
+                else
+                        $info = $pts[ $post-&gt;post_type ]-&gt;labels-&gt;singular_name;
+                
</ins><span class="cx">                 $results[] = array(
</span><span class="cx">                         'ID' =&gt; $post-&gt;ID,
</span><del>-                        'title' =&gt; $post-&gt;post_title,
-                        'permalink' =&gt; get_permalink( $post-&gt;ID )
-                );
</del><ins>+                        'title' =&gt; esc_html( strip_tags($post-&gt;post_title) ),
+                        'permalink' =&gt; get_permalink( $post-&gt;ID ),
+                        'info' =&gt; $info,
+                );;
</ins><span class="cx">         }
</span><ins>+
+        // Remaining pagination values.
+        $pagination['max'] = $get_posts-&gt;max_num_pages;
+        $pagination['page_links'] = paginate_links( array(
+                'prev_text' =&gt; __('&amp;laquo;'),
+                'next_text' =&gt; __('&amp;raquo;'),
+                'total' =&gt; $pagination['max'],
+                'current' =&gt; $pagination['current']
+        ) );
+
</ins><span class="cx">         // Build response.
</span><span class="cx">         $resp = array(
</span><span class="cx">                 'query' =&gt; $get_posts,
</span><span class="cx">                 'objects' =&gt; $posts,
</span><del>-                'results' =&gt; $results
</del><ins>+                'results' =&gt; $results,
+                'pages' =&gt; $pagination,
</ins><span class="cx">         );
</span><del>-        
-        // Set remaining pages values.
-        if ( isset( $pages ) ) {
-                $pages['max'] = $resp['query']-&gt;max_num_pages;
-                $pages['page_links'] = paginate_links( array(
-                        'prev_text' =&gt; __('&amp;laquo;'),
-                        'next_text' =&gt; __('&amp;raquo;'),
-                        'total' =&gt; $pages['max'],
-                        'current' =&gt; $pages['current']
-                ));
-                $resp['pages'] = $pages;
-        }
-        
</del><ins>+
</ins><span class="cx">         return $resp;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> function wp_link_ajax( $request ) {
</span><del>-        if ( !isset($request['type']) || !isset($request['name']) || !isset($request['preset']) )
-                die('-1');
</del><ins>+        // Searches have a title term.
+        if ( isset( $request['title'] ) )
+                $args['s'] = stripslashes( $request['title'] );
+        $args['pagenum'] = ! empty( $request['page'] ) ? absint( $request['page'] ) : 1;
</ins><span class="cx"> 
</span><del>-        // Run only presets we recognize.
-        if ( 'pt' != $request['type'] || ! in_array( $request['preset'], array('all','search','recent') ) )
-                die('-1');
-        // Searches must have a search term.
-        else if ( 'search' == $request['preset'] &amp;&amp; !isset($request['title']) )
-                die('-1');
</del><ins>+        $resp = wp_link_query( $args );
</ins><span class="cx"> 
</span><del>-        $opts = array();
-        if ( 'search' == $request['preset'] ) {
-                $opts['search'] = $request['title'];
-        } else if ( ! empty( $request['page'] ) ) {
-                $opts['pagenum'] = $request['page'];
-        }
-                
-        if ( 'pt' == $request['type'] &amp;&amp; $obj = get_post_type_object($request['name']) )
-                $resp = wp_link_query_post_type( $obj, $request['preset'], $opts );
-
</del><span class="cx">         if ( ! isset( $resp ) )
</span><del>-                die('0');
</del><ins>+                die( '0' );
</ins><span class="cx"> 
</span><span class="cx">         $json = array( 'results' =&gt; $resp['results'] );
</span><span class="cx">         if ( isset( $resp['pages'] ) &amp;&amp; !empty( $resp['pages']['page_links'] ) )
</span><span class="lines">@@ -212,4 +88,5 @@
</span><span class="cx">         echo json_encode( $json );
</span><span class="cx">         echo &quot;\n&quot;;
</span><span class="cx"> }
</span><ins>+
</ins><span class="cx"> ?&gt;
</span><span class="cx">\ No newline at end of file
</span></span></pre></div>
<a id="trunkwpincludesjstinymcewpmcelinkphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/js/tinymce/wp-mce-link.php (16392 => 16393)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/js/tinymce/wp-mce-link.php        2010-11-15 20:13:05 UTC (rev 16392)
+++ trunk/wp-includes/js/tinymce/wp-mce-link.php        2010-11-15 23:48:24 UTC (rev 16393)
</span><span class="lines">@@ -23,8 +23,12 @@
</span><span class="cx"> &lt;?php
</span><span class="cx"> wp_print_scripts( array('jquery', 'jquery-ui-widget') );
</span><span class="cx"> ?&gt;
</span><del>-&lt;script type=&quot;text/javascript&quot; src=&quot;plugins/wplink/js/wplink.js?ver=20101023&quot;&gt;&lt;/script&gt;
</del><span class="cx"> &lt;?php
</span><ins>+        $suffix = defined('SCRIPT_DEBUG') &amp;&amp; SCRIPT_DEBUG ? '.dev' : '';
+        $src = &quot;plugins/wplink/js/wplink$suffix.js?ver=20101023&quot;;
+?&gt;
+&lt;script type=&quot;text/javascript&quot; src=&quot;&lt;?php echo $src; ?&gt;&quot;&gt;&lt;/script&gt;
+&lt;?php
</ins><span class="cx"> wp_admin_css( 'global', true );
</span><span class="cx"> wp_admin_css( 'wp-admin', true );
</span><span class="cx"> register_admin_color_schemes();
</span><span class="lines">@@ -43,26 +47,11 @@
</span><span class="cx">         height: 2em;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-#link-header,
</del><span class="cx"> #link-options,
</span><span class="cx"> #link-advanced-options {
</span><span class="cx">         padding: 5px;
</span><span class="cx">         border-bottom: 1px solid #dfdfdf;
</span><span class="cx"> }
</span><del>-        #link-header {
-                padding-bottom: 0;
-                background: #fff;
-        }
-        #link-panel-tab-bar li {
-                font-weight: bold;
-                border: #dfdfdf solid;
-                margin-right: 5px;
-                border-width: 1px 1px 0;
-        }
-        #link-panel-tab-bar .wp-tab-active {
-                border-color:#ccc;
-                background-color: #f1f1f1;
-        }
</del><span class="cx"> 
</span><span class="cx"> #link-type {
</span><span class="cx">         width: 140px;
</span><span class="lines">@@ -77,12 +66,9 @@
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx"> label input[type=&quot;text&quot;] {
</span><del>-        width: 220px;
</del><ins>+        width: 360px;
+        margin-top: 5px;
</ins><span class="cx"> }
</span><del>-        .wp-tab-panel label input[type=&quot;text&quot;] {
-                float: left;
-                width: 200px;
-        }
</del><span class="cx"> 
</span><span class="cx"> label span {
</span><span class="cx">         display: inline-block;
</span><span class="lines">@@ -90,20 +76,21 @@
</span><span class="cx">         text-align: right;
</span><span class="cx">         padding-right: 5px;
</span><span class="cx"> }
</span><del>-        .wp-tab-panel label span {
-                width: auto;
-                text-align: left;
-                float: left;
-                margin-top: 3px;
-        }
</del><span class="cx">         .link-search-wrapper {
</span><span class="cx">                 padding: 5px;
</span><del>-                border-bottom: solid 1px #dfdfdf;
</del><span class="cx">                 display: block;
</span><span class="cx">                 overflow: hidden;
</span><span class="cx">         }
</span><ins>+                .link-search-wrapper span {
+                        float: left;
+                        margin-top: 6px;
+                }
+                .link-search-wrapper input[type=&quot;text&quot;] {
+                        float: left;
+                        width: 220px;
+                }
</ins><span class="cx">                 .link-search-wrapper img.waiting {
</span><del>-                        margin: 4px 1px 0 4px;
</del><ins>+                        margin: 8px 1px 0 4px;
</ins><span class="cx">                         float: left;
</span><span class="cx">                         display: none;
</span><span class="cx">                 }
</span><span class="lines">@@ -116,9 +103,53 @@
</span><span class="cx">                 margin-left: 10px;
</span><span class="cx">                 font-size: 11px;
</span><span class="cx">         }
</span><ins>+        
+.query-results {
+        border: #dfdfdf solid;
+        border-width: 1px 0;
+        margin: 5px 0;
+        background: #fff;
+        height: 220px;
+        overflow: auto;
+}
+        .query-results li {
+                margin-bottom: 0;
+                border-bottom: 1px solid #dfdfdf;
+                color: #555;
+                padding: 4px 6px;
+                cursor: pointer;
+        }
+        .query-results li:hover {
+                background: #EAF2FA;
+                color: #333;
+        }
+        .query-results li.selected {
+                background: #f1f1f1;
+                font-weight: bold;
+                color: #333;
+        }
+.item-info {
+        text-transform: uppercase;
+        color: #aaa;
+        font-weight: bold;
+        font-size: 11px;
+        float: right;
+}
+#search-results {
+        display: none;
+}
+        
+.wp-results-pagelinks {
+        padding:4px 0;
+        margin:0 auto;
+        text-align:center;
+}
+        .wp-results-pagelinks-top {
+                border-bottom: 1px solid #dfdfdf;
+        }
</ins><span class="cx"> 
</span><span class="cx"> .submitbox {
</span><del>-        padding: 5px;
</del><ins>+        padding: 5px 5px 0;
</ins><span class="cx">         font-size: 11px;
</span><span class="cx">         overflow: auto;
</span><span class="cx">         height: 29px;
</span><span class="lines">@@ -134,71 +165,18 @@
</span><span class="cx"> #wp-update a {
</span><span class="cx">         display: inline-block;
</span><span class="cx"> }
</span><del>-.wp-tab-active,
-.wp-tab-panel {
-        background: #fff;
-}
-        .wp-tab-panel {
-                height: 160px;
-                padding: 0;
-        }
-.wp-tab-panel li {
-        margin-bottom: 0;
-        border-bottom: 1px solid #dfdfdf;
-        color: #555;
-        padding: 4px 6px;
-        cursor: pointer;
-}
-        .wp-tab-panel li:hover {
-                background: #EAF2FA;
-                color: #333;
-        }
-        .wp-tab-panel li.selected {
-                background: #f1f1f1;
-                font-weight: bold;
-                color: #333;
-        }
-.wp-tab-panel-pagelinks {
-        display: none;
-        padding:4px 0;
-        margin:0 auto;
-        text-align:center;
-}
-        .wp-tab-panel-pagelinks-top {
-                border-bottom: 1px solid #dfdfdf;
-        }
</del><span class="cx"> &lt;/style&gt;
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;?php
</span><del>-// @TODO: Support custom post types.
-// $pts = get_post_types( array( 'public' =&gt; true ), 'objects' );
-$pts = array( get_post_type_object( 'post' ), get_post_type_object( 'page' ) );
-$queries = array(
-        array( 'preset' =&gt; 'all', 'label' =&gt; __('View All') ),
-        array( 'preset' =&gt; 'recent', 'label' =&gt; __('Most Recent') ),
-        array( 'preset' =&gt; 'search', 'label' =&gt; __('Search') )
-);
</del><span class="cx"> 
</span><del>-$tb = new WP_Tab_Bar();
-$tb-&gt;id = 'link-panel-tab-bar';
-$tb-&gt;add( 'link-panel-id-custom', __('External Link') );
-foreach( $pts as $pt ) {
-        $tb-&gt;add( &quot;link-panel-id-pt-$pt-&gt;name&quot;, $pt-&gt;labels-&gt;singular_name );
-}
</del><span class="cx"> 
</span><del>-
</del><span class="cx"> ?&gt;
</span><span class="cx"> &lt;body id=&quot;post-body&quot;&gt;
</span><del>-&lt;div id=&quot;link-header&quot;&gt;
-        &lt;?php $tb-&gt;render(); ?&gt;
-&lt;/div&gt;
</del><span class="cx"> &lt;div id=&quot;link-selector&quot;&gt;
</span><del>-        &lt;?php
-        wp_link_panel_custom();
-        foreach( $pts as $pt )
-                wp_link_panel_structure('pt', $pt-&gt;name, $queries);
-        ?&gt;
</del><span class="cx">         &lt;div id=&quot;link-options&quot;&gt;
</span><ins>+                &lt;label for=&quot;url-field&quot;&gt;
+                        &lt;span&gt;&lt;?php _e('URL:'); ?&gt;&lt;/span&gt;&lt;input id=&quot;url-field&quot; type=&quot;text&quot; /&gt;
+                &lt;/label&gt;
</ins><span class="cx">                 &lt;label for=&quot;link-title-field&quot;&gt;
</span><span class="cx">                         &lt;span&gt;&lt;?php _e('Description:'); ?&gt;&lt;/span&gt;&lt;input id=&quot;link-title-field&quot; type=&quot;text&quot; /&gt;
</span><span class="cx">                 &lt;/label&gt;
</span><span class="lines">@@ -206,6 +184,40 @@
</span><span class="cx">                         &lt;input type=&quot;checkbox&quot; id=&quot;link-target-checkbox&quot; /&gt;&lt;span&gt;&lt;?php _e('Open in new tab'); ?&gt;&lt;/span&gt;
</span><span class="cx">                 &lt;/label&gt;
</span><span class="cx">         &lt;/div&gt;
</span><ins>+        &lt;div id=&quot;search-panel&quot;&gt;
+                &lt;label for=&quot;search-field&quot; class=&quot;link-search-wrapper&quot;&gt;
+                        &lt;span&gt;&lt;?php _e('Search:'); ?&gt;&lt;/span&gt;
+                        &lt;input type=&quot;text&quot; id=&quot;search-field&quot; class=&quot;link-search-field&quot; /&gt;
+                        &lt;img class=&quot;waiting&quot; src=&quot;&lt;?php echo esc_url( admin_url( 'images/wpspin_light.gif' ) ); ?&gt;&quot; alt=&quot;&quot; /&gt;
+                &lt;/label&gt;
+                
+                &lt;div id=&quot;search-results&quot; class=&quot;query-results&quot;&gt;
+                        &lt;div class=&quot;wp-results-pagelinks wp-results-pagelinks-top&quot;&gt;&lt;/div&gt;
+                        &lt;ul&gt;
+                                &lt;li class=&quot;wp-results-loading unselectable&quot;&gt;&lt;em&gt;&lt;?php _e('Loading...'); ?&gt;&lt;/em&gt;&lt;/li&gt;
+                        &lt;/ul&gt;
+                        &lt;div class=&quot;wp-results-pagelinks wp-results-pagelinks-bottom&quot;&gt;&lt;/div&gt;
+                &lt;/div&gt;
+                
+                &lt;?php $most_recent = wp_link_query(); ?&gt;
+                &lt;div id=&quot;most-recent-results&quot; class=&quot;query-results&quot;&gt;
+                        &lt;div class=&quot;wp-results-pagelinks wp-results-pagelinks-top&quot;&gt;
+                                &lt;?php echo $most_recent['pages']['page_links']; ?&gt;
+                        &lt;/div&gt;
+                        &lt;ul&gt;
+                                &lt;?php foreach ( $most_recent['results'] as $item ): ?&gt;
+                                        &lt;li&gt;
+                                                &lt;input type=&quot;hidden&quot; class=&quot;item-permalink&quot; value=&quot;&lt;?php echo esc_url( $item['permalink'] ); ?&gt;&quot; /&gt;
+                                                &lt;span class=&quot;item-title&quot;&gt;&lt;?php echo $item['title']; ?&gt;&lt;/span&gt;
+                                                &lt;span class=&quot;item-info&quot;&gt;&lt;?php echo esc_html( $item['info'] ); ?&gt;&lt;/span&gt;
+                                        &lt;/li&gt;
+                                &lt;?php endforeach; ?&gt;
+                        &lt;/ul&gt;
+                        &lt;div class=&quot;wp-results-pagelinks wp-results-pagelinks-bottom&quot;&gt;
+                                &lt;?php echo $most_recent['pages']['page_links']; ?&gt;
+                        &lt;/div&gt;
+                &lt;/div&gt;
+        &lt;/div&gt;
</ins><span class="cx"> &lt;/div&gt;
</span><span class="cx"> &lt;div class=&quot;submitbox&quot;&gt;
</span><span class="cx">         &lt;div id=&quot;wp-cancel&quot;&gt;
</span></span></pre></div>
<a id="trunkwpincludesjstinymcewptinymcejsgz"></a>
<div class="binary"><h4>Modified: trunk/wp-includes/js/tinymce/wp-tinymce.js.gz</h4>
<pre class="diff"><span>
<span class="cx">(Binary files differ)
</span></span></pre></div>
</div>

</body>
</html>