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


PHP TimeExpressionParser::getHistoricTimestamps方法代码示例

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


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

示例1: parseValue

 public function parseValue($ps_value, $pa_element_info, $pa_options = null)
 {
     $o_date_config = Configuration::load(__CA_CONF_DIR__ . '/datetime.conf');
     $show_Undated = $o_date_config->get('showUndated');
     $ps_value = trim($ps_value);
     $va_settings = $this->getSettingValuesFromElementArray($pa_element_info, array('dateRangeBoundaries', 'mustNotBeBlank'));
     if ($ps_value) {
         if (!DateRangeAttributeValue::$o_tep->parse($ps_value)) {
             // invalid date
             $this->postError(1970, _t('%1 is invalid', $pa_element_info['displayLabel']), 'DateRangeAttributeValue->parseValue()');
             return false;
         }
         $va_dates = DateRangeAttributeValue::$o_tep->getHistoricTimestamps();
         if ($va_settings['dateRangeBoundaries']) {
             if (DateRangeAttributeValue::$o_tep->parse($va_settings['dateRangeBoundaries'])) {
                 $va_boundary_dates = DateRangeAttributeValue::$o_tep->getHistoricTimestamps();
                 if ($va_dates[0] < $va_boundary_dates[0] || $va_dates[0] > $va_boundary_dates[1] || $va_dates[1] < $va_boundary_dates[0] || $va_dates[1] > $va_boundary_dates[1]) {
                     // date is out of bounds
                     $this->postError(1970, _t('%1 must be within %2', $pa_element_info['displayLabel'], $va_settings['dateRangeBoundaries']), 'DateRangeAttributeValue->parseValue()');
                     return false;
                 }
             }
         }
     } else {
         if ((bool) $va_settings['mustNotBeBlank']) {
             $this->postError(1970, _t('%1 must not be empty', $pa_element_info['displayLabel']), 'DateRangeAttributeValue->parseValue()');
             return false;
         } else {
             $o_date_config = Configuration::load(__CA_CONF_DIR__ . '/datetime.conf');
             // Default to "undated" date for blanks
             $vs_undated_date = '';
             if ((bool) $o_date_config->get('showUndated')) {
                 $o_lang_config = DateRangeAttributeValue::$o_tep->getLanguageSettings();
                 $vs_undated_date = array_shift($o_lang_config->getList('undatedDate'));
             }
             return array('value_longtext1' => $vs_undated_date, 'value_decimal1' => null, 'value_decimal2' => null);
         }
     }
     return array('value_longtext1' => $ps_value, 'value_decimal1' => $va_dates[0], 'value_decimal2' => $va_dates[1]);
 }
开发者ID:samrahman,项目名称:providence,代码行数:40,代码来源:DateRangeAttributeValue.php

示例2: caNormalizeDateRange

/**
 * Normalize arbitrarily precise date expression to century, decade, year, month or day
 *
 * @param string $ps_expression A valid date expression parseable by the TimeExpressionParser class
 * @param string $ps_normalization Level to normalize to. Valid values are centuries, decades, years, months, days
 * @param array $pa_options
 *			delimiter = A string to join multiple values with when returning normalized date range as a string. Default is semicolon followed by space ("; ")
 *			returnAsArray = If set an array of normalized values will be returned rather than a string. Default is false.
 * @return mixes The normalized expression. If the expression normalizes to multiple values (eg. a range of years being normalized to months) then the values will be joined with a delimiter and returned as a string unless the "returnAsArray" option is set.
 */
function caNormalizeDateRange($ps_expression, $ps_normalization, $pa_options = null)
{
    $o_tep = new TimeExpressionParser();
    if ($o_tep->parse($ps_expression)) {
        $va_dates = $o_tep->getHistoricTimestamps();
        $va_vals = $o_tep->normalizeDateRange($va_dates['start'], $va_dates['end'], $ps_normalization);
        if (isset($pa_options['returnAsArray']) && $pa_options['returnAsArray']) {
            return $va_vals;
        } else {
            $vs_delimiter = isset($pa_options['returnAsArray']) ? $pa_options['returnAsArray'] : "; ";
            return join($vs_delimiter, $va_vals);
        }
    }
    return null;
}
开发者ID:kai-iak,项目名称:providence,代码行数:25,代码来源:displayHelpers.php

示例3: set


//.........这里部分代码省略.........
                 case FT_DATERANGE:
                 case FT_HISTORIC_DATERANGE:
                     $vs_start_field_name = $this->getFieldInfo($vs_field, "START");
                     $vs_end_field_name = $this->getFieldInfo($vs_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 ($this->DIRECT_DATETIMES || $pa_options["SET_DIRECT_DATE"]) {
                         if (is_array($vm_value) && sizeof($vm_value) == 2 && $vm_value[0] <= $vm_value[1]) {
                             if ($vn_start_date != $vm_value[0]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_start_field_name] = $vm_value[0];
                             }
                             if ($vn_end_date != $vm_value[1]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_end_field_name] = $vm_value[1];
                             }
                         } else {
                             $this->postError(1100, _t("Invalid direct date values"), "BaseModel->set()", $this->tableName() . '.' . $vs_field);
                         }
                     } else {
                         if (!$vm_value && $this->FIELDS[$vs_field]["IS_NULL"]) {
                             if ($vn_start_date || $vn_end_date) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                             }
                             $this->_FIELD_VALUES[$vs_start_field_name] = null;
                             $this->_FIELD_VALUES[$vs_end_field_name] = null;
                         } else {
                             $o_tep = new TimeExpressionParser();
                             if (!$o_tep->parseDatetime($vm_value)) {
                                 $this->postError(1805, $o_tep->getParseErrorMessage(), 'BaseModel->set()', $this->tableName() . '.' . $vs_field);
                                 return false;
                             }
                             if ($pa_fields_type == FT_HISTORIC_DATERANGE) {
                                 $va_timestamps = $o_tep->getHistoricTimestamps();
                             } else {
                                 $va_timestamps = $o_tep->getUnixTimestamps();
                                 if ($va_timestamps[0] == -1) {
                                     $this->postError(1830, $o_tep->getParseErrorMessage(), 'BaseModel->set()', $this->tableName() . '.' . $vs_field);
                                     return false;
                                 }
                             }
                             if ($vn_start_date != $va_timestamps["start"]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_start_field_name] = $va_timestamps["start"];
                             }
                             if ($vn_end_date != $va_timestamps["end"]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_end_field_name] = $va_timestamps["end"];
                             }
                         }
                     }
                     break;
                 case FT_TIMERANGE:
                     $vs_start_field_name = $this->getFieldInfo($vs_field, "START");
                     $vs_end_field_name = $this->getFieldInfo($vs_field, "END");
                     if ($this->DIRECT_TIMES || $pa_options["SET_DIRECT_TIMES"]) {
                         if (is_array($vm_value) && sizeof($vm_value) == 2 && $vm_value[0] <= $vm_value[1]) {
                             if ($this->_FIELD_VALUES[$vs_start_field_name] != $vm_value[0]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_start_field_name] = $vm_value[0];
                             }
                             if ($this->_FIELD_VALUES[$vs_end_field_name] != $vm_value[1]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_end_field_name] = $vm_value[1];
                             }
                         } else {
开发者ID:samrahman,项目名称:providence,代码行数:67,代码来源:BaseModel.php

示例4: getFacetContent


//.........这里部分代码省略.........
             }
             if ($t_item->hasField('deleted')) {
                 $va_wheres[] = "(" . $vs_browse_table_name . ".deleted = 0)";
             }
             if ($va_facet_info['relative_to']) {
                 if ($t_subject->hasField('deleted')) {
                     $va_wheres[] = "(" . $t_subject->tableName() . ".deleted = 0)";
                 }
                 if ($va_relative_sql_data = $this->_getRelativeFacetSQLData($va_facet_info['relative_to'], $pa_options)) {
                     $va_joins = array_merge($va_joins, $va_relative_sql_data['joins']);
                     $va_wheres = array_merge($va_wheres, $va_relative_sql_data['wheres']);
                 }
             }
             if ($this->opo_config->get('perform_item_level_access_checking')) {
                 if ($t_item = $this->opo_datamodel->getInstanceByTableName($vs_browse_table_name, true)) {
                     // Join to limit what browse table items are used to generate facet
                     $va_joins[] = 'LEFT JOIN ca_acl ON ' . $vs_browse_table_name . '.' . $t_item->primaryKey() . ' = ca_acl.row_id AND ca_acl.table_num = ' . $t_item->tableNum() . "\n";
                     $va_wheres[] = "(\n\t\t\t\t\t\t\t\t((\n\t\t\t\t\t\t\t\t\t(ca_acl.user_id = " . (int) $vn_user_id . ")\n\t\t\t\t\t\t\t\t\t" . (sizeof($va_group_ids) > 0 ? "OR\n\t\t\t\t\t\t\t\t\t(ca_acl.group_id IN (" . join(",", $va_group_ids) . "))" : "") . "\n\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t(ca_acl.user_id IS NULL and ca_acl.group_id IS NULL)\n\t\t\t\t\t\t\t\t) AND ca_acl.access >= " . __CA_ACL_READONLY_ACCESS__ . ")\n\t\t\t\t\t\t\t\t" . ($vb_show_if_no_acl ? "OR ca_acl.acl_id IS NULL" : "") . "\n\t\t\t\t\t\t\t)";
                 }
             }
             $vs_where_sql = '';
             if (is_array($va_wheres) && sizeof($va_wheres) && ($vs_where_sql = join(' AND ', $va_wheres))) {
                 $vs_where_sql = ' AND (' . $vs_where_sql . ')';
             }
             $vs_join_sql = join("\n", $va_joins);
             if ($vb_is_element) {
                 $vn_element_id = $t_element->getPrimaryKey();
                 $vs_dir = strtoupper($va_facet_info['sort']) === 'DESC' ? "DESC" : "ASC";
                 $o_tep = new TimeExpressionParser();
                 $vn_min_date = $vn_max_date = null;
                 $vs_min_sql = $vs_max_sql = '';
                 if (isset($va_facet_info['minimum_date'])) {
                     if ($o_tep->parse($va_facet_info['minimum_date'])) {
                         $va_tmp = $o_tep->getHistoricTimestamps();
                         $vn_min_date = (double) $va_tmp['start'];
                         $vs_min_sql = " AND (ca_attribute_values.value_decimal1 >= {$vn_min_date})";
                     }
                 }
                 if (isset($va_facet_info['maximum_date'])) {
                     if ($o_tep->parse($va_facet_info['maximum_date'])) {
                         $va_tmp = $o_tep->getHistoricTimestamps();
                         $vn_max_date = (double) $va_tmp['end'];
                         $vs_max_sql = " AND (ca_attribute_values.value_decimal2 <= {$vn_max_date})";
                     }
                 }
                 if ($vb_check_availability_only) {
                     $vs_sql = "\n\t\t\t\t\t\t\t\tSELECT 1\n\t\t\t\t\t\t\t\tFROM ca_attributes\n\t\t\t\t\t\t\t\t{$vs_join_sql}\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tca_attribute_values.element_id = ? \n\t\t\t\t\t\t\t\t\t{$vs_min_sql}\n\t\t\t\t\t\t\t\t\t{$vs_max_sql}\n\t\t\t\t\t\t\t\t\t{$vs_where_sql}\n\t\t\t\t\t\t\t\t\tLIMIT 1";
                     //print $vs_sql;
                     $qr_res = $this->opo_db->query($vs_sql, $vn_element_id);
                     return (int) $qr_res->numRows() > 0 ? true : false;
                 } else {
                     $vs_sql = "\n\t\t\t\t\t\t\t\tSELECT DISTINCT ca_attribute_values.value_decimal1, ca_attribute_values.value_decimal2\n\t\t\t\t\t\t\t\tFROM ca_attributes\n\t\t\t\t\t\t\t\t{$vs_join_sql}\n\t\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\t\tca_attribute_values.element_id = ? \n\t\t\t\t\t\t\t\t\t{$vs_min_sql}\n\t\t\t\t\t\t\t\t\t{$vs_max_sql}\n\t\t\t\t\t\t\t\t\t{$vs_where_sql}\n\t\t\t\t\t\t\t";
                     //print $vs_sql;
                     $qr_res = $this->opo_db->query($vs_sql, $vn_element_id);
                     $vn_current_year = (int) date("Y");
                     $va_values = array();
                     $vb_include_unknown = (bool) caGetOption('include_unknown', $va_facet_info, false);
                     $vb_unknown_is_set = false;
                     while ($qr_res->nextRow()) {
                         $vn_start = $qr_res->get('value_decimal1');
                         $vn_end = $qr_res->get('value_decimal2');
                         if (!($vn_start && $vn_end)) {
                             if ($vb_include_unknown) {
                                 $vb_unknown_is_set = true;
                             }
                             continue;
开发者ID:kai-iak,项目名称:pawtucket2,代码行数:67,代码来源:BrowseEngine.php

示例5: caDateToHistoricTimestamp

/**
 * Parses natural language date and returns an historic timestamp
 *
 * @param string $ps_date_expression A valid date/time expression as described in http://docs.collectiveaccess.org/wiki/Date_and_Time_Formats
 * @return float An historic timestamp for the date expression or null if expression cannot be parsed.
 */
function caDateToHistoricTimestamp($ps_date_expression)
{
    $o_tep = new TimeExpressionParser();
    if ($o_tep->parse($ps_date_expression)) {
        $va_date = $o_tep->getHistoricTimestamps();
        return isset($va_date['start']) ? $va_date['start'] : null;
    }
    return null;
}
开发者ID:samrahman,项目名称:providence,代码行数:15,代码来源:utilityHelpers.php

示例6: 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

示例7: parseValue

 public function parseValue($ps_value, $pa_element_info, $pa_options = null)
 {
     $ps_value = trim($ps_value);
     $va_settings = $this->getSettingValuesFromElementArray($pa_element_info, array('dateRangeBoundaries', 'mustNotBeBlank'));
     $o_tep = new TimeExpressionParser();
     if ($ps_value) {
         if (!$o_tep->parse($ps_value)) {
             // invalid date
             $this->postError(1970, _t('%1 is invalid', $pa_element_info['displayLabel']), 'DateRangeAttributeValue->parseValue()');
             return false;
         }
         $va_dates = $o_tep->getHistoricTimestamps();
         if ($va_settings['dateRangeBoundaries']) {
             if ($o_tep->parse($va_settings['dateRangeBoundaries'])) {
                 $va_boundary_dates = $o_tep->getHistoricTimestamps();
                 if ($va_dates[0] < $va_boundary_dates[0] || $va_dates[0] > $va_boundary_dates[1] || $va_dates[1] < $va_boundary_dates[0] || $va_dates[1] > $va_boundary_dates[1]) {
                     // date is out of bounds
                     $this->postError(1970, _t('%1 must be within %2', $pa_element_info['displayLabel'], $va_settings['dateRangeBoundaries']), 'DateRangeAttributeValue->parseValue()');
                     return false;
                 }
             }
         }
     } else {
         if ((bool) $va_settings['mustNotBeBlank']) {
             $this->postError(1970, _t('%1 must not be empty', $pa_element_info['displayLabel']), 'DateRangeAttributeValue->parseValue()');
             return false;
         } else {
             // Default to "undated" date for blanks
             $o_config = $o_tep->getLanguageSettings();
             $va_undated_dates = $o_config->getList('undatedDate');
             return array('value_longtext1' => $va_undated_dates[0], 'value_decimal1' => null, 'value_decimal2' => null);
         }
     }
     return array('value_longtext1' => $ps_value, 'value_decimal1' => $va_dates[0], 'value_decimal2' => $va_dates[1]);
 }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:35,代码来源:DateRangeAttributeValue.php

示例8: 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

示例9: caDateToHistoricTimestamps

/**
 * Parses natural language date and returns pair of historic timestamps defining date/time range
 *
 * @param string $ps_date_expression A valid date/time expression as described in http://docs.collectiveaccess.org/wiki/Date_and_Time_Formats
 * @return array The start and end timestamps for the parsed date/time range. Array contains values key'ed under 0 and 1 and 'start' and 'end'; null is returned if expression cannot be parsed.
 */
function caDateToHistoricTimestamps($ps_date_expression)
{
    $o_tep = new TimeExpressionParser();
    if ($o_tep->parse($ps_date_expression)) {
        return $o_tep->getHistoricTimestamps();
    }
    return null;
}
开发者ID:guaykuru,项目名称:pawtucket,代码行数:14,代码来源:utilityHelpers.php

示例10: caCalculateDateRangeAvgInDays

function caCalculateDateRangeAvgInDays()
{
    $va_date_ranges = func_get_args();
    $o_tep = new TimeExpressionParser();
    $va_days = array();
    foreach ($va_date_ranges as $vs_date_range) {
        if (!$o_tep->parse($vs_date_range)) {
            print "no parse {$vs_date_range}";
            return false;
        }
        $va_arg_historic_stamps = $o_tep->getHistoricTimestamps();
        $va_start_parts = $o_tep->getHistoricDateParts($va_arg_historic_stamps['start']);
        $va_end_parts = $o_tep->getHistoricDateParts($va_arg_historic_stamps['end']);
        $vs_start = $o_tep->getISODateTime($va_start_parts);
        $vs_end = $o_tep->getISODateTime($va_end_parts);
        $o_start = new DateTime($vs_start);
        $o_end = new DateTime($vs_end);
        $va_days[] = $o_start->diff($o_end)->days;
    }
    if (sizeof($va_days)) {
        return array_sum($va_days) / sizeof($va_days);
    } else {
        return false;
    }
}
开发者ID:samrahman,项目名称:providence,代码行数:25,代码来源:expressionHelpers.php

示例11: set


//.........这里部分代码省略.........
                 case FT_DATERANGE:
                 case FT_HISTORIC_DATERANGE:
                     $vs_start_field_name = $this->getFieldInfo($vs_field, "START");
                     $vs_end_field_name = $this->getFieldInfo($vs_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 ($this->DIRECT_DATETIMES || $pa_options["SET_DIRECT_DATE"]) {
                         if (is_array($vm_value) && sizeof($vm_value) == 2 && $vm_value[0] <= $vm_value[1]) {
                             if ($vn_start_date != $vm_value[0]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_start_field_name] = $vm_value[0];
                             }
                             if ($vn_end_date != $vm_value[1]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_end_field_name] = $vm_value[1];
                             }
                         } else {
                             $this->postError(1100, _t("Invalid direct date values"), "BaseModel->set()");
                         }
                     } else {
                         if (!$vm_value && $this->FIELDS[$vs_field]["IS_NULL"]) {
                             if ($vn_start_date || $vn_end_date) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                             }
                             $this->_FIELD_VALUES[$vs_start_field_name] = null;
                             $this->_FIELD_VALUES[$vs_end_field_name] = null;
                         } else {
                             $o_tep = new TimeExpressionParser();
                             if (!$o_tep->parseDatetime($vm_value)) {
                                 $this->postError(1805, $o_tep->getParseErrorMessage(), 'BaseModel->set()');
                                 return false;
                             }
                             if ($pa_fields_type == FT_HISTORIC_DATERANGE) {
                                 $va_timestamps = $o_tep->getHistoricTimestamps();
                             } else {
                                 $va_timestamps = $o_tep->getUnixTimestamps();
                                 if ($va_timestamps[0] == -1) {
                                     $this->postError(1830, $o_tep->getParseErrorMessage(), 'BaseModel->set()');
                                     return false;
                                 }
                             }
                             if ($vn_start_date != $va_timestamps["start"]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_start_field_name] = $va_timestamps["start"];
                             }
                             if ($vn_end_date != $va_timestamps["end"]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_end_field_name] = $va_timestamps["end"];
                             }
                         }
                     }
                     break;
                 case FT_TIMERANGE:
                     $vs_start_field_name = $this->getFieldInfo($vs_field, "START");
                     $vs_end_field_name = $this->getFieldInfo($vs_field, "END");
                     if ($this->DIRECT_TIMES || $pa_options["SET_DIRECT_TIMES"]) {
                         if (is_array($vm_value) && sizeof($vm_value) == 2 && $vm_value[0] <= $vm_value[1]) {
                             if ($this->_FIELD_VALUES[$vs_start_field_name] != $vm_value[0]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_start_field_name] = $vm_value[0];
                             }
                             if ($this->_FIELD_VALUES[$vs_end_field_name] != $vm_value[1]) {
                                 $this->_FIELD_VALUE_CHANGED[$vs_field] = true;
                                 $this->_FIELD_VALUES[$vs_end_field_name] = $vm_value[1];
                             }
                         } else {
开发者ID:guaykuru,项目名称:pawtucket,代码行数:67,代码来源:BaseModel.php

示例12: getFacetContent


//.........这里部分代码省略.........
             if ($vs_browse_type_limit_sql) {
                 $va_wheres[] = $vs_browse_type_limit_sql;
             }
             if ($t_item->hasField('deleted')) {
                 $va_wheres[] = "(" . $vs_browse_table_name . ".deleted = 0)";
             }
             if ($va_facet_info['relative_to']) {
                 if ($t_subject->hasField('deleted')) {
                     $va_wheres[] = "(" . $t_subject->tableName() . ".deleted = 0)";
                 }
                 if ($va_relative_sql_data = $this->_getRelativeFacetSQLData($va_facet_info['relative_to'], $pa_options)) {
                     $va_joins = array_merge($va_joins, $va_relative_sql_data['joins']);
                     $va_wheres = array_merge($va_wheres, $va_relative_sql_data['wheres']);
                 }
             }
             if ($this->opo_config->get('perform_item_level_access_checking')) {
                 if ($t_item = $this->opo_datamodel->getInstanceByTableName($vs_browse_table_name, true)) {
                     // Join to limit what browse table items are used to generate facet
                     $va_joins[] = 'LEFT JOIN ca_acl ON ' . $vs_browse_table_name . '.' . $t_item->primaryKey() . ' = ca_acl.row_id AND ca_acl.table_num = ' . $t_item->tableNum() . "\n";
                     $va_wheres[] = "(\n\t\t\t\t\t\t\t\t((\n\t\t\t\t\t\t\t\t\t(ca_acl.user_id = " . (int) $vn_user_id . ")\n\t\t\t\t\t\t\t\t\t" . (sizeof($va_group_ids) > 0 ? "OR\n\t\t\t\t\t\t\t\t\t(ca_acl.group_id IN (" . join(",", $va_group_ids) . "))" : "") . "\n\t\t\t\t\t\t\t\t\tOR\n\t\t\t\t\t\t\t\t\t(ca_acl.user_id IS NULL and ca_acl.group_id IS NULL)\n\t\t\t\t\t\t\t\t) AND ca_acl.access >= " . __CA_ACL_READONLY_ACCESS__ . ")\n\t\t\t\t\t\t\t\t" . ($vb_show_if_no_acl ? "OR ca_acl.acl_id IS NULL" : "") . "\n\t\t\t\t\t\t\t)";
                 }
             }
             $vs_join_sql = join("\n", $va_joins);
             $vs_where_sql = '';
             if (is_array($va_wheres) && sizeof($va_wheres) && ($vs_where_sql = join(' AND ', $va_wheres))) {
                 $vs_where_sql = ' AND (' . $vs_where_sql . ')';
             }
             $vs_dir = strtoupper($va_facet_info['sort']) === 'DESC' ? "DESC" : "ASC";
             $o_tep = new TimeExpressionParser();
             $vn_min_date = $vn_max_date = null;
             $vs_min_sql = $vs_max_sql = '';
             if (isset($va_facet_info['minimum_date'])) {
                 if ($o_tep->parse($va_facet_info['minimum_date'])) {
                     $va_tmp = $o_tep->getHistoricTimestamps();
                     $vn_min_date = (double) $va_tmp['start'];
                     $vs_min_sql = " AND (ca_attribute_values.value_decimal1 >= {$vn_min_date})";
                 }
             }
             if (isset($va_facet_info['maximum_date'])) {
                 if ($o_tep->parse($va_facet_info['maximum_date'])) {
                     $va_tmp = $o_tep->getHistoricTimestamps();
                     $vn_max_date = (double) $va_tmp['end'];
                     $vs_max_sql = " AND (ca_attribute_values.value_decimal2 <= {$vn_max_date})";
                 }
             }
             if ($vb_check_availability_only) {
                 $vs_sql = "\n\t\t\t\t\t\t\tSELECT 1\n\t\t\t\t\t\t\tFROM ca_attributes\n\t\t\t\t\t\t\t{$vs_join_sql}\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tca_attribute_values.element_id = ? \n\t\t\t\t\t\t\t\t{$vs_min_sql}\n\t\t\t\t\t\t\t\t{$vs_max_sql}\n\t\t\t\t\t\t\t\t{$vs_where_sql}\n\t\t\t\t\t\t\t\tLIMIT 1";
                 //print $vs_sql;
                 $qr_res = $this->opo_db->query($vs_sql, $vn_element_id);
                 return (int) $qr_res->numRows() > 0 ? true : false;
             } else {
                 $vs_sql = "\n\t\t\t\t\t\t\tSELECT DISTINCT ca_attribute_values.value_decimal1, ca_attribute_values.value_decimal2\n\t\t\t\t\t\t\tFROM ca_attributes\n\t\t\t\t\t\t\t{$vs_join_sql}\n\t\t\t\t\t\t\tWHERE\n\t\t\t\t\t\t\t\tca_attribute_values.element_id = ? \n\t\t\t\t\t\t\t\t{$vs_min_sql}\n\t\t\t\t\t\t\t\t{$vs_max_sql}\n\t\t\t\t\t\t\t\t{$vs_where_sql}\n\t\t\t\t\t\t";
                 //print $vs_sql;
                 $qr_res = $this->opo_db->query($vs_sql, $vn_element_id);
                 $va_values = array();
                 while ($qr_res->nextRow()) {
                     $vn_start = $qr_res->get('value_decimal1');
                     $vn_end = $qr_res->get('value_decimal2');
                     if (!($vn_start && $vn_end)) {
                         continue;
                     }
                     $va_normalized_values = $o_tep->normalizeDateRange($vn_start, $vn_end, $vs_normalization);
                     foreach ($va_normalized_values as $vn_sort_value => $vs_normalized_value) {
                         if ($va_criteria[$vs_normalized_value]) {
                             continue;
                         }
开发者ID:guaykuru,项目名称:pawtucket,代码行数:67,代码来源:BrowseEngine.php


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