[eluser]tonanbarbarian[/eluser]
It is a little unclear how the globals are used in the original code you want to convert
Are they hard coded at the start of the script and then used later?
If so here is how I would do it.
CI, by default, will look to see if a config file exists for your library before loading it.
So if you create a config file for your class and then let the config array be passed to the constructor you can set all of the values any way you like.
I would also change the code to use properties of the class rather than globals
i.e. if your class is named RssReader
config/Rssreader.php (Config file name must be the same as the library file name, including the same case)
Code:
$config['xxx'] = 'something';
$config['yyy'] = 'foo';
$config['zzz'] = 2;
Then in the class
libraries/Rssreader.php
Code:
class RssReader {
var $xxx=null;
var $yyy=null;
var $zzz=null;
function RssReader($config=array()) {
if (is_array($config) && count($config)) {
$this->initialise($config);
}
} // RssReader()
function initialise($config=array()) {
if (!is_array($config)) return;
if (!count($config)) return;
foreach ($config as $property=>$value) {
if (isset($this->$property)) {
$this->$property = $value;
}
}
} // initialise()
...
} // class RssReader
This will then work exactly the same as any other CI class and makes it easy to modify the config because it is in the config folder where it is expected