summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon2011-03-04 18:33:19 +0100
committerSimon2011-03-04 18:33:19 +0100
commit2c3d9f3d53afedf153a28f1f0ac2c8c4957dcf51 (patch)
tree99e2391da8bedfcbda3122653c26144a8a439d92
parentFiltertypen in SQL hinzugefügt && notes (von notiz-zettel)n hinzugefügt (diff)
downloadpbs2-2c3d9f3d53afedf153a28f1f0ac2c8c4957dcf51.tar.gz
pbs2-2c3d9f3d53afedf153a28f1f0ac2c8c4957dcf51.tar.xz
pbs2-2c3d9f3d53afedf153a28f1f0ac2c8c4957dcf51.zip
Filters Übersicht, FilterEntries hinzufügen
-rw-r--r--.zfproject.xml1
-rw-r--r--application/controllers/FilterController.php41
-rw-r--r--application/forms/FilterEdit.php54
-rw-r--r--application/models/DbTable/FilterEntries.php2
-rw-r--r--application/models/FilterEntriesMapper.php36
-rw-r--r--application/models/FilterType.php2
-rw-r--r--application/models/FilterTypeMapper.php6
-rw-r--r--application/views/scripts/filter/editfilter.phtml16
-rw-r--r--application/views/scripts/filter/index.phtml34
9 files changed, 167 insertions, 25 deletions
diff --git a/.zfproject.xml b/.zfproject.xml
index ad4a683..b956d27 100644
--- a/.zfproject.xml
+++ b/.zfproject.xml
@@ -37,6 +37,7 @@
<formFile formName="FilterCreate"/>
<formFile formName="AuthDelete"/>
<formFile formName="FilterAdd"/>
+ <formFile formName="FilterEdit"/>
</formsDirectory>
<layoutsDirectory enabled="false"/>
<modelsDirectory>
diff --git a/application/controllers/FilterController.php b/application/controllers/FilterController.php
index 35dfd75..09f4081 100644
--- a/application/controllers/FilterController.php
+++ b/application/controllers/FilterController.php
@@ -18,7 +18,12 @@ class FilterController extends Zend_Controller_Action
{
try{
$this->_filtermapper = new Application_Model_FilterMapper();
- $this->view->filters = $this->_filtermapper->fetchAll();
+ $this->view->filters = $this->_filtermapper->fetchAll();
+
+ $filterentries = new Application_Model_FilterEntriesMapper();
+
+ $this->view->filterentries = $filterentries->fetchAll();
+
}catch (Zend_Exception $e) {
echo "Error message 2: " . $e->getMessage() . "\n";
}
@@ -26,7 +31,6 @@ class FilterController extends Zend_Controller_Action
public function addfilterAction()
{
- $db = Zend_Db_Table::getDefaultAdapter();
if (!isset($_POST["add"])){
$addfilterform = new Application_Form_FilterAdd();
$this->view->addfilterform = $addfilterform;
@@ -43,9 +47,7 @@ class FilterController extends Zend_Controller_Action
// TODO: Ändere mit ACL
$newfilter->setGroupID('1');
$newfilter->setMembershipID('1');
- $newfilter->setBootmenuID('1');
-
-
+ $newfilter->setBootmenuID('1');
$newfilter2 = new Application_Model_FilterMapper();
$newfilter2->save($newfilter);
@@ -77,7 +79,34 @@ class FilterController extends Zend_Controller_Action
public function editfilterAction()
{
-
+ // TODO: ACL implementieren ob er editieren darf
+ if (!isset($_POST["add"])){
+ echo "case1";
+ try{
+ $editfilterform = new Application_Form_FilterEdit(array('filterID' => $this->_request->getParam('filterID')));
+ $this->view->editfilterform=$editfilterform;
+
+ }catch (Zend_Exception $e) {
+ echo "Error message 2: " . $e->getMessage() . "\n";
+ }
+ } else{
+ $editfilterform = new Application_Form_FilterEdit($_POST);
+ echo "case2";
+
+ if ($editfilterform->isValid($_POST)) {
+
+ $newfilterenty = new Application_Model_FilterEntries();
+ $newfilterenty->setFilterID($_POST['filterID']);
+ $newfilterenty->setFiltertypeID($_POST['filtertype']);
+ $newfilterenty->setFiltervalue($_POST['filtervalue1']);
+ $newfilterenty->setFiltervalue2($_POST['filtervalue2']);
+
+ $newfilter2 = new Application_Model_FilterEntriesMapper();
+
+ $newfilter2->save($newfilterenty);
+ }
+ $this->_redirect('/filter');
+ }
}
diff --git a/application/forms/FilterEdit.php b/application/forms/FilterEdit.php
new file mode 100644
index 0000000..5d5a242
--- /dev/null
+++ b/application/forms/FilterEdit.php
@@ -0,0 +1,54 @@
+<?php
+
+class Application_Form_FilterEdit extends Zend_Form
+{
+ private $filterID = null;
+
+ public function init()
+ {
+ $this->setName("Add Filter");
+ $this->setMethod('post');
+
+
+ try{
+ $filtertypemapper = new Application_Model_FilterTypeMapper();
+ $filtertype = $filtertypemapper->fetchAll();
+ }catch (Zend_Exception $e) {
+ echo "Error message 1: " . $e->getMessage() . "\n";
+ }
+
+ $filtertypes = $this->createElement('select','filtertype');
+ $filtertypes ->setLabel('Type:');
+ foreach($filtertype as $f){
+ $filtertypes->addMultiOption($f->getID(),$f->getFiltertypename());
+ }
+ $this->addElement($filtertypes);
+
+
+ $this->addElement('text', 'filtervalue1', array(
+ 'label' => 'Value1:'
+ ));
+
+ $this->addElement('text', 'filtervalue2', array(
+ 'label' => 'Value2:'
+ ));
+
+ $this->addElement('hidden', 'filterID', array(
+ 'value' => $this->filterID
+ ));
+
+ $this->addElement('submit', 'add', array(
+ 'required' => false,
+ 'ignore' => true,
+ 'label' => 'Add Filtertype',
+ ));
+ }
+ public function setFilterID($id)
+ {
+ $this->filterID = $id;
+ }
+
+
+
+}
+
diff --git a/application/models/DbTable/FilterEntries.php b/application/models/DbTable/FilterEntries.php
index f0f976d..309858d 100644
--- a/application/models/DbTable/FilterEntries.php
+++ b/application/models/DbTable/FilterEntries.php
@@ -4,7 +4,7 @@ class Application_Model_DbTable_FilterEntries extends Zend_Db_Table_Abstract
{
protected $_name = 'pbs_filterentries';
-
+ protected $_primary = array('filterID','filtertypeID');
}
diff --git a/application/models/FilterEntriesMapper.php b/application/models/FilterEntriesMapper.php
index 58ea563..09bc627 100644
--- a/application/models/FilterEntriesMapper.php
+++ b/application/models/FilterEntriesMapper.php
@@ -32,13 +32,19 @@ class Application_Model_FilterEntriesMapper
public function save(Application_Model_FilterEntries $filterentries)
{
- $data = array('filterID'=> $filterentries->getFilterID() ,'filtertypeID'=> $filterentries->getFiltertypeID() ,'filtervalue'=> $filterentries->getFiltervalue() ,'filtervalue2'=> $filterentries->getFiltervalue2() );
-
- if (null === ($id = $filterentries->getID()) ) {
- unset($data['filterentriesID']);
+ $data = array('filterID'=> $filterentries->getFilterID() ,
+ 'filtertypeID'=> $filterentries->getFiltertypeID() ,
+ 'filtervalue'=> $filterentries->getFiltervalue() ,
+ 'filtervalue2'=> $filterentries->getFiltervalue2() );
+
+ if (null != ($id1 = $filterentries->getFilterID()) &&
+ null != ($id2 = $filterentries->getFiltertypeID()) &&
+ $this->getDbTable()->find($filterentries->getFilterID(),$filterentries->getFiltertypeID())) {
$this->getDbTable()->insert($data);
+ echo 'fall1';
} else {
- $this->getDbTable()->update($data, array('filterentriesID = ?' => $id));
+ $this->getDbTable()->update($data, array('filterID = ?' => $id1, 'filtertypeID = ?' => $id2));
+ echo 'fall2';
}
}
@@ -51,17 +57,29 @@ class Application_Model_FilterEntriesMapper
}
}
- public function find($id, Application_Model_FilterEntries $filterentries)
+ public function find($filterID,$filtertypeID, Application_Model_FilterEntries $filterentries)
{
- $result = $this->getDbTable()->find($id);
+ $result = $this->getDbTable()->find($filterID,$filtertypeID);
+ echo 'dump1';
if (0 == count($result)) {
return;
}
-
+ echo 'dump2';
$row = $result->current();
- $filterentries->setFilterID($row->filterID)->setFiltertypeID($row->filtertypeID)->setFiltervalue($row->filtervalue)->setFiltervalue2($row->filtervalue2);
+ $filterentries->setFilterID($row->filterID)
+ ->setFiltertypeID($row->filtertypeID)
+ ->setFiltervalue($row->filtervalue)
+ ->setFiltervalue2($row->filtervalue2);
+ return $filterentries;
}
+ public function findBy($field,$value)
+ {
+ $db = $this->getAdapter();
+ $where = $db->quoteInto($db->quoteIdentifier($field).' = ?', value);
+ return $this->fetchAll($where);
+
+ }
public function fetchAll()
{
diff --git a/application/models/FilterType.php b/application/models/FilterType.php
index 9601368..a66950a 100644
--- a/application/models/FilterType.php
+++ b/application/models/FilterType.php
@@ -50,6 +50,7 @@ class Application_Model_FilterType
public function setID($_filtertypeID)
{
$this->_filtertypeID = $_filtertypeID;
+ return $this;
}
public function getFiltertypename()
{
@@ -58,6 +59,7 @@ class Application_Model_FilterType
public function setFiltertypename($_filtertypename)
{
$this->_filtertypename = $_filtertypename;
+ return $this;
}
}
diff --git a/application/models/FilterTypeMapper.php b/application/models/FilterTypeMapper.php
index f10ee21..8ed2722 100644
--- a/application/models/FilterTypeMapper.php
+++ b/application/models/FilterTypeMapper.php
@@ -60,7 +60,8 @@ class Application_Model_FilterTypeMapper
$row = $result->current();
- $filtertype->setID($row->filtertypeID)->setFiltertypename($row->filtertypename);
+ $filtertype->setID($row->filtertypeID)
+ ->setFiltertypename($row->filtertypename);
}
public function fetchAll()
@@ -70,7 +71,8 @@ class Application_Model_FilterTypeMapper
foreach ($resultSet as $row) {
$entry = new Application_Model_FilterType();
- $entry->setID($row->filtertypeID)->setFiltertypename($row->filtertypename);
+ $entry->setID($row->filtertypeID)
+ ->setFiltertypename($row->filtertypename);
$entries[] = $entry;
}
diff --git a/application/views/scripts/filter/editfilter.phtml b/application/views/scripts/filter/editfilter.phtml
index 452a096..9b54ac7 100644
--- a/application/views/scripts/filter/editfilter.phtml
+++ b/application/views/scripts/filter/editfilter.phtml
@@ -1 +1,15 @@
-<br /><br /><center>View script for controller <b>Filter</b> and script/action name <b>editfilter</b></center> \ No newline at end of file
+<h1>Edit Filter</h1>
+<?php
+echo "<h2>".$this->filterID."</h2>";
+echo 'test';
+?>
+<?php
+echo
+
+$this->editfilterform->setAction($this->url());
+
+
+$this->editfilterform;
+
+
+?>
diff --git a/application/views/scripts/filter/index.phtml b/application/views/scripts/filter/index.phtml
index 711bad9..4e5f8af 100644
--- a/application/views/scripts/filter/index.phtml
+++ b/application/views/scripts/filter/index.phtml
@@ -1,4 +1,9 @@
<h1>Filters</h1>
+<style>
+table{font-family:verdana;font-size:12px;}
+td{border:1px solid #CCC;}
+tr.filter{background-color:#DDD;}
+</style>
<p><a href="<?php echo $this->url(
array(
'controller' => 'filter',
@@ -12,13 +17,15 @@
<!-- A table of filters. -->
<table border=1>
<tr>
- <th>filterid</th>
- <th>filterID</th>
+ <th>filterID</th>
+ <th>Title</th>
+ <th>Priority</th>
</tr>
<?php foreach ($this->filters as $filter): ?>
- <tr>
+ <tr class='filter'>
<td><?php echo $this->escape($filter->getID()) ?></td>
<td><?php echo $this->escape($filter->title) ?></td>
+ <td><?php echo $this->escape($filter->priority) ?></td>
<td><a href="<?php echo $this->url(
array(
'controller' => 'filter',
@@ -35,11 +42,26 @@
),
'default',
true) ?>">delete filter</a></td>
+ </tr>
+ <tr><td></td>
+ <td colspan=4>
+ <table style='width:100%;'>
+ <?php foreach ($this->filterentries as $filterentry): ?>
+ <?php
+ // TODO: Quick and dirty
+ // hier wird die gesamte liste durchgegangen... unperformant
+ if($filterentry->filterID == $filter->getID()): ?>
+ <tr>
+ <td><?php echo $filterentry->getFiltertypeID();?></td>
+ <td><?php echo $filterentry->getFiltervalue();?></td>
+ <td><?php echo $filterentry->getFiltervalue();?></td>
+ </tr>
+ <?php endif; ?>
+ <?php endforeach ?>
+ </table>
+ </td>
</tr>
<?php endforeach ?>
-
-
-
</table>
<?php else: ?>