Example #1
0
	/**
	 * Returns the files mimetype from extension
	 *
	 * @return string
	 */
	public function getMimeType()
	{

		$domain				=	$this->getLinkDomain();

		if ( $domain && in_array( $domain, array( 'youtube', 'youtu' ) ) ) {
			return 'video/youtube';
		}

		static $cache		=	array();

		$id					=	$this->getExtension();

		if ( ! isset( $cache[$id] ) ) {
			$cache[$id]		=	cbgalleryClass::getMimeTypes( $id );
		}

		return $cache[$id];
	}
Example #2
0
	/**
	 * Returns the fontawesome icon based off extension and that extensions mimetype
	 *
	 * @param string $extension
	 * @return string
	 */
	static public function getFileIcon( $extension )
	{
		$type							=	'file-o';

		if ( ! $extension ) {
			return $type;
		}

		static $cache					=	array();

		if ( ! isset( $cache[$extension] ) ) {
			$mimeParts					=	explode( '/', cbgalleryClass::getMimeTypes( $extension ) );

			switch ( $mimeParts[0] ) {
				case 'text':
					switch ( $extension ) {
						case 'csv':
							$type		=	'file-excel-o';
							break;
						case 'css':
						case 'html':
						case 'htm':
							$type		=	'file-code-o';
							break;
						default:
							$type		=	'file-text-o';
							break;
					}
					break;
				case 'video':
					$type				=	'file-video-o';
					break;
				case 'audio':
					$type				=	'file-audio-o';
					break;
				case 'image':
					$type				=	'file-image-o';
					break;
				default:
					switch ( $extension ) {
						case 'pdf':
							$type		=	'file-pdf-o';
							break;
						case 'zip':
						case '7z':
						case 'rar':
						case 'tar':
						case 'iso':
							$type		=	'file-archive-o';
							break;
						case 'js':
						case 'php':
						case 'xml':
						case 'java':
							$type		=	'file-code-o';
							break;
						case 'ods':
						case 'xls':
						case 'xlsx':
						case 'xlt':
							$type		=	'file-excel-o';
							break;
						case 'doc':
						case 'docx':
						case 'odt':
						case 'dot':
							$type		=	'file-word-o';
							break;
					}
					break;
			}

			$cache[$extension]			=	$type;
		}

		return $cache[$extension];
	}