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

Source for file LContentBrick.php

Documentation is available at LContentBrick.php

  1. <?php
  2.  
  3.  
  4. /**
  5. * LContentBrick 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 Controls
  13. */
  14.  
  15. /**
  16. * Displays a brick with one item from LContent
  17. *
  18. * @package System.Web.UI.WebControls
  19. * @subpackage Bricks
  20. */
  21.  
  22. class LContentBrick extends LBrick
  23. {
  24. /**
  25. * content for brick (propel object)
  26. */
  27. public $ContentObject;
  28.  
  29. /**
  30. * Prepares core, adds admin snippets
  31. */
  32. public function __construct()
  33. {
  34. parent :: __construct();
  35. Prado :: using("Lithron.LContent.LContentCore");
  36. $admin = '<div>';
  37. $admin .= '<com:TListBox ID="ContentId" Width="100%" Rows="10"/>';
  38. $admin .= '<com:TRequiredFieldValidator
  39. ValidationGroup="' . $this->getUniqueValidationGroup() . '"
  40. ControlToValidate="ContentId" ErrorMessage="Select a record!" />';
  41. $admin .= '</div>';
  42. $this->addAdminSnippet($admin);
  43. }
  44.  
  45. /**
  46. * @return id for selecting records
  47. */
  48. public function getClassId()
  49. {
  50. return "LContentBrick";
  51. }
  52.  
  53. /**
  54. * @ignore
  55. */
  56. public function getDescriptiveName()
  57. {
  58. return "Content Record (basic)";
  59. }
  60.  
  61. /**
  62. * @ignore
  63. */
  64. public function getHasAdministrationPage()
  65. {
  66. return true;
  67. }
  68.  
  69. /**
  70. * @ignore
  71. */
  72. public function getAdministrationPage()
  73. {
  74. if ($this->getParameters() instanceof TMap)
  75. {
  76. $id= $this->getParameters()->itemAt("ContentId");
  77. }
  78. else
  79. $id= "";
  80. return "packages.LContent.AdminRecord&l_content_id={$id}&back_url=" . $this->Service->getServicePage();
  81. }
  82.  
  83. /**
  84. * prepares admin or content, depending on panel
  85. */
  86. public function onPreRender($param)
  87. {
  88. if ($this->getShowAdminPanel())
  89. {
  90. $this->prepareAdmin();
  91. }
  92. else
  93. {
  94. $this->prepareContent();
  95. }
  96. parent :: onPreRender($param);
  97. }
  98.  
  99. /**
  100. * gets data and performs databBind
  101. */
  102. protected function prepareAdmin()
  103. {
  104. // get content records
  105. $crit= new LContentCriteria;
  106. $crit->setType($this->getClassId());
  107. $crit->setStatus(LContentCore::STATUS_PUBLISHED);
  108. $items= LContentCore :: queryRecords($crit->build());
  109. Prado :: log("Queried " . count($items) . " record(s)", 1, "Lithron.LContent");
  110.  
  111. $ds= array ();
  112. if (is_array($items))
  113. foreach ($items as $item)
  114. {
  115. // parse the headlines
  116. $ds[$item->getId()]= $item->getHeadline();
  117. }
  118. // set the data source
  119. try
  120. {
  121. $this->AdminControls->ContentId->setDataSource($ds);
  122. $this->AdminControls->ContentId->dataBind();
  123. Prado :: log("Admin Datasource set!", 1, "Lithron.LContent");
  124. }
  125. catch (Exception $e)
  126. {
  127. Prado :: log("Error (!!!!) while databinding admin controls in brick: " . $e->getMessage(), 8, "Lithron.LContent");
  128. }
  129. }
  130.  
  131. /**
  132. * gets data and performs databBind
  133. */
  134. protected function prepareContent()
  135. {
  136. $p= $this->getParameters();
  137. if ($p !== null)
  138. {
  139. $this->ContentObject= LContentCore :: queryRecords($p->itemAt("ContentId"));
  140. }
  141. if (!is_object($this->ContentObject))
  142. $this->ContentObject= new LContent();
  143. }
  144. }
  145. ?>

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