本文整理汇总了PHP中TimeExpressionParser类的典型用法代码示例。如果您正苦于以下问题:PHP TimeExpressionParser类的具体用法?PHP TimeExpressionParser怎么用?PHP TimeExpressionParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimeExpressionParser类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: testGets
public function testGets()
{
$vm_ret = $this->opt_object->get('ca_objects.type_id', array('convertCodesToDisplayText' => true));
$this->assertEquals('Moving Image', $vm_ret);
$vm_ret = $this->opt_object->get('ca_objects.preferred_labels');
$this->assertEquals('My test moving image', $vm_ret);
$vm_ret = $this->opt_object->get('ca_objects.duration');
$this->assertEquals('0:23:28', $vm_ret);
$vm_ret = $this->opt_object->get('ca_objects.access');
$this->assertEquals('0', $vm_ret);
$vm_ret = $this->opt_object->get('ca_objects.access', array('convertCodesToDisplayText' => true));
$this->assertEquals('not accessible to public', $vm_ret);
$o_tep = new TimeExpressionParser();
$vn_now = time();
$vm_ret = $this->opt_object->get('ca_objects.lastModified');
$this->assertTrue($o_tep->parse($vm_ret));
$va_modified_unix = $o_tep->getUnixTimestamps();
//$this->assertEquals($vn_now, $va_modified_unix['start'], 'lastModified timestamp cannot be more than 1 minute off', 60);
}
开发者ID:samrahman,项目名称:providence,代码行数:19,代码来源:SimpleGetTest.php
示例2: testGets
public function testGets()
{
$vm_ret = $this->opt_object->get('ca_objects.type_id', array('convertCodesToDisplayText' => true));
$this->assertEquals('Moving Image', $vm_ret);
$vm_ret = $this->opt_object->get('ca_objects.preferred_labels');
$this->assertEquals('My test moving image', $vm_ret);
$vm_ret = $this->opt_object->get('ca_objects.duration');
$this->assertEquals('0:23:28', $vm_ret);
$vm_ret = $this->opt_object->get('ca_item_comments.comment');
$this->assertEquals('I like this very much.', $vm_ret);
$this->assertTrue(!is_numeric($this->opt_object->get('ca_item_comments.created_on')));
// should always be current date/time as text
$o_tep = new TimeExpressionParser();
$vn_now = time();
$vm_ret = $this->opt_object->get('ca_objects.lastModified');
$this->assertTrue($o_tep->parse($vm_ret));
$va_modified_unix = $o_tep->getUnixTimestamps();
//$this->assertEquals($vn_now, $va_modified_unix['start'], 'lastModified timestamp cannot be more than 1 minute off', 60);
}
开发者ID:idiscussforum,项目名称:providence,代码行数:19,代码来源:SimpleGetTest.php
示例3: search
/**
*
*/
public function search($ps_datetime_expression, $ps_code = null)
{
$o_tep = new TimeExpressionParser();
if ($o_tep->parse($ps_datetime_expression)) {
list($vn_period_start, $vn_period_end) = $o_tep->getUnixTimestamps();
if ($vn_period_start && $vn_period_end) {
$o_db = new Db();
$qr_log = $o_db->query("\n\t\t\t\t\tSELECT sl.*, u.fname, u.lname, u.email, sfl.name form\n\t\t\t\t\tFROM ca_search_log sl\n\t\t\t\t\tLEFT JOIN ca_users AS u ON sl.user_id = u.user_id\n\t\t\t\t\tLEFT JOIN ca_search_form_labels AS sfl ON sl.form_id = sfl.form_id\n\t\t\t\t\tWHERE \n\t\t\t\t\t\t(log_datetime BETWEEN {$vn_period_start} AND {$vn_period_end})\n\t\t\t\t\tORDER BY log_datetime DESC\n\t\t\t\t");
$o_dm = Datamodel::load();
$va_rows = array();
while ($qr_log->nextRow()) {
$va_row = $qr_log->getRow();
$t_table = $o_dm->getInstanceByTableNum($va_row['table_num'], true);
$va_row['table_name'] = $t_table->getProperty('NAME_PLURAL');
$va_row['user_name'] = $va_row['fname'] . ' ' . $va_row['lname'];
$va_rows[$va_row['search_id']] = $va_row;
}
return $va_rows;
}
}
return null;
}
开发者ID:idiscussforum,项目名称:providence,代码行数:25,代码来源:Searchlog.php
示例4: 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;
}
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:57,代码来源:LabelableBaseModelWithAttributes.php
示例5: _doQueriesForSqlSearch
//.........这里部分代码省略.........
}
if (get_class($o_lucene_query_element) != 'Zend_Search_Lucene_Search_Query_MultiTerm') {
$vs_stripped_term = preg_replace('!\\*+$!u', '', $vs_term);
// do stemming
if ($this->opb_do_stemming) {
$vs_to_stem = preg_replace('!\\*$!u', '', $vs_term);
if (!preg_match('!y$!u', $vs_to_stem) && !preg_match('![0-9]+!', $vs_to_stem)) {
// don't stem things ending in 'y' as that can cause problems (eg "Bowery" becomes "Boweri")
if (!($vs_stem = trim($this->opo_stemmer->stem($vs_to_stem)))) {
$vs_stem = (string) $vs_term;
}
$va_ft_stem_terms[] = "'" . $this->opo_db->escape($vs_stem) . "'";
} else {
$va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
}
} else {
$va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
}
$vb_output_term = true;
}
}
if ($vb_output_term) {
$va_raw_terms[] = $vs_term;
} else {
$vn_i--;
}
break;
}
$vs_fld_num = $vs_table_num = $t_table = null;
$vb_ft_bit_optimization = false;
if ($vs_access_point) {
list($vs_table, $vs_field, $vs_sub_field) = explode('.', $vs_access_point);
if (in_array($vs_table, array('created', 'modified'))) {
$o_tep = new TimeExpressionParser();
$vs_date = join(' ', $va_raw_terms);
if (!$o_tep->parse($vs_date)) {
break;
}
$va_range = $o_tep->getUnixTimestamps();
$vn_user_id = null;
if ($vs_field = trim($vs_field)) {
if (!is_int($vs_field)) {
$t_user = new ca_users();
if ($t_user->load(array("user_name" => $vs_field))) {
$vn_user_id = (int) $t_user->getPrimaryKey();
}
} else {
$vn_user_id = (int) $vs_field;
}
}
$vs_user_sql = $vn_user_id ? " AND (ccl.user_id = " . (int) $vn_user_id . ")" : "";
switch ($vs_table) {
case 'created':
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.logged_table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.changetype = 'I')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
break;
case 'modified':
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.logged_table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.changetype = 'U')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccls.subject_row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_change_log_subjects AS ccls ON ccls.log_id = ccl.log_id\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccls.subject_table_num = {$pn_subject_tablenum})\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
break;
}
} else {
if ($vs_table && $vs_field) {
$t_table = $this->opo_datamodel->getInstanceByTableName($vs_table, true);
if ($t_table) {
$vs_table_num = $t_table->tableNum();
if (is_numeric($vs_field)) {
$vs_fld_num = 'I' . $vs_field;
开发者ID:guaykuru,项目名称:pawtucket,代码行数:67,代码来源:SqlSearch.php
示例6: caSortableValue
/**
* Convert text into string suitable for sorting, by moving articles to end of string, etc.
*
* @param string $ps_text Text to convert to sortable value
* @param array $pa_options Options include:
* locale = Locale settings to use. If omitted current default locale is used. [Default is current locale]
* omitArticle = Omit leading definite and indefinited articles, rather than moving them to the end of the text [Default is true]
*
* @return string Converted text. If locale cannot be found $ps_text is returned unchanged.
*/
function caSortableValue($ps_text, $pa_options = null)
{
global $g_ui_locale;
$ps_locale = caGetOption('locale', $pa_options, $g_ui_locale);
if (!$ps_locale) {
return $ps_text;
}
$pb_omit_article = caGetOption('omitArticle', $pa_options, true);
$o_locale_settings = TimeExpressionParser::getSettingsForLanguage($ps_locale);
$vs_display_value = trim(preg_replace('![^\\p{L}0-9 ]+!u', ' ', $ps_text));
// Move articles to end of string
$va_definite_articles = $o_locale_settings ? $o_locale_settings->get('definiteArticles') : array();
$va_indefinite_articles = $o_locale_settings ? $o_locale_settings->get('indefiniteArticles') : array();
foreach (array($va_definite_articles, $va_indefinite_articles) as $va_articles) {
if (is_array($va_articles)) {
foreach ($va_articles as $vs_article) {
if (preg_match('!^(' . $vs_article . ')[ ]+!i', $vs_display_value, $va_matches)) {
$vs_display_value = trim(str_replace($va_matches[1], '', $vs_display_value) . ($pb_omit_article ? '' : ', ' . $va_matches[1]));
break 2;
}
}
}
}
// Left-pad numbers
if (preg_match("![\\d]+!", $vs_display_value, $va_matches)) {
for ($i = 0; $i < sizeof($va_matches); $i++) {
$vs_padded = str_pad($va_matches[$i], 15, 0, STR_PAD_LEFT);
$vs_display_value = str_replace($va_matches[$i], $vs_padded, $vs_display_value);
}
}
return $vs_display_value;
}
开发者ID:samrahman,项目名称:providence,代码行数:42,代码来源:utilityHelpers.php
示例7: caGetISODates
/**
*
*
* @param string $ps_date_expression Start of date range, as Unix timestamp
* @param array $pa_options All options supported by TimeExpressionParser::getText() are supported
*
* @return array
*/
function caGetISODates($ps_date_expression, $pa_options = null)
{
if (!is_array($pa_options)) {
$pa_options = array();
}
$o_tep = new TimeExpressionParser();
if (!$o_tep->parse($ps_date_expression)) {
return null;
}
return array('start' => $o_tep->getText(array_merge($pa_options, array('start_as_iso8601' => true))), 'end' => $o_tep->getText(array_merge($pa_options, array('end_as_iso8601' => true))));
}
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:19,代码来源:utilityHelpers.php
示例8: now
/**
* Return current date/time
*
* @param array $pa_options Options include:
* format = format of return value. Options are:
* unix = Unix-timestamp
* historic = Historic timestamp
* [Default is historic]
*
*/
public static function now($pa_options = null)
{
$ps_format = caGetOption('format', $pa_options, null, ['toLowerCase' => true]);
$o_tep = new TimeExpressionParser();
$o_tep->parse(__TEP_NOW__);
switch ($ps_format) {
case 'unix':
return array_shift($o_tep->getUnixTimestamps());
break;
case 'historic':
default:
return array_shift($o_tep->getHistoricTimestamps());
break;
}
return null;
}
开发者ID:samrahman,项目名称:providence,代码行数:26,代码来源:TimeExpressionParser.php
示例9: _doQueriesForSqlSearch
//.........这里部分代码省略.........
$vb_do_stemming = $this->opb_do_stemming;
if (mb_substr($vs_term, -1) == '|') {
$vs_term = mb_substr($vs_term, 0, mb_strlen($vs_term) - 1);
$vb_do_stemming = false;
}
if ($vb_do_stemming) {
$vs_to_stem = preg_replace('!\\*$!u', '', $vs_term);
if (!preg_match('!y$!u', $vs_to_stem) && !preg_match('![0-9]+!', $vs_to_stem)) {
// don't stem things ending in 'y' as that can cause problems (eg "Bowery" becomes "Boweri")
if (!($vs_stem = trim($this->opo_stemmer->stem($vs_to_stem)))) {
$vs_stem = (string) $vs_term;
}
$va_ft_stem_terms[] = "'" . $this->opo_db->escape($vs_stem) . "'";
} else {
$va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
}
} else {
$va_ft_terms[] = '"' . $this->opo_db->escape($vs_term) . '"';
}
}
$vb_output_term = true;
}
if ($vb_output_term) {
$va_raw_terms[] = $vs_term;
}
}
break;
}
$vs_fld_num = $vs_table_num = $t_table = null;
$vb_ft_bit_optimization = false;
if ($vs_access_point) {
list($vs_table, $vs_field, $vs_sub_field) = explode('.', $vs_access_point);
if (in_array($vs_table, array('created', 'modified'))) {
$o_tep = new TimeExpressionParser();
$vs_date = join(' ', $va_raw_terms);
if (!$o_tep->parse($vs_date)) {
break;
}
$va_range = $o_tep->getUnixTimestamps();
$vn_user_id = null;
if ($vs_field = trim($vs_field)) {
if (!is_int($vs_field)) {
$t_user = new ca_users();
if ($t_user->load(array("user_name" => $vs_field))) {
$vn_user_id = (int) $t_user->getPrimaryKey();
}
} else {
$vn_user_id = (int) $vs_field;
}
}
$vs_user_sql = $vn_user_id ? " AND (ccl.user_id = " . (int) $vn_user_id . ")" : "";
switch ($vs_table) {
case 'created':
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.logged_table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.changetype = 'I')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
break;
case 'modified':
$vs_direct_sql_query = "\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccl.logged_row_id row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.logged_table_num = ?)\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.changetype = 'U')\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\tUNION\n\t\t\t\t\t\t\t\t\t\t\tSELECT ccls.subject_row_id row_id, 1\n\t\t\t\t\t\t\t\t\t\t\tFROM ca_change_log ccl\n\t\t\t\t\t\t\t\t\t\t\tINNER JOIN ca_change_log_subjects AS ccls ON ccls.log_id = ccl.log_id\n\t\t\t\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\t\t\t\t(ccl.log_datetime BETWEEN " . (int) $va_range['start'] . " AND " . (int) $va_range['end'] . ")\n\t\t\t\t\t\t\t\t\t\t\t\tAND\n\t\t\t\t\t\t\t\t\t\t\t\t(ccls.subject_table_num = {$pn_subject_tablenum})\n\t\t\t\t\t\t\t\t\t\t\t\t{$vs_user_sql}\n\t\t\t\t\t\t\t\t\t\t";
break;
}
} else {
if ($vs_table && $vs_field && ($t_table = $this->opo_datamodel->getInstanceByTableName($vs_table, true))) {
$vs_table_num = $t_table->tableNum();
if (is_numeric($vs_field)) {
$vs_fld_num = 'I' . $vs_field;
$vn_fld_num = (int) $vs_field;
} else {
开发者ID:ymani2435,项目名称:providence,代码行数:67,代码来源:SqlSearch.php
示例10: caSortableValue
/**
* Convert text into string suitable for sorting, by moving articles to end of string, etc.
*
* @param string $ps_text Text to convert to sortable value
* @param array $pa_options Options include:
* locale = Locale settings to use. If omitted current default locale is used. [Default is current locale]
*
* @return string Converted text. If locale cannot be found $ps_text is returned unchanged.
*/
function caSortableValue($ps_text, $pa_options = null)
{
global $g_ui_locale;
$ps_locale = caGetOption('locale', $pa_options, $g_ui_locale);
if (!$ps_locale) {
return $ps_text;
}
$o_locale_settings = TimeExpressionParser::getSettingsForLanguage($ps_locale);
$vs_display_value = trim(preg_replace('![^\\p{L}0-9 ]+!u', ' ', $ps_text));
$va_definite_articles = $o_locale_settings->get('definiteArticles');
$va_indefinite_articles = $o_locale_settings->get('indefiniteArticles');
foreach (array($va_definite_articles, $va_indefinite_articles) as $va_articles) {
if (is_array($va_articles)) {
foreach ($va_articles as $vs_article) {
if (preg_match('!^(' . $vs_article . ')[ ]+!i', $vs_display_value, $va_matches)) {
$vs_display_value = trim(str_replace($va_matches[1], '', $vs_display_value) . ', ' . $va_matches[1]);
break 2;
}
}
}
}
return $vs_display_value;
}
开发者ID:idiscussforum,项目名称:providence,代码行数:32,代码来源:utilityHelpers.php
示例11: getRelatedItems
//.........这里部分代码省略.........
if (($pa_options['restrictToRelationshipTypes'] = caGetOption(array('restrictToRelationshipTypes', 'restrict_to_relationship_types', 'restrictToRelationshipType', 'restrict_to_relationship_type'), $pa_options, null)) && !is_array($pa_options['restrictToRelationshipTypes'])) {
$pa_options['restrictToRelationshipTypes'] = array($pa_options['restrictToRelationshipTypes']);
}
if (($pa_options['excludeTypes'] = caGetOption(array('excludeTypes', 'exclude_types', 'excludeType', 'exclude_type'), $pa_options, null)) && !is_array($pa_options['excludeTypes'])) {
$pa_options['excludeTypes'] = array($pa_options['excludeTypes']);
}
if (($pa_options['excludeRelationshipTypes'] = caGetOption(array('excludeRelationshipTypes', 'exclude_relationship_types', 'excludeRelationshipType', 'exclude_relationship_type'), $pa_options, null)) && !is_array($pa_options['excludeRelationshipTypes'])) {
$pa_options['excludeRelationshipTypes'] = array($pa_options['excludeRelationshipTypes']);
}
if (!isset($pa_options['dontIncludeSubtypesInTypeRestriction']) && (isset($pa_options['dont_include_subtypes_in_type_restriction']) && $pa_options['dont_include_subtypes_in_type_restriction'])) {
$pa_options['dontIncludeSubtypesInTypeRestriction'] = $pa_options['dont_include_subtypes_in_type_restriction'];
}
if (!isset($pa_options['returnNonPreferredLabels']) && (isset($pa_options['restrict_to_type']) && $pa_options['restrict_to_type'])) {
$pa_options['returnNonPreferredLabels'] = $pa_options['restrict_to_type'];
}
if (!isset($pa_options['returnLabelsAsArray']) && (isset($pa_options['return_labels_as_array']) && $pa_options['return_labels_as_array'])) {
$pa_options['returnLabelsAsArray'] = $pa_options['return_labels_as_array'];
}
if (!isset($pa_options['restrictToLists']) && (isset($pa_options['restrict_to_lists']) && $pa_options['restrict_to_lists'])) {
$pa_options['restrictToLists'] = $pa_options['restrict_to_lists'];
}
$pb_group_fields = isset($pa_options['groupFields']) ? $pa_options['groupFields'] : false;
$pa_primary_ids = isset($pa_options['primaryIDs']) && is_array($pa_options['primaryIDs']) ? $pa_options['primaryIDs'] : null;
$pb_show_current_only = caGetOption('showCurrentOnly', $pa_options, caGetOption('currentOnly', $pa_options, false));
if (!isset($pa_options['useLocaleCodes']) && (isset($pa_options['returnLocaleCodes']) && $pa_options['returnLocaleCodes'])) {
$pa_options['useLocaleCodes'] = $pa_options['returnLocaleCodes'];
}
$pb_use_locale_codes = isset($pa_options['useLocaleCodes']) ? $pa_options['useLocaleCodes'] : false;
$pa_get_where = isset($pa_options['where']) && is_array($pa_options['where']) && sizeof($pa_options['where']) ? $pa_options['where'] : null;
$pa_row_ids = isset($pa_options['row_ids']) && is_array($pa_options['row_ids']) ? $pa_options['row_ids'] : null;
$pn_row_id = isset($pa_options['row_id']) && $pa_options['row_id'] ? $pa_options['row_id'] : $this->getPrimaryKey();
$o_db = $this->getDb();
$t_locale = $this->getLocaleInstance();
$o_tep = $this->getTimeExpressionParser();
$vb_uses_effective_dates = false;
if (isset($pa_options['sort']) && !is_array($pa_options['sort'])) {
$pa_options['sort'] = array($pa_options['sort']);
}
$pa_sort_fields = isset($pa_options['sort']) && is_array($pa_options['sort']) ? array_filter($pa_options['sort'], "strlen") : null;
$ps_sort_direction = isset($pa_options['sortDirection']) && $pa_options['sortDirection'] ? $pa_options['sortDirection'] : null;
if (!$pa_row_ids && $pn_row_id > 0) {
$pa_row_ids = array($pn_row_id);
}
if (!$pa_row_ids || !is_array($pa_row_ids) || !sizeof($pa_row_ids)) {
return array();
}
$pb_return_labels_as_array = isset($pa_options['returnLabelsAsArray']) && $pa_options['returnLabelsAsArray'] ? true : false;
$pn_limit = isset($pa_options['limit']) && (int) $pa_options['limit'] > 0 ? (int) $pa_options['limit'] : 1000;
$pn_start = isset($pa_options['start']) && (int) $pa_options['start'] > 0 ? (int) $pa_options['start'] : 0;
if (is_numeric($pm_rel_table_name_or_num)) {
if (!($vs_related_table_name = $this->getAppDatamodel()->getTableName($pm_rel_table_name_or_num))) {
return null;
}
} else {
if (sizeof($va_tmp = explode(".", $pm_rel_table_name_or_num)) > 1) {
$pm_rel_table_name_or_num = array_shift($va_tmp);
}
if (!($o_instance = $this->getAppDatamodel()->getInstanceByTableName($pm_rel_table_name_or_num, true))) {
return null;
}
$vs_related_table_name = $pm_rel_table_name_or_num;
}
if (!is_array($pa_options)) {
$pa_options = array();
}
$vb_is_combo_key_relation = false;
开发者ID:samrahman,项目名称:providence,代码行数:67,代码来源:BundlableLabelableBaseModelWithAttributes.php
示例12: listResponse
/**
* Responds to the two main List verbs, includes resumption and limiting.
*
* @param string $verb OAI-PMH verb for the request
* @param string $metadataPrefix Metadata prefix
* @param int $cursor Offset in response to begin output at
* @param mixed $set Optional set argument
* @param string $from Optional from date argument
* @param string $until Optional until date argument
* @uses createResumptionToken()
*/
private function listResponse($oaiData, $verb, $metadataPrefix, $cursor, $set, $from, $until)
{
$listLimit = $this->_listLimit;
$o_dm = Datamodel::load();
// by this point, the mapping code was checked to be valid
$t_instance = $o_dm->getInstanceByTableName($this->table, true);
$vs_pk = $t_instance->primaryKey();
$va_access_values = caGetUserAccessValues($this->opo_request, $this->opa_provider_info);
$vb_show_deleted = (bool) $this->opa_provider_info['show_deleted'];
$vb_dont_enforce_access_settings = (bool) $this->opa_provider_info['dont_enforce_access_settings'];
$vb_dont_cache = (bool) $this->opa_provider_info['dont_cache'];
$vs_table = $t_instance->tableName();
if (!($o_search = caGetSearchInstance($vs_table))) {
$this->throwError(self::OAI_ERR_BAD_ARGUMENT);
return;
}
// Construct date range for from/until if defined
$o_tep = new TimeExpressionParser();
$o_lang_settings = $o_tep->getLanguageSettings();
$vs_conj = array_shift($o_lang_settings->getList("rangeConjunctions"));
$vs_range = $from && $until ? "{$from} {$vs_conj} {$until}" : '';
if ($set && $this->opa_provider_info['setFacet']) {
$o_browse = caGetBrowseInstance($this->table);
if (($vs_query = $this->opa_provider_info['query']) && $vs_query != "*") {
$o_browse->addCriteria("_search", $vs_query);
}
$o_browse->addCriteria($this->opa_provider_info['setFacet'], $set);
$o_browse->execute(array('showDeleted' => $vb_show_deleted, 'no_cache' => $vb_dont_cache, 'limitToModifiedOn' => $vs_range, 'checkAccess' => $vb_dont_enforce_access_settings ? null : $va_access_values));
$qr_res = $o_browse->getResults();
} else {
$qr_res = $o_search->search(strlen($this->opa_provider_info['query']) ? $this->opa_provider_info['query'] : "*", array('no_cache' => $vb_dont_cache, 'limitToModifiedOn' => $vs_range, 'showDeleted' => $vb_show_deleted, 'checkAccess' => $vb_dont_enforce_access_settings ? null : $va_access_values));
}
if (!$qr_res) {
$this->throwError(self::OAI_ERR_NO_RECORDS_MATCH, _t('Query failed'));
return;
}
$rows = $qr_res->numHits();
if (count($qr_res->numHits()) == 0) {
$this->throwError(self::OAI_ERR_NO_RECORDS_MATCH, _t('No records match the given criteria'));
} else {
$verbElement = $oaiData->createElement($verb);
$oaiData->documentElement->appendChild($verbElement);
$t_change_log = new ApplicationChangeLog();
if ($vb_show_deleted) {
// get list of deleted records
$va_deleted_items = array();
$qr_res->seek($cursor);
$vn_c = 0;
$va_get_deleted_timestamps_for = array();
while ($qr_res->nextHit()) {
if ((bool) $qr_res->get("{$vs_table}.deleted")) {
$va_deleted_items[$vs_pk_val = (int) $qr_res->get("{$vs_table}.{$vs_pk}")] = true;
$va_get_deleted_timestamps_for[$vs_pk_val] = true;
} else {
$vn_access = (int) $qr_res->get("{$vs_table}.access");
if (!in_array($vn_access, $va_access_values)) {
$va_deleted_items[(int) $qr_res->get("{$vs_table}.{$vs_pk}")] = true;
}
}
$vn_c++;
if ($vn_c >= $listLimit) {
break;
}
}
$qr_res->seek(0);
$va_deleted_timestamps = $t_change_log->getDeleteOnTimestampsForIDs($vs_table, array_keys($va_get_deleted_timestamps_for));
}
// Export data using metadata mapping
$va_items = ca_data_exporters::exportRecordsFromSearchResultToArray($this->getMappingCode(), $qr_res, array('start' => $cursor, 'limit' => $listLimit));
if (is_array($va_items) && sizeof($va_items)) {
$va_timestamps = $t_change_log->getLastChangeTimestampsForIDs($vs_table, array_keys($va_items));
foreach ($va_items as $vn_id => $vs_item_xml) {
if ($vb_show_deleted && $va_deleted_items[$vn_id]) {
$headerData = array('identifier' => OaiIdentifier::itemToOaiId($vn_id), 'datestamp' => self::unixToUtc($va_deleted_timestamps[$vn_id]['timestamp'] ? $va_deleted_timestamps[$vn_id]['timestamp'] : $va_timestamps[$vn_id]['timestamp']));
if ($verb == 'ListIdentifiers') {
$header = $this->createElementWithChildren($oaiData, $verbElement, 'header', $headerData);
$header->setAttribute("status", "deleted");
} else {
$recordElement = $verbElement->appendChild($oaiData->createElement('record'));
$header = $this->createElementWithChildren($oaiData, $recordElement, 'header', $headerData);
$header->setAttribute("status", "deleted");
}
} else {
$headerData = array('identifier' => OaiIdentifier::itemToOaiId($vn_id), 'datestamp' => self::unixToUtc($va_timestamps[$vn_id]['timestamp']));
if ($verb == 'ListIdentifiers') {
$this->createElementWithChildren($oaiData, $verbElement, 'header', $headerData);
} else {
$recordElement = $verbElement->appendChild($oaiData->createElement('record'));
$this->createElementWithChildren($oaiData, $recordElement, 'header', $headerData);
//.........这里部分代码省略.........
开发者ID:samrahman,项目名称:providence,代码行数:101,代码来源:OAIPMHService.php
示例13: testNormalizationDecades
function testNormalizationDecades()
{
$o_tep = new TimeExpressionParser('16th century', 'en_US');
$va_historic = $o_tep->getHistoricTimestamps();
$va_decades_expected = array(1500 => '1500s', 1510 => '1510s', 1520 => '1520s', 1530 => '1530s', 1540 => '1540s', 1550 => '1550s', 1560 => '1560s', 1570 => '1570s', 1580 => '1580s', 1590 => '1590s');
$va_decades = $o_tep->normalizeDateRange($va_historic['start'], $va_historic['end'], 'decades');
$this->assertEquals(10, sizeof($va_decades));
$this->assertEquals($va_decades_expected, $va_decades);
}
开发者ID:idiscussforum,项目名称:providence,代码行数:9,代码来源:TimeExpressionParserTest.php
示例14: getComments
/**
*
*/
public function getComments($ps_mode = null, $pn_limit = null, $pa_options = null)
{
$o_db = $this->getDb();
$vs_where = '';
switch ($ps_mode) {
case 'moderated':
$vs_where = "WHERE cic.moderated_on IS NOT NULL";
break;
case 'unmoderated':
$vs_where = "WHERE cic.moderated_on IS NULL";
break;
}
if (intval($pn_limit) > 0) {
$vs_limit = " LIMIT " . intval($pn_limit);
}
$o_tep = new TimeExpressionParser();
$qr_res = $o_db->query("\n\t\t\tSELECT cic.*, u.user_id, u.fname, u.lname, u.email user_email\n\t\t\tFROM ca_item_comments cic\n\t\t\tLEFT JOIN ca_users AS u ON u.user_id = cic.user_id\n\t\t\t{$vs_where} ORDER BY cic.created_on DESC {$vs_limit}\n\t\t");
$o_datamodel = $this->getAppDatamodel();
$va_comments = array();
while ($qr_res->nextRow()) {
$vn_datetime = $qr_res->get('created_on');
$o_tep->setUnixTimestamps($vn_datetime, $vn_datetime);
$va_row = $qr_res->getRow();
$va_row['created_on'] = $o_tep->getText();
$t_table = $o_datamodel->getInstanceByTableNum($qr_res->get('table_num'), true);
if ($t_table->load($qr_res->get('row_id'))) {
$va_row['commented_on'] = $t_table->getLabelForDisplay(false);
if ($vs_idno = $t_table->get('idno')) {
$va_row['commented_on'] .= ' [' . $vs_idno . ']';
}
}
foreach (array("media1", "media2", "media3", "media4") as $vs_media_field) {
$va_media_versions = array();
$va_media_versions = $qr_res->getMediaVersions($vs_media_field);
$va_media = array();
if (is_array($va_media_versions) && sizeof($va_media_versions) > 0) {
foreach ($va_media_versions as $vs_version) {
$va_image_info = array();
$va_image_info = $qr_res->getMediaInfo($vs_media_field, $vs_version);
$va_image_info["TAG"] = $qr_res->getMediaTag($vs_media_field, $vs_version);
$va_image_info["URL"] = $qr_res->getMediaUrl($vs_media_field, $vs_version);
$va_media[$vs_version] = $va_image_info;
}
$va_row[$vs_media_field] = $va_media;
}
}
$va_comments[] = $va_row;
}
return $va_comments;
}
开发者ID:idiscussforum,项目名称:providence,代码行数:53,代码来源:ca_item_comments.php
示例15: getRelatedItems
/**
* Returns list of items in the specified table related to the currently loaded row.
*
* @param $pm_rel_table_name_or_num - the table name or table number of the item type you want to get a list of (eg. if you are calling this on an ca_objects instance passing 'ca_entities' here will get you a list of entities related to the object)
* @param $pa_options - array of options. Supported options are:
*
* restrict_to_type = restricts returned items to those of the specified type; only supports a single type which can be specified as a list item_code or item_id
* restrictToType = synonym for restrict_to_type
* restrict_to_types = restricts returned items to those of the specified types; pass an array of list item_codes or item_ids
* restrictToTypes = synonym for restrict_to_types
* dont_include_subtypes_in_type_restriction = if set subtypes are not included when enforcing restrict_to_types. Note that restrict_to_relationship_types always includes subtypes in its restriction.
* dontIncludeSubtypesInTypeRestriction = synonym for dont_include_subtypes_in_type_restriction
* restrict_to_relationship_types = restricts returned items to those related to the current row by the specified relationship type(s). You can pass either an array of types or a single type. The types can be relationship type_code's or type_id's.
* restrictToRelationshipTypes = synonym for restrict_to_relationship_types
*
* restrictToBundleValues = restricts returned items to bundle values in related table. pass an associative array with elements like this: bundle_name => list of values
*
* exclude_relationship_types = omits any items related to the current row with any of the specified types from the returned set of ids. You can pass either an array of types or a single type. The types can be relationship type_code's or type_id's.
* excludeRelationshipTypes = synonym for exclude_relationship_types
* exclude_type = excludes returned items of the specified type; only supports a single type which can be specified as a list item_code or item_id
* excludeType = synonym for exclude_type
* exclude_types = omits any items related to the current row that are of any of the specified types from the returned set of ids. You can pass either an array of types or a single type. The types can be type_code's or type_id's.
* excludeTypes = synonym for exclude_types
*
* restrict_to_lists = when fetching related ca_list_items restricts returned items to those that are in the specified lists; pass an array of list list_codes or list_ids
* restrictToLists = synonym for restrict_to_lists
*
* fields = array of fields (in table.fieldname format) to include in returned data
* return_non_preferred_labels = if set to true, non-preferred labels are included in returned data
* returnNonPreferredLabels = synonym for return_non_preferred_labels
* checkAccess = array of access values to filter results by; if defined only items with the specified access code(s) are returned
* return_labels_as_array = if set to true then all labels associated with row are returned in an array, otherwise only a text value in the current locale is returned; default is false - return single label in current locale
* returnLabelsAsArray = synonym for return_labels_as_array
* row_ids = array of primary key values to use when fetching related items; if omitted or set to a null value the 'row_id' option (single value) will be used; if row_id is also not set then the currently loaded primary key value will be used
* row_id = primary key value to use when fetching related items; if omitted or set to a false value (eg. null, false, 0) then the currently loaded primary key value is used [default]
* start = item to start return set at; first item is numbered zero; default is 0
* limit = number of items to limit return set to; default is 1000
* sort = optional array of bundles to sort returned values on. Currently only supported when getting related values via simple related <table_name> and <table_name>.related invokations. Eg. from a ca_objects results you can use the 'sort' option got get('ca_entities'), get('ca_entities.related') or get('ca_objects.related'). The bundle specifiers are fields with or without tablename. Only those fields returned for the related tables (intrinsics, label fields and attributes) are sortable.
* sortDirection = direction of sort. Valid values as "ASC" (ascending) and "DESC" (descending). Default is ASC.
* showDeleted = if set to true, related items that have been deleted are returned. Default is false.
* where = optional array of fields and field values to filter returned values on. The fields must be intrinsic and in the same table as the field being "get()'ed" Can be used to filter returned values from primary and related tables. This option can be useful when you want to fetch certain values from a related table. For example, you want to get the relationship source_info values, but only for relationships going to a specific related record. Note that multiple fields/values are effectively AND'ed together - all must match for a row to be returned - and that only equivalence is supported (eg. field equals value).
* user_id = If set item level access control is performed relative to specified user_id, otherwise defaults to logged in user
* groupFields = Groups together fields in an arrangement that is easier for import to another system. Used by the ItemInfo web service when in "import" mode. Default is false.
* returnLocaleCodes = Return locale values as codes (Ex. en_US)
|
请发表评论