<commit_before><?php

/**
 * Plugin Name: EPFL Infoscience search shortcode
 * Plugin URI: https://github.com/epfl-idevelop/jahia2wp
 * Description: provides a shortcode to search and dispay results from Infoscience
 * Version: 1.0
 * Author: <NAME>
 * Author URI: https://people.epfl.ch/julien.delasoie?lang=en
 * Contributors: 
 * License: Copyright (c) 2018 Ecole Polytechnique Federale de Lausanne, Switzerland
*/

set_include_path(get_include_path() . PATH_SEPARATOR . dirname( __FILE__) . '/lib');
 
require_once 'utils.php';
require_once 'shortcake-config.php';
require_once 'render.php';
require_once 'marc_converter.php';
require_once 'group_by.php';
require_once 'mathjax-config.php';

define("INFOSCIENCE_SEARCH_URL", "https://infoscience.epfl.ch/search?");

function epfl_infoscience_search_url_exists( $url )
{
    $handle = curl_init( $url );
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);

    $response = curl_exec( $handle );
    $httpCode = curl_getinfo( $handle, CURLINFO_HTTP_CODE );
    curl_close($handle);
    return ( $httpCode >= 200 && $httpCode <= 400 );
}

 /**
  * From any attributes, set them as url parameters for Infoscience
  *
  * @param array $attrs attributes that need to be sent to Infoscience
  *
  * @return string $url the url build
  */
  function epfl_infoscience_search_convert_keys_values($array_to_convert) {
    $convert_fields = function($value) {
        return ($value === 'any') ? '' : $value;
    };

    $convert_operators = function($value) {<commit_msg>Fix missing argument that echo curl result<commit_after><?php

/**
 * Plugin Name: EPFL Infoscience search shortcode
 * Plugin URI: https://github.com/epfl-idevelop/jahia2wp
 * Description: provides a shortcode to search and dispay results from Infoscience
 * Version: 1.3
 * Author: <NAME>
 * Author URI: https://people.epfl.ch/julien.delasoie?lang=en
 * Contributors: 
 * License: Copyright (c) 2018 Ecole Polytechnique Federale de Lausanne, Switzerland
*/

set_include_path(get_include_path() . PATH_SEPARATOR . dirname( __FILE__) . '/lib');
 
require_once 'utils.php';
require_once 'shortcake-config.php';
require_once 'render.php';
require_once 'marc_converter.php';
require_once 'group_by.php';
require_once 'mathjax-config.php';

define("INFOSCIENCE_SEARCH_URL", "https://infoscience.epfl.ch/search?");

function epfl_infoscience_search_url_exists( $url )
{
    $handle = curl_init( $url );
    curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);

    $response = curl_exec( $handle );
    $httpCode = curl_getinfo( $handle, CURLINFO_HTTP_CODE );
    curl_close($handle);

    return ( $httpCode >= 200 && $httpCode <= 400 );
}

 /**
  * From any attributes, set them as url parameters for Infoscience
  *
  * @param array $attrs attributes that need to be sent to Infoscience
  *
  * @return string $url the url build
  */
  function epfl_infoscience_search_convert_keys_values($array_to_convert) {
    $convert_fields = function($value) {
        return ($value === 'any') ? '' : $value;
    };

    $convert_operators = function($value) {
{'fraction_non_alphanumeric': 0.12636305323925592, 'fraction_numerical': 0.008338678640153944, 'mean_word_length': 4.599640933572711, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '22590', 'n_tokens_mistral': 1082, 'n_tokens_neox': 1019, 'n_words': 243}