Commit accefe31 authored by speedprogs_de's avatar speedprogs_de
Browse files

reorderd and extended index template, added frontendUser to Extension object,...

reorderd and extended index template, added frontendUser to Extension object, renamed some labels, added several partials, added CSS file, added several actions

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@45582 735d13b6-9817-0410-8766-e36946ffe9aa
parent 587fbd50
......@@ -61,6 +61,17 @@
}
/**
* Action that displays a single Author
*
* @param Tx_TerFe2_Domain_Model_Author $author The Author to display
* @return void
*/
public function showAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->view->assign('author', $author);
}
/**
* Displays a form for creating a new Author
*
......@@ -81,7 +92,7 @@
*/
public function createAction(Tx_TerFe2_Domain_Model_Author $newAuthor) {
$this->authorRepository->add($newAuthor);
$this->flashMessageContainer->add($this->translate('msg_author_created'));
$this->flashMessageContainer->add($this->translate('msg.author_created'));
$this->redirect('index');
}
......@@ -106,7 +117,7 @@
*/
public function updateAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->authorRepository->update($author);
$this->flashMessageContainer->add($this->translate('msg_author_updated'));
$this->flashMessageContainer->add($this->translate('msg.author_updated'));
$this->redirect('index');
}
......@@ -119,7 +130,7 @@
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->authorRepository->remove($author);
$this->flashMessageContainer->add($this->translate('msg_author_deleted'));
$this->flashMessageContainer->add($this->translate('msg.author_deleted'));
$this->redirect('index');
}
......
......@@ -81,7 +81,7 @@
*/
public function createAction(Tx_TerFe2_Domain_Model_Category $newCategory) {
$this->categoryRepository->add($newCategory);
$this->flashMessageContainer->add($this->translate('msg_category_created'));
$this->flashMessageContainer->add($this->translate('msg.category_created'));
$this->redirect('index');
}
......@@ -106,7 +106,7 @@
*/
public function updateAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->categoryRepository->update($category);
$this->flashMessageContainer->add($this->translate('msg_category_updated'));
$this->flashMessageContainer->add($this->translate('msg.category_updated'));
$this->redirect('index');
}
......@@ -119,7 +119,7 @@
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->categoryRepository->remove($category);
$this->flashMessageContainer->add($this->translate('msg_category_deleted'));
$this->flashMessageContainer->add($this->translate('msg.category_deleted'));
$this->redirect('index');
}
......
......@@ -48,6 +48,11 @@
*/
protected $tagRepository;
/**
* @var Tx_TerFe2_Domain_Repository_AuthorRepository
*/
protected $authorRepository;
/**
* Initializes the current action
......@@ -58,6 +63,7 @@
$this->extensionRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_ExtensionRepository');
$this->categoryRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_CategoryRepository');
$this->tagRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_TagRepository');
$this->authorRepository = t3lib_div::makeInstance('Tx_TerFe2_Domain_Repository_AuthorRepository');
// Pre-parse TypoScript setup
$this->settings = Tx_TerFe2_Utility_TypoScript::parse($this->settings);
......@@ -65,13 +71,33 @@
/**
* Index action
* Index action, shows an overview
*
* @return void
*/
public function indexAction() {
// Can be replaced by another action/view later
//$this->forward('listLatest');
// Get latest extensions
$latestCount = (!empty($this->settings['latestCount']) ? $this->settings['latestCount'] : 10);
$latestExtensions = $this->extensionRepository->findNewAndUpdated($latestCount);
$this->view->assign('latestExtensions', $latestExtensions);
// Get top rated extensions
$topRatedCount = (!empty($this->settings['topRatedCount']) ? $this->settings['topRatedCount'] : 10);
$topRatedExtensions = $this->extensionRepository->findTopRated($topRatedCount);
$this->view->assign('topRatedExtensions', $topRatedExtensions);
// Get all categories
$categories = $this->categoryRepository->findAll();
$this->view->assign('categories', $categories);
// Get all tags
$tags = $this->tagRepository->findAll();
$this->view->assign('tags', $tags);
// Get random authors
$randomAuthorCount = (!empty($this->settings['randomAuthorCount']) ? $this->settings['randomAuthorCount'] : 10);
$randomAuthors = $this->authorRepository->findRandom($randomAuthorCount);
$this->view->assign('randomAuthors', $randomAuthors);
}
......@@ -154,7 +180,7 @@
*/
public function createAction(Tx_TerFe2_Domain_Model_Extension $newExtension) {
$this->extensionRepository->add($newExtension);
$this->flashMessageContainer->add($this->translate('msg_extension_created'));
$this->flashMessageContainer->add($this->translate('msg.extension_created'));
$this->redirect('index');
}
......@@ -179,7 +205,7 @@
*/
public function updateAction(Tx_TerFe2_Domain_Model_Extension $extension) {
$this->extensionRepository->update($extension);
$this->flashMessageContainer->add($this->translate('msg_extension_updated'));
$this->flashMessageContainer->add($this->translate('msg.extension_updated'));
$this->redirect('index');
}
......@@ -192,7 +218,7 @@
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Extension $extension) {
$this->extensionRepository->remove($extension);
$this->flashMessageContainer->add($this->translate('msg_extension_deleted'));
$this->flashMessageContainer->add($this->translate('msg.extension_deleted'));
$this->redirect('index');
}
......@@ -215,7 +241,7 @@
$extension->addVersion($newVersion);
$extension->setLastUpdate(new DateTime());
} else {
$this->flashMessageContainer->add($this->translate('msg_file_not_valid'));
$this->flashMessageContainer->add($this->translate('msg.file_not_valid'));
}
$this->redirect('index');
......@@ -241,14 +267,14 @@
// Get URL to file
$urlToFile = $extensionProvider->getExtensionFile($version);
if (empty($urlToFile)) {
$this->flashMessageContainer->add($this->translate('msg_file_not_found'));
$this->flashMessageContainer->add($this->translate('msg.file_not_found'));
$this->redirect('index');
}
// Check file hash
$fileHash = Tx_TerFe2_Utility_Files::getFileHash($urlToFile);
if ($fileHash != $version->getFileHash()) {
$this->flashMessageContainer->add($this->translate('msg_file_hash_not_equal'));
$this->flashMessageContainer->add($this->translate('msg.file_hash_not_equal'));
$this->redirect('index');
}
......
......@@ -81,7 +81,7 @@
*/
public function createAction(Tx_TerFe2_Domain_Model_Tag $newTag) {
$this->tagRepository->add($newTag);
$this->flashMessageContainer->add($this->translate('msg_tag_created'));
$this->flashMessageContainer->add($this->translate('msg.tag_created'));
$this->redirect('index');
}
......@@ -106,7 +106,7 @@
*/
public function updateAction(Tx_TerFe2_Domain_Model_Tag $tag) {
$this->tagRepository->update($tag);
$this->flashMessageContainer->add($this->translate('msg_tag_updated'));
$this->flashMessageContainer->add($this->translate('msg.tag_updated'));
$this->redirect('index');
}
......@@ -119,7 +119,7 @@
*/
public function deleteAction(Tx_TerFe2_Domain_Model_Tag $tag) {
$this->tagRepository->remove($tag);
$this->flashMessageContainer->add($this->translate('msg_tag_deleted'));
$this->flashMessageContainer->add($this->translate('msg.tag_deleted'));
$this->redirect('index');
}
......
......@@ -83,6 +83,12 @@
*/
protected $lastVersion;
/**
* frontendUser
* @var Tx_Extbase_Domain_Model_FrontendUser
*/
protected $frontendUser;
/**
* Constructor. Initializes all Tx_Extbase_Persistence_ObjectStorage instances.
......@@ -316,5 +322,26 @@
return $this->lastVersion;
}
/**
* Setter for frontendUser
*
* @param Tx_Extbase_Domain_Model_FrontendUser $frontendUser Frontend user
* @return void
*/
public function setFrontendUser(Tx_Extbase_Domain_Model_FrontendUser $frontendUser) {
$this->frontendUser = $frontendUser;
}
/**
* Getter for frontendUser
*
* @return Tx_Extbase_Domain_Model_FrontendUser Frontend user
*/
public function getFrontendUser() {
return $this->frontendUser;
}
}
?>
\ No newline at end of file
......@@ -32,5 +32,26 @@
*/
class Tx_TerFe2_Domain_Repository_AuthorRepository extends Tx_Extbase_Persistence_Repository {
/**
* Returns random authors
*
* @param integer $randomAuthorCount Count of authors
* @return array An array of extensions
*/
public function findRandom($randomAuthorCount) {
$query = $this->createQuery();
$query->setLimit((int) $randomAuthorCount);
// Workaround for random ordering until Extbase doesn't support this
// See: http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2010-July/005870.html
$backend = $this->objectManager->get('Tx_Extbase_Persistence_Storage_Typo3DbBackend');
$parameters = array();
$statementParts = $backend->parseQuery($query, $parameters);
$statementParts['orderings'][] = ' RAND()';
$statement = $backend->buildQuery($statementParts, $parameters);
$query->statement($statement, $parameters);
return $query->execute();
}
}
?>
\ No newline at end of file
......@@ -67,6 +67,24 @@
}
/**
* Returns top rated extensions
*
* @param integer $topRatedCount Count of extensions
* @param boolean $rawResult Return raw data
* @return array An array of extensions
*/
public function findTopRated($topRatedCount, $rawResult = FALSE) {
$query = $this->createQuery();
$query->getQuerySettings()->setReturnRawQueryResult($rawResult);
$query->setLimit((int) $topRatedCount);
$query->setOrderings(
array('lastVersion.experience.rating' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING)
);
return $query->execute();
}
/**
* Returns all extensions in a category
*
......@@ -91,7 +109,6 @@
*/
public function findByTag(Tx_TerFe2_Domain_Model_Tag $tag) {
$query = $this->createQuery();
//$query->equals('tags.title', $tag->getTitle());
$query->matching($query->contains('tags', $tag));
$query->setOrderings(
array('lastVersion.title' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING)
......@@ -100,6 +117,22 @@
}
/**
* Returns all extensions by an author
*
* @param Tx_TerFe2_Domain_Model_Author $author The Author to search for
* @return array An array of extensions
*/
public function findByAuthor(Tx_TerFe2_Domain_Model_Author $author) {
$query = $this->createQuery();
$query->matching($query->contains('versions.author', $author));
$query->setOrderings(
array('extKey' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING)
);
return $query->execute();
}
/**
* Returns count of extensions with given extKey and versionNumber
*
......
......@@ -254,6 +254,9 @@
/**
* Load Extension object if already exists, else create new one
*
* TODO: Add current frontend user to extension dataset while
* creating extension via frontend form
*
* @param array $extInfo Extension information
* @return Tx_TerFe2_Domain_Model_Extension New or existing Extension object
*/
......@@ -268,6 +271,7 @@
$extension->setHudsonLink($extInfo['hudsonLink']);
$extension->setLastUpload($dateTime);
$extension->setLastMaintained($dateTime);
//$extension->setFrontendUser($frontendUser);
}
return $extension;
......
......@@ -6,10 +6,10 @@
$TCA['tx_terfe2_domain_model_extension'] = array(
'ctrl' => $TCA['tx_terfe2_domain_model_extension']['ctrl'],
'interface' => array(
'showRecordFieldList' => 'ext_key,forge_link,hudson_link,last_update,categories,tags,versions,last_version',
'showRecordFieldList' => 'ext_key,forge_link,hudson_link,last_update,categories,tags,versions,last_version, frontend_user',
),
'types' => array(
'1' => array('showitem' => 'ext_key,forge_link,hudson_link,last_update,categories,tags,versions,last_version'),
'1' => array('showitem' => 'ext_key,forge_link,hudson_link,last_update,categories,tags,versions,last_version, frontend_user'),
),
'palettes' => array(
'1' => array('showitem' => ''),
......@@ -163,6 +163,15 @@
'maxitems' => 1,
),
),
'frontend_user' => array(
'exclude' => 1,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_extension.frontend_user',
'config' => array(
'type' => 'inline',
'foreign_table' => 'fe_users',
'maxitems' => 1,
),
),
),
);
?>
\ No newline at end of file
# ======================================================================
# Default configuration ot the extension "ter_fe2"
# Default configuration of the extension "ter_fe2"
# ======================================================================
plugin.tx_terfe2 {
settings {
# cat=TER Frontend/settings/100; type=int+; label=Count of results in latest Extensions overview
latestCount = 20
# cat=TER Frontend/settings/100; type=int+; label=Count of latest Extensions
latestCount = 10
# cat=TER Frontend/settings/110; type=int+; label=Count of top rated Extensions
topRatedCount = 10
# cat=TER Frontend/settings/120; type=int+; label=Count of random Authors
randomAuthorCount = 10
fileProvider {
# cat=TER Frontend/settings/200; type=string; label=Class name of the Filesystem Extension Provider
......
# ======================================================================
# Default configuration ot the extension "ter_fe2"
# Default configuration of the extension "ter_fe2"
# ======================================================================
plugin.tx_terfe2 {
## General settings
settings {
latestCount = {$plugin.tx_terfe2.settings.latestCount}
latestCount = {$plugin.tx_terfe2.settings.latestCount}
topRatedCount = {$plugin.tx_terfe2.settings.topRatedCount}
randomAuthorCount = {$plugin.tx_terfe2.settings.randomAuthorCount}
extensionProviders {
## Filesystem Extension Provider
......@@ -47,4 +49,10 @@ plugin.tx_terfe2 {
_CSS_DEFAULT_STYLE (
)
}
\ No newline at end of file
}
# ======================================================================
# Page object configuration of the extension "ter_fe2"
# ======================================================================
page.includeCSS.tx_terfe2 = EXT:ter_fe2/Resources/Public/CSS/tx_terfe2_default.css
\ No newline at end of file
......@@ -60,21 +60,41 @@
<label index="tx_terfe2_task_updateextensionlisttask.name">Get new extensions</label>
<label index="tx_terfe2_task_updateextensionlisttask.description">Get new extensions in ter directory</label>
<label index="msg_extension_created">Extension created</label>
<label index="msg_extension_updated">Extension updated</label>
<label index="msg_extension_deleted">Extension deleted</label>
<label index="msg_category_created">Category created</label>
<label index="msg_category_updated">Category updated</label>
<label index="msg_category_deleted">Category deleted</label>
<label index="msg_tag_created">Tag created</label>
<label index="msg_tag_updated">Tag updated</label>
<label index="msg_tag_deleted">Tag deleted</label>
<label index="msg_author_created">Author created</label>
<label index="msg_author_updated">Author updated</label>
<label index="msg_author_deleted">Author deleted</label>
<label index="msg_file_not_valid">Given file is not valid</label>
<label index="msg_file_not_found">File not found</label>
<label index="msg_file_hash_not_equal">File was changed and is therefore corrupt</label>
<label index="msg.extension_created">Extension created</label>
<label index="msg.extension_updated">Extension updated</label>
<label index="msg.extension_deleted">Extension deleted</label>
<label index="msg.category_created">Category created</label>
<label index="msg.category_updated">Category updated</label>
<label index="msg.category_deleted">Category deleted</label>
<label index="msg.tag_created">Tag created</label>
<label index="msg.tag_updated">Tag updated</label>
<label index="msg.tag_deleted">Tag deleted</label>
<label index="msg.author_created">Author created</label>
<label index="msg.author_updated">Author updated</label>
<label index="msg.author_deleted">Author deleted</label>
<label index="msg.file_not_valid">Given file is not valid</label>
<label index="msg.file_not_found">File not found</label>
<label index="msg.file_hash_not_equal">File was changed and is therefore corrupt</label>
<label index="msg.no_entries_found">No entries found</label>
<label index="header.latest_extensions">Latest Extensions</label>
<label index="header.top_rated_extensions">Top rated Extensions</label>
<label index="header.categories">All categories</label>
<label index="header.tags">All tags</label>
<label index="header.random_authors">Random Authors</label>
<label index="header.quicklinks">Quicklinks</label>
<label index="header.json_output">JSON Output</label>
<label index="header.rss_output">RSS Output</label>
<label index="link.latest_extensions">Latest Extensions</label>
<label index="link.latest_extensions.rss">Latest Extensions (RSS)</label>
<label index="link.latest_extensions.json">Latest Extensions (JSON)</label>
<label index="link.all_extensions">All Extensions</label>
<label index="link.all_extensions.rss">All Extensions (RSS)</label>
<label index="link.all_extensions.json">All Extensions (JSON)</label>
<label index="link.all_categories">All Categories</label>
<label index="link.all_tags">All Tags</label>
<label index="link.all_authors">All Authors</label>
<label index="list_all_extensions">List of all extensions</label>
<label index="list_latest_extensions">List of new and updated extensions</label>
......
......@@ -16,6 +16,7 @@
<label index="tags.description">tag</label>
<label index="versions.description">version</label>
<label index="last_version.description">lastVersion</label>
<label index="frontend_user.description">frontendUser</label>
</languageKey>
</data>
</T3locallang>
\ No newline at end of file
......@@ -15,6 +15,7 @@
<label index="tx_terfe2_domain_model_extension.tags">Tags</label>
<label index="tx_terfe2_domain_model_extension.versions">Versions</label>
<label index="tx_terfe2_domain_model_extension.last_version">Last Version</label>
<label index="tx_terfe2_domain_model_extension.frontend_user">Frontend User</label>
<label index="tx_terfe2_domain_model_category">Category</label>
<label index="tx_terfe2_domain_model_category.title">Title</label>
......
<div class="tx-terfe2-pi1">
<f:renderFlashMessages />
<f:render section="main" />
<div class="tx_terfe2">
<div class="tx_terfe2_messages">
<f:renderFlashMessages />
</div>
<div class="tx_terfe2_content">
<div class="tx_terfe2_main">
<f:render section="main" />
</div>
<div class="tx_terfe2_additional">
<h2><f:translate key="header.categories"/></h2>
<f:render partial="CategoryList" arguments="{categories: categories}"/><br />
<h2><f:translate key="header.tags"/></h2>
<f:render partial="TagCloud" arguments="{tags: tags}"/><br />
<h2><f:translate key="header.random_authors"/></h2>
<f:render partial="AuthorList" arguments="{authors: randomAuthors}"/><br />
<h2><f:translate key="header.quicklinks"/></h2>
<ul>
<li><f:link.action action="listLatest"><f:translate key="link.latest_extensions"/></f:link.action></li>
<li><f:link.action action="list"><f:translate key="link.all_extensions"/></f:link.action></li>
<li><f:link.action controller="Category" action="index"><f:translate key="link.all_categories"/></f:link.action></li>
<li><f:link.action controller="Tag" action="index"><f:translate key="link.all_tags"/></f:link.action></li>
<li><f:link.action controller="Author" action="index"><f:translate key="link.all_authors"/></f:link.action></li>
</ul>
</div>
<br class="clear" />
</div>
<div class="tx_terfe2_footer">
<ul>
<li><f:link.action controller="Extension" action="listLatest" format="rss" pageType="{settings.rssOutput.typeNum}" target="_blank"><f:translate key="link.latest_extensions.rss"/></f:link.action></li>
<li><f:link.action controller="Extension" action="listLatest" format="json" pageType="{settings.jsonOutput.typeNum}" target="_blank"><f:translate key="link.latest_extensions.json"/></f:link.action></li>
<li><f:link.action controller="Extension" action="list" format="rss" pageType="{settings.rssOutput.typeNum}" target="_blank"><f:translate key="link.all_extensions.rss"/></f:link.action></li>
<li><f:link.action controller="Extension" action="list" format="json" pageType="{settings.jsonOutput.typeNum}" target="_blank"><f:translate key="link.all_extensions.json"/></f:link.action></li>
</ul>
<br class="clear" />
</div>
</div>
\ No newline at end of file
<ul class="tx_terfe2_authors">
<f:if condition="{authors}">
<f:then>
<f:for each="{authors}" as="author">
<li class="author">
<f:link.action controller="Author" action="show" arguments="{author : author}">{author.name}</f:link.action>
</li>
</f:for>
</f:then>
<f:else>
<f:translate key="msg.no_entries_found"/>
</f:else>
</f:if>
</ul>
\ No newline at end of file
<ul class="tx_terfe2_categories">
<f:if condition="{categories}">
<f:then>
<f:for each="{categories}" as="category">
<li class="category">
<f:link.action controller="Category" action="show" arguments="{category : category}">{category.title}</f:link.action>
</li>
</f:for>
</f:then>
<f:else>
<f:translate key="msg.no_entries_found"/>
</f:else>
</f:if>
</ul>
\ No newline at end of file
{namespace terfe2=Tx_TerFe2_ViewHelpers}
<f:for each="{extensions}" as="extension">
<div class="extension">
<h3>
<span class="icon"><terfe2:extIcon version="{extension.lastVersion}" alt="{extension.lastVersion.title}"></terfe2:extIcon></span>
<f:link.action action="show" arguments="{extension : extension}">{extension.lastVersion.title} ({extension.extKey})</f:link.action>
</h3>
<p class="description">{extension.lastVersion.description}</p>
<p class="categories"><f:for each="{extension.categories}" as="{category}">{category.title}</f:for></p>
<p class="tags"><f:for each="{extension.tags}" as="{tag}">{tag.title}</f:for></p>
<p class="download_t3x"><f:link.action action="download" arguments="{version : extension.lastVersion}"><f:translate key="download_t3x"/></f:link.action></p>
<p class="download_zip"><f:link.action action="download" arguments="{version : extension.lastVersion, format : 'zip'}"><f:translate key="download_zip"/></f:link.action></p>
</div>
<hr />
</f:for>
\ No newline at end of file
<f:if condition="{extensions}">
<f:then>
<f:for each="{extensions}" as="extension">
<div class="extension">
<h3>
<span class="icon"><terfe2:extIcon version="{extension.lastVersion}" alt="{extension.lastVersion.title}"></terfe2:extIcon></span>
<f:link.action action="show" arguments="{extension : extension}">{extension.lastVersion.title} ({extension.extKey})</f:link.action>
</h3>