Source for file REPFileItems.class.php
Documentation is available at REPFileItems.class.php
* @author Takács Ákos (Rimelek), programmer [at] rimelek [dot] hu
* @copyright Copyright (C) 2010, Takács Ákos
require_once dirname(__FILE__
).
'/../REPClasses.class.php';
* Egyszerű, szöveges fájlok tartalmát iterálhatóvá tevő osztály.
* Egy sor egy rekord. És egy rekordban a mezőket tetszőlegesen
* megadható karaktersor választja el.
* @author Takács Ákos (Rimelek), programmer [at] rimelek [dot] hu
* @copyright Copyright (C) 2010, Takács Ákos
* A fájlban levő rekordok tömbje. Két dimenziós.
* A mezőket elválasztó karaktersor
* @param mixed $file Ha string, akkor a {@link $filename fájlnevet} állítja be.
* Ha tömb, akkor rögtön az {@link $items} tulajdonságot.
* Így akár előre beolvasott tartalmat, vagy tömböt is
* @param array $indexes Lekérdezendő mezők listája Részletek az {@link init()} metódusnál.
* @param string $sep Mezőket elválasztó karaktersor.
public function __construct($file,$indexes=
array(), $sep=
'&&')
$this->init($indexes, $sep);
* Beolvassa a megfelelő fájlt, ha szükséges
* és beállítja az indexeit a mezőknek.
* @param array $indexes Két dimenziós tömb, amiben megadható,
* hogy melyik oszlopnak mi legyen az asszociatív indexe.
* Az eredeti tömbben azonos indexű elem új neve lesz az
* $indexes adott eleme. Ezzel sorrend is változtatható, ha megadjuk
* kézzel az indexeket a tömbben.
* @param string $sep Mezőket elválasztó karaktersor.
protected function init($indexes=
array(),$sep =
'&&')
foreach ($this->items as &$item)
foreach ($indexes as $key =>
$value)
if (!isset
($item[$key])) continue;
$tmp[$value] =
$item[$key];
* Létrehoz egy új azonos típusú példányt, mint az objektum, amin hívjuk a metódust.
* @param array $items Az új példány {@link $items} tulajdonsága ezt fogja tartalmazni
* @return REPFileItems A leszármaztatott osztályokból származtatott
* objektumok ezen metódusa az adott osztály típusú objektummal
$ref =
new ReflectionObject($this);
$obj =
$ref->newInstance($this->filename);
$props =
$ref->getProperties();
foreach ($props as $prop =>
$value)
if ($prop ==
'items') continue;
public function offsetExists($offset)
return isset
($this->items[$offset]);
public function offsetUnset($offset)
unset
($this->items[$offset]);
public function offsetGet($offset)
return isset
($this->items[$offset]) ?
$this->items[$offset] :
null;
public function offsetSet($offset, $value)
$this->items[$offset] =
$value;
* {@link $items} tömb mérete
public function current()
Documentation generated on Sat, 06 Mar 2010 22:00:16 +0100 by phpDocumentor 1.4.1