aboutsummaryrefslogblamecommitdiff
path: root/h-source/Application/Include/hardware.php
blob: 89ea519141fb7b97d03e4862d5a5a4be6da40b4b (plain) (tree)
1
2
3
4
5
6
7
8


                                                                                                         


                                                                   


                                                                       
                                                              



                                                                    
                                                                    





                                                      
                                                                                                                                                                                      
 
                               




                                             






                                                                          
                                                                
                                                                                  








                                                      
                                                  
                                                    
























































                                                                                         
                                                                                                                                                      

 
                              
 
 






                                                                                              
                                                                    
 





                                                                       
                           
 
 



















                                                                         

                                             


                                                                   
 
                                
 
 
                                           
                                                                                                
                                                                                           
                                                                                                                



                                                                                     
                                                                   
          
                                                                             
        




















                                                                            
                                                                         
                                                                         
                                                                      





                                                                            
                                                                       










                                                                           
                                                           




























                                                                                                        












                                                                                     








                                                                     



                                                                      








                                                                       
 
                              
 
 
                                         
 


                                 
 


                                                                                              


                              



                                                                                     


                                

                                         
                                                                                                         
 
 
<?php

// h-source, a web software to build a community of people that want to share their hardware information.
// Copyright (C) 2010  Antonio Gallo (h-source-copyright.txt)
//
// This file is part of h-source
//
// h-source is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// 
// h-source is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with h-source.  If not, see <http://www.gnu.org/licenses/>.

if (!defined('EG')) die('Direct access not allowed!');


class Hardware
{
	
	public static $controllers = array('notebooks','wifi','videocards','printers','scanners','threegcards','soundcards','webcams','bluetooth'); //used by UsersController::login()

	//classId => controller
	public static $deviceClasses = array(
		'0403'	=>	'soundcards',
		'0280'	=>	'wifi',
		'0300'	=>	'videocards',
	);

	public static $icons = array(
		'notebook'	=>	'H2O/computer-laptop_22.png',
		'wifi'		=>	'H2O/network-wireless_22.png',
		'videocard'	=>	'Crystal/1282042976_hardware.png',
		'printer'	=>	'H2O/printer_22.png',
		'scanner'	=>	'H2O/scanner_22.png',
		'3G-card'	=>	'Crystal/usb_22.png',
		'soundcard'	=>	'H2O/audio-card_22.png',
		'webcam'	=>	'H2O/camera-web_22.png',
		'bluetooth'	=>	'H2O/preferences-system-bluetooth-22.png',
	);

	public static $typeToController = array(
		'notebook'	=>	'notebooks',
		'wifi'		=>	'wifi',
		'videocard'	=>	'videocards',
		'printer'	=>	'printers',
		'scanner'	=>	'scanners',
		'3G-card'	=>	'threegcards',
		'soundcard'	=>	'soundcards',
		'webcam'	=>	'webcams',
		'bluetooth'	=>	'bluetooth',
	);

	public static function getControllerFromType($type)
	{
		if (array_key_exists($type,self::$typeToController))
		{
			return self::$typeToController[$type];
		}
		return null;
	}

	//get the type from the controller
	public static function getTypeFromController($controller)
	{
		$temp = array_flip(self::$typeToController);
		if (array_key_exists($controller,$temp))
		{
			return $temp[$controller];
		}
		return null;
	}

	public static function getTypeFromClass($class)
	{
		if (array_key_exists($class,self::$deviceClasses))
		{
			return self::getTypeFromController(self::$deviceClasses[$class]);
		}
		return null;
	}

	public static function getIconFromType($type)
	{
		if (array_key_exists($type,self::$icons))
		{
			return "http://".DOMAIN_NAME."/Public/Img/".self::$icons[$type];
		}
		return null;
	}

	public static function getIconFromController($controller)
	{
		if ($type = self::getTypeFromController($controller))
		{
			return self::getIconFromType($type);
		}
		return null;
	}

	public static function getIconFromClass($class)
	{
		if (array_key_exists($class,self::$deviceClasses))
		{
			return self::getIconFromController(self::$deviceClasses[$class]);
		}
		return null;
	}

	public static $commYear = 'not-specified,2011,2010,2009,2008,2007,2006,2005,2004,2003,2002,2001,2000,1999,1998,1997,1996,1995,1994,1993,1992';

}

class Printer extends Hardware
{

	public static $compatibility = array(
		"A Full" 				=>	"A-Full",
		"B Partial"				=>	"B-Partial",
		"C None"				=>	"C-None",
	);
	
	public static $interface = "not-specified,USB,Serial,Parallel,Firewire,SCSI,Ethernet";
	
	public static $subtype = "not-specified,laser,inkjet,other";

	public static function compatibilityList()
	{
		return implode(',',array_values(self::$compatibility));
	}
	
}

class Wifi extends Hardware
{

	public static $interface = array(
		"not-specified"	 	=>	"not-specified",
		"USB"				=>	"USB",
		"PCI"				=>	"PCI",
		"PCI-E"				=>	"PCI-E",
		"mini-PCI"			=>	"mini-PCI",
		"mini-PCI-E"		=>	"mini-PCI-E",
		"ExpressCard"		=>	"ExpressCard",
		"PCMCIA/PC-Card"	=>	"PC-Card",
	);
	
	public static $interfaceReverse = array(
		"not-specified"	 	=>	"not-specified",
		"USB"				=>	"USB",
		"PCI"				=>	"PCI",
		"PCI-E"				=>	"PCI-E",
		"mini-PCI"			=>	"mini-PCI",
		"mini-PCI-E"		=>	"mini-PCI-E",
		"ExpressCard"		=>	"ExpressCard",
		"PC-Card"			=>	"PCMCIA/PC-Card",
	);
	
	public static $wifiSelect = 'yes,no';
	
	public static function interfaceList()
	{
		return implode(',',array_values(self::$interface));
	}
}

class Videocard extends Hardware
{

	public static $videoSelect = array(
		"works with 3D acceleration" 				=>	"works_with_3D",
		"works, but without 3D acceleration"		=>	"works_without_3D",
		"it does not work"							=>	"does_not_work",
	);
	
	public static $videoReverse = array(
		"works_with_3D"		=>	"works with 3D acceleration",
		"works_without_3D"	=>	"works, but without 3D acceleration",
		"does_not_work"		=>	"it does not work",
	);
	
	public static $interface = "not-specified,PCI,AGP,PCI-E,ISA,MCA,VLB";
	
	public static function videoList()
	{
		return implode(',',array_values(self::$videoSelect));
	}
}


class Notebooks extends Hardware
{
	
	public static $vendors = array(
		"Acer"					=>	"Acer",
		"Apple"					=>	"Apple",
		"Asus"					=>	"Asus",
		"Compal Electronics"	=>	"Compal-Electronics",
		"COMPAQ"				=>	"COMPAQ",
		"Dell"					=>	"Dell",
		"emachines"				=>	"emachines",
		"FUJITSU"				=>	"FUJITSU",
		"Gateway"				=>	"Gateway",
		"Hewlett Packard" 		=>	"Hewlett-Packard",
		"IBM" 					=>	"IBM",
		"Lemote"				=>	"Lemote",
		"Lenovo"				=>	"Lenovo",
		"LG"					=>	"LG",
		"msi"					=>	"msi",
		"Philco"				=>	"Philco",
		"Philips"				=>	"Philips",
		"Panasonic"				=>	"Panasonic",
		"Sony"					=>	"Sony",
		"SAMSUNG"				=>	"SAMSUNG",
		"Thomson"				=>	"Thomson",
		"TOSHIBA"				=>	"TOSHIBA",
		"ZaReason, Inc"			=>	"ZaReason-Inc",
	);

	public static $compatibility = array(
		"A Platinum" 			=>	"A-platinum",
		"B Gold"				=>	"B-gold",
		"C Silver"				=>	"C-silver",
		"D Bronze"				=>	"D-bronze",
		"E Garbage"				=>	"E-garbage"
	);
	
	public static $subtypeSelect = 'notebook,netbook,not-specified';
	
	public static $biosSelect = 'not-specified,no,yes';
	
	public static $videoSelect = array(
		"not specified"							=>	'not-specified',
		"yes, with 3D acceleration" 			=>	"yes_with_3D",
		"yes, but without 3D acceleration"		=>	"yes_without_3D",
		"it does not work"						=>	"no",
	);

	public static $videoReverse = array(
		"yes_with_3D"		=>	"works with 3D acceleration",
		"yes_without_3D"	=>	"works but without 3D acceleration",
		"no"				=>	"it does not work",
		'not-specified'		=>	"not specified how it works",
		""					=>	""
	);
	
	public static $wifiSelect = array(
		"not specified"			=>	'not-specified',
		'yes'					=>	'yes',
		'no'					=>	'no',
		'there is no wifi card'	=>	'no-wifi-card',
	);
	
	public static $wifiReverse = array(
		"yes"			=>	"it works",
		"no"			=>	"it does not work",
		'not-specified'	=>	"not specified how it works",
		'no-wifi-card'	=>	'there is no wifi card',
		""				=>	""
	);
	
	public static $webcamSelect = array(
		'not specified'			=>	'not-specified',
		'it works'				=>	'yes',
		'it does not work'		=>	'no',
		'there is no webcam'	=>	'there-is-no-webcam',
	);
	
	public static $webcamReverse = array(
		"yes"					=>	"it works",
		"no"					=>	"it does not work",
		'not-specified'			=>	"not specified how it works",
		'there-is-no-webcam'	=>	'there is no webcam',
	);
	
	public static function videoList()
	{
		return implode(',',array_values(self::$videoSelect));
	}

	public static function wifiList()
	{
		return implode(',',array_values(self::$wifiSelect));
	}
	
	public static function webcamList()
	{
		return implode(',',array_values(self::$webcamSelect));
	}
	
	public static function vendorsList()
	{
		return implode(',',array_values(self::$vendors));
	}
	
	public static function compatibilityList()
	{
		return implode(',',array_values(self::$compatibility));
	}
	
}

class ThreeGcards extends Wifi
{

	public static $select = 'yes,no';


}

class Soundcards extends Hardware
{

	public static $audioSelect = 'yes,no';
	
	public static $interface = "not-specified,PCI,ISA,USB,Firewire,Parallel,PCI-E,PCMCIA";

}

class Webcams extends Hardware
{

	public static $select = 'yes,no';

	public static $interface = "not-specified,USB,Firewire,Parallel,Wifi,Serial";

}

class Bluetooth extends Hardware
{

	public static $select = 'yes,no';

	public static $interface = "not-specified,USB,PCI,PCI-E,mini-PCI,mini-PCI-E,ExpressCard,PC-Card";

}