Lithron.LContent
[ class tree: Lithron.LContent ] [ index: Lithron.LContent ] [ all elements ]

Source for file LContentCore.php

Documentation is available at LContentCore.php

  1. <?php
  2.  
  3.  
  4. /**
  5. * LContentCore class file.
  6. *
  7. * @license http://opensource.org/licenses/mozilla1.1.php Mozilla Public License
  8. * @copyright 2005, diemeisterei GmbH. All rights reserved.
  9. * @author $Author: schmunk $
  10. * @version $Revision: 270 $ $Date: 2006-06-12 23:41:45 +0200 (Mo, 12 Jun 2006) $
  11. * @package Lithron.LContent
  12. * @subpackage Core
  13. */
  14. /**
  15. * Mainly provides database access for LContent database
  16. *
  17. * @package Lithron.LContent
  18. * @subpackage Core
  19. */
  20. Prado :: setPathOfAlias("LContent", dirname(__FILE__));
  21. Prado :: using("LContent.db.propel.*");
  22. Prado :: using("LContent.db.propel.l_content.*");
  23. class LContentCore extends TControl
  24. {
  25. const STATUS_OFF = 1;
  26. const STATUS_STAGING = 2;
  27. const STATUS_PUBLISHED = 3;
  28.  
  29. /**
  30. * returns records from database
  31. */
  32. public function queryRecords($c= null)
  33. {
  34. if (is_numeric($c))
  35. {
  36. Prado :: trace("Querying database by id($c)", "Lithron.LContent");
  37. return LContentPeer :: retrieveByPK($c, $this->Application->getModule("database")->getConnection("l_content", "propel"));
  38. }
  39. if ($c == null)
  40. $c= new Criteria;
  41. Prado :: trace("Querying database by criteria", "Lithron.LContent");
  42. $result= LContentPeer :: doSelect($c, $this->Application->getModule("database")->getConnection("l_content", "propel"));
  43. return $result;
  44. }
  45.  
  46. /**
  47. * deletes record in database
  48. */
  49. public function deleteRecordById($id)
  50. {
  51. $c= new Criteria();
  52. $c->add(LMetaDataPeer :: OWNER_ID, "lcontent"); // TODO ? solution , from config or single md per pkg?
  53. $c->add(LMetaDataPeer :: OWNER_RECORD_ID, $id);
  54. LMetaDataPeer :: doDelete($c);
  55.  
  56. $record= $this->queryRecords($id);
  57. $record->delete();
  58. $this->redirectToList();
  59. }
  60.  
  61. /**
  62. * saves record in database and performs redirect
  63. */
  64. public function saveRecord($record)
  65. {
  66. $record->save($this->Application->getModule("database")->getConnection("l_content", "propel"));
  67. Prado :: trace("LContent record saved", "Lithron.LContent");
  68. self :: redirectToList();
  69. }
  70.  
  71. /**
  72. * redirects to user to admin or content
  73. */
  74. public function redirectToList()
  75. {
  76. if (is_object($this->Page))
  77. {
  78. $backUrl= $this->Page->getViewState("BackUrl");
  79. if ($backUrl !== null)
  80. {
  81. $url= $backUrl;
  82. $this->Page->setViewState("BackUrl", null);
  83. }
  84. else
  85. $url= "packages.LContent.AdminList";
  86. }
  87. else
  88. $url= "packages.LContent.AdminList";
  89. Prado :: trace("Redirecting to {$url} ...", "Lithron.LContentCore");
  90. Lithron :: saveLogging($this->Application);
  91. $url= $this->Request->constructUrl("page", $url);
  92. $this->Response->redirect($url);
  93. }
  94.  
  95. /**
  96. * returns brick configuration
  97. */
  98. public function getConfiguration($option)
  99. {
  100. $val= $this->Application->getParameters()->itemAt($option);
  101. $bricks= split(",", $val);
  102. if (is_array($bricks))
  103. foreach ($bricks as $brick)
  104. {
  105. $ds[$brick]= $brick;
  106. try
  107. {
  108. if (@ include ($brick . ".php"))
  109. {
  110. $dummy= Prado :: createComponent($brick); // TODO
  111. if (method_exists($dummy, "getDescriptiveName"))
  112. $ds[$brick]= $dummy->getDescriptiveName();
  113. }
  114. }
  115. catch (Exception $e)
  116. {
  117. }
  118. Prado :: trace("Configuration option: {$brick}", "Lithron.LContent");
  119. #if (empty($brick)) continue;
  120. #$dummy = new $brick;
  121. #$ds[$brick] = $dummy->getDescriptiveName();
  122. }
  123. return $ds;
  124. }
  125. }
  126. ?>

Documentation generated on Tue, 20 Jun 2006 05:15:03 +0200 by phpDocumentor 1.3.0RC4