Ticket #2702: ajax sortable pages for wp.19-09-07.patch

File ajax sortable pages for wp.19-09-07.patch, 70.4 KB (added by berpasan, 6 years ago)

This is the patch as of 19-september-2007. If you need it updated to the latest version of trunk just ask me and I will send it here.

  • wp-admin/admin-ajax.php

     
    312312        } 
    313313        die('0'); 
    314314break; 
     315case 'page-order-load' : 
     316         
     317        if ( !current_user_can('order_pages') ) { 
     318                header("HTTP/1.0 400 Bad Request"); 
     319                die(); 
     320        } 
     321         
     322        require_once('../wp-includes/class-page-order.php'); 
     323        require_once('../wp-includes/class-JSON.php'); 
     324        $wppo = new WP_Page_Order(); 
     325 
     326        //USER FETCHING DATA FROM THE SERVER 
     327        $json = new Services_JSON(SERVICES_JSON_LOOSE_TYPE); 
     328        $firstReq = $_REQUEST['firstIndex']; 
     329        $count = $_REQUEST['count']; 
     330        $hash = $wppo->get_paginated_pages($firstReq, $count); 
     331        $retJson = $json->encode($hash); 
     332        echo $retJson; 
     333        die(); 
     334 
     335case 'page-order-save' : 
     336         
     337        if ( !current_user_can('order_pages') ) { 
     338                header("HTTP/1.0 400 Bad Request"); 
     339                die(); 
     340        } 
     341         
     342        require_once('../wp-includes/class-page-order.php'); 
     343        $wppo = new WP_Page_Order(); 
     344 
     345        //USER SENDING DATA TO THE SERVER 
     346        if(isset($_POST['nested-sortable-widget']) && is_array($_POST['nested-sortable-widget']['items'])) { 
     347                //if there is only one chunk of data 
     348                $page_chunks = array($_POST['nested-sortable-widget']); 
     349        } elseif (isset($_POST['nested-sortable-widget'][0]) && is_array($_POST['nested-sortable-widget'][0]['items'])) { 
     350                //more than one chunk 
     351                $page_chunks = $_POST['nested-sortable-widget']; 
     352        } else { 
     353                header("HTTP/1.0 400 Bad Request"); 
     354                die(); 
     355        } 
     356        foreach($page_chunks as $key => $chunk) { 
     357                if(!$wppo->save_page_order($chunk['items'])) { 
     358                        $return_error = true; 
     359                } 
     360        } 
     361        if(!$return_error) { 
     362                echo "SUCCESS"; 
     363        } else { 
     364                header("HTTP/1.0 500 Internal Server Error"); 
     365        } 
     366        die(); 
     367         
     368break; 
    315369default : 
    316370        do_action( 'wp_ajax_' . $_POST['action'] ); 
    317371        die('0'); 
  • wp-admin/css/nestedsortablewidget.css

     
     1/*##################################*/ 
     2/*Units are written in em, considering a font size of 13px*/ 
     3 
     4.nsw-load-button { 
     5  margin: 14px 0 0 0 
     6} 
     7 
     8.nsw-list-wrap { 
     9        padding: 0em 1em 1em 1em; 
     10} 
     11 
     12.nsw-header-wrap { 
     13        padding: 1em 1em 0em 1em; 
     14} 
     15 
     16.nsw-wrap { 
     17        border:1px solid #BBBBBB; 
     18        padding: 1em 1em 1em 1em; 
     19} 
     20 
     21.nsw-drop { 
     22        background: #F0F8FF; 
     23        color: #A0A0A0; 
     24        text-align: center; 
     25        margin: 0.5em 0 0.5em 0; 
     26        padding: 1em 0 1em 0; 
     27        border-color: #F2F2F2 rgb(232, 232, 232) rgb(232, 232, 232) rgb(242, 242, 242); 
     28        border-style: solid; 
     29        border-width: 1px; 
     30} 
     31 
     32.nsw-active-drop { 
     33        background: yellow; 
     34} 
     35 
     36.nsw-nav-previous { 
     37float:left; 
     38} 
     39.nsw-nav-next { 
     40float:right; 
     41} 
     42.nsw-nav-links { 
     43display:block; 
     44margin-bottom:1em; 
     45margin-top:1em; 
     46text-align:center; 
     47clear: both; 
     48float: none; 
     49} 
     50 
     51.nsw-list-holder, .nsw-header { 
     52        list-style: none; 
     53        margin: 0; 
     54        padding: 0; 
     55} 
     56 
     57.nsw-clear { 
     58        clear: both; 
     59} 
     60 
     61.nsw-item , .nsw-header-item{ 
     62        margin: 0; 
     63        padding: 0; 
     64} 
     65 
     66.nsw-alt-cell{ 
     67        background: #f1f1f1 !important; 
     68} 
     69 
     70.nsw-item div div { 
     71        background: #f8f8f8; 
     72} 
     73 
     74.nsw-header-item div div { 
     75        background: #DFDFDF; 
     76        font-weight: bold; 
     77} 
     78 
     79.nsw-save-button, 
     80.nsw-disabled-save-button,  
     81.nsw-disabled-save-button:focus,  
     82.nsw-disabled-save-button:active,  
     83.nsw-save-button:focus { 
     84        background: url( ../images/fade-butt.png ); 
     85        background-color: #F2F2F2; 
     86        border-color:#CCCCCC rgb(153, 153, 153) rgb(153, 153, 153) rgb(204, 204, 204); 
     87        border-style:double; 
     88        border-width:3px; 
     89        color:#333333; 
     90        padding:0.25em; 
     91        float:right; 
     92} 
     93 
     94.nsw-disabled-save-button, 
     95.nsw-disabled-save-button:focus,  
     96.nsw-disabled-save-button:active { 
     97        color: #AAAAAA; 
     98} 
     99 
     100.nsw-save-button:active { 
     101        background:#F4F4F4 none repeat scroll 0%; 
     102        border-color:#999999 rgb(204, 204, 204) rgb(204, 204, 204) rgb(153, 153, 153); 
     103        border-style:double; 
     104        border-width:3px; 
     105} 
     106 
     107.nsw-progress { 
     108        background: center url(../images/progress_indicator.gif) no-repeat; 
     109        width:16px; 
     110        height:16px; 
     111        left: 50%; 
     112        top: 0.5em; 
     113        position: absolute; 
     114} 
     115 
     116.nsw-warning { 
     117        left: 30%; 
     118        top: 0.5em; 
     119        width: 40%; 
     120        position: absolute; 
     121        background: yellow; 
     122        border: solid 1px; 
     123        border-color:#CCCCCC rgb(153, 153, 153) rgb(153, 153, 153) rgb(204, 204, 204); 
     124        text-align: center; 
     125} 
     126 
     127.nsw-save-progress-wrap { 
     128        position: static; 
     129} 
     130 
     131.nsw-progress-warning-wrap { 
     132        position: relative; 
     133} 
     134 
     135.nsw-handle { 
     136        font-weight: bold; 
     137} 
     138 
     139.nsw-helper { 
     140border:2px dashed #777777; 
     141} 
  • wp-admin/edit-pages.php

     
    33$title = __('Pages'); 
    44$parent_file = 'edit.php'; 
    55wp_enqueue_script( 'listman' ); 
     6if ( current_user_can('order_pages') ) { 
     7        wp_enqueue_script( 'edit-page-order' ); 
     8} 
     9 
    610require_once('admin-header.php'); 
    711 
     12if ( current_user_can('order_pages') ) { 
     13        wp_admin_css('css/nestedsortablewidget'); 
     14} 
     15 
    816$post_stati  = array(   //      array( adj, noun ) 
    917                        'publish' => array(__('Published'), __('Published pages')), 
    1018                        'draft'   => array(__('Draft'), __('Draft pages')), 
  • wp-admin/includes/schema.php

    Cannot display: file marked as a binary type.
    svn:mime-type = application/octet-stream
    
    Property changes on: wp-admin\images\progress_indicator.gif
    ___________________________________________________________________
    Name: svn:mime-type
       + application/octet-stream
    
     
    251251        populate_roles_160(); 
    252252        populate_roles_210(); 
    253253        populate_roles_230(); 
     254        populate_roles_240(); 
    254255} 
    255256 
    256257function populate_roles_160() { 
     
    392393        } 
    393394} 
    394395 
     396function populate_roles_240(){ 
     397        $roles = array('administrator', 'editor'); 
     398        foreach ($roles as $role) { 
     399                $role = get_role($role); 
     400                if ( empty($role) ) 
     401                        continue; 
     402                $role->add_cap( 'order_pages' ); 
     403        } 
     404} 
     405 
    395406?> 
  • wp-admin/includes/upgrade.php

     
    194194 
    195195        if ( $wp_current_db_version < 5539 ) 
    196196                upgrade_230(); 
    197  
     197                 
    198198        if ( $wp_current_db_version < 6124 ) 
    199199                upgrade_230_old_tables(); 
    200200 
     201        if ( $wp_current_db_version < 6125 ) 
     202                upgrade_240(); 
     203                 
    201204        maybe_disable_automattic_widgets(); 
    202205 
    203206        $wp_rewrite->flush_rules(); 
     
    703706        $wpdb->query('DROP TABLE IF EXISTS ' . $wpdb->prefix . 'post2cat'); 
    704707} 
    705708 
     709function upgrade_240() { 
     710        populate_roles_240(); 
     711} 
     712 
    706713function upgrade_old_slugs() { 
    707714        // upgrade people who were using the Redirect Old Slugs plugin 
    708715        global $wpdb; 
  • wp-admin/js/edit-page-order.js

     
     1jQuery( function($){ 
     2         
     3  editPageOrderL10n.editButton += " \xBB"; 
     4  editPageOrderL10n.cancelButton = "\xAB " + editPageOrderL10n.cancelButton; 
     5  var addEditButtonEvent = function(button) { 
     6        wasSaved = false; 
     7        button.one ( 
     8          "click", 
     9          function() { 
     10                $('table.widefat').hide(); 
     11                $('#ajax-response').NestedSortableWidget({ 
     12                        loadUrl: "admin-ajax.php", 
     13                        loadUrlParams: {action:"page-order-load", cookie:document.cookie}, 
     14                        saveUrlParams: {action:"page-order-save", cookie:document.cookie}, 
     15                        loadRequestType : 'POST', 
     16                        text: editPageOrderL10n, 
     17                        colsWidth: [230, 170], 
     18                        paginate: true, 
     19                        greedy : true, 
     20                        itemsPerPage: 20, 
     21                        transitionAnim: 'fade-series', 
     22                        nestedSortCfg: { 
     23                                opacity: 0.6, 
     24                                fx:400, 
     25                                revert: true, 
     26                                rightToLeft: (document.dir === "rtl") ? true : false 
     27                        }, 
     28                        onInitialLoad: function() { 
     29                                addRemoveButtom(button, this); 
     30                        }, 
     31                        onLoadError: function() { 
     32                                addRemoveButtom(button, this); 
     33                        }, 
     34                        onSave: function() { 
     35                                wasSaved = true; 
     36                        } 
     37                });  
     38          } 
     39        ); 
     40  }; 
     41   
     42  var addRemoveButtom = function(button, widget) { 
     43        button.val(editPageOrderL10n.cancelButton).one ( 
     44          "click", 
     45          function() { 
     46                if (wasSaved) { 
     47                        window.location.reload(); 
     48                } else { 
     49                        $('table.widefat').show(); 
     50                        $(widget).NestedSortableWidgetDestroy(); 
     51                        button.val(editPageOrderL10n.editButton); 
     52                        addEditButtonEvent(button); 
     53                } 
     54          } 
     55        ); 
     56  }; 
     57   
     58 
     59  var editButton = $('<input class= "nsw-save-button nsw-load-button" type="submit"/>'); 
     60  $('#searchform').after(editButton); 
     61  editButton.val(editPageOrderL10n.editButton); 
     62  addEditButtonEvent(editButton); 
     63} 
     64); 
     65 No newline at end of file 
  • wp-includes/class-JSON.php

     
     1<?php 
     2/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 
     3 
     4/** 
     5 * Converts to and from JSON format. 
     6 * 
     7 * JSON (JavaScript Object Notation) is a lightweight data-interchange 
     8 * format. It is easy for humans to read and write. It is easy for machines 
     9 * to parse and generate. It is based on a subset of the JavaScript 
     10 * Programming Language, Standard ECMA-262 3rd Edition - December 1999. 
     11 * This feature can also be found in  Python. JSON is a text format that is 
     12 * completely language independent but uses conventions that are familiar 
     13 * to programmers of the C-family of languages, including C, C++, C#, Java, 
     14 * JavaScript, Perl, TCL, and many others. These properties make JSON an 
     15 * ideal data-interchange language. 
     16 * 
     17 * This package provides a simple encoder and decoder for JSON notation. It 
     18 * is intended for use with client-side Javascript applications that make 
     19 * use of HTTPRequest to perform server communication functions - data can 
     20 * be encoded into JSON notation for use in a client-side javascript, or 
     21 * decoded from incoming Javascript requests. JSON format is native to 
     22 * Javascript, and can be directly eval()'ed with no further parsing 
     23 * overhead 
     24 * 
     25 * All strings should be in ASCII or UTF-8 format! 
     26 * 
     27 * LICENSE: Redistribution and use in source and binary forms, with or 
     28 * without modification, are permitted provided that the following 
     29 * conditions are met: Redistributions of source code must retain the 
     30 * above copyright notice, this list of conditions and the following 
     31 * disclaimer. Redistributions in binary form must reproduce the above 
     32 * copyright notice, this list of conditions and the following disclaimer 
     33 * in the documentation and/or other materials provided with the 
     34 * distribution. 
     35 * 
     36 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 
     37 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 
     38 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 
     39 * NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
     40 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 
     41 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 
     42 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 
     43 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 
     44 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 
     45 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 
     46 * DAMAGE. 
     47 * 
     48 * @category 
     49 * @package     Services_JSON 
     50 * @author      Michal Migurski <mike-json@teczno.com> 
     51 * @author      Matt Knapp <mdknapp[at]gmail[dot]com> 
     52 * @author      Brett Stimmerman <brettstimmerman[at]gmail[dot]com> 
     53 * @copyright   2005 Michal Migurski 
     54 * @version     CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $ 
     55 * @license     http://www.opensource.org/licenses/bsd-license.php 
     56 * @link        http://pear.php.net/pepr/pepr-proposal-show.php?id=198 
     57 */ 
     58 
     59/** 
     60 * Marker constant for Services_JSON::decode(), used to flag stack state 
     61 */ 
     62define('SERVICES_JSON_SLICE',   1); 
     63 
     64/** 
     65 * Marker constant for Services_JSON::decode(), used to flag stack state 
     66 */ 
     67define('SERVICES_JSON_IN_STR',  2); 
     68 
     69/** 
     70 * Marker constant for Services_JSON::decode(), used to flag stack state 
     71 */ 
     72define('SERVICES_JSON_IN_ARR',  3); 
     73 
     74/** 
     75 * Marker constant for Services_JSON::decode(), used to flag stack state 
     76 */ 
     77define('SERVICES_JSON_IN_OBJ',  4); 
     78 
     79/** 
     80 * Marker constant for Services_JSON::decode(), used to flag stack state 
     81 */ 
     82define('SERVICES_JSON_IN_CMT', 5); 
     83 
     84/** 
     85 * Behavior switch for Services_JSON::decode() 
     86 */ 
     87define('SERVICES_JSON_LOOSE_TYPE', 16); 
     88 
     89/** 
     90 * Behavior switch for Services_JSON::decode() 
     91 */ 
     92define('SERVICES_JSON_SUPPRESS_ERRORS', 32); 
     93 
     94/** 
     95 * Converts to and from JSON format. 
     96 * 
     97 * Brief example of use: 
     98 * 
     99 * <code> 
     100 * // create a new instance of Services_JSON 
     101 * $json = new Services_JSON(); 
     102 * 
     103 * // convert a complexe value to JSON notation, and send it to the browser 
     104 * $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4))); 
     105 * $output = $json->encode($value); 
     106 * 
     107 * print($output); 
     108 * // prints: ["foo","bar",[1,2,"baz"],[3,[4]]] 
     109 * 
     110 * // accept incoming POST data, assumed to be in JSON notation 
     111 * $input = file_get_contents('php://input', 1000000); 
     112 * $value = $json->decode($input); 
     113 * </code> 
     114 */ 
     115class Services_JSON 
     116{ 
     117   /** 
     118    * constructs a new JSON instance 
     119    * 
     120    * @param    int     $use    object behavior flags; combine with boolean-OR 
     121    * 
     122    *                           possible values: 
     123    *                           - SERVICES_JSON_LOOSE_TYPE:  loose typing. 
     124    *                                   "{...}" syntax creates associative arrays 
     125    *                                   instead of objects in decode(). 
     126    *                           - SERVICES_JSON_SUPPRESS_ERRORS:  error suppression. 
     127    *                                   Values which can't be encoded (e.g. resources) 
     128    *                                   appear as NULL instead of throwing errors. 
     129    *                                   By default, a deeply-nested resource will 
     130    *                                   bubble up with an error, so all return values 
     131    *                                   from encode() should be checked with isError() 
     132    */ 
     133    function Services_JSON($use = 0) 
     134    { 
     135        $this->use = $use; 
     136    } 
     137 
     138   /** 
     139    * convert a string from one UTF-16 char to one UTF-8 char 
     140    * 
     141    * Normally should be handled by mb_convert_encoding, but 
     142    * provides a slower PHP-only method for installations 
     143    * that lack the multibye string extension. 
     144    * 
     145    * @param    string  $utf16  UTF-16 character 
     146    * @return   string  UTF-8 character 
     147    * @access   private 
     148    */ 
     149    function utf162utf8($utf16) 
     150    { 
     151        // oh please oh please oh please oh please oh please 
     152        if(function_exists('mb_convert_encoding')) { 
     153            return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16'); 
     154        } 
     155 
     156        $bytes = (ord($utf16{0}) << 8) | ord($utf16{1}); 
     157 
     158        switch(true) { 
     159            case ((0x7F & $bytes) == $bytes): 
     160                // this case should never be reached, because we are in ASCII range 
     161                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     162                return chr(0x7F & $bytes); 
     163 
     164            case (0x07FF & $bytes) == $bytes: 
     165                // return a 2-byte UTF-8 character 
     166                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     167                return chr(0xC0 | (($bytes >> 6) & 0x1F)) 
     168                     . chr(0x80 | ($bytes & 0x3F)); 
     169 
     170            case (0xFFFF & $bytes) == $bytes: 
     171                // return a 3-byte UTF-8 character 
     172                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     173                return chr(0xE0 | (($bytes >> 12) & 0x0F)) 
     174                     . chr(0x80 | (($bytes >> 6) & 0x3F)) 
     175                     . chr(0x80 | ($bytes & 0x3F)); 
     176        } 
     177 
     178        // ignoring UTF-32 for now, sorry 
     179        return ''; 
     180    } 
     181 
     182   /** 
     183    * convert a string from one UTF-8 char to one UTF-16 char 
     184    * 
     185    * Normally should be handled by mb_convert_encoding, but 
     186    * provides a slower PHP-only method for installations 
     187    * that lack the multibye string extension. 
     188    * 
     189    * @param    string  $utf8   UTF-8 character 
     190    * @return   string  UTF-16 character 
     191    * @access   private 
     192    */ 
     193    function utf82utf16($utf8) 
     194    { 
     195        // oh please oh please oh please oh please oh please 
     196        if(function_exists('mb_convert_encoding')) { 
     197            return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8'); 
     198        } 
     199 
     200        switch(strlen($utf8)) { 
     201            case 1: 
     202                // this case should never be reached, because we are in ASCII range 
     203                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     204                return $utf8; 
     205 
     206            case 2: 
     207                // return a UTF-16 character from a 2-byte UTF-8 char 
     208                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     209                return chr(0x07 & (ord($utf8{0}) >> 2)) 
     210                     . chr((0xC0 & (ord($utf8{0}) << 6)) 
     211                         | (0x3F & ord($utf8{1}))); 
     212 
     213            case 3: 
     214                // return a UTF-16 character from a 3-byte UTF-8 char 
     215                // see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     216                return chr((0xF0 & (ord($utf8{0}) << 4)) 
     217                         | (0x0F & (ord($utf8{1}) >> 2))) 
     218                     . chr((0xC0 & (ord($utf8{1}) << 6)) 
     219                         | (0x7F & ord($utf8{2}))); 
     220        } 
     221 
     222        // ignoring UTF-32 for now, sorry 
     223        return ''; 
     224    } 
     225 
     226   /** 
     227    * encodes an arbitrary variable into JSON format 
     228    * 
     229    * @param    mixed   $var    any number, boolean, string, array, or object to be encoded. 
     230    *                           see argument 1 to Services_JSON() above for array-parsing behavior. 
     231    *                           if var is a strng, note that encode() always expects it 
     232    *                           to be in ASCII or UTF-8 format! 
     233    * 
     234    * @return   mixed   JSON string representation of input var or an error if a problem occurs 
     235    * @access   public 
     236    */ 
     237    function encode($var) 
     238    { 
     239        switch (gettype($var)) { 
     240            case 'boolean': 
     241                return $var ? 'true' : 'false'; 
     242 
     243            case 'NULL': 
     244                return 'null'; 
     245 
     246            case 'integer': 
     247                return (int) $var; 
     248 
     249            case 'double': 
     250            case 'float': 
     251                return (float) $var; 
     252 
     253            case 'string': 
     254                // STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT 
     255                $ascii = ''; 
     256                $strlen_var = strlen($var); 
     257 
     258               /* 
     259                * Iterate over every character in the string, 
     260                * escaping with a slash or encoding to UTF-8 where necessary 
     261                */ 
     262                for ($c = 0; $c < $strlen_var; ++$c) { 
     263 
     264                    $ord_var_c = ord($var{$c}); 
     265 
     266                    switch (true) { 
     267                        case $ord_var_c == 0x08: 
     268                            $ascii .= '\b'; 
     269                            break; 
     270                        case $ord_var_c == 0x09: 
     271                            $ascii .= '\t'; 
     272                            break; 
     273                        case $ord_var_c == 0x0A: 
     274                            $ascii .= '\n'; 
     275                            break; 
     276                        case $ord_var_c == 0x0C: 
     277                            $ascii .= '\f'; 
     278                            break; 
     279                        case $ord_var_c == 0x0D: 
     280                            $ascii .= '\r'; 
     281                            break; 
     282 
     283                        case $ord_var_c == 0x22: 
     284                        case $ord_var_c == 0x2F: 
     285                        case $ord_var_c == 0x5C: 
     286                            // double quote, slash, slosh 
     287                            $ascii .= '\\'.$var{$c}; 
     288                            break; 
     289 
     290                        case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)): 
     291                            // characters U-00000000 - U-0000007F (same as ASCII) 
     292                            $ascii .= $var{$c}; 
     293                            break; 
     294 
     295                        case (($ord_var_c & 0xE0) == 0xC0): 
     296                            // characters U-00000080 - U-000007FF, mask 110XXXXX 
     297                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     298                            $char = pack('C*', $ord_var_c, ord($var{$c + 1})); 
     299                            $c += 1; 
     300                            $utf16 = $this->utf82utf16($char); 
     301                            $ascii .= sprintf('\u%04s', bin2hex($utf16)); 
     302                            break; 
     303 
     304                        case (($ord_var_c & 0xF0) == 0xE0): 
     305                            // characters U-00000800 - U-0000FFFF, mask 1110XXXX 
     306                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     307                            $char = pack('C*', $ord_var_c, 
     308                                         ord($var{$c + 1}), 
     309                                         ord($var{$c + 2})); 
     310                            $c += 2; 
     311                            $utf16 = $this->utf82utf16($char); 
     312                            $ascii .= sprintf('\u%04s', bin2hex($utf16)); 
     313                            break; 
     314 
     315                        case (($ord_var_c & 0xF8) == 0xF0): 
     316                            // characters U-00010000 - U-001FFFFF, mask 11110XXX 
     317                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     318                            $char = pack('C*', $ord_var_c, 
     319                                         ord($var{$c + 1}), 
     320                                         ord($var{$c + 2}), 
     321                                         ord($var{$c + 3})); 
     322                            $c += 3; 
     323                            $utf16 = $this->utf82utf16($char); 
     324                            $ascii .= sprintf('\u%04s', bin2hex($utf16)); 
     325                            break; 
     326 
     327                        case (($ord_var_c & 0xFC) == 0xF8): 
     328                            // characters U-00200000 - U-03FFFFFF, mask 111110XX 
     329                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     330                            $char = pack('C*', $ord_var_c, 
     331                                         ord($var{$c + 1}), 
     332                                         ord($var{$c + 2}), 
     333                                         ord($var{$c + 3}), 
     334                                         ord($var{$c + 4})); 
     335                            $c += 4; 
     336                            $utf16 = $this->utf82utf16($char); 
     337                            $ascii .= sprintf('\u%04s', bin2hex($utf16)); 
     338                            break; 
     339 
     340                        case (($ord_var_c & 0xFE) == 0xFC): 
     341                            // characters U-04000000 - U-7FFFFFFF, mask 1111110X 
     342                            // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     343                            $char = pack('C*', $ord_var_c, 
     344                                         ord($var{$c + 1}), 
     345                                         ord($var{$c + 2}), 
     346                                         ord($var{$c + 3}), 
     347                                         ord($var{$c + 4}), 
     348                                         ord($var{$c + 5})); 
     349                            $c += 5; 
     350                            $utf16 = $this->utf82utf16($char); 
     351                            $ascii .= sprintf('\u%04s', bin2hex($utf16)); 
     352                            break; 
     353                    } 
     354                } 
     355 
     356                return '"'.$ascii.'"'; 
     357 
     358            case 'array': 
     359               /* 
     360                * As per JSON spec if any array key is not an integer 
     361                * we must treat the the whole array as an object. We 
     362                * also try to catch a sparsely populated associative 
     363                * array with numeric keys here because some JS engines 
     364                * will create an array with empty indexes up to 
     365                * max_index which can cause memory issues and because 
     366                * the keys, which may be relevant, will be remapped 
     367                * otherwise. 
     368                * 
     369                * As per the ECMA and JSON specification an object may 
     370                * have any string as a property. Unfortunately due to 
     371                * a hole in the ECMA specification if the key is a 
     372                * ECMA reserved word or starts with a digit the 
     373                * parameter is only accessible using ECMAScript's 
     374                * bracket notation. 
     375                */ 
     376 
     377                // treat as a JSON object 
     378                if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) { 
     379                    $properties = array_map(array($this, 'name_value'), 
     380                                            array_keys($var), 
     381                                            array_values($var)); 
     382 
     383                    foreach($properties as $property) { 
     384                        if(Services_JSON::isError($property)) { 
     385                            return $property; 
     386                        } 
     387                    } 
     388 
     389                    return '{' . join(',', $properties) . '}'; 
     390                } 
     391 
     392                // treat it like a regular array 
     393                $elements = array_map(array($this, 'encode'), $var); 
     394 
     395                foreach($elements as $element) { 
     396                    if(Services_JSON::isError($element)) { 
     397                        return $element; 
     398                    } 
     399                } 
     400 
     401                return '[' . join(',', $elements) . ']'; 
     402 
     403            case 'object': 
     404                $vars = get_object_vars($var); 
     405 
     406                $properties = array_map(array($this, 'name_value'), 
     407                                        array_keys($vars), 
     408                                        array_values($vars)); 
     409 
     410                foreach($properties as $property) { 
     411                    if(Services_JSON::isError($property)) { 
     412                        return $property; 
     413                    } 
     414                } 
     415 
     416                return '{' . join(',', $properties) . '}'; 
     417 
     418            default: 
     419                return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS) 
     420                    ? 'null' 
     421                    : new Services_JSON_Error(gettype($var)." can not be encoded as JSON string"); 
     422        } 
     423    } 
     424 
     425   /** 
     426    * array-walking function for use in generating JSON-formatted name-value pairs 
     427    * 
     428    * @param    string  $name   name of key to use 
     429    * @param    mixed   $value  reference to an array element to be encoded 
     430    * 
     431    * @return   string  JSON-formatted name-value pair, like '"name":value' 
     432    * @access   private 
     433    */ 
     434    function name_value($name, $value) 
     435    { 
     436        $encoded_value = $this->encode($value); 
     437 
     438        if(Services_JSON::isError($encoded_value)) { 
     439            return $encoded_value; 
     440        } 
     441 
     442        return $this->encode(strval($name)) . ':' . $encoded_value; 
     443    } 
     444 
     445   /** 
     446    * reduce a string by removing leading and trailing comments and whitespace 
     447    * 
     448    * @param    $str    string      string value to strip of comments and whitespace 
     449    * 
     450    * @return   string  string value stripped of comments and whitespace 
     451    * @access   private 
     452    */ 
     453    function reduce_string($str) 
     454    { 
     455        $str = preg_replace(array( 
     456 
     457                // eliminate single line comments in '// ...' form 
     458                '#^\s*//(.+)$#m', 
     459 
     460                // eliminate multi-line comments in '/* ... */' form, at start of string 
     461                '#^\s*/\*(.+)\*/#Us', 
     462 
     463                // eliminate multi-line comments in '/* ... */' form, at end of string 
     464                '#/\*(.+)\*/\s*$#Us' 
     465 
     466            ), '', $str); 
     467 
     468        // eliminate extraneous space 
     469        return trim($str); 
     470    } 
     471 
     472   /** 
     473    * decodes a JSON string into appropriate variable 
     474    * 
     475    * @param    string  $str    JSON-formatted string 
     476    * 
     477    * @return   mixed   number, boolean, string, array, or object 
     478    *                   corresponding to given JSON input string. 
     479    *                   See argument 1 to Services_JSON() above for object-output behavior. 
     480    *                   Note that decode() always returns strings 
     481    *                   in ASCII or UTF-8 format! 
     482    * @access   public 
     483    */ 
     484    function decode($str) 
     485    { 
     486        $str = $this->reduce_string($str); 
     487 
     488        switch (strtolower($str)) { 
     489            case 'true': 
     490                return true; 
     491 
     492            case 'false': 
     493                return false; 
     494 
     495            case 'null': 
     496                return null; 
     497 
     498            default: 
     499                $m = array(); 
     500 
     501                if (is_numeric($str)) { 
     502                    // Lookie-loo, it's a number 
     503 
     504                    // This would work on its own, but I'm trying to be 
     505                    // good about returning integers where appropriate: 
     506                    // return (float)$str; 
     507 
     508                    // Return float or int, as appropriate 
     509                    return ((float)$str == (integer)$str) 
     510                        ? (integer)$str 
     511                        : (float)$str; 
     512 
     513                } elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) { 
     514                    // STRINGS RETURNED IN UTF-8 FORMAT 
     515                    $delim = substr($str, 0, 1); 
     516                    $chrs = substr($str, 1, -1); 
     517                    $utf8 = ''; 
     518                    $strlen_chrs = strlen($chrs); 
     519 
     520                    for ($c = 0; $c < $strlen_chrs; ++$c) { 
     521 
     522                        $substr_chrs_c_2 = substr($chrs, $c, 2); 
     523                        $ord_chrs_c = ord($chrs{$c}); 
     524 
     525                        switch (true) { 
     526                            case $substr_chrs_c_2 == '\b': 
     527                                $utf8 .= chr(0x08); 
     528                                ++$c; 
     529                                break; 
     530                            case $substr_chrs_c_2 == '\t': 
     531                                $utf8 .= chr(0x09); 
     532                                ++$c; 
     533                                break; 
     534                            case $substr_chrs_c_2 == '\n': 
     535                                $utf8 .= chr(0x0A); 
     536                                ++$c; 
     537                                break; 
     538                            case $substr_chrs_c_2 == '\f': 
     539                                $utf8 .= chr(0x0C); 
     540                                ++$c; 
     541                                break; 
     542                            case $substr_chrs_c_2 == '\r': 
     543                                $utf8 .= chr(0x0D); 
     544                                ++$c; 
     545                                break; 
     546 
     547                            case $substr_chrs_c_2 == '\\"': 
     548                            case $substr_chrs_c_2 == '\\\'': 
     549                            case $substr_chrs_c_2 == '\\\\': 
     550                            case $substr_chrs_c_2 == '\\/': 
     551                                if (($delim == '"' && $substr_chrs_c_2 != '\\\'') || 
     552                                   ($delim == "'" && $substr_chrs_c_2 != '\\"')) { 
     553                                    $utf8 .= $chrs{++$c}; 
     554                                } 
     555                                break; 
     556 
     557                            case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)): 
     558                                // single, escaped unicode character 
     559                                $utf16 = chr(hexdec(substr($chrs, ($c + 2), 2))) 
     560                                       . chr(hexdec(substr($chrs, ($c + 4), 2))); 
     561                                $utf8 .= $this->utf162utf8($utf16); 
     562                                $c += 5; 
     563                                break; 
     564 
     565                            case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F): 
     566                                $utf8 .= $chrs{$c}; 
     567                                break; 
     568 
     569                            case ($ord_chrs_c & 0xE0) == 0xC0: 
     570                                // characters U-00000080 - U-000007FF, mask 110XXXXX 
     571                                //see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     572                                $utf8 .= substr($chrs, $c, 2); 
     573                                ++$c; 
     574                                break; 
     575 
     576                            case ($ord_chrs_c & 0xF0) == 0xE0: 
     577                                // characters U-00000800 - U-0000FFFF, mask 1110XXXX 
     578                                // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     579                                $utf8 .= substr($chrs, $c, 3); 
     580                                $c += 2; 
     581                                break; 
     582 
     583                            case ($ord_chrs_c & 0xF8) == 0xF0: 
     584                                // characters U-00010000 - U-001FFFFF, mask 11110XXX 
     585                                // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     586                                $utf8 .= substr($chrs, $c, 4); 
     587                                $c += 3; 
     588                                break; 
     589 
     590                            case ($ord_chrs_c & 0xFC) == 0xF8: 
     591                                // characters U-00200000 - U-03FFFFFF, mask 111110XX 
     592                                // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     593                                $utf8 .= substr($chrs, $c, 5); 
     594                                $c += 4; 
     595                                break; 
     596 
     597                            case ($ord_chrs_c & 0xFE) == 0xFC: 
     598                                // characters U-04000000 - U-7FFFFFFF, mask 1111110X 
     599                                // see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8 
     600                                $utf8 .= substr($chrs, $c, 6); 
     601                                $c += 5; 
     602                                break; 
     603 
     604                        } 
     605 
     606                    } 
     607 
     608                    return $utf8; 
     609 
     610                } elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) { 
     611                    // array, or object notation 
     612 
     613                    if ($str{0} == '[') { 
     614                        $stk = array(SERVICES_JSON_IN_ARR); 
     615                        $arr = array(); 
     616                    } else { 
     617                        if ($this->use & SERVICES_JSON_LOOSE_TYPE) { 
     618                            $stk = array(SERVICES_JSON_IN_OBJ); 
     619                            $obj = array(); 
     620                        } else { 
     621                            $stk = array(SERVICES_JSON_IN_OBJ); 
     622                            $obj = new stdClass(); 
     623                        } 
     624                    } 
     625 
     626                    array_push($stk, array('what'  => SERVICES_JSON_SLICE, 
     627                                           'where' => 0, 
     628                                           'delim' => false)); 
     629 
     630                    $chrs = substr($str, 1, -1); 
     631                    $chrs = $this->reduce_string($chrs); 
     632 
     633                    if ($chrs == '') { 
     634                        if (reset($stk) == SERVICES_JSON_IN_ARR) { 
     635                            return $arr; 
     636 
     637                        } else { 
     638                            return $obj; 
     639 
     640                        } 
     641                    } 
     642 
     643                    //print("\nparsing {$chrs}\n"); 
     644 
     645                    $strlen_chrs = strlen($chrs); 
     646 
     647                    for ($c = 0; $c <= $strlen_chrs; ++$c) { 
     648 
     649                        $top = end($stk); 
     650                        $substr_chrs_c_2 = substr($chrs, $c, 2); 
     651 
     652                        if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) { 
     653                            // found a comma that is not inside a string, array, etc., 
     654                            // OR we've reached the end of the character list 
     655                            $slice = substr($chrs, $top['where'], ($c - $top['where'])); 
     656                            array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false)); 
     657                            //print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); 
     658 
     659                            if (reset($stk) == SERVICES_JSON_IN_ARR) { 
     660                                // we are in an array, so just push an element onto the stack 
     661                                array_push($arr, $this->decode($slice)); 
     662 
     663                            } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { 
     664                                // we are in an object, so figure 
     665                                // out the property name and set an 
     666                                // element in an associative array, 
     667                                // for now 
     668                                $parts = array(); 
     669                                 
     670                                if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { 
     671                                    // "name":value pair 
     672                                    $key = $this->decode($parts[1]); 
     673                                    $val = $this->decode($parts[2]); 
     674 
     675                                    if ($this->use & SERVICES_JSON_LOOSE_TYPE) { 
     676                                        $obj[$key] = $val; 
     677                                    } else { 
     678                                        $obj->$key = $val; 
     679                                    } 
     680                                } elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) { 
     681                                    // name:value pair, where name is unquoted 
     682                                    $key = $parts[1]; 
     683                                    $val = $this->decode($parts[2]); 
     684 
     685                                    if ($this->use & SERVICES_JSON_LOOSE_TYPE) { 
     686                                        $obj[$key] = $val; 
     687                                    } else { 
     688                                        $obj->$key = $val; 
     689                                    } 
     690                                } 
     691 
     692                            } 
     693 
     694                        } elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) { 
     695                            // found a quote, and we are not inside a string 
     696                            array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c})); 
     697                            //print("Found start of string at {$c}\n"); 
     698 
     699                        } elseif (($chrs{$c} == $top['delim']) && 
     700                                 ($top['what'] == SERVICES_JSON_IN_STR) && 
     701                                 ((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) { 
     702                            // found a quote, we're in a string, and it's not escaped 
     703                            // we know that it's not escaped becase there is _not_ an 
     704                            // odd number of backslashes at the end of the string so far 
     705                            array_pop($stk); 
     706                            //print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n"); 
     707 
     708                        } elseif (($chrs{$c} == '[') && 
     709                                 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { 
     710                            // found a left-bracket, and we are in an array, object, or slice 
     711                            array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false)); 
     712                            //print("Found start of array at {$c}\n"); 
     713 
     714                        } elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) { 
     715                            // found a right-bracket, and we're in an array 
     716                            array_pop($stk); 
     717                            //print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); 
     718 
     719                        } elseif (($chrs{$c} == '{') && 
     720                                 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { 
     721                            // found a left-brace, and we are in an array, object, or slice 
     722                            array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false)); 
     723                            //print("Found start of object at {$c}\n"); 
     724 
     725                        } elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) { 
     726                            // found a right-brace, and we're in an object 
     727                            array_pop($stk); 
     728                            //print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); 
     729 
     730                        } elseif (($substr_chrs_c_2 == '/*') && 
     731                                 in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) { 
     732                            // found a comment start, and we are in an array, object, or slice 
     733                            array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false)); 
     734                            $c++; 
     735                            //print("Found start of comment at {$c}\n"); 
     736 
     737                        } elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) { 
     738                            // found a comment end, and we're in one now 
     739                            array_pop($stk); 
     740                            $c++; 
     741 
     742                            for ($i = $top['where']; $i <= $c; ++$i) 
     743                                $chrs = substr_replace($chrs, ' ', $i, 1); 
     744 
     745                            //print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n"); 
     746 
     747                        } 
     748 
     749                    } 
     750 
     751                    if (reset($stk) == SERVICES_JSON_IN_ARR) { 
     752                        return $arr; 
     753 
     754                    } elseif (reset($stk) == SERVICES_JSON_IN_OBJ) { 
     755                        return $obj; 
     756 
     757                    } 
     758 
     759                } 
     760        } 
     761    } 
     762 
     763    /** 
     764     * @todo Ultimately, this should just call PEAR::isError() 
     765     */ 
     766    function isError($data, $code = null) 
     767    { 
     768        if (class_exists('pear')) { 
     769            return PEAR::isError($data, $code); 
     770        } elseif (is_object($data) && (get_class($data) == 'services_json_error' || 
     771                                 is_subclass_of($data, 'services_json_error'))) { 
     772            return true; 
     773        } 
     774 
     775        return false; 
     776    } 
     777} 
     778 
     779if (class_exists('PEAR_Error')) { 
     780 
     781    class Services_JSON_Error extends PEAR_Error 
     782    { 
     783        function Services_JSON_Error($message = 'unknown error', $code = null, 
     784                                     $mode = null, $options = null, $userinfo = null) 
     785        { 
     786            parent::PEAR_Error($message, $code, $mode, $options, $userinfo); 
     787        } 
     788    } 
     789 
     790} else { 
     791 
     792    /** 
     793     * @todo Ultimately, this class shall be descended from PEAR_Error 
     794     */ 
     795    class Services_JSON_Error 
     796    { 
     797        function Services_JSON_Error($message = 'unknown error', $code = null, 
     798                                     $mode = null, $options = null, $userinfo = null) 
     799        { 
     800 
     801        } 
     802    } 
     803 
     804} 
     805     
     806?> 
  • wp-includes/class-page-order.php

     
     1<?php 
     2/* 
     3* This class will retrieve and save the page order. It takes and returns arrays in 
     4* the same format used by the "NestedSortableWidget" javascript component. Look 
     5* at admin-ajax.php to see how it is used.  
     6* 
     7 * @author      Bernardo Padua <berpasan@gmail.com> 
     8 * @link        http://bitsinashortbit.wordpress.com 
     9 
     10*/ 
     11class WP_Page_Order { 
     12        var $count = 0; 
     13        var $items; 
     14        var $completeHash; 
     15         
     16        function WP_Page_Order() { 
     17 
     18        } 
     19         
     20         
     21        /** 
     22         * Returns a nested symbolic array with pages organized hierarchically. 
     23         *  
     24         * Always returns full hierarchies of pages. 
     25         *  
     26         * @param integer $firstIndex The zero based index of the page after which the first returned page (in a root hierarchy) will be returned. 
     27         * @param integer $count Minimum number of pages that will be returned. 
     28         */ 
     29        function get_paginated_pages($firstIndex = null, $count = null) { 
     30                //Pagination here is still dumb; it fetches all the 
     31                //pages than filters the ones that are going to 
     32                //be sent. But hey, at least it works... 
     33                $this->_fetch_page_list(); 
     34                if($firstIndex === null || $count === null) { 
     35                        return $this->completeHash; 
     36                } else { 
     37                        $firstIndex = (int)$firstIndex; 
     38                        $count = (int)$count; 
     39                        $return = array( 
     40                                        "requestFirstIndex"=> $firstIndex, 
     41                                        "columns"=> $this->completeHash['columns'], 
     42                                        "totalCount" => $this->completeHash['totalCount'] 
     43                                ); 
     44                         
     45                                 
     46                        $first = null; 
     47                        $last = null;    
     48                        $curPos = 0; 
     49                        foreach ($this->completeHash['items'] as $key => $value) { 
     50                                $nextPos = $this->_count_items($value) + 1 + $curPos; 
     51                                if($first === null && $firstIndex === $curPos) { 
     52                                        $newFirstIndex = $curPos; 
     53                                        $first = $key; 
     54                                } 
     55                                if ($first === null && $nextPos > $firstIndex) { 
     56                                        $first = $key + 1;  
     57                                        $newFirstIndex = $nextPos; 
     58                                } 
     59                                if(     $last === null && 
     60                                        $newFirstIndex!==null && 
     61                                        ($nextPos >= $newFirstIndex + $count || $nextPos >= $return['totalCount'] ) )    
     62                                { 
     63                                        $last = $key; //the root element where the item with the last index is 
     64                                        $newCount = $nextPos - $newFirstIndex; 
     65                                        break; //we are done if we got here 
     66                                } 
     67                                $curPos = $nextPos; 
     68                        } 
     69                         
     70                        $return['firstIndex'] = $newFirstIndex; 
     71                        $return['count'] = $newCount; 
     72                        $return['items'] = array_slice($this->completeHash['items'], $first, $last - $first + 1); 
     73                         
     74                        return $return; 
     75                } 
     76        } 
     77         
     78 
     79        /** 
     80         * Saves the page order. 
     81         *  
     82         * This function calls itself recursivelly to save the order of its child pages. 
     83         *  
     84         * @param array $pages_array Array with the page ids organized in order and hiearachically. 
     85         * @param integer $parent_id The db index of the page which is the parent of all the passed in pages. 
     86         */ 
     87        function save_page_order($pages_array, $parent_id = 0) { 
     88                global $wpdb; 
     89                $first_page = $wpdb->escape($pages_array[0]['id']); 
     90                $current_menu_order = get_post_field('menu_order', $first_page, 'db'); 
     91                if(is_wp_error($current_menu_order)) return false; 
     92                if($parent_id === 0) { 
     93                        //shifts the menu order for all the root pages after the ones we 
     94                        //will alter 
     95                        $num_root_pages = count($pages_array); 
     96                        $query_ret = $wpdb->query("UPDATE $wpdb->posts SET menu_order = menu_order + $num_root_pages WHERE  post_type = 'page' AND post_parent = 0 AND menu_order > $current_menu_order"); 
     97                        if($query_ret === false) return false; 
     98                } 
     99                foreach ($pages_array as $index => $page) { 
     100                        $page_id = $wpdb->escape($page['id']); 
     101                         
     102                        $query_ret = $wpdb->query("UPDATE $wpdb->posts SET post_parent = '$parent_id', menu_order = '$current_menu_order' WHERE id ='$page_id'"); 
     103                         
     104                        if($query_ret === false) return false; 
     105                         
     106                        $current_menu_order++; 
     107                        if (is_array($page['children'])) { 
     108                                //does it for the children as well 
     109                                if (!$this->save_page_order($page['children'], $page_id)) return false; 
     110                        } 
     111                } 
     112 
     113                return true; 
     114        } 
     115         
     116        function _fetch_page_list() { 
     117                wp("post_type=page&orderby=menu_order&what_to_show=posts&posts_per_page=-1&posts_per_archive_page=-1&order=asc"); 
     118                if($GLOBALS['posts']) { 
     119                        $this->items = $this->_build_items_array(0, 0, $GLOBALS['posts']); 
     120                        $this->completeHash = array( 
     121                                "requestFirstIndex" => 0, 
     122                                "firstIndex" => 0, 
     123                                "count" => $this->count, 
     124                                "totalCount" => $this->count, 
     125                                "columns" => array("Title (ID)", "Owner", "Updated"), 
     126                                "items" => $this->items 
     127                        ); 
     128                } 
     129        } 
     130         
     131        function _count_items($item) { 
     132                $cur_count = 0; 
     133                 
     134                if($item['children']) { 
     135                        foreach ($item['children'] as $i) { 
     136                                $cur_count++; 
     137                                $cur_count += $this->_count_items($i); 
     138                        } 
     139                } 
     140                 
     141                return $cur_count; 
     142        } 
     143         
     144        function _build_items_array( $parent = 0, $level = 0, $pages = 0, $hierarchy = true ) { 
     145                //this is not the neatest of the algorithms, a lot of waste here 
     146                //based on get_pages() 
     147                global $wpdb, $post; 
     148                 
     149                if (!$pages ) 
     150                        $pages = get_pages( 'sort_column=menu_order' ); 
     151         
     152                if (! $pages ) 
     153                        return false;            
     154                         
     155                $ret_array = array();    
     156                foreach ( $pages as $post ) { 
     157                        setup_postdata( $post); 
     158                        if ( $hierarchy && ($post->post_parent != $parent) ) 
     159                                continue; 
     160                        $cur_index = count($ret_array); 
     161                        $post->post_title = wp_specialchars( $post->post_title ); 
     162                        $id = (int) $post->ID; 
     163                        $ret_array[$cur_index] = array( 
     164                                "id" => $id, 
     165                                "info" => array(get_the_title() . " (" . $id .")", get_the_author(), ( '0000-00-00 00:00:00' ==$post->post_modified ) ? __('Unpublished'): mysql2date( __('Y-m-d g:i a'), $post->post_modified )) 
     166                        ); 
     167                         
     168                        $this->count ++; 
     169                         
     170                        if ( $hierarchy ) { 
     171                                $children = $this->_build_items_array( $id, $level + 1, $pages ); 
     172                                if ( $children ) { 
     173                                        $ret_array[$cur_index]['children'] = $children; 
     174                                } 
     175                        } 
     176                } 
     177                 
     178                return $ret_array; 
     179        } 
     180 
     181} 
     182?> 
     183 No newline at end of file 
  • wp-includes/js/jquery/inestedsortable.js

     
     1/** 
     2 *  
     3 * Nested Sortable Plugin for jQuery/Interface. 
     4 *   
     5 * Version 1.0 
     6 *   
     7 * Copyright (c) 2007 Bernardo de Padua dos Santos 
     8 * Dual licensed under the MIT (MIT-LICENSE.txt)  
     9 * and GPL (GPL-LICENSE.txt) licenses. 
     10 *  
     11 * http://code.google.com/p/nestedsortables/ 
     12 *  
     13 * Compressed using Dean Edwards' Packer (http://dean.edwards.name/packer/) 
     14 *  
     15 */ 
     16 
     17eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('2.6={26:9(e,o){5(e.L){2.6.1Q(e);8 2.6.1J(e)}r{8 2.6.1D(e,o)}},1D:2.n.29,1J:9(e){5(!2.u.z){8}5(!(e.1q.1s.1k()>0)){8}5(!e.3.Z){2.n.2n(e);e.3.Z=C}7 a=2.6.1A(e);7 b=2.6.1v(e,a);7 c=(!a)?2.6.23(e):p;7 d=p;5(a){5(e.3.1d===a&&e.3.1V===b){d=C}}r 5(e.3.1d===a&&e.3.1U===c){d=C}e.3.1d=a;e.3.1V=b;e.3.1U=c;5(d){8}5(a!==N){5(b){2.6.1T(e,a)}r{2.6.1P(e,a)}}r 5(c){2.6.1O(e)}},1Q:9(e){5(!e.3.17){8 p}7 a=e.3.16;7 b=e.3.15;7 c=2.u.z.B.2o;7 d=2.1i.1K();5((c.y-d.M)-d.t>-a){1G.1F(0,b)}5(c.y-d.t<a){1G.1F(0,-b)}},14:9(a){2.6.1C(a);8 2.6.1B(a)},1B:2.n.14,1C:9(a){5(2.6.T&&2.6.D){2.6.D.1y(2.6.T);2.6.D=N;2.6.T=""}5(2.1r.1w.L){2.1r.1w.3.Z=p}},W:9(s){5(2(\'#\'+s).v(0).L){8 2.6.25(s)}r{8 2.6.28(s)}},28:2.n.W,25:9(s){7 i;7 h=\'\';7 j=\'\';7 o={};7 e;7 k=9(f){7 g=[];1W=2(f).J(\'.\'+2.n.19[s]);1W.1p(9(i){7 a=2.2s(m,\'1m\');5(a&&a.1R){a=a.1R(e.3.11)[0]}5(h.I>0){h+=\'&\'}h+=s+j+\'[\'+i+\'][1m]=\'+a;g[i]={1m:a};7 b=2(m).J(e.3.G+"."+e.3.S.V(" ").U(".")).v(0);7 c=j;j+=\'[\'+i+\'][J]\';7 d=k(b);5(d.I>0){g[i].J=d}j=c});8 g};5(s){5(2.n.19[s]){e=2(\'#\'+s).v(0);o[s]=k(e)}r{1N(a 1M s){5(2.n.19[s[a]]){e=2(\'#\'+s[a]).v(0);o[s[a]]=k(e)}}}}r{1N(i 1M 2.n.19){e=2(\'#\'+i).v(0);o[i]=k(e)}}8{2p:h,o:o}},1A:9(e){7 d=0;7 f=2.1L(e.1q.1s,9(i){7 a=(i.A.y<2.u.z.B.1j)&&(i.A.y>d);5(!a){8 p}7 b;5(e.3.O){b=(i.A.x+i.A.13+e.3.Q>2.u.z.B.12+2.u.z.B.1h.13)}r{b=(i.A.x-e.3.Q<2.u.z.B.12)}5(!b){8 p}7 c=2.6.1g(e,i);5(c){8 p}d=i.A.y;8 C});5(f.I>0){8 f[(f.I-1)]}r{8 N}},23:9(e){7 c;7 d=2.1L(e.1q.1s,9(i){7 a=(c===1I||i.A.y<c);5(!a){8 p}7 b=2.6.1g(e,i);5(b){8 p}c=i.A.y;8 C});5(d.I>0){d=d[(d.I-1)];8 d.A.y<2.u.z.B.1j+2.u.z.B.1h.2m&&d.A.y>2.u.z.B.1j}r{8 p}},1g:9(e,a){7 b=2.u.z;5(!b){8 p}5(a==b){8 C}5(2(a).2l("."+e.1H.1e.V(" ").U(".")).2k(9(){8 m==b}).I!==0){8 C}r{8 p}},1v:9(e,a){5(!a){8 p}5(e.3.O){8 a.A.x+a.A.13-(e.3.H-e.3.Q)>2.u.z.B.12+2.u.z.B.1h.13}r{8 a.A.x+(e.3.H-e.3.Q)<2.u.z.B.12}},1T:9(e,a){7 b=2(a).J(e.3.G+"."+e.3.S.V(" ").U("."));7 c=2.n.P;1E=c.v(0).2j;1E.2i=\'2h\';5(!b.1k()){7 d="<"+e.3.G+" 2g=\'"+e.3.S+"\'></"+e.3.G+">";b=2(a).2f(d).J(e.3.G).1z(e.3.1l)}2.6.Y(e,b);2.6.1b(e);b.1x(c.v(0));2.6.X(e)},1P:9(e,a){2.6.Y(e,2(a).1c());2.6.1b(e);2(a).2e(2.n.P.v(0));2.6.X(e)},1O:9(e){2.6.Y(e,e);2.6.1b(e);2(e).1x(2.n.P.v(0));2.6.X(e)},1b:9(e){7 a=2.n.P.1c(e.3.G+"."+e.3.S.V(" ").U("."));7 b=a.J("."+e.1H.1e.V(" ").U(".")+":2d").1k();5(b===0&&a.v(0)!==e){a.2c()}},X:9(e){7 a=2.n.P.1c();5(a.v(0)!==e){a.2b()}e.3.Z=p},Y:9(e,a){7 b=2(a);5((e.3.K)&&(!2.6.D||b.v(0)!=2.6.D.v(0))){5(2.6.D){2.6.D.1y(e.3.K)}5(b.v(0)!=e){2.6.D=b;b.2E(e.3.K);2.6.T=e.3.K}r{2.6.D=N;2.6.T=""}}},2a:9(){8 m.1p(9(){5(m.L){m.3=N;m.L=N;2(m).2D()}})},27:9(a){5(a.1e&&2.1i&&2.u&&2.1r&&2.n){m.1p(9(){m.L=C;m.3={O:a.O?C:p,H:24(a.H,10)||2C,K:a.K?a.K:"",1u:a.1u?a.1u:"",1f:a.1f?a.1f:p,17:a.17!==1I?a.17==C:C,16:a.16?a.16:20,15:a.15?a.15:20,11:a.11?a.11:/[^\\-]*$/};m.3.Q=24(m.3.H*0.4,10);m.3.G=m.2B;m.3.S=m.2A;m.3.1l=(m.3.O)?{"1a-1Z":0,"1a-1Y":m.3.H+\'1X\'}:{"1a-1Z":m.3.H+\'1X\',"1a-1Y":0};2(m.3.G,m).1z(m.3.1l)});2.n.29=2.6.26;2.n.14=2.6.14;2.n.W=2.6.W}8 m.2z(a)}};2.2y.2x({2w:2.6.27,2v:2.6.2a});2.1i.1K=9(e){7 t,l,w,h,R,M;5(e&&e.2u.2t()!=\'E\'){t=e.18;l=e.1o;w=e.1n;h=e.1t;R=0;M=0}r{5(q.F&&q.F.18){t=q.F.18;l=q.F.1o;w=q.F.1n;h=q.F.1t}r 5(q.E){t=q.E.18;l=q.E.1o;w=q.E.1n;h=q.E.1t}R=1S.2r||q.F.22||q.E.22||0;M=1S.2q||q.F.21||q.E.21||0}8{t:t,l:l,w:w,h:h,R:R,M:M}};',62,165,'||jQuery|nestedSortCfg||if|iNestedSortable|var|return|function|||||||||||||this|iSort||false|document|else|||iDrag|get||||dragged|pos|dragCfg|true|currentNesting|body|documentElement|nestingTag|nestingPxSpace|length|children|currentNestingClass|isNestedSortable|ih|null|rightToLeft|helper|snapTolerance|iw|nestingTagClass|latestNestingClass|join|split|serialize|afterHelperInsert|updateCurrentNestingClass|remeasured||serializeRegExp|nx|wb|check|scrollSpeed|scrollSensitivity|autoScroll|scrollTop|collected|padding|beforeHelperRemove|parent|lastPrecedingItem|accept|nestingLimit|isBeingDragged|oC|iUtil|ny|size|styleToAttach|id|scrollWidth|scrollLeft|each|dropCfg|iDrop|el|scrollHeight|currentParentClass|shouldNestItem|overzone|prepend|removeClass|css|findPrecedingItem|oldCheck|newCheck|oldCheckHover|styleHelper|scrollBy|window|sortCfg|undefined|newCheckHover|getScroll|grep|in|for|insertOnTop|appendItem|scroll|match|self|nestItem|lastTouchingFirst|lastShouldNest|thisChildren|px|right|left||clientHeight|clientWidth|isTouchingFirstItem|parseInt|newSerialize|checkHover|build|oldSerialize|checkhover|destroy|show|hide|visible|after|append|class|auto|width|style|filter|parents|hb|measure|currentPointer|hash|innerHeight|innerWidth|attr|toLowerCase|nodeName|NestedSortableDestroy|NestedSortable|extend|fn|Sortable|className|tagName|30|SortableDestroy|addClass'.split('|'),0,{})) 
     18 No newline at end of file 
  • wp-includes/js/jquery/jquery.nestedsortablewidget.js

     
     1/** 
     2 *  
     3 * Nested Sortable Widget with pagination support for jQuery/Interface. 
     4 *   
     5 * Version 1.0 
     6 *   
     7 * Copyright (c) 2007 Bernardo de Padua dos Santos 
     8 * Dual licensed under the MIT (MIT-LICENSE.txt)  
     9 * and GPL (GPL-LICENSE.txt) licenses. 
     10 *  
     11 * http://code.google.com/p/nestedsortables/ 
     12 *  
     13 * Compressed using Dean Edwards' Packer (http://dean.edwards.name/packer/) 
     14 *  
     15 */ 
     16 
     17eval(function(p,a,c,k,e,r){e=function(c){return(c<a?'':e(parseInt(c/a)))+((c=c%a)>35?String.fromCharCode(c+29):c.toString(36))};if(!''.replace(/^/,String)){while(c--)r[e(c)]=k[c]||e(c);k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('6.U={1M:R(e,a){e.5.3m=a;9 b=6(\'.\'+e.5.V.1O,e);7(a){b.1L()}S{b.1t()}},2L:R(e,a){9 b=6(\'.\'+e.5.V.1U,e).2i(a).1L(\'3Y\',R(){3Q(R(){b.1t(\'3Y\')},\'4R\')})},2A:R(e,a){9 b=e.5.2x;9 c=6.U.2u;9 d;34(a){1h\'1G\':7(e.5.1i){d=e.5.1Q-1}S{d=b-1}1o;1h\'1A\':7(e.5.1i){d=e.5.1u+1}S{d=b+1}1o}X c(e,d)},2u:R(e,d){9 f=R(){7(e.5.1W&&!e.5.3i){9 a;7(e.5.1i){9 b;7(d>e.5.1u){b=e.5.1u}S{b=e.5.1Q}a=6.U.2b(e,d,b)}S{a=6.U.2b(e,d,e.5.2x)}6.19(e.5.11,R(i){7(8.2B<=a.12&&(8.12+8.Z)>=(a.12+a.Z)){a=15;X Y}});X a}S 7(e.5.11.W===0){X{}}S{X 15}};9 g=R(a){9 b=e.5.37;7(b){e.5.37=15;b.3G();7(e.5.1S){e.5.1S.18(e)}}6.U.3B(e,a);6.U.30(e,d);7(e.5.1V){e.5.1V.18(e)}6.U.1M(e,Y)};9 h=R(a,b,c){6.U.2L(e,e.5.1g.4E);6.U.1M(e,Y);7(e.5.22){e.5.22.18(e)}};7(e.5.3m||e.5.2S){X Y}6.U.1M(e,1d);9 j;7(!e.5.13.1Z[d]&&(j=f())!==15){7(e.5.2k){6.24(j,e.5.2k)}6.4q({3k:e.5.2t,2K:j,5l:\'5j\',4d:g,49:h,45:e.5.2p})}S{6.U.30(e,d);6.U.1M(e,Y)}},2b:R(e,a,b){9 c=e.5.2r;9 d,Z;7(b){3d=e.5.13.1K[b].12;3U=e.5.13.1K[b].Z;7(b+1==a){d=3d+3U}S 7(b==a+1){d=(a-1)*c;7(d<0){d=0}Z=3d-d}}S{d=(a-1)*c}7(!Z){7(e.5.11[0]){9 f=e.5.11[0].2q;7(d+c>f){Z=f-d}S{Z=c}}S{Z=c}}X{12:d,Z:Z}},3B:R(e,a){9 b=15;9 c=15;9 d=0;6.19(e.5.11,R(i){7(a.12==8.12+8.Z){b=i}S 7(a.12+a.Z==8.12){c=i}S 7(a.12>8.12){d=i+1}});7(b!==15){e.5.11[b].17=e.5.11[b].17.2M(a.17);e.5.11[b].Z+=a.Z;7(c!==15){e.5.11[b].17=e.5.11[b].17.2M(e.5.11[c].17);e.5.11[b].Z+=e.5.11[c].Z;e.5.11.3P(c,1)}}S 7(c!==15){e.5.11[c].17=a.17.2M(e.5.11[c].17);e.5.11[c].12=a.12;e.5.11[c].2B=a.2B;e.5.11[c].Z+=a.Z}S{e.5.11.3P(d,0,a)}},2d:R(b){9 c=0;9 a;7(b.1f==1T){a=b}S{a=b.1J}7(a){6.19(a,R(i){c++;c+=6.U.2d(8)})}X c},3O:R(e,b,c){7(e.5.1W){9 d=e.5.11;9 f=e.5.2r;9 g;7(e.5.1i){9 h;7(b>e.5.1u){h=e.5.1u}S{h=e.5.1Q}g=6.U.2b(e,b,h)}S{g=6.U.2b(e,b,c)}9 j=g.12;9 k=g.Z;9 l;9 m=e.5.13.1K[b+1];7(m){l=m.12}S{l=d[0].2q}9 n=15;6.19(d,R(i){7(8.2B<=j&&(8.12+8.Z)>=(j+k)){n=8}});9 o=n.12;9 p=15;9 q=15;9 r=15;9 s=15;6.19(n.17,R(i){9 a=6.U.2d(8)+1+o;7(p===15&&j<=o){p=i;r=o}7(p===15&&a>j){p=i+1;r=a}7(q===15&&r!==15&&(a>=r+k||a>=l)){q=i;s=a-r;X Y}o=a});X{2a:n.2a,17:n.17.4Q(p,q+1),12:r,Z:s,2q:n.2q}}S{X e.5.11[0]}},30:R(e,t){9 u=R(k,l){9 m=R(a){9 b=[];9 c="";9 d=(6.38.2Z)?"1e=\'4P:1;4O: 4N(1R=33);\'":"";7(a.1y){c="1y=\'"+e.5.V.1l+\'-\'+a.1y+"\' "}b[b.W]="<2E "+c+"16=\'"+e.5.V.1C+" "+e.5.V.1l+"\' "+d+"\'>";9 f="";7(!e.5.1b){f="3w:3v;"}9 g=(6.38.2Z)?"2g:33%;":"";b[b.W]="<T 16=\'"+e.5.V.2h+"\' 1e=\'"+f+" 23:0 0 "+1c(e.5.1n)+e.5.1X+" 0; "+g+"\'>";b[b.W]=o(a.5I,e.5.1b);b[b.W]="</T>";7(a.1J){b[b.W]=n(a.1J)}b[b.W]="</2E>";X b.2n("")};9 n=R(a,b){9 c=[];c[c.W]="<2R "+((b)?"1y=\'"+e.5.1q+"-"+t+"\'":"")+"\' 16=\'"+e.5.V.4z+" "+e.5.V.1C+"\'>";3r(9 i=0;i<a.W;i++){c[c.W]=m(a[i])}c[c.W]="</2R>";X c.2n("")};9 o=R(a,b){9 c=[];9 d=e.5.1X;9 f=e.5.1m.5E;3r(9 i=a.W-1;i>=0;i--){9 g="";7(i!==0){9 h;7(e.5.1a.1f===1T){h=(e.5.1a[i-1])?e.5.1a[i-1]:e.5.1a[e.5.1a.W-1]}S{h=e.5.1a}g+="5D: "+1c(h)+d+";";7(f){g+="4u:5A;";g+="23:0 0 0 "+1c(e.5.1n)+d+";"}S{g+="4u:5y;";g+="23:0 "+1c(e.5.1n)+d+" 0 0;"}}S{7(f){g+="23:0 "+1c(e.5.1n)+d+" 0 "+r+d+";"}S{g+="23:0 "+r+d+" 0 "+1c(e.5.1n)+d+";"}}9 j;7(e.5.1F.1f===1T){j=e.5.1F.2n(d+" ")+d}S{j=1c(e.5.1F)+d}g+="1F:"+j+";";c[c.W]="<T 1e=\'"+g+"\'>";7(b&&i===0){c[c.W]="<4r 16=\'"+e.5.V.1b+"\' 1e=\'3w:3v;\'>"+e.5.1g.1b+"</4r> "}c[c.W]=a[i]+"</T>"}X c.2n("")};9 p=R(b){9 c=0;9 d=e.5.1F;9 f;7(d.W===4){f=1c(d[1])+1c(d[3])}S{f=2*1c(d)}6.19(b,R(i){7(i===0){X 1d}9 a;7(e.5.1a.1f===1T){a=(e.5.1a[i-1])?e.5.1a[i-1]:e.5.1a[e.5.1a.W-1]}S{a=e.5.1a}c+=1c(a)+1c(e.5.1n)+f});X c+1c(e.5.1n)};9 q=[];9 r=p(k.2a);7(l===\'1z\'){7(k.2a){q[q.W]="<T 16=\'"+e.5.V.4n+"\'>";q[q.W]="<2R 16=\'"+e.5.V.1z+"\'>";q[q.W]="<2E 16=\'"+e.5.V.4k+"\'>";9 s=(6.38.2Z)?"2g:33%;":"";q[q.W]="<T 1e=\'23:0 0 "+1c(e.5.1n)+e.5.1X+" 0;"+s+" \'>";q[q.W]=o(k.2a);q[q.W]="</T></2E></2R>";q[q.W]="</T>"}}S{q[q.W]=n(k.17,1d)}X 6(q.2n(""))};9 v=R(){X 6("<T 16=\'"+e.5.V.2F+"\'></T>")};9 w=R(a){7(e.5.1W){9 b=\'<T 16="\'+e.5.V.2J+\' \'+e.5.V.1C+\'"></T>\';7(a=="1G"){X 6(b).2i(e.5.1g.4f)}S 7(a=="1A"){X 6(b).2i(e.5.1g.4c)}S{X 15}}S{X 15}};9 x=R(){7(e.5.1W){9 a=e.5.V;9 b=e.5.1g;9 c="",2f="";7(L){c=6("<T 16=\'"+a.46+"\'><a 44=\'42:;\'>"+b.41+"</a></T>").4m("2H",R(){6.U.2A(e,"1G")})}7(M){2f=6("<T 16=\'"+a.4l+"\'><a 44=\'42:;\'>"+b.3X+"</a></T>").4m("2H",R(){6.U.2A(e,"1A")})}X 6("<T 16=\'"+a.3W+"\'></T>").1s(c).1s(2f).1s("<T 1e=\'1C:3l;2g:0;\'>&1H;</T>")}S{X 15}};9 y=R(){9 a=e.5.V;9 b=e.5.1g;9 c=6("<4Z 3k=\'4Y\' 16=\'"+a.2N+"\' 4U=\'"+b.2T+"\'/>");X 6("<T 16=\'"+a.3c+"\'></T>").1s("<T 16=\'"+a.3b+"\'><T 16=\'"+a.1U+"\' 1e=\'2D:2c;\'>&1H;</T><T 16=\'"+a.1O+"\' 1e=\'2D:2c;\'>&1H;</T></T>").1s(c).1s("<T 1e=\'1C:3l;2g:0;\'>&1H;</T>")};9 z=R(a,b){e.5.2S=1d;7(!e.5.1i){7(2C e.5.1j==\'R\'){7(b){e.5.1j.18(a,[R(){A(b)}])}S{e.5.1j.18(a)}}S{a.1t();7(b){A(b)}}}};9 A=R(a){7(2C e.5.1r==\'R\'){e.5.1r.18(a,[R(){6.2U();e.5.2S=Y}])}S{a.1L();6.2U();e.5.2S=Y}};9 B=e.5.2x;9 C=e.5.1z;9 D=Y;7(!C){D=1d;C=e.5.1z=u(e.5.11[0],\'1z\')}9 E=e.5.2F;7(!E){E=e.5.2F=v()}9 F=e.5.13.1Z[t];9 G=e.5.13.1K[t];7(!F){G=e.5.13.1K[t]=6.U.3O(e,t,B);F=e.5.13.1Z[t]=u(G);7(E.2i()===""){E.1s(F)}}7(e.5.1i){G=e.5.11[0]}7(G.12>0){e.5.13.2z[t]=1d}S{e.5.13.2z[t]=Y}7(e.5.1i){G=e.5.11[e.5.11.W-1]}7((G.12+G.Z)<G.2q){e.5.13.2y[t]=1d}S{e.5.13.2y[t]=Y}9 H;7(e.5.1i){7(t>e.5.1u){H=e.5.1u}S{H=e.5.1Q}}S{H=B}9 I=e.5.13.1Z[H];7(I){7(H<t){I.1A(F.1t())}S{I.1G(F.1t())}34(e.5.1k){1h"1w-1E":7(!e.5.1i){z(I)}A(F);1o;1h"1w-1D":z(I,F);1o}}9 J=e.5.2w;7(!J){J=e.5.2w=w(\'1G\')}9 K=e.5.2v;7(!K){K=e.5.2v=w(\'1A\')}9 L=e.5.13.2z[t];7(J){7(L){J.1L().3a(\'1R\',\'1\')}S{J.1t()}}9 M=e.5.13.2y[t];7(K){7(M){K.1L().3a(\'1R\',\'1\')}S{K.1t()}}9 N=e.5.39;e.5.39=x();9 O=e.5.39;7(N){N.1t().1A(O).3G()}9 P=e.5.3N;7(!P){P=e.5.3N=[];P[0]=y();P[1]=y()}7(D){e.5.3M.29(E).29(C).29(J).1s(K).29(O).29(P[0]).1s(P[1]).3L(e)}7(J&&!J.25(0).3K){J.3J({2X:e.5.V.1l,3I:\'3H\',3F:e.5.V.36,3E:R(a){6.U.35(e,a,"1G",8)},3D:R(a){6.U.28(e,a,"1G",8)},3C:R(a){6.U.28(e,a,"1G",8)}})}7(K&&!K.25(0).3K){K.3J({2X:e.5.V.1l,3I:\'3H\',3F:e.5.V.36,3E:R(a){6.U.35(e,a,"1A",8)},3D:R(a){6.U.28(e,a,"1A",8)},3C:R(a){6.U.28(e,a,"1A",8)}})}9 Q;7(!F.25(0).4M){Q=F.4L(\'1y\');e.5.13.32[Q]=t;F.4K(e.5.1m)}7(I){6.3A.4J(F.25(0))}e.5.4I=B;e.5.2x=t;7(!e.5.1u||t>e.5.1u){e.5.1u=t}7(!e.5.1Q||t<e.5.1Q){e.5.1Q=t}6.2U();6.U.31(e)},3z:R(e,b){6.U.31(e);6.19(b,R(i){9 a=e.5.13.32[8.1y];e.5.13.27[a]=8.o[8.1y]});6("."+e.5.V.2N,e).2H(R(a){6(e).3y();a.4H()}).2Y(e.5.V.2T).3x(e.5.V.2N)},35:R(e,a,b,c){3h=R(){6.U.2A(e,b)};9 d=e.5.2G;7(e.5.26&&6.1p.3u!=="1.2"){9 f={};f[e.5.2I]=\'1t\';6(c).4G({1R:\'0\'},2V(d,10),3h)}S{e.5.3t=3Q(3h,d+"")}},28:R(e,a,b,c){7(e.5.26&&6.1p.3u!=="1.2"){6(c).5N().3a(\'1R\',\'1\')}S{5M(e.5.3t)}},31:R(e){6(\'T.\'+e.5.V.2h+\':5L\',e).4D(\'T\').2Y(e.5.V.3s);6(\'T.\'+e.5.V.2h+\':5J\',e).4D(\'T\').3x(e.5.V.3s)},2o:R(){9 l=R(e,a){6.U.2L(e,e.5.1g.4C);7(e.5.20){e.5.20.18(e,[a])}};9 m=R(e){6.U.2L(e,e.5.1g.4B);7(e.5.21){e.5.21.18(e,[5H])}};9 n=R(e){6.U.1M(e,Y)};X 8.19(R(){7(8.2m){7(8.5.3m||8.5.13.27.W===0){X Y}6.U.1M(8,1d);9 d=[];9 e;9 f;9 g=8;6.19(g.5.13.27,R(i){7(!g.5.13.27[i]){X 1d}9 a=8;7(e&&f&&(f+1==i)){e.17=e.17.2M(a);e.Z+=6.U.2d(a)}S{e=d[d.W]={12:g.5.13.1K[i].12,Z:6.U.2d(a),17:a}}f=i});9 h=(d.W)>1?d:d[0];9 j;7(6.4A&&g.5.2Q){j={};j[g.5.1q]=6.4A(h);7(g.5.1N){6.24(j,g.5.1N)}}S{j="";7(g.5.1N){6.19(g.5.1N,R(a){7(j.W>0){j+="&"}j+=a+"="+8})}9 k=R(a,b){9 c="";6.19(a,R(i){7(c.W>0){c+=\'&\'}c+=b+\'[\'+i+\'][1y]=\'+8.1y;7(8.1J&&8.1J.1f==1T){c+="&"+k(8.1J,b+\'[\'+i+\'][1J]\')}});X c};7(h.1f==1T){6.19(h,R(i){7(j.W>0){j+="&"}j+=g.5.1q+"["+i+"][Z]="+8.Z+"&"+g.5.1q+"["+i+"][12]="+8.12+"&";j+=k(8.17,g.5.1q+"["+i+"][17]")})}S{7(j.W>0){j+="&"}j+=g.5.1q+"[Z]="+h.Z+"&"+g.5.1q+"[12]="+h.12+"&";j+=k(h.17,g.5.1q+"[17]")}}6.4q({45:g.5.2P,3k:g.5.2O,2K:j,4d:R(a){l(g,a)},49:R(a,b,c){m(g)},5G:R(a,b){n(g)}})}})},4y:R(){X 8.19(R(){7(8.2m){9 a=8.5.2l;6.19(8.5.13.1Z,R(i){7(8){6(8).5F()}});7(8.5.2w){8.5.2w.4x()}7(8.5.2v){8.5.2v.4x()}8.5=15;8.2m=Y;6(8).2i(\'\');7(a){a.18(8)}}})},4w:R(d){X 8.19(R(){7(8.2m||!d.2p||!6.3q||!6.3p||!6.1B||!6.3o||!6.3A){X}9 b=8;8.2m=1d;8.5={1q:d.1q?d.1q:"5C-5B-5z",2p:d.2p,2P:d.2P?d.2P:d.2p,2k:d.2k?d.2k:3n,1N:d.1N?d.1N:3n,2t:d.2t?d.2t:\'5x\',2O:d.2O?d.2O:\'5w\',2Q:d.2Q===3n?Y:d.2Q,1V:(d.1V&&d.1V.1f==1Y)?d.1V:Y,22:(d.22&&d.22.1f==1Y)?d.22:Y,1S:(d.1S&&d.1S.1f==1Y)?d.1S:Y,20:(d.20&&d.20.1f==1Y)?d.20:Y,21:(d.21&&d.21.1f==1Y)?d.21:Y,2l:(d.2l&&d.2l.1f==1Y)?d.2l:Y,1m:d.1m?d.1m:{},2j:d.2j?d.2j:Y,1a:d.1a?d.1a:5v,1n:d.1n?d.1n:2,1F:d.1F?d.1F:4,1X:d.1X?d.1X:"5u",1k:d.1k?d.1k:\'2W-1E\',1j:2C d.1j==\'R\'?d.1j:Y,1r:2C d.1r==\'R\'?d.1r:Y,1b:d.1b?d.1b:Y,1W:d.1W?1d:Y,3i:d.3i?1d:Y,1i:d.1i?d.1i:Y,2r:2V(d.2r,10)||10,2s:2V(d.2s,10)||1,2G:d.2G?d.2G:"5t",26:d.26?d.26:1d,2I:d.2I?d.2I:\'1R\'};8.5.V={2F:\'14-4p-1I\',4n:\'14-1z-1I\',1I:\'14-1I\',2J:\'14-2J\',36:\'14-5s-2J\',3W:\'14-3j-5r\',46:\'14-3j-4b\',4l:\'14-3j-2f\',4z:\'14-4p-5q\',1z:\'14-1z\',4k:\'14-1z-1l\',1C:\'14-1C\',1l:\'14-1l\',3s:\'14-5p-5o\',2h:\'14-1l-5m\',1O:\'14-1O\',2T:\'14-2o-4i\',2N:\'14-5k-2o-4i\',3c:\'14-2o-1O-1I\',3b:\'14-1O-1U-1I\',1U:\'14-1U\',1b:\'14-1b\',3e:\'14-3e\'};7(d.V){6.24(8.5.V,d.V)}8.5.1g={4c:"4h 1v 4g 4e 3V 3T 3f 3S 1v 1l 3g 1v 2f 48.",4f:"4h 1v 4g 4e 3V 3T 3f 3S 1v 1l 3g 1v 4b 48.",3X:"5i 47 &3Z;",41:"&5h; 5g 47",2T:"5f 5e &3Z; ",4E:"43 4a 5d 1v 2K 5c 1v 40.",4B:"43 4a 5b 1v 2K 3f 1v 40.",4C:"5a 5n 59.",1b:"[58]"};7(d.1g){6.24(8.5.1g,d.1g)}8.5.1m.2X=8.5.V.1l;9 c=8.5.1m.4j;8.5.1m.4j=R(a){7(c){c(a)}6.U.3z(b,a)};8.5.1m.57=8.5.V.3e;7(8.5.1b){8.5.1m.1b="."+8.5.V.1b}S{8.5.1m.1b="."+8.5.V.2h}8.5.3M=6("<T 16=\'"+8.5.V.1I+"\'></T>");8.5.11=[];8.5.13={1Z:[],1K:[],27:[],2z:[],2y:[],56:[],32:{}};8.5.37=6("<T 16=\'"+8.5.V.3c+"\'></T>").1s("<T 16=\'"+8.5.V.3b+"\'><T 16=\'"+8.5.V.1U+"\' 1e=\'2D:2c;\'>&1H;</T><T 16=\'"+8.5.V.1O+"\' 1e=\'2D:2c;\'>&1H;</T></T>").1s("<T 1e=\'1C:3l;2g:0;\'>&1H;</T>").3L(8);34(8.5.1k){1h"2W-1E":8.5.1j=R(a){6.1p.4t.18(8,["1x",a])};8.5.1r=R(a){6.1p.4o.18(8,["1x",a])};8.5.1k="1w-1E";1o;1h"2W-1D":8.5.1j=R(a){6.1p.4t.18(8,["1x",a])};8.5.1r=R(a){6.1p.4o.18(8,["1x",a])};8.5.1k="1w-1D";1o;1h"55-1D":8.5.1j=R(a){8.54("4s",a)};8.5.1r=R(a){8.53("4s",a)};8.5.1k="1w-1D";1o;1h"1x-1E":8.5.1j=R(a){6.1p.1t.18(8,["1x",a])};8.5.1r=R(a){6.1p.1L.18(8,["1x",a])};8.5.1k="1w-1E";1o;1h"1x-1D":8.5.1j=R(a){6.1p.1t.18(8,["1x",a])};8.5.1r=R(a){6.1p.1L.18(8,["1x",a])};8.5.1k="1w-1D";1o;1h"1w-1D":1h"1w-1E":1o;1h"2c":52:8.5.1j=Y;8.5.1r=Y;8.5.1k="1w-1E";1o}7(8.5.2j){6(8.5.2j).2H(R(){6.U.2u(b,b.5.2s)})}S{6.U.2u(8,8.5.2s)}})}};6.1p.24({U:6.U.4w,3y:6.U.2o,51:6.U.4y});6.1B.50=6.2U=R(){6.1B.4v={};3r(i 3g 6.1B.2e){7(6.1B.2e[i]!=15){9 a=6.1B.2e[i].25(0);7(6(6.3p.3R).4X(\'.\'+a.1P.a)){a.1P.p=6.24(6.3q.4W(a),6.3q.4V(a));7(a.1P.4F){6.1B.2e[i].2Y(a.1P.4F)}6.1B.4v[i]=6.1B.2e[i];7(6.3o&&a.1P.s&&6.3p.3R.5K.4T){a.1P.4S=6(\'.\'+a.1P.a,a);6.3o.5O(a)}}}}};',62,361,'|||||nestedSortWidgetCfg|jQuery|if|this|var||||||||||||||||||||||||||||||||||||||||||||function|else|div|NestedSortableWidget|classes|length|return|false|count||loadedJsons|firstIndex|builtLists|nsw|null|class|items|apply|each|colsWidth|handle|parseFloat|true|style|constructor|text|case|incremental|transitionOut|transitionAnim|item|nestedSortCfg|whiteMargin|break|fn|name|transitionIn|append|hide|upperPage|the|custom|normal|id|header|after|iDrop|clear|series|parallel|padding|before|nbsp|wrap|children|jsons|show|setBusyState|saveUrlParams|progress|dropCfg|bottomPage|opacity|onInitialLoad|Array|warning|onLoad|paginate|measureUnit|Function|sorts|onSave|onSaveError|onLoadError|margin|extend|get|fadeOutHover|sers|onBoxOutOrDrop|prepend|columns|nextPageContents|none|countItems|zones|next|height|itemRow|html|loadButtonSel|loadUrlParams|onDestroy|isNestedSortableWidget|join|save|loadUrl|totalCount|itemsPerPage|startPage|loadRequestType|loadData|hoverAfter|hoverBefore|currentPage|pageAfter|pageBefore|loadPage|requestFirstIndex|typeof|display|li|listWrap|pageChangeTimer|click|fadeOutProperty|drop|data|userWarning|concat|disabledSaveButton|saveRequestType|saveUrl|serializeWithJSON|ul|busyAnimating|saveButton|recallDroppables|parseInt|slide|accept|addClass|msie|buildAndShowList|alternateClasses|indexFromSortId|100|switch|onBoxHover|activeDrop|tempProgress|browser|pageChanger|css|progressAndWarningWrap|saveAndProgressWrap|curFirstIndex|helper|to|in|callback|greedy|nav|type|both|busyLoading|undefined|iSort|iDrag|iUtil|for|altCell|lastTimeOut|jquery|move|cursor|removeClass|NestedSortableWidgetSave|onListChange|iNestedSortable|augmentJson|onDrop|onOut|onHover|hoverclass|remove|pointer|tolerance|Droppable|isDroppable|appendTo|divWrap|saveAndProgress|jsonToDisplay|splice|setTimeout|dragged|place|dragging|curCount|when|navLinks|nextItems|slow|raquo|server|previousItems|javascript|Could|href|url|navPrevious|Entries|page|error|not|previous|nextPageDrop|success|here|previousPageDrop|mouse|Hover|button|onChange|headerItem|navNext|bind|headerWrap|slideDown|list|ajax|span|fast|slideUp|float|highlighted|build|DroppableDestroy|destroy|listHolder|toJSON|saveError|saveMessage|find|loadError|ac|animate|preventDefault|lastPage|insertOnTop|NestedSortable|attr|isNestedSortable|alpha|FILTER|ZOOM|slice|10000|el|so|value|getSizeLite|getPosition|is|submit|input|remeasure|NestedSortableWidgetDestroy|default|fadeIn|fadeOut|fade|pageChangers|helperclass|drag|saved|Data|send|from|load|Order|Save|Previous|laquo|Next|json|disabled|dataType|row|successfully|cell|alt|holder|links|active|500|px|150|POST|GET|right|widget|left|sortable|nested|width|rightToLeft|NestedSortableDestroy|complete|returnText|info|even|dragCfg|odd|clearTimeout|stop|measure'.split('|'),0,{})) 
     18 No newline at end of file 
  • wp-includes/script-loader.php

     
    7676                $this->add( 'jquery-form', '/wp-includes/js/jquery/jquery.form.js', array('jquery'), '1.0.3'); 
    7777                $this->add( 'interface', '/wp-includes/js/jquery/interface.js', array('jquery'), '1.2'); 
    7878 
     79    $this->add( 'nested-sortable', '/wp-includes/js/jquery/inestedsortable.js', array('interface'), '1.0'); 
     80    $this->add( 'nested-sortable-widget', '/wp-includes/js/jquery/jquery.nestedsortablewidget.js', array('nested-sortable'), '1.0'); 
     81    $this->add( 'edit-page-order', '/wp-admin/js/edit-page-order.js', array('nested-sortable-widget'), '20070827'); 
     82    $this->localize( 'edit-page-order', 'editPageOrderL10n', array( 
     83      'saveButton' => __("Save Page Order &raquo;"), 
     84      'editButton' => __("Edit Page Order"), 
     85      'cancelButton' => __("Return to the Regular Page List"), 
     86      'nextPageDrop' => __("Hover the mouse here when dragging to place the item in the next page."), 
     87      'previousPageDrop' => __("Hover the mouse here when dragging to place the item in the previous page."), 
     88      'nextItems' => __("Next Entries &raquo;"), 
     89      'previousItems' => __("&laquo; Previous Entries"), 
     90      'loadError' => __("Error loading data. Check your connection."), 
     91      'saveError' => __("Error saving page order. Check you connection."), 
     92      'saveMessage' => __("Page order saved successfully.") 
     93    ) ); 
     94     
    7995                if ( is_admin() ) { 
    8096                        global $pagenow; 
    8197                        $man = false; 
  • wp-includes/version.php

     
    33// This holds the version number in a separate file so we can bump it without cluttering the SVN 
    44 
    55$wp_version = '2.3-RC1'; 
    6 $wp_db_version = 6124; 
     6$wp_db_version = 6125; 
    77 
    88?>