本文整理汇总了PHP中BaseModel::tableName方法的典型用法代码示例。如果您正苦于以下问题:PHP BaseModel::tableName方法的具体用法?PHP BaseModel::tableName怎么用?PHP BaseModel::tableName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BaseModel
的用法示例。
在下文中一共展示了BaseModel::tableName方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findFirst
public static function findFirst($parameters = NULL, $hostType = NULL)
{
$class = get_called_class();
$object = new $class();
BaseModel::$tableName = $object->getSource();
BaseModel::$hostType = $hostType;
return parent::findFirst($parameters);
}
示例2: caProcessRelationshipLookupLabel
/**
* Converts result set into display labels for relationship lookup
*
* @param SearchResult $qr_rel_items
* @param BaseModel $pt_rel
* @param array $pa_options Array of options, including:
* stripTags = default is false
* exclude = list of primary key values to omit from returned list
* config =
* limit = maximum number of items to return; if omitted all items are returned
* inlineCreateMessage =
* inlineCreateQuery =
* inlineCreateMessageDoesNotExist =
* template =
* primaryIDs = row_ids for primary rows in related table, keyed by table name; when resolving ambiguous relationships the row_ids will be excluded from consideration. This option is rarely used and exists primarily to take care of a single
* edge case: you are processing a template relative to a self-relationship such as ca_entities_x_entities that includes references to the subject table (ca_entities, in the case of ca_entities_x_entities). There are
* two possible paths to take in this situations; primaryIDs lets you specify which ones you *don't* want to take by row_id. For interstitial editors, the ids will be set to a single id: that of the subject (Eg. ca_entities) row
* from which the interstitial was launched.
* @return mixed
*/
function caProcessRelationshipLookupLabel($qr_rel_items, $pt_rel, $pa_options = null)
{
$va_initial_values = array();
$vs_hier_fld = $pt_rel->getProperty('HIERARCHY_ID_FLD');
$vs_idno_fld = $pt_rel->getProperty('ID_NUMBERING_ID_FIELD');
$vs_idno_sort_fld = $pt_rel->getProperty('ID_NUMBERING_SORT_FIELD');
$vs_rel_pk = caGetOption('primaryKey', $pa_options, $pt_rel->primaryKey());
$vs_rel_table = caGetOption('table', $pa_options, $pt_rel->tableName());
$o_config = !isset($pa_options['config']) || !is_object($pa_options['config']) ? Configuration::load() : $pa_options['config'];
$pn_limit = caGetOption('limit', $pa_options, null);
$ps_inline_create_message = caGetOption('inlineCreateMessage', $pa_options, null);
$ps_inline_create_does_not_exist_message = caGetOption('inlineCreateMessageDoesNotExist', $pa_options, null);
$ps_inline_create_query = caGetOption('inlineCreateQuery', $pa_options, null);
$ps_inline_create_query_lc = mb_strtolower($ps_inline_create_query);
$ps_empty_result_message = caGetOption('emptyResultMessage', $pa_options, null);
$ps_empty_result_query = caGetOption('emptyResultQuery', $pa_options, null);
$vs_template = caGetOption('template', $pa_options, null);
$va_exclude = caGetOption('exclude', $pa_options, array(), array('castTo' => 'array'));
$va_display_format = $o_config->getList("{$vs_rel_table}_lookup_settings");
$vs_display_delimiter = $o_config->get("{$vs_rel_table}_lookup_delimiter");
if (!$vs_template) {
$vs_template = join($vs_display_delimiter, $va_display_format);
}
$va_related_item_info = $va_parent_ids = $va_hierarchy_ids = array();
$va_items = array();
$o_dm = Datamodel::load();
$t_rel = $o_dm->getInstanceByTableName($vs_rel_table, true);
$vs_type_id_fld = method_exists($t_rel, 'getTypeFieldName') ? $t_rel->getTypeFieldName() : null;
$vn_c = 0;
$vb_include_inline_add_does_not_exist_message = $vb_include_empty_result_message = false;
$vb_include_inline_add_message = true;
if (is_object($qr_rel_items)) {
if (!$qr_rel_items->numHits()) {
if ($ps_inline_create_does_not_exist_message) {
$vb_include_inline_add_does_not_exist_message = true;
$vb_include_inline_add_message = false;
} else {
if ($ps_empty_result_message) {
$vb_include_empty_result_message = true;
}
}
} else {
$vs_table = $qr_rel_items->tableName();
$vs_pk = $qr_rel_items->primaryKey();
$va_primary_ids = method_exists($pt_rel, "isSelfRelationship") && ($vb_is_self_rel = $pt_rel->isSelfRelationship()) ? caGetOption("primaryIDs", $pa_options, null) : null;
while ($qr_rel_items->nextHit()) {
$vn_id = $qr_rel_items->get("{$vs_rel_table}.{$vs_rel_pk}");
if (in_array($vn_id, $va_exclude)) {
continue;
}
$va_item = array('id' => $vn_id, $vs_rel_pk => $vn_id);
if ($vs_type_id_fld) {
$va_item['type_id'] = $qr_rel_items->get("{$vs_rel_table}.{$vs_type_id_fld}");
}
$va_item['_display'] = caProcessTemplateForIDs($vs_template, $vs_table, array($qr_rel_items->get("{$vs_table}.{$vs_pk}")), array('returnAsArray' => false, 'returnAsLink' => false, 'delimiter' => caGetOption('delimiter', $pa_options, $vs_display_delimiter), 'resolveLinksUsing' => $vs_rel_table, 'primaryIDs' => $va_primary_ids));
$va_item['label'] = mb_strtolower($qr_rel_items->get("{$vs_table}.preferred_labels"));
$va_items[$vn_id] = $va_item;
$vn_c++;
if ($pn_limit && $pn_limit <= $vn_c) {
break;
}
}
}
}
if (isset($pa_options['relatedItems']) && is_array($pa_options['relatedItems']) && sizeof($pa_options['relatedItems'])) {
$va_tmp = array();
foreach ($pa_options['relatedItems'] as $vn_relation_id => $va_relation) {
$va_items[$va_relation[$vs_rel_pk]]['relation_id'] = $va_relation['relation_id'];
$va_items[$va_relation[$vs_rel_pk]]['relationship_type_id'] = $va_items[$va_relation[$vs_rel_pk]]['type_id'] = $va_relation['direction'] ? $va_relation['direction'] . '_' . $va_relation['relationship_type_id'] : $va_relation['relationship_type_id'];
$va_items[$va_relation[$vs_rel_pk]]['rel_type_id'] = $va_relation['relationship_type_id'];
$va_items[$va_relation[$vs_rel_pk]]['relationship_typename'] = $va_relation['relationship_typename'];
$va_items[$va_relation[$vs_rel_pk]]['idno'] = $va_relation[$vs_idno_fld];
$va_items[$va_relation[$vs_rel_pk]]['idno_sort'] = $va_relation[$vs_idno_sort_fld];
$va_items[$va_relation[$vs_rel_pk]]['label'] = $va_relation['label'];
$va_items[$va_relation[$vs_rel_pk]]['direction'] = $va_relation['direction'];
$va_items[$va_relation[$vs_rel_pk]]['effective_date'] = $va_relation['effective_date'];
if (isset($va_relation['surname'])) {
// pass forename and surname entity label fields to support proper sorting by name
$va_items[$va_relation[$vs_rel_pk]]['surname'] = $va_relation['surname'];
$va_items[$va_relation[$vs_rel_pk]]['forename'] = $va_relation['forename'];
//.........这里部分代码省略.........
示例3: caMergeSourceRestrictionLists
/**
* Merges sources specified with any specified "restrict_to_sources"/"restrictToSources" option, user access settings and sources configured in app.conf
* into a single list of source_ids suitable for enforcing source restrictions.
*
* @param BaseModel $t_instance A model instance for the table to which the sources apply
* @param array $pa_options An array of options containing, if specified, a list of sources for either the "restrict_to_sources" or "restrictToSources" keys
*
* @return array List of numeric source_ids for which the user has access
*/
function caMergeSourceRestrictionLists($t_instance, $pa_options)
{
$va_restrict_to_source_ids = null;
if (is_array($pa_options['restrict_to_sources']) && sizeof($pa_options['restrict_to_sources'])) {
$pa_options['restrictToSources'] = $pa_options['restrict_to_sources'];
}
if (is_array($pa_options['restrictToSources']) && sizeof($pa_options['restrictToSources'])) {
$va_restrict_to_source_ids = caMakeSourceIDList($t_instance->tableName(), $pa_options['restrictToSources'], array('noChildren' => true));
}
$va_sources = null;
$o_config = Configuration::load();
if ((bool) $o_config->get('perform_source_access_checking') && method_exists($t_instance, 'getSourceFieldName') && ($vs_source_field_name = $t_instance->getSourceFieldName())) {
$va_sources = caGetSourceRestrictionsForUser($t_instance->tableName());
}
if (is_array($va_sources) && sizeof($va_sources) && is_array($va_restrict_to_source_ids) && sizeof($va_restrict_to_source_ids)) {
if (sizeof($va_tmp = array_intersect($va_restrict_to_source_ids, $va_sources))) {
$va_sources = $va_tmp;
}
} else {
if (!is_array($va_sources) || !sizeof($va_sources)) {
$va_sources = $va_restrict_to_source_ids;
}
}
return $va_sources;
}
示例4: _getIntrinsicValue
/**
* get() value for intrinsic
*
* @param array $pa_value_list
* @param BaseModel $pt_instance
* @param array Options
*
* @return array|string
*/
private function _getIntrinsicValue($pa_value_list, $pt_instance, $pa_options)
{
$vb_return_as_link = isset($pa_options['returnAsLink']) ? $pa_options['returnAsLink'] : false;
$vb_get_direct_date = (bool) caGetOption(array('getDirectDate', 'GET_DIRECT_DATE'), $pa_options, false);
$vb_sortable = isset($pa_options['sortable']) ? $pa_options['sortable'] : false;
$va_path_components = $pa_options['pathComponents'];
$va_field_info = $pa_options['fieldInfo'];
$vs_pk = $pa_options['primaryKey'];
$vs_table_name = $pt_instance->tableName();
// Handle specific intrinsic types
switch ($va_field_info['FIELD_TYPE']) {
case FT_DATERANGE:
case FT_HISTORIC_DATERANGE:
case FT_TIMESTAMP:
case FT_DATETIME:
case FT_HISTORIC_DATETIME:
foreach ($pa_value_list as $vn_locale_id => $va_values) {
if ($pa_options['useLocaleCodes']) {
if (!$vn_locale_id || !($vm_locale_id = $this->opo_locales->localeIDToCode($vn_locale_id))) {
$vm_locale_id = __CA_DEFAULT_LOCALE__;
}
} else {
if (!($vm_locale_id = $vn_locale_id)) {
$vm_locale_id = $this->opo_locales->localeCodeToID(__CA_DEFAULT_LOCALE__);
}
}
foreach ($va_values as $vn_i => $va_value) {
$va_ids[] = $vn_id = $va_value[$vs_pk];
if (in_array($va_field_info['FIELD_TYPE'], array(FT_TIMESTAMP, FT_DATETIME, FT_HISTORIC_DATETIME))) {
$vs_prop = $va_value[$va_path_components['field_name']];
if (!$vb_get_direct_date && !$vb_sortable) {
$this->opo_tep->init();
if ($va_field_info['FIELD_TYPE'] !== FT_HISTORIC_DATETIME) {
$this->opo_tep->setUnixTimestamps($vs_prop, $vs_prop);
} else {
$this->opo_tep->setHistoricTimestamps($vs_prop, $vs_prop);
}
$vs_prop = $this->opo_tep->getText($pa_options);
}
} elseif ($vb_get_direct_date) {
$vs_prop = $va_value[$va_field_info['START']];
} elseif ($vb_sortable) {
$vs_prop = $va_value[$va_field_info['START']];
} else {
$this->opo_tep->init();
if ($va_field_info['FIELD_TYPE'] == FT_DATERANGE) {
$this->opo_tep->setUnixTimestamps($va_value[$va_field_info['START']], $va_value[$va_field_info['END']]);
} else {
$this->opo_tep->setHistoricTimestamps($va_value[$va_field_info['START']], $va_value[$va_field_info['END']]);
}
$vs_prop = $this->opo_tep->getText($pa_options);
}
if ($vb_return_as_link) {
$vs_prop = array_shift(caCreateLinksFromText(array($vs_prop), $vs_table_name, array($vn_id)));
}
$va_return_values[$vn_id][$vm_locale_id] = $vs_prop;
}
}
break;
case FT_MEDIA:
if (!($vs_version = $va_path_components['subfield_name'])) {
$vs_version = "largeicon";
// TODO: fix
}
foreach ($pa_value_list as $vn_locale_id => $va_values) {
if ($pa_options['useLocaleCodes']) {
if (!$vn_locale_id || !($vm_locale_id = $this->opo_locales->localeIDToCode($vn_locale_id))) {
$vm_locale_id = __CA_DEFAULT_LOCALE__;
}
} else {
if (!($vm_locale_id = $vn_locale_id)) {
$vm_locale_id = $this->opo_locales->localeCodeToID(__CA_DEFAULT_LOCALE__);
}
}
foreach ($va_values as $vn_i => $va_value) {
$va_ids[] = $vn_id = $va_value[$vs_pk];
$o_media_settings = new MediaProcessingSettings($va_path_components['table_name'], $va_path_components['field_name']);
$va_versions = $o_media_settings->getMediaTypeVersions('*');
if (!isset($va_versions[$vs_version])) {
$va_tmp = array_keys($va_versions);
$vs_version = array_shift($va_tmp);
}
// See if an info element was passed, eg. ca_object_representations.media.icon.width should return the width of the media rather than a tag or url to the media
$vs_info_element = $va_path_components['num_components'] == 4 ? $va_path_components['components'][3] : null;
if ($pa_options['unserialize']) {
$va_return_values[$vn_id][$vm_locale_id] = caUnserializeForDatabase($va_value[$va_path_components['field_name']]);
} elseif ($vs_info_element) {
$va_return_values[$vn_id][$vm_locale_id] = $this->getMediaInfo($va_path_components['table_name'] . '.' . $va_path_components['field_name'], $vs_version, $vs_info_element, $pa_options);
} elseif (isset($pa_options['returnURL']) && $pa_options['returnURL']) {
$va_return_values[$vn_id][$vm_locale_id] = $this->getMediaUrl($va_path_components['table_name'] . '.' . $va_path_components['field_name'], $vs_version, $pa_options);
} elseif (isset($pa_options['returnPath']) && $pa_options['returnPath']) {
//.........这里部分代码省略.........
示例5: 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;
}
}
//.........这里部分代码省略.........
示例6: model
public static function model($tableName = '', $className = __CLASS__)
{
self::$tableName = $tableName;
return parent::model($className);
}