From 64f1a73dd50943eae2f45e24b410defaa5db6dc1 Mon Sep 17 00:00:00 2001
From: Tim Steiner <tsteiner2@unl.edu>
Date: Thu, 10 May 2007 17:14:59 +0000
Subject: [PATCH] Updates for ZF-0.9.3 Compatibility DB_Table_Row_DataType
added Support for Linking Tables in DB_Table_Relation_HasMany
---
library/Nmc/Auth/Interface.php | 1 -
library/Nmc/Auth/Ldap.php | 3 -
library/Nmc/Auth/Multi.php | 3 -
library/Nmc/Auth/Mysql.php | 5 +-
library/Nmc/Db/RowManager.php | 1 -
library/Nmc/Db/SessionHandler.php | 1 -
library/Nmc/Db/Table.php | 2 -
library/Nmc/Db/Table/AclRecord.php | 1 -
library/Nmc/Db/Table/DataType/Date.php | 46 +++++++
library/Nmc/Db/Table/DataType/Interface.php | 9 ++
library/Nmc/Db/Table/Relation/Abstract.php | 2 -
library/Nmc/Db/Table/Relation/Extend.php | 2 -
library/Nmc/Db/Table/Relation/HasMany.php | 144 +++++++++++++-------
library/Nmc/Db/Table/Relation/HasOne.php | 2 -
library/Nmc/Db/Table/Row.php | 20 +++
library/Nmc/EqualToInterface.php | 4 -
library/Nmc/Image.php | 1 -
library/Nmc/Image/Abstract.php | 1 -
library/Nmc/Image/Color.php | 2 -
library/Nmc/Image/Jpeg.php | 1 -
library/Nmc/Image/Png.php | 1 -
library/Nmc/Ldap.php | 2 -
library/Nmc/Ldap/Exception.php | 2 -
library/Nmc/Math/OrderedPair.php | 1 -
library/Nmc/Model/AclGroups.php | 3 -
library/Nmc/Model/AclOthers.php | 1 -
library/Nmc/Model/AclUsers.php | 1 -
library/Nmc/Model/UserInterface.php | 2 -
library/Nmc/Semaphore.php | 2 -
library/Nmc/User.php | 1 -
library/Nmc/View.php | 6 +-
library/Nmc/View/Helper/FormSelectDay.php | 15 ++
library/Nmc/View/Helper/FormSelectMonth.php | 25 ++++
library/Nmc/View/Helper/FormSelectYear.php | 15 ++
library/Nmc/View/Oss.php | 2 -
library/Nmc/View/Unl.php | 1 -
36 files changed, 233 insertions(+), 98 deletions(-)
create mode 100644 library/Nmc/Db/Table/DataType/Date.php
create mode 100644 library/Nmc/Db/Table/DataType/Interface.php
create mode 100644 library/Nmc/View/Helper/FormSelectDay.php
create mode 100644 library/Nmc/View/Helper/FormSelectMonth.php
create mode 100644 library/Nmc/View/Helper/FormSelectYear.php
diff --git a/library/Nmc/Auth/Interface.php b/library/Nmc/Auth/Interface.php
index 1d5bcec..da5cf0f 100644
--- a/library/Nmc/Auth/Interface.php
+++ b/library/Nmc/Auth/Interface.php
@@ -1,6 +1,5 @@
<?php
-require_once('Zend.php');
Zend_Loader::loadClass('Nmc_Auth_Exception');
interface Nmc_Auth_Interface
diff --git a/library/Nmc/Auth/Ldap.php b/library/Nmc/Auth/Ldap.php
index 990280c..0a56497 100644
--- a/library/Nmc/Auth/Ldap.php
+++ b/library/Nmc/Auth/Ldap.php
@@ -1,6 +1,5 @@
<?php
-require_once 'Zend.php';
require_once 'Nmc/Auth/Interface.php';
class Nmc_Auth_Ldap implements Nmc_Auth_Interface
@@ -26,5 +25,3 @@ class Nmc_Auth_Ldap implements Nmc_Auth_Interface
return true;
}
}
-
-?>
\ No newline at end of file
diff --git a/library/Nmc/Auth/Multi.php b/library/Nmc/Auth/Multi.php
index c1171f9..513991d 100644
--- a/library/Nmc/Auth/Multi.php
+++ b/library/Nmc/Auth/Multi.php
@@ -1,6 +1,5 @@
<?php
-require_once 'Zend.php';
require_once 'Nmc/Auth/Interface.php';
class Nmc_Auth_Multi implements Nmc_Auth_Interface
@@ -55,5 +54,3 @@ class Nmc_Auth_Multi implements Nmc_Auth_Interface
return true;
}
}
-
-?>
\ No newline at end of file
diff --git a/library/Nmc/Auth/Mysql.php b/library/Nmc/Auth/Mysql.php
index 1a0b21a..3d84c31 100644
--- a/library/Nmc/Auth/Mysql.php
+++ b/library/Nmc/Auth/Mysql.php
@@ -1,6 +1,5 @@
<?php
-require_once('Zend.php');
require_once 'Nmc/Auth/Interface.php';
class Nmc_Auth_Mysql implements Nmc_Auth_Interface
@@ -15,12 +14,12 @@ class Nmc_Auth_Mysql implements Nmc_Auth_Interface
public function login( $user_name, $password )
{
$db = $this->table->getAdapter();
- $where = $db->quoteInto('user_name=?', $user_name)
+ $where = $db->quoteInto('userName=?', $user_name)
. ' AND '
. $db->quoteInto('password=?', md5($password));
$data = $this->table->fetchAll($where);
if( count( $data->toArray() ) == 0 ) {
- throw new Nmc_Auth_Exception( 'MySQL: user_name or password incorrect.');
+ throw new Nmc_Auth_Exception( 'MySQL: userName or password incorrect.');
}
return true;
diff --git a/library/Nmc/Db/RowManager.php b/library/Nmc/Db/RowManager.php
index a07d06f..e9117c5 100644
--- a/library/Nmc/Db/RowManager.php
+++ b/library/Nmc/Db/RowManager.php
@@ -11,7 +11,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
require_once 'Nmc/SingletonInterface.php';
/**
diff --git a/library/Nmc/Db/SessionHandler.php b/library/Nmc/Db/SessionHandler.php
index 46591e0..9fe1c8b 100644
--- a/library/Nmc/Db/SessionHandler.php
+++ b/library/Nmc/Db/SessionHandler.php
@@ -12,7 +12,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
/**
* Nmc_Db_SessionHandler - Use a Db Table as your session handler
diff --git a/library/Nmc/Db/Table.php b/library/Nmc/Db/Table.php
index 4821315..aaef856 100644
--- a/library/Nmc/Db/Table.php
+++ b/library/Nmc/Db/Table.php
@@ -1,7 +1,5 @@
<?php
-require_once('Zend.php');
-
require_once 'Nmc/SingletonInterface.php';
Zend_Loader::loadClass('Zend_Db_Table');
diff --git a/library/Nmc/Db/Table/AclRecord.php b/library/Nmc/Db/Table/AclRecord.php
index a868f96..834ee03 100644
--- a/library/Nmc/Db/Table/AclRecord.php
+++ b/library/Nmc/Db/Table/AclRecord.php
@@ -1,6 +1,5 @@
<?php
-require_once('Zend.php');
Zend_Loader::loadClass('Zend_Db_Table_Row');
abstract class Nmc_Db_Table_AclRow extends Zend_Db_Table_Row
diff --git a/library/Nmc/Db/Table/DataType/Date.php b/library/Nmc/Db/Table/DataType/Date.php
new file mode 100644
index 0000000..efa5338
--- /dev/null
+++ b/library/Nmc/Db/Table/DataType/Date.php
@@ -0,0 +1,46 @@
+<?php
+
+require_once 'Nmc/Db/Table/DataType/Interface.php';
+
+class Nmc_Db_Table_DataType_Date implements Nmc_Db_Table_DataType_Interface
+{
+ /**
+ * Stores the date object
+ *
+ * @var Zend_Date
+ */
+ protected $_dateObject = null;
+
+ public function setColumnData($columnData)
+ {
+ if ($columnData) {
+ $this->_dateObject = new Zend_Date($columnData);
+ }
+ }
+
+ public function setObject($object)
+ {
+ if (is_null($object)) {
+ $this->_dateObject = null;
+ return;
+ }
+ if(!$object instanceof Zend_Date) {
+ throw new Nmc_Exception('Attempt to set wrong data type');
+ }
+
+ $this->_dateObject = $object;
+ }
+
+ public function getColumnData()
+ {
+ if ($this->_dateObject) {
+ return $this->_dateObject->getTimestamp();
+ }
+ return null;
+ }
+
+ public function getObject()
+ {
+ return $this->_dateObject;
+ }
+}
\ No newline at end of file
diff --git a/library/Nmc/Db/Table/DataType/Interface.php b/library/Nmc/Db/Table/DataType/Interface.php
new file mode 100644
index 0000000..98e0c54
--- /dev/null
+++ b/library/Nmc/Db/Table/DataType/Interface.php
@@ -0,0 +1,9 @@
+<?php
+
+interface Nmc_Db_Table_DataType_Interface
+{
+ public function setColumnData($columnData);
+ public function setObject($object);
+ public function getColumnData();
+ public function getObject();
+}
diff --git a/library/Nmc/Db/Table/Relation/Abstract.php b/library/Nmc/Db/Table/Relation/Abstract.php
index 2268330..43f74cb 100644
--- a/library/Nmc/Db/Table/Relation/Abstract.php
+++ b/library/Nmc/Db/Table/Relation/Abstract.php
@@ -1,7 +1,5 @@
<?php
-require_once('Zend.php');
-
require_once 'Nmc/Db/Table/Relation/Interface.php';
/**
diff --git a/library/Nmc/Db/Table/Relation/Extend.php b/library/Nmc/Db/Table/Relation/Extend.php
index f961427..65955c5 100644
--- a/library/Nmc/Db/Table/Relation/Extend.php
+++ b/library/Nmc/Db/Table/Relation/Extend.php
@@ -12,8 +12,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
-
/**
* Nmc_Db_Table_Relation_Extend - A one to one relation where one table extends another
*
diff --git a/library/Nmc/Db/Table/Relation/HasMany.php b/library/Nmc/Db/Table/Relation/HasMany.php
index 45873ad..f8c9765 100644
--- a/library/Nmc/Db/Table/Relation/HasMany.php
+++ b/library/Nmc/Db/Table/Relation/HasMany.php
@@ -12,8 +12,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
-
/**
* Nmc_Db_Table_Relation_HasMany - A relation where one row is the parent of many others
*
@@ -45,6 +43,17 @@ class Nmc_Db_Table_Relation_HasMany extends Nmc_Db_Table_Relation_Abstract
protected $_attributeName;
+ protected $_saveChildRows = true;
+
+ /**
+ * The linking table, if one is used
+ *
+ * @var Nmc_Db_Table
+ */
+ protected $_linkingTable;
+
+ protected $_linkingForeignKeyName;
+
/**
* The set of rows belonging to this relation
*
@@ -71,11 +80,43 @@ class Nmc_Db_Table_Relation_HasMany extends Nmc_Db_Table_Relation_Abstract
$this->_attributeName = $attributeName;
}
+ /**
+ * If the rows are related via a linking table, use this function to tell
+ * the parent table how to use the linking table.
+ *
+ * @param Nmc_Db_Table $linkingTable
+ * @param unknown_type $foreignKeyName
+ */
+ public function setLinkingTable(Nmc_Db_Table $linkingTable, $foreignKeyName)
+ {
+ $this->_linkingTable = $linkingTable;
+ $this->_linkingForeignKeyName = $foreignKeyName;
+ }
+
+ public function setSaveChildRows($value = true)
+ {
+ $this->_saveChildRows = $value;
+ }
+
public function register()
{
$db = $this->_childTable->getAdapter();
- $where = $db->quoteInto($this->_foreignKeyName . ' = ?', $this->_row->getPrimaryKey());
- $this->_rowset = $this->_childTable->fetchAll($where);
+
+ if ($this->_linkingTable) {
+ $where = $db->quoteInto($this->_foreignKeyName . ' = ?', $this->_row->getPrimaryKey());
+ $linkingRowset = $this->_linkingTable->fetchAll($where);
+
+ $keys = array();
+ foreach($linkingRowset as $row) {
+ $keys[] = $row->{$this->_linkingForeignKeyName};
+ }
+
+ $this->_rowset = $this->_childTable->find($keys);
+
+ } else {
+ $where = $db->quoteInto($this->_foreignKeyName . ' = ?', $this->_row->getPrimaryKey());
+ $this->_rowset = $this->_childTable->fetchAll($where);
+ }
}
public function onPostGet($name)
@@ -102,58 +143,67 @@ class Nmc_Db_Table_Relation_HasMany extends Nmc_Db_Table_Relation_Abstract
public function onPostSave()
{
- $selectedRows = $this->_rowset;
- $where = $this->_childTable->getAdapter()->quoteInto(
- $this->_foreignKeyName . ' = ?', $this->_row->getPrimaryKey()
- );
- $currentRows = $this->_childTable->fetchAll($where);
-
- $removedRows = $currentRows->getRowsNotInCommonWith($selectedRows);
-
- foreach($removedRows as $removedRow) {
- $removedRow->delete();
- }
-
- foreach($selectedRows as $selectedRow) {
- $foreignKeyName = $this->_foreignKeyName;
- $selectedRow->$foreignKeyName = $this->_row->getPrimaryKey();
- $selectedRow->save();
- }
+ if (!$this->_saveChildRows) {
+ return;
+ }
+ $db = $this->_childTable->getAdapter();
+ if ($this->_linkingTable) {
+ $keys = array(-1);
+ foreach($this->_rowset as $row) {
+ $keys[] = $row->getPrimaryKey();
+ }
+ $where = array();
+ $where[] = $db->quoteInto($this->_foreignKeyName . ' = ?', $this->_row->getPrimaryKey());
+ $where[] = $db->quoteInto($this->_linkingForeignKeyName . ' IN(?)', $keys);
+ $where = implode(' AND ', $where);
+ $selectedRows = $this->_linkingTable->fetchAll($where);
+ $where = $db->quoteInto(
+ $this->_foreignKeyName . ' = ?', $this->_row->getPrimaryKey()
+ );
+ $currentRows = $this->_linkingTable->fetchAll($where);
+ $removedRows = $currentRows->getRowsNotInCommonWith($selectedRows);
+ foreach ($removedRows as $removedRow) {
+ $removedRow->delete();
+ }
+ foreach ($this->_rowset as $row) {
+ $row->save();
+
+ $where = array();
+ $where[] = $db->quoteInto($this->_foreignKeyName . ' = ?', $this->_row->getPrimaryKey());
+ $where[] = $db->quoteInto($this->_linkingForeignKeyName . ' = ?', $row->getPrimaryKey());
+ $where = implode(' AND ', $where);
+ $linkingRow = $this->_linkingTable->fetchAll($where);
+ if ($linkingRow->count() == 0) {
+ $linkingRow = $this->_linkingTable->fetchNew();
+ $linkingRow->{$this->_foreignKeyName} = $this->_row->getPrimaryKey();
+ $linkingRow->{$this->_linkingForeignKeyName} = $row->getPrimaryKey();
+ $linkingRow->save();
+ }
+ }
+ } else {
+ $selectedRows = $this->_rowset;
+ $where = $db->quoteInto(
+ $this->_foreignKeyName . ' = ?', $this->_row->getPrimaryKey()
+ );
+ $currentRows = $this->_childTable->fetchAll($where);
- /*
- $newRows = array();
- foreach($this->_rowset as $row) {
- $row->{$this->_foreignKeyName} = $this->_row->getPrimaryKey();
- $newRows[] = $row;
- }
+ $removedRows = $currentRows->getRowsNotInCommonWith($selectedRows);
- $where = $this->_childTable->getAdapter()->quoteInto($this->_foreignKeyName . ' = ?', $this->_row->getPrimaryKey());
- $currentRows = $this->_childTable->fetchAll($where);
-
- foreach($currentRows as $currentRow) {
- $keepRow = false;
- foreach($newRows as $key => $newRow) {
- if($currentRow->equalTo($newRow)) {
- $keepRow = true;
- if($currentRow !== $newRow) {
- unset($newRows[$key]);
- }
- }
- }
- if(!$keepRow) {
- $currentRow->delete();
+ foreach($removedRows as $removedRow) {
+ $removedRow->delete();
}
- }
- foreach($newRows as $newRow) {
- $newRow->save();
- }
- */
+ foreach($selectedRows as $selectedRow) {
+ $foreignKeyName = $this->_foreignKeyName;
+ $selectedRow->$foreignKeyName = $this->_row->getPrimaryKey();
+ $selectedRow->save();
+ }
+ }
}
public function onPostClone(Nmc_Db_Table_Row $newParentRow)
diff --git a/library/Nmc/Db/Table/Relation/HasOne.php b/library/Nmc/Db/Table/Relation/HasOne.php
index 8fd2145..bf2110c 100644
--- a/library/Nmc/Db/Table/Relation/HasOne.php
+++ b/library/Nmc/Db/Table/Relation/HasOne.php
@@ -12,8 +12,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
-
/**
* Nmc_Db_Table_Relation_HasOne - A relation where one row is the parent of a single other row
*
diff --git a/library/Nmc/Db/Table/Row.php b/library/Nmc/Db/Table/Row.php
index 86422a8..66b5575 100644
--- a/library/Nmc/Db/Table/Row.php
+++ b/library/Nmc/Db/Table/Row.php
@@ -37,6 +37,8 @@ class Nmc_Db_Table_Row extends Zend_Db_Table_Row
protected $_relations = array();
+ protected $_dataTypes = array();
+
protected $_uuid;
public function __construct($config = array())
@@ -181,6 +183,9 @@ class Nmc_Db_Table_Row extends Zend_Db_Table_Row
protected function _get($name)
{
+ if (array_key_exists($name, $this->_dataTypes)) {
+ return $this->_dataTypes[$name]->getObject();
+ }
return parent::__get($name);
}
@@ -219,6 +224,9 @@ class Nmc_Db_Table_Row extends Zend_Db_Table_Row
protected function _set($name, $value)
{
+ if (array_key_exists($name, $this->_dataTypes)) {
+ return $this->_dataTypes[$name]->setObject($value);
+ }
return parent::__set($name, $value);
}
@@ -275,6 +283,9 @@ class Nmc_Db_Table_Row extends Zend_Db_Table_Row
protected function _save()
{
+ foreach ($this->_dataTypes as $columnName => $columnType) {
+ $this->_data[$columnName] = $columnType->getColumnData();
+ }
parent::save();
}
@@ -289,6 +300,15 @@ class Nmc_Db_Table_Row extends Zend_Db_Table_Row
$this->_relations[] = $relation;
}
+ protected function _registerColumnDataType($columnName, Nmc_Db_Table_DataType_Interface $dataType)
+ {
+ if(!array_key_exists($columnName, $this->_data)) {
+ throw new Nmc_Exception('Column does not exist');
+ }
+ $this->_dataTypes[$columnName] = $dataType;
+ $dataType->setColumnData($this->_data[$columnName]);
+ }
+
/**
* Duplicates record in database and sets current record to
* the duplicated record.
diff --git a/library/Nmc/EqualToInterface.php b/library/Nmc/EqualToInterface.php
index f802ed5..b1d19a0 100644
--- a/library/Nmc/EqualToInterface.php
+++ b/library/Nmc/EqualToInterface.php
@@ -11,8 +11,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
-
/**
* Objects implementing the equalTo interface supply the equalTo() function
* This function is used to do custom equality comparisons.
@@ -29,5 +27,3 @@ interface Nmc_EqualToInterface {
public function equalTo($object);
}
-
-?>
\ No newline at end of file
diff --git a/library/Nmc/Image.php b/library/Nmc/Image.php
index c2d1346..4aba73c 100644
--- a/library/Nmc/Image.php
+++ b/library/Nmc/Image.php
@@ -1,6 +1,5 @@
<?php
-require_once('Zend.php');
Zend_Loader::loadClass('Zend_Filter');
Zend_Loader::loadClass('Nmc_Math_OrderedPair');
Zend_Loader::loadClass('Nmc_Image_Exception');
diff --git a/library/Nmc/Image/Abstract.php b/library/Nmc/Image/Abstract.php
index 5caab74..a35d5d7 100644
--- a/library/Nmc/Image/Abstract.php
+++ b/library/Nmc/Image/Abstract.php
@@ -1,6 +1,5 @@
<?php
-require_once('Zend.php');
Zend_Loader::loadClass('Zend_Filter');
Zend_Loader::loadClass('Nmc_Math_OrderedPair');
Zend_Loader::loadClass('Nmc_Image_Exception');
diff --git a/library/Nmc/Image/Color.php b/library/Nmc/Image/Color.php
index 31da8e1..9812ab4 100644
--- a/library/Nmc/Image/Color.php
+++ b/library/Nmc/Image/Color.php
@@ -11,8 +11,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
-
/**
* Color Class
*
diff --git a/library/Nmc/Image/Jpeg.php b/library/Nmc/Image/Jpeg.php
index 2773b9a..8c9212f 100644
--- a/library/Nmc/Image/Jpeg.php
+++ b/library/Nmc/Image/Jpeg.php
@@ -12,7 +12,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
Zend_Loader::loadClass('Nmc_Image');
/**
diff --git a/library/Nmc/Image/Png.php b/library/Nmc/Image/Png.php
index e548d63..cb1e963 100644
--- a/library/Nmc/Image/Png.php
+++ b/library/Nmc/Image/Png.php
@@ -12,7 +12,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
Zend_Loader::loadClass('Nmc_Image');
/**
diff --git a/library/Nmc/Ldap.php b/library/Nmc/Ldap.php
index b616eee..37f1481 100644
--- a/library/Nmc/Ldap.php
+++ b/library/Nmc/Ldap.php
@@ -11,8 +11,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
-
/**
* LDAP Class
*
diff --git a/library/Nmc/Ldap/Exception.php b/library/Nmc/Ldap/Exception.php
index 1e0ea62..23ef904 100644
--- a/library/Nmc/Ldap/Exception.php
+++ b/library/Nmc/Ldap/Exception.php
@@ -11,8 +11,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
-
/**
* NMC LDAP Exception
*
diff --git a/library/Nmc/Math/OrderedPair.php b/library/Nmc/Math/OrderedPair.php
index 6d1454b..4270f03 100644
--- a/library/Nmc/Math/OrderedPair.php
+++ b/library/Nmc/Math/OrderedPair.php
@@ -11,7 +11,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
Zend_Loader::loadClass('Zend_Filter');
Zend_Loader::loadClass('Nmc_Math_Exception');
diff --git a/library/Nmc/Model/AclGroups.php b/library/Nmc/Model/AclGroups.php
index 85c5f73..eef0fc1 100644
--- a/library/Nmc/Model/AclGroups.php
+++ b/library/Nmc/Model/AclGroups.php
@@ -1,11 +1,8 @@
<?php
-require_once('Zend.php');
Zend_Loader::loadClass('Zend_Db_Table');
class Nmc_Model_AclGroups extends Zend_Db_Table
{
}
-
-?>
\ No newline at end of file
diff --git a/library/Nmc/Model/AclOthers.php b/library/Nmc/Model/AclOthers.php
index 8bb7666..3af268d 100644
--- a/library/Nmc/Model/AclOthers.php
+++ b/library/Nmc/Model/AclOthers.php
@@ -1,6 +1,5 @@
<?php
-require_once('Zend.php');
Zend_Loader::loadClass('Zend_Db_Table');
class Nmc_Model_AclOthers extends Zend_Db_Table
diff --git a/library/Nmc/Model/AclUsers.php b/library/Nmc/Model/AclUsers.php
index 4dd64f5..fdfaadc 100644
--- a/library/Nmc/Model/AclUsers.php
+++ b/library/Nmc/Model/AclUsers.php
@@ -1,6 +1,5 @@
<?php
-require_once('Zend.php');
Zend_Loader::loadClass('Zend_Db_Table');
class Nmc_Model_AclUsers extends Zend_Db_Table
diff --git a/library/Nmc/Model/UserInterface.php b/library/Nmc/Model/UserInterface.php
index 5be4120..2a1761b 100644
--- a/library/Nmc/Model/UserInterface.php
+++ b/library/Nmc/Model/UserInterface.php
@@ -11,8 +11,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
-
interface Nmc_Model_UserInterface
{
public function getId();
diff --git a/library/Nmc/Semaphore.php b/library/Nmc/Semaphore.php
index bcb6270..0f90a23 100644
--- a/library/Nmc/Semaphore.php
+++ b/library/Nmc/Semaphore.php
@@ -11,8 +11,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
-
/**
* Nmc_Semaphore
*
diff --git a/library/Nmc/User.php b/library/Nmc/User.php
index a84a0bc..e981fda 100644
--- a/library/Nmc/User.php
+++ b/library/Nmc/User.php
@@ -11,7 +11,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
require_once 'Nmc/Model/UserInterface.php';
/**
diff --git a/library/Nmc/View.php b/library/Nmc/View.php
index 493767c..b90daf1 100644
--- a/library/Nmc/View.php
+++ b/library/Nmc/View.php
@@ -11,8 +11,6 @@
* @since File available since Release 0.0.1
*/
-require_once('Zend.php');
-
/**
* NMC_View
*
@@ -39,6 +37,10 @@ class Nmc_View extends Zend_View {
function __construct($config = array())
{
parent::__construct($config);
+ $this->addHelperPath(FRAMEWORK_PATH . DIRECTORY_SEPARATOR . 'library'
+ . DIRECTORY_SEPARATOR . 'Nmc'
+ . DIRECTORY_SEPARATOR . 'View'
+ . DIRECTORY_SEPARATOR . 'Helper', 'Nmc_View_Helper_');
$this->addScriptPath(APPLICATION_PATH . DIRECTORY_SEPARATOR . 'views');
$this->css_files = array();
$this->css_files[] = '/css/index.css';
diff --git a/library/Nmc/View/Helper/FormSelectDay.php b/library/Nmc/View/Helper/FormSelectDay.php
new file mode 100644
index 0000000..fa55c5f
--- /dev/null
+++ b/library/Nmc/View/Helper/FormSelectDay.php
@@ -0,0 +1,15 @@
+<?php
+
+class Nmc_View_Helper_FormSelectDay extends Zend_View_Helper_FormSelect
+{
+ public function formSelectDay($name, $value = null, $attribs = null, $listsep = "<br />\n")
+ {
+ $options = array();
+ $options[-1] = '--Day--';
+ for ($i = 1; $i <= 31; $i++) {
+ $options[$i] = $i;
+ }
+
+ return parent::formSelect($name, $value, $attribs, $options, $listsep);
+ }
+}
diff --git a/library/Nmc/View/Helper/FormSelectMonth.php b/library/Nmc/View/Helper/FormSelectMonth.php
new file mode 100644
index 0000000..ee7765c
--- /dev/null
+++ b/library/Nmc/View/Helper/FormSelectMonth.php
@@ -0,0 +1,25 @@
+<?php
+
+class Nmc_View_Helper_FormSelectMonth extends Zend_View_Helper_FormSelect
+{
+ public function formSelectMonth($name, $value = null, $attribs = null, $listsep = "<br />\n")
+ {
+ $options = array(
+ -1 => '--Month--',
+ 1 => 'January',
+ 2 => 'February',
+ 3 => 'March',
+ 4 => 'April',
+ 5 => 'May',
+ 6 => 'June',
+ 7 => 'July',
+ 8 => 'August',
+ 9 => 'September',
+ 10 => 'October',
+ 11 => 'November',
+ 12 => 'December'
+ );
+
+ return parent::formSelect($name, $value, $attribs, $options, $listsep);
+ }
+}
diff --git a/library/Nmc/View/Helper/FormSelectYear.php b/library/Nmc/View/Helper/FormSelectYear.php
new file mode 100644
index 0000000..ccbb495
--- /dev/null
+++ b/library/Nmc/View/Helper/FormSelectYear.php
@@ -0,0 +1,15 @@
+<?php
+
+class Nmc_View_Helper_FormSelectYear extends Zend_View_Helper_FormSelect
+{
+ public function formSelectYear($name, $value = null, $attribs = null, $listsep = "<br />\n")
+ {
+ $options = array();
+ $options[-1] = '--Year--';
+ for ($i = 2006; $i <= date('Y'); $i++) {
+ $options[$i] = $i;
+ }
+
+ return parent::formSelect($name, $value, $attribs, $options, $listsep);
+ }
+}
diff --git a/library/Nmc/View/Oss.php b/library/Nmc/View/Oss.php
index b9c561f..0c7082a 100644
--- a/library/Nmc/View/Oss.php
+++ b/library/Nmc/View/Oss.php
@@ -1,7 +1,5 @@
<?php
-require_once('Zend.php');
-
class Nmc_View_Oss
{
diff --git a/library/Nmc/View/Unl.php b/library/Nmc/View/Unl.php
index 8e3bd7c..0d75377 100644
--- a/library/Nmc/View/Unl.php
+++ b/library/Nmc/View/Unl.php
@@ -1,6 +1,5 @@
<?php
-require_once('Zend.php');
Zend_Loader::loadClass('Zend_View');
class Nmc_View_Unl extends Zend_View
--
GitLab