本文整理汇总了PHP中ca_lists::getItemFromListByItemID方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_lists::getItemFromListByItemID方法的具体用法?PHP ca_lists::getItemFromListByItemID怎么用?PHP ca_lists::getItemFromListByItemID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ca_lists
的用法示例。
在下文中一共展示了ca_lists::getItemFromListByItemID方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getValuesForExport
/**
*
*/
public function getValuesForExport($pa_options = null)
{
$va_fields = $this->getFields();
$va_data = array();
$t_list = new ca_lists();
// get field values
foreach ($va_fields as $vs_field) {
$vs_value = $this->get($this->tableName() . '.' . $vs_field);
// Convert list item_id's to idnos for export
if ($vs_list_code = $this->getFieldInfo($vs_field, 'LIST_CODE')) {
$va_item = $t_list->getItemFromListByItemID($vs_list_code, $vs_value);
$vs_value = $va_item['idno'];
}
$va_data[$vs_field] = $vs_value;
}
return $va_data;
}
示例2: getItemInfoForImport
/**
* Get a record summary that is easier to parse when importing to another system
*/
private function getItemInfoForImport()
{
if (!($t_instance = $this->_getTableInstance($this->ops_table, $this->opn_id))) {
return false;
}
$o_dm = Datamodel::load();
$t_list = new ca_lists();
$t_locales = new ca_locales();
//
// Options
//
if (!($vs_delimiter = $this->opo_request->getParameter('delimiter', pString))) {
$vs_delimiter = "; ";
}
if (!($vs_flatten = $this->opo_request->getParameter('flatten', pString))) {
$vs_flatten = null;
}
$va_flatten = preg_split("![ ]*[;]+[ ]*!", $vs_flatten);
$va_flatten = array_flip($va_flatten);
$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));
}
// "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))) {
if (preg_match("/^hier\\_/", $vs_field_name)) {
continue;
}
if (preg_match("/\\_sort\$/", $vs_field_name)) {
continue;
}
if ($vs_field_name == $t_instance->primaryKey()) {
continue;
}
if (isset($va_field_info["LIST_CODE"])) {
// typical example: type_id
$va_item = $t_list->getItemFromListByItemID($va_field_info["LIST_CODE"], $vs_val);
if ($t_item = new ca_list_items($va_item["item_id"])) {
$vs_val = $t_item->get('idno');
}
}
$va_return['intrinsic'][$vs_field_name] = $vs_val;
}
}
// preferred labels
$va_labels = $t_instance->get($this->ops_table . ".preferred_labels", array("returnAllLocales" => true));
$va_labels = end($va_labels);
$vs_display_field_name = $t_instance->getLabelDisplayField();
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_label = array();
$va_label['locale'] = $va_locales[$vn_locale_id]["code"];
// add only UI fields to return
foreach (array_merge($t_instance->getLabelUIFields(), array('type_id')) as $vs_label_fld) {
$va_label[$vs_label_fld] = $va_tmp[$vs_label_fld];
}
$va_label[$vs_label_fld] = $va_tmp[$vs_label_fld];
$va_label['label'] = $va_tmp[$vs_display_field_name];
$va_return["preferred_labels"][$va_label['locale']] = $va_label;
}
}
if (isset($va_flatten['locales'])) {
$va_return["preferred_labels"] = array_pop(caExtractValuesByUserLocale(array($va_return["preferred_labels"])));
}
}
// nonpreferred labels
$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_label = array();
$va_label['locale'] = $va_locales[$vn_locale_id]["code"];
// add only UI fields to return
foreach (array_merge($t_instance->getLabelUIFields(), array('type_id')) as $vs_label_fld) {
$va_label[$vs_label_fld] = $va_tmp[$vs_label_fld];
}
$va_return["nonpreferred_labels"][$va_label['locale']] = $va_label;
}
}
if (isset($va_flatten['locales'])) {
$va_return["nonpreferred_labels"] = array_pop(caExtractValuesByUserLocale(array($va_return["nonpreferred_labels"])));
}
}
// 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" => false, "returnAllLocales" => true))) {
$va_vals_as_text = end($t_instance->get($this->ops_table . "." . $vs_code, array("convertCodesToDisplayText" => true, "returnAllLocales" => true)));
//.........这里部分代码省略.........
示例3: getRolesAsDOM
public function getRolesAsDOM()
{
$t_role = new ca_user_roles();
$t_list = new ca_lists();
$t_ui_screens = new ca_editor_ui_screens();
$vo_roles = $this->opo_dom->createElement("roles");
$qr_roles = $this->opo_db->query("SELECT * FROM ca_user_roles");
while ($qr_roles->nextRow()) {
$t_role->load($qr_roles->get("role_id"));
$vo_role = $this->opo_dom->createElement("role");
$vo_role->setAttribute("code", $this->makeIDNO($t_role->get("code")));
$vo_role->appendChild($this->opo_dom->createElement("name", $t_role->get("name")));
$vo_role->appendChild($this->opo_dom->createElement("description", $t_role->get("description")));
if (is_array($va_actions = $t_role->getRoleActions())) {
$vo_actions = $this->opo_dom->createElement("actions");
foreach ($va_actions as $vs_action) {
$vo_actions->appendChild($this->opo_dom->createElement("action", $vs_action));
}
$vo_role->appendChild($vo_actions);
}
$va_vars = $t_role->get('vars');
// add bundle level ACL items
if (is_array($va_vars['bundle_access_settings'])) {
$vo_bundle_lvl_ac = $this->opo_dom->createElement("bundleLevelAccessControl");
foreach ($va_vars['bundle_access_settings'] as $vs_bundle => $vn_val) {
$va_tmp = explode('.', $vs_bundle);
$vs_table_name = $va_tmp[0];
$vs_bundle_name = $va_tmp[1];
if ($t_ui_screens->isAvailableBundle($vs_table_name, $vs_bundle_name)) {
// only add this entry to the export if it's actually a valid bundle
$vs_access = $this->_convertACLConstantToString(intval($vn_val));
$vo_permission = $this->opo_dom->createElement("permission");
$vo_bundle_lvl_ac->appendChild($vo_permission);
$vo_permission->setAttribute('table', $vs_table_name);
$vo_permission->setAttribute('bundle', $vs_bundle_name);
$vo_permission->setAttribute('access', $vs_access);
}
}
$vo_role->appendChild($vo_bundle_lvl_ac);
}
// add type level ACL items
if (is_array($va_vars['type_access_settings'])) {
$vo_type_lvl_ac = $this->opo_dom->createElement("typeLevelAccessControl");
foreach ($va_vars['type_access_settings'] as $vs_id => $vn_val) {
$va_tmp = explode('.', $vs_id);
$vs_table_name = $va_tmp[0];
$vn_type_id = $va_tmp[1];
$vs_access = $this->_convertACLConstantToString(intval($vn_val));
/** @var BaseModelWithAttributes $t_instance */
$t_instance = $this->opo_dm->getInstanceByTableName($vs_table_name, true);
if (!($vs_list_code = $t_instance->getTypeListCode())) {
continue;
}
$va_item = $t_list->getItemFromListByItemID($vs_list_code, $vn_type_id);
if (!isset($va_item['idno'])) {
continue;
}
$vo_permission = $this->opo_dom->createElement("permission");
$vo_type_lvl_ac->appendChild($vo_permission);
$vo_permission->setAttribute('table', $vs_table_name);
$vo_permission->setAttribute('type', $va_item['idno']);
$vo_permission->setAttribute('access', $vs_access);
}
$vo_role->appendChild($vo_type_lvl_ac);
}
$vo_roles->appendChild($vo_role);
}
return $vo_roles;
}
示例4: getValuesForExport
/**
*
*/
public function getValuesForExport($pa_options = null)
{
$va_codes = $this->getApplicableElementCodes();
$va_data = parent::getValuesForExport($pa_options);
// get intrinsics
$t_locale = new ca_locales();
$t_list = new ca_lists();
// get attributes
foreach ($va_codes as $vs_code) {
if ($va_v = $this->get($this->tableName() . '.' . $vs_code, array('returnWithStructure' => true, 'returnAllLocales' => true, 'returnAsArray' => true, 'return' => 'url', 'version' => 'original'))) {
foreach ($va_v as $vn_id => $va_v_by_locale) {
foreach ($va_v_by_locale as $vn_locale_id => $va_v_list) {
if (!is_array($va_v_list)) {
continue;
}
if (!($vs_locale = $t_locale->localeIDToCode($vn_locale_id))) {
$vs_locale = 'NONE';
}
$vn_i = 0;
foreach ($va_v_list as $vn_index => $va_values) {
if (is_array($va_values)) {
foreach ($va_values as $vs_sub_code => $vs_value) {
if (!$vs_sub_code) {
continue;
}
if (!($t_element = $this->_getElementInstance($vs_sub_code))) {
continue;
}
switch ((int) $t_element->get('datatype')) {
case 3:
// list
$va_list_item = $t_list->getItemFromListByItemID($t_element->get('list_id'), $vs_value);
$vs_value = $vs_value . ":" . $va_list_item['idno'];
break;
}
$va_data['ca_attribute_' . $vs_code][$vs_locale]['value_' . $vn_i][$vs_sub_code] = $vs_value;
}
$vn_i++;
} else {
$va_data['ca_attribute_' . $vs_code][$vs_locale]['value_' . $vn_i][$vs_code] = $va_values;
}
}
}
}
}
}
return $va_data;
}
示例5: getRelationshipTypesForParentAsDOM
private function getRelationshipTypesForParentAsDOM($pn_parent_id)
{
$t_list = new ca_lists();
$vo_types = $this->opo_dom->createElement("types");
$qr_types = $this->opo_db->query("SELECT * FROM ca_relationship_types WHERE parent_id=?", $pn_parent_id);
if (!$qr_types->numRows()) {
return false;
}
while ($qr_types->nextRow()) {
$vo_type = $this->opo_dom->createElement("type");
if (preg_match("/root\\_for\\_[0-9]{1,3}/", $qr_types->get("type_code"))) {
// ignore legacy root records
continue;
}
$vo_type->setAttribute("code", $this->makeIDNO($qr_types->get("type_code")));
$vo_type->setAttribute("default", $qr_types->get("is_default"));
$vo_labels = $this->opo_dom->createElement("labels");
$qr_type_labels = $this->opo_db->query("SELECT * FROM ca_relationship_type_labels WHERE type_id=?", $qr_types->get("type_id"));
while ($qr_type_labels->nextRow()) {
$vo_label = $this->opo_dom->createElement("label");
$vo_label->setAttribute("locale", $this->opt_locale->localeIDToCode($qr_type_labels->get("locale_id")));
$vo_label->appendChild($this->opo_dom->createElement("typename", caEscapeForXML($qr_type_labels->get("typename"))));
$vo_label->appendChild($this->opo_dom->createElement("typename_reverse", caEscapeForXML($qr_type_labels->get("typename_reverse"))));
$vo_labels->appendChild($vo_label);
}
$vo_type->appendChild($vo_labels);
// restrictions (left side)
$t_instance = $this->opo_dm->getInstanceByTableNum($qr_types->get("table_num"));
if ($qr_types->get("sub_type_left_id")) {
$vs_left_table = $t_instance->getLeftTableName();
$t_left_instance = $this->opo_dm->getInstanceByTableNum($vs_left_table);
$vs_type_code = $t_left_instance->getTypeListCode();
$va_item = $t_list->getItemFromListByItemID($vs_type_code, $qr_types->get("sub_type_left_id"));
$vo_type->appendChild($this->opo_dom->createElement("subTypeLeft", $va_item["idno"]));
}
// restrictions (right side)
if ($qr_types->get("sub_type_right_id")) {
$vs_right_table = $t_instance->getRightTableName();
$t_right_instance = $this->opo_dm->getInstanceByTableNum($vs_right_table);
$vs_type_code = $t_right_instance->getTypeListCode();
$va_item = $t_list->getItemFromListByItemID($vs_type_code, $qr_types->get("sub_type_right_id"));
$vo_type->appendChild($this->opo_dom->createElement("subTypeRight", $va_item["idno"]));
}
// subtypes
if ($vo_subtypes = $this->getRelationshipTypesForParentAsDOM($qr_types->get("type_id"))) {
$vo_types->appendChild($vo_subtypes);
}
$vo_types->appendChild($vo_type);
}
return $vo_types;
}
示例6: 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))) {
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();
// 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 objects
if ($this->ops_table == "ca_objects") {
$va_return['representations'] = $t_instance->getRepresentations();
}
// 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
if ($this->ops_table == "ca_sets" && $vs_rel_table == "ca_tours") {
// throws SQL error in getRelatedItems
continue;
}
// you'd expect the set items to be included for sets but
// we don't wan't to list set items as allowed related table
// which is why we add them by hand here
if ($this->ops_table == "ca_sets") {
$va_tmp = $t_instance->getItems();
$va_set_items = array();
foreach ($va_tmp as $va_loc) {
foreach ($va_loc as $va_item) {
$va_set_items[] = $va_item;
}
}
$va_return["related"]["ca_set_items"] = $va_set_items;
}
// end set-related hacks
//.........这里部分代码省略.........