Commit 45f6906e authored by merlinofchaos's avatar merlinofchaos
Browse files

Some data updates primarily for files; also allow node titles that aren't a link

parent a87e1399
......@@ -16,6 +16,13 @@ function node_views_tables() {
'views_handler_field_nodelink' => t('Normal'),
'views_handler_field_nodelink_with_mark' => t('With updated mark')
),
'option' => array(
'#type' => 'select',
'#options' => array(
'link' => 'As link',
'nolink' => 'Without link'
),
),
'sortable' => true,
'addlfields' => array('changed'),
'help' => t('Display the title of the node.'),
......@@ -321,6 +328,9 @@ function node_views_default_views() {
* Format a field as a link to a node.
*/
function views_handler_field_nodelink($fieldinfo, $fielddata, $value, $data) {
if ($fielddata['options'] == 'nolink') {
return check_plain($value);
}
return l($value, "node/$data->nid");
}
......@@ -329,7 +339,13 @@ function views_handler_field_nodelink($fieldinfo, $fielddata, $value, $data) {
* updated since it was last viewed by the user.
*/
function views_handler_field_nodelink_with_mark($fieldinfo, $fielddata, $value, $data) {
return l($value, "node/$data->nid") .' '. theme('mark', node_mark($data->nid, $data->node_changed));
if ($fielddata['options'] == 'nolink') {
$link = check_plain($value);
}
else {
$link = l($value, "node/$data->nid");
}
return l($link, "node/$data->nid") .' '. theme('mark', node_mark($data->nid, $data->node_changed));
}
/*
......
......@@ -68,6 +68,7 @@ function upload_views_tables() {
),
'sortable' => true,
'addlfields' => array('filepath'),
'option' => 'string',
'help' => t('Display file name'),
),
'filepath' => array(
......@@ -75,12 +76,50 @@ function upload_views_tables() {
'sortable' => false,
'help' => t('Display Path to File.'),
),
'filesize' => array(
'name' => t('File: Size'),
'handler' => 'views_handler_file_size',
'sortable' => true,
'help' => t('Display the size of the associated file.'),
),
'filemime' => array(
'name' => t('File: Mime type'),
'sortable' => true,
'help' => t('This filter allows nodes to be filtered by mime type.'),
),
),
'filters' => array(
'filename' => array(
'name' => t('File: Filename'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
'help' => t('This filter allows nodes to be filtered by the name of attached files.'),
),
'filesize' => array(
'name' => t('File: Size'),
'operator' => 'views_handler_operator_gtlt',
'help' => t('This filter allows nodes to be filtered by file size.'),
),
'filemime' => array(
'name' => t('File: Mime type'),
'operator' => 'views_handler_operator_like',
'handler' => 'views_handler_filter_like',
'help' => t('This filter allows nodes to be filtered by mime type.'),
),
),
'sorts' => array(
'filename' => array(
'name' => t('File: Sort by Filename'),
'help' => t('Sort by file name'),
),
'filesize' => array(
'name' => t('File: File size'),
'help' => t('Sort by file size.'),
),
'filemime' => array(
'name' => t('File: Mime type'),
'help' => t('Sort by mime type.'),
),
),
);
return $tables;
......@@ -90,8 +129,13 @@ function views_handler_file_filename($fieldinfo, $fielddata, $value, $data) {
return $value;
}
function views_handler_file_size($fieldinfo, $fielddata, $value, $data) {
return format_size($value);
}
function views_handler_file_filename_download($fieldinfo, $fielddata, $value, $data) {
return $value ? l($value, check_url(file_create_url($data->files_filepath))) : '';
$link_text = $fielddata['options'] ? $fielddata['options'] : $value;
return $value ? l($link_text, check_url(file_create_url($data->files_filepath))) : '';
}
function views_handler_file_filter_fid_exist($op, $filter, $filterdata, &$query) {
......
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