本文整理汇总了PHP中ca_list_items::getHierarchyAncestors方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_list_items::getHierarchyAncestors方法的具体用法?PHP ca_list_items::getHierarchyAncestors怎么用?PHP ca_list_items::getHierarchyAncestors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_list_items
的用法示例。
在下文中一共展示了ca_list_items::getHierarchyAncestors方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFacetHierarchyAncestorList
/**
* Given a item_id (request parameter 'id') returns a list of ancestors for use in the hierarchy browser
* Returned data is JSON format
*/
public function getFacetHierarchyAncestorList()
{
$pn_id = $this->request->getParameter('id', pInteger);
$ps_facet_name = $this->request->getParameter('facet', pString);
if (!is_array($va_facet_info = $this->opo_browse->getInfoForFacet($ps_facet_name))) {
return null;
}
$va_ancestors = array();
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
if (!$pn_id) {
$t_list = new ca_lists();
$pn_id = $t_list->getRootListItemID($t_element->get('list_id'));
}
$t_item = new ca_list_items($pn_id);
if ($t_item->getPrimaryKey()) {
$va_ancestors = array_reverse($t_item->getHierarchyAncestors(null, array('includeSelf' => true, 'idsOnly' => true)));
array_shift($va_ancestors);
}
}
}
break;
case 'label':
// label facet
$va_facet_info['table'] = $this->ops_tablename;
// fall through to default case
// fall through to default case
default:
$t_item = $this->opo_datamodel->getInstanceByTableName($va_facet_info['table']);
$t_item->load($pn_id);
if (method_exists($t_item, "getHierarchyList")) {
$va_access_values = caGetUserAccessValues($this->request);
$va_facet = $this->opo_browse->getFacet($ps_facet_name, array('sort' => 'name', 'checkAccess' => $va_access_values));
$va_hierarchy_list = $t_item->getHierarchyList(true);
$vn_hierarchies_in_use = 0;
foreach ($va_hierarchy_list as $vn_i => $va_item) {
if (isset($va_facet[$va_item[$t_item->primaryKey()]])) {
$vn_hierarchies_in_use++;
if ($vn_hierarchies_in_use > 1) {
break;
}
}
}
}
if ($t_item->getPrimaryKey()) {
$va_ancestors = array_reverse($t_item->getHierarchyAncestors(null, array('includeSelf' => true, 'idsOnly' => true)));
if (!is_array($va_ancestors)) {
$va_ancestors = array();
}
}
if ($vn_hierarchies_in_use <= 1) {
array_shift($va_ancestors);
}
break;
}
$this->view->setVar('ancestors', $va_ancestors);
return $this->render('Browse/facet_hierarchy_ancestors_json.php');
}
示例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);
$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));
//.........这里部分代码省略.........
示例3: getTypesForItems
/**
* Returns list of types present for items in set
*
* @param array $pa_options
* user_id = Restricts access to sets accessible by the current user. If omitted then all sets, regardless of access are returned.
* checkAccess = Restricts returned sets to those with an public access level with the specified values. If omitted sets are returned regardless of public access (ca_sets.access) value. Can be a single value or array if you wish to filter on multiple public access values.
* includeParents = Include parent types in the returned type list. [Default is false]
* @return array List of types. Keys are integer type_ids, values are plural type names for the current locale
*/
public function getTypesForItems($pa_options = null)
{
if (!($vn_set_id = $this->getPrimaryKey())) {
return null;
}
if (!is_array($pa_options)) {
$pa_options = array();
}
if ($pa_options['user_id'] && !$this->haveAccessToSet($pa_options['user_id'], __CA_SET_READ_ACCESS__)) {
return false;
}
$o_db = $this->getDb();
$o_dm = $this->getAppDatamodel();
if (!($t_rel_table = $o_dm->getInstanceByTableNum($this->get('table_num'), true))) {
return null;
}
if (!($vs_type_id_fld = $t_rel_table->getTypeFieldName())) {
return array();
}
// get set items
$vs_access_sql = '';
if (isset($pa_options['checkAccess']) && is_array($pa_options['checkAccess']) && sizeof($pa_options['checkAccess']) && $t_rel_table->hasField('access')) {
$vs_access_sql = ' AND rel.access IN (' . join(',', $pa_options['checkAccess']) . ')';
}
$vs_deleted_sql = '';
if ($t_rel_table->hasField('deleted')) {
$vs_deleted_sql = ' AND rel.deleted = 0';
}
$va_type_list = method_exists($t_rel_table, "getTypeList") ? $t_rel_table->getTypeList() : array();
$qr_res = $o_db->query("\n\t\t\tSELECT distinct rel.{$vs_type_id_fld}\n\t\t\tFROM ca_set_items casi\n\t\t\tINNER JOIN " . $t_rel_table->tableName() . " AS rel ON rel." . $t_rel_table->primaryKey() . " = casi.row_id\n\t\t\tWHERE\n\t\t\t\tcasi.set_id = ? {$vs_access_sql} {$vs_deleted_sql}\n\t\t", array($vn_set_id));
$va_type_ids = array();
while ($qr_res->nextRow()) {
$va_type_ids[$vn_type_id = $qr_res->get($vs_type_id_fld)] = $va_type_list[$vn_type_id]['name_plural'];
}
if (caGetOption('includeParents', $pa_options, false)) {
$t_item = new ca_list_items();
$va_expanded_types = $va_type_ids;
$va_labels = $t_item->getPreferredDisplayLabelsForIDs($va_type_ids);
foreach ($va_type_ids as $vn_type_id => $vs_type) {
if (is_array($va_parents = $t_item->getHierarchyAncestors($vn_type_id, array('idsOnly' => true)))) {
foreach ($va_parents as $vn_parent_id) {
$va_expanded_types[$vn_parent_id] = $va_labels[$vn_parent_id];
}
}
}
$va_type_ids = $va_expanded_types;
}
return $va_type_ids;
}
示例4: caReturnDefaultIfBlank
print "<div class='unit'><b>" . _t('Era') . ": </b>" . caReturnDefaultIfBlank($vs_era) . "</div>";
print "<div class='unit'><b>" . _t('Period') . ": </b>" . caReturnDefaultIfBlank(str_replace(", -", "", $vs_period)) . "</div>";
print "<div class='unit'><b>" . _t('Epoch') . ": </b>" . caReturnDefaultIfBlank($vs_epoch) . "</div>";
print "<div class='unit'><b>" . _t('Age') . ": </b>" . caReturnDefaultIfBlank($vs_ageNALMA) . "</div>";
print "<div class='unit'><b>" . _t('Zone') . ": </b>" . caReturnDefaultIfBlank($vs_unit) . "</div>";
print "<div class='unit'><b>" . _t('Group') . ": </b>" . caReturnDefaultIfBlank($vs_group) . "</div>";
print "<div class='unit'><b>" . _t('Formation') . ": </b>" . caReturnDefaultIfBlank($vs_formation) . "</div>";
print "<div class='unit'><b>" . _t('Member') . ": </b>" . caReturnDefaultIfBlank($vs_member) . "</div>";
} elseif (in_array($t_object->get('ca_objects.type_id'), $va_track_type_ids)) {
# --- Tracks, Tracings
if ($vs_other = $t_object->get("ca_objects.other_catalog_number")) {
print "<div class='unit'><b>" . _t('Other Catalog Number') . ":</b> {$vs_other}</div><!-- end unit -->";
}
if ($vn_taxonomy = $t_object->get('ca_objects.taxonomic_rank', array('idsOnly' => true))) {
$t_list_item = new ca_list_items();
$va_hierarchy = caExtractValuesByUserLocale($t_list_item->getHierarchyAncestors($vn_taxonomy, array("includeSelf" => true, "additionalTableToJoin" => "ca_list_item_labels", "additionalTableSelectFields" => array("name_singular"))));
$va_hierarchy = array_reverse($va_hierarchy);
foreach ($va_hierarchy as $va_hier_taxonomy) {
if ($va_hier_taxonomy["parent_id"]) {
print "<div class='unit'><b>" . $t_lists->getItemFromListForDisplayByItemID("list_item_types", $va_hier_taxonomy["type_id"]) . ": </b>" . $va_hier_taxonomy["name_singular"] . "</div>";
}
}
}
if ($va_ichnogenus = $t_object->get('ca_objects.ichnogenus', array('convertCodesToDisplayText' => true))) {
print "<div class='unit'><b>" . _t('Ichnogenus') . ":</b> " . $va_ichnogenus . "</div>";
}
if ($vs_ichnospecies = $t_object->get("ca_objects.ichnospecies")) {
print "<div class='unit'><b>" . _t('Ichnospecies') . ":</b> {$vs_ichnospecies}</div><!-- end unit -->";
}
if ($vs_clade = $t_object->get("ca_objects.clade", array('convertCodesToDisplayText' => true, 'delimiter' => ', '))) {
print "<div class='unit'><b>" . _t('Trackmaker clade') . ":</b> {$vs_clade}</div><!-- end unit -->";
示例5: getFacetHierarchyAncestorList
/**
* Given a item_id (request parameter 'id') returns a list of ancestors for use in the hierarchy browser
* Returned data is JSON format
*/
public function getFacetHierarchyAncestorList()
{
$pn_id = $this->request->getParameter('id', pInteger);
$va_access_values = caGetUserAccessValues($this->request);
$ps_facet_name = $this->request->getParameter('facet', pString);
$this->view->setVar("facet_name", $ps_facet_name);
$this->view->setVar("key", $this->request->getParameter('key', pString));
$ps_browse_type = $this->request->getParameter('browseType', pString);
if (!($va_browse_info = caGetInfoForBrowseType($ps_browse_type))) {
// invalid browse type – throw error
die("Invalid browse type");
}
$this->view->setVar("browse_type", $ps_browse_type);
$vs_class = $va_browse_info['table'];
$o_browse = caGetBrowseInstance($vs_class);
if (!is_array($va_facet_info = $o_browse->getInfoForFacet($ps_facet_name))) {
return null;
}
if ($ps_cache_key = $this->request->getParameter('key', pString)) {
$o_browse->reload($ps_cache_key);
}
$va_ancestors = array();
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
if (!$pn_id) {
$t_list = new ca_lists();
$pn_id = $t_list->getRootListItemID($t_element->get('list_id'));
}
$t_item = new ca_list_items($pn_id);
if ($t_item->getPrimaryKey()) {
$vs_primary_key = $t_item->primaryKey();
$this->view->setVar("primary_key", $vs_primary_key);
$vs_display_fld = $t_item->getLabelDisplayField();
$this->view->setVar("display_field", $vs_display_fld);
$vs_label_table_name = $t_item->getLabelTableName();
$va_ancestors = array_reverse($t_item->getHierarchyAncestors(null, array('includeSelf' => true, 'additionalTableToJoin' => $vs_label_table_name, 'additionalTableJoinType' => 'LEFT', 'additionalTableSelectFields' => array($vs_display_fld, 'locale_id'), 'additionalTableWheres' => array('(' . $vs_label_table_name . '.is_preferred = 1 OR ' . $vs_label_table_name . '.is_preferred IS NULL)'))));
array_shift($va_ancestors);
}
}
}
break;
case 'label':
// label facet
$va_facet_info['table'] = $this->ops_tablename;
// fall through to default case
// fall through to default case
default:
$t_item = $this->request->datamodel->getInstanceByTableName($va_facet_info['table']);
$t_item->load($pn_id);
if (method_exists($t_item, "getHierarchyList")) {
$va_access_values = caGetUserAccessValues($this->request);
$va_facet = $o_browse->getFacet($ps_facet_name, array('sort' => 'name', 'checkAccess' => $va_access_values));
$va_hierarchy_list = $t_item->getHierarchyList(true);
$vn_hierarchies_in_use = 0;
foreach ($va_hierarchy_list as $vn_i => $va_item) {
if (isset($va_facet[$va_item[$t_item->primaryKey()]])) {
$vn_hierarchies_in_use++;
if ($vn_hierarchies_in_use > 1) {
break;
}
}
}
}
if ($t_item->getPrimaryKey()) {
$vs_primary_key = $t_item->primaryKey();
$this->view->setVar("primary_key", $vs_primary_key);
$vs_display_fld = $t_item->getLabelDisplayField();
$this->view->setVar("display_field", $vs_display_fld);
$vs_label_table_name = $t_item->getLabelTableName();
$va_ancestors = array_reverse($t_item->getHierarchyAncestors(null, array('includeSelf' => true, 'additionalTableToJoin' => $vs_label_table_name, 'additionalTableJoinType' => 'LEFT', 'additionalTableSelectFields' => array($vs_display_fld, 'locale_id'), 'additionalTableWheres' => array('(' . $vs_label_table_name . '.is_preferred = 1 OR ' . $vs_label_table_name . '.is_preferred IS NULL)'))));
}
if ($vn_hierarchies_in_use <= 1) {
array_shift($va_ancestors);
}
break;
}
$this->view->setVar('ancestors', $va_ancestors);
switch ($this->request->getParameter('returnAs', pString)) {
case "json":
return $this->render('Browse/facet_hierarchy_ancestors_json.php');
break;
# ------------------------------------------------
# ------------------------------------------------
case "html":
default:
return $this->render('Browse/facet_hierarchy_ancestors_html.php');
break;
# ------------------------------------------------
}
}
示例6: array
print "<div class='unit'><b>" . _t("Lesson type") . "</b>: " . unicode_ucfirst($t_occurrence->getTypeName()) . "</div><!-- end unit -->";
}
# --- attributes in label: value format
$va_attributes = array("gradelevel", "lessonTopic", "learning_standard", "commonCore", "skills", "EdProject", "funder");
# --- which of these attributes can be edited when customizing?
$va_edit_attributes = array("lessonTopic", "learning_standard", "commonCore", "skills");
if (is_array($va_attributes) && sizeof($va_attributes) > 0) {
foreach ($va_attributes as $vs_attribute_code) {
if ($va_values = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertCodesToDisplayText" => false, "returnAsArray" => true))) {
$va_output_parts = array();
foreach ($va_values as $k => $va_value) {
if ($va_value[$vs_attribute_code]) {
# --- display hierarchy path for "lessonTopic", "learning_standard", "commonCore"
if (in_array($vs_attribute_code, array("lessonTopic", "learning_standard", "commonCore"))) {
$vs_tmp = "";
$va_hierarchy_ancestors = $t_list_items->getHierarchyAncestors($va_value[$vs_attribute_code], array("idsOnly" => true, "includeSelf" => true));
if (is_array($va_hierarchy_ancestors) && sizeof($va_hierarchy_ancestors)) {
# --- remove the root - we don't want to display it
$va_root = array_pop($va_hierarchy_ancestors);
if (is_array($va_hierarchy_ancestors) && sizeof($va_hierarchy_ancestors)) {
foreach ($va_hierarchy_ancestors as $vni => $vn_list_item_id) {
$vs_tmp = $t_lists->getItemForDisplayByItemID($vn_list_item_id) . ($vni > 0 ? " > " . $vs_tmp : "");
}
$va_output_parts[] = $vs_tmp;
}
}
} else {
$vs_value = "";
if ($vs_value = trim($va_value[$vs_attribute_code])) {
$va_output_parts[] = $t_lists->getItemForDisplayByItemID($vs_value);
}
示例7: getTypeRestrictionInstanceForElement
/**
* Load type restriction for specified table and type and return loaded model instance.
* Will return specific restriction for type_id, or a general (type_id=null) restriction if no
* type-specific restriction is defined.
*
* @param $pn_table_num - table_num of type restriction
* @param $pn_type_id - type_id of type restriction; leave null if you want a non-type-specific restriction
* @return ca_metadata_type_restrictions instance - will be loaded with type restriction
*/
public function getTypeRestrictionInstanceForElement($pn_table_num, $pn_type_id)
{
if (!($vn_element_id = $this->getPrimaryKey())) {
return null;
}
// element must be loaded
if ($this->get('parent_id')) {
return null;
}
// element must be root of hierarchy
$t_restriction = new ca_metadata_type_restrictions();
if ($pn_type_id > 0 && $t_restriction->load(array('table_num' => (int) $pn_table_num, 'type_id' => (int) $pn_type_id, 'element_id' => (int) $vn_element_id))) {
return $t_restriction;
} else {
if ($t_restriction->load(array('table_num' => (int) $pn_table_num, 'type_id' => null, 'element_id' => (int) $vn_element_id))) {
return $t_restriction;
}
// try going up the hierarchy to find one that we can inherit from
if ($pn_type_id && ($t_type_instance = new ca_list_items($pn_type_id))) {
$va_ancestors = $t_type_instance->getHierarchyAncestors(null, array('idsOnly' => true));
if (is_array($va_ancestors)) {
array_pop($va_ancestors);
// get rid of root
if (sizeof($va_ancestors)) {
$qr_res = $this->getDb()->query("\n\t\t\t\t\t\t\tSELECT restriction_id\n\t\t\t\t\t\t\tFROM ca_metadata_type_restrictions\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\ttype_id IN (?) AND table_num = ? AND include_subtypes = 1 AND element_id = ?\n\t\t\t\t\t\t", array($va_ancestors, (int) $pn_table_num, (int) $vn_element_id));
if ($qr_res->nextRow()) {
if ($t_restriction->load($qr_res->get('restriction_id'))) {
return $t_restriction;
}
}
}
}
}
}
return null;
}
示例8: getRelationshipTypesBySubtype
/**
* Returns an associative array of relationship types for the relationship
* organized by the sub_type_id specified by $ps_orientation. If $ps_orientation is the name of the "right" table
* then sub_type_left_id is used for keys in the array, if $ps_orientation is the name of the "left" table
* then sub_type_right_id is used for keys.
*
* For example, for ca_objects_x_entities, if $ps_orientation is ca_objects then then sub_type_right_id is
* used as the key; if ca_entities is passed then sub_type_left_id is used; if a table name is passed that
* is not either side of the relation then an empty array is returned
*
*/
public function getRelationshipTypesBySubtype($ps_orientation, $pn_type_id, $pa_options = null)
{
unset($pa_options['request']);
if (!$this->hasField('type_id')) {
return array();
}
$vs_left_table_name = $this->getLeftTableName();
$vs_right_table_name = $this->getRightTableName();
$vb_dont_include_subtypes_in_type_restriction = caGetOptions('dont_include_subtypes_in_type_restriction', $pa_options, false);
$o_db = $this->getDb();
$t_rel_type = new ca_relationship_types();
$vs_restrict_to_relationship_type_sql = '';
if (isset($pa_options['restrict_to_relationship_types']) && $pa_options['restrict_to_relationship_types']) {
if (!is_array($pa_options['restrict_to_relationship_types'])) {
$pa_options['restrict_to_relationship_types'] = array($pa_options['restrict_to_relationship_types']);
}
if (sizeof($pa_options['restrict_to_relationship_types'])) {
$va_restrict_to_type_list = array();
foreach ($pa_options['restrict_to_relationship_types'] as $vs_type_code) {
if (!strlen(trim($vs_type_code))) {
continue;
}
$va_criteria = array('table_num' => $this->tableNum());
if (is_numeric($vs_type_code)) {
$va_criteria['type_id'] = (int) $vs_type_code;
} else {
$va_criteria['type_code'] = $vs_type_code;
}
if ($t_rel_type->load($va_criteria)) {
$va_restrict_to_type_list[] = "(crt.hier_left >= " . $t_rel_type->get('hier_left') . " AND crt.hier_right <= " . $t_rel_type->get('hier_right') . ")";
}
}
if (sizeof($va_restrict_to_type_list)) {
$vs_restrict_to_relationship_type_sql = " AND (" . join(' OR ', $va_restrict_to_type_list) . ")";
}
}
}
$qr_res = $o_db->query("\n\t\t\t\tSELECT *\n\t\t\t\tFROM ca_relationship_types crt\n\t\t\t\tINNER JOIN ca_relationship_type_labels AS crtl ON crt.type_id = crtl.type_id\n\t\t\t\tWHERE\n\t\t\t\t\t(crt.table_num = ?)\n\t\t\t\t\t{$vs_restrict_to_relationship_type_sql}\n\t\t\t", $this->tableNum());
// Support hierarchical subtypes - if the subtype restriction is a type with parents then include those as well
// Allows subtypes to "inherit" bindings from parent types
$t_list_item = new ca_list_items($pn_type_id);
if (!$vb_dont_include_subtypes_in_type_restriction) {
if (!is_array($va_ancestor_ids = $t_list_item->getHierarchyAncestors(null, array('idsOnly' => true, 'includeSelf' => true)))) {
$va_ancestor_ids = array();
}
// remove hierarchy root from ancestor list, otherwise invalid bindings
// from root nodes (which are not "real" rel types) may be inherited
array_pop($va_ancestor_ids);
} else {
$va_ancestor_ids = array($pn_type_id);
}
$va_types = array();
$va_parent_ids = array();
$vn_l = 0;
$vn_root_id = $t_rel_type->load(array('parent_id' => null, 'table_num' => $this->tableNum())) ? $t_rel_type->getPrimaryKey() : null;
$va_hier = array();
if ($vs_left_table_name === $vs_right_table_name) {
// ----------------------------------------------------------------------------------------
// self relationship
while ($qr_res->nextRow()) {
$va_row = $qr_res->getRow();
$vn_parent_id = $va_row['parent_id'];
$va_hier[$vn_parent_id][] = $va_row['type_id'];
// skip type if it has a subtype set and it's not in our list
$vs_subtype_orientation = null;
$vs_subtype = null;
if ($va_row['sub_type_left_id'] && !in_array($va_row['sub_type_left_id'], $va_ancestor_ids)) {
// not left
if ($va_row['sub_type_right_id'] && !in_array($va_row['sub_type_right_id'], $va_ancestor_ids)) {
// not left and not right
continue;
} else {
// not left and right
$vs_subtype = $va_row['sub_type_left_id'];
$vs_subtype_orientation = "left";
}
} else {
if ($va_row['sub_type_left_id'] && in_array($va_row['sub_type_left_id'], $va_ancestor_ids)) {
// left
if ($va_row['sub_type_right_id'] && in_array($va_row['sub_type_right_id'], $va_ancestor_ids)) {
// left and right
$vs_subtype = $va_row['sub_type_right_id'];
$vs_subtype_orientation = "";
} else {
// left and not right
$vs_subtype_orientation = "right";
$vs_subtype = $va_row['sub_type_right_id'];
}
}
//.........这里部分代码省略.........
示例9: Full
public function Full()
{
$t_lists = new ca_lists();
$t_list_items = new ca_list_items();
$o_purifier = new HTMLPurifier();
$pn_occurrence_id = $this->request->getParameter('occurrence_id', pString);
$t_occurrence = new ca_occurrences($pn_occurrence_id);
$va_access_values = caGetUserAccessValues($this->request);
$va_occ_info[] = "<b>" . _t("Lesson type") . "</b>: " . $t_occurrence->getTypeName();
$va_occ_info2 = array();
foreach (array("gradelevel", "lessonTopic", "learning_standard", "commonCore", "skills", "EdProject", "funder") as $vs_attribute_code) {
if ($va_values = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertCodesToDisplayText" => false, "returnAsArray" => true))) {
$va_output_parts = array();
foreach ($va_values as $k => $va_value) {
if ($va_value[$vs_attribute_code]) {
# --- display hierarchy path for "lessonTopic", "learning_standard", "commonCore"
if (in_array($vs_attribute_code, array("lessonTopic", "learning_standard", "commonCore"))) {
$vs_tmp = "";
$va_hierarchy_ancestors = $t_list_items->getHierarchyAncestors($va_value[$vs_attribute_code], array("idsOnly" => true, "includeSelf" => true));
if (is_array($va_hierarchy_ancestors) && sizeof($va_hierarchy_ancestors)) {
# --- remove the root - we don't want to display it
$va_root = array_pop($va_hierarchy_ancestors);
if (is_array($va_hierarchy_ancestors) && sizeof($va_hierarchy_ancestors)) {
foreach ($va_hierarchy_ancestors as $vni => $vn_list_item_id) {
$vs_tmp = $t_lists->getItemForDisplayByItemID($vn_list_item_id) . ($vni > 0 ? " > " . $vs_tmp : "");
}
$va_output_parts[] = $vs_tmp;
}
}
} else {
$vs_value = "";
if ($vs_value = trim($va_value[$vs_attribute_code])) {
$va_output_parts[] = $t_lists->getItemForDisplayByItemID($vs_value);
}
}
}
}
if (sizeof($va_output_parts)) {
$va_occ_info[$vs_attribute_code] = "<b>" . $t_occurrence->getDisplayLabel("ca_occurrences.{$vs_attribute_code}") . "</b>: " . join(", ", $va_output_parts);
}
}
}
$va_occ_info["HR"] = "<HR>";
$va_attributes = array("theme", "guidelines", "sure", "directions", "context", "task", "glossary", "instructions", "essay", "essential", "check");
foreach ($va_attributes as $vs_attribute_code) {
if ($vs_value = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertLineBreaks" => true, "delimiter" => "<br/>"))) {
if ($vs_attribute_code == "glossary") {
$va_glossary_terms = array();
$va_values = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertLineBreaks" => true, "returnAsArray" => true));
foreach ($va_values as $va_value) {
$va_glossary_terms[] = $va_value["glossary"];
}
sort($va_glossary_terms);
$vs_value = implode("<br/>", $va_glossary_terms);
$va_occ_info[$vs_attribute_code] = "<div class='unit'><b>" . $t_occurrence->getDisplayLabel("ca_occurrences.{$vs_attribute_code}") . "</b><br/>" . $vs_value . "</div><!-- end unit -->";
} else {
$va_occ_info[$vs_attribute_code] = "<div class='unit'><b>" . $t_occurrence->getDisplayLabel("ca_occurrences.{$vs_attribute_code}") . "</b><br/>" . str_replace("*", "• ", $vs_value) . "</div><!-- end unit -->";
}
}
}
$va_attributes = array("questions", "challenge", "connections", "resources", "transcription", "translation", "essay");
foreach ($va_attributes as $vs_attribute_code) {
if ($vs_value = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertLineBreaks" => true, "delimiter" => "<br/>"))) {
if (in_array($vs_attribute_code, array("questions", "resources"))) {
$va_values = $t_occurrence->get("ca_occurrences.{$vs_attribute_code}", array("convertLineBreaks" => true, "delimiter" => "<br/>", "returnAsArray" => true));
$vs_tmp = "";
$vs_tmp .= "<div class='unit'><b>" . $t_occurrence->getDisplayLabel("ca_occurrences.{$vs_attribute_code}") . "</b><ol>";
foreach ($va_values as $va_value_info) {
$vs_tmp .= "<li>" . $va_value_info[$vs_attribute_code] . "</li>";
}
$vs_tmp .= "</ol></div><!-- end unit -->";
$va_occ_info2[$vs_attribute_code] = $vs_tmp;
} else {
$va_occ_info2[$vs_attribute_code] = "<div class='unit'><b>" . $t_occurrence->getDisplayLabel("ca_occurrences.{$vs_attribute_code}") . "</b><br/>" . str_replace("*", "• ", $vs_value) . "</div><!-- end unit -->";
}
}
}
# --- related objects
$va_related_objects_links = $t_occurrence->get("ca_objects_x_occurrences.relation_id", array("returnAsArray" => true));
$va_related_objects_info = array();
if (sizeof($va_related_objects_links)) {
$t_objects_x_occurrences = new ca_objects_x_occurrences();
foreach ($va_related_objects_links as $vn_relation_id) {
$va_object_info = array();
$t_objects_x_occurrences->load($vn_relation_id);
$va_reps = $t_objects_x_occurrences->get("ca_objects_x_occurrences.representation_list", array("returnAsArray" => true, 'idsOnly' => true));
$va_reps_info = array();
if (is_array($va_reps)) {
foreach ($va_reps as $vn_relation_id => $va_attr) {
$t_rep = new ca_object_representations($va_attr['representation_list']);
$va_media_info = $t_rep->getMediaInfo('media');
$vn_height = $va_media_info["large"]["HEIGHT"];
$vn_width = $va_media_info["large"]["WIDTH"];
if ($vn_height > 900) {
$vn_new_width = 900 * $vn_width / $vn_height;
$va_reps_info[] = "<img src='" . $t_rep->getMediaUrl('media', 'large') . "' style='height:900px; width:" . $vn_new_width . "px;'>";
} else {
$va_reps_info[] = $t_rep->getMediaTag('media', 'large');
}
}
//.........这里部分代码省略.........