Commit 71341edf authored by speedprogs_de's avatar speedprogs_de
Browse files

optimized repository methods, added options to enable extension list on author...

optimized repository methods, added options to enable extension list on author and category detail page, added extension list on author and category detail page

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@52442 735d13b6-9817-0410-8766-e36946ffe9aa
parent 7118a844
......@@ -33,6 +33,11 @@
*/
protected $authorRepository;
/**
* @var Tx_TerFe2_Domain_Repository_ExtensionRepository
*/
protected $extensionRepository;
/**
* Initializes the controller
......@@ -40,7 +45,8 @@
* @return void
*/
protected function initializeController() {
$this->authorRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_AuthorRepository');
$this->authorRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_AuthorRepository');
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
}
......@@ -62,6 +68,8 @@
*/
public function showAction(Tx_TerFe2_Domain_Model_Author $author) {
$this->view->assign('author', $author);
$authorExtensions = $this->extensionRepository->findByAuthor($author);
$this->view->assign('authorExtensions', $authorExtensions);
}
......
......@@ -33,6 +33,11 @@
*/
protected $categoryRepository;
/**
* @var Tx_TerFe2_Domain_Repository_ExtensionRepository
*/
protected $extensionRepository;
/**
* Initializes the controller
......@@ -40,7 +45,8 @@
* @return void
*/
protected function initializeController() {
$this->categoryRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_CategoryRepository');
$this->categoryRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_CategoryRepository');
$this->extensionRepository = $this->objectManager->get('Tx_TerFe2_Domain_Repository_ExtensionRepository');
}
......@@ -62,6 +68,8 @@
*/
public function showAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->view->assign('category', $category);
$categoryExtensions = $this->extensionRepository->findByCategory($category);
$this->view->assign('categoryExtensions', $categoryExtensions);
}
......
......@@ -99,29 +99,10 @@
$this->view->assign('sorting', $sorting);
$this->view->assign('direction', $direction);
// 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);*/
// Get authors
$authors = $this->authorRepository->findByLatestExtensionVersion();
$this->view->assign('authors', $authors);
......
......@@ -28,6 +28,33 @@
*/
abstract class Tx_TerFe2_Domain_Repository_AbstractRepository extends Tx_Extbase_Persistence_Repository {
/**
* Returns a query for objects of this repository
*
* @param string $offset Offset to start with
* @param string $count Count of result
* @param array $ordering Ordering <-> Direction
* @return Tx_Extbase_Persistence_QueryInterface
*/
public function createQuery($offset = 0, $count = 0, $ordering = array()) {
$query = parent::createQuery();
if (!empty($offset)) {
$query->setOffset((int) $offset);
}
if (!empty($count)) {
$query->setLimit((int) $count);
}
if (!empty($ordering)) {
$query->setOrderings($ordering);
}
return $query;
}
/**
* Returns random objects from db
*
......@@ -35,8 +62,7 @@
* @return Tx_Extbase_Persistence_ObjectStorage Objects
*/
public function findRandom($limit) {
$query = $this->createQuery();
$query->setLimit((int) $limit);
$query = $this->createQuery(0, $limit);
// Workaround for random ordering while Extbase doesn't support this
// See: http://lists.typo3.org/pipermail/typo3-project-typo3v4mvc/2010-July/005870.html
......@@ -59,8 +85,7 @@
* @return Tx_Extbase_Persistence_ObjectStorage Objects
*/
public function findAllBySortingAndDirection($sorting, $direction) {
$query = $this->createQuery();
$query->setOrderings(array($sorting => $direction));
$query = $this->createQuery(0, 0, array($sorting => $direction));
return $query->execute();
}
......
......@@ -37,17 +37,11 @@
* @return array Objects
*/
public function findLastUpdated($lastUpdateDate, $offset = 0, $count = 0) {
$query = $this->createQuery();
$query = $this->createQuery($offset, $count);
$query->getQuerySettings()->setRespectStoragePage(FALSE);
$query->getQuerySettings()->setRespectSysLanguage(FALSE);
$query->getQuerySettings()->setReturnRawQueryResult(TRUE);
$query->matching($query->greaterThan('lastuploaddate', (int) $lastUpdateDate));
if (!empty($offset)) {
$query->setOffset((int) $offset);
}
if (!empty($count)) {
$query->setLimit((int) $count);
}
return $query->execute();
}
......@@ -60,8 +54,7 @@
* @return array Objects
*/
public function findOneByExtKeyAndVersionString($extKey, $versionString) {
$query = $this->createQuery();
$query->setLimit(1);
$query = $this->createQuery(0, 1);
$query->getQuerySettings()->setRespectStoragePage(FALSE);
$query->getQuerySettings()->setRespectSysLanguage(FALSE);
$query->getQuerySettings()->setReturnRawQueryResult(TRUE);
......
......@@ -31,13 +31,16 @@
/**
* Returns all extensions
*
* @param string $offset Offset to start with
* @param string $count Count of result
* @param string $ordering Ordering <-> Direction
* @return Tx_Extbase_Persistence_ObjectStorage Objects
*/
public function findAll() {
$query = $this->createQuery();
$query->setOrderings(
array('lastVersion.title' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING)
);
public function findAll($offset = 0, $count = 0, $ordering = array()) {
if (empty($ordering)) {
$ordering = array('lastVersion.title' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING);
}
$query = $this->createQuery($offset, $count, $ordering);
return $query->execute();
}
......@@ -48,13 +51,9 @@
* @param integer $latestCount Count of extensions
* @return Tx_Extbase_Persistence_ObjectStorage Objects
*/
public function findNewAndUpdated($latestCount) {
$query = $this->createQuery();
$query->setLimit((int) $latestCount);
$query->setOrderings(
array('lastVersion.uploadDate' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING)
);
return $query->execute();
public function findLatest($latestCount = 0) {
$ordering = array('lastVersion.uploadDate' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING);
return $this->findAll(0, $latestCount, $ordering);
}
......@@ -62,17 +61,11 @@
* Returns top rated extensions
*
* @param integer $topRatedCount Count of extensions
* @param boolean $rawResult Return raw data
* @return Tx_Extbase_Persistence_ObjectStorage Objects
*/
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();
public function findTopRated($topRatedCount = 0) {
$ordering = array('lastVersion.experience.rating' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING);
return $this->findAll(0, $topRatedCount, $ordering);
}
......@@ -85,9 +78,6 @@
public function findByCategory(Tx_TerFe2_Domain_Model_Category $category) {
$query = $this->createQuery();
$query->matching($query->contains('categories', $category));
$query->setOrderings(
array('lastVersion.title' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING)
);
return $query->execute();
}
......@@ -101,9 +91,6 @@
public function findByTag(Tx_TerFe2_Domain_Model_Tag $tag) {
$query = $this->createQuery();
$query->matching($query->contains('tags', $tag));
$query->setOrderings(
array('lastVersion.title' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING)
);
return $query->execute();
}
......@@ -115,29 +102,29 @@
* @return Tx_Extbase_Persistence_ObjectStorage Objects
*/
public function findByAuthor(Tx_TerFe2_Domain_Model_Author $author) {
$statement = '
SELECT extension FROM tx_terfe2_domain_model_version
WHERE tx_terfe2_domain_model_version.author = ' . (int) $author->getUid() . '
';
// Workaround while extbase doesn't support JOIN
$query = $this->createQuery();
$query->getQuerySettings()->setReturnRawQueryResult(TRUE);
$query->statement($statement, array());
$rows = $query->execute();
unset($query);
// Workaround to enable paginate
$uids = array();
foreach ($rows as $row) {
$uids[] = (int) $row['extension'];
}
$query = $this->createQuery();
$query->matching($query->contains('versions.author', $author));
$query->setOrderings(
array('extKey' => Tx_Extbase_Persistence_QueryInterface::ORDER_ASCENDING)
);
return $query->execute();
}
$query->matching($query->in('uid', $uids));
/**
* Returns all extensions limited by offset and count
*
* @param string $offset Offset to start with
* @param string $count Count of results
* @return Tx_Extbase_Persistence_ObjectStorage Objects
*/
public function findByOffsetAndCount($offset, $count) {
$query = $this->createQuery();
$query->setOffset((int) $offset);
$query->setLimit((int) $count);
$query->setOrderings(
array('lastVersion.uploadDate' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING)
);
return $query->execute();
}
......
......@@ -36,7 +36,7 @@
* @return Tx_Extbase_Persistence_ObjectStorage Objects
*/
public function findForMediaCreation($offset = 0, $count = 0) {
$query = $this->createQuery();
$query = $this->createQuery($offset, $count);
$query->getQuerySettings()->setRespectStoragePage(FALSE);
$query->getQuerySettings()->setRespectSysLanguage(FALSE);
$query->matching(
......@@ -45,12 +45,6 @@
$query->equals('hasImages', FALSE)
)
);
if (!empty($offset)) {
$query->setOffset((int) $offset);
}
if (!empty($count)) {
$query->setLimit((int) $count);
}
return $query->execute();
}
......@@ -63,8 +57,7 @@
* @return Tx_TerFe2_Domain_Model_Version Version object
*/
public function findOneByExtensionAndVersionString(Tx_TerFe2_Domain_Model_Extension $extension, $versionString) {
$query = $this->createQuery();
$query->setLimit(1);
$query = $this->createQuery(0, 1);
$query->getQuerySettings()->setRespectStoragePage(FALSE);
$query->getQuerySettings()->setRespectSysLanguage(FALSE);
$query->matching(
......@@ -77,24 +70,6 @@
}
/**
* Returns all versions limited by offset and count
*
* @param string $offset Offset to start with
* @param string $count Count of results
* @return Tx_Extbase_Persistence_ObjectStorage Objects
*/
public function findByOffsetAndCount($offset, $count) {
$query = $this->createQuery();
$query->setOffset((int) $offset);
$query->setLimit((int) $count);
$query->setOrderings(
array('uploadDate' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING)
);
return $query->execute();
}
/**
* Get version history
*
......@@ -104,12 +79,10 @@
* @return Tx_Extbase_Persistence_ObjectStorage Objects
*/
public function getVersionHistory($extension, $count = 0, $skipLatest = TRUE) {
$query = $this->createQuery();
$ordering = array('uploadDate' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING);
$query = $this->createQuery(0, $count, $ordering);
$query->getQuerySettings()->setRespectStoragePage(FALSE);
$query->getQuerySettings()->setRespectSysLanguage(FALSE);
$query->setOrderings(
array('uploadDate' => Tx_Extbase_Persistence_QueryInterface::ORDER_DESCENDING)
);
if (!empty($skipLatest)) {
$query->matching(
......@@ -124,10 +97,6 @@
$query->matching($query->equals('extension', $extension));
}
if (!empty($count)) {
$query->setLimit((int) $count);
}
return $query->execute();
}
......
......@@ -70,9 +70,7 @@
* @return boolean TRUE on success
*/
protected function executeTask($lastRun, $offset, $count) {
// Get given count of versions
$versions = $this->versionRepository->findByOffsetAndCount($offset, $count);
$versions = $this->versionRepository->findAll($offset, $count);
if (empty($versions)) {
return FALSE;
}
......
......@@ -6,10 +6,10 @@
$TCA['tx_terfe2_domain_model_version'] = array(
'ctrl' => $TCA['tx_terfe2_domain_model_version']['ctrl'],
'interface' => array(
'showRecordFieldList' => 'title,description,version_number,version_string,upload_date,upload_comment,download_counter,frontend_download_counter,state,em_category,load_order,priority,shy,internal,do_not_load_in_fe,uploadfolder,clear_cache_on_load,module,create_dirs,modify_tables,lock_type,cgl_compliance,cgl_compliance_note,review_state,manual,media,experiences,software_relations,file_hash,extension_provider,has_zip_file,has_images',
'showRecordFieldList' => 'title,description,version_number,version_string,upload_date,upload_comment,download_counter,frontend_download_counter,state,em_category,load_order,priority,shy,internal,do_not_load_in_fe,uploadfolder,clear_cache_on_load,module,create_dirs,modify_tables,lock_type,cgl_compliance,cgl_compliance_note,review_state,manual,media,experiences,software_relations,author,file_hash,extension_provider,has_zip_file,has_images',
),
'types' => array(
'1' => array('showitem' => 'title,description,version_number,version_string,upload_date,upload_comment,download_counter,frontend_download_counter,state,em_category,load_order,priority,shy,internal,do_not_load_in_fe,uploadfolder,clear_cache_on_load,module,create_dirs,modify_tables,lock_type,cgl_compliance,cgl_compliance_note,review_state,manual,media,experiences,software_relations,file_hash,extension_provider,has_zip_file,has_images'),
'1' => array('showitem' => 'title,description,version_number,version_string,upload_date,upload_comment,download_counter,frontend_download_counter,state,em_category,load_order,priority,shy,internal,do_not_load_in_fe,uploadfolder,clear_cache_on_load,module,create_dirs,modify_tables,lock_type,cgl_compliance,cgl_compliance_note,review_state,manual,media,experiences,software_relations,author,file_hash,extension_provider,has_zip_file,has_images'),
),
'palettes' => array(
'1' => array('showitem' => ''),
......@@ -353,8 +353,12 @@
),
),
'author' => array(
'exclude' => 1,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_version.author',
'config' => array(
'type' => 'passthrough',
'type' => 'inline',
'foreign_table' => 'tx_terfe2_domain_model_author',
'maxitems' => 1,
),
),
'extension' => array(
......
......@@ -3,103 +3,111 @@
# ======================================================================
plugin.tx_terfe2 {
settings {
# cat=TER Frontend/settings/90; type=int+; label=List count: Count of Extensions per page in list view
# cat=TER Frontend/settings/1000; type=int+; label=List count: Count of Extensions per page in list view
listCount = 10
# cat=TER Frontend/settings/100; type=int+; label=Latest count: Count of latest Extensions
# cat=TER Frontend/settings/1010; type=int+; label=Latest count: Count of latest Extensions
latestCount = 10
# cat=TER Frontend/settings/105; type=int+; label=Latest count: Count of entries in author list
# cat=TER Frontend/settings/1020; type=int+; label=Author list count: Count of entries in author list
authorListCount = 25
# cat=TER Frontend/settings/110; type=int+; label=Top rated count: Count of top rated Extensions
# cat=TER Frontend/settings/1030; type=int+; label=Top rated count: Count of top rated Extensions
topRatedCount = 10
# cat=TER Frontend/settings/120; type=int+; label=Random author count: Count of random Authors
# cat=TER Frontend/settings/1040; type=int+; label=Random author count: Count of random Authors
randomAuthorCount = 10
# cat=TER Frontend/settings/130; type=int+; label=Description length: Crop description at this count of signs
# cat=TER Frontend/settings/1050; type=int+; label=Description length: Crop description at this count of signs
descriptionLength = 350
# cat=TER Frontend/settings/140; type=string; label=Date format: Date format
# cat=TER Frontend/settings/1060; type=string; label=Date format: Date format
dateFormat = F j, Y
# cat=TER Frontend/settings/150; type=string; label=Media root path: Media root path for zip files and images
# cat=TER Frontend/settings/1070; type=string; label=Media root path: Media root path for zip files and images
mediaRootPath = fileadmin/extensionFiles/
# cat=TER Frontend/settings/155; type=bool; label=Count downloads: Count extension downloads via download action
# cat=TER Frontend/settings/1080; type=boolean; label=Count downloads: Count extension downloads via download action
countDownloads = 0
# cat=TER Frontend/settings/155; type=int+; label=Default point count: Count of points to show in chart
# cat=TER Frontend/settings/1090; type=int+; label=Default point count: Count of points to show in chart
defaultPointCount = 5
# cat=TER Frontend/settings/156; type=int+; label=Version history count: Count of versions to show in history
# cat=TER Frontend/settings/1100; type=int+; label=Version history count: Count of versions to show in history
versionHistoryCount = 3
# cat=TER Frontend/settings/157; type=int+; label=Skip latest version: Skip latest version in version history
# cat=TER Frontend/settings/1110; type=boolean; label=Skip latest version: Skip latest version in version history
skipLatestVersion = 1
terConnection {
# cat=TER Frontend/settings/160; type=string; label=TER WSDL URI: WSDL URI to connect TER server
# cat=TER Frontend/settings/2000; type=string; label=TER WSDL URI: WSDL URI to connect TER server
wsdl = http://typo3.org/wsdl/tx_ter_wsdl.php
# cat=TER Frontend/settings/170; type=string; label=TER Username: Username to connect TER server
# cat=TER Frontend/settings/2010; type=string; label=TER Username: Username to connect TER server
username =
# cat=TER Frontend/settings/180; type=string; label=TER Password: Password to connect TER server
# cat=TER Frontend/settings/2020; type=string; label=TER Password: Password to connect TER server
password =
}
smallImage {
# cat=TER Frontend/settings/200; type=int+; label=Small image maxW: Maximal width for small images
# cat=TER Frontend/settings/3000; type=int+; label=Small image maxW: Maximal width for small images
maxW = 200
# cat=TER Frontend/settings/210; type=int+; label=Small image maxH: Maximal height for small images
# cat=TER Frontend/settings/3010; type=int+; label=Small image maxH: Maximal height for small images
maxH = 160
# cat=TER Frontend/settings/220; type=int+; label=Small image quality: Quality of small images
# cat=TER Frontend/settings/3020; type=int+; label=Small image quality: Quality of small images
quality = 70
# cat=TER Frontend/settings/230; type=string; label=Small image format: Output format of small images
# cat=TER Frontend/settings/3030; type=string; label=Small image format: Output format of small images
ext = jpg
}
largeImage {
# cat=TER Frontend/settings/240; type=int+; label=Large image maxW: Maximal width for large images in fullscreen mode
# cat=TER Frontend/settings/4000; type=int+; label=Large image maxW: Maximal width for large images in fullscreen mode
maxW = 1024
# cat=TER Frontend/settings/250; type=int+; label=Large image maxH: Maximal height for large images in fullscreen mode
# cat=TER Frontend/settings/4010; type=int+; label=Large image maxH: Maximal height for large images in fullscreen mode
maxH = 768
# cat=TER Frontend/settings/260; type=int+; label=Large image quality: Quality of large images
# cat=TER Frontend/settings/4020; type=int+; label=Large image quality: Quality of large images
quality = 70
# cat=TER Frontend/settings/270; type=string; label=Large image format: Output format of large images
# cat=TER Frontend/settings/4030; type=string; label=Large image format: Output format of large images
ext = jpg
}
show {
# cat=TER Frontend/settings/5000; type=boolean; label=Show author extensions: Show all extensions of an author on detail view
authorExtensions = 0
# cat=TER Frontend/settings/5010; type=boolean; label=Show category extensions: Show all extensions of a category on detail view
categoryExtensions = 0
}
}
persistence {
# cat=TER Frontend/persistence/300; type=int+; label=Storage PID: General storage PID for the TER Frontend Index
# cat=TER Frontend/persistence/6000; type=int+; label=Storage PID: General storage PID for the TER Frontend Index
storagePid = 0
}
view {
# cat=TER Frontend/view/400; type=string; label=Template root path: Path to template root
# cat=TER Frontend/view/7000; type=string; label=Template root path: Path to template root
templateRootPath = EXT:ter_fe2/Resources/Private/Templates/
# cat=TER Frontend/view/410; type=string; label=Partial root path: Path to template partials
# cat=TER Frontend/view/7010; type=string; label=Partial root path: Path to template partials
partialRootPath = EXT:ter_fe2/Resources/Private/Partials/
# cat=TER Frontend/view/420; type=string; label=Layout root path: Path to template layouts
# cat=TER Frontend/view/7020; type=string; label=Layout root path: Path to template layouts
layoutRootPath = EXT:ter_fe2/Resources/Private/Layouts/
}
libraries {
# cat=TER Frontend/libraries/500; type=string; label=Load jQuery: Load jQuery libraray into footer
# cat=TER Frontend/libraries/8000; type=string; label=Load jQuery: Load jQuery libraray into footer
jquery.load = 1
# cat=TER Frontend/libraries/510; type=string; label=Load jqPlot: Load jqPlot libraray into footer
# cat=TER Frontend/libraries/8010; type=string; label=Load jqPlot: Load jqPlot libraray into footer
jqplot.load = 1
}
......
......@@ -36,6 +36,11 @@ plugin.tx_terfe2 {
quality = {$plugin.tx_terfe2.settings.largeImage.quality}
ext = {$plugin.tx_terfe2.settings.largeImage.ext}
}
show {
authorExtensions = {$plugin.tx_terfe2.settings.show.authorExtensions}
categoryExtensions = {$plugin.tx_terfe2.settings.show.categoryExtensions}
}
}
## Storage settings
......
......@@ -66,7 +66,7 @@
<label index="tx_terfe2_domain_model_author.name">Name of the author</label>
<label index="tx_terfe2_domain_model_author.email">Email address</label>
<label index="tx_terfe2_domain_model_author.company">Company name</label>
<label index="tx_terfe2_domain_model_author.forge_link">Link to forge profile</label>
<label index="tx_terfe2_domain_model_author.forge_link">Forge profile</label>
<label index="tx_terfe2_task_elementsPerRun">Element count to process at once</label>
<label index="tx_terfe2_task_clearCachePages">Clear cache of these pages after run</label>
......@@ -157,6 +157,7 @@
<label index="edit_category">Edit Category</label>
<label index="create_category">Create new Category</label>
<label index="single_category">Show single Category</label>
<label index="category_extensions">Extensions in this category</label>
<label index="new_tag">Create new Tag for extension</label>
<label index="edit_tag">Edit Tag</label>
......@@ -170,6 +171,7 @@
<label index="edit_author">Edit Author</label>
<label index="create_author">Create new Author</label>
<label index="single_author">Show single Author</label>
<label index="author_extensions">Extensions of this author</label>
<label index="by">by</label>
<label index="author">Author</label>
......
......@@ -11,6 +11,7 @@
<label index="tx_terfe2_domain_model_extension.forge_link">Forge Link</label>
<label index="tx_terfe2_domain_model_extension.hudson_link">Hudson Link</label>