' . __( 'Paramètres', 'wp-hal' ) . '';
array_unshift( $links, $settings_link );
return $links;
}
add_filter( 'plugin_action_links', 'hal_plugin_action_links',10,2);
/***********************************************************************************************************************
* PLUGIN SHORTCODE ND-DOC
**********************************************************************************************************************/
function nb_doc($param)
{
$idhal = verifSolr(get_option('option_idhal'));
extract(shortcode_atts(array(
'type' => get_option('option_type'),
'id' => $idhal
),
$param
));
$id = verifSolr($id);
$url = api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&rows=0&wt=json';
$ch = curl_init($url);
// Options
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
CURLOPT_TIMEOUT => 10,
CURLOPT_USERAGENT => "HAL Plugin Wordpress " . version
);
// Bind des options et de l'objet cURL que l'on va utiliser
curl_setopt_array($ch, $options);
// Récupération du résultat JSON
$json = json_decode(curl_exec($ch));
curl_close($ch);
return $json->response->numFound;
}
/***********************************************************************************************************************
* PLUGIN SHORTCODE CV-HAL
**********************************************************************************************************************/
function cv_hal($param){
if ( !function_exists('curl_init' ) ) {
echo 'Please check the';?> FAQ get_option('option_type'),
'id' => $idhal,
'contact' => get_option('option_infocontact')
),
$param
));
$id = verifSolr($id);
if (get_option('option_groupe') == 'grouper') {
//cURL sur l'API pour récupérer les données
$url = api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&group=true&group.field=docType_s&group.limit=1000&fl=docid,citationFull_s&facet.field=' . lang . '_domainAllCodeLabel_fs&facet.field=keyword_s&facet.field=journalIdTitle_fs&facet.field=producedDateY_i&facet.field=authIdLastNameFirstName_fs&facet.field=instStructIdName_fs&facet.field=labStructIdName_fs&facet.field=deptStructIdName_fs&facet.field=rteamStructIdName_fs&facet.mincount=1&facet=true&sort=' . producedDateY . '&wt=json&json.nl=arrarr';
} elseif (get_option('option_groupe') == 'paginer') {
$url = api . '?q=*:*&fq=' . $type . ':(' . urlencode($id) . ')&fl=docid,citationFull_s&facet.field=' . lang . '_domainAllCodeLabel_fs&facet.field=keyword_s&facet.field=journalIdTitle_fs&facet.field=producedDateY_i&facet.field=authIdLastNameFirstName_fs&facet.field=instStructIdName_fs&facet.field=labStructIdName_fs&facet.field=deptStructIdName_fs&facet.field=rteamStructIdName_fs&facet.mincount=1&facet=true&sort=' . producedDateY . '&wt=json&json.nl=arrarr';
}
$ch = curl_init($url);
// Options
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
CURLOPT_TIMEOUT => 10,
CURLOPT_USERAGENT => "HAL Plugin Wordpress " . version
);
// Bind des options et de l'objet cURL que l'on va utiliser
curl_setopt_array($ch, $options);
// Récupération du résultat JSON
$json = json_decode(curl_exec($ch));
curl_close($ch);
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$content = '
';
}
$content .= '';
//--AFFICHAGE GRAPHIQUE DOMAINE--//
if (!is_null($facetdomain)) {
foreach ($facetdomain as $res) {
$name = explode(delimiter, $res[0])[1];
$value = $res[1];
$array[] = array($name, $value);
}
}
wp_localize_script('wp-hal-script4', 'WPWallSettings', json_encode($array));
$translation = array('liste' => __('Liste', 'wp-hal'), 'compl' => __('Liste complète', 'wp-hal'), 'princ' => __('Liste principale', 'wp-hal'), 'graph' => __('Graphique', 'wp-hal'), 'nuage' => __('Nuage de mots', 'wp-hal'));
wp_localize_script('wp-hal-script4', 'translate', $translation);
}
return $content;
}
function verifSolr($values){
$verifsolr = explode(',',$values);
$numverif = count($verifsolr);
$solrsql = '';
if ($numverif<1024){
$solrsql = str_replace(',',' OR ',$values);
} else {
$listsolrsql = explode(',',$values);
for($i=0;$i<1024;$i++){
if ($i == 0){
$solrsql = $listsolrsql[$i];
} else {
$solrsql .= ' OR ';
$solrsql .= $listsolrsql[$i];
}
}
}
return $solrsql;
}
function wp_adding_style() {
wp_register_style('wp-hal-style1', plugins_url('/css/style.css', __FILE__));
wp_register_style('wp-hal-style2', plugins_url('/css/jquery.jqplot.css', __FILE__));
wp_enqueue_style('wp-hal-style1');
}
function wp_adding_script() {
wp_register_script('wp-hal-script1',plugins_url('/js/jquery.jqplot.js', __FILE__));
wp_register_script('wp-hal-script2',plugins_url('/js/jqplot.highlighter.js', __FILE__));
wp_register_script('wp-hal-script3',plugins_url('/js/jqplot.pieRenderer.js', __FILE__));
wp_register_script('wp-hal-script4',plugins_url('/js/cv-hal.js', __FILE__));
wp_enqueue_script("jquery");
wp_enqueue_script('wp-hal-script4', false, array(), false, true);
}
/**
* Récupère les fichiers css et js
*/
if ( function_exists('curl_init' ) ) {
add_action('wp_enqueue_scripts', 'wp_adding_style');
add_action('wp_enqueue_scripts', 'wp_adding_script');
}
/**
* Charge lorsque le plugin est désactivé
*/
register_deactivation_hook( __FILE__, 'reset_option' );
/**
* Ajoute le widget wphal à l'initialisation des widgets
*/
add_action('widgets_init','wphal_init');
/**
* Ajoute le menu à l'initialisation du menu admin
*/
add_action( 'admin_menu', 'wphal_menu' );
/**
* Fonction de création du menu
*/
function wphal_menu() {
add_menu_page( 'Options', 'Hal', 'manage_options', 'wp-hal.php', 'wphal_option' , '', 21);
add_action( 'admin_init', 'register_settings' );
}
/**
* Initialise le nouveau widget
*/
function wphal_init(){
register_widget("wphal_widget");
}
/***********************************************************************************************************************
* PLUGIN WIDGET
**********************************************************************************************************************/
/**
* Classe du widget wphal
*/
class wphal_widget extends WP_widget{
/**
* Défini les propriétés du widget
*/
function wphal_widget(){
$options = array(
"classname" => "wphal-publications",
"description" => __("Afficher les dernières publications d'un auteur ou d'une structure.", 'wp-hal')
);
parent::__construct(
'hal-publications',
__("Publications récentes", 'wp-hal'),
$options
);
}
/**
* Crée le widget
* @param $args
* @param $instance
*/
function widget($args, $instance){
if ( !function_exists('curl_init' ) ) {
$content = 'Please check the FAQ with the code : CURL';
extract($args);
echo $before_widget;
echo $before_title . $instance['titre'] . $after_title;
echo $content;
echo $after_widget;
} else {
$instance['idhal'] = verifSolr($instance['idhal']);
$url = api . '?q=*:*&fq=' . $instance['select'] . ':' . urlencode($instance['idhal']) . '&fl=uri_s,'. $instance['typetext'] .'&sort=' . producedDateY . '&rows=' . $instance['nbdoc'] . '&wt=json';
$ch = curl_init($url);
// Options
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-type: application/json'),
CURLOPT_TIMEOUT => 10,
CURLOPT_USERAGENT => "HAL Plugin Wordpress " . version
);
// Bind des options et de l'objet cURL que l'on va utiliser
curl_setopt_array($ch, $options);
// Récupération du résultat JSON
$json = json_decode(curl_exec($ch));
curl_close($ch);
$content = '';
for ($i = 0; $i < $instance['nbdoc']; $i++) {
if ($instance['typetext']=='citationRef_s') {
$typetext = $json->response->docs[$i]->citationRef_s;
} else {
$typetext = $json->response->docs[$i]->title_s[0];
}
$content .= '' . $typetext . ' ';
}
$content .= ' ';
extract($args);
echo $before_widget;
echo $before_title . $instance['titre'] . $after_title;
echo $content;
echo $after_widget;
}
}
/**
* Sauvegarde des données
* @param $new
* @param $old
*/
function update($new, $old){
return $new;
}
/**
* Formulaire du widget
* @param $instance
*/
function form($instance){
$defaut = array(
'titre' => __("Publications récentes", 'wp-hal'),
'select' => "authIdHal_s",
'typetext' => "title_s",
'nbdoc' => 5
);
$instance = wp_parse_args($instance,$defaut);
?>
">
" id="get_field_id("titre");?>" class="widefat" type="text"/>
">
" name="get_field_name("nbdoc");?>" type="number" step="1" min="1" max="10" value="" size="3">
">
" name="get_field_name("typetext");?>">
" value="title_s" >">
" value="citationRef_s" >">
">
" name="get_field_name("select");?>">
" value="authIdHal_s" >">Id Hal
" value="structId_i" >">Struct Id
" value="authStructId_i" >">AuthorStruct Id
" value="authId_i" >">Author Id
" value="anrProjectId_i" >">anrProject Id
" value="europeanProjectId_i" >">europeanProject Id
" value="collCode_s" >">Collection
">
" id="get_field_id("idhal");?>" type="text"/>