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


PHP ca_lists::getItemIDFromListByLabel方法代码示例

本文整理汇总了PHP中ca_lists::getItemIDFromListByLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP ca_lists::getItemIDFromListByLabel方法的具体用法?PHP ca_lists::getItemIDFromListByLabel怎么用?PHP ca_lists::getItemIDFromListByLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ca_lists的用法示例。


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

示例1: saveInlineEdit

 /**
  * Save edits from "spreadsheet" (editable results) mode
  *
  */
 public function saveInlineEdit($pa_options = null)
 {
     global $g_ui_locale_id;
     $pa_changes = $this->request->getParameter("changes", pArray);
     $vs_resp = array();
     $o_dm = Datamodel::load();
     if (!is_array($pa_changes) || !sizeof($pa_changes)) {
         $va_resp['messages'][0] = _t("Nothing to save");
     } else {
         foreach ($pa_changes as $vn_i => $pa_change) {
             $ps_table = $pa_change['table'];
             $pa_bundle = explode("-", $ps_bundle = $pa_change['bundle']);
             $pn_id = (int) $pa_change['id'];
             $ps_val = $pa_change['value'];
             if (!($t_instance = $o_dm->getInstanceByTableName($ps_table, true))) {
                 $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Invalid table: %1', $ps_table));
             } else {
                 if (!$t_instance->load($pn_id)) {
                     $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Invalid id: %1', $pn_id));
                 } else {
                     if (!$t_instance->isSaveable($this->request)) {
                         $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('You are not allowed to edit this.'));
                     } elseif ($pa_bundle[0] == 'preferred_labels') {
                         if ($this->request->user->getBundleAccessLevel($ps_table, $pa_bundle[0]) != __CA_BUNDLE_ACCESS_EDIT__) {
                             $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('You are not allowed to edit this.'));
                         } else {
                             $vn_label_id = $t_instance->getPreferredLabelID($g_ui_locale_id);
                             $va_label_values = array();
                             if (sizeof($pa_bundle) == 1) {
                                 // is generic "preferred_labels"
                                 $va_label_values[$t_instance->getLabelDisplayField()] = $ps_val;
                             } else {
                                 $vs_preferred_label_element = $pa_bundle[1];
                                 $va_label_values[$vs_preferred_label_element] = $ps_val;
                             }
                             if ($vn_label_id) {
                                 $t_instance->editLabel($vn_label_id, $va_label_values, $g_ui_locale_id, null, true);
                                 // TODO: what about type?
                             } else {
                                 $t_instance->addLabel($va_label_values, $g_ui_locale_id, null, true);
                             }
                             if ($t_instance->numErrors()) {
                                 $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Could not set preferred label %1 to %2: %3', $ps_bundle, $ps_val, join("; ", $t_instance->getErrors())));
                             } else {
                                 $va_resp['messages'][$pn_id] = array('message' => _t('Set preferred label %1 to %2', $ps_bundle, $ps_val), 'value' => $ps_val);
                             }
                         }
                     } elseif ($t_instance->hasField($ps_bundle)) {
                         if ($this->request->user->getBundleAccessLevel($ps_table, $ps_bundle) != __CA_BUNDLE_ACCESS_EDIT__) {
                             $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('You are not allowed to edit this.'));
                         } else {
                             // is it a list?
                             $t_list = new ca_lists();
                             $t_instance->setMode(ACCESS_WRITE);
                             if (($vs_list_code = $t_instance->getFieldInfo($ps_bundle, 'LIST')) && ($va_item = $t_list->getItemFromListByLabel($vs_list_code, $ps_val))) {
                                 $t_instance->set($ps_bundle, $va_item['item_value']);
                             } elseif (($vs_list_code = $t_instance->getFieldInfo($ps_bundle, 'LIST_CODE')) && ($vn_item_id = $t_list->getItemIDFromListByLabel($vs_list_code, $ps_val))) {
                                 $t_instance->set($ps_bundle, $vn_item_id);
                             } else {
                                 $t_instance->set($ps_bundle, $ps_val);
                             }
                             $t_instance->update();
                             if ($t_instance->numErrors()) {
                                 $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Could not set %1 to %2: %3', $ps_bundle, $ps_val, join("; ", $t_instance->getErrors())));
                             } else {
                                 $va_resp['messages'][$pn_id] = array('message' => _t('Set %1 to %2', $ps_bundle, $ps_val), 'value' => $ps_val);
                             }
                         }
                     } elseif ($t_instance->hasElement($ps_bundle)) {
                         $vn_datatype = ca_metadata_elements::getElementDatatype($ps_bundle);
                         // Check if it repeats?
                         if ($vn_count = $t_instance->getAttributeCountByElement($ps_bundle) > 1) {
                             $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Cannot edit <em>%1</em> here because it has multiple values. Try editing it directly.', mb_strtolower($t_instance->getDisplayLabel("{$ps_table}.{$ps_bundle}"))));
                         } elseif (!in_array($vn_datatype, array(1, 2, 3, 5, 6, 8, 9, 10, 11, 12))) {
                             // Check if it's a supported type?
                             $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('Cannot edit <em>%1</em> here. Try editing it directly.', mb_strtolower($t_instance->getDisplayLabel("{$ps_table}.{$ps_bundle}"))));
                         } elseif ($this->request->user->getBundleAccessLevel($ps_table, $ps_bundle) != __CA_BUNDLE_ACCESS_EDIT__) {
                             $va_resp['errors'][$pn_id] = array('error' => 100, 'message' => _t('You are not allowed to edit this.'));
                         } else {
                             // Do edit
                             $t_instance->setMode(ACCESS_WRITE);
                             $vs_val_proc = null;
                             if ($vn_datatype == 3) {
                                 if ($vn_id = ca_list_items::find(array('preferred_labels' => array('name_plural' => $ps_val)), array('returnAs' => 'firstId'))) {
                                     $t_instance->replaceAttribute(array('locale_id' => $g_ui_locale_id, $ps_bundle => $vn_id), $ps_bundle);
                                     // convert list codes to display text
                                     $t_list_item = new ca_list_items((int) $vn_id);
                                     if ($t_list_item->getPrimaryKey()) {
                                         $vs_val_proc = $t_list_item->get('ca_list_items.preferred_labels.name_plural');
                                     }
                                 }
                             } else {
                                 $t_instance->replaceAttribute(array('locale_id' => $g_ui_locale_id, $ps_bundle => $ps_val), $ps_bundle);
                             }
                             $t_instance->update();
                             if (!$vs_val_proc) {
//.........这里部分代码省略.........
开发者ID:ffarago,项目名称:pawtucket2,代码行数:101,代码来源:BaseFindController.php

示例2: caGetListItemIDForLabel

/**
 * Fetch item_id for item with specified label. Value must match exactly.
 *
 * @param string $ps_list_code List code
 * @param string $ps_label The label value to search for
 * @return int item_id of list item or null if no matching item was found
 */
function caGetListItemIDForLabel($ps_list_code, $ps_label)
{
    $t_list = new ca_lists();
    return $t_list->getItemIDFromListByLabel($ps_list_code, $ps_label);
}
开发者ID:guaykuru,项目名称:pawtucket,代码行数:12,代码来源:listHelpers.php

示例3: caGetListItemIDForLabel

function caGetListItemIDForLabel($ps_list_code, $ps_label, $pa_options = null)
{
    global $g_list_item_id_for_label_cache;
    if (isset($g_list_item_id_for_label_cache[$ps_list_code . '/' . $ps_label])) {
        return $g_list_item_id_for_label_cache[$ps_list_code . '/' . $ps_label];
    }
    $t_list = new ca_lists();
    if ($o_trans = caGetOption('transaction', $pa_options, null)) {
        $t_list->setTransaction($o_trans);
    }
    return $g_list_item_id_for_label_cache[$ps_list_code . '/' . $ps_label] = $t_list->getItemIDFromListByLabel($ps_list_code, $ps_label);
}
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:12,代码来源:listHelpers.php

示例4: caGetListItemIDForLabel

function caGetListItemIDForLabel($ps_list_code, $ps_label)
{
    global $g_list_item_id_for_label_cache;
    if (isset($g_list_item_id_for_label_cache[$ps_list_code . '/' . $ps_label])) {
        return $g_list_item_id_for_label_cache[$ps_list_code . '/' . $ps_label];
    }
    $t_list = new ca_lists();
    return $g_list_item_id_for_label_cache[$ps_list_code . '/' . $ps_label] = $t_list->getItemIDFromListByLabel($ps_list_code, $ps_label);
}
开发者ID:ffarago,项目名称:pawtucket2,代码行数:9,代码来源:listHelpers.php


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