Commit b20e2dbe authored by speedprogs_de's avatar speedprogs_de

added methods to list extensions by tag or category, added mm-table for tags

git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/terfe/branches/ter_fe2@42989 735d13b6-9817-0410-8766-e36946ffe9aa
parent c5413a30
......@@ -77,12 +77,10 @@
/**
* Index action, displays new and updated extensions
* Index action
*/
public function indexAction() {
$latestCount = (!empty($this->settings['latestCount']) ? $this->settings['latestCount'] : 20);
$extensions = $this->extensionRepository->findNewAndUpdated($latestCount);
$this->view->assign('extensions', $extensions);
$this->listLatestAction();
}
......@@ -94,6 +92,37 @@
}
/**
* List latest action, displays new and updated extensions
*/
public function listLatestAction() {
$latestCount = (!empty($this->settings['latestCount']) ? $this->settings['latestCount'] : 20);
$extensions = $this->extensionRepository->findNewAndUpdated($latestCount);
$this->view->assign('extensions', $extensions);
}
/**
* List by category action, displays all extensions in a category
*
* @param Tx_TerFe2_Domain_Model_Category $category The Category to search in
*/
public function listByCategoryAction(Tx_TerFe2_Domain_Model_Category $category) {
$this->view->assign('extensions', $this->extensionRepository->findByCategory($category));
}
/**
* List by tag action, displays all extensions with a tag
*
* @param Tx_TerFe2_Domain_Model_Tag $tag The Tag to search for
*/
public function listByTagAction(Tx_TerFe2_Domain_Model_Tag $tag) {
$this->view->assign('extensions', $this->extensionRepository->findByTag($tag));
}
/**
* Action that displays a single Extension
*
......@@ -178,10 +207,11 @@
$newVersion->setExtension($extension);
$extension->addVersion($newVersion);
$extension->setLastUpdate(new DateTime());
$this->redirect('index');
} else {
$this->flashMessages->add($this->translate('msg_file_not_valid'));
}
$this->redirect('index');
}
......@@ -193,7 +223,8 @@
* @return string Translated label
*/
protected function translate($label, array $arguments = array()) {
return Tx_Extbase_Utility_Localization::translate($label, 'ter_fe2', $arguments);
$extKey = $this->request->getControllerExtensionKey();
return Tx_Extbase_Utility_Localization::translate($label, $extKey, $arguments);
}
}
?>
\ No newline at end of file
......@@ -48,5 +48,33 @@
return $query->execute();
}
/**
* Returns all extensions in a category
*
* @param Tx_TerFe2_Domain_Model_Category $category The Category to search in
* @return array An array of extensions
*/
public function findByCategory(Tx_TerFe2_Domain_Model_Category $category) {
$query = $this->createQuery();
//$query->equals('categories.title', $category->getTitle());
$query->matching($query->contains('categories', $category));
return $query->execute();
}
/**
* Returns all extensions with a tag
*
* @param Tx_TerFe2_Domain_Model_Tag $tag The Tag to search for
* @return array An array of extensions
*/
public function findByTag(Tx_TerFe2_Domain_Model_Tag $tag) {
$query = $this->createQuery();
//$query->equals('tags.title', $tag->getTitle());
$query->matching($query->contains('tags', $tag));
return $query->execute();
}
}
?>
\ No newline at end of file
......@@ -33,7 +33,7 @@
class Tx_TerFe2_Service_FileHandlerService implements t3lib_Singleton {
/**
* Check if a file exists and is readable
* Check if a file or folder exists
*
* @param string $filename Path to the file
* @return boolean TRUE if file exists
......@@ -43,6 +43,10 @@
return FALSE;
}
if (@is_dir($filename)) {
return (bool) @file_exists($filename);
}
return (bool) @is_readable($filename);
}
......@@ -149,5 +153,58 @@
ob_flush();
exit;
}
/**
* Get a list of all files in a directory
*
* @param string $dirname Path to the directory
* @param boolean $recursive Get subfolder content too
* @return array All contained files
*/
public function getFiles($dirname, $recursive = FALSE) {
$dirname = $this->getAbsFilename($dirname);
if (empty($dirname)) {
return array();
}
if ($recursive) {
$files = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dirname));
} else {
$files = new DirectoryIterator($dirname);
}
$result = array();
foreach ($files as $file) {
if ($file->isFile()) {
$result[] = $file->getPathname();
}
}
return $result;
}
/**
* Get all files in a directory by filetype
*
* @param string $dirname Path to the directory
* @param string $fileType Type of the files to find
* @param boolean $recursive Get subfolder content too
* @return array All found files
*/
public function getFilesByType($dirname, $fileType, $recursive = FALSE) {
$files = $this->getFiles($dirname, $recursive);
$fileType = ltrim($fileType, '.');
$result = array();
foreach ($files as $file) {
if (substr($file, strrpos($file, '.') + 1) == $fileType) {
$result[] = $file;
}
}
return $result;
}
}
?>
\ No newline at end of file
......@@ -118,14 +118,15 @@
'exclude' => 0,
'label' => 'LLL:EXT:ter_fe2/Resources/Private/Language/locallang_db.xml:tx_terfe2_domain_model_extension.tags',
'config' => array(
'type' => 'inline',
'foreign_table' => 'tx_terfe2_domain_model_tag',
'foreign_field' => 'extension',
'maxitems' => 9999,
'appearance' => array(
'collapse' => 0,
'newRecordLinkPosition' => 'bottom',
),
'type' => 'select',
'size' => 3,
'minitems' => 0,
'maxitems' => 9999,
'autoSizeMax' => 10,
'multiple' => 0,
'foreign_table' => 'tx_terfe2_domain_model_tag',
'MM' => 'tx_terfe2_extension_tag_mm',
'MM_opposite_field' => 'extensions',
),
),
'versions' => array(
......
......@@ -70,11 +70,6 @@
'eval' => 'trim,required',
),
),
'extension' => array(
'config' => array(
'type' => 'passthrough',
),
),
),
);
?>
\ No newline at end of file
......@@ -51,6 +51,10 @@
<label index="tx_terfe2_domain_model_relation.software_type">Core, extension or system</label>
<label index="tx_terfe2_domain_model_relation.tx_terfe2_key">extension key, php, mysql or something else</label>
<label index="tx_terfe2_domain_model_relation.version">Version of the field "key", e.g. key "php" and version "5.2"</label>
<label index="msg_extension_created">Extension created</label>
<label index="msg_extension_updated">Extension updated</label>
<label index="msg_file_not_valid">Given file is not valid</label>
</languageKey>
</data>
</T3locallang>
\ No newline at end of file
<div class="tx-terfe2-pi1">
<f:renderFlashMessages class="tx-extbase-flash-message" />
<f:render section="main" />
</div>
\ No newline at end of file
......@@ -8,7 +8,7 @@
$_EXTKEY,
'Pi1',
array(
'Extension' => 'index, list, show, new, create, edit, update, delete, createVersion',
'Extension' => 'index, list, listLatest, listByCategory, listByTag, show, new, create, edit, update, delete, createVersion',
),
array(
'Extension' => 'create, update, delete, createVersion',
......
......@@ -79,7 +79,7 @@ CREATE TABLE tx_terfe2_domain_model_tag (
uid int(11) NOT NULL auto_increment,
pid int(11) DEFAULT '0' NOT NULL,
extension int(11) unsigned DEFAULT '0' NOT NULL,
extensions int(11) unsigned DEFAULT '0' NOT NULL,
title tinytext,
tstamp int(11) unsigned DEFAULT '0' NOT NULL,
......@@ -287,6 +287,20 @@ CREATE TABLE tx_terfe2_extension_category_mm (
sorting int(10) unsigned DEFAULT '0' NOT NULL,
sorting_foreign int(10) unsigned DEFAULT '0' NOT NULL,
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);
# ======================================================================
# Table configuration for table "tx_terfe2_extension_tag_mm"
# ======================================================================
CREATE TABLE tx_terfe2_extension_tag_mm (
uid_local int(10) unsigned DEFAULT '0' NOT NULL,
uid_foreign int(10) unsigned DEFAULT '0' NOT NULL,
sorting int(10) unsigned DEFAULT '0' NOT NULL,
sorting_foreign int(10) unsigned DEFAULT '0' NOT NULL,
KEY uid_local (uid_local),
KEY uid_foreign (uid_foreign)
);
\ No newline at end of file
Markdown is supported
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