1<?php
2/**
3* Class for creating an RSS-feed
4* @author Michael Wimmer <flaimo@gmail.com>
5* @category flaimo-php
6* @copyright Copyright � 2002-2008, Michael Wimmer
7* @license GNU General Public License v3
8* @link http://code.google.com/p/flaimo-php/
9* @package RSS
10* @version 2.2.1
11*/
12abstract class RSSBase {
13
14	protected $allowed_datatypes = array('string', 'int', 'boolean',
15								   'object', 'float', 'array'
16								  );
17
18	function __construct() {
19	} // end constructor
20
21	protected function setVar($data = FALSE, $var_name = '', $type = 'string') {
22		if (!in_array($type, $this->allowed_datatypes) ||
23			$type != 'boolean' && ($data === FALSE ||
24			$this->isFilledString($var_name) === FALSE)) {
25			return (boolean) FALSE;
26		} // end if
27
28		switch ($type) {
29			case 'string':
30				if ($this->isFilledString($data) === TRUE) {
31					$this->$var_name = (string) trim($data);
32					return (boolean) TRUE;
33				} // end if
34			case 'int':
35				if (is_numeric($data)) {
36					$this->$var_name = (int) $data;
37					return (boolean) TRUE;
38				} // end if
39			case 'boolean':
40				if (is_bool($data)) {
41					$this->$var_name = (boolean) $data;
42					return (boolean) TRUE;
43				}  // end if
44			case 'object':
45				if (is_object($data)) {
46					$this->$var_name =& $data;
47					return (boolean) TRUE;
48				} // end if
49			case 'array':
50				if (is_array($data)) {
51					$this->$var_name = (array) $data;
52					return (boolean) TRUE;
53				} // end if
54		} // end switch
55		return (boolean) FALSE;
56	} // end function
57
58	protected function getVar($var_name = 'dummy') {
59		return (isset($this->$var_name)) ? $this->$var_name: FALSE;
60	} // end function
61
62	public static function isFilledString($string = '', $min_length = 0) {
63		if ($min_length == 0) {
64			return (boolean) (!ctype_space($string)) ? TRUE : FALSE;
65		} // end if
66
67		return (boolean) (strlen(trim($var)) > $min_length) ? TRUE : FALSE;
68	} // end function
69
70} // end class
71?>
72