function before_filter(&$action, &$args) { parent::before_filter($action, $args); Navigation::activateItem("/pluginmarket/presenting"); if ($GLOBALS['perm']->have_perm("user")) { $config = UserConfig::get($GLOBALS['user']->id); $this->last_pluginmarket_visit = $config->getValue("last_pluginmarket_visit") ?: time(); $_SESSION['last_pluginmarket_visit'] = time(); $config->store("last_pluginmarket_visit", $_SESSION['last_pluginmarket_visit']); } PageLayout::addScript($this->plugin->getPluginURL() . "/assets/studiptable.js"); PageLayout::addScript($this->plugin->getPluginURL() . "/assets/pluginmarket.js"); $tags_statement = DBManager::get()->prepare("\n SELECT pluginmarket_tags.tag, COUNT(*) AS number\n FROM pluginmarket_tags\n INNER JOIN pluginmarket_plugins ON (pluginmarket_plugins.plugin_id = pluginmarket_tags.plugin_id)\n WHERE pluginmarket_tags. proposal = '0'\n AND pluginmarket_plugins.approved = 1\n AND pluginmarket_plugins.publiclyvisible = 1\n GROUP BY pluginmarket_tags.tag\n ORDER BY number DESC, RAND()\n LIMIT 25\n "); $tags_statement->execute(); $this->tags = $tags_statement->fetchAll(PDO::FETCH_ASSOC); // Set view $_SESSION['pluginmarket']['view'] = Request::get('view') ?: $_SESSION['pluginmarket']['view']; if (!isset($_SESSION['pluginmarket']['view'])) { $_SESSION['pluginmarket']['view'] = 'tiles'; } // Sidebar $sidebar = Sidebar::Get(); // Create search widget $searchWidget = new SearchWidget($this->url_for('presenting/all')); $searchWidget->addNeedle(_('Suche'), 'search', true); $sidebar->addWidget($searchWidget); // Create cloud $tagWidget = new LinkCloudWidget(); $tagWidget->setTitle(_("Beliebte Tags")); foreach ($this->tags as $tag) { $tagWidget->addLink($tag['tag'], $this->url_for('presenting/all', array('tag' => $tag['tag'])), $tag['number']); } $sidebar->addWidget($tagWidget); // Create view widget if ($action != 'details') { $viewWidget = new ViewsWidget(); $viewWidget->addLink(_('Kacheln'), URLHelper::getLink('', array('view' => 'tiles')))->setActive($_SESSION['pluginmarket']['view'] == 'tiles'); $viewWidget->addLink(_('Liste'), $this->url_for('presenting/all', array('view' => 'list')))->setActive($_SESSION['pluginmarket']['view'] == 'list'); $sidebar->addWidget($viewWidget); } // Create versionfilter widget $versionWidget = new OptionsWidget(); $versionWidget->setTitle(_('Stud.IP Version')); // Create options for all studip versions $_SESSION['pluginmarket']['version'] = Request::submitted('version') ? Request::get('version') : $_SESSION['pluginmarket']['version']; $options[] = "<option value='" . URLHelper::getLink('', array('version' => 0)) . "'>" . _('Alle Versionen') . "</option>"; foreach (array_reverse(PluginMarket::getStudipReleases()) as $version) { $options[] = "<option value='" . URLHelper::getLink('', array('version' => $version)) . "' " . ($_SESSION['pluginmarket']['version'] == $version ? "SELECTED" : "") . ">{$version}</option>"; } $versionWidget->addElement(new WidgetElement('<select style="width: 100%" onchange="location = this.options[this.selectedIndex].value;">' . join("", $options) . '</select>')); // Add checkbox to ignore older releases (use invese logic to be applied on startup) $sidebar->addWidget($versionWidget, 'comments'); }
public function addTagCloudWidgetToSidebar($tags, $context = 'global') { if (count($tags) && $tags[0]) { $cloud = new LinkCloudWidget(); $cloud->setTitle(_('Hashtags')); $maximum = $tags[0]['counter']; //$average = ceil(array_sum(array_filter($tags, function ($val) { return $val['counter']; })) / count($tags)); foreach ($tags as $tag) { $cloud->addLink("#" . $tag['tag'], URLHelper::getLink("plugins.php/blubber/streams/{$context}", array('hash' => $tag['tag'])), ceil(10 * $tag['counter'] / $maximum)); } Sidebar::get()->addWidget($cloud, 'tagcloud'); } }