- <?php
-
-
- /**
- * LContentCore 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: 270 $ $Date: 2006-06-12 23:41:45 +0200 (Mo, 12 Jun 2006) $
- * @package Lithron.LContent
- * @subpackage Core
- */
- /**
- * Mainly provides database access for LContent database
- *
- * @package Lithron.LContent
- * @subpackage Core
- */
- Prado :: setPathOfAlias("LContent", dirname(__FILE__));
- Prado :: using("LContent.db.propel.*");
- Prado :: using("LContent.db.propel.l_content.*");
- class LContentCore extends TControl
- {
- const STATUS_OFF = 1;
- const STATUS_STAGING = 2;
- const STATUS_PUBLISHED = 3;
-
- /**
- * returns records from database
- */
- public function queryRecords($c= null)
- {
- if (is_numeric($c))
- {
- Prado :: trace("Querying database by id($c)", "Lithron.LContent");
- return LContentPeer :: retrieveByPK($c, $this->Application->getModule("database")->getConnection("l_content", "propel"));
- }
- if ($c == null)
- $c= new Criteria;
- Prado :: trace("Querying database by criteria", "Lithron.LContent");
- $result= LContentPeer :: doSelect($c, $this->Application->getModule("database")->getConnection("l_content", "propel"));
- return $result;
- }
-
- /**
- * deletes record in database
- */
- public function deleteRecordById($id)
- {
- $c= new Criteria();
- $c->add(LMetaDataPeer :: OWNER_ID, "lcontent"); // TODO ? solution , from config or single md per pkg?
- $c->add(LMetaDataPeer :: OWNER_RECORD_ID, $id);
- LMetaDataPeer :: doDelete($c);
-
- $record= $this->queryRecords($id);
- $record->delete();
- $this->redirectToList();
- }
-
- /**
- * saves record in database and performs redirect
- */
- public function saveRecord($record)
- {
- $record->save($this->Application->getModule("database")->getConnection("l_content", "propel"));
- Prado :: trace("LContent record saved", "Lithron.LContent");
- self :: redirectToList();
- }
-
- /**
- * redirects to user to admin or content
- */
- public function redirectToList()
- {
- if (is_object($this->Page))
- {
- $backUrl= $this->Page->getViewState("BackUrl");
- if ($backUrl !== null)
- {
- $url= $backUrl;
- $this->Page->setViewState("BackUrl", null);
- }
- else
- $url= "packages.LContent.AdminList";
- }
- else
- $url= "packages.LContent.AdminList";
- Prado :: trace("Redirecting to {$url} ...", "Lithron.LContentCore");
- Lithron :: saveLogging($this->Application);
- $url= $this->Request->constructUrl("page", $url);
- $this->Response->redirect($url);
- }
-
- /**
- * returns brick configuration
- */
- public function getConfiguration($option)
- {
- $val= $this->Application->getParameters()->itemAt($option);
- $bricks= split(",", $val);
- if (is_array($bricks))
- foreach ($bricks as $brick)
- {
- $ds[$brick]= $brick;
- try
- {
- if (@ include ($brick . ".php"))
- {
- $dummy= Prado :: createComponent($brick); // TODO
- if (method_exists($dummy, "getDescriptiveName"))
- $ds[$brick]= $dummy->getDescriptiveName();
- }
- }
- catch (Exception $e)
- {
- }
- Prado :: trace("Configuration option: {$brick}", "Lithron.LContent");
- #if (empty($brick)) continue;
- #$dummy = new $brick;
- #$ds[$brick] = $dummy->getDescriptiveName();
- }
- return $ds;
- }
- }
- ?>