Commit a9b6bae3 authored by speedprogs_de's avatar speedprogs_de
Browse files

edited list template, added version utility, fixed format view helper

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@51960 735d13b6-9817-0410-8766-e36946ffe9aa
parent 4b04ada5
......@@ -170,6 +170,21 @@
}
/**
* Action that displays a single extension by extension key
*
* @param string $extensionKey The extension key
* @return void
*/
public function showByExtensionKey($extensionKey) {
if (empty($extensionKey) || !is_string($extensionKey)) {
throw new Exception('No valid extension key given');
}
$extension = $this->extensionRepository->findOneByExtKey($extensionKey);
$this->showAction($extension);
}
/**
* Displays a form for creating a new extension
*
......@@ -273,7 +288,7 @@
// Add extension key to session
$downloads[] = $extensionKey;
$session->add('downloads', $downloads);
$this->session->add('downloads', $downloads);
}
// Send file to browser
......
......@@ -353,5 +353,35 @@
return $this->frontendUser;
}
/**
* Returns all votes for the extension
*
* @return array Vote counts
*/
public function getVotes() {
$votes = array(
'positive' => 0,
'negative' => 0,
);
foreach ($this->versions as $version) {
$experiences = $version->getExperiences();
if (!is_array($experiences)) {
continue;
}
foreach ($experiences as $experience) {
$rating = (int) $experience->getRating();
if ($rating > 0) {
$votes['positive'] += $rating;
} else {
$votes['negative'] += $rating;
}
}
}
return $votes;
}
}
?>
\ No newline at end of file
......@@ -35,13 +35,6 @@
*/
protected $relationType;
/**
* Core, extension or system
* @var string
* @validate NotEmpty
*/
protected $softwareType;
/**
* Extension key, php, mysql or something else
* @var string
......@@ -83,27 +76,6 @@
}
/**
* Setter for softwareType
*
* @param string $softwareType Core, extension or system
* @return void
*/
public function setSoftwareType($softwareType) {
$this->softwareType = $softwareType;
}
/**
* Getter for softwareType
*
* @return string Core, extension or system
*/
public function getSoftwareType() {
return $this->softwareType;
}
/**
* Setter for relationKey
*
......@@ -121,7 +93,10 @@
* @return string extension key, php, mysql or something else
*/
public function getRelationKey() {
return $this->relationKey;
if (empty($this->relationKey)) {
return '';
}
return strtolower(trim($this->relationKey));
}
......@@ -142,7 +117,7 @@
* @return integer Minimum required version
*/
public function getMinimumVersion() {
return $this->minimumVersion;
return (int) $this->minimumVersion;
}
......@@ -163,7 +138,81 @@
* @return integer Maximum allowed version
*/
public function getMaximumVersion() {
return $this->maximumVersion;
return (int) $this->maximumVersion;
}
/**
* Returns minumum and maximum version as string
*
* @return string Version
*/
public function getVersionString() {
$version = array();
if (!empty($this->minimumVersion)) {
$version[] = Tx_TerFe2_Utility_Version::versionFromInteger($this->minimumVersion);
}
if (!empty($this->maximumVersion)) {
$version[] = Tx_TerFe2_Utility_Version::versionFromInteger($this->maximumVersion);
}
return (!empty($version) ? implode(' - ', $version) : '');
}
/**
* Get software type
*
* @return string core, system or extension
*/
public function getType() {
$key = $this->getRelationKey();
if (empty($key)) {
return '';
}
if ($key === 'cms' || $key === 'typo3') {
return 'core';
}
if ($key === 'php') {
return 'system';
}
return 'extension';
}
/**
* Is core relation
*
* @return boolean TRUE if related to core
*/
public function getIsCore() {
return ($this->getType() == 'core');
}
/**
* Is system relation
*
* @return boolean TRUE if related to system
*/
public function getIsSystem() {
return ($this->getType() == 'system');
}
/**
* Is extension relation
*
* @return boolean TRUE if related to an extension
*/
public function getIsExtension() {
return ($this->getType() == 'extension');
}
}
......
......@@ -901,6 +901,29 @@
}
/**
* Get filtered relations
*
* @return array Relations
*/
public function getFilteredSoftwareRelations() {
if (empty($this->softwareRelations)) {
return array();
}
$relations = array();
foreach ($this->softwareRelations as $relation) {
$relationKey = $relation->getRelationKey();
if (!empty($relationKey)) {
$relations[] = $relation;
}
}
return $relations;
}
/**
* Adds a relation
*
......
<?php
/*******************************************************************
* Copyright notice
*
* (c) 2011 Kai Vogel <kai.vogel@speedprogs.de>, Speedprogs.de
*
* All rights reserved
*
* This script is part of the TYPO3 project. The TYPO3 project is
* free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* The GNU General Public License can be found at
* http://www.gnu.org/copyleft/gpl.html.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* This copyright notice MUST APPEAR in all copies of the script!
******************************************************************/
/**
* Utilities to manage versions
*/
class Tx_TerFe2_Utility_Version {
/**
* Build version from integer
*
* @param integer $version The numeric version
* @return string Version string
*/
public static function versionFromInteger($version) {
if (empty($version)) {
return '';
}
$parts = t3lib_div::trimExplode('0', (string) $version, TRUE);
$parts = array_pad($parts, 3, 0);
return implode('.', $parts);
}
}
?>
\ No newline at end of file
......@@ -37,11 +37,11 @@
/**
* Formats content with given function
*
* @param mixed $content Content
* @param string $function Function to format the content
* @param mixed $content Content
* @return string Formated content
*/
public function render($content = NULL, $function) {
public function render($function, $content = NULL) {
if ($content === NULL) {
$content = $this->renderChildren();
}
......
......@@ -140,14 +140,18 @@
<label index="details">Details</label>
<label index="extension">Extension</label>
<label index="version">Version</label>
<label index="votes">Votes</label>
<label index="upload_comment">Upload comment</label>
<label index="version_history">Version history</label>
<label index="tags">Tags</label>
<label index="back_to_list">Back to list</label>
<label index="back_to_detail">Back to details</label>
<label index="create">Create</label>
<label index="edit">Edit</label>
<label index="delete">Delete</label>
<label index="download_t3x">Download T3X file</label>
<label index="download_zip">Download ZIP file</label>
<label index="download_t3x">Download [t3x]</label>
<label index="download_zip">Download [zip]</label>
<label index="read_manual">Manual</label>
<label index="downloads_by_version">Downloads by Version</label>
</languageKey>
......
......@@ -11,27 +11,84 @@
<span class="extension-date"><f:translate key="version"/> {extension.lastVersion.versionString} - <terfe2:dateTime format="{settings.dateFormat}">{extension.lastVersion.uploadDate}</terfe2:dateTime> | <strong><terfe2:format content="{extension.lastVersion.state}" function="ucfirst" /></strong></span>
</h4>
</div>
<div class="extension-description">
<p><terfe2:crop length="{settings.descriptionLength}">{extension.lastVersion.description}</terfe2:crop></p>
<div class="extension-regular">
<!-- Description -->
<div class="extension-description">
<p><terfe2:crop length="{settings.descriptionLength}">{extension.lastVersion.description}</terfe2:crop></p>
</div>
<div class="extension-info">
<!-- General information -->
<table>
<tr>
<td class="extension-label"><f:translate key="extension"/>:</td>
<td>{extension.extKey}</td>
</tr>
<tr>
<td class="extension-label"><f:translate key="author"/>:</td>
<td><f:link.action controller="Extension" action="listByAuthor" arguments="{author : extension.lastVersion.author}">{extension.lastVersion.author.name}</f:link.action></td>
</tr>
<tr>
<td class="extension-label"><f:translate key="category"/>:</td>
<td><f:render partial="InlineCategoryList" arguments="{categories: extension.categories}"/></td>
</tr>
<tr>
<td class="extension-label"><f:translate key="votes"/>:</td>
<td><span class="extension-plus">+&nbsp;{extension.votes.positive}</span>&nbsp;&nbsp;|&nbsp;&nbsp;<span class="extension-minus">-&nbsp;{extension.votes.negative}</span></td>
</tr>
</table>
<!-- Downloads chart -->
<div class="extension-chart">
</div>
</div>
</div>
<div class="extension-info">
<table>
<tr>
<td class="extension-label"><f:translate key="extension"/>:</td>
<td>{extension.extKey}</td>
</tr>
<tr>
<td class="extension-label"><f:translate key="author"/>:</td>
<td><f:link.action controller="Extension" action="listByAuthor" arguments="{author : extension.lastVersion.author}">{extension.lastVersion.author.name}</f:link.action></td>
</tr>
<tr>
<td class="extension-label"><f:translate key="category"/>:</td>
<td><f:render partial="InlineCategoryList" arguments="{categories: extension.categories}"/></td>
</tr>
</table>
<div class="extension-additional" style="display:block;"> <!-- TODO "display: none" -->
<div class="extension-description">
<!-- Images -->
<div class="extension-images">
</div>
<!-- Comments / changelog -->
<div class="accordion ">
<h5 class="a-h open"><span><f:translate key="upload_comment"/></span></h5>
<div class="a-body">
<div class="a-content">
<p>{extension.lastVersion.uploadComment}</p>
</div>
</div>
<h5 class="a-h closed"><span><f:translate key="version_history"/></span></h5>
<div class="a-body">
<div class="a-content">
<p>TODO: Version history from old upload comments</p>
</div>
</div>
</div>
</div>
<div class="extension-info">
<!-- Additional information -->
<table>
<tr>
<td class="extension-label"><f:translate key="relations"/>:</td>
<td><f:render partial="InlineRelationList" arguments="{relations: extension.lastVersion.filteredSoftwareRelations}"/></td>
</tr>
<tr>
<td class="extension-label"><f:translate key="tags"/>:</td>
<td>TODO: InlineTagList</td>
</tr>
</table>
</div>
</div>
<br class="tx_terfe2-clear" />
<span class="extension-button"><f:translate key="details"/></span>
<div class="extension-buttons">
<span class="extension-button"><f:translate key="details"/></span>
<span class="extension-button extension-button-right"><f:link.action controller="Extension" action="download" arguments="{version : extension.lastVersion}"><f:translate key="download_t3x"/></f:link.action></span>
<f:if condition="{extension.lastVersion.zipFile}">
<span class="extension-button extension-button-right"><f:link.action controller="Extension" action="download" arguments="{version : extension.lastVersion, format : 'zip'}"><f:translate key="download_zip"/></f:link.action></span>
</f:if>
</div>
</div>
</f:for>
</f:then>
......
{namespace terfe2=Tx_TerFe2_ViewHelpers}
<f:if condition="{relations}">
<f:for each="{relations}" as="relation" iteration="relationIteration">
<f:link.action controller="Extension" action="listByRelation" arguments="{relation : relation}">{relation.relationKey}</f:link.action><f:if condition="{relationIteration.isLast}"><f:then></f:then><f:else>, </f:else></f:if>
<f:if condition="{relation.isExtension}">
<f:link.action controller="Extension" action="showByExtensionKey" arguments="{extensionKey : relation.relationKey}">{relation.relationKey}</f:link.action><f:if condition="{relation.versionString}"> ({relation.versionString})</f:if><f:if condition="{relationIteration.isLast}"><f:then></f:then><f:else>, </f:else></f:if>
</f:if>
<f:if condition="{relation.isSystem}">
<terfe2:format function="strtoupper">{relation.relationKey}</terfe2:format><f:if condition="{relation.versionString}"> ({relation.versionString})</f:if><f:if condition="{relationIteration.isLast}"><f:then></f:then><f:else>, </f:else></f:if>
</f:if>
<f:if condition="{relation.isCore}">
TYPO3<f:if condition="{relation.versionString}"> ({relation.versionString})</f:if><f:if condition="{relationIteration.isLast}"><f:then></f:then><f:else>, </f:else></f:if>
</f:if>
</f:for>
</f:if>
\ No newline at end of file
<f:layout name="Default" />
<f:section name="main">
</f:section>
\ No newline at end of file
......@@ -19,22 +19,31 @@ div.extension-head h4 {
margin-top: 0;
}
div.extension-head a {
}
span.extension-icon {
}
span.extension-date {
float: right;
font-size: 10px;
font-size: 11px;
color: #555555;
}
div.extension-description {
margin-bottom: 7px;
overflow: auto;
width: 62%;
width: 64%;
float: left;
padding: 6px 18px 0 0;
padding: 6px 0 0 0;
margin: 0 18px 0 0;
}
div.extension-buttons {
padding-top: 12px;
}
span.extension-button {
......@@ -43,7 +52,7 @@ span.extension-button {
padding: 0 8px;
color: white;
font-size: 11px;
background: url(../Images/button.png) no-repeat 0 0;
background: url(../Images/button.png) left top no-repeat;
cursor: pointer;
text-decoration: none;
display: inline-block;
......@@ -51,35 +60,46 @@ span.extension-button {
border: 1px solid #E87C0C;
}
span.extension-button a {
text-decoration: none;
border-bottom: none;
color: #ffffff;
}
span.extension-button-right {
float: right;
margin-left: 12px;
}
div.extension-info {
width: 35%;
width: 33%;
float: left;
font-size: 11px;
}
div.extension-info a {
vertical-align: baseline;
}
div.extension-info table {
margin: 0;
}
div.extension-info table td {
div.extension-info td {
border: none;
padding: 6px 0 5px 0;
}
div.extension-info table tr {
div.extension-info tr {
border-top: 1px solid #D1D1D1;
padding: 6px 0;
}
div.extension-info table tr:first-child {
div.extension-regular div.extension-info tr:first-child {
border: none;
}
div.extension-info table td.extension-label {
div.extension-info td.extension-label {
width: 60px;
}
......@@ -89,4 +109,12 @@ br.tx_terfe2-clear {
padding: 0;
margin: 0;
clear: both;
}
span.extension-plus {
color: #009C21;
}
span.extension-minus {
color: #EE1B00;
}
\ No newline at end of file
......@@ -50,6 +50,7 @@
'tx_terfe2_utility_datetime' => $extensionClassesPath . 'Utility/Datetime.php',
'tx_terfe2_utility_file' => $extensionClassesPath . 'Utility/File.php',
'tx_terfe2_utility_typoscript' => $extensionClassesPath . 'Utility/TypoScript.php',
'tx_terfe2_utility_version' => $extensionClassesPath . 'Utility/Version.php',
'Tx_TerFe2_view_extension_listjson' => $extensionClassesPath . 'View/Extension/ListJson.php',
'Tx_TerFe2_view_extension_listlatestjson' => $extensionClassesPath . 'View/Extension/ListLatestJson.php',
'tx_terfe2_viewhelpers_cdataviewhelper' => $extensionClassesPath . 'ViewHelpers/CdataViewHelper.php',
......
......@@ -8,13 +8,13 @@
$_EXTKEY,
'Pi1',
array(
'Extension' => 'index, list, listLatest, listByCategory, listByTag, show, new, create, edit, update, delete, createVersion, download',
'Extension' => 'index, list, listLatest, listByCategory, listByTag, show, showByExtensionKey, new, create, edit, update, delete, createVersion, download',
'Category' => 'index, new, create, edit, update, delete',
'Tag' => 'index, new, create, edit, update, delete',
'Author' => 'index, new, create, edit, update, delete, show',
),
array(
'Extension' => 'create, update, delete, createVersion, download',
'Extension' => 'create, update, delete, createVersion',
'Category' => 'create, update, delete',
'Tag' => 'create, update, delete',
'Author' => 'create, update, delete',
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment