blueshoes php application framework and cms            core_util
[ class tree: core_util ] [ index: core_util ] [ all elements ]

Class: Bs_IniHandler

Source Location: /core/util/Bs_IniHandler.class.php

Class Overview

Bs_Object
   |
   --Bs_IniHandler

This class provides methods to work with ini-style files.


Author(s):

Version:

  • 4.3.$Revision: 1.4 $ $Date: 2003/10/29 17:48:43 $

Copyright:

  • blueshoes.org

Variables

Methods


Inherited Variables

Inherited Methods

Class: Bs_Object

Bs_Object::Bs_Object()
Bs_Object::getErrors()
Basic error handling: Get *all* errors as string array from the global Bs_Error-error stack.
Bs_Object::getLastError()
Basic error handling: Get last error string from the global Bs_Error-error stack.
Bs_Object::getLastErrors()
Basic error handling: Get last errors string array from the global Bs_Error-error stack sinc last call of getLastErrors().
Bs_Object::persist()
Persists this object by serializing it and saving it to a file with unique name.
Bs_Object::setError()
Basic error handling: Push an error string on the global Bs_Error-error stack.
Bs_Object::toHtml()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::toString()
Dumps the content of this object to a string using PHP's var_dump().
Bs_Object::unpersist()
Fetches an object that was persisted with persist()

Class Details

[line 42]
This class provides methods to work with ini-style files.

E.g.

  • Comment
[Some test data] one = hallo two = "hallo" food = "Tom's Pizza = 'good stuff'" more food = Sam's Pizza's = 'best stuff' empty = "" noVal = [more test data] one = hi two = 'hi' food = 'Pizza = "good"' empty = '' noVal

no dependencies here.




Tags:

access:  public
version:  4.3.$Revision: 1.4 $ $Date: 2003/10/29 17:48:43 $
copyright:  blueshoes.org
author:  andrej arn <at blueshoes dot org>, Sam Blum <sam at blueshoes dot org>


[ Top ]


Class Variables

$commentChars = array('#', '/', ';')

[line 57]

specifies which chars at the start of a line define a comment line.

the line is left-trimmed before the comparison is made.

default: '#', '/', ';'

note: you can only specify chars, not strings. so if you want '//' as comment char, you need to define '/'. (which is done by default)




Tags:

var:  (vector)
access:  public

Type:   array


[ Top ]

$unQuote =  BS_INIHANDLER_UNQUOTE_ALL

[line 70]

should quoted values be unquoted?

  1. = no
BS_INIHANDLER_UNQUOTE_SINGLE = only single-quotes 'like this' BS_INIHANDLER_UNQUOTE_DOUBLE = only double-quotes "like this" BS_INIHANDLER_UNQUOTE_ALL = single and double quotes (default)




Tags:

access:  public

Type:   int


[ Top ]

$_fileFullPath =

[line 102]

the fullpath to the currently used file.


Type:   string


[ Top ]



Class Methods


constructor Bs_IniHandler [line 110]

Bs_IniHandler Bs_IniHandler( [string $fileFullPath = ''])

Constructor.

WARNING: please do not use the param $fileFullPath here, better call loadFile() yourself because otherwise you won't know if it worked or not.




Parameters:

string   $fileFullPath  

[ Top ]

method get [line 371]

mixed get( [string $section = NULL], [string $key = NULL])

returns [all parameters|parameter] [for the given section].

examples: get() => returns all sections with all params as 2-D hash. array of [<section>][<key>] => <string> get('section') => returns all params for the section specified as 1-D hash. array of [<key>] => <string> get('section', 'key') => returns the param specified of the section specified as string.

note: if a param is defined in the 'global scope', use an empty string for the $section name. example: get('', 'key')




Tags:

return:  (see above)
throws:  null (if the given section or key does not exist)
access:  public


Parameters:

string   $section   if not given returns all sections
string   $key   if not given returns all keys

[ Top ]

method has [line 394]

bool has( string $section, [string $key = NULL])

tells if the section or key specified is set.

examples: has('mySection') => tells if 'mySection' is set has('mySection', 'myKey' => tells if myKey in mySection is set.

note: case matters!




Tags:

access:  public


Parameters:

string   $section  
string   $key   (default is NULL)

[ Top ]

method loadFile [line 124]

bool loadFile( string $fileFullPath)

Loads the given file (read in and parse).



Tags:

return:  TRUE on sccess, FALSE on error (see getLastError())
access:  public


Parameters:

string   $fileFullPath   (a fullpath to the desired file.)

[ Top ]

method loadString [line 151]

bool loadString( string $str)

loads the ini stuff from the given string instead of a file (read in and parse).



Tags:

return:  (see getLastError())
access:  public


Parameters:

string   $str  

[ Top ]

method reset [line 345]

void reset( )

resets this object so we can re-use it for something else.

some setting vars are not reset.

resets: _sections _params _fileFullPath

keeps: commentChars unQuote




Tags:

access:  public


[ Top ]

method saveFile [line 312]

bool saveFile( [string $fileFullPath = NULL])

saves the ini settings to the file specified.



Tags:

return:  TRUE on sccess, FALSE on error (see getLastError())
see:  saveString()
access:  public


Parameters:

string   $fileFullPath   (if not specified then the current one will be used. useful for load, modify, save.)

[ Top ]

method set [line 412]

void set( string $section, string $key, string $value)

sets the given value.



Tags:

since:  bs4.3
access:  public


Parameters:

string   $section  
string   $key  
string   $value  

[ Top ]

method setQuoteHandling [line 167]

void setQuoteHandling( [int $mode = BS_INIHANDLER_UNQUOTE_ALL])

sets the quote handling.



Tags:

access:  public


Parameters:

int   $mode   (see constants)

[ Top ]

method toString [line 275]

string toString( )

toString conversion as used in saveFile(), to export the values.



Tags:

access:  public


Overrides Bs_Object::toString() (Dumps the content of this object to a string using PHP's var_dump().)

[ Top ]


Documentation generated on Mon, 29 Dec 2003 21:11:20 +0100 by phpDocumentor 1.2.3