Your IP : 216.73.216.59


Current Path : /home/quelfutuu/www/lchg/plugins/auto/oembed/v3.3.0/spip-cli/
Upload File :
Current File : /home/quelfutuu/www/lchg/plugins/auto/oembed/v3.3.0/spip-cli/OembedRecupererData.php

<?php

use Spip\Cli\Console\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Helper\ProgressHelper;

class OembedRecupererData extends Command {
	protected function configure() {
		$this
			->setName('oembed:recupererdata')
			->setDescription('Recuperer les donnees oembed d\'une URL')
			->addOption(
				'url',
				null,
				InputOption::VALUE_REQUIRED,
				'URL de la ressource',
				null
			)
			->addOption(
				'maxwidth',
				null,
				InputOption::VALUE_OPTIONAL,
				'Largeur maxi',
				''
			)
			->addOption(
				'maxheight',
				null,
				InputOption::VALUE_OPTIONAL,
				'Hauteur maxi',
				''
			)
			->addOption(
				'format',
				null,
				InputOption::VALUE_OPTIONAL,
				'Format des données',
				'json'
			)
			->addOption(
				'detect',
				null,
				InputOption::VALUE_NONE,
				'Detecter automatiquement le provider oembed si il n\'est pas connu',
				null
			)
			->addOption(
				'force',
				null,
				InputOption::VALUE_NONE,
				'forcer une nouvelle récupération des données depuis le serveur source (ignorer le cache)',
				null
			)
		;
	}

	protected function execute(InputInterface $input, OutputInterface $output) {

		include_spip('inc/oembed');

		#global $spip_racine;
		#global $spip_loaded;

		$url = $input->getOption('url');
		if (!$url) {
			$output->writeln('<error>Indiquez une URL</error>');
			exit(Command::FAILURE);
		}

		$maxwidth = $input->getOption('maxwidth');
		$maxheight = $input->getOption('maxheight');
		$format = $input->getOption('format');
		$detect = $input->getOption('detect');
		$force = $input->getOption('force');

		$data = oembed_recuperer_data($url, $maxwidth, $maxheight, $format, $detect ? true : null, $force);

		$output->writeln(var_export($data, true));
		return Command::SUCCESS;
	}
}