Browse Source

start eds port port settings form info yml and routing yml

d9
ppound 3 years ago
parent
commit
f24f3de869
  1. 38
      targets/eds/Controller/RoblibSearchEdsController.php
  2. 133
      targets/eds/Form/RoblibSearchEdsSettingsForm.php
  3. 10
      targets/eds/roblib_search_eds.info
  4. 8
      targets/eds/roblib_search_eds.info.yml
  5. 2
      targets/eds/roblib_search_eds.install
  6. 98
      targets/eds/roblib_search_eds.module
  7. 25
      targets/eds/roblib_search_eds.routing.yml

38
targets/eds/Controller/RoblibSearchEdsController.php

@ -0,0 +1,38 @@
<?php
namespace Drupal\roblib_search_eds\Controller;
use Drupal\Core\Controller\ControllerBase;
/**
* Controller for d3 graphs.
*/
class RoblibSearchEdsController extends ControllerBase {
/**
* Display the markup.
*
* @return array
* A renderable array.
*/
public function articleResults($query = NULL) {
return [
'#theme' => 'roblib_search_results',
'#query' => $query,
];
}
/**
* Display the markup.
*
* @return array
* A renderable array.
*/
public function bookResults($query = NULL) {
return [
'#theme' => 'roblib_search_results',
'#query' => $query,
];
}
}

133
targets/eds/Form/RoblibSearchEdsSettingsForm.php

@ -0,0 +1,133 @@
<?php
namespace Drupal\roblib_search\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormStateInterface;
/**
* Settings form for module
*
* @author ppound
*/
class RoblibSearchEdsSettingsForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormId() {
return 'roblib_search_eds_settings_form';
}
/**
* {@inheritdoc}
*/
public function buildForm(array $form, FormStateInterface $form_state) {
$config = \Drupal::config('roblib_search_eds.settings');
$form['eds_rest_url'] = array(
'#type' => 'textfield',
'#title' => t('EDS Rest endpoint'),
'#default_value' => $config->get('eds_rest_url'),
'#description' => t('The base EDS URL, for example https://eds-api.ebscohost.com/edsapi/rest'),
'#required' => TRUE,
);
$form['eds_auth_url'] = array(
'#type' => 'textfield',
'#title' => t('EDS Auth endpoint'),
'#default_value' => $config->get('eds_auth_url'),
'#description' => t('The EDS Auth endpoint, for example https://eds-api.ebscohost.com/Authservice/rest'),
'#required' => TRUE,
);
$form['eds_user'] = array(
'#type' => 'textfield',
'#title' => t('EDS user'),
'#default_value' => $config->get('eds_user'),
'#description' => t('EDS user, for example username'),
'#required' => TRUE,
);
$form['eds_pass'] = array(
'#type' => 'textfield',
'#title' => t('EDS password'),
'#default_value' => $config->get('eds_pass'),
'#description' => t('EDS password, for example password'),
'#required' => TRUE,
);
$form['eds_guest'] = array(
'#type' => 'textfield',
'#title' => t('EDS Guest access'),
'#default_value' => $config->get('eds_guest'),
'#description' => t('EDS Guest access, y = guest access, n = not a guest'),
'#required' => TRUE,
);
$form['eds_article_profile'] = array(
'#type' => 'textfield',
'#title' => t('EDS Article profile'),
'#default_value' => $config->get('eds_article_profile'),
'#description' => t('EDS profile, for example edsapi'),
'#required' => TRUE,
);
$form['eds_book_profile'] = array(
'#type' => 'textfield',
'#title' => t('EDS Book profile'),
'#default_value' => $config->get('eds_book_profile'),
'#description' => t('EDS Book profile, for example apilite'),
'#required' => TRUE,
);
$form['eds_num_results'] = array(
'#type' => 'textfield',
'#title' => t('Number of results to return'),
'#default_value' => $config->get('eds_num_results'),
'#description' => t('The number of results to display in the Bento box, usurally 5'),
'#required' => TRUE,
);
$form['eds_article_limiters'] = array(
'#type' => 'textarea',
'#title' => t('The limiters for Article searches'),
'#default_value' => $config->get('eds_article_limiters'),
'#description' => t('Specify the Publication Types to use as limiters for Article searches. Formatted similar to
AND (PT Article OR PT Magazines OR PT News OR PT Academic Journals OR PT Conference Materials)'),
'#required' => TRUE,
);
$form['eds_book_limiters'] = array(
'#type' => 'textarea',
'#title' => t('The limiters for Books and Media searches'),
'#default_value' => $config->get('eds_book_limiters'),
'#description' => t('Specify the Publication Types to use as limiters for Article searches. Formatted similar to
AND (PT Book OR PT Video OR PT Audio'),
'#required' => TRUE,
);
return $form;
}
/**
* {@inheritdoc}
*/
public function validateForm(array &$form, FormStateInterface $form_state) {
}
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
$config = \Drupal::configFactory()->getEditable('roblib_search_eds.settings');
$config->set('eds_rest_url', $form_state->getValue('eds_rest_url'))->save();
$config->set('eds_auth_url', $form_state->getValue('eds_auth_url'))->save();
$config->set('eds_user', $form_state->getValue('eds_user'))->save();
$config->set('eds_pass', $form_state->getValue('eds_pass'))->save();
$config->set('eds_guest', $form_state->getValue('eds_guest'))->save();
$config->set('eds_article_profile', $form_state->getValue('eds_article_profile'))->save();
$config->set('eds_book_profile', $form_state->getValue('eds_book_profile'))->save();
$config->set('eds_num_results', $form_state->getValue('eds_num_results'))->save();
$config->set('eds_article_limiters', $form_state->getValue('eds_article_limiters'))->save();
$config->set('eds_book_limiters', $form_state->getValue('eds_book_limiters'))->save();
}
}

10
targets/eds/roblib_search_eds.info

@ -1,10 +0,0 @@
name = Roblib Search EDS
dependencies[] = roblib_search
dependencies[] = ebsco
configure = admin/roblib_search/eds_search
description = implements the Roblib Search modules _roblib_search hook
package = Roblib Search
version = 7.x-dev
core = 7.x
stylesheets[all][] = css/roblib_search_eds.css

8
targets/eds/roblib_search_eds.info.yml

@ -0,0 +1,8 @@
name: Roblib Search EDS
configure: admin/roblib_search/eds_search
description: Implements the Roblib Search modules _roblib_search hook
package: Roblib Search
core_version_requirement: ^8.9 || ^9
dependancies:
- roblib_search
- ebsco

2
targets/eds/roblib_search_eds.install

@ -1,2 +0,0 @@
<?php

98
targets/eds/roblib_search_eds.module

@ -57,93 +57,6 @@ function roblib_search_eds_info($type = 'Articles') {
exit();
}
function roblib_search_eds_config_form($form, &$form_state) {
$form['roblib_search_eds_rest_url'] = array(
'#type' => 'textfield',
'#title' => t('EDS Rest endpoint'),
'#default_value' => variable_get('roblib_search_eds_rest_url', 'https://eds-api.ebscohost.com/edsapi/rest'),
'#description' => t('The base EDS URL, for example https://eds-api.ebscohost.com/edsapi/rest'),
'#required' => TRUE,
);
$form['roblib_search_eds_auth_url'] = array(
'#type' => 'textfield',
'#title' => t('EDS Auth endpoint'),
'#default_value' => variable_get('roblib_search_eds_auth_url', 'https://eds-api.ebscohost.com/Authservice/rest'),
'#description' => t('The EDS Auth endpoint, for example https://eds-api.ebscohost.com/Authservice/rest'),
'#required' => TRUE,
);
$form['roblib_search_eds_user'] = array(
'#type' => 'textfield',
'#title' => t('EDS user'),
'#default_value' => variable_get('roblib_search_eds_user', 'edsusername'),
'#description' => t('EDS user, for example username'),
'#required' => TRUE,
);
$form['roblib_search_eds_pass'] = array(
'#type' => 'textfield',
'#title' => t('EDS password'),
'#default_value' => variable_get('roblib_search_eds_pass', 'edspassword'),
'#description' => t('EDS password, for example password'),
'#required' => TRUE,
);
$form['roblib_search_eds_guest'] = array(
'#type' => 'textfield',
'#title' => t('EDS Guest access'),
'#default_value' => variable_get('roblib_search_eds_guest', 'y'),
'#description' => t('EDS Guest access, y = guest access, n = not a guest'),
'#required' => TRUE,
);
$form['roblib_search_eds_profile'] = array(
'#type' => 'textfield',
'#title' => t('EDS Article profile'),
'#default_value' => variable_get('roblib_search_eds_profile', 'edsapi'),
'#description' => t('EDS profile, for example edsapi'),
'#required' => TRUE,
);
$form['roblib_search_eds_book_profile'] = array(
'#type' => 'textfield',
'#title' => t('EDS Book profile'),
'#default_value' => variable_get('roblib_search_eds_book_profile', 'apilite'),
'#description' => t('EDS Book profile, for example apilite'),
'#required' => TRUE,
);
$form['roblib_search_eds_num_results'] = array(
'#type' => 'textfield',
'#title' => t('Number of results to return'),
'#default_value' => variable_get('roblib_search_eds_num_results', '5'),
'#description' => t('The number of results to display in the Bento box'),
'#required' => TRUE,
);
$form['roblib_search_eds_article_limiters'] = array(
'#type' => 'textarea',
'#title' => t('The limiters for Article searches'),
'#default_value' => variable_get('roblib_search_eds_article_limiters',
'AND (PT Article OR PT Magazines OR PT News OR PT Academic Journals OR PT Conference Materials)'),
'#description' => t('Specify the Publication Types to use as limiters for Article searches. Formatted similar to
AND (PT Article OR PT Magazines OR PT News OR PT Academic Journals OR PT Conference Materials)'),
'#required' => TRUE,
);
$form['roblib_search_eds_book_limiters'] = array(
'#type' => 'textarea',
'#title' => t('The limiters for Books and Media searches'),
'#default_value' => variable_get('roblib_search_eds_book_limiters',
'AND (PT Book OR PT Video OR PT Audio)'),
'#description' => t('Specify the Publication Types to use as limiters for Article searches. Formatted similar to
AND (PT Book OR PT Video OR PT Audio'),
'#required' => TRUE,
);
return system_settings_form($form);
}
/**
* Implements hook_permission().
*/
@ -185,16 +98,7 @@ function roblib_search_eds_theme() {
);
}
function roblib_search_eds_preprocess_panels_pane(&$variables, $hook){
if($variables['pane']->subtype == 'roblib_search_eds-roblib_search_eds_articles'){
$variables['title_prefix'] = '<div class="roblib-search-header roblib-search-eds-articles-header">';
$variables['title_suffix'] ='</div>';
}
if($variables['pane']->subtype == 'roblib_search_eds-roblib_search_eds_results'){
$variables['title_prefix'] = '<div class="roblib-search-header roblib-search-eds-media-header">';
$variables['title_suffix'] ='</div>';
}
}
function roblib_search_eds_block_info() {

25
targets/eds/roblib_search_eds.routing.yml

@ -0,0 +1,25 @@
roblib_search_eds.settings:
path: '/admin/config/system/roblib_search'
defaults:
_form: '\Drupal\roblib_search_eds\Form\RoblibSearchEdsSettingsForm'
_title: 'Roblib Search EDS Settings Form'
requirements:
_permission: 'administer site configuration'
roblib_search_eds.article_search:
path: '/roblib_search/eds/articles/{query}'
defaults:
_controller: '\Drupal\roblib_search_eds\Controller\RoblibSearchEdsController::articleResults'
_title: 'Roblib Search EDS Articles'
query: '[a-zA-Z\s]+'
requirements:
_permission: 'access content'
roblib_search_eds.book_search:
path: '/roblib_search/eds/book/{query}'
defaults:
_controller: '\Drupal\roblib_search_eds\Controller\RoblibSearchEdsController::bookResults'
_title: 'Roblib Search EDS Articles'
query: '[a-zA-Z\s]+'
requirements:
_permission: 'access content'
Loading…
Cancel
Save