| 1 |
<?php |
| 2 |
/** |
| 3 |
* |
| 4 |
*/ |
| 5 |
|
| 6 |
/** |
| 7 |
* |
| 8 |
*/ |
| 9 |
abstract class CJT_Models_Block_Assignmentpanel_Taxonomybase |
| 10 |
extends CJT_Models_Block_Assignmentpanel_Wordpress { |
| 11 |
|
| 12 |
|
| 13 |
/** |
| 14 |
* put your comment there... |
| 15 |
* |
| 16 |
* @var mixed |
| 17 |
*/ |
| 18 |
protected $args = array( |
| 19 |
'child_of' => 0, |
| 20 |
'hide_empty' => false, |
| 21 |
'hierarchical' => 1, |
| 22 |
'include_last_update_time' => false, |
| 23 |
'order' => 'DESC', |
| 24 |
'orderby' => 'name', |
| 25 |
'pad_counts' => 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 |
// Initialize. |
| 36 |
$typeParams =& $this->getTypeParams(); |
| 37 |
$taxonomy = $typeParams['type']; |
| 38 |
// COMMON names for 'ID' and 'TITLE' |
| 39 |
$preItem['id'] = $item->term_id; |
| 40 |
$preItem['title'] = $item->name; |
| 41 |
$preItem['parent'] = $item->parent; |
| 42 |
// Get taxonomy link. |
| 43 |
$preItem['link'] = get_term_link($item, $taxonomy); |
| 44 |
/// Flag if term has child terms! |
| 45 |
// Query childs. |
| 46 |
$args = $this->args; |
| 47 |
$args['parent'] = $preItem['id']; |
| 48 |
$args['hide_empty'] = false; |
| 49 |
$args['fields'] = 'ids'; |
| 50 |
$args['number'] = 1; |
| 51 |
$childTerms = get_terms($typeParams['type'], $args); |
| 52 |
// Flag it! |
| 53 |
$preItem['hasChilds'] = !empty($childTerms); |
| 54 |
// Re-Reference. |
| 55 |
$item = $preItem; |
| 56 |
} |
| 57 |
|
| 58 |
} // End class. |
| 59 |
|