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

Source for file LMediaCriteria.php

Documentation is available at LMediaCriteria.php

  1. <?php
  2.  
  3.  
  4. /**
  5. * 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: 233 $ $Date: 2006-05-30 17:14:13 +0200 (Di, 30 Mai 2006) $
  11. * @package Lithron.LMediaManager
  12. * @subpackage Core
  13. */
  14.  
  15. /**
  16. * builts predefined criterias for LContent
  17. *
  18. * @package Lithron.LMediaManager
  19. * @subpackage Core
  20. */
  21. class LMediaCriteria
  22. {
  23. private $_parameters;
  24.  
  25. function __construct()
  26. {
  27. $this->_parameters = new TMap;
  28. Prado::using("LMediaManagerCore");
  29. }
  30. function setActive($value)
  31. {
  32. $this->_parameters['Active']= $value;
  33. }
  34. function getActive()
  35. {
  36. if ($this->_parameters['Active'] !== false)
  37. $this->_parameters['Active'] = true;
  38. return $this->_parameters['Active'];
  39. }
  40. function setMissing($value)
  41. {
  42. $this->_parameters['Missing']= $value;
  43. }
  44. function getMissing()
  45. {
  46. return $this->_parameters['Missing'];
  47. }
  48. function setSearchString($value)
  49. {
  50. $this->_parameters['SearchString']= $value;
  51. }
  52. function getSearchString()
  53. {
  54. return $this->_parameters['SearchString'];
  55. }
  56. function setRecordIds($value)
  57. {
  58. $this->_parameters['RecordIds']= $value;
  59. }
  60. function getRecordIds()
  61. {
  62. return $this->_parameters['RecordIds'];
  63. }
  64.  
  65. function build()
  66. {
  67. $c= new Criteria;
  68.  
  69. $c->addDescendingOrderByColumn(LMediaManagerFilesPeer :: DIRECTORY);
  70. $c->addDescendingOrderByColumn(LMediaManagerFilesPeer :: FILE_NAME);
  71.  
  72. if ($param= $this->getSearchString())
  73. {
  74. $array= Lithron :: createArrayFromString($param);
  75. foreach ($array AS $string)
  76. {
  77. #echo $string;
  78.  
  79. $c1= $c->getNewCriterion(LMediaManagerFilesPeer :: DESCRIPTION, "%{$string}%", Criteria :: LIKE);
  80. $c2= $c->getNewCriterion(LMediaManagerFilesPeer :: DIRECTORY, "%{$string}%", Criteria :: LIKE);
  81. $c3= $c->getNewCriterion(LMediaManagerFilesPeer :: FILE_NAME, "%{$string}%", Criteria :: LIKE);
  82. $c4= $c->getNewCriterion(LMediaManagerFilesPeer :: TYPE, "%{$string}%", Criteria :: LIKE);
  83. $c1->addOr($c4);
  84. $c1->addOr($c3);
  85. $c1->addOr($c2);
  86. $c->add($c1);
  87. }
  88. $c->add(LMediaManagerFilesPeer :: STATUS, 1);
  89. }
  90.  
  91. #if ($param= $this->getType())
  92. #{
  93. #$c->addAscendingOrderByColumn(LContentPeer :: HEADLINE);
  94. #$c->add(LContentPeer :: TYPE, $param);
  95. #}
  96.  
  97. if ($param= $this->getMissing())
  98. {
  99. $c->add(LMediaManagerFilesPeer :: STATUS, 0);
  100. }
  101.  
  102. if ($param= $this->getActive())
  103. {
  104. $c->add(LMediaManagerFilesPeer :: STATUS, 1);
  105. }
  106.  
  107. if ($param= $this->getRecordIds())
  108. {
  109. $criterion= $c->getNewCriterion(LMediaManagerFilesPeer :: ID, null, Criteria :: EQUAL);
  110. foreach ($param AS $id)
  111. {
  112. $_c= $c->getNewCriterion(LMediaManagerFilesPeer :: ID, $id);
  113. $criterion->addOr($_c);
  114. }
  115. $c->add($criterion);
  116. }
  117.  
  118. return $c;
  119.  
  120. // ----------------------------------------------------------------------
  121. $c= new Criteria;
  122. $c->addDescendingOrderByColumn(LMediaManagerFilesPeer :: DIRECTORY);
  123. $c->addDescendingOrderByColumn(LMediaManagerFilesPeer :: FILE_NAME);
  124.  
  125. switch ($set)
  126. {
  127. case 'search' :
  128.  
  129. break;
  130.  
  131. case 'all' :
  132. default :
  133. break;
  134. }
  135. Prado :: trace("Media files criteria built", "Lithron.LMediaManager");
  136. $result= LMediaManagerFilesPeer :: doSelect($c, $this->Application->getModule("database")->getConnection("l_content", "propel"));
  137.  
  138. if (isset ($cache))
  139. {
  140. $resultSets[$setId]= $result;
  141. $cache->set("LMediaManager:sets", $resultSets);
  142. }
  143. if ($result === false)
  144. return array ();
  145. return $result;
  146.  
  147. Prado :: trace("Media files queried from database", "Lithron.LMediaManager");
  148. }
  149. }
  150. ?>

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