本文整理汇总了PHP中ca_lists::getItemFromListByItemValue方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_lists::getItemFromListByItemValue方法的具体用法?PHP ca_lists::getItemFromListByItemValue怎么用?PHP ca_lists::getItemFromListByItemValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_lists
的用法示例。
在下文中一共展示了ca_lists::getItemFromListByItemValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: caGetListItemIDForValue
/**
* Fetch item_id for item with specified value. Value must match exactly.
*
* @param string $ps_list_code List code
* @param string $ps_value The item value to search for
* @param array $pa_options Options include:
* transaction = transaction to execute queries within. [Default=null]
* @return int item_id of list item or null if no matching item was found
*/
function caGetListItemIDForValue($ps_list_code, $ps_value, $pa_options = null)
{
$vs_cache_key = md5($ps_list_code . $ps_value . serialize($pa_options));
if (MemoryCache::contains($vs_cache_key, 'ListItemIDsForValues')) {
return MemoryCache::fetch($vs_cache_key, 'ListItemIDsForValues');
}
$t_list = new ca_lists();
if ($o_trans = caGetOption('transaction', $pa_options, null)) {
$t_list->setTransaction($o_trans);
}
if ($va_item = $t_list->getItemFromListByItemValue($ps_list_code, $ps_value)) {
$vs_ret = array_shift(array_keys($va_item));
MemoryCache::save($vs_cache_key, $vs_ret, 'ListItemIDsForValues');
return $vs_ret;
}
return null;
}
示例2: 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
//.........这里部分代码省略.........
示例3: caGetListItemIDForValue
function caGetListItemIDForValue($ps_list_code, $ps_value, $pa_options = null)
{
global $g_list_item_id_for_value_cache;
if (isset($g_list_item_id_for_value_cache[$ps_list_code . '/' . $ps_value])) {
return $g_list_item_id_for_value_cache[$ps_list_code . '/' . $ps_value];
}
$t_list = new ca_lists();
if ($o_trans = caGetOption('transaction', $pa_options, null)) {
$t_list->setTransaction($o_trans);
}
if ($g_list_item_id_for_value_cache[$ps_list_code . '/' . $ps_value] = $t_list->getItemFromListByItemValue($ps_list_code, $ps_value)) {
$va_tmp = array_keys($g_list_item_id_for_value_cache[$ps_list_code . '/' . $ps_value]);
return array_shift($va_tmp);
}
return null;
}