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


PHP BaseModel::_getElementInstance方法代码示例

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


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

示例1: _getAttributeValue

 /**
  * get() value for attribute
  *
  * @param array $pa_value_list
  * @param BaseModel $pt_instance
  * @param array Options
  *
  * @return array|string
  */
 private function _getAttributeValue($pa_value_list, $pt_instance, $pa_options)
 {
     $va_path_components =& $pa_options['pathComponents'];
     $vs_delimiter = isset($pa_options['delimiter']) ? $pa_options['delimiter'] : ';';
     $va_return_values = array();
     $vn_id = $this->get($pt_instance->primaryKey(true));
     $vs_table_name = $pt_instance->tableName();
     if (is_array($pa_value_list) && sizeof($pa_value_list)) {
         $va_val_proc = array();
         foreach ($pa_value_list as $o_attribute) {
             $t_attr_element = $pt_instance->_getElementInstance($o_attribute->getElementID());
             $vn_attr_type = $t_attr_element->get('datatype');
             $va_acc = array();
             $va_values = $o_attribute->getValues();
             if ($pa_options['useLocaleCodes']) {
                 if (!$o_attribute->getLocaleID() || !($vm_locale_id = SearchResult::$opo_locales->localeIDToCode($o_attribute->getLocaleID()))) {
                     $vm_locale_id = __CA_DEFAULT_LOCALE__;
                 }
             } else {
                 if (!($vm_locale_id = $o_attribute->getLocaleID())) {
                     $vm_locale_id = SearchResult::$opo_locales->localeCodeToID(__CA_DEFAULT_LOCALE__);
                 }
             }
             $vb_did_return_value = false;
             foreach ($va_values as $o_value) {
                 $vs_val_proc = null;
                 $vb_dont_return_value = false;
                 $vs_element_code = $o_value->getElementCode();
                 $va_auth_spec = null;
                 if (is_a($o_value, "AuthorityAttributeValue")) {
                     $va_auth_spec = $va_path_components['components'];
                     if ($pt_instance->hasElement($va_path_components['subfield_name'], null, true, array('dontCache' => false))) {
                         array_shift($va_auth_spec);
                         array_shift($va_auth_spec);
                         array_shift($va_auth_spec);
                     } elseif ($pt_instance->hasElement($va_path_components['field_name'], null, true, array('dontCache' => false))) {
                         array_shift($va_auth_spec);
                         array_shift($va_auth_spec);
                         $va_path_components['subfield_name'] = null;
                     }
                 }
                 if ($va_path_components['subfield_name'] && $va_path_components['subfield_name'] !== $vs_element_code && !$o_value instanceof InformationServiceAttributeValue) {
                     $vb_dont_return_value = true;
                     if (!$pa_options['filter']) {
                         continue;
                     }
                 }
                 if (is_a($o_value, "AuthorityAttributeValue") && sizeof($va_auth_spec) > 0) {
                     array_unshift($va_auth_spec, $vs_auth_table_name = $o_value->tableName());
                     if ($qr_res = caMakeSearchResult($vs_auth_table_name, array($o_value->getID()))) {
                         if ($qr_res->nextHit()) {
                             unset($pa_options['returnWithStructure']);
                             $va_options['returnAsArray'] = true;
                             $va_val_proc = $qr_res->get(join(".", $va_auth_spec), $pa_options);
                             if (is_array($va_val_proc)) {
                                 foreach ($va_val_proc as $vn_i => $vs_v) {
                                     $va_return_values[(int) $vn_id][$vm_locale_id][(int) $o_attribute->getAttributeID() . "_{$vn_i}"][$vs_element_code] = $vs_v;
                                 }
                             }
                         }
                     }
                     continue;
                 }
                 if (is_null($vs_val_proc)) {
                     switch ($o_value->getType()) {
                         case __CA_ATTRIBUTE_VALUE_LIST__:
                             $t_element = $pt_instance->_getElementInstance($o_value->getElementID());
                             $vn_list_id = $t_element->get('list_id');
                             $vs_val_proc = $o_value->getDisplayValue(array_merge($pa_options, array('output' => $pa_options['output'], 'list_id' => $vn_list_id)));
                             break;
                         case __CA_ATTRIBUTE_VALUE_INFORMATIONSERVICE__:
                             //ca_objects.informationservice.ulan_container
                             // support subfield notations like ca_objects.wikipedia.abstract, but only if we're not already at subfield-level, e.g. ca_objects.container.wikipedia
                             if ($va_path_components['subfield_name'] && $vs_element_code != $va_path_components['subfield_name'] && $vs_element_code == $va_path_components['field_name']) {
                                 $vs_val_proc = $o_value->getExtraInfo($va_path_components['subfield_name']);
                                 $vb_dont_return_value = false;
                                 break;
                             }
                             // support ca_objects.container.wikipedia.abstract
                             if ($vs_element_code == $va_path_components['subfield_name'] && $va_path_components['num_components'] == 4) {
                                 $vs_val_proc = $o_value->getExtraInfo($va_path_components['components'][3]);
                                 $vb_dont_return_value = false;
                                 break;
                             }
                             // support ca_objects.wikipedia or ca_objects.container.wikipedia (Eg. no "extra" value specified)
                             if ($vs_element_code == $va_path_components['field_name'] || $vs_element_code == $va_path_components['subfield_name']) {
                                 $vs_val_proc = $o_value->getDisplayValue(array_merge($pa_options, array('output' => $pa_options['output'])));
                                 $vb_dont_return_value = false;
                                 break;
                             }
                             continue 2;
//.........这里部分代码省略.........
开发者ID:samrahman,项目名称:providence,代码行数:101,代码来源:SearchResult.php

示例2: _getAttributeValue

 /**
  * get() value for attribute
  *
  * @param array $pa_value_list
  * @param BaseModel $pt_instance
  * @param array Options
  *
  * @return array|string
  */
 private function _getAttributeValue($pa_value_list, $pt_instance, $pa_options)
 {
     $va_path_components =& $pa_options['pathComponents'];
     $va_return_values = array();
     $vn_id = $this->get($pt_instance->primaryKey(true));
     $vs_table_name = $pt_instance->tableName();
     if (is_array($pa_value_list) && sizeof($pa_value_list)) {
         foreach ($pa_value_list as $o_attribute) {
             $va_values = $o_attribute->getValues();
             if ($pa_options['useLocaleCodes']) {
                 if (!$o_attribute->getLocaleID() || !($vm_locale_id = $this->opo_locales->localeIDToCode($o_attribute->getLocaleID()))) {
                     $vm_locale_id = __CA_DEFAULT_LOCALE__;
                 }
             } else {
                 if (!($vm_locale_id = $o_attribute->getLocaleID())) {
                     $vm_locale_id = $this->opo_locales->localeCodeToID(__CA_DEFAULT_LOCALE__);
                 }
             }
             foreach ($va_values as $o_value) {
                 $vs_element_code = $o_value->getElementCode();
                 if ($va_path_components['subfield_name']) {
                     if ($va_path_components['subfield_name'] && $va_path_components['subfield_name'] !== $vs_element_code && !$o_value instanceof InformationServiceAttributeValue) {
                         continue;
                     }
                 }
                 switch ($o_value->getType()) {
                     case __CA_ATTRIBUTE_VALUE_LIST__:
                         $t_element = $pt_instance->_getElementInstance($o_value->getElementID());
                         $vn_list_id = $t_element->get('list_id');
                         $vs_val_proc = $o_value->getDisplayValue(array_merge($pa_options, array('output' => $pa_options['output'], 'list_id' => $vn_list_id)));
                         break;
                     case __CA_ATTRIBUTE_VALUE_INFORMATIONSERVICE__:
                         //ca_objects.informationservice.ulan_container
                         // support subfield notations like ca_objects.wikipedia.abstract, but only if we're not already at subfield-level, e.g. ca_objects.container.wikipedia
                         if ($va_path_components['subfield_name'] && $vs_element_code != $va_path_components['subfield_name'] && $vs_element_code == $va_path_components['field_name']) {
                             $vs_val_proc = $o_value->getExtraInfo($va_path_components['subfield_name']);
                             break;
                         }
                         // support ca_objects.container.wikipedia.abstract
                         if ($vs_element_code == $va_path_components['subfield_name'] && $va_path_components['num_components'] == 4) {
                             $vs_val_proc = $o_value->getExtraInfo($va_path_components['components'][3]);
                             break;
                         }
                         // support ca_objects.wikipedia or ca_objects.container.wikipedia (Eg. no "extra" value specified)
                         if ($vs_element_code == $va_path_components['field_name'] || $vs_element_code == $va_path_components['subfield_name']) {
                             $vs_val_proc = $o_value->getDisplayValue(array_merge($pa_options, array('output' => $pa_options['output'])));
                             break;
                         }
                         continue;
                     default:
                         $vs_val_proc = $o_value->getDisplayValue(array_merge($pa_options, array('output' => $pa_options['output'])));
                         break;
                 }
                 if ($pa_options['makeLink']) {
                     $vs_val_proc = array_shift(caCreateLinksFromText(array($vs_val_proc), $vs_table_name, array($vn_id)));
                 }
                 if ($pa_options['returnWithStructure']) {
                     $va_return_values[(int) $vn_id][$vm_locale_id][(int) $o_attribute->getAttributeID()][$vs_element_code] = $vs_val_proc;
                 } else {
                     $va_return_values[(int) $vn_id][$vm_locale_id][(int) $o_attribute->getAttributeID()] = $vs_val_proc;
                 }
             }
         }
     } else {
         // is blank
         if ($pa_options['returnWithStructure'] && $pa_options['returnBlankValues']) {
             $va_return_values[(int) $vn_id][null][null][$va_path_components['subfield_name'] ? $va_path_components['subfield_name'] : $va_path_components['field_name']] = '';
         }
     }
     if (!$pa_options['returnAllLocales']) {
         $va_return_values = caExtractValuesByUserLocale($va_return_values);
     }
     if ($pa_options['returnWithStructure']) {
         return is_array($va_return_values) ? $va_return_values : array();
     }
     //
     // Flatten array for return as string or simple array value
     //
     $va_flattened_values = $this->_flattenArray($va_return_values, $pa_options);
     if ($pa_options['returnAsArray']) {
         return $va_flattened_values;
     } else {
         return sizeof($va_flattened_values) > 0 ? join($pa_options['delimiter'], $va_flattened_values) : null;
     }
 }
开发者ID:kai-iak,项目名称:providence,代码行数:94,代码来源:SearchResult.php

示例3: caExtractEmbeddedMetadata

/**
 * Perform mapping of extracted media metadata to CollectiveAccess bundles.
 *
 * @param BaseModel $po_instance Model instance to insert extracted metadata into
 * @param array $pa_metadata Extracted metadata
 * @param int $pn_locale_id The current locale as a numeric locale_id
 * @return bool True extracted metadata was mapped and the model changed, false if no change was made to the model
 */
function caExtractEmbeddedMetadata($po_instance, $pa_metadata, $pn_locale_id)
{
    if (!is_array($pa_metadata)) {
        return false;
    }
    $vb_did_mapping = false;
    if (!($vs_media_metadata_config = $po_instance->getAppConfig()->get('media_metadata'))) {
        return false;
    }
    $o_metadata_config = Configuration::load($vs_media_metadata_config);
    $va_mappings = $o_metadata_config->getAssoc('import_mappings');
    $vs_tablename = $po_instance->tableName();
    // set extracted georef?
    $va_georef_elements = $o_metadata_config->getList('extract_embedded_exif_georeferencing_to');
    $va_georef_containers = $o_metadata_config->getAssoc('extract_embedded_exif_georeferencing_to_container');
    $va_date_elements = $o_metadata_config->getList('extract_embedded_exif_creation_date_to');
    $va_date_containers = $o_metadata_config->getAssoc('extract_embedded_exif_creation_date_to_container');
    if (isset($pa_metadata['EXIF']) && is_array($pa_metadata['EXIF']) && (is_array($va_georef_elements) && sizeof($va_georef_elements) || is_array($va_georef_containers) && sizeof($va_georef_containers) || is_array($va_date_elements) && sizeof($va_date_elements) || is_array($va_date_containers) && sizeof($va_date_containers))) {
        $va_exif_data = $pa_metadata['EXIF'];
        if (is_array($va_georef_elements)) {
            if (is_array($va_coords = caParseEXIFLatLong($va_exif_data))) {
                foreach ($va_georef_elements as $vs_element) {
                    $va_tmp = explode('.', $vs_element);
                    $po_instance->addAttribute(array($va_tmp[1] => "[" . $va_coords['latitude'] . ", " . $va_coords['longitude'] . "]", 'locale_id' => $pn_locale_id), $va_tmp[1]);
                }
                $vb_did_mapping = true;
            }
        }
        if (is_array($va_georef_containers)) {
            if (is_array($va_coords = caParseEXIFLatLong($va_exif_data))) {
                foreach ($va_georef_containers as $vs_container => $va_info) {
                    $va_tmp = explode('.', $vs_container);
                    $vs_value_element = array_pop(explode('.', $va_info['value']));
                    $va_data = array($vs_value_element => "[" . $va_coords['latitude'] . ", " . $va_coords['longitude'] . "]", 'locale_id' => $pn_locale_id);
                    if (isset($va_info['map']) && is_array($va_info['map'])) {
                        foreach ($va_info['map'] as $vs_sub_element => $vs_value) {
                            $va_tmp2 = explode('.', $vs_sub_element);
                            $vs_sub_element = array_pop($va_tmp2);
                            if ($t_element = $po_instance->_getElementInstance($vs_sub_element)) {
                                switch ($t_element->get('datatype')) {
                                    case 3:
                                        // List
                                        $t_list = new ca_lists();
                                        $va_data[$vs_sub_element] = $t_list->getItemIDFromList($t_element->get('list_id'), $vs_value);
                                        break;
                                    default:
                                        $va_data[$vs_sub_element] = $vs_value;
                                        break;
                                }
                            }
                        }
                    }
                    $po_instance->addAttribute($va_data, $va_tmp[1]);
                }
                $vb_did_mapping = true;
            }
        }
        if (is_array($va_date_elements)) {
            if (($vs_raw_date = $va_exif_data['IFD0']['DateTimeOriginal']) || ($vs_raw_date = $va_exif_data['EXIF']['DateTimeOriginal'])) {
                $va_date_tmp = preg_split('![: ]+!', $vs_raw_date);
                $vs_date = $va_date_tmp[0] . '-' . $va_date_tmp[1] . '-' . $va_date_tmp[2] . 'T' . $va_date_tmp[3] . ':' . $va_date_tmp[4] . ':' . $va_date_tmp[5];
                foreach ($va_date_elements as $vs_element) {
                    $va_tmp = explode('.', $vs_element);
                    $po_instance->addAttribute(array($va_tmp[1] => $vs_date, 'locale_id' => $pn_locale_id), $va_tmp[1]);
                }
                $vb_did_mapping = true;
            }
        }
        if (is_array($va_date_containers)) {
            $t_list = new ca_lists();
            if (($vs_raw_date = $va_exif_data['IFD0']['DateTimeOriginal']) || ($vs_raw_date = $va_exif_data['EXIF']['DateTimeOriginal'])) {
                $va_date_tmp = preg_split('![: ]+!', $vs_raw_date);
                $vs_date = $va_date_tmp[0] . '-' . $va_date_tmp[1] . '-' . $va_date_tmp[2] . 'T' . $va_date_tmp[3] . ':' . $va_date_tmp[4] . ':' . $va_date_tmp[5];
                foreach ($va_date_containers as $vs_container => $va_info) {
                    $va_tmp = explode('.', $vs_container);
                    $vs_value_element = array_pop(explode('.', $va_info['value']));
                    $va_data = array($vs_value_element => $vs_date, 'locale_id' => $pn_locale_id);
                    if (isset($va_info['map']) && is_array($va_info['map'])) {
                        foreach ($va_info['map'] as $vs_sub_element => $vs_value) {
                            $va_tmp2 = explode('.', $vs_sub_element);
                            $vs_sub_element = array_pop($va_tmp2);
                            if ($t_element = $po_instance->_getElementInstance($vs_sub_element)) {
                                switch ($t_element->get('datatype')) {
                                    case 3:
                                        // List
                                        $va_data[$vs_sub_element] = $t_list->getItemIDFromList($t_element->get('list_id'), $vs_value);
                                        break;
                                    default:
                                        $va_data[$vs_sub_element] = $vs_value;
                                        break;
                                }
                            }
//.........这里部分代码省略.........
开发者ID:ffarago,项目名称:pawtucket2,代码行数:101,代码来源:mediaPluginHelpers.php


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