Fixed errors and changed source of flattrs

Fixed errors, and the number displayed is no longer the number of peope
who has flattred an article, but the number of flattrs he has got.
This commit is contained in:
Thomas Citharel 2013-09-08 21:52:01 +02:00
parent a322312740
commit af1d279226
2 changed files with 9 additions and 9 deletions

View File

@ -249,20 +249,21 @@ class Poche
$content = $tidy->value; $content = $tidy->value;
// flattr checking // flattr checking
$flattr = new FlattrItem(); $flattr = new FlattrItem();
$flattr->checkitem($entry['url']); $flattr->checkitem($entry['url']);
$tpl_vars = array( $tpl_vars = array(
'entry' => $entry, 'entry' => $entry,
'content' => $content, 'content' => $content,
'flattr' => $flattr, 'flattr' => $flattr
); );
}
} }
else { else {
Tools::logm('error in view call : entry is null'); Tools::logm('error in view call : entry is null');
} }
break; break;
default: # home, favorites and archive views default : // home, favorites and archive views
$entries = $this->store->getEntriesByView($view, $this->user->getId()); $entries = $this->store->getEntriesByView($view, $this->user->getId());
$tpl_vars = array( $tpl_vars = array(
'entries' => '', 'entries' => '',
@ -577,7 +578,6 @@ class FlattrItem{
public function checkitem($urltoflattr){ public function checkitem($urltoflattr){
$this->cacheflattrfile($urltoflattr); $this->cacheflattrfile($urltoflattr);
$flattrResponse = file_get_contents("cache/flattr/".base64_encode($urltoflattr).".cache"); $flattrResponse = file_get_contents("cache/flattr/".base64_encode($urltoflattr).".cache");
var_dump($flattrResponse);
if($flattrResponse != FALSE){ if($flattrResponse != FALSE){
$result = json_decode($flattrResponse); $result = json_decode($flattrResponse);
if (isset($result->message)){ if (isset($result->message)){
@ -588,7 +588,7 @@ class FlattrItem{
elseif ($result->link) { elseif ($result->link) {
$this->status = "flattred"; $this->status = "flattred";
$this->flattrItemURL = $result->link; $this->flattrItemURL = $result->link;
$this->numflattrs = $result->flattrs_user_count; $this->numflattrs = $result->flattrs;
} }
else{ else{
$this->status = "not flattrable"; $this->status = "not flattrable";

View File

@ -31,7 +31,7 @@
{% if constant('SHARE_TWITTER') == 1 %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@getpoche" target="_blank" class="tool twitter" title="{% trans "tweet" %}"><span>{% trans "tweet" %}</span></a></li>{% endif %} {% if constant('SHARE_TWITTER') == 1 %}<li><a href="https://twitter.com/home?status={{entry.title|url_encode}}%20{{ entry.url|url_encode }}%20via%20@getpoche" target="_blank" class="tool twitter" title="{% trans "tweet" %}"><span>{% trans "tweet" %}</span></a></li>{% endif %}
{% if constant('SHARE_MAIL') == 1 %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&amp;body={{ entry.url|url_encode }}%20via%20@getpoche" class="tool email" title="{% trans "email" %}"><span>{% trans "email" %}</span></a></li>{% endif %} {% if constant('SHARE_MAIL') == 1 %}<li><a href="mailto:?subject={{ entry.title|url_encode }}&amp;body={{ entry.url|url_encode }}%20via%20@getpoche" class="tool email" title="{% trans "email" %}"><span>{% trans "email" %}</span></a></li>{% endif %}
{% if constant('SHARE_SHAARLI') == 1 %}<li><a href="{{ constant('SHAARLI_URL') }}/index.php?post={{ entry.url|url_encode }}&amp;title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans "shaarli" %}"><span>{% trans "shaarli" %}</span></a></li>{% endif %} {% if constant('SHARE_SHAARLI') == 1 %}<li><a href="{{ constant('SHAARLI_URL') }}/index.php?post={{ entry.url|url_encode }}&amp;title={{ entry.title|url_encode }}" target="_blank" class="tool shaarli" title="{% trans "shaarli" %}"><span>{% trans "shaarli" %}</span></a></li>{% endif %}
<li>{% if flattr.status == "flattrable" %} This thing is flattrable !{% elseif flattr.status == "flattred" %} <a href="{{ flattr.flattrItemURL }}" >This thing has already been flattred by {{ flattr.numflattrs }} users and can be flattred !</a>{% else %}This article cannot be flattred{% endif %}</li> <li>{% if flattr.status == "flattrable" %} This thing is flattrable !{% elseif flattr.status == "flattred" %} <a href="{{ flattr.flattrItemURL }}" >This thing has already been flattred {{ flattr.numflattrs }} times and can be flattred !</a>{% else %}This article cannot be flattred{% endif %}</li>
</ul> </ul>
<p>{% trans "this article appears wrong?" %} <a href="https://github.com/inthepoche/poche/issues/new">{% trans "create an issue" %}</a> {% trans "or" %} <a href="mailto:support@inthepoche.com?subject=Wrong%20display%20in%20poche&amp;body={{ entry.url|url_encode }}">{% trans "contact us by mail" %}</a></p> <p>{% trans "this article appears wrong?" %} <a href="https://github.com/inthepoche/poche/issues/new">{% trans "create an issue" %}</a> {% trans "or" %} <a href="mailto:support@inthepoche.com?subject=Wrong%20display%20in%20poche&amp;body={{ entry.url|url_encode }}">{% trans "contact us by mail" %}</a></p>
</div> </div>