本文整理汇总了PHP中ca_list_items::getHierarchyChildCountsForIDs方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_list_items::getHierarchyChildCountsForIDs方法的具体用法?PHP ca_list_items::getHierarchyChildCountsForIDs怎么用?PHP ca_list_items::getHierarchyChildCountsForIDs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_list_items
的用法示例。
在下文中一共展示了ca_list_items::getHierarchyChildCountsForIDs方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFacetHierarchyLevel
/**
* Given a item_id (request parameter 'id') returns a list of direct children for use in the hierarchy browser
* Returned data is JSON format
*/
public function getFacetHierarchyLevel()
{
$va_access_values = caGetUserAccessValues($this->request);
$ps_facet_name = $this->request->getParameter('facet', pString);
$this->opo_browse->setTypeRestrictions(array($this->opn_type_restriction_id));
if (!is_array($va_facet_info = $this->opo_browse->getInfoForFacet($ps_facet_name))) {
return null;
}
$va_facet = $this->opo_browse->getFacet($ps_facet_name, array('sort' => 'name', 'checkAccess' => $va_access_values));
$pa_ids = explode(";", $ps_ids = $this->request->getParameter('id', pString));
if (!sizeof($pa_ids)) {
$pa_ids = array(null);
}
$va_level_data = 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;
}
$t_model = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true);
$o_config = Configuration::load();
if (!is_array($va_sorts = $o_config->getList($this->ops_tablename . '_hierarchy_browser_sort_values')) || !sizeof($va_sorts)) {
$va_sorts = array();
}
foreach ($va_sorts as $vn_i => $vs_sort_fld) {
$va_tmp = explode(".", $vs_sort_fld);
if ($va_tmp[1] == 'preferred_labels') {
$va_tmp[0] = $vs_label_table_name;
if (!($va_tmp[1] = $va_tmp[2])) {
$va_tmp[1] = $vs_label_display_field_name;
}
unset($va_tmp[2]);
$va_sorts[$vn_i] = join(".", $va_tmp);
}
}
if (!in_array($vs_sort_dir = strtolower($o_config->get($this->ops_tablename . '_hierarchy_browser_sort_direction')), array('asc', 'desc'))) {
$vs_sort_dir = 'asc';
}
$va_expanded_facet = array();
$t_item = new ca_list_items();
foreach ($va_facet as $vn_id => $va_facet_item) {
$va_expanded_facet[$vn_id] = true;
$va_ancestors = $t_item->getHierarchyAncestors($vn_id, array('idsOnly' => true));
if (is_array($va_ancestors)) {
foreach ($va_ancestors as $vn_ancestor_id) {
$va_expanded_facet[$vn_ancestor_id] = true;
}
}
}
foreach ($pa_ids as $pn_id) {
$va_json_data = array('_primaryKey' => 'item_id');
$va_tmp = explode(":", $pn_id);
$vn_id = $va_tmp[0];
$vn_start = (int) $va_tmp[1];
if ($vn_start < 0) {
$vn_start = 0;
}
switch ($va_facet_info['type']) {
case 'attribute':
// is it a list attribute?
$t_element = new ca_metadata_elements();
if ($t_element->load(array('element_code' => $va_facet_info['element_code']))) {
if ($t_element->get('datatype') == 3) {
// 3=list
$t_list = new ca_lists();
if (!$vn_id) {
$vn_id = $t_list->getRootListItemID($t_element->get('list_id'));
}
$t_item = new ca_list_items($vn_id);
$va_children = $t_item->getHierarchyChildren(null, array('idsOnly' => true));
$va_child_counts = $t_item->getHierarchyChildCountsForIDs($va_children);
$qr_res = caMakeSearchResult('ca_list_items', $va_children);
$vs_pk = $t_model->primaryKey();
if ($qr_res) {
while ($qr_res->nextHit()) {
$vn_parent_id = $qr_res->get('ca_list_items.parent_id');
$vn_item_id = $qr_res->get('ca_list_items.item_id');
if (!isset($va_expanded_facet[$vn_item_id])) {
continue;
}
$va_item = array();
$va_item['item_id'] = $vn_item_id;
$va_item['name'] = $qr_res->get('ca_list_items.preferred_labels');
$va_item['children'] = isset($va_child_counts[$vn_item_id]) && $va_child_counts[$vn_item_id] ? $va_child_counts[$vn_item_id] : 0;
$va_json_data[$vn_item_id] = $va_item;
}
}
}
}
break;
case 'label':
// label facet
$va_facet_info['table'] = $this->ops_tablename;
// fall through to default case
// fall through to default case
default:
if (!$vn_id) {
$va_hier_ids = $this->opo_browse->getHierarchyIDsForFacet($ps_facet_name, array('checkAccess' => $va_access_values));
//.........这里部分代码省略.........
示例2: getFacetHierarchyLevel
/**
* Given a item_id (request parameter 'id') returns a list of direct children for use in the hierarchy browser
* Returned data is JSON format
*/
public function getFacetHierarchyLevel()
{
$va_access_values = caGetUserAccessValues($this->request);
$ps_facet_name = $this->request->getParameter('facet', pString);
$this->opo_browse->setTypeRestrictions(array($this->opn_type_restriction_id));
if (!is_array($va_facet_info = $this->opo_browse->getInfoForFacet($ps_facet_name))) {
return null;
}
$va_facet = $this->opo_browse->getFacet($ps_facet_name, array('sort' => 'name', 'checkAccess' => $va_access_values));
$pa_ids = explode(";", $ps_ids = $this->request->getParameter('id', pString));
if (!sizeof($pa_ids)) {
$pa_ids = array(null);
}
$va_level_data = 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;
}
$t_model = $this->opo_datamodel->getInstanceByTableName($this->ops_tablename, true);
$va_expanded_facet = array();
$t_item = new ca_list_items();
foreach ($va_facet as $vn_id => $va_facet_item) {
$va_expanded_facet[$vn_id] = true;
$va_ancestors = $t_item->getHierarchyAncestors($vn_id, array('idsOnly' => true));
if (is_array($va_ancestors)) {
foreach ($va_ancestors as $vn_ancestor_id) {
$va_expanded_facet[$vn_ancestor_id] = true;
}
}
}
foreach ($pa_ids as $pn_id) {
$va_json_data = array('_primaryKey' => 'item_id');
$va_tmp = explode(":", $pn_id);
$vn_id = $va_tmp[0];
$vn_start = (int) $va_tmp[1];
if ($vn_start < 0) {
$vn_start = 0;
}
switch ($va_facet_info['type']) {
case 'attribute':
// is it a list attribute?
$t_element = new ca_metadata_elements();
if ($t_element->load(array('element_code' => $va_facet_info['element_code']))) {
if ($t_element->get('datatype') == 3) {
// 3=list
$t_list = new ca_lists();
if (!$vn_id) {
$vn_id = $t_list->getRootListItemID($t_element->get('list_id'));
}
$t_item = new ca_list_items($vn_id);
$va_children = $t_item->getHierarchyChildren(null, array('idsOnly' => true));
$va_child_counts = $t_item->getHierarchyChildCountsForIDs($va_children);
$qr_res = caMakeSearchResult('ca_list_items', $va_children);
$vs_pk = $t_model->primaryKey();
if ($qr_res) {
while ($qr_res->nextHit()) {
$vn_parent_id = $qr_res->get('ca_list_items.parent_id');
$vn_item_id = $qr_res->get('ca_list_items.item_id');
if (!isset($va_expanded_facet[$vn_item_id])) {
continue;
}
$va_item = array();
$va_item['item_id'] = $vn_item_id;
$va_item['name'] = $qr_res->get('ca_list_items.preferred_labels');
$va_item['children'] = isset($va_child_counts[$vn_item_id]) && $va_child_counts[$vn_item_id] ? $va_child_counts[$vn_item_id] : 0;
$va_json_data[$vn_item_id] = $va_item;
}
}
}
}
break;
case 'label':
// label facet
$va_facet_info['table'] = $this->ops_tablename;
// fall through to default case
// fall through to default case
default:
if (!$vn_id) {
$va_hier_ids = $this->opo_browse->getHierarchyIDsForFacet($ps_facet_name, array('checkAccess' => $va_access_values));
$t_item = $this->opo_datamodel->getInstanceByTableName($va_facet_info['table']);
$t_item->load($vn_id);
$vn_id = $vn_root = $t_item->getHierarchyRootID();
$va_hierarchy_list = $t_item->getHierarchyList(true);
$vn_last_id = null;
$vn_c = 0;
foreach ($va_hierarchy_list as $vn_i => $va_item) {
if (!in_array($vn_i, $va_hier_ids)) {
continue;
}
// only show hierarchies that have items in browse result
if ($vn_start <= $vn_c) {
$va_item['item_id'] = $va_item[$t_item->primaryKey()];
if (!isset($va_facet[$va_item['item_id']]) && $vn_root == $va_item['item_id']) {
continue;
}
unset($va_item['parent_id']);
unset($va_item['label']);
//.........这里部分代码省略.........