- <?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: 233 $ $Date: 2006-05-30 17:14:13 +0200 (Di, 30 Mai 2006) $
- * @package Lithron.LMediaManager
- * @subpackage Core
- */
-
- /**
- * builts predefined criterias for LContent
- *
- * @package Lithron.LMediaManager
- * @subpackage Core
- */
- class LMediaCriteria
- {
- private $_parameters;
-
- function __construct()
- {
- $this->_parameters = new TMap;
- Prado::using("LMediaManagerCore");
- }
- function setActive($value)
- {
- $this->_parameters['Active']= $value;
- }
- function getActive()
- {
- if ($this->_parameters['Active'] !== false)
- $this->_parameters['Active'] = true;
- return $this->_parameters['Active'];
- }
- function setMissing($value)
- {
- $this->_parameters['Missing']= $value;
- }
- function getMissing()
- {
- return $this->_parameters['Missing'];
- }
- function setSearchString($value)
- {
- $this->_parameters['SearchString']= $value;
- }
- function getSearchString()
- {
- return $this->_parameters['SearchString'];
- }
- function setRecordIds($value)
- {
- $this->_parameters['RecordIds']= $value;
- }
- function getRecordIds()
- {
- return $this->_parameters['RecordIds'];
- }
-
- function build()
- {
- $c= new Criteria;
-
- $c->addDescendingOrderByColumn(LMediaManagerFilesPeer :: DIRECTORY);
- $c->addDescendingOrderByColumn(LMediaManagerFilesPeer :: FILE_NAME);
-
- if ($param= $this->getSearchString())
- {
- $array= Lithron :: createArrayFromString($param);
- foreach ($array AS $string)
- {
- #echo $string;
-
- $c1= $c->getNewCriterion(LMediaManagerFilesPeer :: DESCRIPTION, "%{$string}%", Criteria :: LIKE);
- $c2= $c->getNewCriterion(LMediaManagerFilesPeer :: DIRECTORY, "%{$string}%", Criteria :: LIKE);
- $c3= $c->getNewCriterion(LMediaManagerFilesPeer :: FILE_NAME, "%{$string}%", Criteria :: LIKE);
- $c4= $c->getNewCriterion(LMediaManagerFilesPeer :: TYPE, "%{$string}%", Criteria :: LIKE);
- $c1->addOr($c4);
- $c1->addOr($c3);
- $c1->addOr($c2);
- $c->add($c1);
- }
- $c->add(LMediaManagerFilesPeer :: STATUS, 1);
- }
-
- #if ($param= $this->getType())
- #{
- #$c->addAscendingOrderByColumn(LContentPeer :: HEADLINE);
- #$c->add(LContentPeer :: TYPE, $param);
- #}
-
- if ($param= $this->getMissing())
- {
- $c->add(LMediaManagerFilesPeer :: STATUS, 0);
- }
-
- if ($param= $this->getActive())
- {
- $c->add(LMediaManagerFilesPeer :: STATUS, 1);
- }
-
- if ($param= $this->getRecordIds())
- {
- $criterion= $c->getNewCriterion(LMediaManagerFilesPeer :: ID, null, Criteria :: EQUAL);
- foreach ($param AS $id)
- {
- $_c= $c->getNewCriterion(LMediaManagerFilesPeer :: ID, $id);
- $criterion->addOr($_c);
- }
- $c->add($criterion);
- }
-
- return $c;
-
- // ----------------------------------------------------------------------
- $c= new Criteria;
- $c->addDescendingOrderByColumn(LMediaManagerFilesPeer :: DIRECTORY);
- $c->addDescendingOrderByColumn(LMediaManagerFilesPeer :: FILE_NAME);
-
- switch ($set)
- {
- case 'search' :
-
- break;
-
- case 'all' :
- default :
- break;
- }
- Prado :: trace("Media files criteria built", "Lithron.LMediaManager");
- $result= LMediaManagerFilesPeer :: doSelect($c, $this->Application->getModule("database")->getConnection("l_content", "propel"));
-
- if (isset ($cache))
- {
- $resultSets[$setId]= $result;
- $cache->set("LMediaManager:sets", $resultSets);
- }
- if ($result === false)
- return array ();
- return $result;
-
- Prado :: trace("Media files queried from database", "Lithron.LMediaManager");
- }
- }
- ?>