first import

Signed-off-by: bachy <git@g-u-i.net>
This commit is contained in:
bachy
2013-01-09 10:53:26 +01:00
commit b20b38f514
526 changed files with 76993 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
<?php
/**
* @file
* Definition of views_handler_argument_file_fid.
*/
/**
* Argument handler to accept multiple file ids.
*
* @ingroup views_argument_handlers
*/
class views_handler_argument_file_fid extends views_handler_argument_numeric {
/**
* Override the behavior of title_query(). Get the filenames.
*/
function title_query() {
$titles = db_select('file_managed', 'f')
->fields('f', array('filename'))
->condition('fid', $this->value)
->execute()
->fetchCol();
foreach ($titles as &$title) {
$title = check_plain($title);
}
return $titles;
}
}

View File

@@ -0,0 +1,61 @@
<?php
/**
* @file
* Definition of views_handler_field_file.
*/
/**
* Field handler to provide simple renderer that allows linking to a file.
*
* @ingroup views_field_handlers
*/
class views_handler_field_file extends views_handler_field {
/**
* Constructor to provide additional field to add.
*/
function init(&$view, &$options) {
parent::init($view, $options);
if (!empty($options['link_to_file'])) {
$this->additional_fields['uri'] = 'uri';
}
}
function option_definition() {
$options = parent::option_definition();
$options['link_to_file'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
/**
* Provide link to file option
*/
function options_form(&$form, &$form_state) {
$form['link_to_file'] = array(
'#title' => t('Link this field to download the file'),
'#description' => t("Enable to override this field's links."),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['link_to_file']),
);
parent::options_form($form, $form_state);
}
/**
* Render whatever the data is as a link to the file.
*
* Data should be made XSS safe prior to calling this function.
*/
function render_link($data, $values) {
if (!empty($this->options['link_to_file']) && $data !== NULL && $data !== '') {
$this->options['alter']['make_link'] = TRUE;
$this->options['alter']['path'] = file_create_url($this->get_value($values, 'uri'));
}
return $data;
}
function render($values) {
$value = $this->get_value($values);
return $this->render_link($this->sanitize_value($value), $values);
}
}

View File

@@ -0,0 +1,19 @@
<?php
/**
* @file
* Definition of views_handler_field_file_extension.
*/
/**
* Returns a pure file extension of the file, for example 'module'.
* @ingroup views_field_handlers
*/
class views_handler_field_file_extension extends views_handler_field {
function render($values) {
$value = $this->get_value($values);
if (preg_match('/\.([^\.]+)$/', $value, $match)) {
return $this->sanitize_value($match[1]);
}
}
}

View File

@@ -0,0 +1,38 @@
<?php
/**
* @file
* Definition of views_handler_field_file_filemime.
*/
/**
* Field handler to add rendering MIME type images as an option on the filemime field.
*
* @ingroup views_field_handlers
*/
class views_handler_field_file_filemime extends views_handler_field_file {
function option_definition() {
$options = parent::option_definition();
$options['filemime_image'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
function options_form(&$form, &$form_state) {
$form['filemime_image'] = array(
'#title' => t('Display an icon representing the file type, instead of the MIME text (such as "image/jpeg")'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['filemime_image']),
);
parent::options_form($form, $form_state);
}
function render($values) {
$data = $values->{$this->field_alias};
if (!empty($this->options['filemime_image']) && $data !== NULL && $data !== '') {
$fake_file = (object) array('filemime' => $data);
$data = theme('file_icon', array('file' => $fake_file));
}
return $this->render_link($data, $values);
}
}

View File

@@ -0,0 +1,18 @@
<?php
/**
* @file
* Definition of views_handler_field_file_status.
*/
/**
* Field handler to translate a node type into its readable form.
*
* @ingroup views_field_handlers
*/
class views_handler_field_file_status extends views_handler_field {
function render($values) {
$value = $this->get_value($values);
return _views_file_status($value);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/**
* @file
* Definition of views_handler_field_file_uri.
*/
/**
* Field handler to add rendering file paths as file URLs instead of as internal file URIs.
*/
class views_handler_field_file_uri extends views_handler_field_file {
function option_definition() {
$options = parent::option_definition();
$options['file_download_path'] = array('default' => FALSE, 'bool' => TRUE);
return $options;
}
function options_form(&$form, &$form_state) {
$form['file_download_path'] = array(
'#title' => t('Display download path instead of file storage URI'),
'#description' => t('This will provide the full download URL rather than the internal filestream address.'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['file_download_path']),
);
parent::options_form($form, $form_state);
}
function render($values) {
$data = $values->{$this->field_alias};
if (!empty($this->options['file_download_path']) && $data !== NULL && $data !== '') {
$data = file_create_url($data);
}
return $this->render_link($data, $values);
}
}

View File

@@ -0,0 +1,19 @@
<?php
/**
* @file
* Definition of views_handler_filter_file_status.
*/
/**
* Filter by file status.
*
* @ingroup views_filter_handlers
*/
class views_handler_filter_file_status extends views_handler_filter_in_operator {
function get_value_options() {
if (!isset($this->value_options)) {
$this->value_options = _views_file_status();
}
}
}

View File

@@ -0,0 +1,21 @@
<?php
/**
* @file
* Definition of views_handler_filter_system_type.
*/
/**
* Filter by system type.
*/
class views_handler_filter_system_type extends views_handler_filter_in_operator {
function get_value_options() {
if (!isset($this->value_options)) {
$this->value_title = t('Type');
// Enable filtering by type.
$types = array();
$types = db_query('SELECT DISTINCT(type) FROM {system} ORDER BY type')->fetchAllKeyed(0, 0);
$this->value_options = $types;
}
}
}