本文整理汇总了PHP中TimeExpressionParser::init方法的典型用法代码示例。如果您正苦于以下问题:PHP TimeExpressionParser::init方法的具体用法?PHP TimeExpressionParser::init怎么用?PHP TimeExpressionParser::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeExpressionParser
的用法示例。
在下文中一共展示了TimeExpressionParser::init方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getUsers
/**
* Returns array of users associated with the currently loaded row. The array
* is key'ed on user user user_id; each value is an array containing information about the user. Array keys are:
* user_id [user_id for user]
* user_name [name of user]
* code [short alphanumeric code identifying the group]
* description [text description of group]
*
* @return array List of groups associated with the currently loaded row
*/
public function getUsers($pa_options = null)
{
if (!($vn_id = (int) $this->getPrimaryKey())) {
return null;
}
if (!($vs_user_rel_table = $this->getProperty('USERS_RELATIONSHIP_TABLE'))) {
return null;
}
$vs_pk = $this->primaryKey();
if (!is_array($pa_options)) {
$pa_options = array();
}
$vb_return_for_bundle = isset($pa_options['returnAsInitialValuesForBundle']) && $pa_options['returnAsInitialValuesForBundle'] ? true : false;
$o_dm = Datamodel::load();
$t_rel = $o_dm->getInstanceByTableName($vs_user_rel_table);
$vb_supports_date_restrictions = (bool) $t_rel->hasField('effective_date');
$o_tep = new TimeExpressionParser();
$o_db = $this->getDb();
$qr_res = $o_db->query("\n\t\t\t\tSELECT u.*, r.*\n\t\t\t\tFROM {$vs_user_rel_table} r\n\t\t\t\tINNER JOIN ca_users AS u ON u.user_id = r.user_id\n\t\t\t\tWHERE\n\t\t\t\t\tr.{$vs_pk} = ?\n\t\t\t", $vn_id);
$va_users = array();
$va_user_ids = $qr_res->getAllFieldValues("user_id");
if ($qr_users = $this->makeSearchResult('ca_users', $va_user_ids)) {
$va_initial_values = caProcessRelationshipLookupLabel($qr_users, new ca_users(), array('stripTags' => true));
} else {
$va_initial_values = array();
}
$qr_res->seek(0);
while ($qr_res->nextRow()) {
$va_row = array();
foreach (array('user_id', 'user_name', 'fname', 'lname', 'email', 'sdatetime', 'edatetime', 'access') as $vs_f) {
$va_row[$vs_f] = $qr_res->get($vs_f);
}
if ($vb_supports_date_restrictions) {
$o_tep->init();
$o_tep->setUnixTimestamps($qr_res->get('sdatetime'), $qr_res->get('edatetime'));
$va_row['effective_date'] = $o_tep->getText();
}
if ($vb_return_for_bundle) {
$va_row['label'] = $va_initial_values[$va_row['user_id']]['label'];
$va_row['id'] = $va_row['user_id'];
$va_users[(int) $qr_res->get('relation_id')] = $va_row;
} else {
$va_users[(int) $qr_res->get('user_id')] = $va_row;
}
}
return $va_users;
}