-
Notifications
You must be signed in to change notification settings - Fork 0
/
s3-coll-status.php
82 lines (76 loc) · 3.71 KB
/
s3-coll-status.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* @package SCOAP3 Status
* @version 0.7.1
*/
/*
Plugin Name: SCOAP3 Status
Plugin URI: http://github.com/scoap3/scoap3-collections-status
Description: Adds a short code to display a dynamically updated table showing current articles count for different SCOAP3 collections
Author: CERN
Version: 0.7.1
*/
wp_register_script('s3-coll-status', plugins_url('s3-coll-status.js', __FILE__ ), array('jquery'), NULL, false);
wp_enqueue_script('s3-coll-status');
function create_collections_table() {
$table = '<p>Last update on: ' . date("d/m/Y") . '</p>
<table id="tablepress-10" class="tablepress tablepress-id-10">
<thead>
<tr class="row-1 odd">
<th class="column-1">Journal Name</th><th class="column-2">Publisher</th><th class="column-3">Number of articles</th>
</tr>
</thead>
<tbody id="s3-collections-count" class="row-hover">
<tr id="s3-count-loader" class="row-2"><td class="column-1"></td><td class="column-2"><img src="'.plugins_url('default.svg', __FILE__ ).'"></td><td class="column-3"></td></tr>
</tbody></table>';
$table .= '<script type="text/javascript"><!--//--><![CDATA[//><!--
getCollectionsCount();
//--><!]]></script>';
return $table;
}
function create_repo_status($atts) {
$attributes = shortcode_atts( array(
'zero_value_filler' => '-'
), $atts );
$text = '<div class="scoap3_repo_cell" id="scoap3_header_out">Articles funded by SCOAP<sup>3</sup>:</div>
<div class="scoap3_repo_table">
<div class="scoap3_repo_row">
<div class="scoap3_repo_cell" id="scoap3_header_in">Articles funded by SCOAP<sup>3</sup>:</div>
<div class="scoap3_repo_cell value">
<span id="scoap3_repo_status_yesterday">'. $attributes['zero_value_filler'] .'</span>
<span class="description">yesterday</span>
</div>
<div class="scoap3_repo_cell value">
<span id="scoap3_repo_status_last_30_days">'. $attributes['zero_value_filler'] .'</span>
<span class="description">last 30 days</span>
</div>
<div class="scoap3_repo_cell value">
<span id="scoap3_repo_status_this_year">'. $attributes['zero_value_filler'] .'</span>
<span class="description">in '. date("Y") .'</span>
</div>
<div class="scoap3_repo_cell value">
<span id="scoap3_repo_status_all">'. $attributes['zero_value_filler'] .'</span>
<span class="description">since 2014</span>
</div>
</div>
</div>';
$text .= '<script type="text/javascript"><!--//--><![CDATA[//><!--
getRepoStatus("'.$attributes['zero_value_filler'].'");
//--><!]]></script>';
return $text;
}
function create_collection_count($atts) {
$attributes = shortcode_atts( array(
'name' => 'Acta'
), $atts );
$text = '<span class="scoap3_collection_count_'.str_replace(' ','_',$attributes['name']).'">-</span>';
$text .= '<script type="text/javascript"><!--//--><![CDATA[//><!--
getCollectionCount("'.$attributes['name'].'");
//--><!]]></script>';
return $text;
}
wp_register_style('s3-status-style', plugins_url('s3-status.css', __FILE__ ));
wp_enqueue_style('s3-status-style');
add_shortcode( 'scoap3-collections-status', 'create_collections_table' );
add_shortcode( 'scoap3-repository-status', 'create_repo_status' );
add_shortcode( 'scoap3-collection-count', 'create_collection_count' );