当前位置: 首页>>代码示例>>PHP>>正文


PHP ca_occurrences::getHierarchyChildren方法代码示例

本文整理汇总了PHP中ca_occurrences::getHierarchyChildren方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_occurrences::getHierarchyChildren方法的具体用法?PHP ca_occurrences::getHierarchyChildren怎么用?PHP ca_occurrences::getHierarchyChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca_occurrences的用法示例。


在下文中一共展示了ca_occurrences::getHierarchyChildren方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getHierarchyList

 /**
  * Return array containing information about all hierarchies, including their root_id's
  * For non-adhoc hierarchies such as occurrences, this call returns the contents of the occurrence_hierarchies list
  * with some extra information such as the # of top-level items in each hierarchy.
  *
  * For an ad-hoc hierarchy like that of an collection, there is only ever one hierarchy to display - that of the current collection.
  * So for adhoc hierarchies we just return a single entry corresponding to the root of the current occurrence hierarchy
  */
 public function getHierarchyList($pb_dummy = false)
 {
     $vn_pk = $this->getPrimaryKey();
     $vs_template = $this->getAppConfig()->get('ca_occurrences_hierarchy_browser_display_settings');
     if (!$vn_pk) {
         $o_db = new Db();
         if (is_array($va_type_ids = caMergeTypeRestrictionLists($this, array())) && sizeof($va_type_ids)) {
             $qr_res = $o_db->query("\n\t\t\t\t\tSELECT o.occurrence_id, count(*) c\n\t\t\t\t\tFROM ca_occurrences o\n\t\t\t\t\tINNER JOIN ca_occurrences AS p ON p.parent_id = o.occurrence_id\n\t\t\t\t\tWHERE o.parent_id IS NULL AND o.type_id IN (?)\n\t\t\t\t\tGROUP BY o.occurrence_id\n\t\t\t\t", array($va_type_ids));
         } else {
             $qr_res = $o_db->query("\n\t\t\t\t\tSELECT o.occurrence_id, count(*) c\n\t\t\t\t\tFROM ca_occurrences o\n\t\t\t\t\tINNER JOIN ca_occurrences AS p ON p.parent_id = o.occurrence_id\n\t\t\t\t\tWHERE o.parent_id IS NULL\n\t\t\t\t\tGROUP BY o.occurrence_id\n\t\t\t\t");
         }
         $va_hiers = array();
         $va_occurrence_ids = $qr_res->getAllFieldValues('occurrence_id');
         $qr_res->seek(0);
         $va_labels = $this->getPreferredDisplayLabelsForIDs($va_occurrence_ids);
         while ($qr_res->nextRow()) {
             $va_hiers[$vn_occurrence_id = $qr_res->get('occurrence_id')] = array('occurrence_id' => $vn_occurrence_id, 'name' => caProcessTemplateForIDs($vs_template, 'ca_occurrences', array($vn_occurrence_id)), 'hierarchy_id' => $vn_occurrence_id, 'children' => (int) $qr_res->get('c'));
         }
         return $va_hiers;
     } else {
         // return specific occurrence as root of hierarchy
         $vs_label = $this->getLabelForDisplay(false);
         $vs_hier_fld = $this->getProperty('HIERARCHY_ID_FLD');
         $vs_parent_fld = $this->getProperty('PARENT_ID_FLD');
         $vn_hier_id = $this->get($vs_hier_fld);
         if ($this->get($vs_parent_fld)) {
             // currently loaded row is not the root so get the root
             $va_ancestors = $this->getHierarchyAncestors();
             if (!is_array($va_ancestors) || sizeof($va_ancestors) == 0) {
                 return null;
             }
             $t_occurrence = new ca_occurrences($va_ancestors[0]);
         } else {
             $t_occurrence =& $this;
         }
         $va_children = $t_occurrence->getHierarchyChildren(null, array('idsOnly' => true));
         $va_occurrence_hierarchy_root = array($t_occurrence->get($vs_hier_fld) => array('occurrence_id' => $vn_pk, 'item_id' => $vn_pk, 'name' => $vs_name = caProcessTemplateForIDs($vs_template, 'ca_occurrences', array($vn_pk)), 'hierarchy_id' => $vn_hier_id, 'children' => sizeof($va_children)));
         return $va_occurrence_hierarchy_root;
     }
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:48,代码来源:ca_occurrences.php


注:本文中的ca_occurrences::getHierarchyChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。