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'); }
protected function installFromDirectory($dir, $originalfile = null) { $manifest = PluginManager::getInstance()->getPluginManifest($dir); if ($manifest['pluginclassname']) { $this->plugin['pluginclassname'] = $manifest['pluginclassname']; $this->plugin->store(); } $this['studip_min_version'] = $manifest['studipMinVersion']; $this['studip_max_version'] = $manifest['studipMaxVersion']; if (!$this['studip_max_version']) { $versions = PluginMarket::getStudipReleases(); $manifest['studipMaxVersion'] = $this['studip_max_version'] = array_pop($versions) . ".99"; if (!$this['studip_max_version']) { PageLayout::postMessage(MessageBox::info(sprintf(_("Die studipMaxVersion wurde auf %s gesetzt, da keine andere angegeben wurde."), $manifest['studipMaxVersion']))); } } if (version_compare($this['studip_min_version'], $this['studip_max_version'], ">")) { $this['studip_max_version'] = $this['studip_min_version']; } $this['version'] = $manifest['version']; if ($this['repository_overwrites_descriptionfrom']) { $readme = ""; $scanner = scandir($dir); foreach ($scanner as $file) { if (strtolower($file) === "readme.md" || strtolower($file) === "readme.markdown") { $readme = file_get_contents($dir . "/" . $file); } } if ($readme) { $html = Parsedown::instance()->text($readme); $this->plugin['description'] = "<div>" . studip_utf8decode($html) . "</div>"; $this->plugin->store(); } } $this->store(); file_put_contents($dir . "/plugin.manifest", $this->createManifest($manifest)); $hash = md5(uniqid()); $plugin_raw = $GLOBALS['TMP_PATH'] . "/plugin_{$hash}.zip"; create_zip_from_directory($dir, $plugin_raw); if ($manifest['studipMaxVersion'] !== $this['studip_max_version']) { copy($plugin_raw, $this->getFilePath()); } else { copy($originalfile, $this->getFilePath()); } unlink($plugin_raw); return true; }