[ Index ] |
|
Code source de PHP PEAR 1.4.5 |
[Code source] [Imprimer] [Statistiques]
(pas de description)
Poids: | 776 lignes (27 kb) |
Inclus ou requis: | 2 fois |
Référencé: | 3 fois |
Nécessite: | 1 fichier Config.php |
Config_Container:: (31 méthodes):
Config_Container()
createItem()
addItem()
createComment()
createBlank()
createDirective()
createSection()
getItem()
searchPath()
directiveContent()
countChildren()
removeItem()
getItemIndex()
getItemPosition()
getParent()
getChild()
setName()
getName()
setContent()
getContent()
setType()
getType()
setAttributes()
updateAttributes()
getAttributes()
getAttribute()
setDirective()
isRoot()
toString()
toArray()
writeDatasrc()
Classe: Config_Container - X-Ref
Interface for Config containersConfig_Container($type = 'section', $name = '', $content = '', $attributes = null) X-Ref |
Constructor param: string $type Type of container object param: string $name Name of container object param: string $content Content of container object param: array $attributes Array of attributes for container object |
createItem($type, $name, $content, $attributes = null, $where = 'bottom', $target = null) X-Ref |
Create a child for this item. param: string $type type of item: directive, section, comment, blank... param: mixed $item item name param: string $content item content param: array $attributes item attributes param: string $where choose a position 'bottom', 'top', 'after', 'before' param: object $target needed if you choose 'before' or 'after' for where return: object reference to new item or Pear_Error |
addItem(&$item, $where = 'bottom', $target = null) X-Ref |
Adds an item to this item. param: object $item a container object param: string $where choose a position 'bottom', 'top', 'after', 'before' param: object $target needed if you choose 'before' or 'after' in $where return: mixed reference to added container on success, Pear_Error on error |
createComment($content = '', $where = 'bottom', $target = null) X-Ref |
Adds a comment to this item. This is a helper method that calls createItem param: string $content Object content param: string $where Position : 'top', 'bottom', 'before', 'after' param: object $target Needed when $where is 'before' or 'after' return: object reference to new item or Pear_Error |
createBlank($where = 'bottom', $target = null) X-Ref |
Adds a blank line to this item. This is a helper method that calls createItem return: object reference to new item or Pear_Error |
createDirective($name, $content, $attributes = null, $where = 'bottom', $target = null) X-Ref |
Adds a directive to this item. This is a helper method that calls createItem param: string $name Name of new directive param: string $content Content of new directive param: mixed $attributes Directive attributes param: string $where Position : 'top', 'bottom', 'before', 'after' param: object $target Needed when $where is 'before' or 'after' return: object reference to new item or Pear_Error |
createSection($name, $attributes = null, $where = 'bottom', $target = null) X-Ref |
Adds a section to this item. This is a helper method that calls createItem If the section already exists, it won't create a new one. It will return reference to existing item. param: string $name Name of new section param: array $attributes Section attributes param: string $where Position : 'top', 'bottom', 'before', 'after' param: object $target Needed when $where is 'before' or 'after' return: object reference to new item or Pear_Error |
getItem($type = null, $name = null, $content = null, $attributes = null, $index = -1) X-Ref |
Tries to find the specified item(s) and returns the objects. Examples: $directives =& $obj->getItem('directive'); $directive_bar_4 =& $obj->getItem('directive', 'bar', null, 4); $section_foo =& $obj->getItem('section', 'foo'); This method can only be called on an object of type 'section'. Note that root is a section. This method is not recursive and tries to keep the current structure. For a deeper search, use searchPath() param: string $type Type of item: directive, section, comment, blank... param: mixed $name Item name param: mixed $content Find item with this content param: array $attributes Find item with attribute set to the given value param: int $index Index of the item in the returned object list. If it is not set, will try to return the last item with this name. return: mixed reference to item found or false when not found |
searchPath($args) X-Ref |
Finds a node using XPATH like format. The search format is an array: array(item1, item2, item3, ...) Each item can be defined as the following: item = 'string' : will match the container named 'string' item = array('string', array('name' => 'xyz')) will match the container name 'string' whose attribute name is equal to "xyz" For example : <string name="xyz"> param: mixed Search path and attributes return: mixed Config_Container object, array of Config_Container objects or false on failure. |
directiveContent($args, $index = -1) X-Ref |
Return a child directive's content. This method can use two different search approach, depending on the parameter it is given. If the parameter is an array, it will use the {@link Config_Container::searchPath()} method. If it is a string, it will use the {@link Config_Container::getItem()} method. Example: <code> require_once 'Config.php'; $ini = new Config(); $conf =& $ini->parseConfig('/path/to/config.ini', 'inicommented'); // Will return the value found at : // [Database] // host=localhost echo $conf->directiveContent(array('Database', 'host'))); // Will return the value found at : // date="dec-2004" echo $conf->directiveContent('date'); </code> param: mixed Search path and attributes or a directive name param: int Index of the item in the returned directive list. return: mixed Content of directive or false if not found. |
countChildren($type = null, $name = null) X-Ref |
Returns how many children this container has param: string $type type of children counted param: string $name name of children counted return: int number of children found |
removeItem() X-Ref |
Deletes an item (section, directive, comment...) from the current object TODO: recursive remove in sub-sections return: mixed true if object was removed, false if not, or PEAR_Error if root |
getItemIndex() X-Ref |
Returns the item index in its parent children array. return: int returns int or null if root object |
getItemPosition($byType = true) X-Ref |
Returns the item rank in its parent children array according to other items with same type and name. param: bool count items differently by type return: int returns int or null if root object |
getParent() X-Ref |
Returns the item parent object. return: object returns reference to parent object or null if root object |
getChild($index = 0) X-Ref |
Returns the item parent object. return: mixed returns reference to child object or false if child does not exist |
setName($name) X-Ref |
Set this item's name. return: void |
getName() X-Ref |
Get this item's name. return: string item's name |
setContent($content) X-Ref |
Set this item's content. return: void |
getContent() X-Ref |
Get this item's content. return: string item's content |
setType($type) X-Ref |
Set this item's type. return: void |
getType() X-Ref |
Get this item's type. return: string item's type |
setAttributes($attributes) X-Ref |
Set this item's attributes. param: array $attributes Array of attributes return: void |
updateAttributes($attributes) X-Ref |
Set this item's attributes. param: array $attributes Array of attributes return: void |
getAttributes() X-Ref |
Get this item's attributes. return: array item's attributes |
getAttribute($attribute) X-Ref |
Get one attribute value of this item param: string $attribute Attribute key return: mixed item's attribute value |
setDirective($name, $content, $index = -1) X-Ref |
Set a children directive content. This is an helper method calling getItem and addItem or setContent for you. If the directive does not exist, it will be created at the bottom. param: string $name Name of the directive to look for param: mixed $content New content param: int $index Index of the directive to set, return: object newly set directive |
isRoot() X-Ref |
Is this item root, in a config container object return: bool true if item is root |
toString($configType, $options = array() X-Ref |
Call the toString methods in the container plugin param: string $configType Type of configuration used to generate the string param: array $options Specify special options used by the parser return: mixed true on success or PEAR_ERROR |
toArray($useAttr = true) X-Ref |
Returns a key/value pair array of the container and its children. Format : section[directive][index] = value If the container has attributes, it will use '@' and '#' index is here because multiple directives can have the same name. param: bool $useAttr Whether to return the attributes too return: array |
writeDatasrc($datasrc, $configType, $options = array() X-Ref |
Writes the configuration to a file param: mixed $datasrc Info on datasource such as path to the configuraton file or dsn... param: string $configType Type of configuration param: array $options Options for writer return: mixed true on success or PEAR_ERROR |
Généré le : Sun Feb 25 14:08:00 2007 | par Balluche grâce à PHPXref 0.7 |