Skip to content

Commit

Permalink
handle incomplete licenses in template
Browse files Browse the repository at this point in the history
  • Loading branch information
eteubert committed Mar 18, 2014
1 parent 66af7aa commit a904248
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
4 changes: 2 additions & 2 deletions lib/model/license.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,13 @@ public function getUrl() {
}
}

private function hasCompleteCCData() {
public function hasCompleteCCData() {
return $this->cc_license_jurisdiction != ""
&& $this->cc_allow_modifications != ""
&& $this->cc_allow_commercial_use != "";
}

private function hasCompleteOtherData() {
public function hasCompleteOtherData() {
return $this->name != "" && $this->url != "";
}

Expand Down
4 changes: 2 additions & 2 deletions lib/template/license.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ public function creativeCommons() {
* @accessor
*/
public function valid() {
return strlen($this->url()) > 0
&& strlen($this->name()) > 0;
return $this->creativeCommons() && $this->license->hasCompleteCCData()
|| !$this->creativeCommons() && $this->license->hasCompleteOtherData();
}

/**
Expand Down
26 changes: 17 additions & 9 deletions templates/license.twig
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,21 @@
{% endif %}
{% endif %}

{% if license.creativeCommons %}
<div class="podlove_cc_license">
<img src="{{ license.imageUrl }}" alt="License" />
<p>
This work is licensed under a <a rel="license" href="{{ license.url }}">{{ license.name }}</a>
</p>
</div>
{% if license.valid %}
{% if license.creativeCommons %}
<div class="podlove_cc_license">
<img src="{{ license.imageUrl }}" alt="License" />
<p>
This work is licensed under a <a rel="license" href="{{ license.url }}">{{ license.name }}</a>
</p>
</div>
{% else %}
This work is licensed under the <a href="{{ license.url }}">{{ license.name }}</a> license.
{% endif %}
{% else %}
This work is licensed under the <a href="{{ license.url }}">{{ license.name }}</a> license.
{% endif %}
<div class="podlove_license">
<p style="color: red;">
This work is (not yet) licensed, as no license was chosen.
</p>
</div>
{% endif %}

0 comments on commit a904248

Please sign in to comment.