| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
*/ |
| 9 |
class CJT_Models_Block_Assignmentpanel_Postpinned |
| 10 |
extends CJT_Models_Block_Assignmentpanel_Postbase { |
| 11 |
|
| 12 |
/** |
| 13 |
* put your comment there... |
| 14 |
* |
| 15 |
*/ |
| 16 |
public function getTotalCount() { |
| 17 |
return count($this->getPinsMap()); |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* put your comment there... |
| 22 |
* |
| 23 |
*/ |
| 24 |
protected function isHierarchical() { |
| 25 |
return false; |
| 26 |
} |
| 27 |
|
| 28 |
/** |
| 29 |
* put your comment there... |
| 30 |
* |
| 31 |
* @param mixed $key |
| 32 |
* @param mixed $item |
| 33 |
*/ |
| 34 |
protected function prepareItem($key, & $item) { |
| 35 |
// Prepare item. |
| 36 |
parent::prepareItem($key, $item); |
| 37 |
// No parents used in assignedOnly items. |
| 38 |
$item['parent'] = 0; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* put your comment there... |
| 43 |
* |
| 44 |
* |
| 45 |
*/ |
| 46 |
protected function queryItems() { |
| 47 |
// All assigned items is fetched in the first request |
| 48 |
// Multiple requestes is now allowed. |
| 49 |
if ($this->getOffset()) { |
| 50 |
return array(); |
| 51 |
} |
| 52 |
// Initialize. |
| 53 |
$params = $this->getTypeParams(); |
| 54 |
// Get all assigned IDs. |
| 55 |
$ids = array_keys($this->getPinsMap()); |
| 56 |
// Query all available Ids. |
| 57 |
$args = $this->args; |
| 58 |
$args['post_type'] = $params['type']; |
| 59 |
$args['post__in'] = $ids; |
| 60 |
$args['offset'] = $this->getOffset(); |
| 61 |
$args['numberposts'] = -1; |
| 62 |
// Return empty list if nothing assigned |
| 63 |
// or the queried items otherwise. |
| 64 |
$items = empty($ids) ? array() : get_posts($args); |
| 65 |
// Returns. |
| 66 |
return $items; |
| 67 |
} |
| 68 |
|
| 69 |
} // End class. |