Skip to content
This repository has been archived by the owner on Jan 15, 2021. It is now read-only.

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
svenhoutmeyers committed Dec 23, 2014
2 parents a81657f + 31b6b88 commit a83a06c
Show file tree
Hide file tree
Showing 56 changed files with 2,929 additions and 1,112 deletions.
4 changes: 3 additions & 1 deletion culturefeed.helpers.inc
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ function culturefeed_create_user($cf_account, $user = NULL) {
if (!$cf_account || empty($cf_account->nick)) {
return FALSE;
}

$uid = db_query("SELECT uid FROM {culturefeed_user} cfu WHERE cfu.uid = :uid", array(':uid' => $user->uid))->fetchField();

if (isset($user->uid) && $user->uid) {
if (isset($user->uid) && $user->uid && $user->uid != $uid) {
// User is already Drupaluser, so map his Drupal and CultureFeed account
$account = $user;
}
Expand Down
50 changes: 42 additions & 8 deletions culturefeed.module
Original file line number Diff line number Diff line change
Expand Up @@ -218,20 +218,54 @@ function culturefeed_page_build(&$page) {
$gtm_globals['search_query'] = json_encode(drupal_get_query_parameters());
}

// Check if it is an event detail page.
$gtm_globals['is_event_detail'] = (arg(0) == 'agenda' && arg(1) == 'e');
if ($gtm_globals['is_event_detail']) {

$event = menu_get_object('culturefeed_agenda_event', 3);
if ($event) {
$gtm_globals['event_detail_title'] = culturefeed_agenda_detail_title($event);
$gtm_globals['cdbid'] = arg(3);
// Check if it is a detail page.
$gtm_globals['is_detail'] = (arg(0) == 'agenda' && in_array(arg(1), array('e', 'a', 'p', 'g')));
if ($gtm_globals['is_detail']) {

// Make this backwards compatible
$gtm_globals['is_event_detail'] = TRUE;

if (arg(1) == 'e') {
$event = menu_get_object('culturefeed_agenda_event', 3);
if ($event) {
$gtm_globals['detail_title'] = culturefeed_agenda_detail_title($event);
$gtm_globals['detail_type'] = 'event';
$gtm_globals['cdbid'] = arg(3);
}
}

else if (arg(1) == 'a') {
$actor = menu_get_object('culturefeed_agenda_actor', 3);
if ($actor) {
$gtm_globals['detail_title'] = culturefeed_agenda_detail_title($actor);
$gtm_globals['detail_type'] = 'actor';
$gtm_globals['cdbid'] = arg(3);
}
}

else if (arg(1) == 'p') {
$production = menu_get_object('culturefeed_agenda_production', 3);
if ($production) {
$gtm_globals['detail_title'] = culturefeed_agenda_detail_title($production);
$gtm_globals['detail_type'] = 'production';
$gtm_globals['cdbid'] = arg(3);
}
}

else if (arg(1) == 'g') {
$cfpage = menu_get_object('culturefeed_pages_page', 3);
if ($cfpage) {
$gtm_globals['detail_title'] = culturefeed_pages_detail_title($cfpage);
$gtm_globals['detail_type'] = 'page';
$gtm_globals['cdbid'] = arg(3);
}
}

}

// Add custom dimensions.
$gtm_globals['consumer_key'] = variable_get('culturefeed_api_application_key', '');
$gtm_globals['consumer_name'] = variable_get('site_name', '');
$gtm_globals['login_status'] = user_is_logged_in();

// Set the script code.
Expand Down
7 changes: 5 additions & 2 deletions culturefeed.pages.inc
Original file line number Diff line number Diff line change
Expand Up @@ -108,8 +108,11 @@ function culturefeed_oauth_authorize($application_key = NULL) {
$account = culturefeed_create_user($cf_account, $user);
}
else {
// If the drupal user already exist we update the reference in the culturefeed_user table
if ($user->uid && $user->uid != $uid) {

$cf_uid = db_query("SELECT cf_uid FROM {culturefeed_user} cfu WHERE cfu.uid = :uid", array(':uid' => $user->uid))->fetchField();

// If the drupal user already exist with another cf_uid we update the reference
if (!$cf_uid && $user->uid && $user->uid != $uid) {
$query = db_update('culturefeed_user')
->condition('cf_uid', $cf_account->id)
->fields(array('uid' => $user->uid))
Expand Down
60 changes: 59 additions & 1 deletion culturefeed_agenda/culturefeed_agenda.module
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,13 @@ function culturefeed_agenda_theme() {
'path' => $path,
);

$theme['culturefeed_agenda_actors_nearby'] = array(
'variables' => array('items' => array()),
'template' => 'culturefeed-agenda-actors-nearby',
'path' => $path,
'file' => 'theme.inc',
);

return $theme;

}
Expand Down Expand Up @@ -172,6 +179,15 @@ function culturefeed_agenda_menu() {
'file' => 'includes/pages.inc',
);

$items['admin/config/culturefeed/agenda'] = array(
'title' => 'CultureFeed Agenda',
'description' => 'Change CultureFeed Agenda settings',
'page callback' => 'drupal_get_form',
'page arguments' => array('culturefeed_agenda_admin_settings_form'),
'access arguments' => array('administer site configuration'),
'file' => 'includes/admin.inc',
);

// Autocomplete for event / production suggestions
$items['autocomplete/culturefeed/activity-suggestion'] = array(
'page callback' => 'culturefeed_agenda_activity_suggestion_autocomplete_page',
Expand All @@ -197,6 +213,14 @@ function culturefeed_agenda_menu() {
'file' => 'includes/pages.inc',
);

$items['autocomplete/culturefeed/agenda/actor-search'] = array(
'page callback' => 'culturefeed_agenda_actor_search_autocomplete',
'page arguments' => array(4, TRUE),
'access arguments' => array('access content'),
'type' => MENU_CALLBACK,
'file' => 'includes/pages.inc',
);

return $items;

}
Expand Down Expand Up @@ -284,6 +308,11 @@ function culturefeed_agenda_block_info() {
'cache' => DRUPAL_CACHE_PER_PAGE,
);

$blocks['agenda-actor-search'] = array(
'info' => t('Culturefeed agenda: actor search'),
'cache' => DRUPAL_CACHE_PER_PAGE,
);

return $blocks;

}
Expand Down Expand Up @@ -358,6 +387,29 @@ function culturefeed_agenda_block_configure($delta) {
'#default_value' => variable_get('agenda_search_block_domain_id'),
);

}
elseif ($delta == 'agenda-actor-search') {

$options = culturefeed_search_get_actortype_categories();
asort($options);
$form['agenda_actor_search'] = array(
'#title' => t('Available actortype categories.'),
'#description' => t('Select the actortype categories that will be used to filter the autocomplete.'),
'#type' => 'checkboxes',
'#options' => $options,
'#default_value' => variable_get('agenda_actor_search'),
);

$visibility_options = culturefeed_search_get_categories_by_domain('eventtype');
asort($visibility_options);
$form['agenda_actor_search_visibility'] = array(
'#title' => t('Visibility settings.'),
'#description' => t('Select the eventtypes where tis block may be visible.'),
'#type' => 'checkboxes',
'#options' => $visibility_options,
'#default_value' => variable_get('agenda_actor_search_visibility'),
);

}

return $form;
Expand All @@ -380,6 +432,10 @@ function culturefeed_agenda_block_save($delta, $edit) {
elseif ($delta == 'agenda-search-block') {
variable_set('agenda_search_block_domain_id', $edit['agenda_search_block_domain_id']);
}
elseif ($delta == 'agenda-actor-search') {
variable_set('agenda_actor_search', $edit['agenda_actor_search']);
variable_set('agenda_actor_search_visibility', $edit['agenda_actor_search_visibility']);
}

}

Expand All @@ -406,6 +462,8 @@ function culturefeed_agenda_block_view($delta) {
case 'production-program':
return culturefeed_agenda_block_production_program();

case 'agenda-actor-search':
return culturefeed_agenda_block_actor_search_facet();
}

return $block;
Expand All @@ -429,7 +487,7 @@ function culturefeed_agenda_culturefeed_search_ui_active_filters($culturefeedFac
unset($search_query['actor']);
$url = url($path, array('query' => $search_query));
$build['nearby'] = array(
'#theme' => 'culturefeed_search_active_filters_item',
'#theme' => 'cul turefeed_search_active_filters_item',
'#label' => check_plain($actor->getTitle(culturefeed_search_get_preferred_language())),
'#url' => $url,
);
Expand Down
39 changes: 39 additions & 0 deletions culturefeed_agenda/includes/admin.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

/**
* @file
* Admin settings for culturefeed_agenda.
*/

/**
* General settings for culturefeed_agenda.
*/
function culturefeed_agenda_admin_settings_form() {

$form = array();

$form['culturefeed_agenda_active_entity_types'] = array(
'#title' => t('Entity types to be searched'),
'#type' => 'checkboxes',
'#options' => culturefeed_agenda_known_entity_types(),
'#default_value' => variable_get('culturefeed_agenda_active_entity_types', array('event', 'production')),
'#description' => t('Select the different entity types that can be shown on agenda/search'),
);

$form = system_settings_form($form);
$form['#submit'] = array('culturefeed_agenda_admin_settings_form_submit');

return $form;

}

/**
* Submit the settings form.
*/
function culturefeed_agenda_admin_settings_form_submit($form, $form_state) {

$form_state['values']['culturefeed_agenda_active_entity_types'] = array_filter($form_state['values']['culturefeed_agenda_active_entity_types']);
system_settings_form_submit($form, $form_state);

}

87 changes: 86 additions & 1 deletion culturefeed_agenda/includes/blocks.inc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
* Block callbacks for culturefeed agenda.
*/

use \CultuurNet\Search\Parameter;

/**
* Block to show the related events from an item.
*/
Expand Down Expand Up @@ -55,10 +57,20 @@ function culturefeed_agenda_search_block_form($form, &$form_state) {
}
asort($options);

if (isset($_GET['facet']['category_' . $domain_id . '_id'][0])) {
$default = $_GET['facet']['category_' . $domain_id . '_id'][0];
}
elseif (isset($_GET['facet']['category_id'][0])) {
$default = $_GET['facet']['category_id'][0];
}
else {
$default = NULL;
}

$form['category'] = array(
'#type' => 'select',
'#options' => $options,
'#default_value' => isset($_GET['facet']['category_' . $domain_id . '_id'][0]) ? $_GET['facet']['category_' . $domain_id . '_id'][0] : NULL,
'#default_value' => $default,
);

$form_state['#domain_id'] = $domain_id;
Expand Down Expand Up @@ -246,3 +258,76 @@ function culturefeed_agenda_block_production_program() {
return $block;

}

function culturefeed_agenda_block_actor_search_facet() {

// Only go if we're on an agenda search page.
if (current_path() != 'agenda/search') {
return;
}

// Only show this block if allowed in the block settings.
if (isset($_GET['facet']['category_eventtype_id'][0])) {
$current_event = $_GET['facet']['category_eventtype_id'][0];
}
elseif (isset($_GET['facet']['category_id'][0])) {
$current_event = $_GET['facet']['category_id'][0];
}
else {
$current_event = '';
}

$saved_events = variable_get('agenda_actor_search_visibility');
$allowed_events = array();

foreach ($saved_events as $saved_event) {
if ($saved_event != 0) {
$allowed_events[] = $saved_event;
}
}

if (!in_array($current_event, $allowed_events)) {
return;
}

// Create build array with actor search form and nearby actors.
$build = array();
$build['form'] = drupal_get_form('culturefeed_agenda_block_actor_search_form');
$build['actors_nearby'] = culturefeed_agenda_get_actors_nearby_for_event($current_event);

return array(
'subject' => t('Actor'),
'content' => $build,
);
}

/**
* Form callback to show the agenda actor search block.
*/
function culturefeed_agenda_block_actor_search_form($form, &$form_state) {
$form = array();

$form['#attached']['js'] = array(
array('data' => CULTUREFEED_GOOGLE_MAPS_JS_API, 'type' => 'external'),
drupal_get_path('module', 'culturefeed_agenda') . '/js/autocomplete_autosubmit.js',
);
$form['#attached']['library'] = array(
array('system', 'jquery.cookie'),
);

$form['search'] = array(
'#type' => 'textfield',
'#size' => 28,
'#title' => t('Search string'),
'#title_display' => 'invisible',
'#attributes' => array('class' => array('auto-submit-field'), 'placeholder' => t('Plaats of naam')),
'#autocomplete_path' => 'autocomplete/culturefeed/agenda/actor-search'
);

return $form;
}





Loading

0 comments on commit a83a06c

Please sign in to comment.