Commit 189ddc27 authored by merlinofchaos's avatar merlinofchaos

Basic node.created summaries for archive view

parent 3f66ae28
...@@ -1009,10 +1009,9 @@ class views_handler_argument_formula extends views_handler_argument { ...@@ -1009,10 +1009,9 @@ class views_handler_argument_formula extends views_handler_argument {
*/ */
function summary_query() { function summary_query() {
$this->ensure_my_table(); $this->ensure_my_table();
$field_alias = $alias . '_' . $this->field;
// Add the field. // Add the field.
$this->base_alias = $this->query->add_field(NULL, $this->formula, $field_alias); $this->base_alias = $this->name_alias = $this->query->add_field(NULL, $this->formula, $this->field);
$this->query->set_count_field(NULL, $this->formula, $field_alias); $this->query->set_count_field(NULL, $this->formula, $this->field);
return $this->summary_basics(FALSE); return $this->summary_basics(FALSE);
} }
...@@ -1022,10 +1021,7 @@ class views_handler_argument_formula extends views_handler_argument { ...@@ -1022,10 +1021,7 @@ class views_handler_argument_formula extends views_handler_argument {
*/ */
function query() { function query() {
$this->ensure_my_table(); $this->ensure_my_table();
$field_alias = $alias . '_' . $this->field; $this->query->add_where(0, "$this->formula = '%s'", $this->argument);
// Add the field.
$this->name_alias = $this->query->add_field(NULL, $this->formula, $field_alias);
$this->query->add_where(0, "$field = '%s'", $this->argument);
} }
} }
......
...@@ -162,11 +162,30 @@ function node_views_data() { ...@@ -162,11 +162,30 @@ function node_views_data() {
// Bogus fields for aliasing purposes. // Bogus fields for aliasing purposes.
$data['node']['year_month'] = array( $data['node']['created_year_month'] = array(
'title' => t('Year + month'), 'title' => t('Created year + month'),
'help' => t('In the form of YYYYMM'), 'help' => t('In the form of YYYYMM'),
'argument' => array( 'argument' => array(
'handler' => 'views_handler_argument_date_year_month', 'handler' => 'views_handler_argument_date_year_month',
'arguments' => array(), // this is required to make sure construct is called.
),
);
$data['node']['created_year'] = array(
'title' => t('Created year'),
'help' => t('In the form of YYYY'),
'argument' => array(
'handler' => 'views_handler_argument_date_year',
'arguments' => array(), // this is required to make sure construct is called.
),
);
$data['node']['created_month'] = array(
'title' => t('Created month'),
'help' => t('In the form of MM 01 - 12'),
'argument' => array(
'handler' => 'views_handler_argument_date_month',
'arguments' => array(), // this is required to make sure construct is called.
), ),
); );
...@@ -374,10 +393,9 @@ class views_handler_argument_date_year_month extends views_handler_argument_form ...@@ -374,10 +393,9 @@ class views_handler_argument_date_year_month extends views_handler_argument_form
/** /**
* Provide a link to the next level of the view * Provide a link to the next level of the view
*/ */
function summary_link($data, $url) { function summary_name($data) {
$value = $data->{$this->base_alias};
$created = $data->{$this->name_alias}; $created = $data->{$this->name_alias};
return l(format_date($created, 'custom', $this->format), "$url/$value"); return format_date(strtotime($created . "15"), 'custom', $this->format, 0);
} }
/** /**
......
...@@ -33,7 +33,7 @@ function template_preprocess_views_view(&$vars) { ...@@ -33,7 +33,7 @@ function template_preprocess_views_view(&$vars) {
/** /**
* Preprocess theme function to print a single record from a row, with fields * Preprocess theme function to print a single record from a row, with fields
*/ */
function template_preprocess_views_view_row(&$vars) { function template_preprocess_views_view_fields(&$vars) {
$view = $vars['view']; $view = $vars['view'];
// Loop through the fields for this view. // Loop through the fields for this view.
......
...@@ -738,3 +738,29 @@ function views_object_types() { ...@@ -738,3 +738,29 @@ function views_object_types() {
), ),
); );
} }
/**
* Figure out what timezone we're in; needed for some date manipulations.
*/
function views_get_timezone() {
global $user;
if (variable_get('configurable_timezones', 1) && $user->uid && strlen($user->timezone)) {
$timezone = $user->timezone;
}
else {
$timezone = variable_get('date_default_timezone', 0);
}
// set up the database timezone
if (in_array($GLOBALS['db_type'], array('mysql', 'mysqli'))) {
static $already_set = false;
if (!$already_set) {
if ($GLOBALS['db_type'] == 'mysqli' || version_compare(mysql_get_server_info(), '4.1.3', '>=')) {
db_query("SET @@session.time_zone = '+00:00'");
}
$already_set = true;
}
}
return $timezone;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment