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


PHP caProcessTemplateForIDs函数代码示例

本文整理汇总了PHP中caProcessTemplateForIDs函数的典型用法代码示例。如果您正苦于以下问题:PHP caProcessTemplateForIDs函数的具体用法?PHP caProcessTemplateForIDs怎么用?PHP caProcessTemplateForIDs使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: testInterstitialTemplateProcessing

 public function testInterstitialTemplateProcessing()
 {
     // should only be one
     $vn_relation_id = $this->opt_object_left->get('ca_objects_x_objects.relation_id');
     $this->assertTrue(is_numeric($vn_relation_id));
     $va_opts = array('resolveLinksUsing' => 'ca_objects', 'primaryIDs' => array('ca_objects' => array($this->opt_object_left->getPrimaryKey())));
     // we're reading from the left side, so the right side pop up
     $this->assertEquals('Test Dataset', caProcessTemplateForIDs('^ca_objects.preferred_labels', 'ca_objects_x_objects', array($vn_relation_id), $va_opts));
     $this->assertEquals('is related to', caProcessTemplateForIDs('^relationship_typename', 'ca_objects_x_objects', array($vn_relation_id), $va_opts));
     $this->assertEquals('is related to', caProcessTemplateForIDs('<unit relativeTo="ca_objects_x_objects">^relationship_typename</unit>', 'ca_objects', array($this->opt_object_left->getPrimaryKey()), $va_opts));
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:11,代码来源:ObjectsXObjectsTest.php

示例2: testInterstitialTemplateProcessing

 public function testInterstitialTemplateProcessing()
 {
     // should only be one
     $vn_relation_id = $this->opt_homer->get('ca_entities_x_entities.relation_id');
     $this->assertTrue(is_numeric($vn_relation_id));
     $va_opts = array('resolveLinksUsing' => 'ca_entities', 'primaryIDs' => array('ca_entities' => array($this->opt_bart->getPrimaryKey())));
     // we're reading from Bart, so Homer should pop up
     $this->assertEquals('Homer J. Simpson', caProcessTemplateForIDs('^ca_entities.preferred_labels', 'ca_entities_x_entities', array($vn_relation_id), $va_opts));
     // Try getting the rel type from the relationship record
     // We don't need $va_opts to do that, by the way!
     $this->assertEquals('is related to', caProcessTemplateForIDs('^relationship_typename', 'ca_entities_x_entities', array($vn_relation_id)));
     // Try getting the rel type from the Homer record
     // We don't need $va_opts to do that either
     $this->assertEquals('is related to', caProcessTemplateForIDs('<unit relativeTo="ca_entities_x_entities">^relationship_typename</unit>', 'ca_entities', array($this->opt_homer->getPrimaryKey())));
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:15,代码来源:EntitiesXEntitiesTest.php

示例3: testGets

 public function testGets()
 {
     $vm_ret = $this->opt_loan_in->get('ca_loans.related');
     $this->assertEquals('New Loan Out', $vm_ret);
     $va_items = $this->opt_loan_in->getRelatedItems('ca_loans');
     $vn_relation_id = array_shift(caExtractArrayValuesFromArrayOfArrays($va_items, 'relation_id'));
     // The relationship we created is Loan Out <-> Loan In, so evaluating with loan in as primary ID should give us the loan out
     $va_opts = array('resolveLinksUsing' => 'ca_loans', 'primaryIDs' => array('ca_loans' => array($this->opt_loan_in->getPrimaryKey())));
     $vm_ret = caProcessTemplateForIDs("^ca_loans.preferred_labels", 'ca_loans_x_loans', array($vn_relation_id), $va_opts);
     $this->assertEquals('New Loan Out', $vm_ret);
     // Now for the other side ...
     $va_opts = array('resolveLinksUsing' => 'ca_loans', 'primaryIDs' => array('ca_loans' => array($this->opt_loan_out->getPrimaryKey())));
     $vm_ret = caProcessTemplateForIDs("^ca_loans.preferred_labels", 'ca_loans_x_loans', array($vn_relation_id), $va_opts);
     $this->assertEquals('New Loan In', $vm_ret);
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:15,代码来源:LoansXLoansTest.php

示例4: getDisplayValue

 /**
  * 
  *
  * @param array Optional array of options. Support options are:
  *			template = 
  *			includeID = 
  *			idsOnly = 
  * @return string The value
  */
 public function getDisplayValue($pa_options = null)
 {
     $o_config = Configuration::load();
     if (is_array($va_lookup_template = $o_config->getList('ca_entities_lookup_settings'))) {
         $vs_default_template = join($o_config->get('ca_entities_lookup_delimiter'), $va_lookup_template);
     } else {
         $vs_default_template = "^ca_entities.preferred_labels.displayname";
     }
     $ps_template = (string) caGetOption('template', $pa_options, $vs_default_template);
     $vb_include_id = (bool) caGetOption('includeID', $pa_options, false);
     $vb_ids_only = (bool) caGetOption('idsOnly', $pa_options, false);
     if ($vb_ids_only) {
         return $this->opn_entity_id;
     }
     return caProcessTemplateForIDs($ps_template, 'ca_entities', array($this->opn_entity_id), array()) . ($vb_include_id ? " [" . $this->opn_entity_id . "]" : '');
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:25,代码来源:EntitiesAttributeValue.php

示例5: hierarchyWithTemplate

 /**
  * 
  * 
  * @param string $ps_template 
  * @param array $pa_options Any options supported by BaseModel::getHierarchyAsList() and caProcessTemplateForIDs() as well as:
  *		sort = An array or semicolon delimited list of elements to sort on. [Default is null]
  * 		sortDirection = Direction to sorting, either 'asc' (ascending) or 'desc' (descending). [Default is asc]
  * @return array
  */
 public function hierarchyWithTemplate($ps_template, $pa_options = null)
 {
     if (!$this->isHierarchical()) {
         return null;
     }
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     $vs_pk = $this->primaryKey();
     $pn_id = caGetOption($vs_pk, $pa_options, null);
     $va_hier = $this->getHierarchyAsList($pn_id, array_merge($pa_options, array('idsOnly' => false)));
     $va_levels = $va_ids = $va_parent_ids = array();
     if (!is_array($va_hier)) {
         return array();
     }
     foreach ($va_hier as $vn_i => $va_item) {
         $va_levels[$vn_i] = $va_item['LEVEL'];
         $va_ids[$vn_i] = $vn_id = $va_item['NODE'][$vs_pk];
         $va_parent_ids[$vn_id] = $va_item['NODE']['parent_id'];
     }
     $va_hierarchy_data = array();
     $va_vals = caProcessTemplateForIDs($ps_template, $this->tableName(), $va_ids, array_merge($pa_options, array('includeBlankValuesInArray' => true, 'returnAsArray' => true)));
     $pa_sort = caGetOption('sort', $pa_options, null);
     if (!is_array($pa_sort) && $pa_sort) {
         $pa_sort = explode(";", $pa_sort);
     }
     $ps_sort_direction = strtolower(caGetOption('sortDirection', $pa_options, 'asc'));
     if (!in_array($ps_sort_direction, array('asc', 'desc'))) {
         $ps_sort_direction = 'asc';
     }
     if (is_array($pa_sort) && sizeof($pa_sort) && sizeof($va_ids)) {
         $va_sort_keys = array();
         $qr_sort_res = caMakeSearchResult($this->tableName(), $va_ids);
         $vn_i = 0;
         while ($qr_sort_res->nextHit()) {
             $va_key = array();
             foreach ($pa_sort as $vs_sort) {
                 $va_key[] = $qr_sort_res->get($vs_sort);
             }
             $va_sort_keys[$vn_i] = join("_", $va_key) . "_{$vn_i}";
             $vn_i++;
         }
         foreach ($va_vals as $vn_i => $vs_val) {
             $va_hierarchy_data[$va_parent_ids[$va_ids[$vn_i]]][$va_sort_keys[$vn_i]] = array('level' => $va_levels[$vn_i], 'id' => $va_ids[$vn_i], 'parent_id' => $va_parent_ids[$va_ids[$vn_i]], 'display' => $vs_val);
         }
         $va_hierarchy_flattened = array();
         foreach ($va_hierarchy_data as $vn_parent_id => $va_level_content) {
             ksort($va_hierarchy_data[$vn_parent_id]);
         }
         return $this->_getFlattenedHierarchyArray($va_hierarchy_data, $va_parent_ids[$pn_id] ? $va_parent_ids[$pn_id] : null, $ps_sort_direction);
     } else {
         foreach ($va_vals as $vn_i => $vs_val) {
             $va_hierarchy_data[] = array('level' => $va_levels[$vn_i], 'id' => $va_ids[$vn_i], 'display' => $vs_val);
         }
     }
     return $va_hierarchy_data;
 }
开发者ID:samrahman,项目名称:providence,代码行数:66,代码来源:BaseModel.php

示例6: caProcessRelationshipLookupLabel


//.........这里部分代码省略.........
                        }
                    } else {
                        if ($vs_display_format) {
                            $vs_display_value = str_replace("^{$vs_bundle_name}", htmlspecialchars($vs_value), $vs_display_value);
                        } else {
                            $vs_display_value .= $vs_value . ' ';
                        }
                    }
                }
                if ($t_rel->isHierarchical()) {
                    if ($vn_parent_id = $qr_rel_items->get("{$vs_rel_table}.{$vs_hier_parent_id_fld}")) {
                        $va_parent_ids[$vn_id] = $vn_parent_id;
                    } else {
                        if ($pt_rel->getHierarchyType() != __CA_HIER_TYPE_ADHOC_MONO__) {
                            // don't show root for hierarchies unless it's adhoc (where the root is a valid record)
                            continue;
                        }
                    }
                    if ($vs_hier_fld) {
                        $va_hierarchy_ids[$vn_id] = $qr_rel_items->get("{$vs_rel_table}.{$vs_hier_fld}");
                    }
                }
                if ($vs_rel_table == 'ca_users') {
                    $va_item['fname'] = $qr_rel_items->get('ca_users.fname');
                    $va_item['lname'] = $qr_rel_items->get('ca_users.lname');
                    $va_item['email'] = $qr_rel_items->get('ca_users.email');
                }
                if ($vb_use_new_display_format) {
                    $va_related_item_info[$vn_id] = $va_display_value;
                } else {
                    $va_related_item_info[$vn_id] = $vs_display_value;
                }
                if ($vs_template) {
                    $va_item['_display'] = caProcessTemplateForIDs($vs_template, $vs_table, array($qr_rel_items->get("{$vs_table}.{$vs_pk}")), array('returnAsArray' => false, 'returnAsLink' => true, 'delimiter' => caGetOption('delimiter', $pa_options, $vs_display_delimiter), 'resolveLinksUsing' => $vs_rel_table, 'primaryIDs' => $va_primary_ids));
                }
                $va_item['_l'] = mb_strtolower($qr_rel_items->get("{$vs_table}.preferred_labels"));
                $va_items[$vn_id] = $va_item;
                $vn_c++;
                if ($pn_limit && $pn_limit <= $vn_c) {
                    break;
                }
            }
        }
    }
    $va_hierarchies = method_exists($t_rel, "getHierarchyList") ? $t_rel->getHierarchyList() : array();
    // Get root entries for hierarchies and remove from labels (we don't want to show the root labels – they are not meant for display)
    if (is_array($va_hierarchies)) {
        foreach ($va_hierarchies as $vn_root_id => $va_hier_info) {
            foreach ($va_parent_ids as $vn_item_id => $vn_parent_id) {
                if ($vn_parent_id == $va_hier_info[$vs_rel_pk]) {
                    unset($va_parent_ids[$vn_item_id]);
                }
            }
        }
    }
    if (method_exists($t_rel, "getPreferredDisplayLabelsForIDs")) {
        $va_parent_labels = $t_rel->getPreferredDisplayLabelsForIDs($va_parent_ids);
    } else {
        $va_parent_labels = array();
    }
    if (isset($pa_options['relatedItems']) && is_array($pa_options['relatedItems']) && sizeof($pa_options['relatedItems'])) {
        $va_tmp = array();
        foreach ($pa_options['relatedItems'] as $vn_relation_id => $va_relation) {
            $va_items[$va_relation[$vs_rel_pk]]['relation_id'] = $va_relation['relation_id'];
            $va_items[$va_relation[$vs_rel_pk]]['relationship_type_id'] = $va_items[$va_relation[$vs_rel_pk]]['type_id'] = $va_relation['direction'] ? $va_relation['direction'] . '_' . $va_relation['relationship_type_id'] : $va_relation['relationship_type_id'];
            $va_items[$va_relation[$vs_rel_pk]]['rel_type_id'] = $va_relation['relationship_type_id'];
开发者ID:ffarago,项目名称:pawtucket2,代码行数:67,代码来源:displayHelpers.php

示例7: get


//.........这里部分代码省略.........
                         require_once __CA_MODELS_DIR__ . '/ca_collections.php';
                         $t_collection = new ca_collections();
                         foreach ($va_collections as $vn_i => $va_collection) {
                             if ($va_collections_ancestor_list = $t_collection->getHierarchyAncestors($va_collection['collection_id'], array('idsOnly' => true, 'includeSelf' => true))) {
                                 $va_ancestor_list = array_merge($va_ancestor_list, $va_collections_ancestor_list);
                             }
                             break;
                             // for now only process first collection (no polyhierarchies)
                         }
                     }
                 }
                 // remove root and children if so desired
                 if (isset($pa_options['removeFirstItems']) && (int) $pa_options['removeFirstItems'] > 0) {
                     for ($vn_i = 0; $vn_i < (int) $pa_options['removeFirstItems']; $vn_i++) {
                         array_pop($va_ancestor_list);
                     }
                 }
                 if ($vs_display_field != $va_tmp[2]) {
                     if ($this->hasField($va_tmp[2])) {
                         $vs_display_field = $va_tmp[2];
                     }
                 }
                 $vb_check_access = is_array($pa_options['checkAccess']) && $this->hasField('access');
                 if ($vb_check_access) {
                     $va_access_values = $this->getFieldValuesForIDs($va_ancestor_list, array('access'));
                     $va_ancestor_list = array();
                     foreach ($va_access_values as $vn_ancestor_id => $vn_access_value) {
                         if (in_array($vn_access_value, $pa_options['checkAccess'])) {
                             $va_ancestor_list[] = $vn_ancestor_id;
                         }
                     }
                 }
                 if ($vs_template) {
                     $va_tmp = caProcessTemplateForIDs($vs_template, $this->tableName(), $va_ancestor_list, array('returnAsArray' => true));
                 } else {
                     $va_tmp = $this->getPreferredDisplayLabelsForIDs($va_ancestor_list, array('returnAsArray' => true, 'returnAllLocales' => $vb_return_all_locales));
                 }
                 if ($vn_top > 0) {
                     $va_tmp = array_slice($va_tmp, sizeof($va_tmp) - $vn_top, $vn_top, true);
                 } else {
                     if ($vn_bottom > 0) {
                         $va_tmp = array_slice($va_tmp, 0, $vn_bottom, true);
                     }
                 }
                 if ($vs_direction == 'ASC') {
                     $va_tmp = array_reverse($va_tmp, true);
                 }
                 if (caGetOption('returnAsLink', $pa_options, false)) {
                     $va_tmp = caCreateLinksFromText(array_values($va_tmp), $this->tableName(), array_keys($va_tmp));
                 }
                 if ($vb_return_as_array) {
                     return $va_tmp;
                 } else {
                     $vs_hier_delimiter = isset($pa_options['hierarchicalDelimiter']) ? $pa_options['hierarchicalDelimiter'] : $pa_options['delimiter'];
                     return join($vs_hier_delimiter, $va_tmp);
                 }
                 break;
         }
     }
     switch (sizeof($va_tmp)) {
         case 1:
             switch ($va_tmp[0]) {
                 # ---------------------------------------------
                 case 'preferred_labels':
                     if (!$vb_return_as_array) {
                         $va_labels = caExtractValuesByUserLocale($t_instance->getPreferredLabels(), null, $va_preferred_locales);
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:67,代码来源:LabelableBaseModelWithAttributes.php

示例8: getDisplayValue

 /**
  * 
  *
  * @param array Optional array of options. Support options are:
  *			template = 
  *			includeID = 
  *			idsOnly = 
  * @return string The value
  */
 public function getDisplayValue($pa_options = null)
 {
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     $o_config = Configuration::load();
     if (is_array($va_lookup_template = $o_config->getList($this->ops_table_name . '_lookup_settings'))) {
         $vs_default_template = join($o_config->get($this->ops_table_name . '_lookup_delimiter'), $va_lookup_template);
     } else {
         $vs_default_template = "^" . $this->ops_table_name . ".preferred_labels";
     }
     $ps_template = (string) caGetOption('template', $pa_options, $vs_default_template);
     $vb_include_id = (bool) caGetOption('includeID', $pa_options, false);
     $vb_ids_only = (bool) caGetOption('idsOnly', $pa_options, false);
     if ($vb_ids_only) {
         return $this->opn_id;
     }
     return $this->opn_id ? caProcessTemplateForIDs($ps_template, $this->ops_table_name, array($this->opn_id), array_merge($pa_options, array('returnAsArray' => false, 'returnAllLocales' => false))) . ($vb_include_id ? " [" . $this->opn_id . "]" : '') : "";
 }
开发者ID:ffarago,项目名称:pawtucket2,代码行数:28,代码来源:AuthorityAttributeValue.php

示例9: getHierarchyList

 /**
  * Return array containing information about all hierarchies, including their root_id's
  * For non-adhoc hierarchies such as places, this call returns the contents of the place_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 object, there is only ever one hierarchy to display - that of the current object.
  * So for adhoc hierarchies we just return a single entry corresponding to the root of the current object hierarchy
  */
 public function getHierarchyList($pb_dummy = false)
 {
     $vn_pk = $this->getPrimaryKey();
     $vs_template = $this->getAppConfig()->get('ca_objects_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.object_id, count(*) c\n\t\t\t\t\tFROM ca_objects o\n\t\t\t\t\tINNER JOIN ca_objects AS p ON p.parent_id = o.object_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.object_id\n\t\t\t\t", array($va_type_ids));
         } else {
             $qr_res = $o_db->query("\n\t\t\t\t\tSELECT o.object_id, count(*) c\n\t\t\t\t\tFROM ca_objects o\n\t\t\t\t\tINNER JOIN ca_objects AS p ON p.parent_id = o.object_id\n\t\t\t\t\tWHERE o.parent_id IS NULL\n\t\t\t\t\tGROUP BY o.object_id\n\t\t\t\t");
         }
         $va_hiers = array();
         $va_object_ids = $qr_res->getAllFieldValues('object_id');
         $qr_res->seek(0);
         $va_labels = $this->getPreferredDisplayLabelsForIDs($va_object_ids);
         while ($qr_res->nextRow()) {
             $va_hiers[$vn_object_id = $qr_res->get('object_id')] = array('object_id' => $vn_object_id, 'item_id' => $vn_object_id, 'name' => caProcessTemplateForIDs($vs_template, 'ca_objects', array($vn_object_id)), 'hierarchy_id' => $vn_object_id, 'children' => (int) $qr_res->get('c'));
         }
         return $va_hiers;
     } else {
         // return specific object 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_object = new ca_objects($va_ancestors[0]);
         } else {
             $t_object =& $this;
         }
         $va_children = $t_object->getHierarchyChildren(null, array('idsOnly' => true));
         $va_object_hierarchy_root = array($t_object->get($vs_hier_fld) => array('object_id' => $vn_pk, 'item_id' => $vn_pk, 'name' => $vs_name = caProcessTemplateForIDs($vs_template, 'ca_objects', array($vn_pk)), 'hierarchy_id' => $vn_hier_id, 'children' => sizeof($va_children)));
         return $va_object_hierarchy_root;
     }
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:48,代码来源:ca_objects.php

示例10: caEditorLink

					</td>
<?php 
    print "<td style='width:5%;'>" . caEditorLink($this->request, caNavIcon($this->request, __CA_NAV_BUTTON_EDIT__), '', 'ca_objects', $vn_object_id, array(), array()) . "</td>";
    ?>
					<td style="padding-left: 5px; padding-right: 5px;">
						<?php 
    print $va_relation_id_map[$vn_object_id]['relationship_typename'];
    ?>
					</td>
<?php 
    foreach ($va_display_list as $vn_placement_id => $va_info) {
        print "<td><span class=\"read-more\">";
        // if there's a template, evaluate template against relationship
        if ($vs_template = $va_info['settings']['format']) {
            $va_opts = array_merge($va_info, array('resolveLinksUsing' => $vs_primary_table, 'primaryIDs' => array($vs_primary_table => array($vn_primary_id))));
            print caProcessTemplateForIDs($vs_template, $vs_rel_table, array($vn_relation_id), $va_opts);
        } else {
            print $t_display->getDisplayValue($vo_result, $vn_placement_id, array_merge(array('request' => $this->request), is_array($va_info['settings']) ? $va_info['settings'] : array()));
        }
        print "</span></td>";
    }
    ?>
	
				</tr>
<?php 
    $i++;
    $vn_item_count++;
}
?>
			</tbody>
<?php 
开发者ID:samrahman,项目名称:providence,代码行数:31,代码来源:ca_objects_results_table_html.php

示例11: getLocationHistory

 /**
  *
  *
  * @param array $pa_options Array of options:
  *		template =
  */
 public function getLocationHistory($pa_options = null)
 {
     $pn_object = caGetOption('object_id', $pa_options, null);
     if (!($vn_object_id = $pn_object_id > 0 ? $pn_object_id : $this->getPrimaryKey())) {
         return null;
     }
     $ps_display_template = caGetOption('template', $pa_options, '^ca_objects_x_storage_locations.relation_id');
     $va_current_date = caDateToHistoricTimestamps(_t('now'));
     $vn_current_date = $va_current_date['start'];
     //
     // Directly query the date field for performance
     //
     $o_db = $this->getDb();
     $qr_res = $o_db->query("\n \t\t\tSELECT csl.relation_id, csl.location_id, csl.object_id, csl.sdatetime, csl.edatetime\n \t\t\tFROM ca_objects_x_storage_locations csl\n \t\t\tINNER JOIN ca_storage_locations AS sl ON sl.location_id = csl.location_id\n \t\t\tWHERE\n \t\t\t\t(csl.object_id = ?) AND \n \t\t\t\t(sl.deleted = 0)\n \t\t\tORDER BY\n \t\t\t\t csl.sdatetime DESC, csl.relation_id DESC\n \t\t", array($vn_object_id));
     $va_relation_ids = $qr_res->getAllFieldValues('relation_id');
     $va_displays = caProcessTemplateForIDs($ps_display_template, 'ca_objects_x_storage_locations', $va_relation_ids, array('returnAsArray' => true));
     $qr_res->seek(0);
     $va_items = array();
     $vb_have_seen_the_present = false;
     while ($qr_res->nextRow()) {
         $va_row = $qr_res->getRow();
         $vn_relation_id = $va_row['relation_id'];
         if ($va_row['sdatetime'] > $vn_current_date) {
             $vs_status = 'FUTURE';
         } else {
             $vs_status = $vb_have_seen_the_present ? 'PAST' : 'PRESENT';
             $vb_have_seen_the_present = true;
         }
         $va_items[$vn_relation_id] = array('object_id' => $va_row['object_id'], 'location_id' => $va_row['location_id'], 'display' => array_shift($va_displays), 'status' => $vs_status);
     }
     return $va_items;
 }
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:38,代码来源:ca_objects.php

示例12: getAttributesForDisplay

 /**
  * Returns text of attributes in the user's currently selected locale, or else falls back to
  * whatever locale is available
  *
  * Supported options
  *	delimiter = text to use between attribute values; default is a single space
  *	convertLineBreaks = if true will convert line breaks to HTML <br/> tags for display in a web browser; default is false
  *	dontUseElementTemplate = By default any display template set in the metadata element is used if the $ps_template parameter is blank or null. Set this option to prevent the metadata element template from being used in any event. [Default is false]
  */
 public function getAttributesForDisplay($pm_element_code_or_id, $ps_template = null, $pa_options = null)
 {
     if (!($vn_row_id = $this->getPrimaryKey())) {
         if (!($vn_row_id = $pa_options['row_id'])) {
             return null;
         }
     }
     if (!$pm_element_code_or_id || !($t_element = $this->_getElementInstance($pm_element_code_or_id))) {
         return null;
     }
     if (!is_array($pa_options)) {
         $pa_options = array();
     }
     if (!isset($pa_options['convertCodesToDisplayText'])) {
         $pa_options['convertCodesToDisplayText'] = true;
     }
     $va_tmp = $this->getAttributeDisplayValues($pm_element_code_or_id, $vn_row_id, array_merge($pa_options, array('returnAllLocales' => false)));
     if (!$ps_template && ($vs_template_tmp = $t_element->getSetting('displayTemplate', true)) && !caGetOption('dontUseElementTemplate', $pa_options, false)) {
         // grab template from metadata element if none is passed in $ps_template
         $ps_template = $vs_template_tmp;
     }
     $vs_delimiter = $t_element->getSetting('displayDelimiter', true);
     if (isset($pa_options['delimiter'])) {
         $vs_delimiter = $pa_options['delimiter'];
     }
     if ($ps_template) {
         unset($pa_options['template']);
         return caProcessTemplateForIDs($ps_template, $this->tableNum(), array($vn_row_id), array_merge($pa_options, array('requireLinkTags' => true, 'placeholderPrefix' => $t_element->get('element_code'))));
     } else {
         // no template
         $va_attribute_list = array();
         foreach ($va_tmp as $vn_id => $va_value_list) {
             foreach ($va_value_list as $va_value) {
                 foreach ($va_value as $vs_element_code => $vs_value) {
                     if (strlen($vs_value)) {
                         $va_attribute_list[] = $vs_value;
                     }
                 }
             }
         }
         //Allow getAttributesForDisplay to return an array value (for "special" returns such as coordinates or raw dates)
         // if the value returns only a single value and it's an array. This is useful for getting "specials" via SearchResult::get()
         if (sizeof($va_attribute_list) === 1 && is_array($va_attribute_list[0])) {
             return $va_attribute_list[0];
         }
         $vs_text = join($vs_delimiter, $va_attribute_list);
         if (isset($pa_options['convertLineBreaks']) && $pa_options['convertLineBreaks']) {
             $vs_text = caConvertLineBreaks($vs_text);
         }
         return $vs_text;
     }
 }
开发者ID:idiscussforum,项目名称:providence,代码行数:61,代码来源:BaseModelWithAttributes.php

示例13: render

 /**
  * Generate SIMILE timeline output in specified format
  *
  * @param array $pa_viz_settings Array of visualization settings taken from visualization.conf
  * @param string $ps_format Specifies format to generate output in. Currently only 'HTML' is supported.
  * @param array $pa_options Array of options to use when rendering output. Supported options are:
  *		width =
  *		height =
  *		request = current request; required for generation of editor links
  */
 public function render($pa_viz_settings, $ps_format = 'HTML', $pa_options = null)
 {
     if (!($vo_data = $this->getData())) {
         return null;
     }
     $this->opn_num_items_rendered = 0;
     $po_request = isset($pa_options['request']) && $pa_options['request'] ? $pa_options['request'] : null;
     list($vs_width, $vs_height) = $this->_parseDimensions(caGetOption('width', $pa_options, 500), caGetOption('height', $pa_options, 500));
     $o_dm = Datamodel::load();
     // generate events
     $va_events = array();
     $va_sources = $pa_viz_settings['sources'];
     $vs_table = $vo_data->tableName();
     $vs_pk = $o_dm->getTablePrimaryKeyName($vs_table);
     $vs_first_date = $vn_first_date = null;
     $vs_last_date = $vn_last_date = null;
     $va_dates = array();
     while ($vo_data->nextHit()) {
         foreach ($va_sources as $vs_source_code => $va_source_info) {
             $vs_start = trim($vo_data->get($va_source_info['data'], array('start_as_iso8601' => true, 'dateFormat' => 'iso8601')));
             $vs_end = trim($vo_data->get($va_source_info['data'], array('end_as_iso8601' => true, 'dateFormat' => 'iso8601')));
             $vn_start = $vo_data->get($va_source_info['data'], array('startHistoricTimestamp' => true));
             $vn_end = $vo_data->get($va_source_info['data'], array('endHistoricTimestamp' => true));
             if ($vn_start < 0 || $vn_end < 0) {
                 continue;
             }
             // TODO: negative numbers mean "BC" which apparently cannot be plotted
             if ($vn_end >= 2000000) {
                 $va_iso = caGetISODates(_t("today"));
                 $vs_end = $va_iso['end'];
                 $va_historic = caDateToHistoricTimestamps(_t("today"));
                 $vn_end = $va_historic['end'];
             }
             if (!$vs_start || !$vs_end) {
                 continue;
             }
             if ($vs_start == _t('undated') || $vs_end == _t('undated')) {
                 continue;
             }
             if (is_null($vn_first_date) || $vn_first_date > $vn_start) {
                 $vn_first_date = $vn_start;
                 $vs_first_date = $vs_start;
             }
             if (is_null($vn_last_date) || $vn_last_date < $vn_end) {
                 $vn_last_date = $vn_end;
                 $vs_last_date = $vs_end;
             }
             $va_dates[] = $vs_start;
             $va_events[] = array('id' => $vs_table . '_' . ($vn_id = $vo_data->get("{$vs_table}.{$vs_pk}")), 'start' => $vs_start, 'end' => $vs_end, 'isDuration' => (int) $vn_start != (int) $vn_end ? true : false, 'title' => caProcessTemplateForIDs(strip_tags($va_source_info['display']['title_template']), $vs_table, array($vn_id)), 'description' => caProcessTemplateForIDs($va_source_info['display']['description_template'], $vs_table, array($vn_id)), 'link' => $po_request ? caEditorUrl($po_request, $vo_data->tableName(), $vn_id) : null, 'image' => $va_source_info['display']['image'] ? $vo_data->getWithTemplate($va_source_info['display']['image'], array('returnURL' => true)) : null, 'icon' => $va_source_info['display']['icon'] ? $vo_data->getWithTemplate($va_source_info['display']['icon'], array('returnURL' => true)) : null);
         }
     }
     $this->opn_num_items_rendered = sizeof($va_events);
     // Find median date - timeline will open there (as good a place as any, no?)
     $vs_default_date = $va_dates[floor((sizeof($va_dates) - 1) / 2)];
     // Derive scale for timeline bands
     $vn_span = $vn_last_date - $vn_first_date;
     if ($vn_span > 1000) {
         // millennia
         $vs_detail_band_scale = " Timeline.DateTime.CENTURY";
         $vs_overview_band_scale = " Timeline.DateTime.MILLENNIUM";
     } elseif ($vn_span > 100) {
         // centuries
         $vs_detail_band_scale = " Timeline.DateTime.DECADE";
         $vs_overview_band_scale = " Timeline.DateTime.CENTURY";
     } elseif ($vn_span > 10) {
         // decades
         $vs_detail_band_scale = " Timeline.DateTime.YEAR";
         $vs_overview_band_scale = " Timeline.DateTime.DECADE";
     } elseif ($vn_span > 1) {
         // years
         $vs_detail_band_scale = " Timeline.DateTime.MONTH";
         $vs_overview_band_scale = " Timeline.DateTime.YEAR";
     } elseif ($vn_span > 0.1) {
         // months
         $vs_detail_band_scale = " Timeline.DateTime.DAY";
         $vs_overview_band_scale = " Timeline.DateTime.MONTH";
     } else {
         // days
         $vs_detail_band_scale = " Timeline.DateTime.HOUR";
         $vs_overview_band_scale = " Timeline.DateTime.DAY";
     }
     $va_highlight_spans = array();
     $vs_highlight_span = '';
     if (isset($pa_options['highlightSpans']) && is_array($pa_options['highlightSpans'])) {
         foreach ($pa_options['highlightSpans'] as $vs_span_name => $va_span_info) {
             $va_range = caGetISODates($va_span_info['range']);
             $vs_span_color = isset($va_span_info['color']) && $va_span_info['color'] ? $va_span_info['color'] : '#FFC080';
             $vs_start_label = isset($va_span_info['startLabel']) && $va_span_info['startLabel'] ? $va_span_info['startLabel'] : '';
             $vs_end_label = isset($va_span_info['endLabel']) && $va_span_info['endLabel'] ? $va_span_info['endLabel'] : '';
             $vs_span_css_class = isset($va_span_info['class']) && $va_span_info['class'] ? $va_span_info['class'] : 't-highlight1';
//.........这里部分代码省略.........
开发者ID:guaykuru,项目名称:pawtucket,代码行数:101,代码来源:SimileTimeline.php

示例14: getHierarchyList

 /**
  * Return array containing information about all hierarchies, including their root_id's
  * For non-adhoc hierarchies such as places, this call returns the contents of the place_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 entity, there is only ever one hierarchy to display - that of the current entity.
  * So for adhoc hierarchies we just return a single entry corresponding to the root of the current entity hierarchy
  */
 public function getHierarchyList($pb_dummy = false)
 {
     $vn_pk = $this->getPrimaryKey();
     if (!$vn_pk) {
         return null;
     }
     // have to load a row first
     $vs_template = $this->getAppConfig()->get('ca_entities_hierarchy_browser_display_settings');
     $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_entity = new ca_entities($va_ancestors[0]);
     } else {
         $t_entity =& $this;
     }
     $va_children = $t_entity->getHierarchyChildren(null, array('idsOnly' => true));
     $va_entity_hierarchy_root = array($t_entity->get($vs_hier_fld) => array('entity_id' => $vn_pk, 'name' => $vs_name = caProcessTemplateForIDs($vs_template, 'ca_entities', array($vn_pk)), 'hierarchy_id' => $vn_hier_id, 'children' => sizeof($va_children)));
     return $va_entity_hierarchy_root;
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:34,代码来源:ca_entities.php

示例15: GetHierarchyLevel

 /**
  * 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 GetHierarchyLevel()
 {
     $ps_bundle = (string) $this->request->getParameter('bundle', pString);
     $pa_ids = explode(";", $ps_ids = $this->request->getParameter('id', pString));
     if (!sizeof($pa_ids)) {
         $pa_ids = array(null);
     }
     $t_item = $this->opo_item_instance;
     $vs_template = $t_item->getAppConfig()->get('ca_list_items_hierarchy_browser_display_settings');
     $va_lists = array();
     if ($ps_lists = $this->request->getParameter('lists', pString)) {
         $va_lists = explode(";", $ps_lists);
     }
     if (($vn_max_items_per_page = $this->request->getParameter('max', pInteger)) < 1 || $vn_max_items_per_page > 1000) {
         $vn_max_items_per_page = 100;
     }
     $va_level_data = array();
     foreach ($pa_ids as $pn_id) {
         $va_tmp = explode(":", $pn_id);
         $vn_id = $va_tmp[0];
         $vn_start = (int) $va_tmp[1];
         if ($vn_start < 0) {
             $vn_start = 0;
         }
         if (!$vn_id && method_exists($t_item, "getHierarchyList")) {
             if (!($pn_list_id = $this->request->getParameter('list_id', pInteger))) {
                 // no id so by default return list of available hierarchies
                 $va_list_items = $t_item->getHierarchyList();
                 if (sizeof($va_lists)) {
                     // filter out lists that weren't specified
                     foreach ($va_list_items as $vn_list_id => $va_list) {
                         if (!in_array($vn_list_id, $va_lists) && !in_array($va_list['list_code'], $va_lists)) {
                             unset($va_list_items[$vn_list_id]);
                         }
                     }
                 } else {
                     if ($this->request->getParameter('voc', pInteger)) {
                         // Only show vocabularies
                         foreach ($va_list_items as $vn_list_id => $va_list) {
                             if (!$va_list['use_as_vocabulary']) {
                                 unset($va_list_items[$vn_list_id]);
                             }
                         }
                     }
                 }
             }
         } else {
             if ($t_item->load($vn_id)) {
                 // id is the id of the parent for the level we're going to return
                 $t_list = new ca_lists($vn_list_id = $t_item->get('list_id'));
                 $vs_label_table_name = $this->opo_item_instance->getLabelTableName();
                 $vs_label_display_field_name = $this->opo_item_instance->getLabelDisplayField();
                 $va_list_items = $t_list->getItemsForList($vn_list_id, array('returnHierarchyLevels' => false, 'item_id' => $vn_id, 'extractValuesByUserLocale' => true, 'sort' => $t_list->get('sort_type'), 'directChildrenOnly' => true, 'limit' => $vn_max_items_per_page, 'start' => $vn_start));
                 // output
                 $va_display_values = caProcessTemplateForIDs($vs_template, 'ca_list_items', array_keys($va_list_items), array('requireLinkTags' => true, 'returnAsArray' => true));
                 $vn_c = 0;
                 foreach ($va_list_items as $vn_item_id => $va_item) {
                     unset($va_item['description']);
                     unset($va_item['icon']);
                     if (!$va_item[$vs_label_display_field_name]) {
                         $va_item[$vs_label_display_field_name] = $va_item['idno'];
                     }
                     if (!$va_item[$vs_label_display_field_name]) {
                         $va_item[$vs_label_display_field_name] = '???';
                     }
                     $va_item['name'] = $va_display_values[$vn_c];
                     if (!$va_item['name']) {
                         $va_item['name'] = '??? ' . $vn_item_id;
                     }
                     $va_item['table'] = 'ca_list_items';
                     // Child count is only valid if has_children is not null
                     $va_item['children'] = 0;
                     $va_list_items[$vn_item_id] = $va_item;
                     $vn_c++;
                 }
                 if (sizeof($va_list_items)) {
                     $o_db = new Db();
                     $qr_res = $o_db->query("\n\t\t\t\t\t\t\t\tSELECT count(*) c, parent_id\n\t\t\t\t\t\t\t\tFROM ca_list_items\n\t\t\t\t\t\t\t\tWHERE \n\t\t\t\t\t\t\t\t\tparent_id IN (" . join(",", array_keys($va_list_items)) . ") AND deleted = 0\n\t\t\t\t\t\t\t\tGROUP BY parent_id\n\t\t\t\t\t\t\t");
                     while ($qr_res->nextRow()) {
                         $va_list_items[$qr_res->get('parent_id')]['children'] = $qr_res->get('c');
                     }
                 }
             }
         }
         $va_list_items['_sortOrder'] = array_keys($va_list_items);
         $va_list_items['_primaryKey'] = $t_item->primaryKey();
         // pass the name of the primary key so the hierbrowser knows where to look for item_id's
         $va_list_items['_itemCount'] = $t_list ? $t_list->numItemsInList() : ($qr_res ? $qr_res->numRows() : 0);
         $va_level_data[$pn_id] = $va_list_items;
     }
     if (!$this->request->getParameter('init', pInteger)) {
         // only set remember "last viewed" if the load is done interactively
         // if the GetHierarchyLevel() call is part of the initialization of the hierarchy browser
         // then all levels are loaded, sometimes out-of-order; if we record these initialization loads
         // as the 'last viewed' we can end up losing the true 'last viewed' value
         //
//.........这里部分代码省略.........
开发者ID:kai-iak,项目名称:providence,代码行数:101,代码来源:ListItemController.php


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