- <?php
-
-
- /**
- * Class file.
- *
- * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
- * @copyright 2005, diemeisterei GmbH. All rights reserved.
- * @author $Author: schmunk $
- * @version $Revision: 249 $ $Date: 2006-06-05 21:32:47 +0200 (Mo, 05 Jun 2006) $
- * @package Lithron.LMetaData
- * @subpackage Modules
- */
-
- /**
- * Core functionality for LMetaData
- *
- * @package Lithron.LMetaData
- * @subpackage Modules
- */
-
- Prado :: setPathOfAlias("LMetaData", dirname(__FILE__));
- Prado :: using("LMetaData.db.propel.*");
- Prado :: using("LMetaData.db.propel.l_meta_data.*");
- class LMetaDataCore extends TModule
- {
- public $_configuration;
-
- /**
- * @return array parsed configuration
- */
- public function getConfiguration()
- {
- return $this->_configuration;
- }
-
- /**
- * parses configuration
- */
- public function init($config)
- {
- $xmlObjs= $config->getElements();
- foreach ($xmlObjs as $obj)
- {
- $_attr= $obj->getAttributes();
- $pkg= $obj->getTagName();
- $id= $_attr->itemAt("id");
- $class= $_attr->itemAt("class");
- $type= ($opt= $_attr->itemAt("type")) ? $opt : "Selection";
- $this->_configuration[$pkg . ":" . $type][]= array (
- "id" => $id,
- "class" => $class
- );
- }
- #var_dump($this->Config);
- }
-
- /**
- * updates the metadata-database for a specified record
- */
- function updateMetaData($ownerRecordId, $metaData)
- {
- $conn= $this->Application->getModule("database")->getConnection("l_meta_data", "propel");
-
- $c= new Criteria();
- $c->add(LMetaDataPeer :: OWNER_ID, $metaData->getMetaId());
- $c->add(LMetaDataPeer :: OWNER_RECORD_ID, $ownerRecordId);
- LMetaDataPeer :: doDelete($c, $conn);
- $_do= $metaData->getDataObject();
- foreach ($_do[LMetaDataBase::DATA_KEY] AS $metaId => $classMetaData)
- {
-
- if (is_array($classMetaData))
- foreach ($classMetaData AS $metaRecord)
- {
- #var_dump($metaRecord);
- $record= new LMetaData;
- $record->setOwnerId($metaData->getMetaId());
- $record->setOwnerRecordId($ownerRecordId);
- $record->setMetaId($metaId);
- $record->setMetaRecordId($metaRecord['MetaRecordId']);
- if (isset($metaRecord['Description'])) $record->setDescription($metaRecord['Description']);
- if (isset($metaRecord['Rank'])) $record->setRank($metaRecord['Rank']);
- $record->save($conn);
- }
- }
- }
-
- /**
- * retuns data from database
- */
- function getMetaData($ownerId, $ownerRecordId)
- {
- $conn= $this->Application->getModule("database")->getConnection("l_meta_data", "propel");
- $c= new Criteria();
- $c->add(LMetaDataPeer :: OWNER_ID, $ownerId);
- $c->add(LMetaDataPeer :: OWNER_RECORD_ID, $ownerRecordId);
- $c->addAscendingOrderByColumn(LMetaDataPeer :: RANK);
- $records= LMetaDataPeer :: doSelect($c, $conn);
- #var_dump($records);
- $return[0]['ApiRevision']= "2";
- foreach ($records AS $record)
- {
- $r['MetaId'] = $record->getMetaId();
- $r['MetaRecordId'] = $record->getMetaRecordId();
- $r['Description'] = $record->getDescription();
- $r['Rank'] = $record->getRank();
- $return[0][LMetaDataBase::DATA_KEY][$record->getMetaId()][]= $r;
- }
- Prado :: log("Queried meta data for $ownerId($ownerRecordId)", 1, "Lithron.LMetaData");
- return $return;
- }
-
- }
-
- /**
- * Interface for LMetaData controls
- *
- * @package Lithron.LMetaData
- * @subpackage Interfaces
- */
- interface IMetaData
- {
- /**
- * Returns selected items
- * @return array
- */
- public function getSelection();
- /**
- * Sets selected items
- * @param array
- */
- public function setSelection($array = null);
- }
- ?>