Permalink
Browse files

Merge branch '2.0' of https://github.com/pods-framework/pods into 2.0

  • Loading branch information...
2 parents 5a8fc6c + fd65f5a commit 1838ed7babcc868a791423ad0367b22425d3296f @mikedamage mikedamage committed Aug 10, 2012
Showing with 335 additions and 89 deletions.
  1. +22 −12 classes/PodsAPI.php
  2. +2 −2 classes/PodsAdmin.php
  3. +15 −8 classes/PodsUI.php
  4. +253 −38 sql/PodsUpgrade.php
  5. +12 −11 ui/admin/upgrade.php
  6. +31 −18 ui/js/jquery.pods.upgrade.js
View
@@ -789,6 +789,9 @@ public function save_pod ( $params ) {
$pod[ 'options' ] = array_merge( $pod[ 'options' ], $options );
+ if ( strlen( $pod[ 'label' ] ) < 1 )
+ $pod[ 'label' ] = $pod[ 'name' ];
+
$params->id = $pod[ 'id' ];
$params->name = $pod[ 'name' ];
@@ -868,7 +871,8 @@ public function save_pod ( $params ) {
'ID' => $pod[ 'id' ],
'post_name' => $pod[ 'name' ],
'post_title' => $pod[ 'label' ],
- 'post_content' => $pod[ 'description' ]
+ 'post_content' => $pod[ 'description' ],
+ 'post_status' => 'publish'
);
}
@@ -1148,13 +1152,16 @@ public function save_field ( $params, $table_operation = true ) {
foreach ( $aliases as $alias ) {
if ( isset( $options[ $alias ] ) ) {
- $field[ $exclude_field ] = $options[ $alias ];
+ $field[ $exclude_field ] = trim( $options[ $alias ] );
unset( $options[ $alias ] );
}
}
}
+ if ( strlen( $field[ 'label' ] ) < 1 )
+ $field[ 'label' ] = $field[ 'name' ];
+
$field[ 'options' ][ 'type' ] = $field[ 'type' ];
if ( in_array( $field[ 'type' ], $tableless_field_types ) ) {
@@ -1166,12 +1173,12 @@ public function save_field ( $params, $table_operation = true ) {
$field[ 'pick_val' ] = pods_str_replace( 'pod-', '', $field[ 'pick_object' ], 1 );
$field[ 'pick_object' ] = 'pod';
}
- elseif ( 0 === strpos( 'post-types-', $field[ 'pick_object' ] ) ) {
- $field[ 'pick_val' ] = pods_str_replace( 'post-types-', '', $field[ 'pick_object' ], 1 );
+ elseif ( 0 === strpos( 'post-type-', $field[ 'pick_object' ] ) ) {
+ $field[ 'pick_val' ] = pods_str_replace( 'post-type-', '', $field[ 'pick_object' ], 1 );
$field[ 'pick_object' ] = 'post_type';
}
- elseif ( 0 === strpos( 'taxonomies-', $field[ 'pick_object' ] ) ) {
- $field[ 'pick_val' ] = pods_str_replace( 'taxonomies-', '', $field[ 'pick_object' ], 1 );
+ elseif ( 0 === strpos( 'taxonomy-', $field[ 'pick_object' ] ) ) {
+ $field[ 'pick_val' ] = pods_str_replace( 'taxonomy-', '', $field[ 'pick_object' ], 1 );
$field[ 'pick_object' ] = 'taxonomy';
}
}
@@ -2578,9 +2585,12 @@ public function load_pod ( $params, $strict = true ) {
'description' => $_pod[ 'post_content' ]
);
+ if ( strlen( $pod[ 'label' ] ) < 1 )
+ $pod[ 'label' ] = $pod[ 'name' ];
+
// @todo update with a method to put all options in
$defaults = array(
- 'is_toplevel' => 1,
+ 'show_in_menu' => 1,
'type' => 'post_type',
'storage' => 'meta',
'object' => '',
@@ -2650,7 +2660,7 @@ public function load_pods ( $params = null ) {
$params = (object) pods_sanitize( $params );
$order = 'ASC';
- $orderby = 'menu_order';
+ $orderby = 'menu_order title';
$limit = -1;
$meta_query = array();
@@ -2722,7 +2732,7 @@ public function load_pods ( $params = null ) {
else
$cache_key = 'pods_get' . $cache_key;
- if ( ( 'pods' != $cache_key || empty( $meta_query ) ) && empty( $limit ) && ( empty ( $orderby ) || 'menu_order' == $orderby ) ) {
+ if ( ( 'pods' != $cache_key || empty( $meta_query ) ) && empty( $limit ) && ( empty ( $orderby ) || 'menu_order title' == $orderby ) ) {
$the_pods = get_transient( $cache_key );
if ( false !== $the_pods )
@@ -2943,10 +2953,10 @@ public function load_fields ( $params, $strict = false ) {
foreach ( $pod[ 'fields' ] as $field ) {
if ( empty( $params->name ) && empty( $params->id ) && empty( $params->type ) )
- $fields[ $field[ 'id' ] ] = $field;
+ $fields[ $field[ 'name' ] ] = $field;
if ( in_array( $fields[ 'name' ], $params->name ) || in_array( $fields[ 'id' ], $params->id ) || in_array( $fields[ 'type' ], $params->type ) )
- $fields[ $field[ 'id' ] ] = $field;
+ $fields[ $field[ 'name' ] ] = $field;
}
}
else {
@@ -2982,7 +2992,7 @@ public function load_fields ( $params, $strict = false ) {
) );
if ( empty( $params->type ) || in_array( $fields[ 'type' ], $params->type ) )
- $fields[ $field[ 'id' ] ] = $field;
+ $fields[ $field[ 'name' ] ] = $field;
}
}
}
View
@@ -147,7 +147,7 @@ public function admin_head () {
public function admin_menu () {
$submenu = array();
- $results = $this->api->load_pods( array( //'options' => array('disable_manage' => 0),
+ $results = $this->api->load_pods( array(
'type' => 'pod'
) );
@@ -162,7 +162,7 @@ public function admin_menu () {
$item[ 'options' ][ 'label' ] = ( !empty( $item[ 'options' ][ 'label' ] ) ) ? $item[ 'options' ][ 'label' ] : ucwords( str_replace( '_', ' ', $item[ 'name' ] ) );
$item[ 'options' ][ 'label' ] = apply_filters( 'pods_admin_menu_label', $item[ 'options' ][ 'label' ], $item );
- if ( 1 == $item[ 'options' ][ 'is_toplevel' ] ) {
+ if ( 1 == $item[ 'options' ][ 'show_in_menu' ] ) {
add_object_page( $item[ 'options' ][ 'label' ], $item[ 'options' ][ 'label' ], 'read', "pods-manage-{$item['name']}" );
if ( is_super_admin() || current_user_can( 'pods_edit_' . $item[ 'name' ] ) || current_user_can( 'pods_delete_' . $item[ 'name' ] ) ) {
View
@@ -54,6 +54,7 @@ class PodsUI
public $searchable = true;
public $sortable = true;
public $pagination = true;
+ public $pagination_total = true;
public $export = array('on' => false,
'formats' => array('csv' => ',',
'tsv' => "\t",
@@ -1223,11 +1224,11 @@ public function manage ($reorder = false) {
<?php
}
- if (!empty($this->data) && ( false !== $this->pagination || ( true === $reorder && !in_array( 'reorder', $this->actions_disabled ) && !in_array( 'delete', $this->actions_hidden ) && false !== $this->reorder[ 'on' ] ) ) || ( !in_array( 'export', $this->actions_disabled ) && !in_array( 'export', $this->actions_hidden ) ) ) {
+ if (!empty($this->data) && ( false !== $this->pagination_total || false !== $this->pagination || ( true === $reorder && !in_array( 'reorder', $this->actions_disabled ) && !in_array( 'delete', $this->actions_hidden ) && false !== $this->reorder[ 'on' ] ) ) || ( !in_array( 'export', $this->actions_disabled ) && !in_array( 'export', $this->actions_hidden ) ) ) {
?>
<div class="tablenav">
<?php
- if (false !== $this->pagination) {
+ if ( false !== $this->pagination_total || false !== $this->pagination ) {
?>
<div class="tablenav-pages<?php echo ($this->limit < $this->total_found || 1 < $this->page) ? '' : ' one-page'; ?>">
<?php $this->pagination(1); ?>
@@ -1295,7 +1296,7 @@ public function manage ($reorder = false) {
</div>
<?php
}*/
- if (false !== $this->pagination) {
+ if ( false !== $this->pagination_total || false !== $this->pagination ) {
?>
<div class="tablenav">
<div class="tablenav-pages<?php echo ($this->limit < $this->total_found || 1 < $this->page) ? '' : ' one-page'; ?>">
@@ -1849,15 +1850,20 @@ public function pagination ($header = false) {
return call_user_func($this->actions_custom['pagination'], $header, $this);
$total_pages = ceil($this->total_found / $this->limit);
$request_uri = pods_var_update(array('pg' . $this->num => ''), array('limit' . $this->num, 'orderby' . $this->num, 'orderby_dir' . $this->num, 'search' . $this->num), $this->exclusion());
+
+ if ( false !== $this->pagination_total ) {
?>
<span class="displaying-num"><?php echo $this->total_found; ?> item<?php echo (1 == $this->total_found) ? '' : 's'; ?></span>
<?php
- if (1 < $total_pages) {
+ }
+
+ if ( false !== $this->pagination ) {
+ if (1 < $total_pages) {
?>
<a class="first-page<?php echo (1 < $this->page) ? '' : ' disabled'; ?>" title="<?php _e('Go to the first page', 'pods'); ?>" href="<?php echo $request_uri; ?>">&laquo;</a>
<a class="prev-page<?php echo (1 < $this->page) ? '' : ' disabled'; ?>" title="<?php _e('Go to the previous page', 'pods'); ?>" href="<?php echo $request_uri; ?>&pg<?php echo $this->num; ?>=<?php echo max($this->page - 1, 1); ?>">&lsaquo;</a>
<?php
- if (true == $header) {
+ if (true == $header) {
?>
<span class="paging-input"><input class="current-page" title="<?php _e('Current page', 'pods'); ?>" type="text" name="pg<?php echo $this->num; ?>" value="<?php echo $this->page; ?>" size="<?php echo strlen($total_pages); ?>"> <?php _e('of', 'pods'); ?> <span class="total-pages"><?php echo $total_pages; ?></span></span>
<script>
@@ -1872,16 +1878,17 @@ public function pagination ($header = false) {
});
</script>
<?php
- }
- else {
+ }
+ else {
?>
<span class="paging-input"><?php echo $this->page; ?> <?php _e('of', 'pods'); ?> <span class="total-pages"><?php echo $total_pages; ?></span></span>
<?php
- }
+ }
?>
<a class="next-page<?php echo ($this->page < $total_pages) ? '' : ' disabled'; ?>" title="<?php _e('Go to the next page', 'pods'); ?>" href="<?php echo $request_uri; ?>&pg<?php echo $this->num; ?>=<?php echo min($this->page + 1, $total_pages); ?>">&rsaquo;</a>
<a class="last-page<?php echo ($this->page < $total_pages) ? '' : ' disabled'; ?>" title="<?php _e('Go to the last page', 'pods'); ?>'" href="<?php echo $request_uri; ?>&pg<?php echo $this->num; ?>=<?php echo $total_pages; ?>">&raquo;</a>
<?php
+ }
}
}
Oops, something went wrong.

0 comments on commit 1838ed7

Please sign in to comment.