Skip to content
Snippets Groups Projects
Commit a9b8826d authored by Rasmus Fuhse's avatar Rasmus Fuhse
Browse files

add tags

parent fb2e983b
No related branches found
No related tags found
No related merge requests found
......@@ -54,4 +54,44 @@ class MarketPlugin extends SimpleORMap {
$firstimage = $this->images->first();
return $firstimage ? $firstimage->getURL() : null;
}
public function setTags($tags) {
if (!$this->getId()) {
return false;
}
$tags = array_map("strtolower", $tags);
$old_tags = $this->getTags();
$insert = DBManager::get()->prepare("
INSERT IGNORE INTO pluginmarket_tags
SET plugin_id = :plugin_id,
tag = :tag,
user_id = :user_id
");
$delete = DBManager::get()->prepare("
DELETE FROM pluginmarket_tags
WHERE plugin_id = :plugin_id,
AND tag = :tag
");
foreach (array_diff($old_tags, $tags) as $tag_to_delete) {
$delete->execute(array(
'plugin_id' => $this->getId(),
'tag' => $tag_to_delete
));
}
foreach ($tags as $tag) {
$insert->execute(array(
'plugin_id' => $this->getId(),
'tag' => $tag,
'user_id' => $GLOBALS['user']->id
));
}
}
public function getTags() {
$statement = DBManager::get()->prepare("
SELECT tag FROM pluginmarket_tags WHERE plugin_id = ? ORDER BY tag ASC
");
$statement->execute(array($this->getId()));
return $statement->fetchAll(PDO::FETCH_COLUMN, 0);
}
}
\ No newline at end of file
......@@ -100,7 +100,7 @@ class MarketRelease extends SimpleORMap {
}
if ($readme) {
$html = Parsedown::instance()->text($readme);
$this->plugin['description'] = "<div>".$html."</div>";
$this->plugin['description'] = "<div>".studip_utf8decode($html)."</div>";
$this->plugin->store();
}
}
......
......@@ -14,7 +14,7 @@ class MypluginsController extends PluginController {
public function overview_action()
{
$this->plugins = MarketPlugin::findBySQL("1=1");
$this->plugins = MarketPlugin::findBySQL("user_id = ?", array($GLOBALS['user']->id));
}
public function add_action() {
......@@ -83,6 +83,7 @@ class MypluginsController extends PluginController {
}
$this->marketplugin->store();
$this->marketplugin->setTags(array_map("trim", explode(",", Request::get("tags"))));
if (Request::submitted("image_order")) {
$order = array_flip(Request::getArray("image_order"));
......
......@@ -56,10 +56,13 @@ CREATE TABLE IF NOT EXISTS `pluginmarket_rezension` (
CREATE TABLE IF NOT EXISTS `pluginmarket_tags` (
`plugin_id` varchar(32) NOT NULL,
`tag` varchar(255) NOT NULL,
KEY (`tag_id`),
KEY `plugin_id` (`plugin_id`)
`tag` varchar(64) NOT NULL,
`plugin_id` varchar(32) NOT NULL,
`proposal` tinyint(4) NOT NULL DEFAULT '0',
`user_id` varchar(32) NOT NULL,
PRIMARY KEY (`tag`,`plugin_id`),
KEY `plugin_id` (`plugin_id`),
KEY `user_id` (`user_id`)
) ENGINE=MyISAM;
CREATE TABLE IF NOT EXISTS `pluginmarket_rezension` (
......
......@@ -43,6 +43,11 @@
<input type="text" name="data[url]" value="<?= htmlReady($marketplugin['url']) ?>">
</label>
<label>
<?= _("Schlagworte") ?>
<input type="text" name="tags" value="<?= htmlReady(ucwords(implode(", ", $marketplugin->getTags()))) ?>">
</label>
<div>
<?= _("Lizenz") ?>
<input type="hidden" name="data[license]" value="GPL 2 or later">
......
......@@ -44,6 +44,14 @@ if ($icon) {
<div><?= formatLinks($marketplugin['url']) ?></div>
<? endif ?>
<? $tags = $marketplugin->getTags() ?>
<? if (count($tags)) : ?>
<h2><?= _("Schlagworte") ?></h2>
<div>
<?= htmlReady(ucwords(implode(", ", $tags))) ?>
</div>
<? endif ?>
<h2><?= _("Zum Autor") ?></h2>
<ul class="clean">
<li>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment