本文整理汇总了PHP中ca_objects::getHierarchyChildCountsForIDs方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_objects::getHierarchyChildCountsForIDs方法的具体用法?PHP ca_objects::getHierarchyChildCountsForIDs怎么用?PHP ca_objects::getHierarchyChildCountsForIDs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_objects
的用法示例。
在下文中一共展示了ca_objects::getHierarchyChildCountsForIDs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: GetHierarchyLevelData
//.........这里部分代码省略.........
if (!($vs_item_template = trim($o_config->get("{$vs_table}_hierarchy_browser_display_settings")))) {
$vs_item_template = "^{$vs_table}.preferred_labels.{$vs_label_display_field_name}";
}
$va_child_counts = array();
if (($vn_max_items_per_page = $this->request->getParameter('max', pInteger)) < 1 || $vn_max_items_per_page > 1000) {
$vn_max_items_per_page = null;
}
$vn_c = 0;
$vn_item_count = $qr_children->numRows();
$qr_children->seek($vn_start);
while ($qr_children->nextRow()) {
$va_tmp = array($vs_pk => $vn_id = $qr_children->get($vs_table . '.' . $vs_pk), 'item_id' => $vs_table . '-' . $vn_id, 'parent_id' => $qr_children->get($vs_table . '.parent_id'), 'idno' => $qr_children->get($vs_table . '.idno'), 'locale_id' => $qr_children->get($vs_table . '.' . 'locale_id'));
if (!$va_tmp[$vs_label_display_field_name]) {
$va_tmp[$vs_label_display_field_name] = $va_tmp['idno'];
}
if (!$va_tmp[$vs_label_display_field_name]) {
$va_tmp[$vs_label_display_field_name] = '???';
}
$va_tmp['name'] = caProcessTemplateForIDs($vs_item_template, $vs_table, array($va_tmp[$vs_pk]));
// Child count is only valid if has_children is not null
$va_tmp['children'] = $qr_children->get('has_children') ? (int) $qr_children->get('child_count') : 0;
if (is_array($va_sorts)) {
$vs_sort_acc = array();
foreach ($va_sorts as $vs_sort) {
$vs_sort_acc[] = $qr_children->get($vs_sort);
}
$va_tmp['sort'] = join(";", $vs_sort_acc);
}
$va_items[$va_tmp['item_id']][$va_tmp['locale_id']] = $va_tmp;
$vn_c++;
if (!is_null($vn_max_items_per_page) && $vn_c >= $vn_max_items_per_page) {
break;
}
}
if ($t_item->tableName() == 'ca_collections') {
$va_cross_table_items = $t_item->getRelatedItems('ca_objects');
$vn_item_count += sizeof($va_cross_table_items);
$va_ids = array();
foreach ($va_cross_table_items as $vn_x_item_id => $va_x_item) {
$va_items['ca_objects-' . $vn_x_item_id][$va_x_item['locale_id']] = $va_x_item;
//$va_x_item_extracted = caExtractValuesByUserLocale(array(0 => $va_x_item['labels']));
//$va_items[$va_x_item['object_id']][$va_x_item['locale_id']]['name'] = $va_x_item_extracted[0];
$va_items['ca_objects-' . $va_x_item['object_id']][$va_x_item['locale_id']]['item_id'] = 'ca_objects-' . $va_x_item['object_id'];
$va_items['ca_objects-' . $va_x_item['object_id']][$va_x_item['locale_id']]['parent_id'] = $vn_id;
unset($va_items['ca_objects-' . $vn_x_item_id][$va_x_item['locale_id']]['labels']);
$va_items['ca_objects-' . $va_x_item['object_id']][$va_x_item['locale_id']]['children'] = 0;
$va_ids[] = $va_x_item['object_id'];
}
if (!($vs_item_template = trim($o_config->get("ca_objects_hierarchy_browser_display_settings")))) {
$vs_item_template = "^ca_objects.preferred_labels.name";
}
if (sizeof($va_ids)) {
$va_child_counts = $t_object->getHierarchyChildCountsForIDs($va_ids);
$va_templates = caProcessTemplateForIDs($vs_item_template, 'ca_objects', $va_ids, array('returnAsArray' => true));
foreach ($va_child_counts as $vn_id => $vn_c) {
$va_items['ca_objects-' . $vn_id][$va_x_item['locale_id']]['children'] = $vn_c;
}
foreach ($va_ids as $vn_i => $vn_id) {
$va_items['ca_objects-' . $vn_id][$va_x_item['locale_id']]['name'] = $va_templates[$vn_i];
}
}
}
$va_items_for_locale = caExtractValuesByUserLocale($va_items);
$vs_rank_fld = $t_item->getProperty('RANK');
$va_sorted_items = array();
foreach ($va_items_for_locale as $vn_id => $va_node) {
$vs_key = preg_replace('![^A-Za-z0-9]!', '_', $va_node['name']);
if (isset($va_node['sort']) && $va_node['sort']) {
$va_sorted_items[$va_node['sort']][$vs_key] = $va_node;
} else {
if ($vs_rank_fld && ($vs_rank = (int) sprintf("%08d", $va_node[$vs_rank_fld]))) {
$va_sorted_items[$vs_rank][$vs_key] = $va_node;
} else {
$va_sorted_items[$vs_key][$vs_key] = $va_node;
}
}
}
ksort($va_sorted_items);
if ($vs_sort_dir == 'desc') {
$va_sorted_items = array_reverse($va_sorted_items);
}
$va_items_for_locale = array();
foreach ($va_sorted_items as $vs_k => $va_v) {
ksort($va_v);
if ($vs_sort_dir == 'desc') {
$va_v = array_reverse($va_v);
}
$va_items_for_locale = array_merge($va_items_for_locale, $va_v);
}
}
}
$va_items_for_locale['_sortOrder'] = array_keys($va_items_for_locale);
$va_items_for_locale['_primaryKey'] = $t_item->primaryKey();
// pass the name of the primary key so the hierbrowser knows where to look for item_id's
$va_items_for_locale['_itemCount'] = $vn_item_count;
//$qr_children ? $qr_children->numRows() : 0;
$va_level_data[$pn_id] = $va_items_for_locale;
}
return $va_level_data;
}