WordPress.org

Plugin Directory

Changeset 632792


Ignore:
Timestamp:
12/01/12 23:26:05 (17 months ago)
Author:
scribu
Message:

deploy from git

Location:
posts-to-posts/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • posts-to-posts/trunk/admin/column.php

    r630742 r632792  
    4040        $connected = $this->ctype->get_connected( $items, $extra_qv, 'abstract' ); 
    4141 
    42         $this->connected = p2p_triage_connected( $connected->items ); 
     42        $this->connected = p2p_list_cluster( $connected, '_p2p_get_other_id' ); 
    4343    } 
    4444 
  • posts-to-posts/trunk/core/api.php

    r630742 r632792  
    22 
    33/** 
    4  * Register a connection between two post types. 
    5  * 
    6  * This creates the appropriate meta box in the admin edit screen. 
    7  * 
    8  * Takes the following parameters, as an associative array: 
     4 * Register a connection type. 
     5 * 
     6 * @param array $args Associative array: 
    97 * 
    108 * - 'name' - string A unique identifier for this connection type. 
    119 * 
    12  * - 'from' - string|array The first end of the connection. 
     10 * - 'from' - string|array The first end of the connection: post type name or 'user' 
    1311 * 
    1412 * - 'from_query_vars' - array Additional query vars to pass to WP_Query. Default: none. 
    1513 * 
    16  * - 'to' - string|array The second end of the connection. 
     14 * - 'to' - string|array The second end of the connection: post type name or 'user' 
    1715 * 
    1816 * - 'to_query_vars' - array Additional query vars to pass to WP_Query. Default: none. 
     
    2422 * - 'duplicate_connections' - bool Whether to allow more than one connection between the same two posts. Default: false. 
    2523 * 
    26  * - 'self_connections' - bool Whether to allow a post to connect to itself. Default: false. 
     24 * - 'self_connections' - bool Whether to allow a post/user to connect to itself. Default: false. 
    2725 * 
    2826 * - 'sortable' - bool|string Whether to allow connections to be ordered via drag-and-drop. Can be 'from', 'to', 'any' or false. Default: false. 
     
    3634 * - 'reciprocal' - bool For indeterminate connections: True means all connections are displayed in a single box. False means 'from' connections are shown in one box and 'to' connections are shown in another box. Default: false. 
    3735 * 
    38  * - 'admin_box' - bool|string|array Whether and where to show the admin connections box. 
     36 * - 'admin_box' - bool|string|array Whether and where to show the admin connections box. Default: 'any' 
    3937 * 
    4038 * - 'can_create_post' - bool Whether to allow post creation via the connection box. Default: true. 
    4139 * 
    42  * @param array $args 
     40 * - 'admin_column' - bool|string|array Whether to show connection columns on post/user list table. Default: false 
     41 * 
     42 * - 'admin_dropdown' - bool|string|array Whether to show connection dropdown on post/user list table. Default: false 
    4343 * 
    4444 * @return bool|object False on failure, P2P_Connection_Type instance on success. 
     
    354354    } 
    355355 
    356     $groups = p2p_triage_connected( $connected ); 
     356    $groups = p2p_list_cluster( $connected, '_p2p_get_other_id' ); 
    357357 
    358358    foreach ( $groups as $outer_item_id => $connected_items ) { 
     
    361361} 
    362362 
    363 function p2p_triage_connected( $connected ) { 
    364     $groups = array(); 
    365  
    366     foreach ( $connected as $inner_item ) { 
    367         if ( $inner_item->ID == $inner_item->p2p_from ) { 
    368             $outer_item_id = $inner_item->p2p_to; 
    369         } elseif ( $inner_item->ID == $inner_item->p2p_to ) { 
    370             $outer_item_id = $inner_item->p2p_from; 
    371         } else { 
    372             trigger_error( "Corrupted data for item $inner_item->ID", E_USER_WARNING ); 
    373             continue; 
    374         } 
    375  
    376         $groups[ $outer_item_id ][] = $inner_item; 
    377     } 
    378  
    379     return $groups; 
    380 } 
    381  
  • posts-to-posts/trunk/core/util.php

    r604130 r632792  
    11<?php 
     2 
     3function p2p_list_cluster( $items, $callback ) { 
     4    $groups = array(); 
     5 
     6    foreach ( $items as $item ) { 
     7        $key = $callback( $item ); 
     8 
     9        if ( null === $key ) 
     10            continue; 
     11 
     12        $groups[ $key ][] = $item; 
     13    } 
     14 
     15    return $groups; 
     16} 
    217 
    318/** @internal */ 
     
    108123} 
    109124 
     125/** @internal */ 
     126function _p2p_get_other_id( $item ) { 
     127    if ( $item->ID == $item->p2p_from ) 
     128        return $item->p2p_to; 
     129 
     130    if ( $item->ID == $item->p2p_to ) 
     131        return $item->p2p_from; 
     132 
     133    trigger_error( "Corrupted data for item $inner_item->ID", E_USER_WARNING ); 
     134} 
     135 
  • posts-to-posts/trunk/posts-to-posts.php

    r630742 r632792  
    3232    P2P_Shortcodes::init(); 
    3333 
    34     if ( is_admin() ) { 
    35         _p2p_load_files( "$base/admin", array( 
    36             'mustache', 'factory', 
    37             'box-factory', 'box', 'fields', 
    38             'column-factory', 'column', 
    39             'dropdown-factory', 'dropdown', 
    40             'tools' 
    41         ) ); 
    42     } 
     34    if ( is_admin() ) 
     35        _p2p_load_admin(); 
    4336 
    4437    register_uninstall_hook( __FILE__, array( 'P2P_Storage', 'uninstall' ) ); 
    4538} 
    4639scb_init( '_p2p_load' ); 
     40 
     41function _p2p_load_admin() { 
     42    _p2p_load_files( dirname(__FILE__) . '/admin', array( 
     43        'mustache', 'factory', 
     44        'box-factory', 'box', 'fields', 
     45        'column-factory', 'column', 
     46        'dropdown-factory', 'dropdown', 
     47        'tools' 
     48    ) ); 
     49} 
    4750 
    4851function _p2p_init() { 
Note: See TracChangeset for help on using the changeset viewer.