first import

This commit is contained in:
Bachir Soussi Chiadmi
2015-04-08 11:40:19 +02:00
commit 1bc61b12ad
8435 changed files with 1582817 additions and 0 deletions

View File

@@ -0,0 +1,64 @@
<?php
/**
* @file
* Plugin to provide an relationship handler for node from view.
*/
/**
* Plugins are described by creating a $plugin array which will be used
* by the system that includes this file.
*/
$plugin = array(
'title' => t('Node from view'),
'keyword' => 'node',
'description' => t('Extract a node context from a view context of the base type node.'),
'required context' => new ctools_context_required(t('View'), 'view', array('base' => 'node')),
'context' => 'views_content_node_from_view_context',
'edit form' => 'views_content_node_from_view_settings_form',
'edit form validate' => 'views_content_node_from_view_settings_form_validate',
'defaults' => array('row' => 1),
);
/**
* Return a new context based on an existing context.
*/
function views_content_node_from_view_context($context, $conf, $placeholder = FALSE) {
// If unset it wants a generic, unfilled context, which is just NULL.
if (empty($context->data) || $placeholder) {
return ctools_context_create_empty('node', NULL);
}
$view = views_content_context_get_view($context);
// Ensure the view executes, but we don't need its output.
views_content_context_get_output($context);
$row = intval($conf['row']) - 1;
if (isset($view->result[$row])) {
$nid = $view->result[$row]->{$view->base_field};
if ($nid) {
$node = node_load($nid);
return ctools_context_create('node', $node);
}
}
return ctools_context_create_empty('node', NULL);
}
/**
* Settings form for the relationship.
*/
function views_content_node_from_view_settings_form($form, &$form_state) {
$conf = $form_state['conf'];
$form['row'] = array(
'#title' => t('Row number'),
'#type' => 'textfield',
'#default_value' => $conf['row'],
);
return $form;
}
function views_content_node_from_view_settings_form_validate($form, &$form_state) {
if (intval($form_state['values']['row']) <= 0) {
form_error($form['row'], t('Row number must be a positive integer value.'));
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* @file
* Plugin to provide an relationship handler for term from view.
*/
/**
* Plugins are described by creating a $plugin array which will be used
* by the system that includes this file.
*/
$plugin = array(
'title' => t('Term from view'),
'keyword' => 'term',
'description' => t('Extract a term context from a view context of the base type term.'),
'required context' => new ctools_context_required(t('View'), 'view', array('base' => 'term_data')),
'context' => 'views_content_term_from_view_context',
'edit form' => 'views_content_term_from_view_settings_form',
'edit form validate' => 'views_content_term_from_view_settings_form_validate',
'defaults' => array('row' => 1),
);
/**
* Return a new context based on an existing context.
*/
function views_content_term_from_view_context($context, $conf, $placeholder = FALSE) {
// If unset it wants a generic, unfilled context, which is just NULL.
if (empty($context->data) || $placeholder) {
return ctools_context_create_empty('term', NULL);
}
$view = views_content_context_get_view($context);
// Ensure the view executes, but we don't need its output.
views_content_context_get_output($context);
$row = intval($conf['row']) - 1;
if (isset($view->result[$row])) {
$tid = $view->result[$row]->{$view->base_field};
if ($tid) {
$term = taxonomy_get_term($tid);
return ctools_context_create('term', $term);
}
}
return ctools_context_create_empty('term', NULL);
}
/**
* Settings form for the relationship.
*/
function views_content_term_from_view_settings_form($form, &$form_state) {
$conf = $form_state['conf'];
$form['row'] = array(
'#title' => t('Row number'),
'#type' => 'textfield',
'#default_value' => $conf['row'],
);
return $form;
}
function views_content_term_from_view_settings_form_validate($form, &$form_state) {
if (intval($form_state['values']['row']) <= 0) {
form_error($form['row'], t('Row number must be a positive integer value.'));
}
}

View File

@@ -0,0 +1,64 @@
<?php
/**
* @file
* Plugin to provide an relationship handler for user from term.
*/
/**
* Plugins are described by creating a $plugin array which will be used
* by the system that includes this file.
*/
$plugin = array(
'title' => t('User from view'),
'keyword' => 'user',
'description' => t('Extract a user context from a view context of the base type user.'),
'required context' => new ctools_context_required(t('View'), 'view', array('base' => 'users')),
'context' => 'views_content_user_from_view_context',
'edit form' => 'views_content_user_from_view_settings_form',
'edit form validate' => 'views_content_user_from_view_settings_form_validate',
'defaults' => array('row' => 1),
);
/**
* Return a new context based on an existing context.
*/
function views_content_user_from_view_context($context, $conf, $placeholder = FALSE) {
// If unset it wants a generic, unfilled context, which is just NULL.
if (empty($context->data) || $placeholder) {
return ctools_context_create_empty('user', NULL);
}
$view = views_content_context_get_view($context);
// Ensure the view executes, but we don't need its output.
views_content_context_get_output($context);
$row = intval($conf['row']) - 1;
if (isset($view->result[$row])) {
$uid = $view->result[$row]->{$view->base_field};
if ($uid) {
$user = user_load($uid);
return ctools_context_create('user', $user);
}
}
return ctools_context_create_empty('user', NULL);
}
/**
* Settings form for the relationship.
*/
function views_content_user_from_view_settings_form($form, &$form_state) {
$conf = $form_state['conf'];
$form['row'] = array(
'#title' => t('Row number'),
'#type' => 'textfield',
'#default_value' => $conf['row'],
);
return $form;
}
function views_content_user_from_view_settings_form_validate($form, &$form_state) {
if (intval($form_state['values']['row']) <= 0) {
form_error($form['row'], t('Row number must be a positive integer value.'));
}
}

View File

@@ -0,0 +1,100 @@
<?php
/**
* @file
* Plugin to provide an relationship handler for a view by argument input settings.
*/
/**
* Plugins are described by creating a $plugin array which will be used
* by the system that includes this file.
*/
$plugin = array(
'title' => t('View From Argument'),
'description' => t('Creates a view context from argument input settings.'),
'context' => 'views_content_view_from_argument_context',
'get child' => 'views_content_view_from_argument_get_child',
'get children' => 'views_content_view_from_argument_get_children',
);
function views_content_view_from_argument_get_child($plugin, $parent, $child) {
list($name, $id) = explode('-', $child, 2);
$view = views_get_view($name);
if (!$view) {
return;
}
$view->set_display($id);
if ($view->current_display != $id) {
return;
}
$info = _views_content_get_context_from_display($view, $id, $parent, TRUE);
if ($info) {
return $info;
}
return;
}
function views_content_view_from_argument_get_children($plugin, $parent) {
$types = array();
$views = views_get_applicable_views('returns context');
foreach ($views as $data) {
list($view, $id) = $data;
$info = _views_content_get_context_from_display($view, $id, $parent, TRUE);
if ($info) {
$types[$info['name']] = $info;
}
}
return $types;
}
/**
* Return a new context based on an existing context.
*/
function views_content_view_from_argument_context($contexts, $conf) {
$name = $conf['name'];
list($plugin, $view_data) = explode(':', $name);
list($view_name, $display_id) = explode('-', $view_data);
$keys = array_keys($conf['context']);
if (empty($contexts[$keys[0]]->data)) {
return ctools_context_create_empty('view', NULL);
}
// Load our view up.
$data = views_get_view($view_name);
if ($data) {
// Set the display.
$data->set_display($display_id);
$context_keys = array_keys($contexts);
foreach ($data->display_handler->get_argument_input() as $id => $argument) {
if ($argument['type'] == 'context') {
$key = array_shift($context_keys);
if (isset($contexts [$key])) {
if (strpos($argument['context'], '.')) {
list($context, $converter) = explode('.', $argument['context'], 2);
$args[] = ctools_context_convert_context($contexts[$key], $converter, array('sanitize' => FALSE));
}
else {
$args[] = $contexts[$key]->argument;
}
}
}
}
// remove any trailing NULL arguments as these are non-args:
while (count($args) && end($args) === NULL) {
array_pop($args);
}
$data->set_arguments($args);
if ($path = $data->display_handler->get_option('inherit_panels_path')) {
$data->override_path = $_GET['q'];
}
}
if (isset($contexts[$keys[0]]->data)) {
return ctools_context_create('view', $data);
}
}