Conditions | 3 |
Paths | 3 |
Total Lines | 22 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
41 | public function renderPageViewCount(Meta $meta = null) |
||
42 | { |
||
43 | if (null === $meta) { |
||
44 | return; |
||
45 | } |
||
46 | |||
47 | $jsTemplate = <<<'EOT' |
||
48 | <script type="text/javascript"> |
||
49 | var xhr = new XMLHttpRequest(); |
||
50 | var read_date = new Date(); |
||
51 | var request_randomizer = "&" + read_date.getTime() + Math.random(); |
||
52 | xhr.open('GET', '/_swp_analytics?articleId=%s'+request_randomizer); |
||
53 | xhr.send(); |
||
54 | </script> |
||
55 | EOT; |
||
56 | $article = $meta->getValues(); |
||
57 | if (!$article instanceof ArticleInterface) { |
||
58 | return; |
||
59 | } |
||
60 | |||
61 | return sprintf($jsTemplate, $article->getId()); |
||
62 | } |
||
63 | } |
||
64 |