/** * Seed the licenses * * @return void */ private function seedLicenses() { // Fetch the licenses from the json file $this->command->info('---- DCAT Licenses ----'); $this->command->info('Trying to fetch the licenses from a local json file.'); $licenses = json_decode(file_get_contents(app_path() . '/database/seeds/data/licenses.json')); if (!empty($licenses)) { $this->command->info('Licenses have been found, deleting the current ones, and replacing them with the new ones.'); // Empty the licenses table $this->command->info('Emptying the current licenses table.'); \License::truncate(); foreach ($licenses as $license) { \License::create(array('domain_content' => $license->domain_content, 'domain_data' => $license->domain_data, 'domain_software' => $license->domain_software, 'family' => $license->family, 'license_id' => $license->license_id, 'is_generic' => @$license->is_generic, 'is_okd_compliant' => $license->is_okd_compliant, 'is_osi_compliant' => $license->is_osi_compliant, 'maintainer' => $license->maintainer, 'status' => $license->status, 'title' => $license->title, 'url' => $license->url)); } $this->command->info('Added the licenses from a local json file.'); } else { $this->command->info('The licenses from the json file were empty, the old ones will not be replaced.'); } }
require_once '../lib/init.php'; if (!Access::check('interface', '100')) { UI::access_denied(); exit; } UI::show_header(); switch ($_REQUEST['action']) { case 'edit': if (isset($_POST['license_id'])) { $license = new License($_POST['license_id']); if ($license->id) { $license->update($_POST); } $text = T_('License Updated'); } else { License::create($_POST); $text = T_('License Created'); } show_confirmation($text, '', AmpConfig::get('web_path') . '/admin/license.php'); break; case 'show_edit': $license = new License($_REQUEST['license_id']); case 'show_create': require_once AmpConfig::get('prefix') . '/templates/show_edit_license.inc.php'; break; case 'delete': License::delete($_REQUEST['license_id']); show_confirmation(T_('License Deleted'), '', AmpConfig::get('web_path') . '/admin/license.php'); break; default: $browse = new Browse();
/** * Seed the themes * * @return @void */ private function seedLicenses() { $this->info('---- Seeding new licenses ----'); $license_name = $this->argument('name'); $license_uri = $this->licenses_uri . $license_name; if (substr($license_uri, -5) != '.json') { $license_uri .= '.json'; } // Try to get the themes from the ns.thedatatank.com (semantic data) try { $this->info('Trying to fetch triples from the uri: ' . $license_uri); try { $licenses_graph = \EasyRdf_Graph::newAndLoad($license_uri, 'jsonld'); } catch (\EasyRdf_Http_Exception $ex) { $this->info('We could not fetch licenses from the URL ' . $license_uri . ', defaulting to ' . $this->DEFAULT_LICENSE . '.'); $licenses_graph = $this->fetchDefaultGraph(); } if ($licenses_graph->isEmpty()) { $this->info('We could not fetch licenses from the URL ' . $license_uri . ', defaulting to ' . $this->DEFAULT_LICENSE . '.'); $licenses_graph = $this->fetchDefaultGraph(); } else { $this->info('Fetched new licenses, removing the old ones.'); // Empty the licenses table \License::truncate(); } // Fetch the resources with a skos:conceptScheme relationship $licenses = $licenses_graph->allOfType('cc:License'); $taxonomy_uris = array(); foreach ($licenses as $license) { $url = ''; $title = ''; $identifier = ''; $title_resource = $license->getLiteral('dc:title'); $identifier_resource = $license->getLiteral('dc:identifier'); if (!empty($title_resource)) { $title = $title_resource->getValue(); } if (!empty($identifier_resource)) { $identifier = $identifier_resource->getValue(); } if (!$license->isBNode()) { $url = $license->getUri(); } \License::create(['url' => $url, 'title' => $title, 'license_id' => $identifier]); $this->info('Added license "' . $identifier . '" with title "' . $title . '" and URI ' . $url); } } catch (EasyRdf_Exception $ex) { $this->info('An error occurred when we tried to fetch online themes.'); } }
/** * Store a newly created resource in storage. * * @return Response */ public function store() { $input = Input::all(); $create = License::create($input); return $create ? Redirect::to('licenses') : Redirect::back('error'); }