本文整理汇总了PHP中TimeExpressionParser::setHistoricTimestamps方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeExpressionParser::setHistoricTimestamps方法的具体用法?PHP TimeExpressionParser::setHistoricTimestamps怎么用?PHP TimeExpressionParser::setHistoricTimestamps使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeExpressionParser
的用法示例。
在下文中一共展示了TimeExpressionParser::setHistoricTimestamps方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getDisplayValue
/**
* Options:
* rawDate - if true, returns date as an array of start and end historic timestames
* sortable - if true a language-independent sortable representation is returned.
* getDirectDate - get underlying historic timestamp (floatval)
*/
public function getDisplayValue($pa_options = null)
{
if (!is_array($pa_options)) {
$pa_options = array();
}
if (isset($pa_options['rawDate']) && $pa_options['rawDate']) {
return array(0 => $this->opn_start_date, 1 => $this->opn_end_date, 'start' => $this->opn_start_date, 'end' => $this->opn_end_date);
}
if (caGetOption('GET_DIRECT_DATE', $pa_options, false) || caGetOption('getDirectDate', $pa_options, false)) {
return $this->opn_start_date;
}
if (isset($pa_options['sortable']) && $pa_options['sortable']) {
if (!$this->opn_start_date || !$this->opn_end_date) {
return null;
}
return $this->opn_start_date . '/' . $this->opn_end_date;
}
$o_date_config = Configuration::load(__CA_CONF_DIR__ . '/datetime.conf');
$vs_date_format = $o_date_config->get('dateFormat');
$vs_cache_key = md5($vs_date_format . $this->opn_start_date . $this->opn_end_date);
// pull from cache
if (isset(DateRangeAttributeValue::$s_date_cache[$vs_cache_key])) {
return DateRangeAttributeValue::$s_date_cache[$vs_cache_key];
}
// if neither start nor end date are set, the setHistoricTimestamps() call below will
// fail and the TEP will return the text for whatever happened to be parsed previously
// so we have to init() before trying
DateRangeAttributeValue::$o_tep->init();
if ($vs_date_format == 'original') {
return DateRangeAttributeValue::$s_date_cache[$vs_cache_key] = $this->ops_text_value;
} else {
if (!is_array($va_settings = MemoryCache::fetch($this->getElementID(), 'ElementSettings'))) {
$t_element = new ca_metadata_elements($this->getElementID());
$va_settings = MemoryCache::fetch($this->getElementID(), 'ElementSettings');
}
DateRangeAttributeValue::$o_tep->setHistoricTimestamps($this->opn_start_date, $this->opn_end_date);
return DateRangeAttributeValue::$s_date_cache[$vs_cache_key] = DateRangeAttributeValue::$o_tep->getText(array_merge(array('isLifespan' => $va_settings['isLifespan']), $pa_options));
//$this->ops_text_value;
}
}
示例2: caGetLocalizedHistoricDateRange
/**
* Returns date range as a localized string for display, subject to the settings in the app/conf/datetime.conf configuration
*
* @param int $pn_start_timestamp Historic start timestamp for date range to localize
* @param int $pn_end_timestamp Historic end timestamp for date range to localize
* @param array $pa_options All options supported by TimeExpressionParser::getText() are supported
*
* @return string Localized date/time expression
*/
function caGetLocalizedHistoricDateRange($pn_start_timestamp, $pn_end_timestamp, $pa_options = null)
{
$o_tep = new TimeExpressionParser();
$o_tep->setHistoricTimestamps($pn_start_timestamp, $pn_end_timestamp);
return $o_tep->getText($pa_options);
}
示例3: get
//.........这里部分代码省略.........
$t_locale = new ca_locales($vs_prop);
$vs_prop = $t_locale->getName();
} else {
if (isset($pa_options['convertCodesToDisplayText']) && $pa_options['convertCodesToDisplayText'] && is_array($va_list = $this->getFieldInfo($ps_field, "BOUNDS_CHOICE_LIST"))) {
foreach ($va_list as $vs_option => $vs_value) {
if ($vs_value == $vs_prop) {
$vs_prop = $vs_option;
break;
}
}
}
}
}
}
if (isset($pa_options["CONVERT_HTML_BREAKS"]) && $pa_options["CONVERT_HTML_BREAKS"] || isset($pa_options["convertLineBreaks"]) && $pa_options["convertLineBreaks"]) {
$vs_prop = caConvertLineBreaks($vs_prop);
}
break;
case FT_DATETIME:
case FT_TIMESTAMP:
case FT_HISTORIC_DATETIME:
case FT_HISTORIC_DATE:
case FT_DATE:
$vn_timestamp = isset($this->_FIELD_VALUES[$ps_field]) ? $this->_FIELD_VALUES[$ps_field] : 0;
if ($vb_return_with_structure) {
$vs_prop = array('start' => $this->_FIELD_VALUES[$ps_field], 'end' => $this->_FIELD_VALUES[$ps_field]);
} elseif (caGetOption('GET_DIRECT_DATE', $pa_options, false) || caGetOption('getDirectDate', $pa_options, false) || caGetOption('rawDate', $pa_options, false)) {
$vs_prop = $this->_FIELD_VALUES[$ps_field];
} elseif (isset($pa_options['sortable']) && $pa_options['sortable']) {
$vs_prop = $vn_timestamp . "/" . $vn_timestamp;
} else {
$o_tep = new TimeExpressionParser();
if ($ps_field_type == FT_HISTORIC_DATETIME || $ps_field_type == FT_HISTORIC_DATE) {
$o_tep->setHistoricTimestamps($vn_timestamp, $vn_timestamp);
} else {
$o_tep->setUnixTimestamps($vn_timestamp, $vn_timestamp);
}
if ($ps_field_type == FT_DATE || $ps_field_type == FT_HISTORIC_DATE) {
$vs_prop = $o_tep->getText(array_merge(array('timeOmit' => true), $pa_options));
} else {
$vs_prop = $o_tep->getText($pa_options);
}
}
break;
case FT_TIME:
if ($vb_return_with_structure) {
$vs_prop = array('start' => $this->_FIELD_VALUES[$ps_field], 'end' => $this->_FIELD_VALUES[$ps_field]);
} elseif (caGetOption('GET_DIRECT_TIME', $pa_options, false) || caGetOption('getDirectTime', $pa_options, false) || caGetOption('rawTime', $pa_options, false)) {
$vs_prop = $this->_FIELD_VALUES[$ps_field];
} else {
$o_tep = new TimeExpressionParser();
$vn_timestamp = isset($this->_FIELD_VALUES[$ps_field]) ? $this->_FIELD_VALUES[$ps_field] : 0;
$o_tep->setTimes($vn_timestamp, $vn_timestamp);
$vs_prop = $o_tep->getText($pa_options);
}
break;
case FT_DATERANGE:
case FT_HISTORIC_DATERANGE:
$vs_start_field_name = $this->getFieldInfo($ps_field, "START");
$vs_end_field_name = $this->getFieldInfo($ps_field, "END");
$vn_start_date = isset($this->_FIELD_VALUES[$vs_start_field_name]) ? $this->_FIELD_VALUES[$vs_start_field_name] : null;
$vn_end_date = isset($this->_FIELD_VALUES[$vs_end_field_name]) ? $this->_FIELD_VALUES[$vs_end_field_name] : null;
if ($vb_return_with_structure) {
$vs_prop = array('start' => $vn_start_date, 'end' => $vn_end_date);
} elseif (!caGetOption('GET_DIRECT_DATE', $pa_options, false) && !caGetOption('getDirectDate', $pa_options, false) && !caGetOption('rawDate', $pa_options, false)) {
$o_tep = new TimeExpressionParser();
示例4: getRelatedItems
//.........这里部分代码省略.........
$va_selects[] = $t_item_rel->tableName() . ".rank";
} else {
if ($t_rel_item && ($vs_sort = $t_rel_item->getProperty('ID_NUMBERING_SORT_FIELD'))) {
$vs_order_by = " ORDER BY " . $t_rel_item->tableName() . ".{$vs_sort}";
$vs_sort_fld = $vs_sort;
$va_selects[] = $t_rel_item->tableName() . ".{$vs_sort}";
}
}
$vs_sql = "\n\t\t\t\t\tSELECT " . join(', ', $va_selects) . "\n\t\t\t\t\tFROM " . $va_path[0] . "\n\t\t\t\t\t" . join("\n", array_merge($va_joins, $va_joins_post_add)) . "\n\t\t\t\t\tWHERE\n\t\t\t\t\t\t" . join(' AND ', array_merge($va_wheres, array('(' . $va_path[1] . '.' . $vs_other_field . ' IN (' . join(',', $va_row_ids) . '))'))) . "\n\t\t\t\t\t{$vs_order_by}";
//print "<pre>$vs_sql</pre>\n";
$qr_res = $o_db->query($vs_sql);
if ($vb_uses_relationship_types) {
$va_rel_types = $t_rel->getRelationshipInfo($va_path[1]);
}
$vn_c = 0;
if ($vn_start > 0) {
$qr_res->seek($vn_start);
}
while ($qr_res->nextRow()) {
if ($vn_c >= $vn_limit) {
break;
}
$va_row = $qr_res->getRow();
$vn_id = $va_row[$vs_key] . '/' . $va_row['row_id'];
$vs_sort_key = $qr_res->get($vs_sort_fld);
$vs_display_label = $va_row[$vs_label_display_field];
//unset($va_row[$vs_label_display_field]);
if (!$va_rels[$vs_sort_key][$vn_id]) {
$va_rels[$vs_sort_key][$vn_id] = $qr_res->getRow();
}
if ($vb_uses_effective_dates) {
// return effective dates as display/parse-able text
if ($va_rels[$vs_sort_key][$vn_id]['sdatetime'] || $va_rels[$vs_sort_key][$vn_id]['edatetime']) {
$o_tep->setHistoricTimestamps($va_rels[$vs_sort_key][$vn_id]['sdatetime'], $va_rels[$vs_sort_key][$vn_id]['edatetime']);
$va_rels[$vs_sort_key][$vn_id]['effective_date'] = $o_tep->getText();
}
}
$vn_locale_id = $qr_res->get('locale_id');
if (isset($pa_options['returnLocaleCodes']) && $pa_options['returnLocaleCodes']) {
$va_rels[$vs_v]['locale_id'] = $vn_locale_id = $t_locale->localeIDToCode($vn_locale_id);
}
$va_rels[$vs_sort_key][$vn_id]['labels'][$vn_locale_id] = $vb_return_labels_as_array ? $va_row : $vs_display_label;
$va_rels[$vs_sort_key][$vn_id]['_key'] = $vs_key;
$va_rels[$vs_sort_key][$vn_id]['direction'] = $vs_direction;
$vn_c++;
if ($vb_uses_relationship_types) {
$va_rels[$vs_sort_key][$vn_id]['relationship_typename'] = $vs_direction == 'ltor' ? $va_rel_types[$va_row['relationship_type_id']]['typename'] : $va_rel_types[$va_row['relationship_type_id']]['typename_reverse'];
$va_rels[$vs_sort_key][$vn_id]['relationship_type_code'] = $va_rel_types[$va_row['relationship_type_id']]['type_code'];
}
//
// Return data in an arrangement more convenient for the data importer
//
if ($pa_options['groupFields']) {
$vs_rel_pk = $t_rel_item->primaryKey();
if ($t_rel_item_label) {
foreach ($t_rel_item_label->getFormFields() as $vs_field => $va_field_info) {
if (!isset($va_rels[$vs_v][$vs_field]) || $vs_field == $vs_rel_pk) {
continue;
}
$va_rels[$vs_v]['preferred_labels'][$vs_field] = $va_rels[$vs_v][$vs_field];
unset($va_rels[$vs_v][$vs_field]);
}
}
foreach ($t_rel_item->getFormFields() as $vs_field => $va_field_info) {
if (!isset($va_rels[$vs_v][$vs_field]) || $vs_field == $vs_rel_pk) {
continue;
示例5: getDisplayValue
/**
* Options:
* rawDate - if true, returns date as an array of start and end historic timestames
* sortable - if true a language-independent sortable representation is returned.
* getDirectDate - get underlying historic timestamp (floatval)
*/
public function getDisplayValue($pa_options = null)
{
if (!is_array($pa_options)) {
$pa_options = array();
}
if (isset($pa_options['rawDate']) && $pa_options['rawDate']) {
return array(0 => $this->opn_start_date, 1 => $this->opn_end_date, 'start' => $this->opn_start_date, 'end' => $this->opn_end_date);
}
if (isset($pa_options['GET_DIRECT_DATE']) && $pa_options['GET_DIRECT_DATE'] || isset($pa_options['getDirectDate']) && $pa_options['getDirectDate']) {
return $this->opn_start_date;
}
if (isset($pa_options['sortable']) && $pa_options['sortable']) {
if (!$this->opn_start_date || !$this->opn_end_date) {
return null;
}
return $this->opn_start_date . '/' . $this->opn_end_date;
}
$o_config = Configuration::load();
$o_date_config = Configuration::load($o_config->get('datetime_config'));
if ($o_date_config->get('dateFormat') == 'original') {
return $this->ops_text_value;
} else {
$t_element = new ca_metadata_elements($this->getElementID());
$va_settings = $this->getSettingValuesFromElementArray($t_element->getFieldValuesArray(), array('isLifespan'));
$o_tep = new TimeExpressionParser();
$o_tep->setHistoricTimestamps($this->opn_start_date, $this->opn_end_date);
return $o_tep->getText(array_merge(array('isLifespan' => $va_settings['isLifespan']), $pa_options));
//$this->ops_text_value;
}
}