diff --git a/classes/MarketPlugin.class.php b/classes/MarketPlugin.class.php index 176a9a0dddabde23213124384463c2b7ab4178a5..163a2384ca33120564fc134b47fad1f74357544b 100644 --- a/classes/MarketPlugin.class.php +++ b/classes/MarketPlugin.class.php @@ -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 diff --git a/classes/MarketRelease.class.php b/classes/MarketRelease.class.php index 1b7e0352b3e2accce52cb3a4288e48a26f270c4c..f832ad9b0ac731bebd7a08e544cbd6ee0b8dc2db 100644 --- a/classes/MarketRelease.class.php +++ b/classes/MarketRelease.class.php @@ -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(); } } diff --git a/controllers/myplugins.php b/controllers/myplugins.php index 6ace50043bc702cd38d0292cd35b1e15d81bd645..b3a5ecff53759f1e1e3f759be54e28a33b6e98c9 100644 --- a/controllers/myplugins.php +++ b/controllers/myplugins.php @@ -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")); diff --git a/install.sql b/install.sql index 36defb41ad4bfb2d3dee83e2e3bd94cf12b66d96..764d7dafbe7277558cdc5ee1ad1e9e56865810e3 100644 --- a/install.sql +++ b/install.sql @@ -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` ( diff --git a/views/myplugins/edit.php b/views/myplugins/edit.php index af0f17124f648467b220fbb711f787d81b0af3f1..d156b2b510ac85db3bcb90b0551a5f52bbcf713d 100644 --- a/views/myplugins/edit.php +++ b/views/myplugins/edit.php @@ -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"> diff --git a/views/presenting/details.php b/views/presenting/details.php index 3b42917ca1aab9f74e498b33e6a233d7b3102bfd..33c22a3143b9d3efc24b77f675a42b78488de5f0 100644 --- a/views/presenting/details.php +++ b/views/presenting/details.php @@ -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>