本文整理汇总了PHP中ca_list_items::getLabels方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_list_items::getLabels方法的具体用法?PHP ca_list_items::getLabels怎么用?PHP ca_list_items::getLabels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_list_items
的用法示例。
在下文中一共展示了ca_list_items::getLabels方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAllItemInfo
/**
* Try to return a generic summary for the specified record
*/
protected function getAllItemInfo()
{
if (!($t_instance = $this->_getTableInstance($this->ops_table, $this->opn_id))) {
// note that $this->opn_id might be a string if we're fetching by idno; you can only use an idno for getting an item, not for editing or deleting
return false;
}
$t_list = new ca_lists();
$t_locales = new ca_locales();
$va_locales = $t_locales->getLocaleList(array("available_for_cataloguing_only" => true));
$va_return = array();
// allow user-defined template to be passed; allows flexible formatting of returned "display" value
if (!($vs_template = $this->opo_request->getParameter('template', pString))) {
$vs_template = '';
}
if ($vs_template) {
$va_return['display'] = caProcessTemplateForIDs($vs_template, $this->ops_table, array($this->opn_id));
}
// labels
$va_labels = $t_instance->get($this->ops_table . ".preferred_labels", array("returnAllLocales" => true));
$va_labels = end($va_labels);
if (is_array($va_labels)) {
foreach ($va_labels as $vn_locale_id => $va_labels_by_locale) {
foreach ($va_labels_by_locale as $va_tmp) {
$va_return["preferred_labels"][$va_locales[$vn_locale_id]["code"]][] = $va_tmp[$t_instance->getLabelDisplayField()];
}
}
}
$va_labels = $t_instance->get($this->ops_table . ".nonpreferred_labels", array("returnAllLocales" => true));
$va_labels = end($va_labels);
if (is_array($va_labels)) {
foreach ($va_labels as $vn_locale_id => $va_labels_by_locale) {
foreach ($va_labels_by_locale as $va_tmp) {
$va_return["nonpreferred_labels"][$va_locales[$vn_locale_id]["code"]][] = $va_tmp[$t_instance->getLabelDisplayField()];
}
}
}
// "intrinsic" fields
foreach ($t_instance->getFieldsArray() as $vs_field_name => $va_field_info) {
$vs_list = null;
if (!is_null($vs_val = $t_instance->get($vs_field_name))) {
$va_return[$vs_field_name] = array("value" => $vs_val);
if (isset($va_field_info["LIST"])) {
// fields like "access" and "status"
$va_tmp = end($t_list->getItemFromListByItemValue($va_field_info["LIST"], $vs_val));
foreach ($va_locales as $vn_locale_id => $va_locale) {
$va_return[$vs_field_name]["display_text"][$va_locale["code"]] = $va_tmp[$vn_locale_id]["name_singular"];
}
}
if (isset($va_field_info["LIST_CODE"])) {
// typical example: type_id
$va_item = $t_list->getItemFromListByItemID($va_field_info["LIST_CODE"], $vs_val);
$t_item = new ca_list_items($va_item["item_id"]);
$va_labels = $t_item->getLabels(null, __CA_LABEL_TYPE_PREFERRED__);
foreach ($va_locales as $vn_locale_id => $va_locale) {
if ($vs_label = $va_labels[$va_item["item_id"]][$vn_locale_id][0]["name_singular"]) {
$va_return[$vs_field_name]["display_text"][$va_locale["code"]] = $vs_label;
}
}
}
}
}
// representations for representable stuff
if ($t_instance instanceof RepresentableBaseModel) {
$va_reps = $t_instance->getRepresentations(array('preview170', 'original'));
if (is_array($va_reps) && sizeof($va_reps) > 0) {
$va_return['representations'] = $va_reps;
}
}
// captions for representations
if ($this->ops_table == "ca_object_representations") {
$va_captions = $t_instance->getCaptionFileList();
if (is_array($va_captions) && sizeof($va_captions) > 0) {
$va_return['captions'] = $va_captions;
}
}
// attributes
$va_codes = $t_instance->getApplicableElementCodes();
foreach ($va_codes as $vs_code) {
if ($va_vals = $t_instance->get($this->ops_table . "." . $vs_code, array("convertCodesToDisplayText" => true, "returnAllLocales" => true))) {
$va_vals_by_locale = end($va_vals);
// I seriously have no idea what that additional level of nesting in the return format is for
$va_attribute_values = array();
foreach ($va_vals_by_locale as $vn_locale_id => $va_locale_vals) {
foreach ($va_locale_vals as $vs_val_id => $va_actual_data) {
$vs_locale_code = isset($va_locales[$vn_locale_id]["code"]) ? $va_locales[$vn_locale_id]["code"] : "none";
$va_attribute_values[$vs_val_id][$vs_locale_code] = $va_actual_data;
}
$va_return[$this->ops_table . "." . $vs_code] = array_values($va_attribute_values);
}
}
}
// relationships
// yes, not all combinations between these tables have
// relationships but it also doesn't hurt to query
foreach ($this->opa_valid_tables as $vs_rel_table) {
//
// set-related hacks
//.........这里部分代码省略.........