Skip to content
Snippets Groups Projects
Select Git revision
  • 048c922bc465cedba00f1b231ab9b4b37e4e26d1
  • main default protected
  • studip-rector
  • ci-opt
  • course-members-export-as-word
  • data-vue-app
  • pipeline-improvements
  • webpack-optimizations
  • rector
  • icon-renewal
  • http-client-and-factories
  • jsonapi-atomic-operations
  • vueify-messages
  • tic-2341
  • 135-translatable-study-areas
  • extensible-sorm-action-parameters
  • sorm-configuration-trait
  • jsonapi-mvv-routes
  • docblocks-for-magic-methods
19 results

NotificationCenter.php

Blame
  • Forked from Stud.IP / Stud.IP
    Source project has a limited visibility.
    Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    PluginRepository.class.php 5.00 KiB
    <?php
    
    /*
     * PluginRepository.class.php - query plugin meta data
     *
     * Copyright (c) 2008  Elmar Ludwig
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation; either version 2 of
     * the License, or (at your option) any later version.
     */
    
    /**
     * Class used to locate plugins available from a plugin repository.
     */
    class PluginRepository
    {
        /**
         * list and meta data of available plugins
         */
        private $plugins = [];
    
        /**
         * Initialize a new PluginRepository and read meta data from
         * the given URL or the default list of URLs (if $url is null).
         */
        public function __construct($url = null)
        {
            if (isset($url)) {
                $this->readMetadata($url);
            } else {
                foreach ($GLOBALS['PLUGIN_REPOSITORIES'] as $url) {
                    $this->readMetadata($url);
                }
            }
        }
    
        /**
         * Read plugin meta data from the given URL (using XML format).
         * The structure of the XML is:
         *
         * <plugins>
         *   <plugin name="DummyPlugin"
         *     <release
         *           version="2.0"
         *           url="http://plugins.example.com/dummy-2.0.zip"
         *           studipMinVersion="1.4"
         *           studipMaxVersion="1.9">
         *   </plugin>
         *   [...]
         * </plugins>
         *
         * @param string $url given url for plugin
         */
        public function readMetadata($url)
        {
            $cache = StudipCacheFactory::getCache();
            $cache_key = 'plugin_metadata/'.$url;
            $metadata = $cache->read($cache_key);
    
            if ($metadata === false) {
                // Set small timeout for the rare case that the repository is not
                // available
                $context = get_default_http_stream_context($url);
                stream_context_set_option($context, ['http' => [
                    'timeout' => 5,
                ]]);
                $metadata = @file_get_contents($url, false, $context);