<?php
namespace Modules\Admin\About;

class Controller extends \App\Mvc\ControllerAbstract
{

	/**
	 * (non-PHPdoc)
	 * @see \App\Mvc\Controller\Window\PaginatedListing\PaginatedListing::initialize()
	 */
	protected function initialize()
	{
		parent::initialize();

		$this->actionsCfg['index'] = ['checkSection' => false,  'checkOption' => false,];
		$this->actionsCfg['licenses'] = ['checkSection' => false,  'checkOption' => false,];
	}


	/**
	 * Action index
	 * @param Array $R
	 * @return \Engine\Mvc\Response\Html
	 */
	public function actionIndex($R)
	{
		// instantiate the view
		$view = new View_Index($this);

		// render the view
		return new \Engine\Mvc\Response\Html($view->render());
	}


	public function actionLicenses($R)
	{
		// collect license sources (core + plugins via event)
		$collector = new \Modules\Admin\About\Model\SourcesCollector();
		$collector->addSource('core', APP_REAL_PATH . 'composer.lock', APP_REAL_PATH . 'vendor');

		// manually inject core non-PHP libraries from _3parties
		$this->addCore3partiesLibraries($collector);

		// let plugins register their own vendor sources (composer and/or manual)
		\Engine\Plugins\Manager::getInstance()->executeEvent(
			'Modules\Admin\About-collectLicenseSources',
			['collector' => $collector]
		);

		// read and merge all libraries
		$reader = new \Modules\Admin\About\Model\LicenseReader();
		$libraries = $reader->loadFromSources($collector);

		// instantiate the view
		$view = new View_Licenses($this);
		$view->setOutputVar('libraries', $libraries);

		// render the view
		return new \Engine\Mvc\Response\Html($view->render());
	}


	/**
	 * Manually registers core non-PHP OSS libraries from _3parties.
	 * @param \Modules\Admin\About\Model\SourcesCollector $collector
	 */
	protected function addCore3partiesLibraries(\Modules\Admin\About\Model\SourcesCollector $collector): void
	{

		$collector->addManualLibrary('D3.js', 'v3.5.17', 'BSD-3-Clause', 'Data-Driven Documents - JavaScript visualization library', 'core', 'https://d3js.org', 'Copyright 2010-2023 Mike Bostock
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.');

		$collector->addManualLibrary('NVD3', '1.x', 'Apache-2.0', 'Re-usable charts for D3.js', 'core', 'https://nvd3.org');

		$collector->addManualLibrary('Prototype.js', '1.x', 'MIT', 'JavaScript framework for web development', 'core', 'http://prototypejs.org', 'Prototype is Copyright © 2005-2007 Sam Stephenson. It is freely distributable under the terms of an MIT-style license.
Copyright (c) 2005-2010 Sam Stephenson
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
The Prototype documentation is Copyright © 2007 The Prototype Core Team. It is released under the Creative Commons Attribution-ShareAlike 3.0 license.');

		$collector->addManualLibrary('script.aculo.us', '1.x', 'MIT', 'JavaScript UI effects and controls library', 'core', 'https://script.aculo.us');

		$collector->addManualLibrary('SunEditor', '2.x', 'MIT', 'Pure JavaScript based WYSIWYG web editor', 'core', 'https://github.com/nicksagona/suneditor');

		$collector->addManualLibrary('overlib', '4.x', 'Artistic License', 'JavaScript popup library', 'core', 'http://www.bosrup.com/web/overlib/');

		$collector->addManualLibrary('nuSOAP', '0.9.x', 'LGPL-2.1', 'SOAP toolkit for PHP', 'core', 'https://sourceforge.net/projects/nusoap/', 'GNU Library or Lesser General Public License version 2.0 (LGPLv2)');

		$collector->addManualLibrary('XRegExp', '3.x', 'MIT', 'Extended JavaScript regular expressions', 'core', 'https://xregexp.com', 'The MIT License (MIT)
Copyright © 2026 <copyright holders>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.');

		$collector->addManualLibrary('vkBeautify', '1.x', 'MIT', 'JavaScript plugin to pretty-print XML and JSON', 'core', 'https://github.com/nicksagona/vkbeautify');

		$collector->addManualLibrary('date-functions', '1.x', 'MIT', 'JavaScript date utility functions', 'core', 'Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.');

		$collector->addManualLibrary('coolestCalendar', '1.x', 'MIT', 'JavaScript calendar widget', 'core');

		$collector->addManualLibrary('Apache FOP', '2.x', 'Apache-2.0', 'XSL-FO print formatter for PDF generation', 'core', 'https://xmlgraphics.apache.org/fop/', 'All new Apache™ FOP releases will be licensed under the Apache™ License, version 2.0. Releases until version 0.20.5 are released under the Apache™ License, version 1.1.
To inspect the license terms please consult the LICENSE and NOTICE files in the root directory of the distribution. The full license text can also be accessed via the web from the Apache Licenses page.
Apache FOP comes with a number of libraries all of which are currently coming from within the Apache Software Foundation. These libraries are all licensed under one of the Apache License versions. There is one exception which is "xml-apis.jar" which contains code licensed by the W3C. Please consult the license files included with the libraries in the "lib" directory for details.');
	}

}
