public function actionDetails($name=false)
	{
		if ($name == false)
			throw new CHttpException(400, Yii::t('Api.Theme', 'Missing theme name'));

		// Fetch the data from Packagist
		$data = Yii::app()->cache->get('CiiMS::API::Themes::' . $name);

		if ($data === false)
		{
			$url = 'https://packagist.org/packages/ciims-themes/' . $name . '.json';
			$curl = new \Curl\Curl;
			try {
				$response = $curl->get($url)->package;
			} catch (Exception $e) {
				throw new CHttpException(500, Yii::t('Api.index', 'Failed to retrieve data from Packagist.'));
			}

			if ($curl->error)
				throw new CHttpException(500, Yii::t('Api.index', 'Failed to retrieve data from Packagist.'));

			$curl->close();

			$maintainers 	= array();
			$versions 		= array();
			$latestVersion 	= 0;
			$latestVersionLiteral;

			// Retrieve the version history
			foreach ($response->versions as $version => $details)
			{
				// Ignore dev-master
				if ($version == 'dev-master')
					continue;

				// Push the version
				$versionId = preg_replace("/[^0-9]/", "", $version);

				$versions[$versionId] = $version;
				if ($versionId > $latestVersion)
				{
					$latestVersion = $versionId;
					$latestVersionLiteral = $version;
				}
			}

			// Retreive the maintainers for the latest version
			foreach($response->versions->{$latestVersionLiteral}->authors as $maintainer)
			{
				$maintainers[] = array(
					'name' 		=> $maintainer->name,
					'email' 	=> $maintainer->email,
					'homepage' 	=> $maintainer->homepage 
				);
			}

			$data = array(
				'name' 				=> $response->name,
				'description' 		=> $response->description,
				'repository' 		=> $response->repository,
				'maintainers' 		=> $maintainers,
				'latest-version' 	=> $versions[$latestVersion],
				'sha' 				=> $response->versions->{$latestVersionLiteral}->source->reference,
				'file' 				=> $response->repository . '/archive/' . $versions[$latestVersion] . '.zip',
				'downloads' 		=> (array)$response->downloads
	        );

			Yii::app()->cache->set('CiiMS::API::Themes::' . $name, $data, 900);
		}

		return $data;		
	}
public function actionDetails($name=false)
	{
		if ($name == false)
			throw new CHttpException(400, Yii::t('Api.Theme', 'Missing theme name'));

		// Fetch the data from Packagist
		$data = Yii::app()->cache->get('CiiMS::API::Themes::' . $name);

		if ($data === false)
		{
			$url = 'https://packagist.org/packages/ciims-themes/' . $name . '.json';
			$curl = new \Curl\Curl;
			try {
				$response = $curl->get($url)->package;
			} catch (Exception $e) {
				throw new CHttpException(500, Yii::t('Api.index', 'Failed to retrieve data from Packagist.'));
			}

			if ($curl->error)
				throw new CHttpException(500, Yii::t('Api.index', 'Failed to retrieve data from Packagist.'));

			$curl->close();

			$maintainers 	= array();
			$versions 		= array();
			$latestVersion 	= 0;
			$latestVersionLiteral;

			// Retrieve the version history
			foreach ($response->versions as $version => $details)
			{
				// Ignore dev-master
				if ($version == 'dev-master')
					continue;

				// Push the version
				$versionId = preg_replace("/[^0-9]/", "", $version);

				$versions[$versionId] = $version;
				if ($versionId > $latestVersion)
				{
					$latestVersion = $versionId;
					$latestVersionLiteral = $version;
				}
			}

			// Retreive the maintainers for the latest version
			foreach($response->versions->{$latestVersionLiteral}->authors as $maintainer)
			{
				$maintainers[] = array(
					'name' 		=> $maintainer->name,
					'email' 	=> $maintainer->email,
					'homepage' 	=> $maintainer->homepage 
				);
			}

			$data = array(
				'name' 				=> $response->name,
				'description' 		=> $response->description,
				'repository' 		=> $response->repository,
				'maintainers' 		=> $maintainers,
				'latest-version' 	=> $versions[$latestVersion],
				'sha' 				=> $response->versions->{$latestVersionLiteral}->source->reference,
				'file' 				=> $response->repository . '/archive/' . $versions[$latestVersion] . '.zip',
				'downloads' 		=> (array)$response->downloads
	        );

			Yii::app()->cache->set('CiiMS::API::Themes::' . $name, $data, 900);
		}

		return $data;		
	}
public function actionDetails ( $ name = false ) { if ( $ name == false ) throw new CHttpException ( 400 , Yii :: t ( 'Api.Theme' , 'Missing theme name' ) ) ; // Fetch the data from Packagist $ data = Yii :: app ( ) -> cache -> get ( 'CiiMS::API::Themes::' . $ name ) ; if ( $ data === false ) { $ url = 'https://packagist.org/packages/ciims-themes/' . $ name . '.json' ; $ curl = new \ Curl \ Curl ; try { $ response = $ curl -> get ( $ url ) -> package ; } catch ( Exception $ e ) { throw new CHttpException ( 500 , Yii :: t ( 'Api.index' , 'Failed to retrieve data from Packagist.' ) ) ; } if ( $ curl -> error ) throw new CHttpException ( 500 , Yii :: t ( 'Api.index' , 'Failed to retrieve data from Packagist.' ) ) ; $ curl -> close ( ) ; $ maintainers = array ( ) ; $ versions = array ( ) ; $ latestVersion = 0 ; $ latestVersionLiteral ; // Retrieve the version history foreach ( $ response -> versions as $ version => $ details ) { // Ignore dev-master if ( $ version == 'dev-master' ) continue ; // Push the version $ versionId = preg_replace ( "/[^0-9]/" , "" , $ version ) ; $ versions [ $ versionId ] = $ version ; if ( $ versionId > $ latestVersion ) { $ latestVersion = $ versionId ; $ latestVersionLiteral = $ version ; } } // Retreive the maintainers for the latest version foreach ( $ response -> versions -> { $ latestVersionLiteral } -> authors as $ maintainer ) { $ maintainers [ ] = array ( 'name' => $ maintainer -> name , 'email' => $ maintainer -> email , 'homepage' => $ maintainer -> homepage ) ; } $ data = array ( 'name' => $ response -> name , 'description' => $ response -> description , 'repository' => $ response -> repository , 'maintainers' => $ maintainers , 'latest-version' => $ versions [ $ latestVersion ] , 'sha' => $ response -> versions -> { $ latestVersionLiteral } -> source -> reference , 'file' => $ response -> repository . '/archive/' . $ versions [ $ latestVersion ] . '.zip' , 'downloads' => ( array ) $ response -> downloads ) ; Yii :: app ( ) -> cache -> set ( 'CiiMS::API::Themes::' . $ name , $ data , 900 ) ; } return $ data ; }
Retrieves the details about a particular theme
@param string $name
@return array
Retrieves the details about a particular theme