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


PHP ca_list_items::getHierarchy方法代码示例

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


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

示例1: caMakeSourceIDList

/**
 * Converts the given list of source names or source_ids into an expanded list of numeric source_ids suitable for enforcing source restrictions. Processing
 * includes expansion of sources to include subsources and conversion of any source codes to source_ids.
 *
 * @param mixed $pm_table_name_or_num Table name or number to which sources apply
 * @param array $pa_sources List of source codes and/or source_ids that are the basis of the list
 * @param array $pa_options Array of options:
 * 		dont_include_subsources_in_source_restriction = if set, returned list is not expanded to include subsources
 *		dontIncludeSubsourcesInSourceRestriction = synonym for dont_include_subsources_in_source_restriction
 *
 * @return array List of numeric source_ids
 */
function caMakeSourceIDList($pm_table_name_or_num, $pa_sources, $pa_options = null)
{
    $o_dm = Datamodel::load();
    if (isset($pa_options['dontIncludeSubsourcesInSourceRestriction']) && (!isset($pa_options['dont_include_subsources_in_source_restriction']) || !$pa_options['dont_include_subsources_in_source_restriction'])) {
        $pa_options['dont_include_subsources_in_source_restriction'] = $pa_options['dontIncludeSubsourcesInSourceRestriction'];
    }
    if (isset($pa_options['dont_include_subsources_in_source_restriction']) && $pa_options['dont_include_subsources_in_source_restriction']) {
        $pa_options['noChildren'] = true;
    }
    if (is_numeric($pm_table_name_or_num)) {
        $vs_table_name = $o_dm->getTableName($pm_table_name_or_num);
    } else {
        $vs_table_name = $pm_table_name_or_num;
    }
    $t_instance = $o_dm->getInstanceByTableName($vs_table_name, true);
    if (!$t_instance) {
        return null;
    }
    // bad table
    if (!($vs_source_list_code = $t_instance->getSourceListCode())) {
        return null;
    }
    // table doesn't use sources
    $va_source_ids = array();
    $t_list = new ca_lists();
    $t_item = new ca_list_items();
    $vs_list_code = $t_instance->getSourceListCode();
    foreach ($pa_sources as $vm_source) {
        if (!$vm_source) {
            continue;
        }
        $vn_source_id = null;
        if (is_numeric($vm_source)) {
            $vn_source_id = (int) $vm_source;
        } else {
            $vn_source_id = (int) $t_list->getItemIDFromList($vs_source_list_code, $vm_source);
        }
        if ($vn_source_id && !(isset($pa_options['noChildren']) || $pa_options['noChildren'])) {
            if ($qr_children = $t_item->getHierarchy($vn_source_id, array())) {
                while ($qr_children->nextRow()) {
                    $va_source_ids[$qr_children->get('item_id')] = true;
                }
            }
        } else {
            if ($vn_source_id) {
                $va_source_ids[$vn_source_id] = true;
            }
        }
    }
    return array_keys($va_source_ids);
}
开发者ID:samrahman,项目名称:providence,代码行数:63,代码来源:accessHelpers.php

示例2: _convertTypeCodesToIDs

 /**
  *
  *
  * @param array $pa_type_codes_or_ids List of type codes or ids 
  * @param array $pa_options Options include
  *		dontExpandHierarchically =
  * @return array List of type_ids
  */
 private function _convertTypeCodesToIDs($pa_type_codes_or_ids, $pa_options = null)
 {
     $vs_md5 = caMakeCacheKeyFromOptions($pa_type_codes_or_ids);
     if (isset(BrowseEngine::$s_type_id_cache[$vs_md5])) {
         return BrowseEngine::$s_type_id_cache[$vs_md5];
     }
     if (isset($pa_options['instance']) && is_object($pa_options['instance'])) {
         $t_instance = $pa_options['instance'];
     } else {
         $t_instance = $this->getSubjectInstance();
     }
     $va_type_ids = array();
     if (!$pa_type_codes_or_ids) {
         return false;
     }
     if (is_array($pa_type_codes_or_ids) && !sizeof($pa_type_codes_or_ids)) {
         return false;
     }
     if (!is_array($pa_type_codes_or_ids)) {
         $pa_type_codes_or_ids = array($pa_type_codes_or_ids);
     }
     $t_list = new ca_lists();
     if (!method_exists($t_instance, 'getTypeListCode')) {
         return false;
     }
     if (!($vs_list_name = $t_instance->getTypeListCode())) {
         return false;
     }
     $va_type_list = $t_instance->getTypeList();
     foreach ($pa_type_codes_or_ids as $vs_code_or_id) {
         if (!trim($vs_code_or_id)) {
             continue;
         }
         if (!is_numeric($vs_code_or_id)) {
             $vn_type_id = $t_list->getItemIDFromList($vs_list_name, $vs_code_or_id);
         } else {
             $vn_type_id = (int) $vs_code_or_id;
         }
         if (!$vn_type_id) {
             return false;
         }
         if (isset($va_type_list[$vn_type_id]) && $va_type_list[$vn_type_id]) {
             // is valid type for this subject
             // See if there are any child types
             if (!caGetOption('dontExpandHierarchically', $pa_options, false) && !$this->opb_dont_expand_type_restrictions) {
                 $t_item = new ca_list_items();
                 $va_ids = $t_item->getHierarchy($vn_type_id, array('idsOnly' => true));
             }
             $va_ids[] = $vn_type_id;
             $va_type_ids = array_merge($va_type_ids, $va_ids);
         }
     }
     $va_type_ids = array_keys(array_flip($va_type_ids));
     BrowseEngine::$s_type_id_cache[$vs_md5] = $va_type_ids;
     return $va_type_ids;
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:64,代码来源:BrowseEngine.php

示例3: getItemIDsFromList

 /**
  * Converts the given list of list item idnos or item_ids into an expanded list of numeric item_ids. Processing
  * includes expansion of items to include sub-items and conversion of any idnos to item_ids.
  *
  * @param mixed $pm_table_name_or_num Table name or number to which types apply
  * @param array $pa_types List of item idnos and/or item_ids that are the basis of the list
  * @param array $pa_options Array of options:
  * 		dont_include_sub_items = if set, returned list is not expanded to include sub-items
  *		dontIncludeSubItems = synonym for dont_include_sub_items
  * 		transaction = transaction to perform database operations within. [Default is null]
  *
  * @return array List of numeric item_ids
  */
 public static function getItemIDsFromList($pm_list_name_or_id, $pa_idnos, $pa_options = null)
 {
     if (isset($pa_options['dontIncludeSubItems']) && (!isset($pa_options['dont_include_sub_items']) || !$pa_options['dont_include_sub_items'])) {
         $pa_options['dont_include_sub_items'] = $pa_options['dontIncludeSubItems'];
     }
     if (isset($pa_options['dont_include_sub_items']) && $pa_options['dont_include_sub_items']) {
         $pa_options['noChildren'] = true;
     }
     $t_list = new ca_lists();
     $t_item = new ca_list_items();
     if ($o_trans = caGetOption('transaction', $pa_options, null)) {
         $t_list->setTransaction($o_trans);
         $t_item->setTransaction($o_trans);
     }
     $va_tmp = $va_item_ids = array();
     foreach ($pa_idnos as $vs_idno) {
         $vn_item_id = null;
         if (is_numeric($vs_idno)) {
             $va_tmp = array((int) $vs_idno);
         } else {
             $va_tmp = ca_list_items::find(array('idno' => $vs_idno, 'deleted' => 0), array('returnAs' => 'ids', 'transaction' => $o_trans));
         }
         if (sizeof($va_tmp) && !(isset($pa_options['noChildren']) || $pa_options['noChildren'])) {
             foreach ($va_tmp as $vn_item_id) {
                 if ($qr_children = $t_item->getHierarchy($vn_item_id, array())) {
                     while ($qr_children->nextRow()) {
                         $va_item_ids[$qr_children->get('item_id')] = true;
                     }
                 }
             }
         } else {
             foreach ($va_tmp as $vn_item_id) {
                 $va_item_ids[$vn_item_id] = true;
             }
         }
     }
     return array_keys($va_item_ids);
 }
开发者ID:ffarago,项目名称:pawtucket2,代码行数:51,代码来源:ca_lists.php

示例4: getElementCount

 /**
  * Returns number of elements in system
  *
  * @param $pb_root_elements_only boolean If true, then only root elements are counted; default is false
  * @param $pm_table_name_or_num mixed Optional table name or number to filter list with. If specified then only elements that have a type restriction to the table are counted. If omitted (default) then all elements, regardless of type restrictions, are returned.
  * @param $pm_type_name_or_id mixed Optional type code or type_id to restrict elements to.  If specified then only elements that have a type restriction to the specified table and type are counted. 
  * @return int The number of elements
  */
 public static function getElementCount($pb_root_elements_only = false, $pm_table_name_or_num = null, $pm_type_name_or_id = null)
 {
     $o_dm = Datamodel::load();
     $vn_table_num = $o_dm->getTableNum($pm_table_name_or_num);
     $vo_db = new Db();
     $va_wheres = array();
     if ($pb_root_elements_only) {
         $va_wheres[] = 'cme.parent_id is NULL';
     }
     if ($vn_table_num) {
         $va_wheres[] = 'cmtr.table_num = ?';
         $va_where_params[] = (int) $vn_table_num;
         if ($pm_type_name_or_id) {
             $t_list_item = new ca_list_items();
             if (!is_numeric($pm_type_name_or_id)) {
                 $t_list_item->load(array('idno' => $pm_type_name_or_id));
             } else {
                 $t_list_item->load((int) $pm_type_name_or_id);
             }
             $va_type_ids = array();
             if ($vn_type_id = $t_list_item->getPrimaryKey()) {
                 $va_type_ids[$vn_type_id] = true;
                 if ($qr_children = $t_list_item->getHierarchy($vn_type_id, array())) {
                     while ($qr_children->nextRow()) {
                         $va_type_ids[$qr_children->get('item_id')] = true;
                     }
                 }
                 $va_wheres[] = '((cmtr.type_id = ?) OR (cmtr.include_subtypes = 1 AND cmtr.type_id IN (?)))';
                 $va_where_params[] = (int) $vn_type_id;
                 $va_where_params[] = $va_type_ids;
             }
         }
         $vs_wheres = ' WHERE ' . join(' AND ', $va_wheres);
         $qr_tmp = $vo_db->query("\n\t\t\t\tSELECT count(*) c\n\t\t\t\tFROM ca_metadata_elements cme\n\t\t\t\tINNER JOIN ca_metadata_type_restrictions AS cmtr ON cme.hier_element_id = cmtr.element_id\n\t\t\t\t{$vs_wheres}\n\t\t\t", $va_where_params);
     } else {
         if (sizeof($va_wheres)) {
             $vs_wheres = ' WHERE ' . join(' AND ', $va_wheres);
         } else {
             $vs_wheres = '';
         }
         $qr_tmp = $vo_db->query("\n\t\t\t\tSELECT count(*) c\n\t\t\t\tFROM ca_metadata_elements cme\n\t\t\t\t{$vs_wheres}\n\t\t\t");
     }
     if ($qr_tmp->nextRow()) {
         return $qr_tmp->get('c');
     }
     return 0;
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:55,代码来源:ca_metadata_elements.php

示例5: getItemIDsFromList

 /**
  * Converts the given list of list item idnos or item_ids into an expanded list of numeric item_ids. Processing
  * includes expansion of items to include sub-items and conversion of any idnos to item_ids.
  *
  * @param mixed $pm_table_name_or_num Table name or number to which types apply
  * @param array $pa_types List of item idnos and/or item_ids that are the basis of the list
  * @param array $pa_options Array of options:
  * 		dont_include_sub_items = if set, returned list is not expanded to include sub-items
  *		dontIncludeSubItems = synonym for dont_include_sub_items
  *
  * @return array List of numeric item_ids
  */
 public static function getItemIDsFromList($pm_list_name_or_id, $pa_idnos, $pa_options = null)
 {
     if (isset($pa_options['dontIncludeSubItems']) && (!isset($pa_options['dont_include_sub_items']) || !$pa_options['dont_include_sub_items'])) {
         $pa_options['dont_include_sub_items'] = $pa_options['dontIncludeSubItems'];
     }
     if (isset($pa_options['dont_include_sub_items']) && $pa_options['dont_include_sub_items']) {
         $pa_options['noChildren'] = true;
     }
     $t_list = new ca_lists();
     $t_item = new ca_list_items();
     $va_item_ids = array();
     foreach ($pa_idnos as $vs_idno) {
         $vn_item_id = null;
         if (is_numeric($vs_idno)) {
             $vn_item_id = (int) $vs_idno;
         } else {
             $vn_item_id = (int) $t_list->getItemIDFromList($pm_list_name_or_id, $vs_idno);
         }
         if ($vn_item_id && !(isset($pa_options['noChildren']) || $pa_options['noChildren'])) {
             if ($qr_children = $t_item->getHierarchy($vn_item_id, array())) {
                 while ($qr_children->nextRow()) {
                     $va_item_ids[$qr_children->get('item_id')] = true;
                 }
             }
         } else {
             if ($vn_item_id) {
                 $va_item_ids[$vn_item_id] = true;
             }
         }
     }
     return array_keys($va_item_ids);
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:44,代码来源:ca_lists.php

示例6: execute


//.........这里部分代码省略.........
                         # -----------------------------------------------------
                     # -----------------------------------------------------
                     case 'attribute':
                         $t_element = new ca_metadata_elements();
                         if (!$t_element->load(array('element_code' => $va_facet_info['element_code']))) {
                             return array();
                         }
                         $vn_datatype = $t_element->get('datatype');
                         if ($va_facet_info['relative_to']) {
                             if ($va_relative_execute_sql_data = $this->_getRelativeExecuteSQLData($va_facet_info['relative_to'], $pa_options)) {
                                 $va_relative_to_join = $va_relative_execute_sql_data['relative_joins'];
                                 $vs_relative_to_join = join("\n", $va_relative_to_join);
                                 $vs_target_browse_table_name = $va_relative_execute_sql_data['target_table_name'];
                                 $vs_target_browse_table_num = $va_relative_execute_sql_data['target_table_num'];
                                 $vs_target_browse_table_pk = $va_relative_execute_sql_data['target_table_pk'];
                             }
                         }
                         // TODO: check that it is a *single-value* (ie. no hierarchical ca_metadata_elements) Text or Number attribute
                         // (do we support other types as well?)
                         $vn_element_id = $t_element->getPrimaryKey();
                         $o_attr = Attribute::getValueInstance($t_element->get('datatype'));
                         foreach ($va_row_ids as $vn_row_id) {
                             $vn_row_id = urldecode($vn_row_id);
                             $vn_row_id = str_replace('/', '/', $vn_row_id);
                             $va_value = $o_attr->parseValue($vn_row_id, $t_element->getFieldValuesArray());
                             $va_attr_sql = array();
                             $va_attr_values = array(intval($vs_target_browse_table_num), $vn_element_id);
                             if (is_array($va_value)) {
                                 foreach ($va_value as $vs_f => $vs_v) {
                                     if ($vn_datatype == 3) {
                                         // list
                                         $t_list_item = new ca_list_items((int) $vs_v);
                                         // Include sub-items
                                         $va_item_ids = $t_list_item->getHierarchy((int) $vs_v, array('idsOnly' => true, 'includeSelf' => true));
                                         $va_item_ids[] = (int) $vs_v;
                                         $va_attr_sql[] = "(ca_attribute_values.{$vs_f} IN (?))";
                                         $va_attr_values[] = $va_item_ids;
                                     } else {
                                         $va_attr_sql[] = "(ca_attribute_values.{$vs_f} " . (is_null($vs_v) ? " IS " : " = ") . " ?)";
                                         $va_attr_values[] = $vs_v;
                                     }
                                 }
                             }
                             if ($vs_attr_sql = join(" AND ", $va_attr_sql)) {
                                 $vs_attr_sql = " AND " . $vs_attr_sql;
                             }
                             if ($vn_i == 0) {
                                 $vs_sql = "\n\t\t\t\t\t\t\t\t\t\t\t\tINSERT IGNORE INTO ca_browses_acc\n\t\t\t\t\t\t\t\t\t\t\t\tSELECT " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . "\n\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->ops_browse_table_name . "\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_relative_to_join}\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes ON ca_attributes.row_id = {$vs_target_browse_table_name}.{$vs_target_browse_table_pk} AND ca_attributes.table_num = ?\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values ON ca_attribute_values.attribute_id = ca_attributes.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t(ca_attribute_values.element_id = ?) {$vs_attr_sql}";
                                 //caDebug($vs_sql);
                                 //caDebug(intval($vs_target_browse_table_num)."/".$vn_element_id."/".$vn_row_id);
                                 //caDebug($va_attr_values);
                                 $qr_res = $this->opo_db->query($vs_sql, $va_attr_values);
                             } else {
                                 $qr_res = $this->opo_db->query("TRUNCATE TABLE ca_browses_tmp");
                                 $vs_sql = "\n\t\t\t\t\t\t\t\t\t\t\t\tINSERT IGNORE INTO ca_browses_tmp\n\t\t\t\t\t\t\t\t\t\t\t\tSELECT " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . "\n\t\t\t\t\t\t\t\t\t\t\t\tFROM " . $this->ops_browse_table_name . "\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_relative_to_join}\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attributes ON ca_attributes.row_id = {$vs_target_browse_table_name}.{$vs_target_browse_table_pk} AND ca_attributes.table_num = ?\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_attribute_values ON ca_attribute_values.attribute_id = ca_attributes.attribute_id\n\t\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_browses_acc ON ca_browses_acc.row_id = " . $this->ops_browse_table_name . '.' . $t_item->primaryKey() . "\n\t\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t\t(ca_attribute_values.element_id = ?) {$vs_attr_sql}";
                                 //print "$vs_sql [".intval($vs_target_browse_table_num)."/".$vn_element_id."/".$vn_row_id."]<hr>";print_R($va_attr_values);
                                 $qr_res = $this->opo_db->query($vs_sql, $va_attr_values);
                                 $qr_res = $this->opo_db->query("TRUNCATE TABLE ca_browses_acc");
                                 $qr_res = $this->opo_db->query("INSERT IGNORE INTO ca_browses_acc SELECT row_id FROM ca_browses_tmp");
                             }
                             $vn_i++;
                         }
                         break;
                         # -----------------------------------------------------
                     # -----------------------------------------------------
                     case 'normalizedDates':
开发者ID:guaykuru,项目名称:pawtucket,代码行数:67,代码来源:BrowseEngine.php


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